Commit 935240f9 authored by neis's avatar neis Committed by Commit bot

[generators] Add some explanation on forcing context allocation.

R=mstarzinger@chromium.org
TBR=rossberg
BUG=

Review URL: https://codereview.chromium.org/1806293002

Cr-Commit-Position: refs/heads/master@{#34864}
parent 2aa070be
......@@ -1908,7 +1908,10 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kReceiverOffset));
__ push(r2);
// Push holes for the rest of the arguments to the generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ ldr(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
__ ldr(r3,
FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset));
......
......@@ -3844,7 +3844,10 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
JSGeneratorObject::kReceiverOffset));
__ Push(x10);
// Push holes for the rest of the arguments to the generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ Ldr(x10, FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
// The number of arguments is stored as an int32_t, and -1 is a marker
......
......@@ -1823,7 +1823,10 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Push receiver.
__ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
// Push holes for arguments to generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
__ mov(edx,
FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
......
......@@ -1903,7 +1903,10 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset));
__ push(a2);
// Push holes for the rest of the arguments to the generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset));
__ lw(a3,
FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
......
......@@ -1905,7 +1905,10 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset));
__ push(a2);
// Push holes for the rest of the arguments to the generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset));
// The argument count is stored as int32_t on 64-bit platforms.
// TODO(plind): Smi on 32-bit platforms.
......
......@@ -1870,7 +1870,10 @@ void FullCodeGenerator::EmitGeneratorResume(
__ LoadP(r5, FieldMemOperand(r4, JSGeneratorObject::kReceiverOffset));
__ push(r5);
// Push holes for the rest of the arguments to the generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ LoadP(r6, FieldMemOperand(r7, JSFunction::kSharedFunctionInfoOffset));
__ LoadWordArith(
r6, FieldMemOperand(r6, SharedFunctionInfo::kFormalParameterCountOffset));
......
......@@ -1825,7 +1825,10 @@ void FullCodeGenerator::EmitGeneratorResume(
__ LoadP(r4, FieldMemOperand(r3, JSGeneratorObject::kReceiverOffset));
__ push(r4);
// Push holes for the rest of the arguments to the generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ LoadP(r5, FieldMemOperand(r6, JSFunction::kSharedFunctionInfoOffset));
__ LoadW(
r5, FieldMemOperand(r5, SharedFunctionInfo::kFormalParameterCountOffset));
......
......@@ -1848,7 +1848,10 @@ void FullCodeGenerator::EmitGeneratorResume(
// Push receiver.
__ Push(FieldOperand(rbx, JSGeneratorObject::kReceiverOffset));
// Push holes for arguments to generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
__ LoadSharedFunctionInfoSpecialField(rdx, rdx,
SharedFunctionInfo::kFormalParameterCountOffset);
......
......@@ -1815,7 +1815,10 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Push receiver.
__ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
// Push holes for arguments to generator function.
// Push holes for arguments to generator function. Since the parser forced
// context allocation for any variables in generators, the actual argument
// values have already been copied into the context and these dummy values
// will never be used.
__ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
__ mov(edx,
FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset));
......
......@@ -4103,7 +4103,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
if (is_generator) {
// For generators, allocating variables in contexts is currently a win
// because it minimizes the work needed to suspend and resume an
// activation.
// activation. The machine code produced for generators (by full-codegen)
// relies on this forced context allocation, but not in an essential way.
scope_->ForceContextAllocation();
// Calling a generator returns a generator object. That object is stored
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment