Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Unified Diff: src/hydrogen.cc

Issue 8857001: [hydrogen] don't bailout assignments to consts (Closed) Base URL: gh:v8/v8@master
Patch Set: fixed naming, added test Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 519b4b84ba47b52bcc1a70257d1ed2ae140fddd4..0dca258239a0b6c8c22e00de8bada4675a3d9052 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -3288,9 +3288,6 @@ void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
if (variable->mode() == LET || variable->mode() == CONST_HARMONY) {
return Bailout("reference to harmony declared context slot");
}
- if (variable->mode() == CONST) {
- return Bailout("reference to const context slot");
fschneider 2011/12/09 09:37:54 In order to get rid of this bailout we also additi
- }
HValue* context = BuildContextChainWalk(variable);
HLoadContextSlot* instr =
new(zone()) HLoadContextSlot(context, variable->index());
@@ -3956,20 +3953,18 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
HandlePropertyAssignment(expr);
} else if (proxy != NULL) {
Variable* var = proxy->var();
+
if (var->mode() == CONST) {
if (expr->op() != Token::INIT_CONST) {
- return Bailout("non-initializer assignment to const");
- }
- if (!var->IsStackAllocated()) {
- return Bailout("assignment to const context slot");
+ CHECK_ALIVE(VisitForValue(expr->value()));
+ return ast_context()->ReturnValue(Pop());
}
- // We insert a use of the old value to detect unsupported uses of const
- // variables (e.g. initialization inside a loop).
- HValue* old_value = environment()->Lookup(var);
- AddInstruction(new HUseConst(old_value));
- } else if (var->mode() == LET) {
- if (!var->IsStackAllocated()) {
- return Bailout("assignment to let context slot");
+
+ if (var->IsStackAllocated()) {
+ // We insert a use of the old value to detect unsupported uses of const
+ // variables (e.g. initialization inside a loop).
+ HValue* old_value = environment()->Lookup(var);
+ AddInstruction(new HUseConst(old_value));
}
} else if (var->mode() == CONST_HARMONY) {
if (expr->op() != Token::INIT_CONST_HARMONY) {
@@ -3978,6 +3973,10 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
if (!var->IsStackAllocated()) {
return Bailout("assignment to const context slot");
}
+ } else if (var->mode() == LET) {
+ if (!var->IsStackAllocated()) {
+ return Bailout("assignment to let context slot");
+ }
}
if (proxy->IsArguments()) return Bailout("assignment to arguments");
@@ -4012,7 +4011,6 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
}
case Variable::CONTEXT: {
- ASSERT(var->mode() != CONST);
// Bail out if we try to mutate a parameter value in a function using
// the arguments object. We do not (yet) correctly handle the
// arguments property of the function.
@@ -4031,6 +4029,12 @@ void HGraphBuilder::VisitAssignment(Assignment* expr) {
HValue* context = BuildContextChainWalk(var);
HStoreContextSlot* instr =
new(zone()) HStoreContextSlot(context, var->index(), Top());
+
+ // Ensure that const variable's value will be set only once
+ if (var->is_const_mode()) {
fschneider 2011/12/09 09:37:54 Here I would write if (var->mode() == CONST) to
+ instr->ForceIsHoleCheck();
+ }
+
AddInstruction(instr);
if (instr->HasObservableSideEffects()) {
AddSimulate(expr->AssignmentId());
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698