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;
TF_BUILTIN(WasmStackGuard, CodeStubAssembler) {
TNode<Object> instance = UncheckedCast<Object>(
LoadFromParentFrame(WasmCompiledFrameConstants::kWasmInstanceOffset));
TNode<Object> centry = UncheckedCast<Object>(Load(
TNode<Code> centry = UncheckedCast<Code>(Load(
MachineType::AnyTagged(), instance,
IntPtrConstant(WasmInstanceObject::kCEntryStubOffset - kHeapObjectTag)));
TailCallRuntimeWithCEntry(Runtime::kWasmStackGuard, centry,
......@@ -26,7 +26,7 @@ TF_BUILTIN(WasmStackGuard, CodeStubAssembler) {
TF_BUILTIN(ThrowWasm##name, CodeStubAssembler) { \
TNode<Object> instance = UncheckedCast<Object>( \
LoadFromParentFrame(WasmCompiledFrameConstants::kWasmInstanceOffset)); \
TNode<Object> centry = UncheckedCast<Object>( \
TNode<Code> centry = UncheckedCast<Code>( \
Load(MachineType::AnyTagged(), instance, \
IntPtrConstant(WasmInstanceObject::kCEntryStubOffset - \
kHeapObjectTag))); \
......
......@@ -2158,9 +2158,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Object> GetProperty(SloppyTNode<Context> context,
SloppyTNode<Object> receiver,
SloppyTNode<Object> name) {
return UncheckedCast<Object>(
CallStub(Builtins::CallableFor(isolate(), Builtins::kGetProperty),
context, receiver, name));
return CallStub(Builtins::CallableFor(isolate(), Builtins::kGetProperty),
context, receiver, name);
}
Node* GetMethod(Node* context, Node* object, Handle<Name> name,
......@@ -2171,17 +2170,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TArgs... args) {
DCHECK_IMPLIES(Builtins::KindOf(id) == Builtins::TFJ,
!Builtins::IsLazy(id));
return UncheckedCast<Object>(
CallStub(Builtins::CallableFor(isolate(), id), context, args...));
return CallStub<Object>(Builtins::CallableFor(isolate(), id), context,
args...);
}
template <class... TArgs>
TNode<Object> TailCallBuiltin(Builtins::Name id, SloppyTNode<Object> context,
TArgs... args) {
void TailCallBuiltin(Builtins::Name id, SloppyTNode<Object> context,
TArgs... args) {
DCHECK_IMPLIES(Builtins::KindOf(id) == Builtins::TFJ,
!Builtins::IsLazy(id));
return UncheckedCast<Object>(
TailCallStub(Builtins::CallableFor(isolate(), id), context, args...));
return TailCallStub(Builtins::CallableFor(isolate(), id), context, args...);
}
void LoadPropertyFromFastObject(Node* object, Node* map,
......
This diff is collapsed.
......@@ -975,9 +975,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
// Calls
template <class... TArgs>
TNode<Object> CallRuntimeImpl(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args);
template <class... TArgs>
TNode<Object> CallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args) {
return CallRuntimeImpl(function, context,
......@@ -985,70 +982,75 @@ class V8_EXPORT_PRIVATE CodeAssembler {
}
template <class... TArgs>
TNode<Object> TailCallRuntimeImpl(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args);
template <class... TArgs>
TNode<Object> TailCallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args) {
return TailCallRuntimeImpl(function, context,
void TailCallRuntime(Runtime::FunctionId function,
SloppyTNode<Object> context, TArgs... args) {
int argc = static_cast<int>(sizeof...(args));
TNode<Int32T> arity = Int32Constant(argc);
return TailCallRuntimeImpl(function, arity, context,
implicit_cast<SloppyTNode<Object>>(args)...);
}
template <class... TArgs>
TNode<Object> TailCallRuntimeWithCEntryImpl(Runtime::FunctionId function,
TNode<Object> centry,
TNode<Object> context,
TArgs... args);
void TailCallRuntime(Runtime::FunctionId function, TNode<Int32T> arity,
SloppyTNode<Object> context, TArgs... args) {
return TailCallRuntimeImpl(function, arity, context,
implicit_cast<SloppyTNode<Object>>(args)...);
}
template <class... TArgs>
TNode<Object> TailCallRuntimeWithCEntry(Runtime::FunctionId function,
TNode<Object> centry,
TNode<Object> context,
TArgs... args) {
return TailCallRuntimeWithCEntryImpl(function, centry, context,
implicit_cast<TNode<Object>>(args)...);
void TailCallRuntimeWithCEntry(Runtime::FunctionId function,
TNode<Code> centry, TNode<Object> context,
TArgs... args) {
int argc = static_cast<int>(sizeof...(args));
TNode<Int32T> arity = Int32Constant(argc);
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.
//
template <class... TArgs>
Node* CallStub(Callable const& callable, Node* context, TArgs... args) {
Node* target = HeapConstant(callable.code());
return CallStub(callable.descriptor(), target, context,
implicit_cast<Node*>(args)...);
template <class T = Object, class... TArgs>
TNode<T> CallStub(Callable const& callable, SloppyTNode<Object> context,
TArgs... args) {
TNode<Code> target = HeapConstant(callable.code());
return CallStub<T>(callable.descriptor(), target, context,
implicit_cast<Node*>(args)...);
}
template <class... TArgs>
Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, TArgs... args) {
return CallStubR(descriptor, 1, target, context,
implicit_cast<Node*>(args)...);
template <class T = Object, class... TArgs>
TNode<T> CallStub(const CallInterfaceDescriptor& descriptor,
SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... args) {
return UncheckedCast<T>(CallStubR(descriptor, 1, target, context,
implicit_cast<Node*>(args)...));
}
template <class... TArgs>
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,
int input_count, Node* const* inputs,
bool pass_context = true);
template <class... TArgs>
Node* TailCallStub(Callable const& callable, Node* context, TArgs... args) {
Node* target = HeapConstant(callable.code());
void TailCallStub(Callable const& callable, SloppyTNode<Object> context,
TArgs... args) {
TNode<Code> target = HeapConstant(callable.code());
return TailCallStub(callable.descriptor(), target, context, args...);
}
template <class... TArgs>
Node* TailCallStub(const CallInterfaceDescriptor& descriptor, Node* target,
Node* context, TArgs... args) {
void TailCallStub(const CallInterfaceDescriptor& descriptor,
SloppyTNode<Code> target, SloppyTNode<Object> context,
TArgs... args) {
return TailCallStubImpl(descriptor, target, context,
implicit_cast<Node*>(args)...);
}
template <class... TArgs>
Node* TailCallStubImpl(const CallInterfaceDescriptor& descriptor,
Node* target, Node* context, TArgs... args);
template <class... TArgs>
Node* TailCallBytecodeDispatch(const CallInterfaceDescriptor& descriptor,
......@@ -1179,6 +1181,23 @@ class V8_EXPORT_PRIVATE CodeAssembler {
PoisoningMitigationLevel poisoning_level() const;
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
// where the cast is not necessary.
TNode<Int32T> Signed(TNode<Int32T> x);
......
......@@ -886,8 +886,8 @@ void AccessorAssembler::HandleStoreICHandlerCase(
BIND(&call_handler);
{
StoreWithVectorDescriptor descriptor(isolate());
TailCallStub(descriptor, strong_handler, p->context, p->receiver, p->name,
p->value, p->slot, p->vector);
TailCallStub(descriptor, CAST(strong_handler), CAST(p->context),
p->receiver, p->name, p->value, p->slot, p->vector);
}
}
......@@ -3077,8 +3077,8 @@ void AccessorAssembler::StoreInArrayLiteralIC(const StoreICParameters* p) {
Label if_transitioning_element_store(this);
GotoIfNot(IsCode(handler), &if_transitioning_element_store);
StoreWithVectorDescriptor descriptor(isolate());
TailCallStub(descriptor, handler, p->context, p->receiver, p->name,
p->value, p->slot, p->vector);
TailCallStub(descriptor, CAST(handler), CAST(p->context), p->receiver,
p->name, p->value, p->slot, p->vector);
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