Commit 8713dc57 authored by jgruber's avatar jgruber Committed by Commit bot

[stubs] Add CreateIterResultObject stub

Most notably, the interpreter now calls this stub instead of the
runtime.

BUG=

Review-Url: https://codereview.chromium.org/2619163004
Cr-Commit-Position: refs/heads/master@{#42218}
parent 733569b7
......@@ -65,18 +65,20 @@ void Generate_GeneratorPrototypeResume(
assembler->Bind(&if_receiverisclosed);
{
Callable create_iter_result_object =
CodeFactory::CreateIterResultObject(assembler->isolate());
// The {receiver} is closed already.
Node* result = nullptr;
switch (resume_mode) {
case JSGeneratorObject::kNext:
result = assembler->CallRuntime(Runtime::kCreateIterResultObject,
context, assembler->UndefinedConstant(),
assembler->BooleanConstant(true));
result = assembler->CallStub(create_iter_result_object, context,
assembler->UndefinedConstant(),
assembler->TrueConstant());
break;
case JSGeneratorObject::kReturn:
result =
assembler->CallRuntime(Runtime::kCreateIterResultObject, context,
value, assembler->BooleanConstant(true));
result = assembler->CallStub(create_iter_result_object, context, value,
assembler->TrueConstant());
break;
case JSGeneratorObject::kThrow:
result = assembler->CallRuntime(Runtime::kThrow, context, value);
......
......@@ -927,6 +927,29 @@ BUILTIN(ObjectSeal) {
return *object;
}
void Builtins::Generate_CreateIterResultObject(
compiler::CodeAssemblerState* state) {
typedef CreateIterResultObjectDescriptor Descriptor;
typedef compiler::Node Node;
CodeStubAssembler a(state);
Node* const value = a.Parameter(Descriptor::kValue);
Node* const done = a.Parameter(Descriptor::kDone);
Node* const context = a.Parameter(Descriptor::kContext);
Node* const native_context = a.LoadNativeContext(context);
Node* const map =
a.LoadContextElement(native_context, Context::ITERATOR_RESULT_MAP_INDEX);
Node* const result = a.AllocateJSObjectFromMap(map);
a.StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kValueOffset,
value);
a.StoreObjectFieldNoWriteBarrier(result, JSIteratorResult::kDoneOffset, done);
a.Return(result);
}
void Builtins::Generate_HasProperty(compiler::CodeAssemblerState* state) {
typedef HasPropertyDescriptor Descriptor;
typedef compiler::Node Node;
......
......@@ -412,6 +412,10 @@ namespace internal {
TFJ(FunctionPrototypeHasInstance, 1) \
CPP(FunctionPrototypeToString) \
\
/* Belongs to Objects but is a dependency of GeneratorPrototypeResume */ \
TFS(CreateIterResultObject, BUILTIN, kNoExtraICState, \
CreateIterResultObject) \
\
/* Generator and Async */ \
CPP(GeneratorFunctionConstructor) \
/* ES6 section 25.3.1.2 Generator.prototype.next ( value ) */ \
......
......@@ -252,6 +252,7 @@ TFS_BUILTIN(Equal)
TFS_BUILTIN(NotEqual)
TFS_BUILTIN(StrictEqual)
TFS_BUILTIN(StrictNotEqual)
TFS_BUILTIN(CreateIterResultObject)
TFS_BUILTIN(HasProperty)
TFS_BUILTIN(ToInteger)
TFS_BUILTIN(ToLength)
......
......@@ -167,6 +167,7 @@ class V8_EXPORT_PRIVATE CodeFactory final {
Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny);
static Callable Construct(Isolate* isolate);
static Callable ConstructFunction(Isolate* isolate);
static Callable CreateIterResultObject(Isolate* isolate);
static Callable HasProperty(Isolate* isolate);
static Callable ForInFilter(Isolate* isolate);
......
......@@ -80,6 +80,7 @@ class PlatformInterfaceDescriptor;
V(SubString) \
V(Keyed) \
V(Named) \
V(CreateIterResultObject) \
V(HasProperty) \
V(ForInFilter) \
V(GetProperty) \
......@@ -479,6 +480,13 @@ class TypeConversionDescriptor final : public CallInterfaceDescriptor {
static const Register ArgumentRegister();
};
class CreateIterResultObjectDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kValue, kDone)
DECLARE_DEFAULT_DESCRIPTOR(CreateIterResultObjectDescriptor,
CallInterfaceDescriptor, kParameterCount)
};
class HasPropertyDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kKey, kObject)
......
......@@ -230,6 +230,12 @@ Node* IntrinsicsHelper::IntrinsicAsStubCall(Node* args_reg, Node* context,
return __ CallStubN(callable.descriptor(), 1, input_count, args);
}
Node* IntrinsicsHelper::CreateIterResultObject(Node* input, Node* arg_count,
Node* context) {
return IntrinsicAsStubCall(input, context,
CodeFactory::CreateIterResultObject(isolate()));
}
Node* IntrinsicsHelper::HasProperty(Node* input, Node* arg_count,
Node* context) {
return IntrinsicAsStubCall(input, context,
......
......@@ -23,23 +23,24 @@ namespace interpreter {
// List of supported intrisics, with upper case name, lower case name and
// expected number of arguments (-1 denoting argument count is variable).
#define INTRINSICS_LIST(V) \
V(Call, call, -1) \
V(ClassOf, class_of, 1) \
V(HasProperty, has_property, 2) \
V(IsArray, is_array, 1) \
V(IsJSProxy, is_js_proxy, 1) \
V(IsJSReceiver, is_js_receiver, 1) \
V(IsSmi, is_smi, 1) \
V(IsTypedArray, is_typed_array, 1) \
V(NumberToString, number_to_string, 1) \
V(RegExpExec, reg_exp_exec, 4) \
V(SubString, sub_string, 3) \
V(ToString, to_string, 1) \
V(ToLength, to_length, 1) \
V(ToInteger, to_integer, 1) \
V(ToNumber, to_number, 1) \
V(ToObject, to_object, 1) \
#define INTRINSICS_LIST(V) \
V(Call, call, -1) \
V(ClassOf, class_of, 1) \
V(CreateIterResultObject, create_iter_result_object, 2) \
V(HasProperty, has_property, 2) \
V(IsArray, is_array, 1) \
V(IsJSProxy, is_js_proxy, 1) \
V(IsJSReceiver, is_js_receiver, 1) \
V(IsSmi, is_smi, 1) \
V(IsTypedArray, is_typed_array, 1) \
V(NumberToString, number_to_string, 1) \
V(RegExpExec, reg_exp_exec, 4) \
V(SubString, sub_string, 3) \
V(ToString, to_string, 1) \
V(ToLength, to_length, 1) \
V(ToInteger, to_integer, 1) \
V(ToNumber, to_number, 1) \
V(ToObject, to_object, 1) \
V(ValueOf, value_of, 1)
class IntrinsicsHelper {
......
......@@ -13,7 +13,7 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 199
bytecode array length: 197
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(21),
......@@ -53,26 +53,26 @@ bytecodes: [
B(Star), R(8),
B(LdaZero),
B(TestEqualStrict), R(8), U8(0),
B(JumpIfTrue), U8(32),
B(JumpIfTrue), U8(31),
B(LdaSmi), U8(2),
B(TestEqualStrict), R(8), U8(0),
B(JumpIfTrue), U8(22),
B(JumpIfTrue), U8(21),
B(Jump), U8(2),
B(LdaTrue),
B(Star), R(10),
B(Mov), R(7), R(9),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(Star), R(3),
B(LdaZero),
B(Star), R(2),
B(Jump), U8(36),
B(Jump), U8(35),
B(Ldar), R(7),
/* 11 E> */ B(Throw),
B(LdaUndefined),
B(Star), R(5),
B(LdaTrue),
B(Star), R(6),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(5), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(5), U8(2),
B(Star), R(3),
B(LdaSmi), U8(1),
B(Star), R(2),
......@@ -113,7 +113,7 @@ bytecodes: [
constant pool: [
]
handlers: [
[39, 138, 144],
[39, 136, 142],
]
---
......@@ -123,7 +123,7 @@ snippet: "
"
frame size: 11
parameter count: 1
bytecode array length: 296
bytecode array length: 292
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(28),
......@@ -166,26 +166,26 @@ bytecodes: [
B(Star), R(8),
B(LdaZero),
B(TestEqualStrict), R(8), U8(0),
B(JumpIfTrue), U8(32),
B(JumpIfTrue), U8(31),
B(LdaSmi), U8(2),
B(TestEqualStrict), R(8), U8(0),
B(JumpIfTrue), U8(22),
B(JumpIfTrue), U8(21),
B(Jump), U8(2),
B(LdaTrue),
B(Star), R(10),
B(Mov), R(7), R(9),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(Star), R(3),
B(LdaZero),
B(Star), R(2),
B(Jump), U8(116),
B(Jump), U8(113),
B(Ldar), R(7),
/* 11 E> */ B(Throw),
/* 16 S> */ B(LdaSmi), U8(42),
B(Star), R(5),
B(LdaFalse),
B(Star), R(6),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(5), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(5), U8(2),
B(Star), R(5),
B(LdaCurrentContextSlot), U8(5),
B(Star), R(6),
......@@ -201,26 +201,26 @@ bytecodes: [
B(Star), R(8),
B(LdaZero),
B(TestEqualStrict), R(8), U8(0),
B(JumpIfTrue), U8(33),
B(JumpIfTrue), U8(32),
B(LdaSmi), U8(2),
B(TestEqualStrict), R(8), U8(0),
B(JumpIfTrue), U8(23),
B(JumpIfTrue), U8(22),
B(Jump), U8(2),
B(LdaTrue),
B(Star), R(10),
B(Mov), R(7), R(9),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(9), U8(2),
B(Star), R(3),
B(LdaSmi), U8(1),
B(Star), R(2),
B(Jump), U8(36),
B(Jump), U8(35),
B(Ldar), R(7),
/* 16 E> */ B(Throw),
B(LdaUndefined),
B(Star), R(5),
B(LdaTrue),
B(Star), R(6),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(5), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(5), U8(2),
B(Star), R(3),
B(LdaSmi), U8(2),
B(Star), R(2),
......@@ -264,10 +264,10 @@ bytecodes: [
/* 25 S> */ B(Return),
]
constant pool: [
Smi [132],
Smi [130],
]
handlers: [
[46, 225, 231],
[46, 221, 227],
]
---
......@@ -277,7 +277,7 @@ snippet: "
"
frame size: 17
parameter count: 1
bytecode array length: 775
bytecode array length: 771
bytecodes: [
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(28),
......@@ -320,15 +320,15 @@ bytecodes: [
B(Star), R(10),
B(LdaZero),
B(TestEqualStrict), R(10), U8(0),
B(JumpIfTrue), U8(32),
B(JumpIfTrue), U8(31),
B(LdaSmi), U8(2),
B(TestEqualStrict), R(10), U8(0),
B(JumpIfTrue), U8(22),
B(JumpIfTrue), U8(21),
B(Jump), U8(2),
B(LdaTrue),
B(Star), R(12),
B(Mov), R(9), R(11),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(11), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2),
B(Star), R(5),
B(LdaZero),
B(Star), R(4),
......@@ -398,7 +398,7 @@ bytecodes: [
B(Star), R(11),
B(LdaFalse),
B(Star), R(12),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(11), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(11), U8(2),
B(Star), R(11),
B(LdaContextSlot), R(1), U8(5), U8(0),
B(Star), R(12),
......@@ -414,15 +414,15 @@ bytecodes: [
B(Star), R(14),
B(LdaZero),
B(TestEqualStrict), R(14), U8(0),
B(JumpIfTrue), U8(44),
B(JumpIfTrue), U8(43),
B(LdaSmi), U8(2),
B(TestEqualStrict), R(14), U8(0),
B(JumpIfTrue), U8(34),
B(JumpIfTrue), U8(33),
B(Jump), U8(2),
B(LdaTrue),
B(Star), R(16),
B(Mov), R(13), R(15),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(15), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(15), U8(2),
B(PopContext), R(2),
B(PopContext), R(2),
B(PopContext), R(2),
......@@ -438,7 +438,7 @@ bytecodes: [
B(PopContext), R(2),
B(LdaZero),
B(StaContextSlot), R(1), U8(9), U8(0),
B(Wide), B(JumpLoop), U16(-221), U16(0),
B(Wide), B(JumpLoop), U16(-219), U16(0),
B(Jump), U8(44),
B(Star), R(11),
B(Ldar), R(closure),
......@@ -542,19 +542,19 @@ bytecodes: [
B(LdaSmi), U8(1),
B(Star), R(4),
B(Mov), R(8), R(5),
B(Jump), U8(48),
B(Jump), U8(47),
B(PopContext), R(1),
B(PopContext), R(1),
B(LdaSmi), U8(2),
B(Star), R(4),
B(Mov), R(8), R(5),
B(Jump), U8(35),
B(Jump), U8(34),
B(PopContext), R(1),
B(LdaUndefined),
B(Star), R(7),
B(LdaTrue),
B(Star), R(8),
B(CallRuntime), U16(Runtime::k_CreateIterResultObject), R(7), U8(2),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(7), U8(2),
B(Star), R(5),
B(LdaSmi), U8(3),
B(Star), R(4),
......@@ -606,13 +606,13 @@ constant pool: [
FIXED_ARRAY_TYPE,
CONSTANT_ELEMENTS_PAIR_TYPE,
SYMBOL_TYPE,
Smi [155],
Smi [154],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
FIXED_ARRAY_TYPE,
Smi [135],
Smi [152],
Smi [134],
Smi [150],
ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"],
FIXED_ARRAY_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
......@@ -621,12 +621,12 @@ constant pool: [
FIXED_ARRAY_TYPE,
Smi [133],
Smi [159],
Smi [585],
Smi [582],
]
handlers: [
[46, 694, 700],
[143, 444, 450],
[146, 400, 402],
[546, 562, 564],
[46, 690, 696],
[142, 441, 447],
[145, 397, 399],
[543, 559, 561],
]
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