Commit 38be8e06 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Avoid massive template instantiation in CodeAssembler

Instead of instantiating each function multiple times, just call out to
a common function, passing the variadic number of arguments in an
initializer list.

R=tebbi@chromium.org

Bug: v8:7754
Change-Id: Idb2d77cef7cf8e590de6aa3cea02c0e0773da45f
Reviewed-on: https://chromium-review.googlesource.com/1101689
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53785}
parent f67e424d
This diff is collapsed.
...@@ -983,7 +983,7 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -983,7 +983,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<Object> CallRuntime(Runtime::FunctionId function, TNode<Object> CallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args) { SloppyTNode<Object> context, TArgs... args) {
return CallRuntimeImpl(function, context, return CallRuntimeImpl(function, context,
implicit_cast<SloppyTNode<Object>>(args)...); {implicit_cast<SloppyTNode<Object>>(args)...});
} }
template <class... TArgs> template <class... TArgs>
...@@ -992,14 +992,14 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -992,14 +992,14 @@ class V8_EXPORT_PRIVATE CodeAssembler {
int argc = static_cast<int>(sizeof...(args)); int argc = static_cast<int>(sizeof...(args));
TNode<Int32T> arity = Int32Constant(argc); TNode<Int32T> arity = Int32Constant(argc);
return TailCallRuntimeImpl(function, arity, context, return TailCallRuntimeImpl(function, arity, context,
implicit_cast<SloppyTNode<Object>>(args)...); {implicit_cast<SloppyTNode<Object>>(args)...});
} }
template <class... TArgs> template <class... TArgs>
void TailCallRuntime(Runtime::FunctionId function, TNode<Int32T> arity, void TailCallRuntime(Runtime::FunctionId function, TNode<Int32T> arity,
SloppyTNode<Object> context, TArgs... args) { SloppyTNode<Object> context, TArgs... args) {
return TailCallRuntimeImpl(function, arity, context, return TailCallRuntimeImpl(function, arity, context,
implicit_cast<SloppyTNode<Object>>(args)...); {implicit_cast<SloppyTNode<Object>>(args)...});
} }
template <class... TArgs> template <class... TArgs>
...@@ -1010,7 +1010,7 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1010,7 +1010,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<Int32T> arity = Int32Constant(argc); TNode<Int32T> arity = Int32Constant(argc);
return TailCallRuntimeWithCEntryImpl( return TailCallRuntimeWithCEntryImpl(
function, arity, centry, context, function, arity, centry, context,
implicit_cast<SloppyTNode<Object>>(args)...); {implicit_cast<SloppyTNode<Object>>(args)...});
} }
// //
...@@ -1021,22 +1021,22 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1021,22 +1021,22 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<T> CallStub(Callable const& callable, SloppyTNode<Object> context, TNode<T> CallStub(Callable const& callable, SloppyTNode<Object> context,
TArgs... args) { TArgs... args) {
TNode<Code> target = HeapConstant(callable.code()); TNode<Code> target = HeapConstant(callable.code());
return CallStub<T>(callable.descriptor(), target, context, return CallStub<T>(callable.descriptor(), target, context, args...);
implicit_cast<Node*>(args)...);
} }
template <class T = Object, class... TArgs> template <class T = Object, class... TArgs>
TNode<T> CallStub(const CallInterfaceDescriptor& descriptor, TNode<T> CallStub(const CallInterfaceDescriptor& descriptor,
SloppyTNode<Code> target, SloppyTNode<Object> context, SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... args) { TArgs... args) {
return UncheckedCast<T>(CallStubR(descriptor, 1, target, context, return UncheckedCast<T>(CallStubR(descriptor, 1, target, context, args...));
implicit_cast<Node*>(args)...));
} }
template <class... TArgs> template <class... TArgs>
Node* CallStubR(const CallInterfaceDescriptor& descriptor, size_t result_size, Node* CallStubR(const CallInterfaceDescriptor& descriptor, size_t result_size,
SloppyTNode<Code> target, SloppyTNode<Object> context, SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... args); TArgs... args) {
return CallStubRImpl(descriptor, result_size, target, context, {args...});
}
Node* CallStubN(const CallInterfaceDescriptor& descriptor, size_t result_size, Node* CallStubN(const CallInterfaceDescriptor& descriptor, size_t result_size,
int input_count, Node* const* inputs, int input_count, Node* const* inputs,
...@@ -1053,8 +1053,7 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1053,8 +1053,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
void TailCallStub(const CallInterfaceDescriptor& descriptor, void TailCallStub(const CallInterfaceDescriptor& descriptor,
SloppyTNode<Code> target, SloppyTNode<Object> context, SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... args) { TArgs... args) {
return TailCallStubImpl(descriptor, target, context, return TailCallStubImpl(descriptor, target, context, {args...});
implicit_cast<Node*>(args)...);
} }
template <class... TArgs> template <class... TArgs>
...@@ -1063,8 +1062,11 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1063,8 +1062,11 @@ class V8_EXPORT_PRIVATE CodeAssembler {
template <class... TArgs> template <class... TArgs>
Node* TailCallStubThenBytecodeDispatch( Node* TailCallStubThenBytecodeDispatch(
const CallInterfaceDescriptor& descriptor, Node* context, Node* target, const CallInterfaceDescriptor& descriptor, Node* target, Node* context,
TArgs... args); TArgs... args) {
return TailCallStubThenBytecodeDispatchImpl(descriptor, target, context,
{args...});
}
// Tailcalls to the given code object with JSCall linkage. The JS arguments // Tailcalls to the given code object with JSCall linkage. The JS arguments
// (including receiver) are supposed to be already on the stack. // (including receiver) are supposed to be already on the stack.
...@@ -1186,23 +1188,32 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1186,23 +1188,32 @@ class V8_EXPORT_PRIVATE CodeAssembler {
PoisoningMitigationLevel poisoning_level() const; PoisoningMitigationLevel poisoning_level() const;
private: private:
template <class... TArgs>
TNode<Object> CallRuntimeImpl(Runtime::FunctionId function, TNode<Object> CallRuntimeImpl(Runtime::FunctionId function,
TNode<Object> context, TArgs... args); TNode<Object> context,
std::initializer_list<TNode<Object>> args);
template <class... TArgs>
void TailCallRuntimeImpl(Runtime::FunctionId function, TNode<Int32T> arity, void TailCallRuntimeImpl(Runtime::FunctionId function, TNode<Int32T> arity,
TNode<Object> context, TArgs... args); TNode<Object> context,
std::initializer_list<TNode<Object>> args);
template <class... TArgs>
void TailCallRuntimeWithCEntryImpl(Runtime::FunctionId function, void TailCallRuntimeWithCEntryImpl(Runtime::FunctionId function,
TNode<Int32T> arity, TNode<Code> centry, TNode<Int32T> arity, TNode<Code> centry,
TNode<Object> context, TArgs... args); TNode<Object> context,
std::initializer_list<TNode<Object>> args);
template <class... TArgs>
void TailCallStubImpl(const CallInterfaceDescriptor& descriptor, void TailCallStubImpl(const CallInterfaceDescriptor& descriptor,
TNode<Code> target, TNode<Object> context, TNode<Code> target, TNode<Object> context,
TArgs... args); std::initializer_list<Node*> args);
Node* TailCallStubThenBytecodeDispatchImpl(
const CallInterfaceDescriptor& descriptor, Node* target, Node* context,
std::initializer_list<Node*> args);
Node* CallStubRImpl(const CallInterfaceDescriptor& descriptor,
size_t result_size, SloppyTNode<Code> target,
SloppyTNode<Object> context,
std::initializer_list<Node*> args);
// These two don't have definitions and are here only for catching use cases // These two don't have definitions and are here only for catching use cases
// where the cast is not necessary. // where the cast is not necessary.
TNode<Int32T> Signed(TNode<Int32T> x); TNode<Int32T> Signed(TNode<Int32T> x);
......
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