Commit 4d96f732 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[maglev] Support CallRuntime

Bug: v8:7700
Change-Id: Ifab7c3ba40e8dcb5e1811a239b4970c6763c9df2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3793385Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82059}
parent dff6d864
...@@ -1597,7 +1597,22 @@ void MaglevGraphBuilder::VisitCallUndefinedReceiver2() { ...@@ -1597,7 +1597,22 @@ void MaglevGraphBuilder::VisitCallUndefinedReceiver2() {
} }
MAGLEV_UNIMPLEMENTED_BYTECODE(CallWithSpread) MAGLEV_UNIMPLEMENTED_BYTECODE(CallWithSpread)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallRuntime)
void MaglevGraphBuilder::VisitCallRuntime() {
Runtime::FunctionId function_id = iterator_.GetRuntimeIdOperand(0);
interpreter::RegisterList args = iterator_.GetRegisterListOperand(1);
ValueNode* context = GetContext();
size_t input_count = args.register_count() + CallRuntime::kFixedInputCount;
CallRuntime* call_runtime =
CreateNewNode<CallRuntime>(input_count, function_id, context);
for (int i = 0; i < args.register_count(); ++i) {
call_runtime->set_arg(i, GetTaggedValue(args[i]));
}
SetAccumulator(AddNode(call_runtime));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(CallRuntimeForPair) MAGLEV_UNIMPLEMENTED_BYTECODE(CallRuntimeForPair)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallJSRuntime) MAGLEV_UNIMPLEMENTED_BYTECODE(CallJSRuntime)
MAGLEV_UNIMPLEMENTED_BYTECODE(InvokeIntrinsic) MAGLEV_UNIMPLEMENTED_BYTECODE(InvokeIntrinsic)
......
...@@ -221,6 +221,7 @@ class MaglevGraphVerifier { ...@@ -221,6 +221,7 @@ class MaglevGraphVerifier {
CheckValueInputIs(node, 1, ValueRepresentation::kFloat64); CheckValueInputIs(node, 1, ValueRepresentation::kFloat64);
break; break;
case Opcode::kCall: case Opcode::kCall:
case Opcode::kCallRuntime:
case Opcode::kConstruct: case Opcode::kConstruct:
case Opcode::kPhi: case Opcode::kPhi:
// All inputs should be tagged. // All inputs should be tagged.
......
...@@ -2395,6 +2395,26 @@ void Construct::GenerateCode(MaglevCodeGenState* code_gen_state, ...@@ -2395,6 +2395,26 @@ void Construct::GenerateCode(MaglevCodeGenState* code_gen_state,
code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info()); code_gen_state->DefineLazyDeoptPoint(lazy_deopt_info());
} }
void CallRuntime::AllocateVreg(MaglevVregAllocationState* vreg_state) {
UseFixed(context(), kContextRegister);
for (int i = 0; i < num_args(); i++) {
UseAny(arg(i));
}
DefineAsFixed(vreg_state, this, kReturnRegister0);
}
void CallRuntime::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
DCHECK_EQ(ToRegister(context()), kContextRegister);
for (int i = 0; i < num_args(); i++) {
PushInput(code_gen_state, arg(i));
}
__ CallRuntime(function_id(), num_args());
}
void CallRuntime::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
os << "(" << Runtime::FunctionForId(function_id())->name << ")";
}
void IncreaseInterruptBudget::AllocateVreg( void IncreaseInterruptBudget::AllocateVreg(
MaglevVregAllocationState* vreg_state) { MaglevVregAllocationState* vreg_state) {
set_temporaries_needed(1); set_temporaries_needed(1);
......
...@@ -118,6 +118,7 @@ class CompactInterpreterFrameState; ...@@ -118,6 +118,7 @@ class CompactInterpreterFrameState;
#define VALUE_NODE_LIST(V) \ #define VALUE_NODE_LIST(V) \
V(Call) \ V(Call) \
V(CallRuntime) \
V(Construct) \ V(Construct) \
V(CreateEmptyArrayLiteral) \ V(CreateEmptyArrayLiteral) \
V(CreateArrayLiteral) \ V(CreateArrayLiteral) \
...@@ -2731,6 +2732,42 @@ class Construct : public ValueNodeT<Construct> { ...@@ -2731,6 +2732,42 @@ class Construct : public ValueNodeT<Construct> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {} void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
}; };
class CallRuntime : public ValueNodeT<CallRuntime> {
using Base = ValueNodeT<CallRuntime>;
public:
// We assume the context as fixed input.
static constexpr int kContextIndex = 0;
static constexpr int kFixedInputCount = 1;
// This ctor is used when for variable input counts.
// Inputs must be initialized manually.
CallRuntime(uint64_t bitfield, Runtime::FunctionId function_id,
ValueNode* context)
: Base(bitfield), function_id_(function_id) {
set_input(kContextIndex, context);
}
static constexpr OpProperties kProperties = OpProperties::JSCall();
Runtime::FunctionId function_id() const { return function_id_; }
Input& context() { return input(kContextIndex); }
const Input& context() const { return input(kContextIndex); }
int num_args() const { return input_count() - kFixedInputCount; }
Input& arg(int i) { return input(i + kFixedInputCount); }
void set_arg(int i, ValueNode* node) {
set_input(i + kFixedInputCount, node);
}
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const;
private:
Runtime::FunctionId function_id_;
};
class IncreaseInterruptBudget class IncreaseInterruptBudget
: public FixedInputNodeT<0, IncreaseInterruptBudget> { : public FixedInputNodeT<0, IncreaseInterruptBudget> {
using Base = FixedInputNodeT<0, IncreaseInterruptBudget>; using Base = FixedInputNodeT<0, IncreaseInterruptBudget>;
......
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