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

Side by Side Diff: src/hydrogen.cc

Issue 7671042: Temporal dead zone behaviour for let bindings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Bailout in hydrogen and X64 and ARM code. Created 9 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 } 3114 }
3115 3115
3116 3116
3117 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { 3117 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
3118 ASSERT(!HasStackOverflow()); 3118 ASSERT(!HasStackOverflow());
3119 ASSERT(current_block() != NULL); 3119 ASSERT(current_block() != NULL);
3120 ASSERT(current_block()->HasPredecessor()); 3120 ASSERT(current_block()->HasPredecessor());
3121 Variable* variable = expr->AsVariable(); 3121 Variable* variable = expr->AsVariable();
3122 if (variable == NULL) { 3122 if (variable == NULL) {
3123 return Bailout("reference to rewritten variable"); 3123 return Bailout("reference to rewritten variable");
3124 } else if (variable->mode() == Variable::LET) {
3125 return Bailout("reference to let variable");
3124 } else if (variable->IsStackAllocated()) { 3126 } else if (variable->IsStackAllocated()) {
3125 HValue* value = environment()->Lookup(variable); 3127 HValue* value = environment()->Lookup(variable);
3126 if (variable->mode() == Variable::CONST && 3128 if (variable->mode() == Variable::CONST &&
3127 value == graph()->GetConstantHole()) { 3129 value == graph()->GetConstantHole()) {
3128 return Bailout("reference to uninitialized const variable"); 3130 return Bailout("reference to uninitialized const variable");
3129 } 3131 }
3130 return ast_context()->ReturnValue(value); 3132 return ast_context()->ReturnValue(value);
3131 } else if (variable->IsContextSlot()) { 3133 } else if (variable->IsContextSlot()) {
3132 if (variable->mode() == Variable::CONST) { 3134 if (variable->mode() == Variable::CONST) {
3133 return Bailout("reference to const context slot"); 3135 return Bailout("reference to const context slot");
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 VariableProxy* proxy = target->AsVariableProxy(); 3581 VariableProxy* proxy = target->AsVariableProxy();
3580 Variable* var = proxy->AsVariable(); 3582 Variable* var = proxy->AsVariable();
3581 Property* prop = target->AsProperty(); 3583 Property* prop = target->AsProperty();
3582 ASSERT(var == NULL || prop == NULL); 3584 ASSERT(var == NULL || prop == NULL);
3583 3585
3584 // We have a second position recorded in the FullCodeGenerator to have 3586 // We have a second position recorded in the FullCodeGenerator to have
3585 // type feedback for the binary operation. 3587 // type feedback for the binary operation.
3586 BinaryOperation* operation = expr->binary_operation(); 3588 BinaryOperation* operation = expr->binary_operation();
3587 3589
3588 if (var != NULL) { 3590 if (var != NULL) {
3589 if (var->mode() == Variable::CONST) { 3591 if (var->mode() == Variable::CONST ||
3590 return Bailout("unsupported const compound assignment"); 3592 var->mode() == Variable::LET) {
3593 return Bailout("unsupported let or const compound assignment");
3591 } 3594 }
3592 3595
3593 CHECK_ALIVE(VisitForValue(operation)); 3596 CHECK_ALIVE(VisitForValue(operation));
3594 3597
3595 if (var->is_global()) { 3598 if (var->is_global()) {
3596 HandleGlobalVariableAssignment(var, 3599 HandleGlobalVariableAssignment(var,
3597 Top(), 3600 Top(),
3598 expr->position(), 3601 expr->position(),
3599 expr->AssignmentId()); 3602 expr->AssignmentId());
3600 } else if (var->IsStackAllocated()) { 3603 } else if (var->IsStackAllocated()) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3723 if (expr->op() != Token::INIT_CONST) { 3726 if (expr->op() != Token::INIT_CONST) {
3724 return Bailout("non-initializer assignment to const"); 3727 return Bailout("non-initializer assignment to const");
3725 } 3728 }
3726 if (!var->IsStackAllocated()) { 3729 if (!var->IsStackAllocated()) {
3727 return Bailout("assignment to const context slot"); 3730 return Bailout("assignment to const context slot");
3728 } 3731 }
3729 // We insert a use of the old value to detect unsupported uses of const 3732 // We insert a use of the old value to detect unsupported uses of const
3730 // variables (e.g. initialization inside a loop). 3733 // variables (e.g. initialization inside a loop).
3731 HValue* old_value = environment()->Lookup(var); 3734 HValue* old_value = environment()->Lookup(var);
3732 AddInstruction(new HUseConst(old_value)); 3735 AddInstruction(new HUseConst(old_value));
3736 } else if (var->mode() == Variable::LET) {
3737 return Bailout("unsupported assignment to let");
3733 } 3738 }
3734 3739
3735 if (proxy->IsArguments()) return Bailout("assignment to arguments"); 3740 if (proxy->IsArguments()) return Bailout("assignment to arguments");
3736 3741
3737 // Handle the assignment. 3742 // Handle the assignment.
3738 if (var->IsStackAllocated()) { 3743 if (var->IsStackAllocated()) {
3739 // We do not allow the arguments object to occur in a context where it 3744 // We do not allow the arguments object to occur in a context where it
3740 // may escape, but assignments to stack-allocated locals are 3745 // may escape, but assignments to stack-allocated locals are
3741 // permitted. 3746 // permitted.
3742 CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED)); 3747 CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED));
(...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after
5801 ASSERT(current_block() != NULL); 5806 ASSERT(current_block() != NULL);
5802 ASSERT(current_block()->HasPredecessor()); 5807 ASSERT(current_block()->HasPredecessor());
5803 HThisFunction* self = new(zone()) HThisFunction; 5808 HThisFunction* self = new(zone()) HThisFunction;
5804 return ast_context()->ReturnInstruction(self, expr->id()); 5809 return ast_context()->ReturnInstruction(self, expr->id());
5805 } 5810 }
5806 5811
5807 5812
5808 void HGraphBuilder::VisitDeclaration(Declaration* decl) { 5813 void HGraphBuilder::VisitDeclaration(Declaration* decl) {
5809 // We support only declarations that do not require code generation. 5814 // We support only declarations that do not require code generation.
5810 Variable* var = decl->proxy()->var(); 5815 Variable* var = decl->proxy()->var();
5811 if (!var->IsStackAllocated() || decl->fun() != NULL) { 5816 if (!var->IsStackAllocated() ||
5817 decl->fun() != NULL ||
5818 decl->mode() == Variable::LET) {
5812 return Bailout("unsupported declaration"); 5819 return Bailout("unsupported declaration");
5813 } 5820 }
5814 5821
5815 if (decl->mode() == Variable::CONST) { 5822 if (decl->mode() == Variable::CONST) {
5816 ASSERT(var->IsStackAllocated()); 5823 ASSERT(var->IsStackAllocated());
5817 environment()->Bind(var, graph()->GetConstantHole()); 5824 environment()->Bind(var, graph()->GetConstantHole());
5818 } 5825 }
5819 } 5826 }
5820 5827
5821 5828
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
6749 } 6756 }
6750 } 6757 }
6751 6758
6752 #ifdef DEBUG 6759 #ifdef DEBUG
6753 if (graph_ != NULL) graph_->Verify(); 6760 if (graph_ != NULL) graph_->Verify();
6754 if (allocator_ != NULL) allocator_->Verify(); 6761 if (allocator_ != NULL) allocator_->Verify();
6755 #endif 6762 #endif
6756 } 6763 }
6757 6764
6758 } } // namespace v8::internal 6765 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698