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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 object_literals_(0, info->zone()), | 580 object_literals_(0, info->zone()), |
581 array_literals_(0, info->zone()), | 581 array_literals_(0, info->zone()), |
582 execution_control_(nullptr), | 582 execution_control_(nullptr), |
583 execution_context_(nullptr), | 583 execution_context_(nullptr), |
584 execution_result_(nullptr), | 584 execution_result_(nullptr), |
585 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 585 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
586 generator_state_(), | 586 generator_state_(), |
587 loop_depth_(0), | 587 loop_depth_(0), |
588 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), | 588 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), |
589 iterator_symbol_(info->isolate()->factory()->iterator_symbol()), | 589 iterator_symbol_(info->isolate()->factory()->iterator_symbol()), |
590 async_iterator_symbol_( | |
591 info->isolate()->factory()->async_iterator_symbol()), | |
590 prototype_string_(info->isolate()->factory()->prototype_string()), | 592 prototype_string_(info->isolate()->factory()->prototype_string()), |
591 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()), | 593 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()), |
592 undefined_string_( | 594 undefined_string_( |
593 info->isolate()->ast_string_constants()->undefined_string()) {} | 595 info->isolate()->ast_string_constants()->undefined_string()) {} |
594 | 596 |
595 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { | 597 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { |
596 AllocateDeferredConstants(isolate); | 598 AllocateDeferredConstants(isolate); |
597 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 599 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
598 return builder()->ToBytecodeArray(isolate); | 600 return builder()->ToBytecodeArray(isolate); |
599 } | 601 } |
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2901 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { | 2903 void BytecodeGenerator::VisitGetIterator(GetIterator* expr) { |
2902 FeedbackVectorSlot load_slot = expr->IteratorPropertyFeedbackSlot(); | 2904 FeedbackVectorSlot load_slot = expr->IteratorPropertyFeedbackSlot(); |
2903 FeedbackVectorSlot call_slot = expr->IteratorCallFeedbackSlot(); | 2905 FeedbackVectorSlot call_slot = expr->IteratorCallFeedbackSlot(); |
2904 | 2906 |
2905 RegisterList args = register_allocator()->NewRegisterList(1); | 2907 RegisterList args = register_allocator()->NewRegisterList(1); |
2906 Register method = register_allocator()->NewRegister(); | 2908 Register method = register_allocator()->NewRegister(); |
2907 Register obj = args[0]; | 2909 Register obj = args[0]; |
2908 | 2910 |
2909 VisitForAccumulatorValue(expr->iterable()); | 2911 VisitForAccumulatorValue(expr->iterable()); |
2910 | 2912 |
2911 // Let method be GetMethod(obj, @@iterator). | 2913 if (expr->hint() == GetIterator::kAsync) { |
2912 builder() | 2914 FeedbackVectorSlot load_slot2 = expr->AsyncIteratorPropertyFeedbackSlot(); |
2913 ->StoreAccumulatorInRegister(obj) | 2915 FeedbackVectorSlot call_slot2 = expr->AsyncIteratorCallFeedbackSlot(); |
rmcilroy
2017/01/20 10:34:01
nit - could you name these async_load_slot, etc.
caitp
2017/01/20 20:17:19
done
| |
2914 .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) | 2916 Register tmp = register_allocator()->NewRegister(); |
rmcilroy
2017/01/20 10:34:01
Unused
caitp
2017/01/20 20:17:19
It's gone
| |
2915 .StoreAccumulatorInRegister(method); | 2917 // Set method to GetMethod(obj, @@asyncIterator) |
2918 builder()->StoreAccumulatorInRegister(obj).LoadNamedProperty( | |
2919 obj, async_iterator_symbol(), feedback_index(load_slot2)); | |
neis
2017/01/20 14:38:15
Nit: please format in the same style as below.
| |
2916 | 2920 |
2917 // Let iterator be Call(method, obj). | 2921 BytecodeLabel async_iterator_undefined, async_iterator_null, done; |
2918 builder()->Call(method, args, feedback_index(call_slot), | 2922 builder()->JumpIfUndefined(&async_iterator_undefined); |
2919 Call::NAMED_PROPERTY_CALL); | 2923 builder()->JumpIfNull(&async_iterator_null); |
rmcilroy
2017/01/20 10:34:01
You could use TestUndetectable, JumpIfTrue here in
caitp
2017/01/20 20:17:19
TestUndetectable checks for the Undetectable map b
rmcilroy
2017/01/25 09:20:44
Ahh make sense, I forgot about the weird document.
| |
2920 | 2924 |
2921 // If Type(iterator) is not Object, throw a TypeError exception. | 2925 // Let iterator be Call(method, obj) |
2922 BytecodeLabel no_type_error; | 2926 builder()->StoreAccumulatorInRegister(method).Call( |
2923 builder()->JumpIfJSReceiver(&no_type_error); | 2927 method, args, feedback_index(call_slot), Call::NAMED_PROPERTY_CALL); |
neis
2017/01/20 14:38:15
Shouldn't this be call_slot2 here? And in the Call
caitp
2017/01/20 20:17:19
Renamed these things to `load_iter_slot`, `call_it
| |
2924 builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid); | 2928 |
2925 builder()->Bind(&no_type_error); | 2929 // If Type(iterator) is not Object, throw a TypeError exception. |
2930 builder()->JumpIfJSReceiver(&done); | |
2931 builder()->CallRuntime(Runtime::kThrowSymbolAsyncIteratorInvalid); | |
2932 | |
2933 builder()->Bind(&async_iterator_undefined); | |
2934 builder()->Bind(&async_iterator_null); | |
2935 // If method is undefined, | |
2936 // Let syncMethod be GetMethod(obj, @@iterator) | |
2937 builder() | |
2938 ->LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) | |
2939 .StoreAccumulatorInRegister(method); | |
2940 | |
2941 // Let syncIterator be Call(syncMethod, obj) | |
2942 builder()->Call(method, args, feedback_index(call_slot2), | |
2943 Call::NAMED_PROPERTY_CALL); | |
2944 | |
2945 // Return CreateAsyncFromSyncIterator(syncIterator) | |
2946 RegisterList args = register_allocator()->NewRegisterList(1); | |
2947 Register sync_iterator = args[0]; | |
rmcilroy
2017/01/20 10:34:01
No need to allocate a register list for a single r
caitp
2017/01/20 20:17:19
Something like this?
```
// Return CreateAsyn
rmcilroy
2017/01/25 09:20:44
Yeah this is fine
| |
2948 builder() | |
2949 ->StoreAccumulatorInRegister(sync_iterator) | |
2950 .CallRuntime(Runtime::kInlineCreateAsyncFromSyncIterator, args); | |
2951 | |
2952 builder()->Bind(&done); | |
2953 } else { | |
2954 // Let method be GetMethod(obj, @@iterator). | |
2955 builder() | |
2956 ->StoreAccumulatorInRegister(obj) | |
2957 .LoadNamedProperty(obj, iterator_symbol(), feedback_index(load_slot)) | |
2958 .StoreAccumulatorInRegister(method); | |
2959 | |
2960 // Let iterator be Call(method, obj). | |
2961 builder()->Call(method, args, feedback_index(call_slot), | |
2962 Call::NAMED_PROPERTY_CALL); | |
2963 | |
2964 // If Type(iterator) is not Object, throw a TypeError exception. | |
2965 BytecodeLabel no_type_error; | |
2966 builder()->JumpIfJSReceiver(&no_type_error); | |
2967 builder()->CallRuntime(Runtime::kThrowSymbolIteratorInvalid); | |
2968 builder()->Bind(&no_type_error); | |
2969 } | |
2926 } | 2970 } |
2927 | 2971 |
2928 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { | 2972 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { |
2929 builder()->LoadAccumulatorWithRegister(Register::function_closure()); | 2973 builder()->LoadAccumulatorWithRegister(Register::function_closure()); |
2930 } | 2974 } |
2931 | 2975 |
2932 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { | 2976 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { |
2933 // Handled by VisitCall(). | 2977 // Handled by VisitCall(). |
2934 UNREACHABLE(); | 2978 UNREACHABLE(); |
2935 } | 2979 } |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3341 } | 3385 } |
3342 | 3386 |
3343 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3387 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3344 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3388 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3345 : Runtime::kStoreKeyedToSuper_Sloppy; | 3389 : Runtime::kStoreKeyedToSuper_Sloppy; |
3346 } | 3390 } |
3347 | 3391 |
3348 } // namespace interpreter | 3392 } // namespace interpreter |
3349 } // namespace internal | 3393 } // namespace internal |
3350 } // namespace v8 | 3394 } // namespace v8 |
OLD | NEW |