Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index dfde504339875da64727170e4d82ffa504adcad6..12d0a0577254a7fc2dca4056256a665077ff3291 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -579,13 +579,25 @@ 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()); |
| + constant->InsertAfter(GetConstantUndefined()); |
| + pointer->set(constant); |
| + } |
| + return pointer->get(); |
| +} |
| + |
| + |
| HConstant* HGraph::GetConstant1() { |
| - return GetConstant(&constant_1_, Handle<Smi>(Smi::FromInt(1))); |
| + return GetConstantInt32(&constant_1_, 1); |
| } |
| HConstant* HGraph::GetConstantMinus1() { |
| - return GetConstant(&constant_minus1_, Handle<Smi>(Smi::FromInt(-1))); |
| + return GetConstantInt32(&constant_minus1_, -1); |
| } |
| @@ -3051,6 +3063,12 @@ HGraph* HGraphBuilder::CreateGraph() { |
| graph_ = new(zone()) HGraph(info()); |
| if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info()); |
| + Factory* f = info()->isolate()->factory(); |
|
Michael Starzinger
2012/07/10 12:05:51
I don't think this change is actually needed.
|
| + 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()); |
| @@ -7872,8 +7890,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)->handle()->IsString()) || |
| + (right->IsConstant() && HConstant::cast(right)->handle()->IsString()))) { |
| return instr; |
| } |
| Representation rep = ToRepresentation(info); |
| @@ -8071,10 +8089,12 @@ void HGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, |
| static bool MatchLiteralCompareNil(HValue* left, |
| Token::Value op, |
| HValue* right, |
| - Handle<Object> nil, |
| + HConstant* nil, |
|
Michael Starzinger
2012/07/10 12:05:51
I don't think any of the changes in this file from
|
| 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; |
| @@ -8091,7 +8111,7 @@ static bool MatchLiteralCompareTypeof(HValue* left, |
| if (left->IsTypeof() && |
| Token::IsEqualityOp(op) && |
| right->IsConstant() && |
| - HConstant::cast(right)->HasStringValue()) { |
| + HConstant::cast(right)->handle()->IsString()) { |
| *typeof_expr = HTypeof::cast(left); |
| *check = Handle<String>::cast(HConstant::cast(right)->handle()); |
| return true; |
| @@ -8113,7 +8133,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); |
| @@ -8124,8 +8144,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)->handle()->IsBoolean()) || |
| + (right->IsConstant() && |
| + HConstant::cast(right)->handle()->IsBoolean())); |
| } |
| @@ -8169,11 +8191,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)) { |