Fix IfBuilder to use instruction factories. Add missing instruction factories.

This also makes the instruction constructors private and fixes
all uses of the public constructors to use the factory methods
instead.

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/23654051

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16808 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
bmeurer@chromium.org 2013-09-19 06:45:45 +00:00
parent bf192205ce
commit 557e9b9d5c
4 changed files with 152 additions and 113 deletions

View File

@ -1351,14 +1351,12 @@ class HUnaryControlInstruction : public HTemplateControlInstruction<2, 1> {
class HBranch V8_FINAL : public HUnaryControlInstruction { class HBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
HBranch(HValue* value, DECLARE_INSTRUCTION_FACTORY_P1(HBranch, HValue*);
ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(), DECLARE_INSTRUCTION_FACTORY_P2(HBranch, HValue*,
HBasicBlock* true_target = NULL, ToBooleanStub::Types);
HBasicBlock* false_target = NULL) DECLARE_INSTRUCTION_FACTORY_P4(HBranch, HValue*,
: HUnaryControlInstruction(value, true_target, false_target), ToBooleanStub::Types,
expected_input_types_(expected_input_types) { HBasicBlock*, HBasicBlock*);
SetFlag(kAllowUndefinedAsNaN);
}
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::None(); return Representation::None();
@ -1372,20 +1370,24 @@ class HBranch V8_FINAL : public HUnaryControlInstruction {
DECLARE_CONCRETE_INSTRUCTION(Branch) DECLARE_CONCRETE_INSTRUCTION(Branch)
private: private:
HBranch(HValue* value,
ToBooleanStub::Types expected_input_types = ToBooleanStub::Types(),
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
expected_input_types_(expected_input_types) {
SetFlag(kAllowUndefinedAsNaN);
}
ToBooleanStub::Types expected_input_types_; ToBooleanStub::Types expected_input_types_;
}; };
class HCompareMap V8_FINAL : public HUnaryControlInstruction { class HCompareMap V8_FINAL : public HUnaryControlInstruction {
public: public:
HCompareMap(HValue* value, DECLARE_INSTRUCTION_FACTORY_P2(HCompareMap, HValue*, Handle<Map>);
Handle<Map> map, DECLARE_INSTRUCTION_FACTORY_P4(HCompareMap, HValue*, Handle<Map>,
HBasicBlock* true_target = NULL, HBasicBlock*, HBasicBlock*);
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target),
map_(map) {
ASSERT(!map.is_null());
}
virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
@ -1401,6 +1403,14 @@ class HCompareMap V8_FINAL : public HUnaryControlInstruction {
virtual int RedefinedOperandIndex() { return 0; } virtual int RedefinedOperandIndex() { return 0; }
private: private:
HCompareMap(HValue* value,
Handle<Map> map,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target), map_(map) {
ASSERT(!map.is_null());
}
Handle<Map> map_; Handle<Map> map_;
}; };
@ -4033,13 +4043,11 @@ class HCompareGeneric V8_FINAL : public HBinaryOperation {
class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
public: public:
HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token) DECLARE_INSTRUCTION_FACTORY_P3(HCompareNumericAndBranch,
: token_(token) { HValue*, HValue*, Token::Value);
SetFlag(kFlexibleRepresentation); DECLARE_INSTRUCTION_FACTORY_P5(HCompareNumericAndBranch,
ASSERT(Token::IsCompareOp(token)); HValue*, HValue*, Token::Value,
SetOperandAt(0, left); HBasicBlock*, HBasicBlock*);
SetOperandAt(1, right);
}
HValue* left() { return OperandAt(0); } HValue* left() { return OperandAt(0); }
HValue* right() { return OperandAt(1); } HValue* right() { return OperandAt(1); }
@ -4065,6 +4073,20 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
private: private:
HCompareNumericAndBranch(HValue* left,
HValue* right,
Token::Value token,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: token_(token) {
SetFlag(kFlexibleRepresentation);
ASSERT(Token::IsCompareOp(token));
SetOperandAt(0, left);
SetOperandAt(1, right);
SetSuccessorAt(0, true_target);
SetSuccessorAt(1, false_target);
}
Representation observed_input_representation_[2]; Representation observed_input_representation_[2];
Token::Value token_; Token::Value token_;
}; };
@ -4072,16 +4094,6 @@ class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> {
class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction { class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
// TODO(danno): make this private when the IfBuilder properly constructs
// control flow instructions.
HCompareHoleAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {
SetFlag(kFlexibleRepresentation);
SetFlag(kAllowUndefinedAsNaN);
}
DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*); DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*);
DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*, DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*,
HBasicBlock*, HBasicBlock*); HBasicBlock*, HBasicBlock*);
@ -4094,20 +4106,23 @@ class HCompareHoleAndBranch V8_FINAL : public HUnaryControlInstruction {
} }
DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch) DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch)
private:
HCompareHoleAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {
SetFlag(kFlexibleRepresentation);
SetFlag(kAllowUndefinedAsNaN);
}
}; };
class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> { class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
public: public:
// TODO(danno): make this private when the IfBuilder properly constructs
// control flow instructions.
HCompareObjectEqAndBranch(HValue* left,
HValue* right) {
SetOperandAt(0, left);
SetOperandAt(1, right);
}
DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*); DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
DECLARE_INSTRUCTION_FACTORY_P4(HCompareObjectEqAndBranch, HValue*, HValue*,
HBasicBlock*, HBasicBlock*);
HValue* left() { return OperandAt(0); } HValue* left() { return OperandAt(0); }
HValue* right() { return OperandAt(1); } HValue* right() { return OperandAt(1); }
@ -4123,38 +4138,65 @@ class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
} }
DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch) DECLARE_CONCRETE_INSTRUCTION(CompareObjectEqAndBranch)
private:
HCompareObjectEqAndBranch(HValue* left,
HValue* right,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL) {
SetOperandAt(0, left);
SetOperandAt(1, right);
SetSuccessorAt(0, true_target);
SetSuccessorAt(1, false_target);
}
}; };
class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction { class HIsObjectAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
explicit HIsObjectAndBranch(HValue* value) DECLARE_INSTRUCTION_FACTORY_P1(HIsObjectAndBranch, HValue*);
: HUnaryControlInstruction(value, NULL, NULL) { } DECLARE_INSTRUCTION_FACTORY_P3(HIsObjectAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
} }
DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch) DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch)
private:
HIsObjectAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
}; };
class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction { class HIsStringAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
explicit HIsStringAndBranch(HValue* value) DECLARE_INSTRUCTION_FACTORY_P1(HIsStringAndBranch, HValue*);
: HUnaryControlInstruction(value, NULL, NULL) { } DECLARE_INSTRUCTION_FACTORY_P3(HIsStringAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
} }
DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch) DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch)
private:
HIsStringAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
}; };
class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction { class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
explicit HIsSmiAndBranch(HValue* value) DECLARE_INSTRUCTION_FACTORY_P1(HIsSmiAndBranch, HValue*);
: HUnaryControlInstruction(value, NULL, NULL) { } DECLARE_INSTRUCTION_FACTORY_P3(HIsSmiAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch) DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch)
@ -4164,19 +4206,32 @@ class HIsSmiAndBranch V8_FINAL : public HUnaryControlInstruction {
protected: protected:
virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; } virtual bool DataEquals(HValue* other) V8_OVERRIDE { return true; }
private:
HIsSmiAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
}; };
class HIsUndetectableAndBranch V8_FINAL : public HUnaryControlInstruction { class HIsUndetectableAndBranch V8_FINAL : public HUnaryControlInstruction {
public: public:
explicit HIsUndetectableAndBranch(HValue* value) DECLARE_INSTRUCTION_FACTORY_P1(HIsUndetectableAndBranch, HValue*);
: HUnaryControlInstruction(value, NULL, NULL) { } DECLARE_INSTRUCTION_FACTORY_P3(HIsUndetectableAndBranch, HValue*,
HBasicBlock*, HBasicBlock*);
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
return Representation::Tagged(); return Representation::Tagged();
} }
DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch) DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch)
private:
HIsUndetectableAndBranch(HValue* value,
HBasicBlock* true_target = NULL,
HBasicBlock* false_target = NULL)
: HUnaryControlInstruction(value, true_target, false_target) {}
}; };

View File

@ -63,7 +63,7 @@ HBasicBlock* HOsrBuilder::BuildPossibleOsrLoopEntry(
HBasicBlock* non_osr_entry = graph->CreateBasicBlock(); HBasicBlock* non_osr_entry = graph->CreateBasicBlock();
osr_entry_ = graph->CreateBasicBlock(); osr_entry_ = graph->CreateBasicBlock();
HValue* true_value = graph->GetConstantTrue(); HValue* true_value = graph->GetConstantTrue();
HBranch* test = new(zone) HBranch(true_value, ToBooleanStub::Types(), HBranch* test = builder_->New<HBranch>(true_value, ToBooleanStub::Types(),
non_osr_entry, osr_entry_); non_osr_entry, osr_entry_);
builder_->current_block()->Finish(test); builder_->current_block()->Finish(test);

View File

@ -815,9 +815,8 @@ void HGraphBuilder::IfBuilder::Then() {
HConstant* constant_false = builder_->graph()->GetConstantFalse(); HConstant* constant_false = builder_->graph()->GetConstantFalse();
ToBooleanStub::Types boolean_type = ToBooleanStub::Types(); ToBooleanStub::Types boolean_type = ToBooleanStub::Types();
boolean_type.Add(ToBooleanStub::BOOLEAN); boolean_type.Add(ToBooleanStub::BOOLEAN);
HBranch* branch = HBranch* branch = builder()->New<HBranch>(
new(zone()) HBranch(constant_false, boolean_type, first_true_block_, constant_false, boolean_type, first_true_block_, first_false_block_);
first_false_block_);
builder_->current_block()->Finish(branch); builder_->current_block()->Finish(branch);
} }
builder_->set_current_block(first_true_block_); builder_->set_current_block(first_true_block_);
@ -949,11 +948,8 @@ HValue* HGraphBuilder::LoopBuilder::BeginBody(
builder_->set_current_block(header_block_); builder_->set_current_block(header_block_);
env->Pop(); env->Pop();
HCompareNumericAndBranch* compare = builder_->current_block()->Finish(builder_->New<HCompareNumericAndBranch>(
new(zone()) HCompareNumericAndBranch(phi_, terminating, token); phi_, terminating, token, body_block_, exit_block_));
compare->SetSuccessorAt(0, body_block_);
compare->SetSuccessorAt(1, exit_block_);
builder_->current_block()->Finish(compare);
builder_->set_current_block(body_block_); builder_->set_current_block(body_block_);
if (direction_ == kPreIncrement || direction_ == kPreDecrement) { if (direction_ == kPreIncrement || direction_ == kPreDecrement) {
@ -2772,8 +2768,8 @@ void TestContext::BuildBranch(HValue* value) {
HBasicBlock* empty_true = builder->graph()->CreateBasicBlock(); HBasicBlock* empty_true = builder->graph()->CreateBasicBlock();
HBasicBlock* empty_false = builder->graph()->CreateBasicBlock(); HBasicBlock* empty_false = builder->graph()->CreateBasicBlock();
ToBooleanStub::Types expected(condition()->to_boolean_types()); ToBooleanStub::Types expected(condition()->to_boolean_types());
HBranch* test = new(zone()) HBranch(value, expected, empty_true, empty_false); builder->current_block()->Finish(builder->New<HBranch>(
builder->current_block()->Finish(test); value, expected, empty_true, empty_false));
empty_true->Goto(if_true(), builder->function_state()); empty_true->Goto(if_true(), builder->function_state());
empty_false->Goto(if_false(), builder->function_state()); empty_false->Goto(if_false(), builder->function_state());
@ -3374,12 +3370,10 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
// Test switch's tag value if all clauses are string literals // Test switch's tag value if all clauses are string literals
if (stmt->switch_type() == SwitchStatement::STRING_SWITCH) { if (stmt->switch_type() == SwitchStatement::STRING_SWITCH) {
string_check = new(zone()) HIsStringAndBranch(tag_value);
first_test_block = graph()->CreateBasicBlock(); first_test_block = graph()->CreateBasicBlock();
not_string_block = graph()->CreateBasicBlock(); not_string_block = graph()->CreateBasicBlock();
string_check = New<HIsStringAndBranch>(
string_check->SetSuccessorAt(0, first_test_block); tag_value, first_test_block, not_string_block);
string_check->SetSuccessorAt(1, not_string_block);
current_block()->Finish(string_check); current_block()->Finish(string_check);
set_current_block(first_test_block); set_current_block(first_test_block);
@ -3409,7 +3403,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
} }
HCompareNumericAndBranch* compare_ = HCompareNumericAndBranch* compare_ =
new(zone()) HCompareNumericAndBranch(tag_value, New<HCompareNumericAndBranch>(tag_value,
label_value, label_value,
Token::EQ_STRICT); Token::EQ_STRICT);
compare_->set_observed_input_representation( compare_->set_observed_input_representation(
@ -3695,7 +3689,7 @@ void HOptimizedGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
// Check that we still have more keys. // Check that we still have more keys.
HCompareNumericAndBranch* compare_index = HCompareNumericAndBranch* compare_index =
new(zone()) HCompareNumericAndBranch(index, limit, Token::LT); New<HCompareNumericAndBranch>(index, limit, Token::LT);
compare_index->set_observed_input_representation( compare_index->set_observed_input_representation(
Representation::Smi(), Representation::Smi()); Representation::Smi(), Representation::Smi());
@ -4710,7 +4704,7 @@ void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(
++count; ++count;
HBasicBlock* if_true = graph()->CreateBasicBlock(); HBasicBlock* if_true = graph()->CreateBasicBlock();
HBasicBlock* if_false = graph()->CreateBasicBlock(); HBasicBlock* if_false = graph()->CreateBasicBlock();
HCompareMap* compare = new(zone()) HCompareMap( HCompareMap* compare = New<HCompareMap>(
object, info.map(), if_true, if_false); object, info.map(), if_true, if_false);
current_block()->Finish(compare); current_block()->Finish(compare);
@ -4849,8 +4843,7 @@ void HOptimizedGraphBuilder::HandlePolymorphicStoreNamedField(
++count; ++count;
HBasicBlock* if_true = graph()->CreateBasicBlock(); HBasicBlock* if_true = graph()->CreateBasicBlock();
HBasicBlock* if_false = graph()->CreateBasicBlock(); HBasicBlock* if_false = graph()->CreateBasicBlock();
HCompareMap* compare = HCompareMap* compare = New<HCompareMap>(object, map, if_true, if_false);
new(zone()) HCompareMap(object, map, if_true, if_false);
current_block()->Finish(compare); current_block()->Finish(compare);
set_current_block(if_true); set_current_block(if_true);
@ -5572,7 +5565,7 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess(
HBasicBlock* this_map = graph()->CreateBasicBlock(); HBasicBlock* this_map = graph()->CreateBasicBlock();
HBasicBlock* other_map = graph()->CreateBasicBlock(); HBasicBlock* other_map = graph()->CreateBasicBlock();
HCompareMap* mapcompare = HCompareMap* mapcompare =
new(zone()) HCompareMap(object, map, this_map, other_map); New<HCompareMap>(object, map, this_map, other_map);
current_block()->Finish(mapcompare); current_block()->Finish(mapcompare);
set_current_block(this_map); set_current_block(this_map);
@ -6040,10 +6033,8 @@ void HOptimizedGraphBuilder::HandlePolymorphicCallNamed(
HBasicBlock* empty_smi_block = graph()->CreateBasicBlock(); HBasicBlock* empty_smi_block = graph()->CreateBasicBlock();
HBasicBlock* not_smi_block = graph()->CreateBasicBlock(); HBasicBlock* not_smi_block = graph()->CreateBasicBlock();
number_block = graph()->CreateBasicBlock(); number_block = graph()->CreateBasicBlock();
HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(receiver); current_block()->Finish(New<HIsSmiAndBranch>(
smicheck->SetSuccessorAt(0, empty_smi_block); receiver, empty_smi_block, not_smi_block));
smicheck->SetSuccessorAt(1, not_smi_block);
current_block()->Finish(smicheck);
empty_smi_block->Goto(number_block); empty_smi_block->Goto(number_block);
set_current_block(not_smi_block); set_current_block(not_smi_block);
} else { } else {
@ -6055,20 +6046,17 @@ void HOptimizedGraphBuilder::HandlePolymorphicCallNamed(
HUnaryControlInstruction* compare; HUnaryControlInstruction* compare;
if (handle_smi && map.is_identical_to(number_marker_map)) { if (handle_smi && map.is_identical_to(number_marker_map)) {
compare = new(zone()) HCompareMap( compare = New<HCompareMap>(receiver, heap_number_map, if_true, if_false);
receiver, heap_number_map, if_true, if_false);
map = initial_number_map; map = initial_number_map;
expr->set_number_check( expr->set_number_check(
Handle<JSObject>(JSObject::cast(map->prototype()))); Handle<JSObject>(JSObject::cast(map->prototype())));
} else if (map.is_identical_to(string_marker_map)) { } else if (map.is_identical_to(string_marker_map)) {
compare = new(zone()) HIsStringAndBranch(receiver); compare = New<HIsStringAndBranch>(receiver, if_true, if_false);
compare->SetSuccessorAt(0, if_true);
compare->SetSuccessorAt(1, if_false);
map = initial_string_map; map = initial_string_map;
expr->set_string_check( expr->set_string_check(
Handle<JSObject>(JSObject::cast(map->prototype()))); Handle<JSObject>(JSObject::cast(map->prototype())));
} else { } else {
compare = new(zone()) HCompareMap(receiver, map, if_true, if_false); compare = New<HCompareMap>(receiver, map, if_true, if_false);
expr->set_map_check(); expr->set_map_check();
} }
@ -7812,8 +7800,8 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) {
HBasicBlock* eval_right = graph()->CreateBasicBlock(); HBasicBlock* eval_right = graph()->CreateBasicBlock();
ToBooleanStub::Types expected(expr->left()->to_boolean_types()); ToBooleanStub::Types expected(expr->left()->to_boolean_types());
HBranch* test = is_logical_and HBranch* test = is_logical_and
? new(zone()) HBranch(left_value, expected, eval_right, empty_block) ? New<HBranch>(left_value, expected, eval_right, empty_block)
: new(zone()) HBranch(left_value, expected, empty_block, eval_right); : New<HBranch>(left_value, expected, empty_block, eval_right);
current_block()->Finish(test); current_block()->Finish(test);
set_current_block(eval_right); set_current_block(eval_right);
@ -8036,7 +8024,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
BuildCheckHeapObject(right); BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone())); AddInstruction(HCheckInstanceType::NewIsSpecObject(right, zone()));
HCompareObjectEqAndBranch* result = HCompareObjectEqAndBranch* result =
new(zone()) HCompareObjectEqAndBranch(left, right); New<HCompareObjectEqAndBranch>(left, right);
result->set_position(expr->position()); result->set_position(expr->position());
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} }
@ -8051,7 +8039,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
BuildCheckHeapObject(right); BuildCheckHeapObject(right);
AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone())); AddInstruction(HCheckInstanceType::NewIsInternalizedString(right, zone()));
HCompareObjectEqAndBranch* result = HCompareObjectEqAndBranch* result =
new(zone()) HCompareObjectEqAndBranch(left, right); New<HCompareObjectEqAndBranch>(left, right);
result->set_position(expr->position()); result->set_position(expr->position());
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
} else { } else {
@ -8064,7 +8052,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnInstruction(result, expr->id()); return ast_context()->ReturnInstruction(result, expr->id());
} else { } else {
HCompareNumericAndBranch* result = HCompareNumericAndBranch* result =
new(zone()) HCompareNumericAndBranch(left, right, op); New<HCompareNumericAndBranch>(left, right, op);
result->set_observed_input_representation(left_rep, right_rep); result->set_observed_input_representation(left_rep, right_rep);
result->set_position(expr->position()); result->set_position(expr->position());
return ast_context()->ReturnControl(result, expr->id()); return ast_context()->ReturnControl(result, expr->id());
@ -8506,7 +8494,7 @@ void HOptimizedGraphBuilder::GenerateIsSmi(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1); ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop(); HValue* value = Pop();
HIsSmiAndBranch* result = new(zone()) HIsSmiAndBranch(value); HIsSmiAndBranch* result = New<HIsSmiAndBranch>(value);
return ast_context()->ReturnControl(result, call->id()); return ast_context()->ReturnControl(result, call->id());
} }
@ -8567,7 +8555,7 @@ void HOptimizedGraphBuilder::GenerateIsObject(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1); ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop(); HValue* value = Pop();
HIsObjectAndBranch* result = new(zone()) HIsObjectAndBranch(value); HIsObjectAndBranch* result = New<HIsObjectAndBranch>(value);
return ast_context()->ReturnControl(result, call->id()); return ast_context()->ReturnControl(result, call->id());
} }
@ -8581,8 +8569,7 @@ void HOptimizedGraphBuilder::GenerateIsUndetectableObject(CallRuntime* call) {
ASSERT(call->arguments()->length() == 1); ASSERT(call->arguments()->length() == 1);
CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* value = Pop(); HValue* value = Pop();
HIsUndetectableAndBranch* result = HIsUndetectableAndBranch* result = New<HIsUndetectableAndBranch>(value);
new(zone()) HIsUndetectableAndBranch(value);
return ast_context()->ReturnControl(result, call->id()); return ast_context()->ReturnControl(result, call->id());
} }
@ -8704,13 +8691,10 @@ void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) {
HValue* value = Pop(); HValue* value = Pop();
HValue* object = Pop(); HValue* object = Pop();
// Check if object is a not a smi. // Check if object is a not a smi.
HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(object);
HBasicBlock* if_smi = graph()->CreateBasicBlock(); HBasicBlock* if_smi = graph()->CreateBasicBlock();
HBasicBlock* if_heap_object = graph()->CreateBasicBlock(); HBasicBlock* if_heap_object = graph()->CreateBasicBlock();
HBasicBlock* join = graph()->CreateBasicBlock(); HBasicBlock* join = graph()->CreateBasicBlock();
smicheck->SetSuccessorAt(0, if_smi); current_block()->Finish(New<HIsSmiAndBranch>(object, if_smi, if_heap_object));
smicheck->SetSuccessorAt(1, if_heap_object);
current_block()->Finish(smicheck);
if_smi->Goto(join); if_smi->Goto(join);
// Check if object is a JSValue. // Check if object is a JSValue.

View File

@ -1285,29 +1285,29 @@ class HGraphBuilder {
} }
template<class Condition> template<class Condition>
HInstruction* If(HValue *p) { Condition* If(HValue *p) {
HControlInstruction* compare = new(zone()) Condition(p); Condition* compare = builder()->New<Condition>(p);
AddCompare(compare); AddCompare(compare);
return compare; return compare;
} }
template<class Condition, class P2> template<class Condition, class P2>
HInstruction* If(HValue* p1, P2 p2) { Condition* If(HValue* p1, P2 p2) {
HControlInstruction* compare = new(zone()) Condition(p1, p2); Condition* compare = builder()->New<Condition>(p1, p2);
AddCompare(compare); AddCompare(compare);
return compare; return compare;
} }
template<class Condition, class P2, class P3> template<class Condition, class P2, class P3>
HInstruction* If(HValue* p1, P2 p2, P3 p3) { Condition* If(HValue* p1, P2 p2, P3 p3) {
HControlInstruction* compare = new(zone()) Condition(p1, p2, p3); Condition* compare = builder()->New<Condition>(p1, p2, p3);
AddCompare(compare); AddCompare(compare);
return compare; return compare;
} }
template<class Condition, class P2> template<class Condition, class P2>
HInstruction* IfNot(HValue* p1, P2 p2) { Condition* IfNot(HValue* p1, P2 p2) {
HControlInstruction* compare = new(zone()) Condition(p1, p2); Condition* compare = builder()->New<Condition>(p1, p2);
AddCompare(compare); AddCompare(compare);
HBasicBlock* block0 = compare->SuccessorAt(0); HBasicBlock* block0 = compare->SuccessorAt(0);
HBasicBlock* block1 = compare->SuccessorAt(1); HBasicBlock* block1 = compare->SuccessorAt(1);
@ -1317,8 +1317,8 @@ class HGraphBuilder {
} }
template<class Condition, class P2, class P3> template<class Condition, class P2, class P3>
HInstruction* IfNot(HValue* p1, P2 p2, P3 p3) { Condition* IfNot(HValue* p1, P2 p2, P3 p3) {
HControlInstruction* compare = new(zone()) Condition(p1, p2, p3); Condition* compare = builder()->New<Condition>(p1, p2, p3);
AddCompare(compare); AddCompare(compare);
HBasicBlock* block0 = compare->SuccessorAt(0); HBasicBlock* block0 = compare->SuccessorAt(0);
HBasicBlock* block1 = compare->SuccessorAt(1); HBasicBlock* block1 = compare->SuccessorAt(1);
@ -1328,37 +1328,37 @@ class HGraphBuilder {
} }
template<class Condition> template<class Condition>
HInstruction* OrIf(HValue *p) { Condition* OrIf(HValue *p) {
Or(); Or();
return If<Condition>(p); return If<Condition>(p);
} }
template<class Condition, class P2> template<class Condition, class P2>
HInstruction* OrIf(HValue* p1, P2 p2) { Condition* OrIf(HValue* p1, P2 p2) {
Or(); Or();
return If<Condition>(p1, p2); return If<Condition>(p1, p2);
} }
template<class Condition, class P2, class P3> template<class Condition, class P2, class P3>
HInstruction* OrIf(HValue* p1, P2 p2, P3 p3) { Condition* OrIf(HValue* p1, P2 p2, P3 p3) {
Or(); Or();
return If<Condition>(p1, p2, p3); return If<Condition>(p1, p2, p3);
} }
template<class Condition> template<class Condition>
HInstruction* AndIf(HValue *p) { Condition* AndIf(HValue *p) {
And(); And();
return If<Condition>(p); return If<Condition>(p);
} }
template<class Condition, class P2> template<class Condition, class P2>
HInstruction* AndIf(HValue* p1, P2 p2) { Condition* AndIf(HValue* p1, P2 p2) {
And(); And();
return If<Condition>(p1, p2); return If<Condition>(p1, p2);
} }
template<class Condition, class P2, class P3> template<class Condition, class P2, class P3>
HInstruction* AndIf(HValue* p1, P2 p2, P3 p3) { Condition* AndIf(HValue* p1, P2 p2, P3 p3) {
And(); And();
return If<Condition>(p1, p2, p3); return If<Condition>(p1, p2, p3);
} }
@ -1383,7 +1383,7 @@ class HGraphBuilder {
private: private:
void AddCompare(HControlInstruction* compare); void AddCompare(HControlInstruction* compare);
Zone* zone() { return builder_->zone(); } HGraphBuilder* builder() const { return builder_; }
HGraphBuilder* builder_; HGraphBuilder* builder_;
int position_; int position_;