Commit 28ee240b authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[maglev] Support SetPendingMessage

Bug: v8:7700
Change-Id: Ib3f799f37110ea6ba56417d868a25794abbfa08b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3813071
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82245}
parent eb568ceb
......@@ -2497,7 +2497,10 @@ void MaglevGraphBuilder::VisitForInStep() {
SetAccumulator(AddNewInt32BinaryOperationNode<Operation::kAdd>({index, one}));
}
MAGLEV_UNIMPLEMENTED_BYTECODE(SetPendingMessage)
void MaglevGraphBuilder::VisitSetPendingMessage() {
ValueNode* message = GetAccumulatorTagged();
SetAccumulator(AddNewNode<SetPendingMessage>({message}));
}
void MaglevGraphBuilder::VisitThrow() {
ValueNode* exception = GetAccumulatorTagged();
......
......@@ -130,6 +130,7 @@ class MaglevGraphVerifier {
case Opcode::kCreateClosure:
case Opcode::kFastCreateClosure:
case Opcode::kLogicalNot:
case Opcode::kSetPendingMessage:
case Opcode::kToBooleanLogicalNot:
case Opcode::kTestUndetectable:
case Opcode::kTestTypeOf:
......
......@@ -2281,6 +2281,21 @@ void LogicalNot::GenerateCode(MaglevCodeGenState* code_gen_state,
}
}
void SetPendingMessage::AllocateVreg(MaglevVregAllocationState*) {
UseRegister(value());
}
void SetPendingMessage::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {
Register message = ToRegister(value());
Register return_value = ToRegister(result());
Isolate* isolate = code_gen_state->isolate();
MemOperand message_op = __ ExternalReferenceAsOperand(
ExternalReference::address_of_pending_message(isolate), kScratchRegister);
__ Move(return_value, message_op);
__ movq(message_op, message);
}
void ToBooleanLogicalNot::AllocateVreg(MaglevVregAllocationState* vreg_state) {
UseRegister(value());
DefineAsRegister(vreg_state, this);
......
......@@ -159,6 +159,7 @@ class CompactInterpreterFrameState;
V(Float64Box) \
V(CheckedFloat64Unbox) \
V(LogicalNot) \
V(SetPendingMessage) \
V(ToBooleanLogicalNot) \
V(TaggedEqual) \
V(TaggedNotEqual) \
......@@ -1618,6 +1619,19 @@ class LogicalNot : public FixedInputValueNodeT<1, LogicalNot> {
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
};
class SetPendingMessage : public FixedInputValueNodeT<1, SetPendingMessage> {
using Base = FixedInputValueNodeT<1, SetPendingMessage>;
public:
explicit SetPendingMessage(uint64_t bitfield) : Base(bitfield) {}
Input& value() { return Node::input(0); }
void AllocateVreg(MaglevVregAllocationState*);
void GenerateCode(MaglevCodeGenState*, const ProcessingState&);
void PrintParams(std::ostream&, MaglevGraphLabeller*) const {}
};
class ToBooleanLogicalNot
: public FixedInputValueNodeT<1, ToBooleanLogicalNot> {
using Base = FixedInputValueNodeT<1, ToBooleanLogicalNot>;
......
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --maglev --no-stress-opt --no-always-turbofan
function foo() {
try {
} finally {
return 1;
}
}
%PrepareFunctionForOptimization(foo);
assertEquals(foo(), 1);
assertEquals(foo(), 1);
%OptimizeMaglevOnNextCall(foo);
assertEquals(foo(), 1)
// Maglev will not compile this function now because it has handler table.
// After exceptions are supported in Maglev, we could enable the assert below.
// assertTrue(isMaglevved(foo));
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