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

[turbofan] Implement intrinsic lowering of %_GeneratorClose.

Also change parser to insert %_GeneratorClose instead of %GeneratorClose.
Full-codegen generators will fall back to the runtime function.

BUG=v8:4907

Review-Url: https://codereview.chromium.org/1993073003
Cr-Commit-Position: refs/heads/master@{#36401}
parent 66d76797
......@@ -40,6 +40,8 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceDoubleHi(node);
case Runtime::kInlineDoubleLo:
return ReduceDoubleLo(node);
case Runtime::kInlineGeneratorClose:
return ReduceGeneratorClose(node);
case Runtime::kInlineIsArray:
return ReduceIsInstanceType(node, JS_ARRAY_TYPE);
case Runtime::kInlineIsTypedArray:
......@@ -152,6 +154,19 @@ Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) {
return Change(node, machine()->Float64ExtractLowWord32());
}
Reduction JSIntrinsicLowering::ReduceGeneratorClose(Node* node) {
Node* const generator = NodeProperties::GetValueInput(node, 0);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
Node* const closed = jsgraph()->Constant(JSGeneratorObject::kGeneratorClosed);
Node* const undefined = jsgraph()->UndefinedConstant();
Operator const* const op = simplified()->StoreField(
AccessBuilder::ForJSGeneratorObjectContinuation());
ReplaceWithValue(node, undefined, node);
NodeProperties::RemoveType(node);
return Change(node, op, generator, closed, effect, control);
}
Reduction JSIntrinsicLowering::ReduceIsInstanceType(
Node* node, InstanceType instance_type) {
......
......@@ -42,6 +42,7 @@ class JSIntrinsicLowering final : public AdvancedReducer {
Reduction ReduceDeoptimizeNow(Node* node);
Reduction ReduceDoubleHi(Node* node);
Reduction ReduceDoubleLo(Node* node);
Reduction ReduceGeneratorClose(Node* node);
Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type);
Reduction ReduceIsJSReceiver(Node* node);
Reduction ReduceIsSmi(Node* node);
......
......@@ -4696,7 +4696,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
// We produce:
//
// try { InitialYield; ...body...; return {value: undefined, done: true} }
// finally { %GeneratorClose(generator) }
// finally { %_GeneratorClose(generator) }
//
// - InitialYield yields the actual generator object.
// - Any return statement inside the body will have its argument wrapped
......@@ -4736,7 +4736,7 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
function_state_->generator_object_variable());
args->Add(call_proxy, zone());
Expression* call = factory()->NewCallRuntime(
Runtime::kGeneratorClose, args, RelocInfo::kNoPosition);
Runtime::kInlineGeneratorClose, args, RelocInfo::kNoPosition);
finally_block->statements()->Add(
factory()->NewExpressionStatement(call, RelocInfo::kNoPosition),
zone());
......
......@@ -88,7 +88,7 @@ bytecodes: [
B(Star), R(4),
B(LdaContextSlot), R(context), U8(5),
B(Star), R(5),
B(CallRuntime), U16(Runtime::kGeneratorClose), R(5), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorClose), R(5), U8(1),
B(CallRuntime), U16(Runtime::kInterpreterSetPendingMessage), R(4), U8(1),
B(LdaZero),
B(TestEqualStrict), R(2),
......@@ -232,7 +232,7 @@ bytecodes: [
B(Star), R(4),
B(LdaContextSlot), R(context), U8(5),
B(Star), R(5),
B(CallRuntime), U16(Runtime::kGeneratorClose), R(5), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorClose), R(5), U8(1),
B(CallRuntime), U16(Runtime::kInterpreterSetPendingMessage), R(4), U8(1),
B(LdaZero),
B(TestEqualStrict), R(2),
......@@ -586,7 +586,7 @@ bytecodes: [
B(Star), R(6),
B(LdaContextSlot), R(context), U8(5),
B(Star), R(7),
B(CallRuntime), U16(Runtime::kGeneratorClose), R(7), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorClose), R(7), U8(1),
B(CallRuntime), U16(Runtime::kInterpreterSetPendingMessage), R(6), U8(1),
B(LdaZero),
B(TestEqualStrict), R(4),
......
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