Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index aeeff340459596646fb28f52b736b7f3ad695e9a..537b791d7006ebf17d78dac8cb5fb7e866b583a5 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -7261,8 +7261,21 @@ void HOptimizedGraphBuilder::HandlePolymorphicStoreNamedField( |
AddInstruction(HCheckMaps::New(object, types, zone())); |
HInstruction* instr = BuildStoreNamedField( |
object, name, value, map, &lookup); |
+ AddInstruction(instr); |
instr->set_position(expr->position()); |
- return ast_context()->ReturnInstruction(instr, expr->id()); |
+ // The HSimulate for the store should not see the stored value in |
+ // effect contexts (it is not materialized at expr->id() in the |
+ // unoptimized code). |
+ if (instr->HasObservableSideEffects()) { |
+ if (ast_context()->IsEffect()) { |
+ AddSimulate(expr->id(), REMOVABLE_SIMULATE); |
+ } else { |
+ Push(value); |
+ AddSimulate(expr->id(), REMOVABLE_SIMULATE); |
+ Drop(1); |
+ } |
+ } |
+ return ast_context()->ReturnValue(value); |
} |
} |