Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2639533002: [generators] Always call function with closure context when resuming. (Closed)
Patch Set: Ports. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-intrinsic-lowering.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // The generator resume trampoline abuses the new.target register both to 792 // The generator resume trampoline abuses the new.target register both to
793 // indicate that this is a resume call and to pass in the generator object. 793 // indicate that this is a resume call and to pass in the generator object.
794 // In ordinary calls, new.target is always undefined because generator 794 // In ordinary calls, new.target is always undefined because generator
795 // functions are non-constructable. 795 // functions are non-constructable.
796 Register generator_object = Register::new_target(); 796 Register generator_object = Register::new_target();
797 BytecodeLabel regular_call; 797 BytecodeLabel regular_call;
798 builder() 798 builder()
799 ->LoadAccumulatorWithRegister(generator_object) 799 ->LoadAccumulatorWithRegister(generator_object)
800 .JumpIfUndefined(&regular_call); 800 .JumpIfUndefined(&regular_call);
801 801
802 // This is a resume call. Restore registers and perform state dispatch. 802 // This is a resume call. Restore the current context and the registers, then
803 // (The current context has already been restored by the trampoline.) 803 // perform state dispatch.
804 Register dummy = register_allocator()->NewRegister();
804 builder() 805 builder()
805 ->ResumeGenerator(generator_object) 806 ->CallRuntime(Runtime::kInlineGeneratorGetContext, generator_object)
807 .PushContext(dummy)
808 .ResumeGenerator(generator_object)
806 .StoreAccumulatorInRegister(generator_state_); 809 .StoreAccumulatorInRegister(generator_state_);
807 BuildIndexedJump(generator_state_, 0, generator_resume_points_.size(), 810 BuildIndexedJump(generator_state_, 0, generator_resume_points_.size(),
808 generator_resume_points_); 811 generator_resume_points_);
809 812
810 builder() 813 builder()
811 ->Bind(&regular_call) 814 ->Bind(&regular_call)
812 .LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)) 815 .LoadLiteral(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))
813 .StoreAccumulatorInRegister(generator_state_); 816 .StoreAccumulatorInRegister(generator_state_);
814 // This is a regular call. Fall through to the ordinary function prologue, 817 // This is a regular call. Fall through to the ordinary function prologue,
815 // after which we will run into the generator object creation and other extra 818 // after which we will run into the generator object creation and other extra
(...skipping 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 } 3362 }
3360 3363
3361 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3364 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3362 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3365 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3363 : Runtime::kStoreKeyedToSuper_Sloppy; 3366 : Runtime::kStoreKeyedToSuper_Sloppy;
3364 } 3367 }
3365 3368
3366 } // namespace interpreter 3369 } // namespace interpreter
3367 } // namespace internal 3370 } // namespace internal
3368 } // namespace v8 3371 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-intrinsic-lowering.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698