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/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 global_declarations_(0, info->zone()), | 628 global_declarations_(0, info->zone()), |
629 function_literals_(0, info->zone()), | 629 function_literals_(0, info->zone()), |
630 native_function_literals_(0, info->zone()), | 630 native_function_literals_(0, info->zone()), |
631 object_literals_(0, info->zone()), | 631 object_literals_(0, info->zone()), |
632 array_literals_(0, info->zone()), | 632 array_literals_(0, info->zone()), |
633 execution_control_(nullptr), | 633 execution_control_(nullptr), |
634 execution_context_(nullptr), | 634 execution_context_(nullptr), |
635 execution_result_(nullptr), | 635 execution_result_(nullptr), |
636 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 636 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
637 generator_state_(), | 637 generator_state_(), |
638 loop_depth_(0) { | 638 loop_depth_(0), |
639 source_url_entry_(0), | |
640 has_source_url_entry_(false) { | |
639 DCHECK_EQ(closure_scope(), closure_scope()->GetClosureScope()); | 641 DCHECK_EQ(closure_scope(), closure_scope()->GetClosureScope()); |
640 } | 642 } |
641 | 643 |
642 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { | 644 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { |
643 AllocateDeferredConstants(isolate); | 645 AllocateDeferredConstants(isolate); |
644 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 646 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
645 return builder()->ToBytecodeArray(isolate); | 647 return builder()->ToBytecodeArray(isolate); |
646 } | 648 } |
647 | 649 |
648 void BytecodeGenerator::AllocateDeferredConstants(Isolate* isolate) { | 650 void BytecodeGenerator::AllocateDeferredConstants(Isolate* isolate) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 } | 691 } |
690 } | 692 } |
691 | 693 |
692 // Build array literal constant elements | 694 // Build array literal constant elements |
693 for (std::pair<ArrayLiteral*, size_t> literal : array_literals_) { | 695 for (std::pair<ArrayLiteral*, size_t> literal : array_literals_) { |
694 ArrayLiteral* array_literal = literal.first; | 696 ArrayLiteral* array_literal = literal.first; |
695 Handle<ConstantElementsPair> constant_elements = | 697 Handle<ConstantElementsPair> constant_elements = |
696 array_literal->GetOrBuildConstantElements(isolate); | 698 array_literal->GetOrBuildConstantElements(isolate); |
697 builder()->SetDeferredConstantPoolEntry(literal.second, constant_elements); | 699 builder()->SetDeferredConstantPoolEntry(literal.second, constant_elements); |
698 } | 700 } |
701 | |
702 if (has_source_url_entry()) { | |
703 Handle<String> url(String::cast(info()->script()->name())); | |
704 builder()->SetDeferredConstantPoolEntry(source_url_entry(), url); | |
705 } | |
699 } | 706 } |
700 | 707 |
701 void BytecodeGenerator::GenerateBytecode(uintptr_t stack_limit) { | 708 void BytecodeGenerator::GenerateBytecode(uintptr_t stack_limit) { |
702 DisallowHeapAllocation no_allocation; | 709 DisallowHeapAllocation no_allocation; |
703 DisallowHandleAllocation no_handles; | 710 DisallowHandleAllocation no_handles; |
704 DisallowHandleDereference no_deref; | 711 DisallowHandleDereference no_deref; |
705 | 712 |
706 InitializeAstVisitor(stack_limit); | 713 InitializeAstVisitor(stack_limit); |
707 | 714 |
708 // Initialize the incoming context. | 715 // Initialize the incoming context. |
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2996 builder()->SetExpressionPosition(expr); | 3003 builder()->SetExpressionPosition(expr); |
2997 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); | 3004 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); |
2998 } | 3005 } |
2999 | 3006 |
3000 void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); } | 3007 void BytecodeGenerator::VisitSpread(Spread* expr) { Visit(expr->expression()); } |
3001 | 3008 |
3002 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { | 3009 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
3003 UNREACHABLE(); | 3010 UNREACHABLE(); |
3004 } | 3011 } |
3005 | 3012 |
3013 void BytecodeGenerator::VisitImportCallExpression(ImportCallExpression* expr) { | |
3014 size_t entry; | |
3015 if (has_source_url_entry()) { | |
3016 entry = source_url_entry(); | |
3017 } else { | |
3018 entry = builder()->AllocateDeferredConstantPoolEntry(); | |
rmcilroy
2017/03/16 09:12:38
Instead of storing this seperately, could you just
gsathya
2017/03/17 00:47:22
Done.
| |
3019 set_source_url_entry(entry); | |
3020 } | |
3021 | |
3022 RegisterList args = register_allocator()->NewRegisterList(2); | |
3023 VisitForRegisterValue(expr->argument(), args[1]); | |
3024 builder() | |
3025 ->LoadConstantPoolEntry(entry) | |
3026 .StoreAccumulatorInRegister(args[0]) | |
3027 .CallRuntime(Runtime::kDynamicImportCall, args); | |
3028 } | |
3029 | |
3006 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { | 3030 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { |
3007 FeedbackSlot load_slot = expr->IteratorPropertyFeedbackSlot(); | 3031 FeedbackSlot load_slot = expr->IteratorPropertyFeedbackSlot(); |
3008 FeedbackSlot call_slot = expr->IteratorCallFeedbackSlot(); | 3032 FeedbackSlot call_slot = expr->IteratorCallFeedbackSlot(); |
3009 | 3033 |
3010 RegisterList args = register_allocator()->NewRegisterList(1); | 3034 RegisterList args = register_allocator()->NewRegisterList(1); |
3011 Register method = register_allocator()->NewRegister(); | 3035 Register method = register_allocator()->NewRegister(); |
3012 Register obj = args[0]; | 3036 Register obj = args[0]; |
3013 | 3037 |
3014 VisitForAccumulatorValue(expr->iterable()); | 3038 VisitForAccumulatorValue(expr->iterable()); |
3015 | 3039 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3488 } | 3512 } |
3489 | 3513 |
3490 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3514 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3491 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3515 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3492 : Runtime::kStoreKeyedToSuper_Sloppy; | 3516 : Runtime::kStoreKeyedToSuper_Sloppy; |
3493 } | 3517 } |
3494 | 3518 |
3495 } // namespace interpreter | 3519 } // namespace interpreter |
3496 } // namespace internal | 3520 } // namespace internal |
3497 } // namespace v8 | 3521 } // namespace v8 |
OLD | NEW |