Commit 6d84b8d5 authored by jgruber's avatar jgruber Committed by Commit Bot

[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 <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51512}
parent efd5f6d8
......@@ -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:
......
......@@ -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 <class... TArgs>
Node* CallStub(Callable const& callable, Node* context, TArgs... args) {
if (ShouldLoadConstantsFromRootList()) {
TNode<Code> target = LookupConstantCodeTarget(callable.code());
return compiler::CodeAssembler::CallStub(callable.descriptor(), target,
context, args...);
} else {
return compiler::CodeAssembler::CallStub(callable, context, args...);
}
}
template <class... TArgs>
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 <class... TArgs>
Node* TailCallStub(Callable const& callable, Node* context, TArgs... args) {
if (ShouldLoadConstantsFromRootList()) {
TNode<Code> target = LookupConstantCodeTarget(callable.code());
return compiler::CodeAssembler::TailCallStub(callable.descriptor(),
target, context, args...);
} else {
return compiler::CodeAssembler::TailCallStub(callable, context, args...);
}
}
template <class... TArgs>
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 <class... TArgs>
TNode<Object> CallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args) {
if (ShouldLoadConstantsFromRootList()) {
auto function_info = Runtime::FunctionForId(function);
Handle<Code> code =
CodeFactory::RuntimeCEntry(isolate(), function_info->result_size);
TNode<Code> target = LookupConstantCodeTarget(code);
return compiler::CodeAssembler::CallRuntime(function, target, context,
args...);
} else {
return compiler::CodeAssembler::CallRuntime(function, context, args...);
}
}
template <class... TArgs>
TNode<Object> TailCallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args) {
if (ShouldLoadConstantsFromRootList()) {
auto function_info = Runtime::FunctionForId(function);
Handle<Code> code =
CodeFactory::RuntimeCEntry(isolate(), function_info->result_size);
TNode<Code> target = LookupConstantCodeTarget(code);
return compiler::CodeAssembler::TailCallRuntime(function, target, context,
args...);
} else {
return compiler::CodeAssembler::TailCallRuntime(function, context,
args...);
}
}
#endif // V8_EMBEDDED_BUILTINS
TNode<Object> GetProperty(SloppyTNode<Context> context,
SloppyTNode<Object> receiver, Handle<Name> name) {
return GetProperty(context, receiver, HeapConstant(name));
......
......@@ -236,10 +236,6 @@ bool CodeAssembler::IsIntPtrAbsWithOverflowSupported() const {
}
#ifdef V8_EMBEDDED_BUILTINS
TNode<Code> CodeAssembler::LookupConstantCodeTarget(Handle<Code> code) {
return CAST(LookupConstant(code));
}
TNode<HeapObject> CodeAssembler::LookupConstant(Handle<HeapObject> object) {
DCHECK(isolate()->serializer_enabled());
......@@ -1054,37 +1050,6 @@ TNode<Object> CodeAssembler::CallRuntimeImpl(Runtime::FunctionId function,
REPEAT_1_TO_7(INSTANTIATE, SloppyTNode<Object>)
#undef INSTANTIATE
#ifdef V8_EMBEDDED_BUILTINS
template <class... TArgs>
TNode<Object> CodeAssembler::CallRuntimeImpl(Runtime::FunctionId function,
TNode<Code> target,
SloppyTNode<Object> context,
TArgs... args) {
int argc = static_cast<int>(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<Object>(return_value);
}
// Instantiate CallRuntime() for argument counts used by CSA-generated code
#define INSTANTIATE(...) \
template V8_EXPORT_PRIVATE TNode<Object> CodeAssembler::CallRuntimeImpl( \
Runtime::FunctionId, TNode<Code>, __VA_ARGS__);
REPEAT_1_TO_7(INSTANTIATE, SloppyTNode<Object>)
#undef INSTANTIATE
#endif // V8_EMBEDDED_BUILTINS
template <class... TArgs>
TNode<Object> CodeAssembler::TailCallRuntimeImpl(Runtime::FunctionId function,
SloppyTNode<Object> context,
......@@ -1113,34 +1078,6 @@ TNode<Object> CodeAssembler::TailCallRuntimeImpl(Runtime::FunctionId function,
REPEAT_1_TO_7(INSTANTIATE, SloppyTNode<Object>)
#undef INSTANTIATE
#ifdef V8_EMBEDDED_BUILTINS
template <class... TArgs>
TNode<Object> CodeAssembler::TailCallRuntimeImpl(Runtime::FunctionId function,
TNode<Code> target,
SloppyTNode<Object> context,
TArgs... args) {
int argc = static_cast<int>(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<Object>(
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<Object> CodeAssembler::TailCallRuntimeImpl( \
Runtime::FunctionId, TNode<Code>, __VA_ARGS__);
REPEAT_1_TO_7(INSTANTIATE, SloppyTNode<Object>)
#undef INSTANTIATE
#endif // V8_EMBEDDED_BUILTINS
template <class... TArgs>
Node* CodeAssembler::CallStubR(const CallInterfaceDescriptor& descriptor,
size_t result_size, Node* target, Node* context,
......
......@@ -642,7 +642,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
isolate()->builtins_constants_table_builder() != nullptr);
}
TNode<Code> LookupConstantCodeTarget(Handle<Code> code);
TNode<HeapObject> LookupConstant(Handle<HeapObject> object);
#endif
......@@ -925,18 +924,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
return CallRuntimeImpl(function, context,
base::implicit_cast<SloppyTNode<Object>>(args)...);
}
#ifdef V8_EMBEDDED_BUILTINS
template <class... TArgs>
TNode<Object> CallRuntimeImpl(Runtime::FunctionId function,
TNode<Code> target, SloppyTNode<Object> context,
TArgs... args);
template <class... TArgs>
TNode<Object> CallRuntime(Runtime::FunctionId function, TNode<Code> target,
SloppyTNode<Object> context, TArgs... args) {
return CallRuntimeImpl(function, target, context,
base::implicit_cast<SloppyTNode<Object>>(args)...);
}
#endif
template <class... TArgs>
TNode<Object> TailCallRuntimeImpl(Runtime::FunctionId function,
......@@ -947,20 +934,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
return TailCallRuntimeImpl(
function, context, base::implicit_cast<SloppyTNode<Object>>(args)...);
}
#ifdef V8_EMBEDDED_BUILTINS
template <class... TArgs>
TNode<Object> TailCallRuntimeImpl(Runtime::FunctionId function,
TNode<Code> target,
SloppyTNode<Object> context, TArgs... args);
template <class... TArgs>
TNode<Object> TailCallRuntime(Runtime::FunctionId function,
TNode<Code> target, SloppyTNode<Object> context,
TArgs... args) {
return TailCallRuntimeImpl(
function, target, context,
base::implicit_cast<SloppyTNode<Object>>(args)...);
}
#endif
//
// If context passed to CallStub is nullptr, it won't be passed to the stub.
......
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