Commit bcf81513 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa] Typify [Tail]CallRuntime and [Tail]CallStub.

This CL also introduces TailCallRuntime() with explicit arity
parameter.

Bug: v8:6949
Change-Id: I20266a0d3779e0336d5e9f83d3919ffc91fe0f47
Reviewed-on: https://chromium-review.googlesource.com/1097081
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53679}
parent 10f590c8
...@@ -15,7 +15,7 @@ typedef compiler::Node Node; ...@@ -15,7 +15,7 @@ typedef compiler::Node Node;
TF_BUILTIN(WasmStackGuard, CodeStubAssembler) { TF_BUILTIN(WasmStackGuard, CodeStubAssembler) {
TNode<Object> instance = UncheckedCast<Object>( TNode<Object> instance = UncheckedCast<Object>(
LoadFromParentFrame(WasmCompiledFrameConstants::kWasmInstanceOffset)); LoadFromParentFrame(WasmCompiledFrameConstants::kWasmInstanceOffset));
TNode<Object> centry = UncheckedCast<Object>(Load( TNode<Code> centry = UncheckedCast<Code>(Load(
MachineType::AnyTagged(), instance, MachineType::AnyTagged(), instance,
IntPtrConstant(WasmInstanceObject::kCEntryStubOffset - kHeapObjectTag))); IntPtrConstant(WasmInstanceObject::kCEntryStubOffset - kHeapObjectTag)));
TailCallRuntimeWithCEntry(Runtime::kWasmStackGuard, centry, TailCallRuntimeWithCEntry(Runtime::kWasmStackGuard, centry,
...@@ -26,7 +26,7 @@ TF_BUILTIN(WasmStackGuard, CodeStubAssembler) { ...@@ -26,7 +26,7 @@ TF_BUILTIN(WasmStackGuard, CodeStubAssembler) {
TF_BUILTIN(ThrowWasm##name, CodeStubAssembler) { \ TF_BUILTIN(ThrowWasm##name, CodeStubAssembler) { \
TNode<Object> instance = UncheckedCast<Object>( \ TNode<Object> instance = UncheckedCast<Object>( \
LoadFromParentFrame(WasmCompiledFrameConstants::kWasmInstanceOffset)); \ LoadFromParentFrame(WasmCompiledFrameConstants::kWasmInstanceOffset)); \
TNode<Object> centry = UncheckedCast<Object>( \ TNode<Code> centry = UncheckedCast<Code>( \
Load(MachineType::AnyTagged(), instance, \ Load(MachineType::AnyTagged(), instance, \
IntPtrConstant(WasmInstanceObject::kCEntryStubOffset - \ IntPtrConstant(WasmInstanceObject::kCEntryStubOffset - \
kHeapObjectTag))); \ kHeapObjectTag))); \
......
...@@ -2158,9 +2158,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -2158,9 +2158,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Object> GetProperty(SloppyTNode<Context> context, TNode<Object> GetProperty(SloppyTNode<Context> context,
SloppyTNode<Object> receiver, SloppyTNode<Object> receiver,
SloppyTNode<Object> name) { SloppyTNode<Object> name) {
return UncheckedCast<Object>( return CallStub(Builtins::CallableFor(isolate(), Builtins::kGetProperty),
CallStub(Builtins::CallableFor(isolate(), Builtins::kGetProperty), context, receiver, name);
context, receiver, name));
} }
Node* GetMethod(Node* context, Node* object, Handle<Name> name, Node* GetMethod(Node* context, Node* object, Handle<Name> name,
...@@ -2171,17 +2170,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -2171,17 +2170,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TArgs... args) { TArgs... args) {
DCHECK_IMPLIES(Builtins::KindOf(id) == Builtins::TFJ, DCHECK_IMPLIES(Builtins::KindOf(id) == Builtins::TFJ,
!Builtins::IsLazy(id)); !Builtins::IsLazy(id));
return UncheckedCast<Object>( return CallStub<Object>(Builtins::CallableFor(isolate(), id), context,
CallStub(Builtins::CallableFor(isolate(), id), context, args...)); args...);
} }
template <class... TArgs> template <class... TArgs>
TNode<Object> TailCallBuiltin(Builtins::Name id, SloppyTNode<Object> context, void TailCallBuiltin(Builtins::Name id, SloppyTNode<Object> context,
TArgs... args) { TArgs... args) {
DCHECK_IMPLIES(Builtins::KindOf(id) == Builtins::TFJ, DCHECK_IMPLIES(Builtins::KindOf(id) == Builtins::TFJ,
!Builtins::IsLazy(id)); !Builtins::IsLazy(id));
return UncheckedCast<Object>( return TailCallStub(Builtins::CallableFor(isolate(), id), context, args...);
TailCallStub(Builtins::CallableFor(isolate(), id), context, args...));
} }
void LoadPropertyFromFastObject(Node* object, Node* map, void LoadPropertyFromFastObject(Node* object, Node* map,
......
This diff is collapsed.
...@@ -975,9 +975,6 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -975,9 +975,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
// Calls // Calls
template <class... TArgs> template <class... TArgs>
TNode<Object> CallRuntimeImpl(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args);
template <class... TArgs>
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,
...@@ -985,70 +982,75 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -985,70 +982,75 @@ class V8_EXPORT_PRIVATE CodeAssembler {
} }
template <class... TArgs> template <class... TArgs>
TNode<Object> TailCallRuntimeImpl(Runtime::FunctionId function, void TailCallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args); SloppyTNode<Object> context, TArgs... args) {
template <class... TArgs> int argc = static_cast<int>(sizeof...(args));
TNode<Object> TailCallRuntime(Runtime::FunctionId function, TNode<Int32T> arity = Int32Constant(argc);
SloppyTNode<Object> context, TArgs... args) { return TailCallRuntimeImpl(function, arity, context,
return TailCallRuntimeImpl(function, context,
implicit_cast<SloppyTNode<Object>>(args)...); implicit_cast<SloppyTNode<Object>>(args)...);
} }
template <class... TArgs> template <class... TArgs>
TNode<Object> TailCallRuntimeWithCEntryImpl(Runtime::FunctionId function, void TailCallRuntime(Runtime::FunctionId function, TNode<Int32T> arity,
TNode<Object> centry, SloppyTNode<Object> context, TArgs... args) {
TNode<Object> context, return TailCallRuntimeImpl(function, arity, context,
TArgs... args); implicit_cast<SloppyTNode<Object>>(args)...);
}
template <class... TArgs> template <class... TArgs>
TNode<Object> TailCallRuntimeWithCEntry(Runtime::FunctionId function, void TailCallRuntimeWithCEntry(Runtime::FunctionId function,
TNode<Object> centry, TNode<Code> centry, TNode<Object> context,
TNode<Object> context, TArgs... args) {
TArgs... args) { int argc = static_cast<int>(sizeof...(args));
return TailCallRuntimeWithCEntryImpl(function, centry, context, TNode<Int32T> arity = Int32Constant(argc);
implicit_cast<TNode<Object>>(args)...); return TailCallRuntimeWithCEntryImpl(
function, arity, centry, context,
implicit_cast<SloppyTNode<Object>>(args)...);
} }
// //
// If context passed to CallStub is nullptr, it won't be passed to the stub. // If context passed to CallStub is nullptr, it won't be passed to the stub.
// //
template <class... TArgs> template <class T = Object, class... TArgs>
Node* CallStub(Callable const& callable, Node* context, TArgs... args) { TNode<T> CallStub(Callable const& callable, SloppyTNode<Object> context,
Node* target = HeapConstant(callable.code()); TArgs... args) {
return CallStub(callable.descriptor(), target, context, TNode<Code> target = HeapConstant(callable.code());
implicit_cast<Node*>(args)...); return CallStub<T>(callable.descriptor(), target, context,
implicit_cast<Node*>(args)...);
} }
template <class... TArgs> template <class T = Object, class... TArgs>
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, TNode<T> CallStub(const CallInterfaceDescriptor& descriptor,
Node* context, TArgs... args) { SloppyTNode<Code> target, SloppyTNode<Object> context,
return CallStubR(descriptor, 1, target, context, TArgs... args) {
implicit_cast<Node*>(args)...); return UncheckedCast<T>(CallStubR(descriptor, 1, target, context,
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,
Node* target, Node* context, TArgs... args); SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... 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,
bool pass_context = true); bool pass_context = true);
template <class... TArgs> template <class... TArgs>
Node* TailCallStub(Callable const& callable, Node* context, TArgs... args) { void TailCallStub(Callable const& callable, SloppyTNode<Object> context,
Node* target = HeapConstant(callable.code()); TArgs... args) {
TNode<Code> target = HeapConstant(callable.code());
return TailCallStub(callable.descriptor(), target, context, args...); return TailCallStub(callable.descriptor(), target, context, args...);
} }
template <class... TArgs> template <class... TArgs>
Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target, void TailCallStub(const CallInterfaceDescriptor& descriptor,
Node* context, TArgs... args) { SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... args) {
return TailCallStubImpl(descriptor, target, context, return TailCallStubImpl(descriptor, target, context,
implicit_cast<Node*>(args)...); implicit_cast<Node*>(args)...);
} }
template <class... TArgs>
Node* TailCallStubImpl(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, TArgs... args);
template <class... TArgs> template <class... TArgs>
Node* TailCallBytecodeDispatch(const CallInterfaceDescriptor& descriptor, Node* TailCallBytecodeDispatch(const CallInterfaceDescriptor& descriptor,
...@@ -1179,6 +1181,23 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -1179,6 +1181,23 @@ 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> context, TArgs... args);
template <class... TArgs>
void TailCallRuntimeImpl(Runtime::FunctionId function, TNode<Int32T> arity,
TNode<Object> context, TArgs... args);
template <class... TArgs>
void TailCallRuntimeWithCEntryImpl(Runtime::FunctionId function,
TNode<Int32T> arity, TNode<Code> centry,
TNode<Object> context, TArgs... args);
template <class... TArgs>
void TailCallStubImpl(const CallInterfaceDescriptor& descriptor,
TNode<Code> target, TNode<Object> context,
TArgs... 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);
......
...@@ -886,8 +886,8 @@ void AccessorAssembler::HandleStoreICHandlerCase( ...@@ -886,8 +886,8 @@ void AccessorAssembler::HandleStoreICHandlerCase(
BIND(&call_handler); BIND(&call_handler);
{ {
StoreWithVectorDescriptor descriptor(isolate()); StoreWithVectorDescriptor descriptor(isolate());
TailCallStub(descriptor, strong_handler, p->context, p->receiver, p->name, TailCallStub(descriptor, CAST(strong_handler), CAST(p->context),
p->value, p->slot, p->vector); p->receiver, p->name, p->value, p->slot, p->vector);
} }
} }
...@@ -3077,8 +3077,8 @@ void AccessorAssembler::StoreInArrayLiteralIC(const StoreICParameters* p) { ...@@ -3077,8 +3077,8 @@ void AccessorAssembler::StoreInArrayLiteralIC(const StoreICParameters* p) {
Label if_transitioning_element_store(this); Label if_transitioning_element_store(this);
GotoIfNot(IsCode(handler), &if_transitioning_element_store); GotoIfNot(IsCode(handler), &if_transitioning_element_store);
StoreWithVectorDescriptor descriptor(isolate()); StoreWithVectorDescriptor descriptor(isolate());
TailCallStub(descriptor, handler, p->context, p->receiver, p->name, TailCallStub(descriptor, CAST(handler), CAST(p->context), p->receiver,
p->value, p->slot, p->vector); p->name, p->value, p->slot, p->vector);
BIND(&if_transitioning_element_store); BIND(&if_transitioning_element_store);
{ {
......
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