Commit 6b9bab5d authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[csa][cleanup] TNode use of Projections in interpreter-generator.

Moves CallStubR to be private and drop the return_count argument from
CallStub and its callchain, and instead use the GetReturnCount on the
call descriptor.

Also removes unused Retain function from code-assembler.

BUG=v8:6949,v8:11074

Change-Id: Ic0ebc72f84c2eab156c545af56237d4c46548c05
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2523324
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71038}
parent 19ae98a9
......@@ -838,10 +838,6 @@ Node* CodeAssembler::StoreRoot(RootIndex root_index, Node* value) {
value);
}
Node* CodeAssembler::Retain(Node* value) {
return raw_assembler()->Retain(value);
}
Node* CodeAssembler::Projection(int index, Node* value) {
DCHECK_LT(index, value->op()->ValueOutputCount());
return raw_assembler()->Projection(index, value);
......@@ -897,7 +893,7 @@ class NodeArray {
};
} // namespace
TNode<Object> CodeAssembler::CallRuntimeImpl(
Node* CodeAssembler::CallRuntimeImpl(
Runtime::FunctionId function, TNode<Object> context,
std::initializer_list<TNode<Object>> args) {
int result_size = Runtime::FunctionForId(function)->result_size;
......@@ -927,7 +923,7 @@ TNode<Object> CodeAssembler::CallRuntimeImpl(
raw_assembler()->CallN(call_descriptor, inputs.size(), inputs.data());
HandleException(return_value);
CallEpilogue();
return UncheckedCast<Object>(return_value);
return return_value;
}
void CodeAssembler::TailCallRuntimeImpl(
......@@ -958,8 +954,7 @@ void CodeAssembler::TailCallRuntimeImpl(
Node* CodeAssembler::CallStubN(StubCallMode call_mode,
const CallInterfaceDescriptor& descriptor,
size_t result_size, int input_count,
Node* const* inputs) {
int input_count, Node* const* inputs) {
DCHECK(call_mode == StubCallMode::kCallCodeObject ||
call_mode == StubCallMode::kCallBuiltinPointer);
......@@ -977,7 +972,6 @@ Node* CodeAssembler::CallStubN(StubCallMode call_mode,
// Extra arguments not mentioned in the descriptor are passed on the stack.
int stack_parameter_count = argc - descriptor.GetRegisterParameterCount();
DCHECK_LE(descriptor.GetStackParameterCount(), stack_parameter_count);
DCHECK_EQ(result_size, descriptor.GetReturnCount());
auto call_descriptor = Linkage::GetStubCallDescriptor(
zone(), descriptor, stack_parameter_count, CallDescriptor::kNoFlags,
......@@ -1013,8 +1007,7 @@ void CodeAssembler::TailCallStubImpl(const CallInterfaceDescriptor& descriptor,
Node* CodeAssembler::CallStubRImpl(StubCallMode call_mode,
const CallInterfaceDescriptor& descriptor,
size_t result_size, TNode<Object> target,
TNode<Object> context,
TNode<Object> target, TNode<Object> context,
std::initializer_list<Node*> args) {
DCHECK(call_mode == StubCallMode::kCallCodeObject ||
call_mode == StubCallMode::kCallBuiltinPointer);
......@@ -1029,8 +1022,7 @@ Node* CodeAssembler::CallStubRImpl(StubCallMode call_mode,
inputs.Add(context);
}
return CallStubN(call_mode, descriptor, result_size, inputs.size(),
inputs.data());
return CallStubN(call_mode, descriptor, inputs.size(), inputs.data());
}
Node* CodeAssembler::CallJSStubImpl(const CallInterfaceDescriptor& descriptor,
......@@ -1052,7 +1044,7 @@ Node* CodeAssembler::CallJSStubImpl(const CallInterfaceDescriptor& descriptor,
if (descriptor.HasContextParameter()) {
inputs.Add(context);
}
return CallStubN(StubCallMode::kCallCodeObject, descriptor, 1, inputs.size(),
return CallStubN(StubCallMode::kCallCodeObject, descriptor, inputs.size(),
inputs.data());
}
......
......@@ -991,10 +991,6 @@ class V8_EXPORT_PRIVATE CodeAssembler {
// kSetOverflowToMin.
TNode<Int32T> TruncateFloat32ToInt32(SloppyTNode<Float32T> value);
// No-op that guarantees that the value is kept alive till this point even
// if GC happens.
Node* Retain(Node* value);
// Projections
Node* Projection(int index, Node* value);
......@@ -1007,11 +1003,11 @@ class V8_EXPORT_PRIVATE CodeAssembler {
}
// Calls
template <class... TArgs>
TNode<Object> CallRuntime(Runtime::FunctionId function, TNode<Object> context,
TArgs... args) {
return CallRuntimeImpl(function, context,
{implicit_cast<TNode<Object>>(args)...});
template <class T = Object, class... TArgs>
TNode<T> CallRuntime(Runtime::FunctionId function, TNode<Object> context,
TArgs... args) {
return UncheckedCast<T>(CallRuntimeImpl(
function, context, {implicit_cast<TNode<Object>>(args)...}));
}
template <class... TArgs>
......@@ -1045,27 +1041,19 @@ class V8_EXPORT_PRIVATE CodeAssembler {
TNode<T> CallStub(const CallInterfaceDescriptor& descriptor,
TNode<Code> target, TNode<Object> context, TArgs... args) {
return UncheckedCast<T>(CallStubR(StubCallMode::kCallCodeObject, descriptor,
1, target, context, args...));
}
template <class... TArgs>
Node* CallStubR(StubCallMode call_mode,
const CallInterfaceDescriptor& descriptor, size_t result_size,
TNode<Object> target, TNode<Object> context, TArgs... args) {
return CallStubRImpl(call_mode, descriptor, result_size, target, context,
{args...});
target, context, args...));
}
Node* CallStubN(StubCallMode call_mode,
const CallInterfaceDescriptor& descriptor, size_t result_size,
int input_count, Node* const* inputs);
const CallInterfaceDescriptor& descriptor, int input_count,
Node* const* inputs);
template <class T = Object, class... TArgs>
TNode<T> CallBuiltinPointer(const CallInterfaceDescriptor& descriptor,
TNode<BuiltinPtr> target, TNode<Object> context,
TArgs... args) {
return UncheckedCast<T>(CallStubR(StubCallMode::kCallBuiltinPointer,
descriptor, 1, target, context, args...));
descriptor, target, context, args...));
}
template <class... TArgs>
......@@ -1212,9 +1200,8 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* function, MachineType return_type, SaveFPRegsMode mode,
std::initializer_list<CFunctionArg> args);
TNode<Object> CallRuntimeImpl(Runtime::FunctionId function,
TNode<Object> context,
std::initializer_list<TNode<Object>> args);
Node* CallRuntimeImpl(Runtime::FunctionId function, TNode<Object> context,
std::initializer_list<TNode<Object>> args);
void TailCallRuntimeImpl(Runtime::FunctionId function, TNode<Int32T> arity,
TNode<Object> context,
......@@ -1228,10 +1215,17 @@ class V8_EXPORT_PRIVATE CodeAssembler {
const CallInterfaceDescriptor& descriptor, Node* target, Node* context,
std::initializer_list<Node*> args);
template <class... TArgs>
Node* CallStubR(StubCallMode call_mode,
const CallInterfaceDescriptor& descriptor,
TNode<Object> target, TNode<Object> context, TArgs... args) {
return CallStubRImpl(call_mode, descriptor, target, context, {args...});
}
Node* CallStubRImpl(StubCallMode call_mode,
const CallInterfaceDescriptor& descriptor,
size_t result_size, TNode<Object> target,
TNode<Object> context, std::initializer_list<Node*> args);
TNode<Object> target, TNode<Object> context,
std::initializer_list<Node*> args);
Node* CallJSStubImpl(const CallInterfaceDescriptor& descriptor,
TNode<Object> target, TNode<Object> context,
......
......@@ -21,7 +21,6 @@ namespace internal {
namespace interpreter {
using compiler::CodeAssemblerState;
using compiler::Node;
InterpreterAssembler::InterpreterAssembler(CodeAssemblerState* state,
Bytecode bytecode,
......@@ -842,10 +841,9 @@ TNode<Object> InterpreterAssembler::Construct(
Comment("call using Construct builtin");
Callable callable = CodeFactory::InterpreterPushArgsThenConstruct(
isolate(), InterpreterPushArgsMode::kOther);
TNode<Code> code_target = HeapConstant(callable.code());
var_result = CallStub(callable.descriptor(), code_target, context,
args.reg_count(), args.base_reg_location(), target,
new_target, UndefinedConstant());
var_result =
CallStub(callable, context, args.reg_count(), args.base_reg_location(),
target, new_target, UndefinedConstant());
Goto(&return_result);
}
......@@ -856,10 +854,9 @@ TNode<Object> InterpreterAssembler::Construct(
Comment("call using ConstructArray builtin");
Callable callable = CodeFactory::InterpreterPushArgsThenConstruct(
isolate(), InterpreterPushArgsMode::kArrayFunction);
TNode<Code> code_target = HeapConstant(callable.code());
var_result = CallStub(callable.descriptor(), code_target, context,
args.reg_count(), args.base_reg_location(), target,
new_target, var_site.value());
var_result =
CallStub(callable, context, args.reg_count(), args.base_reg_location(),
target, new_target, var_site.value());
Goto(&return_result);
}
......@@ -984,19 +981,18 @@ TNode<Object> InterpreterAssembler::ConstructWithSpread(
Comment("call using ConstructWithSpread builtin");
Callable callable = CodeFactory::InterpreterPushArgsThenConstruct(
isolate(), InterpreterPushArgsMode::kWithFinalSpread);
TNode<Code> code_target = HeapConstant(callable.code());
return CallStub(callable.descriptor(), code_target, context, args.reg_count(),
args.base_reg_location(), target, new_target,
UndefinedConstant());
return CallStub(callable, context, args.reg_count(), args.base_reg_location(),
target, new_target, UndefinedConstant());
}
Node* InterpreterAssembler::CallRuntimeN(TNode<Uint32T> function_id,
TNode<Context> context,
const RegListNodePair& args,
int result_size) {
template <class T>
TNode<T> InterpreterAssembler::CallRuntimeN(TNode<Uint32T> function_id,
TNode<Context> context,
const RegListNodePair& args,
int return_count) {
DCHECK(Bytecodes::MakesCallAlongCriticalPath(bytecode_));
DCHECK(Bytecodes::IsCallRuntime(bytecode_));
Callable callable = CodeFactory::InterpreterCEntry(isolate(), result_size);
Callable callable = CodeFactory::InterpreterCEntry(isolate(), return_count);
TNode<Code> code_target = HeapConstant(callable.code());
// Get the function entry from the function id.
......@@ -1009,11 +1005,20 @@ Node* InterpreterAssembler::CallRuntimeN(TNode<Uint32T> function_id,
TNode<RawPtrT> function_entry = Load<RawPtrT>(
function, IntPtrConstant(offsetof(Runtime::Function, entry)));
return CallStubR(StubCallMode::kCallCodeObject, callable.descriptor(),
result_size, code_target, context, args.reg_count(),
args.base_reg_location(), function_entry);
return CallStub<T>(callable.descriptor(), code_target, context,
args.reg_count(), args.base_reg_location(),
function_entry);
}
template V8_EXPORT_PRIVATE TNode<Object> InterpreterAssembler::CallRuntimeN(
TNode<Uint32T> function_id, TNode<Context> context,
const RegListNodePair& args, int return_count);
template V8_EXPORT_PRIVATE TNode<PairT<Object, Object>>
InterpreterAssembler::CallRuntimeN(TNode<Uint32T> function_id,
TNode<Context> context,
const RegListNodePair& args,
int return_count);
void InterpreterAssembler::UpdateInterruptBudget(TNode<Int32T> weight,
bool backward) {
Comment("[ UpdateInterruptBudget");
......
......@@ -191,12 +191,10 @@ class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler {
TNode<UintPtrT> slot_id,
TNode<HeapObject> maybe_feedback_vector);
// Call runtime function with |args| arguments which will return |return_size|
// number of values.
compiler::Node* CallRuntimeN(TNode<Uint32T> function_id,
TNode<Context> context,
const RegListNodePair& args,
int return_size = 1);
// Call runtime function with |args| arguments.
template <class T = Object>
TNode<T> CallRuntimeN(TNode<Uint32T> function_id, TNode<Context> context,
const RegListNodePair& args, int return_count);
// Jump forward relative to the current bytecode by the |jump_offset|.
void Jump(TNode<IntPtrT> jump_offset);
......
......@@ -36,7 +36,6 @@ namespace interpreter {
namespace {
using compiler::CodeAssemblerState;
using compiler::Node;
using Label = CodeStubAssembler::Label;
#define IGNITION_HANDLER(Name, BaseAssembler) \
......@@ -600,7 +599,6 @@ class InterpreterStoreNamedPropertyAssembler : public InterpreterAssembler {
: InterpreterAssembler(state, bytecode, operand_scale) {}
void StaNamedProperty(Callable ic, NamedPropertyType property_type) {
TNode<Code> code_target = HeapConstant(ic.code());
TNode<Object> object = LoadRegisterAtOperandIndex(0);
TNode<Name> name = CAST(LoadConstantPoolEntryAtOperandIndex(1));
TNode<Object> value = GetAccumulator();
......@@ -609,8 +607,7 @@ class InterpreterStoreNamedPropertyAssembler : public InterpreterAssembler {
TNode<Context> context = GetContext();
TVARIABLE(Object, var_result);
var_result = CallStub(ic.descriptor(), code_target, context, object, name,
value, slot, maybe_vector);
var_result = CallStub(ic, context, object, name, value, slot, maybe_vector);
// To avoid special logic in the deoptimizer to re-materialize the value in
// the accumulator, we overwrite the accumulator after the IC call. It
// doesn't really matter what we write to the accumulator here, since we
......@@ -1478,7 +1475,7 @@ IGNITION_HANDLER(CallRuntime, InterpreterAssembler) {
TNode<Uint32T> function_id = BytecodeOperandRuntimeId(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
TNode<Context> context = GetContext();
TNode<Object> result = CAST(CallRuntimeN(function_id, context, args));
TNode<Object> result = CallRuntimeN(function_id, context, args, 1);
SetAccumulator(result);
Dispatch();
}
......@@ -1509,10 +1506,11 @@ IGNITION_HANDLER(CallRuntimeForPair, InterpreterAssembler) {
TNode<Uint32T> function_id = BytecodeOperandRuntimeId(0);
RegListNodePair args = GetRegisterListAtOperandIndex(1);
TNode<Context> context = GetContext();
Node* result_pair = CallRuntimeN(function_id, context, args, 2);
auto result_pair =
CallRuntimeN<PairT<Object, Object>>(function_id, context, args, 2);
// Store the results in <first_return> and <first_return + 1>
TNode<Object> result0 = CAST(Projection(0, result_pair));
TNode<Object> result1 = CAST(Projection(1, result_pair));
TNode<Object> result0 = Projection<0>(result_pair);
TNode<Object> result1 = Projection<1>(result_pair);
StoreRegisterPairAtOperandIndex(result0, result1, 3);
Dispatch();
}
......@@ -2193,8 +2191,7 @@ IGNITION_HANDLER(JumpLoop, InterpreterAssembler) {
BIND(&osr_armed);
{
Callable callable = CodeFactory::InterpreterOnStackReplacement(isolate());
TNode<Code> target = HeapConstant(callable.code());
CallStub(callable.descriptor(), target, context);
CallStub(callable, context);
JumpBackward(relative_jump);
}
}
......@@ -2780,10 +2777,10 @@ IGNITION_HANDLER(Debugger, InterpreterAssembler) {
IGNITION_HANDLER(Name, InterpreterAssembler) { \
TNode<Context> context = GetContext(); \
TNode<Object> accumulator = GetAccumulator(); \
TNode<Object> result_pair = \
CallRuntime(Runtime::kDebugBreakOnBytecode, context, accumulator); \
TNode<Object> return_value = CAST(Projection(0, result_pair)); \
TNode<IntPtrT> original_bytecode = SmiUntag(Projection(1, result_pair)); \
TNode<PairT<Object, Smi>> result_pair = CallRuntime<PairT<Object, Smi>>( \
Runtime::kDebugBreakOnBytecode, context, accumulator); \
TNode<Object> return_value = Projection<0>(result_pair); \
TNode<IntPtrT> original_bytecode = SmiUntag(Projection<1>(result_pair)); \
MaybeDropFrames(context); \
SetAccumulator(return_value); \
DispatchToBytecode(original_bytecode, BytecodeOffset()); \
......
......@@ -182,8 +182,7 @@ TNode<Object> IntrinsicsGenerator::IntrinsicAsStubCall(
}
stub_args[index++] = context;
return __ CAST(__ CallStubN(StubCallMode::kCallCodeObject,
callable.descriptor(), 1, input_count,
stub_args));
callable.descriptor(), input_count, stub_args));
}
TNode<Object> IntrinsicsGenerator::IntrinsicAsBuiltinCall(
......
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