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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 NativeFunctionLiteral* expr = literal.first; | 657 NativeFunctionLiteral* expr = literal.first; |
658 Handle<SharedFunctionInfo> shared_info = | 658 Handle<SharedFunctionInfo> shared_info = |
659 Compiler::GetSharedFunctionInfoForNative(expr->extension(), | 659 Compiler::GetSharedFunctionInfoForNative(expr->extension(), |
660 expr->name()); | 660 expr->name()); |
661 if (shared_info.is_null()) return SetStackOverflow(); | 661 if (shared_info.is_null()) return SetStackOverflow(); |
662 builder()->InsertConstantPoolEntryAt(literal.second, shared_info); | 662 builder()->InsertConstantPoolEntryAt(literal.second, shared_info); |
663 } | 663 } |
664 } | 664 } |
665 | 665 |
666 void BytecodeGenerator::GenerateBytecode() { | 666 void BytecodeGenerator::GenerateBytecode() { |
| 667 DisallowHeapAllocation no_allocation; |
| 668 DisallowHandleAllocation no_handles; |
| 669 DisallowHandleDereference no_deref; |
| 670 |
667 // Initialize the incoming context. | 671 // Initialize the incoming context. |
668 ContextScope incoming_context(this, scope(), false); | 672 ContextScope incoming_context(this, scope(), false); |
669 | 673 |
670 // Initialize control scope. | 674 // Initialize control scope. |
671 ControlScopeForTopLevel control(this); | 675 ControlScopeForTopLevel control(this); |
672 | 676 |
673 RegisterAllocationScope register_scope(this); | 677 RegisterAllocationScope register_scope(this); |
674 | 678 |
675 if (IsResumableFunction(info()->literal()->kind())) { | 679 if (IsResumableFunction(info()->literal()->kind())) { |
676 generator_state_ = register_allocator()->NewRegister(); | 680 generator_state_ = register_allocator()->NewRegister(); |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 loop_builder.EndLoop(); | 1156 loop_builder.EndLoop(); |
1153 } | 1157 } |
1154 | 1158 |
1155 void BytecodeGenerator::VisitForInAssignment(Expression* expr, | 1159 void BytecodeGenerator::VisitForInAssignment(Expression* expr, |
1156 FeedbackVectorSlot slot) { | 1160 FeedbackVectorSlot slot) { |
1157 DCHECK(expr->IsValidReferenceExpression()); | 1161 DCHECK(expr->IsValidReferenceExpression()); |
1158 | 1162 |
1159 // Evaluate assignment starting with the value to be stored in the | 1163 // Evaluate assignment starting with the value to be stored in the |
1160 // accumulator. | 1164 // accumulator. |
1161 Property* property = expr->AsProperty(); | 1165 Property* property = expr->AsProperty(); |
1162 LhsKind assign_type = Property::GetAssignType(property); | 1166 LhsKind assign_type = |
| 1167 Property::GetAssignType(property, HandleDereferenceMode::kDisallowed); |
1163 switch (assign_type) { | 1168 switch (assign_type) { |
1164 case VARIABLE: { | 1169 case VARIABLE: { |
1165 Variable* variable = expr->AsVariableProxy()->var(); | 1170 Variable* variable = expr->AsVariableProxy()->var(); |
1166 VisitVariableAssignment(variable, Token::ASSIGN, slot); | 1171 VisitVariableAssignment(variable, Token::ASSIGN, slot); |
1167 break; | 1172 break; |
1168 } | 1173 } |
1169 case NAMED_PROPERTY: { | 1174 case NAMED_PROPERTY: { |
1170 RegisterAllocationScope register_scope(this); | 1175 RegisterAllocationScope register_scope(this); |
1171 Register value = register_allocator()->NewRegister(); | 1176 Register value = register_allocator()->NewRegister(); |
1172 builder()->StoreAccumulatorInRegister(value); | 1177 builder()->StoreAccumulatorInRegister(value); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 Literal* literal_key = property->key()->AsLiteral(); | 1636 Literal* literal_key = property->key()->AsLiteral(); |
1632 switch (property->kind()) { | 1637 switch (property->kind()) { |
1633 case ObjectLiteral::Property::CONSTANT: | 1638 case ObjectLiteral::Property::CONSTANT: |
1634 UNREACHABLE(); | 1639 UNREACHABLE(); |
1635 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1640 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1636 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1641 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
1637 // Fall through. | 1642 // Fall through. |
1638 case ObjectLiteral::Property::COMPUTED: { | 1643 case ObjectLiteral::Property::COMPUTED: { |
1639 // It is safe to use [[Put]] here because the boilerplate already | 1644 // It is safe to use [[Put]] here because the boilerplate already |
1640 // contains computed properties with an uninitialized value. | 1645 // contains computed properties with an uninitialized value. |
| 1646 |
| 1647 // TODO(5203): Remove this temporary exception. |
| 1648 AllowHandleDereference allow_deref; |
| 1649 |
1641 if (literal_key->value()->IsInternalizedString()) { | 1650 if (literal_key->value()->IsInternalizedString()) { |
1642 if (property->emit_store()) { | 1651 if (property->emit_store()) { |
1643 VisitForAccumulatorValue(property->value()); | 1652 VisitForAccumulatorValue(property->value()); |
1644 if (FunctionLiteral::NeedsHomeObject(property->value())) { | 1653 if (FunctionLiteral::NeedsHomeObject(property->value())) { |
1645 RegisterAllocationScope register_scope(this); | 1654 RegisterAllocationScope register_scope(this); |
1646 Register value = register_allocator()->NewRegister(); | 1655 Register value = register_allocator()->NewRegister(); |
1647 builder()->StoreAccumulatorInRegister(value); | 1656 builder()->StoreAccumulatorInRegister(value); |
1648 builder()->StoreNamedProperty( | 1657 builder()->StoreNamedProperty( |
1649 literal, literal_key->AsPropertyName(), | 1658 literal, literal_key->AsPropertyName(), |
1650 feedback_index(property->GetSlot(0)), language_mode()); | 1659 feedback_index(property->GetSlot(0)), language_mode()); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 } | 2150 } |
2142 } | 2151 } |
2143 | 2152 |
2144 void BytecodeGenerator::VisitAssignment(Assignment* expr) { | 2153 void BytecodeGenerator::VisitAssignment(Assignment* expr) { |
2145 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 2154 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
2146 Register object, key, home_object, value; | 2155 Register object, key, home_object, value; |
2147 Handle<String> name; | 2156 Handle<String> name; |
2148 | 2157 |
2149 // Left-hand side can only be a property, a global or a variable slot. | 2158 // Left-hand side can only be a property, a global or a variable slot. |
2150 Property* property = expr->target()->AsProperty(); | 2159 Property* property = expr->target()->AsProperty(); |
2151 LhsKind assign_type = Property::GetAssignType(property); | 2160 LhsKind assign_type = |
| 2161 Property::GetAssignType(property, HandleDereferenceMode::kDisallowed); |
2152 | 2162 |
2153 // Evaluate LHS expression. | 2163 // Evaluate LHS expression. |
2154 switch (assign_type) { | 2164 switch (assign_type) { |
2155 case VARIABLE: | 2165 case VARIABLE: |
2156 // Nothing to do to evaluate variable assignment LHS. | 2166 // Nothing to do to evaluate variable assignment LHS. |
2157 break; | 2167 break; |
2158 case NAMED_PROPERTY: { | 2168 case NAMED_PROPERTY: { |
2159 object = VisitForRegisterValue(property->obj()); | 2169 object = VisitForRegisterValue(property->obj()); |
2160 name = property->key()->AsLiteral()->AsPropertyName(); | 2170 name = property->key()->AsLiteral()->AsPropertyName(); |
2161 break; | 2171 break; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2371 builder()->SetExpressionPosition(expr); | 2381 builder()->SetExpressionPosition(expr); |
2372 builder()->Throw(); | 2382 builder()->Throw(); |
2373 // Throw statements are modeled as expressions instead of statements. These | 2383 // Throw statements are modeled as expressions instead of statements. These |
2374 // are converted from assignment statements in Rewriter::ReWrite pass. An | 2384 // are converted from assignment statements in Rewriter::ReWrite pass. An |
2375 // assignment statement expects a value in the accumulator. This is a hack to | 2385 // assignment statement expects a value in the accumulator. This is a hack to |
2376 // avoid DCHECK fails assert accumulator has been set. | 2386 // avoid DCHECK fails assert accumulator has been set. |
2377 execution_result()->SetResultInAccumulator(); | 2387 execution_result()->SetResultInAccumulator(); |
2378 } | 2388 } |
2379 | 2389 |
2380 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) { | 2390 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) { |
2381 LhsKind property_kind = Property::GetAssignType(expr); | 2391 LhsKind property_kind = |
| 2392 Property::GetAssignType(expr, HandleDereferenceMode::kDisallowed); |
2382 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); | 2393 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); |
2383 builder()->SetExpressionPosition(expr); | 2394 builder()->SetExpressionPosition(expr); |
2384 switch (property_kind) { | 2395 switch (property_kind) { |
2385 case VARIABLE: | 2396 case VARIABLE: |
2386 UNREACHABLE(); | 2397 UNREACHABLE(); |
2387 case NAMED_PROPERTY: { | 2398 case NAMED_PROPERTY: { |
2388 builder()->LoadNamedProperty(obj, | 2399 builder()->LoadNamedProperty(obj, |
2389 expr->key()->AsLiteral()->AsPropertyName(), | 2400 expr->key()->AsLiteral()->AsPropertyName(), |
2390 feedback_index(slot)); | 2401 feedback_index(slot)); |
2391 break; | 2402 break; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 VisitForRegisterValue(super_property->home_object(), home_object); | 2460 VisitForRegisterValue(super_property->home_object(), home_object); |
2450 VisitForRegisterValue(property->key(), key); | 2461 VisitForRegisterValue(property->key(), key); |
2451 BuildKeyedSuperPropertyLoad(receiver, home_object, key); | 2462 BuildKeyedSuperPropertyLoad(receiver, home_object, key); |
2452 | 2463 |
2453 if (opt_receiver_out.is_valid()) { | 2464 if (opt_receiver_out.is_valid()) { |
2454 builder()->MoveRegister(receiver, opt_receiver_out); | 2465 builder()->MoveRegister(receiver, opt_receiver_out); |
2455 } | 2466 } |
2456 } | 2467 } |
2457 | 2468 |
2458 void BytecodeGenerator::VisitProperty(Property* expr) { | 2469 void BytecodeGenerator::VisitProperty(Property* expr) { |
2459 LhsKind property_kind = Property::GetAssignType(expr); | 2470 LhsKind property_kind = |
| 2471 Property::GetAssignType(expr, HandleDereferenceMode::kDisallowed); |
2460 if (property_kind != NAMED_SUPER_PROPERTY && | 2472 if (property_kind != NAMED_SUPER_PROPERTY && |
2461 property_kind != KEYED_SUPER_PROPERTY) { | 2473 property_kind != KEYED_SUPER_PROPERTY) { |
2462 Register obj = VisitForRegisterValue(expr->obj()); | 2474 Register obj = VisitForRegisterValue(expr->obj()); |
2463 VisitPropertyLoad(obj, expr); | 2475 VisitPropertyLoad(obj, expr); |
2464 } else { | 2476 } else { |
2465 VisitPropertyLoad(Register::invalid_value(), expr); | 2477 VisitPropertyLoad(Register::invalid_value(), expr); |
2466 } | 2478 } |
2467 } | 2479 } |
2468 | 2480 |
2469 Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) { | 2481 Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) { |
(...skipping 23 matching lines...) Expand all Loading... |
2493 Register ith_arg = register_allocator()->NextConsecutiveRegister(); | 2505 Register ith_arg = register_allocator()->NextConsecutiveRegister(); |
2494 VisitForAccumulatorValue(args->at(i)); | 2506 VisitForAccumulatorValue(args->at(i)); |
2495 builder()->StoreAccumulatorInRegister(ith_arg); | 2507 builder()->StoreAccumulatorInRegister(ith_arg); |
2496 DCHECK(ith_arg.index() - i == first_arg.index()); | 2508 DCHECK(ith_arg.index() - i == first_arg.index()); |
2497 } | 2509 } |
2498 return first_arg; | 2510 return first_arg; |
2499 } | 2511 } |
2500 | 2512 |
2501 void BytecodeGenerator::VisitCall(Call* expr) { | 2513 void BytecodeGenerator::VisitCall(Call* expr) { |
2502 Expression* callee_expr = expr->expression(); | 2514 Expression* callee_expr = expr->expression(); |
2503 Call::CallType call_type = expr->GetCallType(isolate()); | 2515 Call::CallType call_type = |
| 2516 expr->GetCallType(isolate(), HandleDereferenceMode::kDisallowed); |
2504 | 2517 |
2505 if (call_type == Call::SUPER_CALL) { | 2518 if (call_type == Call::SUPER_CALL) { |
2506 return VisitCallSuper(expr); | 2519 return VisitCallSuper(expr); |
2507 } | 2520 } |
2508 | 2521 |
2509 // Prepare the callee and the receiver to the function call. This depends on | 2522 // Prepare the callee and the receiver to the function call. This depends on |
2510 // the semantics of the underlying call type. | 2523 // the semantics of the underlying call type. |
2511 | 2524 |
2512 // The receiver and arguments need to be allocated consecutively for | 2525 // The receiver and arguments need to be allocated consecutively for |
2513 // Call(). We allocate the callee and receiver consecutively for calls to | 2526 // Call(). We allocate the callee and receiver consecutively for calls to |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 // and strict modes. | 2771 // and strict modes. |
2759 Property* property = expr->expression()->AsProperty(); | 2772 Property* property = expr->expression()->AsProperty(); |
2760 Register object = VisitForRegisterValue(property->obj()); | 2773 Register object = VisitForRegisterValue(property->obj()); |
2761 VisitForAccumulatorValue(property->key()); | 2774 VisitForAccumulatorValue(property->key()); |
2762 builder()->Delete(object, language_mode()); | 2775 builder()->Delete(object, language_mode()); |
2763 } else if (expr->expression()->IsVariableProxy()) { | 2776 } else if (expr->expression()->IsVariableProxy()) { |
2764 // Delete of an unqualified identifier is allowed in sloppy mode but is | 2777 // Delete of an unqualified identifier is allowed in sloppy mode but is |
2765 // not allowed in strict mode. Deleting 'this' is allowed in both modes. | 2778 // not allowed in strict mode. Deleting 'this' is allowed in both modes. |
2766 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2779 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
2767 Variable* variable = proxy->var(); | 2780 Variable* variable = proxy->var(); |
2768 DCHECK(is_sloppy(language_mode()) || variable->HasThisName(isolate())); | 2781 DCHECK( |
| 2782 is_sloppy(language_mode()) || |
| 2783 variable->HasThisName(isolate(), HandleDereferenceMode::kDisallowed)); |
2769 switch (variable->location()) { | 2784 switch (variable->location()) { |
2770 case VariableLocation::GLOBAL: | 2785 case VariableLocation::GLOBAL: |
2771 case VariableLocation::UNALLOCATED: { | 2786 case VariableLocation::UNALLOCATED: { |
2772 // Global var, let, const or variables not explicitly declared. | 2787 // Global var, let, const or variables not explicitly declared. |
2773 Register native_context = register_allocator()->NewRegister(); | 2788 Register native_context = register_allocator()->NewRegister(); |
2774 Register global_object = register_allocator()->NewRegister(); | 2789 Register global_object = register_allocator()->NewRegister(); |
2775 builder() | 2790 builder() |
2776 ->LoadContextSlot(execution_context()->reg(), | 2791 ->LoadContextSlot(execution_context()->reg(), |
2777 Context::NATIVE_CONTEXT_INDEX) | 2792 Context::NATIVE_CONTEXT_INDEX) |
2778 .StoreAccumulatorInRegister(native_context) | 2793 .StoreAccumulatorInRegister(native_context) |
2779 .LoadContextSlot(native_context, Context::EXTENSION_INDEX) | 2794 .LoadContextSlot(native_context, Context::EXTENSION_INDEX) |
2780 .StoreAccumulatorInRegister(global_object) | 2795 .StoreAccumulatorInRegister(global_object) |
2781 .LoadLiteral(variable->name()) | 2796 .LoadLiteral(variable->name()) |
2782 .Delete(global_object, language_mode()); | 2797 .Delete(global_object, language_mode()); |
2783 break; | 2798 break; |
2784 } | 2799 } |
2785 case VariableLocation::PARAMETER: | 2800 case VariableLocation::PARAMETER: |
2786 case VariableLocation::LOCAL: | 2801 case VariableLocation::LOCAL: |
2787 case VariableLocation::CONTEXT: { | 2802 case VariableLocation::CONTEXT: { |
2788 // Deleting local var/let/const, context variables, and arguments | 2803 // Deleting local var/let/const, context variables, and arguments |
2789 // does not have any effect. | 2804 // does not have any effect. |
2790 if (variable->HasThisName(isolate())) { | 2805 if (variable->HasThisName(isolate(), |
| 2806 HandleDereferenceMode::kDisallowed)) { |
2791 builder()->LoadTrue(); | 2807 builder()->LoadTrue(); |
2792 } else { | 2808 } else { |
2793 builder()->LoadFalse(); | 2809 builder()->LoadFalse(); |
2794 } | 2810 } |
2795 break; | 2811 break; |
2796 } | 2812 } |
2797 case VariableLocation::LOOKUP: { | 2813 case VariableLocation::LOOKUP: { |
2798 Register name_reg = register_allocator()->NewRegister(); | 2814 Register name_reg = register_allocator()->NewRegister(); |
2799 builder() | 2815 builder() |
2800 ->LoadLiteral(variable->name()) | 2816 ->LoadLiteral(variable->name()) |
(...skipping 10 matching lines...) Expand all Loading... |
2811 builder()->LoadTrue(); | 2827 builder()->LoadTrue(); |
2812 } | 2828 } |
2813 execution_result()->SetResultInAccumulator(); | 2829 execution_result()->SetResultInAccumulator(); |
2814 } | 2830 } |
2815 | 2831 |
2816 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { | 2832 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { |
2817 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis()); | 2833 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis()); |
2818 | 2834 |
2819 // Left-hand side can only be a property, a global or a variable slot. | 2835 // Left-hand side can only be a property, a global or a variable slot. |
2820 Property* property = expr->expression()->AsProperty(); | 2836 Property* property = expr->expression()->AsProperty(); |
2821 LhsKind assign_type = Property::GetAssignType(property); | 2837 LhsKind assign_type = |
| 2838 Property::GetAssignType(property, HandleDereferenceMode::kDisallowed); |
2822 | 2839 |
2823 bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect(); | 2840 bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect(); |
2824 | 2841 |
2825 // Evaluate LHS expression and get old value. | 2842 // Evaluate LHS expression and get old value. |
2826 Register object, home_object, key, old_value, value; | 2843 Register object, home_object, key, old_value, value; |
2827 Handle<String> name; | 2844 Handle<String> name; |
2828 switch (assign_type) { | 2845 switch (assign_type) { |
2829 case VARIABLE: { | 2846 case VARIABLE: { |
2830 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2847 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
2831 VisitVariableLoadForAccumulatorValue(proxy->var(), | 2848 VisitVariableLoadForAccumulatorValue(proxy->var(), |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3028 VisitForAccumulatorValue(right); | 3045 VisitForAccumulatorValue(right); |
3029 builder()->Bind(&end_label); | 3046 builder()->Bind(&end_label); |
3030 } | 3047 } |
3031 execution_result()->SetResultInAccumulator(); | 3048 execution_result()->SetResultInAccumulator(); |
3032 } | 3049 } |
3033 | 3050 |
3034 void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) { | 3051 void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) { |
3035 Visit(expr->expression()); | 3052 Visit(expr->expression()); |
3036 } | 3053 } |
3037 | 3054 |
| 3055 namespace { |
| 3056 |
| 3057 Handle<ScopeInfo> GetScopeInfo(Scope* scope, Isolate* isolate) { |
| 3058 // TODO(5203): Remove this temporary exception. |
| 3059 AllowHeapAllocation allow_allocation; |
| 3060 AllowHandleAllocation allow_handles; |
| 3061 AllowHandleDereference allow_deref; |
| 3062 return scope->GetScopeInfo(isolate); |
| 3063 } |
| 3064 |
| 3065 } // namespace |
| 3066 |
3038 void BytecodeGenerator::VisitNewLocalFunctionContext() { | 3067 void BytecodeGenerator::VisitNewLocalFunctionContext() { |
3039 AccumulatorResultScope accumulator_execution_result(this); | 3068 AccumulatorResultScope accumulator_execution_result(this); |
3040 Scope* scope = this->scope(); | 3069 Scope* scope = this->scope(); |
3041 | 3070 |
3042 // Allocate a new local context. | 3071 // Allocate a new local context. |
3043 if (scope->is_script_scope()) { | 3072 if (scope->is_script_scope()) { |
3044 RegisterAllocationScope register_scope(this); | 3073 RegisterAllocationScope register_scope(this); |
3045 Register closure = register_allocator()->NewRegister(); | 3074 Register closure = register_allocator()->NewRegister(); |
3046 Register scope_info = register_allocator()->NewRegister(); | 3075 Register scope_info = register_allocator()->NewRegister(); |
3047 DCHECK(Register::AreContiguous(closure, scope_info)); | 3076 DCHECK(Register::AreContiguous(closure, scope_info)); |
3048 builder() | 3077 builder() |
3049 ->LoadAccumulatorWithRegister(Register::function_closure()) | 3078 ->LoadAccumulatorWithRegister(Register::function_closure()) |
3050 .StoreAccumulatorInRegister(closure) | 3079 .StoreAccumulatorInRegister(closure) |
3051 .LoadLiteral(scope->GetScopeInfo(isolate())) | 3080 .LoadLiteral(GetScopeInfo(scope, isolate())) |
3052 .StoreAccumulatorInRegister(scope_info) | 3081 .StoreAccumulatorInRegister(scope_info) |
3053 .CallRuntime(Runtime::kNewScriptContext, closure, 2); | 3082 .CallRuntime(Runtime::kNewScriptContext, closure, 2); |
3054 } else { | 3083 } else { |
3055 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 3084 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
3056 builder()->CreateFunctionContext(slot_count); | 3085 builder()->CreateFunctionContext(slot_count); |
3057 } | 3086 } |
3058 execution_result()->SetResultInAccumulator(); | 3087 execution_result()->SetResultInAccumulator(); |
3059 } | 3088 } |
3060 | 3089 |
3061 void BytecodeGenerator::VisitBuildLocalActivationContext() { | 3090 void BytecodeGenerator::VisitBuildLocalActivationContext() { |
(...skipping 27 matching lines...) Expand all Loading... |
3089 void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { | 3118 void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { |
3090 AccumulatorResultScope accumulator_execution_result(this); | 3119 AccumulatorResultScope accumulator_execution_result(this); |
3091 DCHECK(scope->is_block_scope()); | 3120 DCHECK(scope->is_block_scope()); |
3092 | 3121 |
3093 // Allocate a new local block context. | 3122 // Allocate a new local block context. |
3094 register_allocator()->PrepareForConsecutiveAllocations(2); | 3123 register_allocator()->PrepareForConsecutiveAllocations(2); |
3095 Register scope_info = register_allocator()->NextConsecutiveRegister(); | 3124 Register scope_info = register_allocator()->NextConsecutiveRegister(); |
3096 Register closure = register_allocator()->NextConsecutiveRegister(); | 3125 Register closure = register_allocator()->NextConsecutiveRegister(); |
3097 | 3126 |
3098 builder() | 3127 builder() |
3099 ->LoadLiteral(scope->GetScopeInfo(isolate())) | 3128 ->LoadLiteral(GetScopeInfo(scope, isolate())) |
3100 .StoreAccumulatorInRegister(scope_info); | 3129 .StoreAccumulatorInRegister(scope_info); |
3101 VisitFunctionClosureForContext(); | 3130 VisitFunctionClosureForContext(); |
3102 builder() | 3131 builder() |
3103 ->StoreAccumulatorInRegister(closure) | 3132 ->StoreAccumulatorInRegister(closure) |
3104 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2); | 3133 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2); |
3105 execution_result()->SetResultInAccumulator(); | 3134 execution_result()->SetResultInAccumulator(); |
3106 } | 3135 } |
3107 | 3136 |
3108 void BytecodeGenerator::VisitNewLocalWithContext() { | 3137 void BytecodeGenerator::VisitNewLocalWithContext() { |
3109 AccumulatorResultScope accumulator_execution_result(this); | 3138 AccumulatorResultScope accumulator_execution_result(this); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3280 return execution_context()->scope()->language_mode(); | 3309 return execution_context()->scope()->language_mode(); |
3281 } | 3310 } |
3282 | 3311 |
3283 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3312 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3284 return TypeFeedbackVector::GetIndex(slot); | 3313 return TypeFeedbackVector::GetIndex(slot); |
3285 } | 3314 } |
3286 | 3315 |
3287 } // namespace interpreter | 3316 } // namespace interpreter |
3288 } // namespace internal | 3317 } // namespace internal |
3289 } // namespace v8 | 3318 } // namespace v8 |
OLD | NEW |