Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 16e7a0c5a3d62f5dc49c0afc95fc361f912af5cf..8522d9701c1ab71d69df63df3c6ebbaa3dc508d1 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -579,13 +579,26 @@ HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer, |
} |
+HConstant* HGraph::GetConstantInt32(SetOncePointer<HConstant>* pointer, |
+ int32_t value) { |
+ if (!pointer->is_set()) { |
+ HConstant* constant = new(zone()) HConstant(value, |
+ Representation::Integer32(), |
+ Handle<Object>::null()); |
+ constant->InsertAfter(GetConstantUndefined()); |
+ pointer->set(constant); |
+ } |
+ return pointer->get(); |
+} |
+ |
+ |
HConstant* HGraph::GetConstant1() { |
- return GetConstant(&constant_1_, Smi::FromInt(1)); |
+ return GetConstantInt32(&constant_1_, 1); |
} |
HConstant* HGraph::GetConstantMinus1() { |
- return GetConstant(&constant_minus1_, Smi::FromInt(-1)); |
+ return GetConstantInt32(&constant_minus1_, -1); |
} |
@@ -716,6 +729,8 @@ Handle<Code> HGraph::Compile() { |
chunk->MarkEmptyBlocks(); |
+ EnsureConstantsHaveHandles(); |
+ |
if (generator.GenerateCode()) { |
if (FLAG_trace_codegen) { |
PrintF("Crankshaft Compiler - "); |
@@ -3051,6 +3066,12 @@ HGraph* HGraphBuilder::CreateGraph() { |
graph_ = new(zone()) HGraph(info()); |
if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info()); |
+ Factory* f = info()->isolate()->factory(); |
+ constant_undefined_ = new(zone()) HConstant(f->undefined_value(), |
+ Representation::Tagged()); |
+ constant_null_ = new(zone()) HConstant(f->null_value(), |
+ Representation::Tagged()); |
+ |
{ |
HPhase phase("H_Block building"); |
CompilationHandleScope handle_scope(info()); |
@@ -7790,8 +7811,8 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, |
// for a smi operation. If one of the operands is a constant string |
// do not generate code assuming it is a smi operation. |
if (info.IsSmi() && |
- ((left->IsConstant() && HConstant::cast(left)->HasStringValue()) || |
- (right->IsConstant() && HConstant::cast(right)->HasStringValue()))) { |
+ ((left->IsConstant() && HConstant::cast(left)->IsString()) || |
+ (right->IsConstant() && HConstant::cast(right)->IsString()))) { |
return instr; |
} |
Representation rep = ToRepresentation(info); |
@@ -7989,10 +8010,12 @@ void HGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, |
static bool MatchLiteralCompareNil(HValue* left, |
Token::Value op, |
HValue* right, |
- Handle<Object> nil, |
+ HConstant* nil, |
HValue** expr) { |
+ ASSERT(nil->IsTagged()); |
if (left->IsConstant() && |
- HConstant::cast(left)->handle().is_identical_to(nil) && |
+ HConstant::cast(left)->IsTagged() && |
+ HConstant::cast(left)->handle().is_identical_to(nil->handle()) && |
Token::IsEqualityOp(op)) { |
*expr = right; |
return true; |
@@ -8009,7 +8032,7 @@ static bool MatchLiteralCompareTypeof(HValue* left, |
if (left->IsTypeof() && |
Token::IsEqualityOp(op) && |
right->IsConstant() && |
- HConstant::cast(right)->HasStringValue()) { |
+ HConstant::cast(right)->IsString()) { |
*typeof_expr = HTypeof::cast(left); |
*check = Handle<String>::cast(HConstant::cast(right)->handle()); |
return true; |
@@ -8031,7 +8054,7 @@ static bool IsLiteralCompareTypeof(HValue* left, |
static bool IsLiteralCompareNil(HValue* left, |
Token::Value op, |
HValue* right, |
- Handle<Object> nil, |
+ HConstant* nil, |
HValue** expr) { |
return MatchLiteralCompareNil(left, op, right, nil, expr) || |
MatchLiteralCompareNil(right, op, left, nil, expr); |
@@ -8042,8 +8065,10 @@ static bool IsLiteralCompareBool(HValue* left, |
Token::Value op, |
HValue* right) { |
return op == Token::EQ_STRICT && |
- ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || |
- (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); |
+ ((left->IsConstant() && |
+ HConstant::cast(left)->IsBoolean()) || |
+ (right->IsConstant() && |
+ HConstant::cast(right)->IsBoolean())); |
} |
@@ -8087,11 +8112,10 @@ void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
return HandleLiteralCompareTypeof(expr, typeof_expr, check); |
} |
HValue* sub_expr = NULL; |
- Factory* f = graph()->isolate()->factory(); |
- if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { |
+ if (IsLiteralCompareNil(left, op, right, constant_undefined_, &sub_expr)) { |
return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); |
} |
- if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { |
+ if (IsLiteralCompareNil(left, op, right, constant_null_, &sub_expr)) { |
return HandleLiteralCompareNil(expr, sub_expr, kNullValue); |
} |
if (IsLiteralCompareBool(left, op, right)) { |