Commit d21ed46d authored by cbruni's avatar cbruni Committed by Commit bot

[turbofan] Use fast stub for ForInPrepare and ForInNext

Review-Url: https://codereview.chromium.org/2684043002
Cr-Commit-Position: refs/heads/master@{#43040}
parent 2237106a
......@@ -910,6 +910,51 @@ TF_BUILTIN(ForInFilter, ObjectBuiltinsAssembler) {
Return(ForInFilter(key, object, context));
}
TF_BUILTIN(ForInNext, ObjectBuiltinsAssembler) {
typedef ForInNextDescriptor Descriptor;
Label filter(this);
Node* object = Parameter(Descriptor::kObject);
Node* cache_array = Parameter(Descriptor::kCacheArray);
Node* cache_type = Parameter(Descriptor::kCacheType);
Node* index = Parameter(Descriptor::kIndex);
Node* context = Parameter(Descriptor::kContext);
Node* key = LoadFixedArrayElement(cache_array, SmiUntag(index));
Node* map = LoadMap(object);
GotoUnless(WordEqual(map, cache_type), &filter);
Return(key);
Bind(&filter);
Return(ForInFilter(key, object, context));
}
TF_BUILTIN(ForInPrepare, ObjectBuiltinsAssembler) {
typedef ForInPrepareDescriptor Descriptor;
Label use_cache(this), nothing_to_iterate(this), call_runtime(this);
Node* object = Parameter(Descriptor::kObject);
Node* context = Parameter(Descriptor::kContext);
CheckEnumCache(object, &use_cache, &call_runtime);
Bind(&use_cache);
Node* map = LoadMap(object);
Node* enum_length = EnumLength(map);
GotoIf(WordEqual(enum_length, SmiConstant(0)), &nothing_to_iterate);
Node* descriptors = LoadMapDescriptors(map);
Node* cache_offset =
LoadObjectField(descriptors, DescriptorArray::kEnumCacheOffset);
Node* enum_cache = LoadObjectField(
cache_offset, DescriptorArray::kEnumCacheBridgeCacheOffset);
Return(map, enum_cache, enum_length);
Bind(&nothing_to_iterate);
Node* zero = SmiConstant(0);
Return(zero, zero, zero);
Bind(&call_runtime);
TailCallRuntime(Runtime::kForInPrepare, context, object);
}
TF_BUILTIN(InstanceOf, ObjectBuiltinsAssembler) {
typedef CompareDescriptor Descriptor;
......
......@@ -98,7 +98,8 @@ Code* BuildWithCodeStubAssemblerJS(Isolate* isolate,
Code* BuildWithCodeStubAssemblerCS(Isolate* isolate,
CodeAssemblerGenerator generator,
CallDescriptors::Key interface_descriptor,
Code::Flags flags, const char* name) {
Code::Flags flags, const char* name,
int result_size) {
HandleScope scope(isolate);
Zone zone(isolate->allocator(), ZONE_NAME);
// The interface descriptor with given key must be initialized at this point
......@@ -106,7 +107,8 @@ Code* BuildWithCodeStubAssemblerCS(Isolate* isolate,
CallInterfaceDescriptor descriptor(isolate, interface_descriptor);
// Ensure descriptor is already initialized.
DCHECK_LE(0, descriptor.GetRegisterParameterCount());
compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name);
compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name,
result_size);
generator(&state);
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
PostBuildProfileAndTracing(isolate, *code, name);
......@@ -136,11 +138,11 @@ void Builtins::SetUp(Isolate* isolate, bool create_heap_objects) {
code = BuildWithCodeStubAssemblerJS(isolate, &Generate_##Name, Argc, \
kBuiltinFlags, #Name); \
builtins_[index++] = code;
#define BUILD_TFS(Name, Kind, Extra, InterfaceDescriptor) \
#define BUILD_TFS(Name, Kind, Extra, InterfaceDescriptor, result_size) \
{ InterfaceDescriptor##Descriptor descriptor(isolate); } \
code = BuildWithCodeStubAssemblerCS( \
isolate, &Generate_##Name, CallDescriptors::InterfaceDescriptor, \
Code::ComputeFlags(Code::Kind, Extra), #Name); \
Code::ComputeFlags(Code::Kind, Extra), #Name, result_size); \
builtins_[index++] = code;
#define BUILD_ASM(Name) \
code = \
......
......@@ -42,7 +42,7 @@ class Isolate;
// TFJ: Builtin in Turbofan, with JS linkage (callable as Javascript function).
// Args: name, arguments count
// TFS: Builtin in Turbofan, with CodeStub linkage.
// Args: name, code kind, extra IC state, interface descriptor
// Args: name, code kind, extra IC state, interface descriptor, return_size
// ASM: Builtin in platform-dependent assembly.
// Args: name
// ASH: Handlers implemented in platform-dependent assembly.
......@@ -56,9 +56,9 @@ class Isolate;
\
/* Declared first for dependency reasons */ \
ASM(CompileLazy) \
TFS(ToObject, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(FastNewObject, BUILTIN, kNoExtraICState, FastNewObject) \
TFS(HasProperty, BUILTIN, kNoExtraICState, HasProperty) \
TFS(ToObject, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(FastNewObject, BUILTIN, kNoExtraICState, FastNewObject, 1) \
TFS(HasProperty, BUILTIN, kNoExtraICState, HasProperty, 1) \
\
/* Calls */ \
ASM(ArgumentsAdaptorTrampoline) \
......@@ -98,33 +98,33 @@ class Isolate;
ASM(JSConstructStubGeneric) \
ASM(JSBuiltinsConstructStub) \
ASM(JSBuiltinsConstructStubForDerived) \
TFS(FastNewClosure, BUILTIN, kNoExtraICState, FastNewClosure) \
TFS(FastNewClosure, BUILTIN, kNoExtraICState, FastNewClosure, 1) \
TFS(FastNewFunctionContextEval, BUILTIN, kNoExtraICState, \
FastNewFunctionContext) \
FastNewFunctionContext, 1) \
TFS(FastNewFunctionContextFunction, BUILTIN, kNoExtraICState, \
FastNewFunctionContext) \
TFS(FastNewStrictArguments, BUILTIN, kNoExtraICState, FastNewArguments) \
TFS(FastNewSloppyArguments, BUILTIN, kNoExtraICState, FastNewArguments) \
TFS(FastNewRestParameter, BUILTIN, kNoExtraICState, FastNewArguments) \
TFS(FastCloneRegExp, BUILTIN, kNoExtraICState, FastCloneRegExp) \
FastNewFunctionContext, 1) \
TFS(FastNewStrictArguments, BUILTIN, kNoExtraICState, FastNewArguments, 1) \
TFS(FastNewSloppyArguments, BUILTIN, kNoExtraICState, FastNewArguments, 1) \
TFS(FastNewRestParameter, BUILTIN, kNoExtraICState, FastNewArguments, 1) \
TFS(FastCloneRegExp, BUILTIN, kNoExtraICState, FastCloneRegExp, 1) \
TFS(FastCloneShallowArrayTrack, BUILTIN, kNoExtraICState, \
FastCloneShallowArray) \
FastCloneShallowArray, 1) \
TFS(FastCloneShallowArrayDontTrack, BUILTIN, kNoExtraICState, \
FastCloneShallowArray) \
FastCloneShallowArray, 1) \
TFS(FastCloneShallowObject0, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
TFS(FastCloneShallowObject1, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
TFS(FastCloneShallowObject2, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
TFS(FastCloneShallowObject3, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
TFS(FastCloneShallowObject4, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
TFS(FastCloneShallowObject5, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
TFS(FastCloneShallowObject6, BUILTIN, kNoExtraICState, \
FastCloneShallowObject) \
FastCloneShallowObject, 1) \
\
/* Apply and entries */ \
ASM(Apply) \
......@@ -137,15 +137,15 @@ class Isolate;
ASM(StackCheck) \
\
/* String helpers */ \
TFS(StringCharAt, BUILTIN, kNoExtraICState, StringCharAt) \
TFS(StringCharCodeAt, BUILTIN, kNoExtraICState, StringCharCodeAt) \
TFS(StringEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(StringGreaterThan, BUILTIN, kNoExtraICState, Compare) \
TFS(StringGreaterThanOrEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(StringIndexOf, BUILTIN, kNoExtraICState, StringIndexOf) \
TFS(StringLessThan, BUILTIN, kNoExtraICState, Compare) \
TFS(StringLessThanOrEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(StringNotEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(StringCharAt, BUILTIN, kNoExtraICState, StringCharAt, 1) \
TFS(StringCharCodeAt, BUILTIN, kNoExtraICState, StringCharCodeAt, 1) \
TFS(StringEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StringGreaterThan, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StringGreaterThanOrEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StringIndexOf, BUILTIN, kNoExtraICState, StringIndexOf, 1) \
TFS(StringLessThan, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StringLessThanOrEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StringNotEqual, BUILTIN, kNoExtraICState, Compare, 1) \
\
/* Interpreter */ \
ASM(InterpreterEntryTrampoline) \
......@@ -190,14 +190,14 @@ class Isolate;
\
/* TurboFan support builtins */ \
TFS(CopyFastSmiOrObjectElements, BUILTIN, kNoExtraICState, \
CopyFastSmiOrObjectElements) \
TFS(GrowFastDoubleElements, BUILTIN, kNoExtraICState, GrowArrayElements) \
CopyFastSmiOrObjectElements, 1) \
TFS(GrowFastDoubleElements, BUILTIN, kNoExtraICState, GrowArrayElements, 1) \
TFS(GrowFastSmiOrObjectElements, BUILTIN, kNoExtraICState, \
GrowArrayElements) \
GrowArrayElements, 1) \
TFS(NewUnmappedArgumentsElements, BUILTIN, kNoExtraICState, \
NewArgumentsElements) \
NewArgumentsElements, 1) \
TFS(NewRestParameterElements, BUILTIN, kNoExtraICState, \
NewArgumentsElements) \
NewArgumentsElements, 1) \
\
/* Debugger */ \
DBG(FrameDropperTrampoline) \
......@@ -206,47 +206,48 @@ class Isolate;
DBG(Slot_DebugBreak) \
\
/* Type conversions */ \
TFS(ToBoolean, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(OrdinaryToPrimitive_Number, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(OrdinaryToPrimitive_String, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ToBoolean, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(OrdinaryToPrimitive_Number, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(OrdinaryToPrimitive_String, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(NonPrimitiveToPrimitive_Default, BUILTIN, kNoExtraICState, \
TypeConversion) \
TypeConversion, 1) \
TFS(NonPrimitiveToPrimitive_Number, BUILTIN, kNoExtraICState, \
TypeConversion) \
TypeConversion, 1) \
TFS(NonPrimitiveToPrimitive_String, BUILTIN, kNoExtraICState, \
TypeConversion) \
TFS(StringToNumber, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ToName, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(NonNumberToNumber, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ToNumber, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ToString, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ToInteger, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ToLength, BUILTIN, kNoExtraICState, TypeConversion) \
TFS(ClassOf, BUILTIN, kNoExtraICState, Typeof) \
TFS(Typeof, BUILTIN, kNoExtraICState, Typeof) \
TFS(GetSuperConstructor, BUILTIN, kNoExtraICState, TypeConversion) \
TypeConversion, 1) \
TFS(StringToNumber, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(ToName, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(NonNumberToNumber, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(ToNumber, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(ToString, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(ToInteger, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(ToLength, BUILTIN, kNoExtraICState, TypeConversion, 1) \
TFS(ClassOf, BUILTIN, kNoExtraICState, Typeof, 1) \
TFS(Typeof, BUILTIN, kNoExtraICState, Typeof, 1) \
TFS(GetSuperConstructor, BUILTIN, kNoExtraICState, TypeConversion, 1) \
\
/* Handlers */ \
TFS(LoadICProtoArray, BUILTIN, kNoExtraICState, LoadICProtoArray) \
TFS(LoadICProtoArray, BUILTIN, kNoExtraICState, LoadICProtoArray, 1) \
TFS(LoadICProtoArrayThrowIfNonexistent, BUILTIN, kNoExtraICState, \
LoadICProtoArray) \
TFS(KeyedLoadIC_Megamorphic, BUILTIN, kNoExtraICState, LoadWithVector) \
TFS(KeyedLoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
TFS(KeyedLoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector) \
TFS(KeyedStoreIC_Megamorphic, BUILTIN, kNoExtraICState, StoreWithVector) \
LoadICProtoArray, 1) \
TFS(KeyedLoadIC_Megamorphic, BUILTIN, kNoExtraICState, LoadWithVector, 1) \
TFS(KeyedLoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector, 1) \
TFS(KeyedLoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector, 1) \
TFS(KeyedStoreIC_Megamorphic, BUILTIN, kNoExtraICState, StoreWithVector, 1) \
TFS(KeyedStoreIC_Megamorphic_Strict, BUILTIN, kNoExtraICState, \
StoreWithVector) \
TFS(KeyedStoreIC_Miss, BUILTIN, kNoExtraICState, StoreWithVector) \
TFS(KeyedStoreIC_Slow, HANDLER, Code::STORE_IC, StoreWithVector) \
TFS(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector) \
TFS(LoadGlobalIC_Slow, HANDLER, Code::LOAD_GLOBAL_IC, LoadGlobalWithVector) \
TFS(LoadField, BUILTIN, kNoExtraICState, LoadField) \
StoreWithVector, 1) \
TFS(KeyedStoreIC_Miss, BUILTIN, kNoExtraICState, StoreWithVector, 1) \
TFS(KeyedStoreIC_Slow, HANDLER, Code::STORE_IC, StoreWithVector, 1) \
TFS(LoadGlobalIC_Miss, BUILTIN, kNoExtraICState, LoadGlobalWithVector, 1) \
TFS(LoadGlobalIC_Slow, HANDLER, Code::LOAD_GLOBAL_IC, LoadGlobalWithVector, \
1) \
TFS(LoadField, BUILTIN, kNoExtraICState, LoadField, 1) \
ASH(LoadIC_Getter_ForDeopt, BUILTIN, kNoExtraICState) \
TFS(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector) \
TFS(LoadIC_Normal, HANDLER, Code::LOAD_IC, LoadWithVector) \
TFS(LoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector) \
TFS(StoreIC_Miss, BUILTIN, kNoExtraICState, StoreWithVector) \
TFS(StoreIC_Normal, HANDLER, Code::STORE_IC, StoreWithVector) \
TFS(LoadIC_Miss, BUILTIN, kNoExtraICState, LoadWithVector, 1) \
TFS(LoadIC_Normal, HANDLER, Code::LOAD_IC, LoadWithVector, 1) \
TFS(LoadIC_Slow, HANDLER, Code::LOAD_IC, LoadWithVector, 1) \
TFS(StoreIC_Miss, BUILTIN, kNoExtraICState, StoreWithVector, 1) \
TFS(StoreIC_Normal, HANDLER, Code::STORE_IC, StoreWithVector, 1) \
ASH(StoreIC_Setter_ForDeopt, BUILTIN, kNoExtraICState) \
\
/* Built-in functions for Javascript */ \
......@@ -440,7 +441,7 @@ class Isolate;
\
/* Belongs to Objects but is a dependency of GeneratorPrototypeResume */ \
TFS(CreateIterResultObject, BUILTIN, kNoExtraICState, \
CreateIterResultObject) \
CreateIterResultObject, 1) \
\
/* Generator and Async */ \
CPP(GeneratorFunctionConstructor) \
......@@ -470,24 +471,24 @@ class Isolate;
CPP(JsonStringify) \
\
/* ICs */ \
TFS(LoadIC, LOAD_IC, kNoExtraICState, LoadWithVector) \
TFS(LoadICTrampoline, LOAD_IC, kNoExtraICState, Load) \
TFS(KeyedLoadIC, KEYED_LOAD_IC, kNoExtraICState, LoadWithVector) \
TFS(KeyedLoadICTrampoline, KEYED_LOAD_IC, kNoExtraICState, Load) \
TFS(StoreIC, STORE_IC, kNoExtraICState, StoreWithVector) \
TFS(StoreICTrampoline, STORE_IC, kNoExtraICState, Store) \
TFS(StoreICStrict, STORE_IC, kNoExtraICState, StoreWithVector) \
TFS(StoreICStrictTrampoline, STORE_IC, kNoExtraICState, Store) \
TFS(KeyedStoreIC, KEYED_STORE_IC, kNoExtraICState, StoreWithVector) \
TFS(KeyedStoreICTrampoline, KEYED_STORE_IC, kNoExtraICState, Store) \
TFS(KeyedStoreICStrict, KEYED_STORE_IC, kNoExtraICState, StoreWithVector) \
TFS(KeyedStoreICStrictTrampoline, KEYED_STORE_IC, kNoExtraICState, Store) \
TFS(LoadGlobalIC, LOAD_GLOBAL_IC, kNoExtraICState, LoadGlobalWithVector) \
TFS(LoadIC, LOAD_IC, kNoExtraICState, LoadWithVector, 1) \
TFS(LoadICTrampoline, LOAD_IC, kNoExtraICState, Load, 1) \
TFS(KeyedLoadIC, KEYED_LOAD_IC, kNoExtraICState, LoadWithVector, 1) \
TFS(KeyedLoadICTrampoline, KEYED_LOAD_IC, kNoExtraICState, Load, 1) \
TFS(StoreIC, STORE_IC, kNoExtraICState, StoreWithVector, 1) \
TFS(StoreICTrampoline, STORE_IC, kNoExtraICState, Store, 1) \
TFS(StoreICStrict, STORE_IC, kNoExtraICState, StoreWithVector, 1) \
TFS(StoreICStrictTrampoline, STORE_IC, kNoExtraICState, Store, 1) \
TFS(KeyedStoreIC, KEYED_STORE_IC, kNoExtraICState, StoreWithVector, 1) \
TFS(KeyedStoreICTrampoline, KEYED_STORE_IC, kNoExtraICState, Store, 1) \
TFS(KeyedStoreICStrict, KEYED_STORE_IC, kNoExtraICState, StoreWithVector, 1) \
TFS(KeyedStoreICStrictTrampoline, KEYED_STORE_IC, kNoExtraICState, Store, 1) \
TFS(LoadGlobalIC, LOAD_GLOBAL_IC, kNoExtraICState, LoadGlobalWithVector, 1) \
TFS(LoadGlobalICInsideTypeof, LOAD_GLOBAL_IC, kNoExtraICState, \
LoadGlobalWithVector) \
TFS(LoadGlobalICTrampoline, LOAD_GLOBAL_IC, kNoExtraICState, LoadGlobal) \
LoadGlobalWithVector, 1) \
TFS(LoadGlobalICTrampoline, LOAD_GLOBAL_IC, kNoExtraICState, LoadGlobal, 1) \
TFS(LoadGlobalICInsideTypeofTrampoline, LOAD_GLOBAL_IC, kNoExtraICState, \
LoadGlobal) \
LoadGlobal, 1) \
\
/* Math */ \
/* ES6 section 20.2.2.1 Math.abs ( x ) */ \
......@@ -585,25 +586,25 @@ class Isolate;
CPP(NumberPrototypeToString) \
/* ES6 section 20.1.3.7 Number.prototype.valueOf ( ) */ \
TFJ(NumberPrototypeValueOf, 0) \
TFS(Add, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(Subtract, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(Multiply, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(Divide, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(Modulus, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(BitwiseAnd, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(BitwiseOr, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(BitwiseXor, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(ShiftLeft, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(ShiftRight, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(ShiftRightLogical, BUILTIN, kNoExtraICState, BinaryOp) \
TFS(LessThan, BUILTIN, kNoExtraICState, Compare) \
TFS(LessThanOrEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(GreaterThan, BUILTIN, kNoExtraICState, Compare) \
TFS(GreaterThanOrEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(Equal, BUILTIN, kNoExtraICState, Compare) \
TFS(NotEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(StrictEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(StrictNotEqual, BUILTIN, kNoExtraICState, Compare) \
TFS(Add, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(Subtract, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(Multiply, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(Divide, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(Modulus, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(BitwiseAnd, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(BitwiseOr, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(BitwiseXor, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(ShiftLeft, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(ShiftRight, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(ShiftRightLogical, BUILTIN, kNoExtraICState, BinaryOp, 1) \
TFS(LessThan, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(LessThanOrEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(GreaterThan, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(GreaterThanOrEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(Equal, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(NotEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StrictEqual, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(StrictNotEqual, BUILTIN, kNoExtraICState, Compare, 1) \
\
/* Object */ \
CPP(ObjectAssign) \
......@@ -638,9 +639,11 @@ class Isolate;
CPP(ObjectSeal) \
CPP(ObjectValues) \
\
TFS(InstanceOf, BUILTIN, kNoExtraICState, Compare) \
TFS(OrdinaryHasInstance, BUILTIN, kNoExtraICState, Compare) \
TFS(ForInFilter, BUILTIN, kNoExtraICState, ForInFilter) \
TFS(InstanceOf, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(OrdinaryHasInstance, BUILTIN, kNoExtraICState, Compare, 1) \
TFS(ForInFilter, BUILTIN, kNoExtraICState, ForInFilter, 1) \
TFS(ForInNext, BUILTIN, kNoExtraICState, ForInNext, 1) \
TFS(ForInPrepare, BUILTIN, kNoExtraICState, ForInPrepare, 3) \
\
/* Promise */ \
TFJ(PromiseGetCapabilitiesExecutor, 2) \
......@@ -653,7 +656,7 @@ class Isolate;
TFJ(PromiseThen, 2) \
TFJ(PromiseCatch, 1) \
TFJ(ResolvePromise, 2) \
TFS(PromiseHandleReject, BUILTIN, kNoExtraICState, PromiseHandleReject) \
TFS(PromiseHandleReject, BUILTIN, kNoExtraICState, PromiseHandleReject, 1) \
TFJ(PromiseHandle, 5) \
TFJ(PromiseResolve, 1) \
TFJ(PromiseReject, 1) \
......@@ -710,10 +713,10 @@ class Isolate;
TFJ(RegExpPrototypeUnicodeGetter, 0) \
CPP(RegExpRightContextGetter) \
\
TFS(RegExpReplace, BUILTIN, kNoExtraICState, RegExpReplace) \
TFS(RegExpReplace, BUILTIN, kNoExtraICState, RegExpReplace, 1) \
TFJ(RegExpPrototypeReplace, 2) \
\
TFS(RegExpSplit, BUILTIN, kNoExtraICState, RegExpSplit) \
TFS(RegExpSplit, BUILTIN, kNoExtraICState, RegExpSplit, 1) \
TFJ(RegExpPrototypeSplit, 2) \
\
/* SharedArrayBuffer */ \
......
......@@ -193,7 +193,7 @@ Callable CodeFactory::StringFromCharCode(Isolate* isolate) {
return Callable(code, BuiltinDescriptor(isolate));
}
#define DECLARE_TFS(Name, Kind, Extra, InterfaceDescriptor) \
#define DECLARE_TFS(Name, Kind, Extra, InterfaceDescriptor, result_size) \
typedef InterfaceDescriptor##Descriptor Name##Descriptor;
BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TFS,
IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN)
......@@ -363,6 +363,18 @@ Callable CodeFactory::FastNewStrictArguments(Isolate* isolate) {
FastNewRestParameterDescriptor(isolate));
}
// static
Callable CodeFactory::ForInPrepare(Isolate* isolate) {
return Callable(isolate->builtins()->ForInPrepare(),
ForInPrepareDescriptor(isolate));
}
// static
Callable CodeFactory::ForInNext(Isolate* isolate) {
return Callable(isolate->builtins()->ForInNext(),
ForInNextDescriptor(isolate));
}
// static
Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
AllocateHeapNumberStub stub(isolate);
......
......@@ -152,6 +152,9 @@ class V8_EXPORT_PRIVATE CodeFactory final {
static Callable FastNewSloppyArguments(Isolate* isolate);
static Callable FastNewStrictArguments(Isolate* isolate);
static Callable ForInPrepare(Isolate* isolate);
static Callable ForInNext(Isolate* isolate);
static Callable CopyFastSmiOrObjectElements(Isolate* isolate);
static Callable GrowFastDoubleElements(Isolate* isolate);
static Callable GrowFastSmiOrObjectElements(Isolate* isolate);
......
......@@ -260,6 +260,14 @@ void CodeAssembler::Return(Node* value) {
return raw_assembler()->Return(value);
}
void CodeAssembler::Return(Node* value1, Node* value2) {
return raw_assembler()->Return(value1, value2);
}
void CodeAssembler::Return(Node* value1, Node* value2, Node* value3) {
return raw_assembler()->Return(value1, value2, value3);
}
void CodeAssembler::PopAndReturn(Node* pop, Node* value) {
return raw_assembler()->PopAndReturn(pop, value);
}
......
......@@ -229,6 +229,8 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* Parameter(int value);
Node* GetJSContextParameter();
void Return(Node* value);
void Return(Node* value1, Node* value2);
void Return(Node* value1, Node* value2, Node* value3);
void PopAndReturn(Node* pop, Node* value);
void DebugBreak();
......
......@@ -88,11 +88,12 @@ void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
CallDescriptor::Flags flags,
Operator::Properties properties) {
Operator::Properties properties,
int result_size) {
const CallInterfaceDescriptor& descriptor = callable.descriptor();
CallDescriptor* desc = Linkage::GetStubCallDescriptor(
isolate(), zone(), descriptor, descriptor.GetStackParameterCount(), flags,
properties);
properties, MachineType::AnyTagged(), result_size);
Node* stub_code = jsgraph()->HeapConstant(callable.code());
node->InsertInput(zone(), 0, stub_code);
NodeProperties::ChangeOp(node, common()->Call(desc));
......@@ -586,12 +587,15 @@ void JSGenericLowering::LowerJSConvertReceiver(Node* node) {
}
void JSGenericLowering::LowerJSForInNext(Node* node) {
ReplaceWithRuntimeCall(node, Runtime::kForInNext);
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = CodeFactory::ForInNext(isolate());
ReplaceWithStubCall(node, callable, flags);
}
void JSGenericLowering::LowerJSForInPrepare(Node* node) {
ReplaceWithRuntimeCall(node, Runtime::kForInPrepare);
CallDescriptor::Flags flags = FrameStateFlagForCall(node);
Callable callable = CodeFactory::ForInPrepare(isolate());
ReplaceWithStubCall(node, callable, flags, node->op()->properties(), 3);
}
void JSGenericLowering::LowerJSLoadMessage(Node* node) {
......
......@@ -38,7 +38,8 @@ class JSGenericLowering final : public Reducer {
// Helpers to replace existing nodes with a generic call.
void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags);
void ReplaceWithStubCall(Node* node, Callable c, CallDescriptor::Flags flags,
Operator::Properties properties);
Operator::Properties properties,
int result_size = 1);
void ReplaceWithRuntimeCall(Node* node, Runtime::FunctionId f, int args = -1);
Zone* zone() const;
......
......@@ -87,6 +87,8 @@ class PlatformInterfaceDescriptor;
V(CreateIterResultObject) \
V(HasProperty) \
V(ForInFilter) \
V(ForInNext) \
V(ForInPrepare) \
V(GetProperty) \
V(CallHandler) \
V(ArgumentAdaptor) \
......@@ -531,6 +533,20 @@ class ForInFilterDescriptor final : public CallInterfaceDescriptor {
kParameterCount)
};
class ForInNextDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kObject, kCacheArray, kCacheType, kIndex)
DECLARE_DEFAULT_DESCRIPTOR(ForInNextDescriptor, CallInterfaceDescriptor,
kParameterCount)
};
class ForInPrepareDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kObject)
DECLARE_DEFAULT_DESCRIPTOR(ForInPrepareDescriptor, CallInterfaceDescriptor,
kParameterCount)
};
class GetPropertyDescriptor final : public CallInterfaceDescriptor {
public:
DEFINE_PARAMETERS(kObject, kKey)
......
......@@ -160,22 +160,5 @@ RUNTIME_FUNCTION(Runtime_ForInFilter) {
HasEnumerableProperty(isolate, receiver, key));
}
RUNTIME_FUNCTION(Runtime_ForInNext) {
HandleScope scope(isolate);
DCHECK_EQ(4, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, cache_array, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 2);
CONVERT_SMI_ARG_CHECKED(index, 3);
Handle<Object> key = handle(cache_array->get(index), isolate);
// Don't need filtering if expected map still matches that of the receiver.
if (receiver->map() == *cache_type) {
return *key;
}
RETURN_RESULT_OR_FAILURE(isolate,
HasEnumerableProperty(isolate, receiver, key));
}
} // namespace internal
} // namespace v8
......@@ -209,8 +209,7 @@ namespace internal {
#define FOR_EACH_INTRINSIC_FORIN(F) \
F(ForInEnumerate, 1, 1) \
F(ForInFilter, 2, 1) \
F(ForInHasProperty, 2, 1) \
F(ForInNext, 4, 1)
F(ForInHasProperty, 2, 1)
#define FOR_EACH_INTRINSIC_INTERPRETER(F) \
F(InterpreterNewClosure, 4, 1) \
......
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