Commit f6ffe8e3 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA] Finish TNodifying interpreter assembler

TNodified:
 * AbortIfRegisterCountInvalid
 * MaybeDropFrames
 * TraceBytecodeDispatch
 * UpdateInterruptBudget
 * OperandOffset

There are currently no more Node* in interpreter-assembler!

Bug: v8:6949
Change-Id: I352a1fd18444c6ffb0f85d95f5da2e3e4a1681e1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1787432
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63618}
parent b6b7de0d
......@@ -369,7 +369,7 @@ TNode<IntPtrT> InterpreterAssembler::NextRegister(TNode<IntPtrT> reg_index) {
return Signed(IntPtrAdd(reg_index, IntPtrConstant(-1)));
}
Node* InterpreterAssembler::OperandOffset(int operand_index) {
TNode<IntPtrT> InterpreterAssembler::OperandOffset(int operand_index) {
return IntPtrConstant(
Bytecodes::GetOperandOffset(bytecode_, operand_index, operand_scale()));
}
......@@ -379,7 +379,7 @@ TNode<Uint8T> InterpreterAssembler::BytecodeOperandUnsignedByte(
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(bytecode_));
DCHECK_EQ(OperandSize::kByte, Bytecodes::GetOperandSize(
bytecode_, operand_index, operand_scale()));
Node* operand_offset = OperandOffset(operand_index);
TNode<IntPtrT> operand_offset = OperandOffset(operand_index);
return Load<Uint8T>(BytecodeArrayTaggedPointer(),
IntPtrAdd(BytecodeOffset(), operand_offset),
needs_poisoning);
......@@ -390,7 +390,7 @@ TNode<Int8T> InterpreterAssembler::BytecodeOperandSignedByte(
DCHECK_LT(operand_index, Bytecodes::NumberOfOperands(bytecode_));
DCHECK_EQ(OperandSize::kByte, Bytecodes::GetOperandSize(
bytecode_, operand_index, operand_scale()));
Node* operand_offset = OperandOffset(operand_index);
TNode<IntPtrT> operand_offset = OperandOffset(operand_index);
return Load<Int8T>(BytecodeArrayTaggedPointer(),
IntPtrAdd(BytecodeOffset(), operand_offset),
needs_poisoning);
......@@ -767,9 +767,9 @@ void InterpreterAssembler::CallJSAndDispatch(TNode<Object> function,
if (receiver_mode == ConvertReceiverMode::kNullOrUndefined) {
// The first argument parameter (the receiver) is implied to be undefined.
TailCallStubThenBytecodeDispatch(
callable.descriptor(), code_target, context, function, arg_count,
static_cast<Node*>(UndefinedConstant()), args...);
TailCallStubThenBytecodeDispatch(callable.descriptor(), code_target,
context, function, arg_count,
UndefinedConstant(), args...);
} else {
TailCallStubThenBytecodeDispatch(callable.descriptor(), code_target,
context, function, arg_count, args...);
......@@ -785,13 +785,14 @@ template V8_EXPORT_PRIVATE void InterpreterAssembler::CallJSAndDispatch(
ConvertReceiverMode receiver_mode);
template V8_EXPORT_PRIVATE void InterpreterAssembler::CallJSAndDispatch(
TNode<Object> function, TNode<Context> context, TNode<Word32T> arg_count,
ConvertReceiverMode receiver_mode, Node*);
ConvertReceiverMode receiver_mode, TNode<Object>);
template V8_EXPORT_PRIVATE void InterpreterAssembler::CallJSAndDispatch(
TNode<Object> function, TNode<Context> context, TNode<Word32T> arg_count,
ConvertReceiverMode receiver_mode, Node*, Node*);
ConvertReceiverMode receiver_mode, TNode<Object>, TNode<Object>);
template V8_EXPORT_PRIVATE void InterpreterAssembler::CallJSAndDispatch(
TNode<Object> function, TNode<Context> context, TNode<Word32T> arg_count,
ConvertReceiverMode receiver_mode, Node*, Node*, Node*);
ConvertReceiverMode receiver_mode, TNode<Object>, TNode<Object>,
TNode<Object>);
void InterpreterAssembler::CallJSWithSpreadAndDispatch(
TNode<Object> function, TNode<Context> context, const RegListNodePair& args,
......@@ -1130,9 +1131,8 @@ Node* InterpreterAssembler::CallRuntimeN(TNode<Uint32T> function_id,
TNode<Code> code_target = HeapConstant(callable.code());
// Get the function entry from the function id.
// TODO(solanes): ExternalReference
Node* function_table = ExternalConstant(
ExternalReference::runtime_function_table_address(isolate()));
TNode<RawPtrT> function_table = ReinterpretCast<RawPtrT>(ExternalConstant(
ExternalReference::runtime_function_table_address(isolate())));
TNode<Word32T> function_offset =
Int32Mul(function_id, Int32Constant(sizeof(Runtime::Function)));
TNode<WordT> function =
......@@ -1145,7 +1145,8 @@ Node* InterpreterAssembler::CallRuntimeN(TNode<Uint32T> function_id,
args.base_reg_location(), function_entry);
}
void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
void InterpreterAssembler::UpdateInterruptBudget(TNode<Int32T> weight,
bool backward) {
Comment("[ UpdateInterruptBudget");
// Assert that the weight is positive (negative weights should be implemented
......@@ -1167,7 +1168,7 @@ void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
TVARIABLE(Int32T, new_budget);
if (backward) {
// Update budget by |weight| and check if it reaches zero.
new_budget = Signed(Int32Sub(budget_after_bytecode, weight));
new_budget = Int32Sub(budget_after_bytecode, weight);
TNode<BoolT> condition =
Int32GreaterThanOrEqual(new_budget.value(), Int32Constant(0));
Label ok(this), interrupt_check(this, Label::kDeferred);
......@@ -1181,7 +1182,7 @@ void InterpreterAssembler::UpdateInterruptBudget(Node* weight, bool backward) {
} else {
// For a forward jump, we know we only increase the interrupt budget, so
// no need to check if it's below zero.
new_budget = Signed(Int32Add(budget_after_bytecode, weight));
new_budget = Int32Add(budget_after_bytecode, weight);
}
// Update budget.
......@@ -1353,7 +1354,7 @@ void InterpreterAssembler::DispatchWide(OperandScale operand_scale) {
TraceBytecodeDispatch(next_bytecode);
}
Node* base_index;
TNode<IntPtrT> base_index;
switch (operand_scale) {
case OperandScale::kDouble:
base_index = IntPtrConstant(1 << kBitsPerByte);
......@@ -1420,7 +1421,7 @@ void InterpreterAssembler::AbortIfWordNotEqual(TNode<WordT> lhs,
BIND(&ok);
}
void InterpreterAssembler::MaybeDropFrames(Node* context) {
void InterpreterAssembler::MaybeDropFrames(TNode<Context> context) {
TNode<ExternalReference> restart_fp_address =
ExternalConstant(ExternalReference::debug_restart_fp_address(isolate()));
......@@ -1445,7 +1446,7 @@ void InterpreterAssembler::TraceBytecode(Runtime::FunctionId function_id) {
SmiTag(BytecodeOffset()), GetAccumulatorUnchecked());
}
void InterpreterAssembler::TraceBytecodeDispatch(Node* target_bytecode) {
void InterpreterAssembler::TraceBytecodeDispatch(TNode<WordT> target_bytecode) {
TNode<ExternalReference> counters_table = ExternalConstant(
ExternalReference::interpreter_dispatch_counters(isolate()));
TNode<IntPtrT> source_bytecode_table_index = IntPtrConstant(
......@@ -1485,8 +1486,8 @@ bool InterpreterAssembler::TargetSupportsUnalignedAccess() {
}
void InterpreterAssembler::AbortIfRegisterCountInvalid(
Node* parameters_and_registers, Node* formal_parameter_count,
Node* register_count) {
TNode<FixedArrayBase> parameters_and_registers,
TNode<IntPtrT> formal_parameter_count, TNode<UintPtrT> register_count) {
TNode<IntPtrT> array_size =
LoadAndUntagFixedArrayBaseLength(parameters_and_registers);
......@@ -1508,7 +1509,7 @@ TNode<FixedArray> InterpreterAssembler::ExportParametersAndRegisterFile(
// Store the formal parameters (without receiver) followed by the
// registers into the generator's internal parameters_and_registers field.
TNode<IntPtrT> formal_parameter_count_intptr =
ChangeInt32ToIntPtr(formal_parameter_count);
Signed(ChangeUint32ToWord(formal_parameter_count));
TNode<UintPtrT> register_count = ChangeUint32ToWord(registers.reg_count());
if (FLAG_debug_code) {
CSA_ASSERT(this, IntPtrEqual(registers.base_reg_location(),
......@@ -1581,7 +1582,7 @@ TNode<FixedArray> InterpreterAssembler::ImportRegisterFile(
TNode<FixedArray> array, const RegListNodePair& registers,
TNode<Int32T> formal_parameter_count) {
TNode<IntPtrT> formal_parameter_count_intptr =
ChangeInt32ToIntPtr(formal_parameter_count);
Signed(ChangeUint32ToWord(formal_parameter_count));
TNode<UintPtrT> register_count = ChangeUint32ToWord(registers.reg_count());
if (FLAG_debug_code) {
CSA_ASSERT(this, IntPtrEqual(registers.base_reg_location(),
......
......@@ -245,12 +245,13 @@ class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler {
compiler::TNode<WordT> rhs,
AbortReason abort_reason);
// Abort if |register_count| is invalid for given register file array.
void AbortIfRegisterCountInvalid(compiler::Node* parameters_and_registers,
compiler::Node* formal_parameter_count,
compiler::Node* register_count);
void AbortIfRegisterCountInvalid(
compiler::TNode<FixedArrayBase> parameters_and_registers,
compiler::TNode<IntPtrT> formal_parameter_count,
compiler::TNode<UintPtrT> register_count);
// Dispatch to frame dropper trampoline if necessary.
void MaybeDropFrames(compiler::Node* context);
void MaybeDropFrames(compiler::TNode<Context> context);
// Returns the offset from the BytecodeArrayPointer of the current bytecode.
TNode<IntPtrT> BytecodeOffset();
......@@ -291,7 +292,7 @@ class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler {
void CallEpilogue();
// Increment the dispatch counter for the (current, next) bytecode pair.
void TraceBytecodeDispatch(compiler::Node* target_index);
void TraceBytecodeDispatch(TNode<WordT> target_bytecode);
// Traces the current bytecode by calling |function_id|.
void TraceBytecode(Runtime::FunctionId function_id);
......@@ -299,13 +300,13 @@ class V8_EXPORT_PRIVATE InterpreterAssembler : public CodeStubAssembler {
// Updates the bytecode array's interrupt budget by a 32-bit unsigned |weight|
// and calls Runtime::kInterrupt if counter reaches zero. If |backward|, then
// the interrupt budget is decremented, otherwise it is incremented.
void UpdateInterruptBudget(compiler::Node* weight, bool backward);
void UpdateInterruptBudget(compiler::TNode<Int32T> weight, bool backward);
// Returns the offset of register |index| relative to RegisterFilePointer().
compiler::TNode<IntPtrT> RegisterFrameOffset(compiler::TNode<IntPtrT> index);
// Returns the offset of an operand relative to the current bytecode offset.
compiler::Node* OperandOffset(int operand_index);
compiler::TNode<IntPtrT> OperandOffset(int operand_index);
// Returns a value built from an sequence of bytes in the bytecode
// array starting at |relative_offset| from the current bytecode.
......
......@@ -1600,26 +1600,20 @@ class InterpreterJSCallAssembler : public InterpreterAssembler {
case 1:
CallJSAndDispatch(
function, context, Int32Constant(arg_count), receiver_mode,
static_cast<Node*>(
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex)));
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex));
break;
case 2:
CallJSAndDispatch(
function, context, Int32Constant(arg_count), receiver_mode,
static_cast<Node*>(
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex)),
static_cast<Node*>(
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 1)));
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex),
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 1));
break;
case 3:
CallJSAndDispatch(
function, context, Int32Constant(arg_count), receiver_mode,
static_cast<Node*>(
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex)),
static_cast<Node*>(
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 1)),
static_cast<Node*>(
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 2)));
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex),
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 1),
LoadRegisterAtOperandIndex(kFirstArgumentOperandIndex + 2));
break;
default:
UNREACHABLE();
......
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