OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4808 } | 4808 } |
4809 | 4809 |
4810 | 4810 |
4811 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 4811 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
4812 ASSERT(!HasStackOverflow()); | 4812 ASSERT(!HasStackOverflow()); |
4813 ASSERT(current_block() != NULL); | 4813 ASSERT(current_block() != NULL); |
4814 ASSERT(current_block()->HasPredecessor()); | 4814 ASSERT(current_block()->HasPredecessor()); |
4815 Variable* variable = expr->var(); | 4815 Variable* variable = expr->var(); |
4816 switch (variable->location()) { | 4816 switch (variable->location()) { |
4817 case Variable::UNALLOCATED: { | 4817 case Variable::UNALLOCATED: { |
4818 if (variable->mode() == LET || variable->mode() == CONST_HARMONY) { | 4818 if (IsLexicalVariableMode(variable->mode())) { |
4819 return Bailout("reference to global harmony declared variable"); | 4819 // TODO(rossberg): should this be an ASSERT? |
| 4820 return Bailout("reference to global lexical variable"); |
4820 } | 4821 } |
4821 // Handle known global constants like 'undefined' specially to avoid a | 4822 // Handle known global constants like 'undefined' specially to avoid a |
4822 // load from a global cell for them. | 4823 // load from a global cell for them. |
4823 Handle<Object> constant_value = | 4824 Handle<Object> constant_value = |
4824 isolate()->factory()->GlobalConstantFor(variable->name()); | 4825 isolate()->factory()->GlobalConstantFor(variable->name()); |
4825 if (!constant_value.is_null()) { | 4826 if (!constant_value.is_null()) { |
4826 HConstant* instr = | 4827 HConstant* instr = |
4827 new(zone()) HConstant(constant_value, Representation::Tagged()); | 4828 new(zone()) HConstant(constant_value, Representation::Tagged()); |
4828 return ast_context()->ReturnInstruction(instr, expr->id()); | 4829 return ast_context()->ReturnInstruction(instr, expr->id()); |
4829 } | 4830 } |
(...skipping 24 matching lines...) Expand all Loading... |
4854 ast_context()->is_for_typeof()); | 4855 ast_context()->is_for_typeof()); |
4855 instr->set_position(expr->position()); | 4856 instr->set_position(expr->position()); |
4856 return ast_context()->ReturnInstruction(instr, expr->id()); | 4857 return ast_context()->ReturnInstruction(instr, expr->id()); |
4857 } | 4858 } |
4858 } | 4859 } |
4859 | 4860 |
4860 case Variable::PARAMETER: | 4861 case Variable::PARAMETER: |
4861 case Variable::LOCAL: { | 4862 case Variable::LOCAL: { |
4862 HValue* value = environment()->Lookup(variable); | 4863 HValue* value = environment()->Lookup(variable); |
4863 if (value == graph()->GetConstantHole()) { | 4864 if (value == graph()->GetConstantHole()) { |
4864 ASSERT(variable->mode() == CONST || | 4865 ASSERT(IsDeclaredVariableMode(variable->mode()) && |
4865 variable->mode() == CONST_HARMONY || | 4866 variable->mode() != VAR); |
4866 variable->mode() == LET); | |
4867 return Bailout("reference to uninitialized variable"); | 4867 return Bailout("reference to uninitialized variable"); |
4868 } | 4868 } |
4869 return ast_context()->ReturnValue(value); | 4869 return ast_context()->ReturnValue(value); |
4870 } | 4870 } |
4871 | 4871 |
4872 case Variable::CONTEXT: { | 4872 case Variable::CONTEXT: { |
4873 HValue* context = BuildContextChainWalk(variable); | 4873 HValue* context = BuildContextChainWalk(variable); |
4874 HLoadContextSlot* instr = new(zone()) HLoadContextSlot(context, variable); | 4874 HLoadContextSlot* instr = new(zone()) HLoadContextSlot(context, variable); |
4875 return ast_context()->ReturnInstruction(instr, expr->id()); | 4875 return ast_context()->ReturnInstruction(instr, expr->id()); |
4876 } | 4876 } |
(...skipping 3231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8108 // linear search of the parameter list. | 8108 // linear search of the parameter list. |
8109 int count = info()->scope()->num_parameters(); | 8109 int count = info()->scope()->num_parameters(); |
8110 for (int i = 0; i < count; ++i) { | 8110 for (int i = 0; i < count; ++i) { |
8111 if (var == info()->scope()->parameter(i)) { | 8111 if (var == info()->scope()->parameter(i)) { |
8112 return Bailout("assignment to parameter in arguments object"); | 8112 return Bailout("assignment to parameter in arguments object"); |
8113 } | 8113 } |
8114 } | 8114 } |
8115 } | 8115 } |
8116 | 8116 |
8117 HValue* context = BuildContextChainWalk(var); | 8117 HValue* context = BuildContextChainWalk(var); |
8118 HStoreContextSlot::Mode mode = | 8118 HStoreContextSlot::Mode mode = IsLexicalVariableMode(var->mode()) |
8119 (var->mode() == LET || var->mode() == CONST_HARMONY) | |
8120 ? HStoreContextSlot::kCheckDeoptimize : HStoreContextSlot::kNoCheck; | 8119 ? HStoreContextSlot::kCheckDeoptimize : HStoreContextSlot::kNoCheck; |
8121 HStoreContextSlot* instr = | 8120 HStoreContextSlot* instr = |
8122 new(zone()) HStoreContextSlot(context, var->index(), mode, after); | 8121 new(zone()) HStoreContextSlot(context, var->index(), mode, after); |
8123 AddInstruction(instr); | 8122 AddInstruction(instr); |
8124 if (instr->HasObservableSideEffects()) { | 8123 if (instr->HasObservableSideEffects()) { |
8125 AddSimulate(expr->AssignmentId()); | 8124 AddSimulate(expr->AssignmentId()); |
8126 } | 8125 } |
8127 break; | 8126 break; |
8128 } | 8127 } |
8129 | 8128 |
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9968 } | 9967 } |
9969 } | 9968 } |
9970 | 9969 |
9971 #ifdef DEBUG | 9970 #ifdef DEBUG |
9972 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9971 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
9973 if (allocator_ != NULL) allocator_->Verify(); | 9972 if (allocator_ != NULL) allocator_->Verify(); |
9974 #endif | 9973 #endif |
9975 } | 9974 } |
9976 | 9975 |
9977 } } // namespace v8::internal | 9976 } } // namespace v8::internal |
OLD | NEW |