Chromium Code Reviews| 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 BytecodeLabels* else_labels_; | 593 BytecodeLabels* else_labels_; |
| 594 TestFallthrough fallthrough_; | 594 TestFallthrough fallthrough_; |
| 595 bool result_consumed_by_test_; | 595 bool result_consumed_by_test_; |
| 596 | 596 |
| 597 DISALLOW_COPY_AND_ASSIGN(TestResultScope); | 597 DISALLOW_COPY_AND_ASSIGN(TestResultScope); |
| 598 }; | 598 }; |
| 599 | 599 |
| 600 // Used to build a list of global declaration initial value pairs. | 600 // Used to build a list of global declaration initial value pairs. |
| 601 class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject { | 601 class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject { |
| 602 public: | 602 public: |
| 603 GlobalDeclarationsBuilder(Isolate* isolate, Zone* zone) | 603 explicit GlobalDeclarationsBuilder(Zone* zone) |
| 604 : isolate_(isolate), | 604 : declarations_(0, zone), |
| 605 declarations_(0, zone), | |
| 606 constant_pool_entry_(0), | 605 constant_pool_entry_(0), |
| 607 has_constant_pool_entry_(false) {} | 606 has_constant_pool_entry_(false) {} |
| 608 | 607 |
| 609 void AddFunctionDeclaration(FeedbackVectorSlot slot, FunctionLiteral* func) { | 608 void AddFunctionDeclaration(FeedbackVectorSlot slot, FunctionLiteral* func) { |
| 610 DCHECK(!slot.IsInvalid()); | 609 DCHECK(!slot.IsInvalid()); |
| 611 declarations_.push_back(std::make_pair(slot, func)); | 610 declarations_.push_back(std::make_pair(slot, func)); |
| 612 } | 611 } |
| 613 | 612 |
| 614 void AddUndefinedDeclaration(FeedbackVectorSlot slot) { | 613 void AddUndefinedDeclaration(FeedbackVectorSlot slot) { |
| 615 DCHECK(!slot.IsInvalid()); | 614 DCHECK(!slot.IsInvalid()); |
| 616 declarations_.push_back(std::make_pair(slot, nullptr)); | 615 declarations_.push_back(std::make_pair(slot, nullptr)); |
| 617 } | 616 } |
| 618 | 617 |
| 619 Handle<FixedArray> AllocateDeclarationPairs(CompilationInfo* info) { | 618 Handle<FixedArray> AllocateDeclarationPairs(CompilationInfo* info) { |
| 620 DCHECK(has_constant_pool_entry_); | 619 DCHECK(has_constant_pool_entry_); |
| 621 int array_index = 0; | 620 int array_index = 0; |
| 622 Handle<FixedArray> pairs = isolate_->factory()->NewFixedArray( | 621 Handle<FixedArray> pairs = info->isolate()->factory()->NewFixedArray( |
| 623 static_cast<int>(declarations_.size() * 2), TENURED); | 622 static_cast<int>(declarations_.size() * 2), TENURED); |
| 624 for (std::pair<FeedbackVectorSlot, FunctionLiteral*> declaration : | 623 for (std::pair<FeedbackVectorSlot, FunctionLiteral*> declaration : |
| 625 declarations_) { | 624 declarations_) { |
| 626 FunctionLiteral* func = declaration.second; | 625 FunctionLiteral* func = declaration.second; |
| 627 Handle<Object> initial_value; | 626 Handle<Object> initial_value; |
| 628 if (func == nullptr) { | 627 if (func == nullptr) { |
| 629 initial_value = isolate_->factory()->undefined_value(); | 628 initial_value = info->isolate()->factory()->undefined_value(); |
| 630 } else { | 629 } else { |
| 631 initial_value = | 630 initial_value = |
| 632 Compiler::GetSharedFunctionInfo(func, info->script(), info); | 631 Compiler::GetSharedFunctionInfo(func, info->script(), info); |
| 633 } | 632 } |
| 634 | 633 |
| 635 // Return a null handle if any initial values can't be created. Caller | 634 // Return a null handle if any initial values can't be created. Caller |
| 636 // will set stack overflow. | 635 // will set stack overflow. |
| 637 if (initial_value.is_null()) return Handle<FixedArray>(); | 636 if (initial_value.is_null()) return Handle<FixedArray>(); |
| 638 | 637 |
| 639 pairs->set(array_index++, Smi::FromInt(declaration.first.ToInt())); | 638 pairs->set(array_index++, Smi::FromInt(declaration.first.ToInt())); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 650 void set_constant_pool_entry(size_t constant_pool_entry) { | 649 void set_constant_pool_entry(size_t constant_pool_entry) { |
| 651 DCHECK(!empty()); | 650 DCHECK(!empty()); |
| 652 DCHECK(!has_constant_pool_entry_); | 651 DCHECK(!has_constant_pool_entry_); |
| 653 constant_pool_entry_ = constant_pool_entry; | 652 constant_pool_entry_ = constant_pool_entry; |
| 654 has_constant_pool_entry_ = true; | 653 has_constant_pool_entry_ = true; |
| 655 } | 654 } |
| 656 | 655 |
| 657 bool empty() { return declarations_.empty(); } | 656 bool empty() { return declarations_.empty(); } |
| 658 | 657 |
| 659 private: | 658 private: |
| 660 Isolate* isolate_; | |
| 661 ZoneVector<std::pair<FeedbackVectorSlot, FunctionLiteral*>> declarations_; | 659 ZoneVector<std::pair<FeedbackVectorSlot, FunctionLiteral*>> declarations_; |
| 662 size_t constant_pool_entry_; | 660 size_t constant_pool_entry_; |
| 663 bool has_constant_pool_entry_; | 661 bool has_constant_pool_entry_; |
| 664 }; | 662 }; |
| 665 | 663 |
| 664 class DisallowIsolateAccessScope { | |
|
Michael Starzinger
2016/08/16 09:10:22
Just for my own clarification mostly: How much wor
rmcilroy
2016/08/16 11:24:54
That works, done.
| |
| 665 public: | |
| 666 explicit DisallowIsolateAccessScope(BytecodeGenerator* generator) | |
| 667 : generator_(generator), previous_(generator->isolate_access_allowed()) { | |
| 668 generator_->set_isolate_access_allowed(false); | |
| 669 } | |
| 670 | |
| 671 ~DisallowIsolateAccessScope() { | |
| 672 generator_->set_isolate_access_allowed(previous_); | |
| 673 } | |
| 674 | |
| 675 private: | |
| 676 BytecodeGenerator* generator_; | |
| 677 bool previous_; | |
| 678 }; | |
| 679 | |
| 666 BytecodeGenerator::BytecodeGenerator(CompilationInfo* info) | 680 BytecodeGenerator::BytecodeGenerator(CompilationInfo* info) |
| 667 : isolate_(info->isolate()), | 681 : isolate_(info->isolate()), |
| 668 zone_(info->zone()), | 682 zone_(info->zone()), |
| 669 builder_(new (zone()) BytecodeArrayBuilder( | 683 builder_(new (zone()) BytecodeArrayBuilder( |
| 670 info->isolate(), info->zone(), info->num_parameters_including_this(), | 684 info->isolate(), info->zone(), info->num_parameters_including_this(), |
| 671 info->scope()->MaxNestedContextChainLength(), | 685 info->scope()->MaxNestedContextChainLength(), |
| 672 info->scope()->num_stack_slots(), info->literal(), | 686 info->scope()->num_stack_slots(), info->literal(), |
| 673 info->SourcePositionRecordingMode())), | 687 info->SourcePositionRecordingMode())), |
| 674 info_(info), | 688 info_(info), |
| 675 scope_(info->scope()), | 689 scope_(info->scope()), |
| 676 globals_builder_(new (zone()) GlobalDeclarationsBuilder(info->isolate(), | 690 isolate_access_allowed_(true), |
| 677 info->zone())), | 691 globals_builder_(new (zone()) GlobalDeclarationsBuilder(info->zone())), |
| 678 global_declarations_(0, info->zone()), | 692 global_declarations_(0, info->zone()), |
| 679 function_literals_(0, info->zone()), | 693 function_literals_(0, info->zone()), |
| 680 native_function_literals_(0, info->zone()), | 694 native_function_literals_(0, info->zone()), |
| 681 execution_control_(nullptr), | 695 execution_control_(nullptr), |
| 682 execution_context_(nullptr), | 696 execution_context_(nullptr), |
| 683 execution_result_(nullptr), | 697 execution_result_(nullptr), |
| 684 register_allocator_(nullptr), | 698 register_allocator_(nullptr), |
| 685 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 699 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
| 686 generator_state_(), | 700 generator_state_(), |
| 687 loop_depth_(0) { | 701 loop_depth_(0), |
| 702 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), | |
| 703 prototype_string_(info->isolate()->factory()->prototype_string()) { | |
| 688 InitializeAstVisitor(isolate()->stack_guard()->real_climit()); | 704 InitializeAstVisitor(isolate()->stack_guard()->real_climit()); |
| 689 } | 705 } |
| 690 | 706 |
| 691 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() { | 707 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() { |
| 692 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles | 708 // Create an inner HandleScope to avoid unnecessarily canonicalizing handles |
| 693 // created as part of bytecode finalization. | 709 // created as part of bytecode finalization. |
| 694 HandleScope scope(isolate()); | 710 HandleScope scope(isolate()); |
| 695 | 711 |
| 696 GenerateBytecode(); | 712 GenerateBytecode(); |
| 697 FinalizeBytecode(); | 713 FinalizeBytecode(); |
| 698 | 714 |
| 699 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 715 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
| 700 | 716 |
| 701 return scope.CloseAndEscape(builder()->ToBytecodeArray()); | 717 return scope.CloseAndEscape(builder()->ToBytecodeArray(isolate())); |
| 702 } | 718 } |
| 703 | 719 |
| 704 void BytecodeGenerator::FinalizeBytecode() { | 720 void BytecodeGenerator::FinalizeBytecode() { |
| 705 // Build global declaration pair arrays. | 721 // Build global declaration pair arrays. |
| 706 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { | 722 for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) { |
| 707 Handle<FixedArray> declarations = | 723 Handle<FixedArray> declarations = |
| 708 globals_builder->AllocateDeclarationPairs(info()); | 724 globals_builder->AllocateDeclarationPairs(info()); |
| 709 if (declarations.is_null()) return SetStackOverflow(); | 725 if (declarations.is_null()) return SetStackOverflow(); |
| 710 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), | 726 builder()->InsertConstantPoolEntryAt(globals_builder->constant_pool_entry(), |
| 711 declarations); | 727 declarations); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 729 expr->name()); | 745 expr->name()); |
| 730 if (shared_info.is_null()) return SetStackOverflow(); | 746 if (shared_info.is_null()) return SetStackOverflow(); |
| 731 builder()->InsertConstantPoolEntryAt(literal.second, shared_info); | 747 builder()->InsertConstantPoolEntryAt(literal.second, shared_info); |
| 732 } | 748 } |
| 733 } | 749 } |
| 734 | 750 |
| 735 void BytecodeGenerator::GenerateBytecode() { | 751 void BytecodeGenerator::GenerateBytecode() { |
| 736 DisallowHeapAllocation no_allocation; | 752 DisallowHeapAllocation no_allocation; |
| 737 DisallowHandleAllocation no_handles; | 753 DisallowHandleAllocation no_handles; |
| 738 DisallowHandleDereference no_deref; | 754 DisallowHandleDereference no_deref; |
| 755 DisallowIsolateAccessScope no_isolate(this); | |
| 739 | 756 |
| 740 // Initialize the incoming context. | 757 // Initialize the incoming context. |
| 741 ContextScope incoming_context(this, scope(), false); | 758 ContextScope incoming_context(this, scope(), false); |
| 742 | 759 |
| 743 // Initialize control scope. | 760 // Initialize control scope. |
| 744 ControlScopeForTopLevel control(this); | 761 ControlScopeForTopLevel control(this); |
| 745 | 762 |
| 746 RegisterAllocationScope register_scope(this); | 763 RegisterAllocationScope register_scope(this); |
| 747 | 764 |
| 748 if (IsResumableFunction(info()->literal()->kind())) { | 765 if (IsResumableFunction(info()->literal()->kind())) { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 builder() | 1032 builder() |
| 1016 ->LoadConstantPoolEntry(globals_builder()->constant_pool_entry()) | 1033 ->LoadConstantPoolEntry(globals_builder()->constant_pool_entry()) |
| 1017 .StoreAccumulatorInRegister(pairs) | 1034 .StoreAccumulatorInRegister(pairs) |
| 1018 .LoadLiteral(Smi::FromInt(encoded_flags)) | 1035 .LoadLiteral(Smi::FromInt(encoded_flags)) |
| 1019 .StoreAccumulatorInRegister(flags) | 1036 .StoreAccumulatorInRegister(flags) |
| 1020 .MoveRegister(Register::function_closure(), function) | 1037 .MoveRegister(Register::function_closure(), function) |
| 1021 .CallRuntime(Runtime::kDeclareGlobalsForInterpreter, pairs, 3); | 1038 .CallRuntime(Runtime::kDeclareGlobalsForInterpreter, pairs, 3); |
| 1022 | 1039 |
| 1023 // Push and reset globals builder. | 1040 // Push and reset globals builder. |
| 1024 global_declarations_.push_back(globals_builder()); | 1041 global_declarations_.push_back(globals_builder()); |
| 1025 globals_builder_ = new (zone()) GlobalDeclarationsBuilder(isolate(), zone()); | 1042 globals_builder_ = new (zone()) GlobalDeclarationsBuilder(zone()); |
| 1026 } | 1043 } |
| 1027 | 1044 |
| 1028 void BytecodeGenerator::VisitStatements(ZoneList<Statement*>* statements) { | 1045 void BytecodeGenerator::VisitStatements(ZoneList<Statement*>* statements) { |
| 1029 for (int i = 0; i < statements->length(); i++) { | 1046 for (int i = 0; i < statements->length(); i++) { |
| 1030 // Allocate an outer register allocations scope for the statement. | 1047 // Allocate an outer register allocations scope for the statement. |
| 1031 RegisterAllocationScope allocation_scope(this); | 1048 RegisterAllocationScope allocation_scope(this); |
| 1032 Statement* stmt = statements->at(i); | 1049 Statement* stmt = statements->at(i); |
| 1033 Visit(stmt); | 1050 Visit(stmt); |
| 1034 if (stmt->IsJump()) break; | 1051 if (stmt->IsJump()) break; |
| 1035 } | 1052 } |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1487 execution_result()->SetResultInAccumulator(); | 1504 execution_result()->SetResultInAccumulator(); |
| 1488 } | 1505 } |
| 1489 | 1506 |
| 1490 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { | 1507 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { |
| 1491 VisitClassLiteralForRuntimeDefinition(expr); | 1508 VisitClassLiteralForRuntimeDefinition(expr); |
| 1492 | 1509 |
| 1493 // Load the "prototype" from the constructor. | 1510 // Load the "prototype" from the constructor. |
| 1494 register_allocator()->PrepareForConsecutiveAllocations(2); | 1511 register_allocator()->PrepareForConsecutiveAllocations(2); |
| 1495 Register literal = register_allocator()->NextConsecutiveRegister(); | 1512 Register literal = register_allocator()->NextConsecutiveRegister(); |
| 1496 Register prototype = register_allocator()->NextConsecutiveRegister(); | 1513 Register prototype = register_allocator()->NextConsecutiveRegister(); |
| 1497 Handle<String> name = isolate()->factory()->prototype_string(); | |
| 1498 FeedbackVectorSlot slot = expr->PrototypeSlot(); | 1514 FeedbackVectorSlot slot = expr->PrototypeSlot(); |
| 1499 builder() | 1515 builder() |
| 1500 ->StoreAccumulatorInRegister(literal) | 1516 ->StoreAccumulatorInRegister(literal) |
| 1501 .LoadNamedProperty(literal, name, feedback_index(slot)) | 1517 .LoadNamedProperty(literal, prototype_string(), feedback_index(slot)) |
| 1502 .StoreAccumulatorInRegister(prototype); | 1518 .StoreAccumulatorInRegister(prototype); |
| 1503 | 1519 |
| 1504 VisitClassLiteralProperties(expr, literal, prototype); | 1520 VisitClassLiteralProperties(expr, literal, prototype); |
| 1505 builder()->CallRuntime(Runtime::kToFastProperties, literal, 1); | 1521 builder()->CallRuntime(Runtime::kToFastProperties, literal, 1); |
| 1506 // Assign to class variable. | 1522 // Assign to class variable. |
| 1507 if (expr->class_variable_proxy() != nullptr) { | 1523 if (expr->class_variable_proxy() != nullptr) { |
| 1508 Variable* var = expr->class_variable_proxy()->var(); | 1524 Variable* var = expr->class_variable_proxy()->var(); |
| 1509 FeedbackVectorSlot slot = expr->NeedsProxySlot() | 1525 FeedbackVectorSlot slot = expr->NeedsProxySlot() |
| 1510 ? expr->ProxySlot() | 1526 ? expr->ProxySlot() |
| 1511 : FeedbackVectorSlot::Invalid(); | 1527 : FeedbackVectorSlot::Invalid(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1609 break; | 1625 break; |
| 1610 } | 1626 } |
| 1611 } | 1627 } |
| 1612 } | 1628 } |
| 1613 } | 1629 } |
| 1614 | 1630 |
| 1615 void BytecodeGenerator::VisitClassLiteralStaticPrototypeWithComputedName( | 1631 void BytecodeGenerator::VisitClassLiteralStaticPrototypeWithComputedName( |
| 1616 Register key) { | 1632 Register key) { |
| 1617 BytecodeLabel done; | 1633 BytecodeLabel done; |
| 1618 builder() | 1634 builder() |
| 1619 ->LoadLiteral(isolate()->factory()->prototype_string()) | 1635 ->LoadLiteral(prototype_string()) |
| 1620 .CompareOperation(Token::Value::EQ_STRICT, key) | 1636 .CompareOperation(Token::Value::EQ_STRICT, key) |
| 1621 .JumpIfFalse(&done) | 1637 .JumpIfFalse(&done) |
| 1622 .CallRuntime(Runtime::kThrowStaticPrototypeError, Register(0), 0) | 1638 .CallRuntime(Runtime::kThrowStaticPrototypeError, Register(0), 0) |
| 1623 .Bind(&done); | 1639 .Bind(&done); |
| 1624 } | 1640 } |
| 1625 | 1641 |
| 1626 void BytecodeGenerator::VisitNativeFunctionLiteral( | 1642 void BytecodeGenerator::VisitNativeFunctionLiteral( |
| 1627 NativeFunctionLiteral* expr) { | 1643 NativeFunctionLiteral* expr) { |
| 1628 size_t entry = builder()->AllocateConstantPoolEntry(); | 1644 size_t entry = builder()->AllocateConstantPoolEntry(); |
| 1629 builder()->CreateClosure(entry, NOT_TENURED); | 1645 builder()->CreateClosure(entry, NOT_TENURED); |
| (...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3162 | 3178 |
| 3163 // Allocate a new local context. | 3179 // Allocate a new local context. |
| 3164 if (scope->is_script_scope()) { | 3180 if (scope->is_script_scope()) { |
| 3165 RegisterAllocationScope register_scope(this); | 3181 RegisterAllocationScope register_scope(this); |
| 3166 Register closure = register_allocator()->NewRegister(); | 3182 Register closure = register_allocator()->NewRegister(); |
| 3167 Register scope_info = register_allocator()->NewRegister(); | 3183 Register scope_info = register_allocator()->NewRegister(); |
| 3168 DCHECK(Register::AreContiguous(closure, scope_info)); | 3184 DCHECK(Register::AreContiguous(closure, scope_info)); |
| 3169 builder() | 3185 builder() |
| 3170 ->LoadAccumulatorWithRegister(Register::function_closure()) | 3186 ->LoadAccumulatorWithRegister(Register::function_closure()) |
| 3171 .StoreAccumulatorInRegister(closure) | 3187 .StoreAccumulatorInRegister(closure) |
| 3172 .LoadLiteral(scope->GetScopeInfo(isolate())) | 3188 .LoadLiteral(scope->scope_info()) |
| 3173 .StoreAccumulatorInRegister(scope_info) | 3189 .StoreAccumulatorInRegister(scope_info) |
| 3174 .CallRuntime(Runtime::kNewScriptContext, closure, 2); | 3190 .CallRuntime(Runtime::kNewScriptContext, closure, 2); |
| 3175 } else { | 3191 } else { |
| 3176 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 3192 int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 3177 builder()->CreateFunctionContext(slot_count); | 3193 builder()->CreateFunctionContext(slot_count); |
| 3178 } | 3194 } |
| 3179 execution_result()->SetResultInAccumulator(); | 3195 execution_result()->SetResultInAccumulator(); |
| 3180 } | 3196 } |
| 3181 | 3197 |
| 3182 void BytecodeGenerator::VisitBuildLocalActivationContext() { | 3198 void BytecodeGenerator::VisitBuildLocalActivationContext() { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 3210 void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { | 3226 void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) { |
| 3211 AccumulatorResultScope accumulator_execution_result(this); | 3227 AccumulatorResultScope accumulator_execution_result(this); |
| 3212 DCHECK(scope->is_block_scope()); | 3228 DCHECK(scope->is_block_scope()); |
| 3213 | 3229 |
| 3214 // Allocate a new local block context. | 3230 // Allocate a new local block context. |
| 3215 register_allocator()->PrepareForConsecutiveAllocations(2); | 3231 register_allocator()->PrepareForConsecutiveAllocations(2); |
| 3216 Register scope_info = register_allocator()->NextConsecutiveRegister(); | 3232 Register scope_info = register_allocator()->NextConsecutiveRegister(); |
| 3217 Register closure = register_allocator()->NextConsecutiveRegister(); | 3233 Register closure = register_allocator()->NextConsecutiveRegister(); |
| 3218 | 3234 |
| 3219 builder() | 3235 builder() |
| 3220 ->LoadLiteral(scope->GetScopeInfo(isolate())) | 3236 ->LoadLiteral(scope->scope_info()) |
| 3221 .StoreAccumulatorInRegister(scope_info); | 3237 .StoreAccumulatorInRegister(scope_info); |
| 3222 VisitFunctionClosureForContext(); | 3238 VisitFunctionClosureForContext(); |
| 3223 builder() | 3239 builder() |
| 3224 ->StoreAccumulatorInRegister(closure) | 3240 ->StoreAccumulatorInRegister(closure) |
| 3225 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2); | 3241 .CallRuntime(Runtime::kPushBlockContext, scope_info, 2); |
| 3226 execution_result()->SetResultInAccumulator(); | 3242 execution_result()->SetResultInAccumulator(); |
| 3227 } | 3243 } |
| 3228 | 3244 |
| 3229 void BytecodeGenerator::VisitNewLocalWithContext() { | 3245 void BytecodeGenerator::VisitNewLocalWithContext() { |
| 3230 AccumulatorResultScope accumulator_execution_result(this); | 3246 AccumulatorResultScope accumulator_execution_result(this); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3270 builder()->StoreAccumulatorInRegister(value_out); | 3286 builder()->StoreAccumulatorInRegister(value_out); |
| 3271 VisitSetHomeObject(value_out, home_object, property); | 3287 VisitSetHomeObject(value_out, home_object, property); |
| 3272 } | 3288 } |
| 3273 } | 3289 } |
| 3274 | 3290 |
| 3275 void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object, | 3291 void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object, |
| 3276 ObjectLiteralProperty* property, | 3292 ObjectLiteralProperty* property, |
| 3277 int slot_number) { | 3293 int slot_number) { |
| 3278 Expression* expr = property->value(); | 3294 Expression* expr = property->value(); |
| 3279 if (FunctionLiteral::NeedsHomeObject(expr)) { | 3295 if (FunctionLiteral::NeedsHomeObject(expr)) { |
| 3280 Handle<Name> name = isolate()->factory()->home_object_symbol(); | |
| 3281 FeedbackVectorSlot slot = property->GetSlot(slot_number); | 3296 FeedbackVectorSlot slot = property->GetSlot(slot_number); |
| 3282 builder() | 3297 builder() |
| 3283 ->LoadAccumulatorWithRegister(home_object) | 3298 ->LoadAccumulatorWithRegister(home_object) |
| 3284 .StoreNamedProperty(value, name, feedback_index(slot), language_mode()); | 3299 .StoreNamedProperty(value, home_object_symbol(), feedback_index(slot), |
| 3300 language_mode()); | |
| 3285 } | 3301 } |
| 3286 } | 3302 } |
| 3287 | 3303 |
| 3288 void BytecodeGenerator::VisitArgumentsObject(Variable* variable) { | 3304 void BytecodeGenerator::VisitArgumentsObject(Variable* variable) { |
| 3289 if (variable == nullptr) return; | 3305 if (variable == nullptr) return; |
| 3290 | 3306 |
| 3291 DCHECK(variable->IsContextSlot() || variable->IsStackAllocated()); | 3307 DCHECK(variable->IsContextSlot() || variable->IsStackAllocated()); |
| 3292 | 3308 |
| 3293 // Allocate and initialize a new arguments object and assign to the | 3309 // Allocate and initialize a new arguments object and assign to the |
| 3294 // {arguments} variable. | 3310 // {arguments} variable. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3431 return execution_context()->scope()->language_mode(); | 3447 return execution_context()->scope()->language_mode(); |
| 3432 } | 3448 } |
| 3433 | 3449 |
| 3434 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3450 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3435 return TypeFeedbackVector::GetIndex(slot); | 3451 return TypeFeedbackVector::GetIndex(slot); |
| 3436 } | 3452 } |
| 3437 | 3453 |
| 3438 } // namespace interpreter | 3454 } // namespace interpreter |
| 3439 } // namespace internal | 3455 } // namespace internal |
| 3440 } // namespace v8 | 3456 } // namespace v8 |
| OLD | NEW |