| OLD | NEW | 
|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" | 
| 6 | 6 | 
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" | 
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" | 
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" | 
| 10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" | 
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 865       DCHECK(!variable->binding_needs_init()); | 865       DCHECK(!variable->binding_needs_init()); | 
| 866 | 866 | 
| 867       Register name = register_allocator()->NewRegister(); | 867       Register name = register_allocator()->NewRegister(); | 
| 868 | 868 | 
| 869       builder() | 869       builder() | 
| 870           ->LoadLiteral(variable->name()) | 870           ->LoadLiteral(variable->name()) | 
| 871           .StoreAccumulatorInRegister(name) | 871           .StoreAccumulatorInRegister(name) | 
| 872           .CallRuntime(Runtime::kDeclareEvalVar, name, 1); | 872           .CallRuntime(Runtime::kDeclareEvalVar, name, 1); | 
| 873       break; | 873       break; | 
| 874     } | 874     } | 
|  | 875     case VariableLocation::MODULE: | 
|  | 876       UNREACHABLE(); | 
| 875   } | 877   } | 
| 876 } | 878 } | 
| 877 | 879 | 
| 878 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 880 void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 
| 879   Variable* variable = decl->proxy()->var(); | 881   Variable* variable = decl->proxy()->var(); | 
| 880   switch (variable->location()) { | 882   switch (variable->location()) { | 
| 881     case VariableLocation::GLOBAL: | 883     case VariableLocation::GLOBAL: | 
| 882     case VariableLocation::UNALLOCATED: { | 884     case VariableLocation::UNALLOCATED: { | 
| 883       FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 885       FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 
| 884       globals_builder()->AddFunctionDeclaration(slot, decl->fun()); | 886       globals_builder()->AddFunctionDeclaration(slot, decl->fun()); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 902     } | 904     } | 
| 903     case VariableLocation::LOOKUP: { | 905     case VariableLocation::LOOKUP: { | 
| 904       register_allocator()->PrepareForConsecutiveAllocations(2); | 906       register_allocator()->PrepareForConsecutiveAllocations(2); | 
| 905       Register name = register_allocator()->NextConsecutiveRegister(); | 907       Register name = register_allocator()->NextConsecutiveRegister(); | 
| 906       Register literal = register_allocator()->NextConsecutiveRegister(); | 908       Register literal = register_allocator()->NextConsecutiveRegister(); | 
| 907       builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | 909       builder()->LoadLiteral(variable->name()).StoreAccumulatorInRegister(name); | 
| 908 | 910 | 
| 909       VisitForAccumulatorValue(decl->fun()); | 911       VisitForAccumulatorValue(decl->fun()); | 
| 910       builder()->StoreAccumulatorInRegister(literal).CallRuntime( | 912       builder()->StoreAccumulatorInRegister(literal).CallRuntime( | 
| 911           Runtime::kDeclareEvalFunction, name, 2); | 913           Runtime::kDeclareEvalFunction, name, 2); | 
|  | 914       break; | 
| 912     } | 915     } | 
|  | 916     case VariableLocation::MODULE: | 
|  | 917       UNREACHABLE(); | 
| 913   } | 918   } | 
| 914 } | 919 } | 
| 915 | 920 | 
| 916 void BytecodeGenerator::VisitDeclarations( | 921 void BytecodeGenerator::VisitDeclarations( | 
| 917     ZoneList<Declaration*>* declarations) { | 922     ZoneList<Declaration*>* declarations) { | 
| 918   RegisterAllocationScope register_scope(this); | 923   RegisterAllocationScope register_scope(this); | 
| 919   DCHECK(globals_builder()->empty()); | 924   DCHECK(globals_builder()->empty()); | 
| 920   for (int i = 0; i < declarations->length(); i++) { | 925   for (int i = 0; i < declarations->length(); i++) { | 
| 921     RegisterAllocationScope register_scope(this); | 926     RegisterAllocationScope register_scope(this); | 
| 922     Visit(declarations->at(i)); | 927     Visit(declarations->at(i)); | 
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1897       builder()->LoadContextSlot(context_reg, variable->index()); | 1902       builder()->LoadContextSlot(context_reg, variable->index()); | 
| 1898       BuildHoleCheckForVariableLoad(variable); | 1903       BuildHoleCheckForVariableLoad(variable); | 
| 1899       execution_result()->SetResultInAccumulator(); | 1904       execution_result()->SetResultInAccumulator(); | 
| 1900       break; | 1905       break; | 
| 1901     } | 1906     } | 
| 1902     case VariableLocation::LOOKUP: { | 1907     case VariableLocation::LOOKUP: { | 
| 1903       builder()->LoadLookupSlot(variable->name(), typeof_mode); | 1908       builder()->LoadLookupSlot(variable->name(), typeof_mode); | 
| 1904       execution_result()->SetResultInAccumulator(); | 1909       execution_result()->SetResultInAccumulator(); | 
| 1905       break; | 1910       break; | 
| 1906     } | 1911     } | 
|  | 1912     case VariableLocation::MODULE: | 
|  | 1913       UNREACHABLE(); | 
| 1907   } | 1914   } | 
| 1908 } | 1915 } | 
| 1909 | 1916 | 
| 1910 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( | 1917 void BytecodeGenerator::VisitVariableLoadForAccumulatorValue( | 
| 1911     Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { | 1918     Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { | 
| 1912   AccumulatorResultScope accumulator_result(this); | 1919   AccumulatorResultScope accumulator_result(this); | 
| 1913   VisitVariableLoad(variable, slot, typeof_mode); | 1920   VisitVariableLoad(variable, slot, typeof_mode); | 
| 1914 } | 1921 } | 
| 1915 | 1922 | 
| 1916 Register BytecodeGenerator::VisitVariableLoadForRegisterValue( | 1923 Register BytecodeGenerator::VisitVariableLoadForRegisterValue( | 
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2122       } | 2129       } | 
| 2123 | 2130 | 
| 2124       builder()->StoreContextSlot(context_reg, variable->index()); | 2131       builder()->StoreContextSlot(context_reg, variable->index()); | 
| 2125       break; | 2132       break; | 
| 2126     } | 2133     } | 
| 2127     case VariableLocation::LOOKUP: { | 2134     case VariableLocation::LOOKUP: { | 
| 2128       DCHECK_NE(CONST_LEGACY, variable->mode()); | 2135       DCHECK_NE(CONST_LEGACY, variable->mode()); | 
| 2129       builder()->StoreLookupSlot(variable->name(), language_mode()); | 2136       builder()->StoreLookupSlot(variable->name(), language_mode()); | 
| 2130       break; | 2137       break; | 
| 2131     } | 2138     } | 
|  | 2139     case VariableLocation::MODULE: | 
|  | 2140       UNREACHABLE(); | 
| 2132   } | 2141   } | 
| 2133 } | 2142 } | 
| 2134 | 2143 | 
| 2135 void BytecodeGenerator::VisitAssignment(Assignment* expr) { | 2144 void BytecodeGenerator::VisitAssignment(Assignment* expr) { | 
| 2136   DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 2145   DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 
| 2137   Register object, key, home_object, value; | 2146   Register object, key, home_object, value; | 
| 2138   Handle<String> name; | 2147   Handle<String> name; | 
| 2139 | 2148 | 
| 2140   // Left-hand side can only be a property, a global or a variable slot. | 2149   // Left-hand side can only be a property, a global or a variable slot. | 
| 2141   Property* property = expr->target()->AsProperty(); | 2150   Property* property = expr->target()->AsProperty(); | 
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3271   return execution_context()->scope()->language_mode(); | 3280   return execution_context()->scope()->language_mode(); | 
| 3272 } | 3281 } | 
| 3273 | 3282 | 
| 3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3283 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 
| 3275   return TypeFeedbackVector::GetIndex(slot); | 3284   return TypeFeedbackVector::GetIndex(slot); | 
| 3276 } | 3285 } | 
| 3277 | 3286 | 
| 3278 }  // namespace interpreter | 3287 }  // namespace interpreter | 
| 3279 }  // namespace internal | 3288 }  // namespace internal | 
| 3280 }  // namespace v8 | 3289 }  // namespace v8 | 
| OLD | NEW | 
|---|