Commit e298646b authored by neis's avatar neis Committed by Commit bot

[generators] Simplify %CreateJSGeneratorObject

Instead of looking at the top JavaScriptFrame, take the needed information as
arguments.  This is in preparation of the new generators implementation.

R=adamk@chromium.org, bmeurer@chromium.org
BUG=v8:4907
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#35430}
parent 84c329e2
......@@ -4470,9 +4470,13 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
{
ZoneList<Expression*>* arguments =
new (zone()) ZoneList<Expression*>(0, zone());
new (zone()) ZoneList<Expression*>(2, zone());
arguments->Add(factory()->NewThisFunction(pos), zone());
arguments->Add(
ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone());
CallRuntime* allocation = factory()->NewCallRuntime(
Runtime::kCreateJSGeneratorObject, arguments, pos);
VariableProxy* init_proxy = factory()->NewVariableProxy(
function_state_->generator_object_variable());
Assignment* assignment = factory()->NewAssignment(
......
......@@ -14,22 +14,18 @@ namespace internal {
RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
Handle<JSFunction> function(frame->function());
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1);
RUNTIME_ASSERT(function->shared()->is_generator());
Handle<JSGeneratorObject> generator;
DCHECK(!frame->IsConstructor());
generator = isolate->factory()->NewJSGeneratorObject(function);
Handle<JSGeneratorObject> generator =
isolate->factory()->NewJSGeneratorObject(function);
generator->set_function(*function);
generator->set_context(Context::cast(frame->context()));
generator->set_receiver(frame->receiver());
generator->set_continuation(0);
generator->set_context(isolate->context());
generator->set_receiver(*receiver);
generator->set_operand_stack(isolate->heap()->empty_fixed_array());
generator->set_continuation(JSGeneratorObject::kGeneratorExecuting);
return *generator;
}
......
......@@ -233,7 +233,7 @@ namespace internal {
F(FunctionToString, 1, 1)
#define FOR_EACH_INTRINSIC_GENERATOR(F) \
F(CreateJSGeneratorObject, 0, 1) \
F(CreateJSGeneratorObject, 2, 1) \
F(SuspendJSGeneratorObject, 1, 1) \
F(GeneratorClose, 1, 1) \
F(GeneratorGetFunction, 1, 1) \
......
......@@ -374,7 +374,10 @@ TEST(VisitYield) {
CHECK_VAR(.generator_object, Bounds::Unbounded());
CHECK_EXPR(Assignment, Bounds::Unbounded()) {
CHECK_VAR(.generator_object, Bounds::Unbounded());
CHECK_EXPR(CallRuntime, Bounds::Unbounded());
CHECK_EXPR(CallRuntime, Bounds::Unbounded()) {
CHECK_EXPR(ThisFunction, Bounds::Unbounded());
CHECK_EXPR(VariableProxy, Bounds::Unbounded());
}
}
}
// Explicit yield (argument wrapped with CreateIterResultObject)
......
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