Revision: 14372
Author: [email protected]
Date: Mon Apr 22 04:15:43 2013
Log: Replace CheckBuilder with IfBuilder everywhere.
This deprecates and removes the CheckBuilder which is less powerful
than the generic IfBuilder which can deopt as well by now.
[email protected]
Review URL: https://codereview.chromium.org/14075013
http://code.google.com/p/v8/source/detail?r=14372
Modified:
/branches/bleeding_edge/src/code-stubs-hydrogen.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Thu Apr 18 13:37:27
2013
+++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Mon Apr 22 04:15:43
2013
@@ -191,9 +191,10 @@
virtual HValue* BuildCodeUninitializedStub() {
// Force a deopt that falls back to the runtime.
HValue* undefined = graph()->GetConstantUndefined();
- CheckBuilder builder(this);
- builder.CheckNotUndefined(undefined);
- builder.End();
+ IfBuilder builder(this);
+ builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined,
undefined);
+ builder.Then();
+ builder.ElseDeopt();
return undefined;
}
@@ -263,6 +264,7 @@
HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
Zone* zone = this->zone();
Factory* factory = isolate()->factory();
+ HValue* undefined = graph()->GetConstantUndefined();
AllocationSiteMode alloc_site_mode =
casted_stub()->allocation_site_mode();
FastCloneShallowArrayStub::Mode mode = casted_stub()->mode();
int length = casted_stub()->length();
@@ -273,8 +275,9 @@
NULL,
FAST_ELEMENTS));
- CheckBuilder builder(this);
- builder.CheckNotUndefined(boilerplate);
+ IfBuilder checker(this);
+ checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate,
undefined);
+ checker.Then();
if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) {
HValue* elements =
@@ -313,7 +316,9 @@
length));
}
- return environment()->Pop();
+ HValue* result = environment()->Pop();
+ checker.ElseDeopt();
+ return result;
}
@@ -326,6 +331,7 @@
HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
Zone* zone = this->zone();
Factory* factory = isolate()->factory();
+ HValue* undefined = graph()->GetConstantUndefined();
HInstruction* boilerplate =
AddInstruction(new(zone) HLoadKeyed(GetParameter(0),
@@ -333,8 +339,9 @@
NULL,
FAST_ELEMENTS));
- CheckBuilder builder(this);
- builder.CheckNotUndefined(boilerplate);
+ IfBuilder checker(this);
+ checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate,
undefined);
+ checker.And();
int size = JSObject::kHeaderSize + casted_stub()->length() *
kPointerSize;
HValue* boilerplate_size =
@@ -342,7 +349,8 @@
HValue* size_in_words =
AddInstruction(new(zone) HConstant(size >> kPointerSizeLog2,
Representation::Integer32()));
- builder.CheckIntegerEq(boilerplate_size, size_in_words);
+ checker.IfCompare(boilerplate_size, size_in_words, Token::EQ);
+ checker.Then();
HValue* size_in_bytes =
AddInstruction(new(zone) HConstant(size,
Representation::Integer32()));
@@ -366,7 +374,7 @@
true, i));
}
- builder.End();
+ checker.ElseDeopt();
return object;
}
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Fri Apr 19 09:46:13 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Mon Apr 22 04:15:43 2013
@@ -640,67 +640,6 @@
DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false)
#undef DEFINE_GET_CONSTANT
-
-
-HGraphBuilder::CheckBuilder::CheckBuilder(HGraphBuilder* builder)
- : builder_(builder),
- finished_(false) {
- HEnvironment* env = builder->environment();
- failure_block_ = builder->CreateBasicBlock(env->Copy());
- merge_block_ = builder->CreateBasicBlock(env->Copy());
-}
-
-
-HValue* HGraphBuilder::CheckBuilder::CheckNotUndefined(HValue* value) {
- HEnvironment* env = builder_->environment();
- HCompareObjectEqAndBranch* compare =
- new(zone()) HCompareObjectEqAndBranch(
- value,
- builder_->graph()->GetConstantUndefined());
- HBasicBlock* success_block = builder_->CreateBasicBlock(env->Copy());
- HBasicBlock* failure_block = builder_->CreateBasicBlock(env->Copy());
- compare->SetSuccessorAt(0, failure_block);
- compare->SetSuccessorAt(1, success_block);
- failure_block->GotoNoSimulate(failure_block_);
- builder_->current_block()->Finish(compare);
- builder_->set_current_block(success_block);
- return compare;
-}
-
-
-HValue* HGraphBuilder::CheckBuilder::CheckIntegerCompare(HValue* left,
- HValue* right,
- Token::Value op) {
- HEnvironment* env = builder_->environment();
- HCompareIDAndBranch* compare =
- new(zone()) HCompareIDAndBranch(left, right, op);
- compare->AssumeRepresentation(Representation::Integer32());
- HBasicBlock* success_block = builder_->CreateBasicBlock(env->Copy());
- HBasicBlock* failure_block = builder_->CreateBasicBlock(env->Copy());
- compare->SetSuccessorAt(0, success_block);
- compare->SetSuccessorAt(1, failure_block);
- failure_block->GotoNoSimulate(failure_block_);
- builder_->current_block()->Finish(compare);
- builder_->set_current_block(success_block);
- return compare;
-}
-
-
-HValue* HGraphBuilder::CheckBuilder::CheckIntegerEq(HValue* left,
- HValue* right) {
- return CheckIntegerCompare(left, right, Token::EQ);
-}
-
-
-void HGraphBuilder::CheckBuilder::End() {
- ASSERT(!finished_);
- builder_->current_block()->GotoNoSimulate(merge_block_);
- if (failure_block_->HasPredecessor()) {
- failure_block_->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
- }
- builder_->set_current_block(merge_block_);
- finished_ = true;
-}
HConstant* HGraph::GetInvalidContext() {
@@ -1323,9 +1262,7 @@
external_elements, key, val, bounds_check,
elements_kind, is_store);
AddInstruction(result);
- negative_checker.Else();
- negative_checker.Deopt();
- negative_checker.End();
+ negative_checker.ElseDeopt();
length_checker.End();
return result;
} else {
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Fri Apr 19 09:21:09 2013
+++ /branches/bleeding_edge/src/hydrogen.h Mon Apr 22 04:15:43 2013
@@ -1013,27 +1013,6 @@
HInstruction* BuildStoreMap(HValue* object, HValue* map);
HInstruction* BuildStoreMap(HValue* object, Handle<Map> map);
- class CheckBuilder {
- public:
- explicit CheckBuilder(HGraphBuilder* builder);
- ~CheckBuilder() {
- if (!finished_) End();
- }
-
- HValue* CheckNotUndefined(HValue* value);
- HValue* CheckIntegerCompare(HValue* left, HValue* right, Token::Value
op);
- HValue* CheckIntegerEq(HValue* left, HValue* right);
- void End();
-
- private:
- Zone* zone() { return builder_->zone(); }
-
- HGraphBuilder* builder_;
- bool finished_;
- HBasicBlock* failure_block_;
- HBasicBlock* merge_block_;
- };
-
class IfBuilder {
public:
explicit IfBuilder(HGraphBuilder* builder,
@@ -1064,6 +1043,17 @@
HInstruction* If(HValue* p1, P2 p2) {
HControlInstruction* compare = new(zone()) Condition(p1, p2);
AddCompare(compare);
+ return compare;
+ }
+
+ template<class Condition, class P2>
+ HInstruction* IfNot(HValue* p1, P2 p2) {
+ HControlInstruction* compare = new(zone()) Condition(p1, p2);
+ AddCompare(compare);
+ HBasicBlock* block0 = compare->SuccessorAt(0);
+ HBasicBlock* block1 = compare->SuccessorAt(1);
+ compare->SetSuccessorAt(0, block1);
+ compare->SetSuccessorAt(1, block0);
return compare;
}
@@ -1129,6 +1119,11 @@
void End();
void Deopt();
+ void ElseDeopt() {
+ Else();
+ Deopt();
+ End();
+ }
private:
void AddCompare(HControlInstruction* compare);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.