diff options
Diffstat (limited to 'deps/v8/src/code-factory.cc')
-rw-r--r-- | deps/v8/src/code-factory.cc | 323 |
1 files changed, 202 insertions, 121 deletions
diff --git a/deps/v8/src/code-factory.cc b/deps/v8/src/code-factory.cc index cffb16b7d4..7303f44f2b 100644 --- a/deps/v8/src/code-factory.cc +++ b/deps/v8/src/code-factory.cc @@ -12,17 +12,6 @@ namespace v8 { namespace internal { -namespace { - -// TODO(ishell): make it (const Stub& stub) once CodeStub::GetCode() is const. -template <typename Stub> -Callable make_callable(Stub& stub) { - typedef typename Stub::Descriptor Descriptor; - return Callable(stub.GetCode(), Descriptor{}); -} - -} // namespace - // static Handle<Code> CodeFactory::RuntimeCEntry(Isolate* isolate, int result_size) { return CodeFactory::CEntry(isolate, result_size); @@ -70,54 +59,160 @@ Handle<Code> CodeFactory::CEntry(Isolate* isolate, int result_size, // static Callable CodeFactory::ApiGetter(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, CallApiGetter), ApiGetterDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kCallApiGetter); } // static -Callable CodeFactory::CallApiCallback(Isolate* isolate, int argc) { - switch (argc) { - case 0: - return Callable(BUILTIN_CODE(isolate, CallApiCallback_Argc0), - ApiCallbackDescriptor{}); - case 1: - return Callable(BUILTIN_CODE(isolate, CallApiCallback_Argc1), - ApiCallbackDescriptor{}); - default: { - CallApiCallbackStub stub(isolate, argc); - return make_callable(stub); - } - } - UNREACHABLE(); +Callable CodeFactory::CallApiCallback(Isolate* isolate) { + return Builtins::CallableFor(isolate, Builtins::kCallApiCallback); } // static Callable CodeFactory::LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode) { - return Callable( - typeof_mode == NOT_INSIDE_TYPEOF - ? BUILTIN_CODE(isolate, LoadGlobalICTrampoline) - : BUILTIN_CODE(isolate, LoadGlobalICInsideTypeofTrampoline), - LoadGlobalDescriptor{}); + return typeof_mode == NOT_INSIDE_TYPEOF + ? Builtins::CallableFor(isolate, Builtins::kLoadGlobalICTrampoline) + : Builtins::CallableFor( + isolate, Builtins::kLoadGlobalICInsideTypeofTrampoline); } // static Callable CodeFactory::LoadGlobalICInOptimizedCode(Isolate* isolate, TypeofMode typeof_mode) { - return Callable(typeof_mode == NOT_INSIDE_TYPEOF - ? BUILTIN_CODE(isolate, LoadGlobalIC) - : BUILTIN_CODE(isolate, LoadGlobalICInsideTypeof), - LoadGlobalWithVectorDescriptor{}); + return typeof_mode == NOT_INSIDE_TYPEOF + ? Builtins::CallableFor(isolate, Builtins::kLoadGlobalIC) + : Builtins::CallableFor(isolate, + Builtins::kLoadGlobalICInsideTypeof); } Callable CodeFactory::StoreOwnIC(Isolate* isolate) { // TODO(ishell): Currently we use StoreOwnIC only for storing properties that // already exist in the boilerplate therefore we can use StoreIC. - return Callable(BUILTIN_CODE(isolate, StoreICTrampoline), StoreDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kStoreICTrampoline); } Callable CodeFactory::StoreOwnICInOptimizedCode(Isolate* isolate) { // TODO(ishell): Currently we use StoreOwnIC only for storing properties that // already exist in the boilerplate therefore we can use StoreIC. - return Callable(BUILTIN_CODE(isolate, StoreIC), StoreWithVectorDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kStoreIC); +} + +Callable CodeFactory::KeyedStoreIC_SloppyArguments(Isolate* isolate, + KeyedAccessStoreMode mode) { + Builtins::Name builtin_index; + switch (mode) { + case STANDARD_STORE: + builtin_index = Builtins::kKeyedStoreIC_SloppyArguments_Standard; + break; + case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW: + builtin_index = + Builtins::kKeyedStoreIC_SloppyArguments_GrowNoTransitionHandleCOW; + break; + case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: + builtin_index = + Builtins::kKeyedStoreIC_SloppyArguments_NoTransitionIgnoreOOB; + break; + case STORE_NO_TRANSITION_HANDLE_COW: + builtin_index = + Builtins::kKeyedStoreIC_SloppyArguments_NoTransitionHandleCOW; + break; + default: + UNREACHABLE(); + } + return isolate->builtins()->CallableFor(isolate, builtin_index); +} + +Callable CodeFactory::KeyedStoreIC_Slow(Isolate* isolate, + KeyedAccessStoreMode mode) { + Builtins::Name builtin_index; + switch (mode) { + case STANDARD_STORE: + builtin_index = Builtins::kKeyedStoreIC_Slow_Standard; + break; + case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW: + builtin_index = Builtins::kKeyedStoreIC_Slow_GrowNoTransitionHandleCOW; + break; + case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: + builtin_index = Builtins::kKeyedStoreIC_Slow_NoTransitionIgnoreOOB; + break; + case STORE_NO_TRANSITION_HANDLE_COW: + builtin_index = Builtins::kKeyedStoreIC_Slow_NoTransitionHandleCOW; + break; + default: + UNREACHABLE(); + } + return isolate->builtins()->CallableFor(isolate, builtin_index); +} + +Callable CodeFactory::StoreInArrayLiteralIC_Slow(Isolate* isolate, + KeyedAccessStoreMode mode) { + Builtins::Name builtin_index; + switch (mode) { + case STANDARD_STORE: + builtin_index = Builtins::kStoreInArrayLiteralIC_Slow_Standard; + break; + case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW: + builtin_index = + Builtins::kStoreInArrayLiteralIC_Slow_GrowNoTransitionHandleCOW; + break; + case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: + builtin_index = + Builtins::kStoreInArrayLiteralIC_Slow_NoTransitionIgnoreOOB; + break; + case STORE_NO_TRANSITION_HANDLE_COW: + builtin_index = + Builtins::kStoreInArrayLiteralIC_Slow_NoTransitionHandleCOW; + break; + default: + UNREACHABLE(); + } + return isolate->builtins()->CallableFor(isolate, builtin_index); +} + +Callable CodeFactory::ElementsTransitionAndStore(Isolate* isolate, + KeyedAccessStoreMode mode) { + Builtins::Name builtin_index; + switch (mode) { + case STANDARD_STORE: + builtin_index = Builtins::kElementsTransitionAndStore_Standard; + break; + case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW: + builtin_index = + Builtins::kElementsTransitionAndStore_GrowNoTransitionHandleCOW; + break; + case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: + builtin_index = + Builtins::kElementsTransitionAndStore_NoTransitionIgnoreOOB; + break; + case STORE_NO_TRANSITION_HANDLE_COW: + builtin_index = + Builtins::kElementsTransitionAndStore_NoTransitionHandleCOW; + break; + default: + UNREACHABLE(); + } + return isolate->builtins()->CallableFor(isolate, builtin_index); +} + +Callable CodeFactory::StoreFastElementIC(Isolate* isolate, + KeyedAccessStoreMode mode) { + Builtins::Name builtin_index; + switch (mode) { + case STANDARD_STORE: + builtin_index = Builtins::kStoreFastElementIC_Standard; + break; + case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW: + builtin_index = Builtins::kStoreFastElementIC_GrowNoTransitionHandleCOW; + break; + case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: + builtin_index = Builtins::kStoreFastElementIC_NoTransitionIgnoreOOB; + break; + case STORE_NO_TRANSITION_HANDLE_COW: + builtin_index = Builtins::kStoreFastElementIC_NoTransitionHandleCOW; + break; + default: + UNREACHABLE(); + } + return isolate->builtins()->CallableFor(isolate, builtin_index); } // static @@ -180,33 +275,37 @@ Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags) { // static Callable CodeFactory::ResumeGenerator(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ResumeGeneratorTrampoline), - ResumeGeneratorDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kResumeGeneratorTrampoline); } // static Callable CodeFactory::FrameDropperTrampoline(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, FrameDropperTrampoline), - FrameDropperTrampolineDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kFrameDropperTrampoline); } // static Callable CodeFactory::HandleDebuggerStatement(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, HandleDebuggerStatement), - ContextOnlyDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kHandleDebuggerStatement); } // static Callable CodeFactory::FastNewFunctionContext(Isolate* isolate, ScopeType scope_type) { - return Callable(isolate->builtins()->NewFunctionContext(scope_type), - FastNewFunctionContextDescriptor{}); + switch (scope_type) { + case ScopeType::EVAL_SCOPE: + return Builtins::CallableFor(isolate, + Builtins::kFastNewFunctionContextEval); + case ScopeType::FUNCTION_SCOPE: + return Builtins::CallableFor(isolate, + Builtins::kFastNewFunctionContextFunction); + default: + UNREACHABLE(); + } } // static Callable CodeFactory::ArgumentAdaptor(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ArgumentsAdaptorTrampoline), - ArgumentsAdaptorDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kArgumentsAdaptorTrampoline); } // static @@ -216,14 +315,12 @@ Callable CodeFactory::Call(Isolate* isolate, ConvertReceiverMode mode) { // static Callable CodeFactory::CallWithArrayLike(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, CallWithArrayLike), - CallWithArrayLikeDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kCallWithArrayLike); } // static Callable CodeFactory::CallWithSpread(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, CallWithSpread), - CallWithSpreadDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kCallWithSpread); } // static @@ -234,70 +331,91 @@ Callable CodeFactory::CallFunction(Isolate* isolate, ConvertReceiverMode mode) { // static Callable CodeFactory::CallVarargs(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, CallVarargs), CallVarargsDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kCallVarargs); } // static Callable CodeFactory::CallForwardVarargs(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, CallForwardVarargs), - CallForwardVarargsDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kCallForwardVarargs); } // static Callable CodeFactory::CallFunctionForwardVarargs(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, CallFunctionForwardVarargs), - CallForwardVarargsDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kCallFunctionForwardVarargs); } // static Callable CodeFactory::Construct(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, Construct), JSTrampolineDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kConstruct); } // static Callable CodeFactory::ConstructWithSpread(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ConstructWithSpread), - ConstructWithSpreadDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kConstructWithSpread); } // static Callable CodeFactory::ConstructFunction(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ConstructFunction), - JSTrampolineDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kConstructFunction); } // static Callable CodeFactory::ConstructVarargs(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ConstructVarargs), - ConstructVarargsDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kConstructVarargs); } // static Callable CodeFactory::ConstructForwardVarargs(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ConstructForwardVarargs), - ConstructForwardVarargsDescriptor{}); + return Builtins::CallableFor(isolate, Builtins::kConstructForwardVarargs); } // static Callable CodeFactory::ConstructFunctionForwardVarargs(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, ConstructFunctionForwardVarargs), - ConstructForwardVarargsDescriptor{}); + return Builtins::CallableFor(isolate, + Builtins::kConstructFunctionForwardVarargs); } // static Callable CodeFactory::InterpreterPushArgsThenCall( Isolate* isolate, ConvertReceiverMode receiver_mode, InterpreterPushArgsMode mode) { - return Callable( - isolate->builtins()->InterpreterPushArgsThenCall(receiver_mode, mode), - InterpreterPushArgsThenCallDescriptor{}); + switch (mode) { + case InterpreterPushArgsMode::kArrayFunction: + // There is no special-case handling of calls to Array. They will all go + // through the kOther case below. + UNREACHABLE(); + case InterpreterPushArgsMode::kWithFinalSpread: + return Builtins::CallableFor( + isolate, Builtins::kInterpreterPushArgsThenCallWithFinalSpread); + case InterpreterPushArgsMode::kOther: + switch (receiver_mode) { + case ConvertReceiverMode::kNullOrUndefined: + return Builtins::CallableFor( + isolate, Builtins::kInterpreterPushUndefinedAndArgsThenCall); + case ConvertReceiverMode::kNotNullOrUndefined: + case ConvertReceiverMode::kAny: + return Builtins::CallableFor(isolate, + Builtins::kInterpreterPushArgsThenCall); + } + } + UNREACHABLE(); } // static Callable CodeFactory::InterpreterPushArgsThenConstruct( Isolate* isolate, InterpreterPushArgsMode mode) { - return Callable(isolate->builtins()->InterpreterPushArgsThenConstruct(mode), - InterpreterPushArgsThenConstructDescriptor{}); + switch (mode) { + case InterpreterPushArgsMode::kArrayFunction: + return Builtins::CallableFor( + isolate, Builtins::kInterpreterPushArgsThenConstructArrayFunction); + case InterpreterPushArgsMode::kWithFinalSpread: + return Builtins::CallableFor( + isolate, Builtins::kInterpreterPushArgsThenConstructWithFinalSpread); + case InterpreterPushArgsMode::kOther: + return Builtins::CallableFor(isolate, + Builtins::kInterpreterPushArgsThenConstruct); + } + UNREACHABLE(); } // static @@ -316,20 +434,19 @@ Callable CodeFactory::InterpreterCEntry(Isolate* isolate, int result_size) { // static Callable CodeFactory::InterpreterOnStackReplacement(Isolate* isolate) { - return Callable(BUILTIN_CODE(isolate, InterpreterOnStackReplacement), - ContextOnlyDescriptor{}); + return Builtins::CallableFor(isolate, + Builtins::kInterpreterOnStackReplacement); } // static Callable CodeFactory::ArrayNoArgumentConstructor( Isolate* isolate, ElementsKind kind, AllocationSiteOverrideMode override_mode) { -#define CASE(kind_caps, kind_camel, mode_camel) \ - case kind_caps: \ - return Callable( \ - BUILTIN_CODE(isolate, \ - ArrayNoArgumentConstructor_##kind_camel##_##mode_camel), \ - ArrayNoArgumentConstructorDescriptor{}) +#define CASE(kind_caps, kind_camel, mode_camel) \ + case kind_caps: \ + return Builtins::CallableFor( \ + isolate, \ + Builtins::kArrayNoArgumentConstructor_##kind_camel##_##mode_camel); if (override_mode == DONT_OVERRIDE && AllocationSite::ShouldTrack(kind)) { DCHECK(IsSmiElementsKind(kind)); switch (kind) { @@ -359,13 +476,11 @@ Callable CodeFactory::ArrayNoArgumentConstructor( Callable CodeFactory::ArraySingleArgumentConstructor( Isolate* isolate, ElementsKind kind, AllocationSiteOverrideMode override_mode) { -#define CASE(kind_caps, kind_camel, mode_camel) \ - case kind_caps: \ - return Callable( \ - BUILTIN_CODE( \ - isolate, \ - ArraySingleArgumentConstructor_##kind_camel##_##mode_camel), \ - ArraySingleArgumentConstructorDescriptor{}) +#define CASE(kind_caps, kind_camel, mode_camel) \ + case kind_caps: \ + return Builtins::CallableFor( \ + isolate, \ + Builtins::kArraySingleArgumentConstructor_##kind_camel##_##mode_camel) if (override_mode == DONT_OVERRIDE && AllocationSite::ShouldTrack(kind)) { DCHECK(IsSmiElementsKind(kind)); switch (kind) { @@ -391,39 +506,5 @@ Callable CodeFactory::ArraySingleArgumentConstructor( #undef CASE } -// static -Callable CodeFactory::InternalArrayNoArgumentConstructor(Isolate* isolate, - ElementsKind kind) { - switch (kind) { - case PACKED_ELEMENTS: - return Callable( - BUILTIN_CODE(isolate, InternalArrayNoArgumentConstructor_Packed), - ArrayNoArgumentConstructorDescriptor{}); - case HOLEY_ELEMENTS: - return Callable( - BUILTIN_CODE(isolate, InternalArrayNoArgumentConstructor_Holey), - ArrayNoArgumentConstructorDescriptor{}); - default: - UNREACHABLE(); - } -} - -// static -Callable CodeFactory::InternalArraySingleArgumentConstructor( - Isolate* isolate, ElementsKind kind) { - switch (kind) { - case PACKED_ELEMENTS: - return Callable( - BUILTIN_CODE(isolate, InternalArraySingleArgumentConstructor_Packed), - ArraySingleArgumentConstructorDescriptor{}); - case HOLEY_ELEMENTS: - return Callable( - BUILTIN_CODE(isolate, InternalArraySingleArgumentConstructor_Holey), - ArraySingleArgumentConstructorDescriptor{}); - default: - UNREACHABLE(); - } -} - } // namespace internal } // namespace v8 |