From 6d84b8d57cea1082e070e6d9e170161d021d078a Mon Sep 17 00:00:00 2001 From: jgruber Date: Fri, 23 Feb 2018 13:43:26 +0100 Subject: [PATCH] [builtins] Remove off-heap CallStub and CallRuntime boilerplate This is the follow-up CL to https://chromium-review.googlesource.com/#/c/v8/v8/+/931122. Now that HeapConstants can be loaded through the builtins constants table, the extra CallStub and CallRuntime has become unnecessary. Bug: v8:6666 Change-Id: I02bb7805ac37bed6fe27fdd0689ac22ad7de034b Reviewed-on: https://chromium-review.googlesource.com/931123 Commit-Queue: Jakob Gruber Reviewed-by: Michael Starzinger Cr-Commit-Position: refs/heads/master@{#51512} --- src/builtins/builtins.cc | 15 ++++++- src/code-stub-assembler.h | 75 ---------------------------------- src/compiler/code-assembler.cc | 63 ---------------------------- src/compiler/code-assembler.h | 27 ------------ 4 files changed, 13 insertions(+), 167 deletions(-) diff --git a/src/builtins/builtins.cc b/src/builtins/builtins.cc index 1d3801a918..1b55e559a9 100644 --- a/src/builtins/builtins.cc +++ b/src/builtins/builtins.cc @@ -276,13 +276,20 @@ bool Builtins::IsLazy(int index) { // static bool Builtins::IsIsolateIndependent(int index) { DCHECK(IsBuiltinId(index)); - // TODO(jgruber): Extend this list. switch (index) { +#ifdef DEBUG case kContinueToCodeStubBuiltin: case kContinueToCodeStubBuiltinWithResult: case kContinueToJavaScriptBuiltin: case kContinueToJavaScriptBuiltinWithResult: -#ifndef DEBUG + case kKeyedLoadICTrampoline: + case kKeyedStoreICTrampoline: + case kLoadGlobalICInsideTypeofTrampoline: + case kLoadGlobalICTrampoline: + case kLoadICTrampoline: + case kStoreGlobalICTrampoline: + case kStoreICTrampoline: +#else case kAsyncFunctionAwaitFulfill: case kAsyncFunctionAwaitReject: case kAsyncGeneratorAwaitFulfill: @@ -292,6 +299,10 @@ bool Builtins::IsIsolateIndependent(int index) { case kAsyncGeneratorReturnFulfill: case kAsyncGeneratorYieldFulfill: case kConstructFunction: + case kContinueToCodeStubBuiltin: + case kContinueToCodeStubBuiltinWithResult: + case kContinueToJavaScriptBuiltin: + case kContinueToJavaScriptBuiltinWithResult: case kKeyedLoadICTrampoline: case kKeyedStoreICTrampoline: case kLoadGlobalICInsideTypeofTrampoline: diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h index 51ac09c05e..bc6a173729 100644 --- a/src/code-stub-assembler.h +++ b/src/code-stub-assembler.h @@ -1613,81 +1613,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { Label* if_not_found, Label* if_bailout, GetOwnPropertyMode mode); -#ifdef V8_EMBEDDED_BUILTINS -#if V8_TARGET_ARCH_IA32 -#error "ia32 does not yet support embedded builtins" -#endif - - template - Node* CallStub(Callable const& callable, Node* context, TArgs... args) { - if (ShouldLoadConstantsFromRootList()) { - TNode target = LookupConstantCodeTarget(callable.code()); - return compiler::CodeAssembler::CallStub(callable.descriptor(), target, - context, args...); - } else { - return compiler::CodeAssembler::CallStub(callable, context, args...); - } - } - - template - Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, - Node* context, TArgs... args) { - // Just a forwarding definition, required due to the other overload above. - return compiler::CodeAssembler::CallStub(descriptor, target, context, - args...); - } - - template - Node* TailCallStub(Callable const& callable, Node* context, TArgs... args) { - if (ShouldLoadConstantsFromRootList()) { - TNode target = LookupConstantCodeTarget(callable.code()); - return compiler::CodeAssembler::TailCallStub(callable.descriptor(), - target, context, args...); - } else { - return compiler::CodeAssembler::TailCallStub(callable, context, args...); - } - } - - template - Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target, - Node* context, TArgs... args) { - // Just a forwarding definition, required due to the other overload above. - return compiler::CodeAssembler::TailCallStub(descriptor, target, context, - args...); - } - - template - TNode CallRuntime(Runtime::FunctionId function, - SloppyTNode context, TArgs... args) { - if (ShouldLoadConstantsFromRootList()) { - auto function_info = Runtime::FunctionForId(function); - Handle code = - CodeFactory::RuntimeCEntry(isolate(), function_info->result_size); - TNode target = LookupConstantCodeTarget(code); - return compiler::CodeAssembler::CallRuntime(function, target, context, - args...); - } else { - return compiler::CodeAssembler::CallRuntime(function, context, args...); - } - } - - template - TNode TailCallRuntime(Runtime::FunctionId function, - SloppyTNode context, TArgs... args) { - if (ShouldLoadConstantsFromRootList()) { - auto function_info = Runtime::FunctionForId(function); - Handle code = - CodeFactory::RuntimeCEntry(isolate(), function_info->result_size); - TNode target = LookupConstantCodeTarget(code); - return compiler::CodeAssembler::TailCallRuntime(function, target, context, - args...); - } else { - return compiler::CodeAssembler::TailCallRuntime(function, context, - args...); - } - } -#endif // V8_EMBEDDED_BUILTINS - TNode GetProperty(SloppyTNode context, SloppyTNode receiver, Handle name) { return GetProperty(context, receiver, HeapConstant(name)); diff --git a/src/compiler/code-assembler.cc b/src/compiler/code-assembler.cc index 1ca5afb873..4ad286c68c 100644 --- a/src/compiler/code-assembler.cc +++ b/src/compiler/code-assembler.cc @@ -236,10 +236,6 @@ bool CodeAssembler::IsIntPtrAbsWithOverflowSupported() const { } #ifdef V8_EMBEDDED_BUILTINS -TNode CodeAssembler::LookupConstantCodeTarget(Handle code) { - return CAST(LookupConstant(code)); -} - TNode CodeAssembler::LookupConstant(Handle object) { DCHECK(isolate()->serializer_enabled()); @@ -1054,37 +1050,6 @@ TNode CodeAssembler::CallRuntimeImpl(Runtime::FunctionId function, REPEAT_1_TO_7(INSTANTIATE, SloppyTNode) #undef INSTANTIATE -#ifdef V8_EMBEDDED_BUILTINS -template -TNode CodeAssembler::CallRuntimeImpl(Runtime::FunctionId function, - TNode target, - SloppyTNode context, - TArgs... args) { - int argc = static_cast(sizeof...(args)); - auto call_descriptor = Linkage::GetRuntimeCallDescriptor( - zone(), function, argc, Operator::kNoProperties, - CallDescriptor::kNoFlags); - - Node* ref = ExternalConstant(ExternalReference(function, isolate())); - Node* arity = Int32Constant(argc); - - Node* nodes[] = {target, args..., ref, arity, context}; - - CallPrologue(); - Node* return_value = - raw_assembler()->CallN(call_descriptor, arraysize(nodes), nodes); - CallEpilogue(); - return UncheckedCast(return_value); -} - -// Instantiate CallRuntime() for argument counts used by CSA-generated code -#define INSTANTIATE(...) \ - template V8_EXPORT_PRIVATE TNode CodeAssembler::CallRuntimeImpl( \ - Runtime::FunctionId, TNode, __VA_ARGS__); -REPEAT_1_TO_7(INSTANTIATE, SloppyTNode) -#undef INSTANTIATE -#endif // V8_EMBEDDED_BUILTINS - template TNode CodeAssembler::TailCallRuntimeImpl(Runtime::FunctionId function, SloppyTNode context, @@ -1113,34 +1078,6 @@ TNode CodeAssembler::TailCallRuntimeImpl(Runtime::FunctionId function, REPEAT_1_TO_7(INSTANTIATE, SloppyTNode) #undef INSTANTIATE -#ifdef V8_EMBEDDED_BUILTINS -template -TNode CodeAssembler::TailCallRuntimeImpl(Runtime::FunctionId function, - TNode target, - SloppyTNode context, - TArgs... args) { - int argc = static_cast(sizeof...(args)); - auto call_descriptor = Linkage::GetRuntimeCallDescriptor( - zone(), function, argc, Operator::kNoProperties, - CallDescriptor::kNoFlags); - - Node* ref = ExternalConstant(ExternalReference(function, isolate())); - Node* arity = Int32Constant(argc); - - Node* nodes[] = {target, args..., ref, arity, context}; - - return UncheckedCast( - raw_assembler()->TailCallN(call_descriptor, arraysize(nodes), nodes)); -} - -// Instantiate TailCallRuntime() for argument counts used by CSA-generated code -#define INSTANTIATE(...) \ - template V8_EXPORT_PRIVATE TNode CodeAssembler::TailCallRuntimeImpl( \ - Runtime::FunctionId, TNode, __VA_ARGS__); -REPEAT_1_TO_7(INSTANTIATE, SloppyTNode) -#undef INSTANTIATE -#endif // V8_EMBEDDED_BUILTINS - template Node* CodeAssembler::CallStubR(const CallInterfaceDescriptor& descriptor, size_t result_size, Node* target, Node* context, diff --git a/src/compiler/code-assembler.h b/src/compiler/code-assembler.h index c4e107e13d..924e5b1a37 100644 --- a/src/compiler/code-assembler.h +++ b/src/compiler/code-assembler.h @@ -642,7 +642,6 @@ class V8_EXPORT_PRIVATE CodeAssembler { isolate()->builtins_constants_table_builder() != nullptr); } - TNode LookupConstantCodeTarget(Handle code); TNode LookupConstant(Handle object); #endif @@ -925,18 +924,6 @@ class V8_EXPORT_PRIVATE CodeAssembler { return CallRuntimeImpl(function, context, base::implicit_cast>(args)...); } -#ifdef V8_EMBEDDED_BUILTINS - template - TNode CallRuntimeImpl(Runtime::FunctionId function, - TNode target, SloppyTNode context, - TArgs... args); - template - TNode CallRuntime(Runtime::FunctionId function, TNode target, - SloppyTNode context, TArgs... args) { - return CallRuntimeImpl(function, target, context, - base::implicit_cast>(args)...); - } -#endif template TNode TailCallRuntimeImpl(Runtime::FunctionId function, @@ -947,20 +934,6 @@ class V8_EXPORT_PRIVATE CodeAssembler { return TailCallRuntimeImpl( function, context, base::implicit_cast>(args)...); } -#ifdef V8_EMBEDDED_BUILTINS - template - TNode TailCallRuntimeImpl(Runtime::FunctionId function, - TNode target, - SloppyTNode context, TArgs... args); - template - TNode TailCallRuntime(Runtime::FunctionId function, - TNode target, SloppyTNode context, - TArgs... args) { - return TailCallRuntimeImpl( - function, target, context, - base::implicit_cast>(args)...); - } -#endif // // If context passed to CallStub is nullptr, it won't be passed to the stub.