Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 6bc7f6982fb798f442eb5a55da8b380ac7868d0c..bb0ceada840fdbde9bdd0ae2f8adb37ffbbf90e0 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -5909,18 +5909,27 @@ void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
Handle<GlobalObject> global(current_info()->global_object()); |
Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); |
if (cell->type()->IsConstant()) { |
- IfBuilder builder(this); |
- HValue* constant = Add<HConstant>(cell->type()->AsConstant()); |
- if (cell->type()->AsConstant()->IsNumber()) { |
- builder.If<HCompareNumericAndBranch>(value, constant, Token::EQ); |
+ Handle<Object> constant = cell->type()->AsConstant(); |
+ if (value->IsConstant()) { |
+ HConstant* c_value = HConstant::cast(value); |
+ if (!constant.is_identical_to(c_value->handle(isolate()))) { |
+ Add<HDeoptimize>("Constant global variable assignment", |
+ Deoptimizer::EAGER); |
+ } |
} else { |
- builder.If<HCompareObjectEqAndBranch>(value, constant); |
+ HValue* c_constant = Add<HConstant>(constant); |
+ IfBuilder builder(this); |
+ if (constant->IsNumber()) { |
+ builder.If<HCompareNumericAndBranch>(value, c_constant, Token::EQ); |
+ } else { |
+ builder.If<HCompareObjectEqAndBranch>(value, c_constant); |
+ } |
+ builder.Then(); |
+ builder.Else(); |
+ Add<HDeoptimize>("Constant global variable assignment", |
+ Deoptimizer::EAGER); |
+ builder.End(); |
} |
- builder.Then(); |
- builder.Else(); |
- Add<HDeoptimize>("Constant global variable assignment", |
- Deoptimizer::EAGER); |
- builder.End(); |
} |
HInstruction* instr = |
Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails()); |