Commit 1292721f authored by neis's avatar neis Committed by Commit bot

[turbofan] Intrinsic-lowering for GeneratorGetInput and GeneratorGetResumeMode.

Also use the inlined version of CreateIterResultObject in Ignition's VisitYield.

BUG=v8:4907
TBR=littledan@chromium.org

Review-Url: https://codereview.chromium.org/2006613002
Cr-Commit-Position: refs/heads/master@{#36444}
parent f2a7ba64
......@@ -152,6 +152,14 @@ FieldAccess AccessBuilder::ForJSGeneratorObjectContinuation() {
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectInput() {
FieldAccess access = {
kTaggedBase, JSGeneratorObject::kInputOffset, Handle<Name>(),
Type::Any(), MachineType::AnyTagged(), kFullWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectOperandStack() {
FieldAccess access = {kTaggedBase,
......@@ -163,6 +171,18 @@ FieldAccess AccessBuilder::ForJSGeneratorObjectOperandStack() {
return access;
}
// static
FieldAccess AccessBuilder::ForJSGeneratorObjectResumeMode() {
TypeCache const& type_cache = TypeCache::Get();
FieldAccess access = {kTaggedBase,
JSGeneratorObject::kResumeModeOffset,
Handle<Name>(),
type_cache.kSmi,
MachineType::AnyTagged(),
kNoWriteBarrier};
return access;
}
// static
FieldAccess AccessBuilder::ForJSArrayLength(ElementsKind elements_kind) {
TypeCache const& type_cache = TypeCache::Get();
......
......@@ -58,9 +58,15 @@ class AccessBuilder final : public AllStatic {
// Provides access to JSGeneratorObject::continuation() field.
static FieldAccess ForJSGeneratorObjectContinuation();
// Provides access to JSGeneratorObject::input() field.
static FieldAccess ForJSGeneratorObjectInput();
// Provides access to JSGeneratorObject::operand_stack() field.
static FieldAccess ForJSGeneratorObjectOperandStack();
// Provides access to JSGeneratorObject::resume_mode() field.
static FieldAccess ForJSGeneratorObjectResumeMode();
// Provides access to JSArray::length() field.
static FieldAccess ForJSArrayLength(ElementsKind elements_kind);
......
......@@ -42,6 +42,10 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
return ReduceDoubleLo(node);
case Runtime::kInlineGeneratorClose:
return ReduceGeneratorClose(node);
case Runtime::kInlineGeneratorGetInput:
return ReduceGeneratorGetInput(node);
case Runtime::kInlineGeneratorGetResumeMode:
return ReduceGeneratorGetResumeMode(node);
case Runtime::kInlineIsArray:
return ReduceIsInstanceType(node, JS_ARRAY_TYPE);
case Runtime::kInlineIsTypedArray:
......@@ -168,6 +172,26 @@ Reduction JSIntrinsicLowering::ReduceGeneratorClose(Node* node) {
return Change(node, op, generator, closed, effect, control);
}
Reduction JSIntrinsicLowering::ReduceGeneratorGetInput(Node* node) {
Node* const generator = NodeProperties::GetValueInput(node, 0);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
Operator const* const op =
simplified()->LoadField(AccessBuilder::ForJSGeneratorObjectInput());
return Change(node, op, generator, effect, control);
}
Reduction JSIntrinsicLowering::ReduceGeneratorGetResumeMode(Node* node) {
Node* const generator = NodeProperties::GetValueInput(node, 0);
Node* const effect = NodeProperties::GetEffectInput(node);
Node* const control = NodeProperties::GetControlInput(node);
Operator const* const op =
simplified()->LoadField(AccessBuilder::ForJSGeneratorObjectResumeMode());
return Change(node, op, generator, effect, control);
}
Reduction JSIntrinsicLowering::ReduceIsInstanceType(
Node* node, InstanceType instance_type) {
// if (%_IsSmi(value)) {
......
......@@ -43,6 +43,8 @@ class JSIntrinsicLowering final : public AdvancedReducer {
Reduction ReduceDoubleHi(Node* node);
Reduction ReduceDoubleLo(Node* node);
Reduction ReduceGeneratorClose(Node* node);
Reduction ReduceGeneratorGetInput(Node* node);
Reduction ReduceGeneratorGetResumeMode(Node* node);
Reduction ReduceIsInstanceType(Node* node, InstanceType instance_type);
Reduction ReduceIsJSReceiver(Node* node);
Reduction ReduceIsSmi(Node* node);
......
......@@ -2301,12 +2301,12 @@ void BytecodeGenerator::VisitYield(Yield* expr) {
Register input = register_allocator()->NewRegister();
builder()
->CallRuntime(Runtime::kGeneratorGetInput, generator, 1)
->CallRuntime(Runtime::kInlineGeneratorGetInput, generator, 1)
.StoreAccumulatorInRegister(input);
Register resume_mode = register_allocator()->NewRegister();
builder()
->CallRuntime(Runtime::kGeneratorGetResumeMode, generator, 1)
->CallRuntime(Runtime::kInlineGeneratorGetResumeMode, generator, 1)
.StoreAccumulatorInRegister(resume_mode);
// Now dispatch on resume mode.
......@@ -2333,7 +2333,7 @@ void BytecodeGenerator::VisitYield(Yield* expr) {
->MoveRegister(input, value)
.LoadTrue()
.StoreAccumulatorInRegister(done)
.CallRuntime(Runtime::kCreateIterResultObject, value, 2);
.CallRuntime(Runtime::kInlineCreateIterResultObject, value, 2);
execution_control()->ReturnAccumulator();
}
......
......@@ -669,13 +669,13 @@ Expression* ParserTraits::NewTargetExpression(Scope* scope,
Expression* ParserTraits::FunctionSentExpression(Scope* scope,
AstNodeFactory* factory,
int pos) {
// We desugar function.sent into %GeneratorGetInput(generator).
// We desugar function.sent into %_GeneratorGetInput(generator).
Zone* zone = parser_->zone();
ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(1, zone);
VariableProxy* generator = factory->NewVariableProxy(
parser_->function_state_->generator_object_variable());
args->Add(generator, zone);
return factory->NewCallRuntime(Runtime::kGeneratorGetInput, args, pos);
return factory->NewCallRuntime(Runtime::kInlineGeneratorGetInput, args, pos);
}
......
......@@ -48,9 +48,9 @@ bytecodes: [
B(Return),
B(LdaSmi), U8(-2),
B(Star), R(1),
B(CallRuntime), U16(Runtime::kGeneratorGetInput), R(6), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetInput), R(6), U8(1),
B(Star), R(7),
B(CallRuntime), U16(Runtime::kGeneratorGetResumeMode), R(6), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(6), U8(1),
B(Star), R(8),
B(LdaZero),
B(TestEqualStrict), R(8),
......@@ -62,7 +62,7 @@ bytecodes: [
B(Mov), R(7), R(9),
B(LdaTrue),
B(Star), R(10),
B(CallRuntime), U16(Runtime::kCreateIterResultObject), R(9), U8(2),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(Star), R(3),
B(LdaZero),
B(Star), R(2),
......@@ -157,9 +157,9 @@ bytecodes: [
B(Return),
B(LdaSmi), U8(-2),
B(Star), R(1),
B(CallRuntime), U16(Runtime::kGeneratorGetInput), R(6), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetInput), R(6), U8(1),
B(Star), R(7),
B(CallRuntime), U16(Runtime::kGeneratorGetResumeMode), R(6), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(6), U8(1),
B(Star), R(8),
B(LdaZero),
B(TestEqualStrict), R(8),
......@@ -171,7 +171,7 @@ bytecodes: [
B(Mov), R(7), R(9),
B(LdaTrue),
B(Star), R(10),
B(CallRuntime), U16(Runtime::kCreateIterResultObject), R(9), U8(2),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(Star), R(3),
B(LdaZero),
B(Star), R(2),
......@@ -192,9 +192,9 @@ bytecodes: [
B(Return),
B(LdaSmi), U8(-2),
B(Star), R(1),
B(CallRuntime), U16(Runtime::kGeneratorGetInput), R(5), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetInput), R(5), U8(1),
B(Star), R(6),
B(CallRuntime), U16(Runtime::kGeneratorGetResumeMode), R(5), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(5), U8(1),
B(Star), R(8),
B(LdaZero),
B(TestEqualStrict), R(8),
......@@ -206,7 +206,7 @@ bytecodes: [
B(Mov), R(6), R(9),
B(LdaTrue),
B(Star), R(10),
B(CallRuntime), U16(Runtime::kCreateIterResultObject), R(9), U8(2),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(Star), R(3),
B(LdaSmi), U8(1),
B(Star), R(2),
......@@ -307,9 +307,9 @@ bytecodes: [
B(Return),
B(LdaSmi), U8(-2),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kGeneratorGetInput), R(8), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetInput), R(8), U8(1),
B(Star), R(9),
B(CallRuntime), U16(Runtime::kGeneratorGetResumeMode), R(8), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(8), U8(1),
B(Star), R(10),
B(LdaZero),
B(TestEqualStrict), R(10),
......@@ -321,7 +321,7 @@ bytecodes: [
B(Mov), R(9), R(11),
B(LdaTrue),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kCreateIterResultObject), R(11), U8(2),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(11), U8(2),
B(Star), R(5),
B(LdaZero),
B(Star), R(4),
......@@ -411,9 +411,9 @@ bytecodes: [
B(Return),
B(LdaSmi), U8(-2),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kGeneratorGetInput), R(11), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetInput), R(11), U8(1),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kGeneratorGetResumeMode), R(11), U8(1),
B(CallRuntime), U16(Runtime::k_GeneratorGetResumeMode), R(11), U8(1),
B(Star), R(14),
B(LdaZero),
B(TestEqualStrict), R(14),
......@@ -425,7 +425,7 @@ bytecodes: [
B(Mov), R(12), R(15),
B(LdaTrue),
B(Star), R(16),
B(CallRuntime), U16(Runtime::kCreateIterResultObject), R(15), U8(2),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(15), U8(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
......
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