[maglev] Allow graph building to bail out

Start allowing heavier testing of maglev by allowing graph building to
bail out if passed an unsupported bytecode.

Bug: v8:7700
Change-Id: I7e3d2c5a8896d4f4e0da5ef444c95a286f9ac117
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3500417
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79371}
This commit is contained in:
Leszek Swirski 2022-03-04 15:33:13 +01:00 committed by V8 LUCI CQ
parent 5704f86c58
commit b9af6604c3
7 changed files with 190 additions and 155 deletions

View File

@ -309,8 +309,8 @@ class MaglevCodeGeneratingNodeProcessor {
class MaglevCodeGeneratorImpl final {
public:
static Handle<Code> Generate(MaglevCompilationUnit* compilation_unit,
Graph* graph) {
static MaybeHandle<Code> Generate(MaglevCompilationUnit* compilation_unit,
Graph* graph) {
return MaglevCodeGeneratorImpl(compilation_unit, graph).Generate();
}
@ -321,7 +321,7 @@ class MaglevCodeGeneratorImpl final {
processor_(compilation_unit, &code_gen_state_),
graph_(graph) {}
Handle<Code> Generate() {
MaybeHandle<Code> Generate() {
EmitCode();
EmitMetadata();
return BuildCodeObject();
@ -337,14 +337,14 @@ class MaglevCodeGeneratorImpl final {
stack_slot_count_with_fixed_frame());
}
Handle<Code> BuildCodeObject() {
MaybeHandle<Code> BuildCodeObject() {
CodeDesc desc;
static constexpr int kNoHandlerTableOffset = 0;
masm()->GetCode(isolate(), &desc, safepoint_table_builder(),
kNoHandlerTableOffset);
return Factory::CodeBuilder{isolate(), desc, CodeKind::MAGLEV}
.set_stack_slots(stack_slot_count_with_fixed_frame())
.Build();
.TryBuild();
}
int stack_slot_count() const { return code_gen_state_.vreg_slots(); }
@ -367,7 +367,7 @@ class MaglevCodeGeneratorImpl final {
};
// static
Handle<Code> MaglevCodeGenerator::Generate(
MaybeHandle<Code> MaglevCodeGenerator::Generate(
MaglevCompilationUnit* compilation_unit, Graph* graph) {
return MaglevCodeGeneratorImpl::Generate(compilation_unit, graph);
}

View File

@ -16,8 +16,8 @@ struct MaglevCompilationUnit;
class MaglevCodeGenerator : public AllStatic {
public:
static Handle<Code> Generate(MaglevCompilationUnit* compilation_unit,
Graph* graph);
static MaybeHandle<Code> Generate(MaglevCompilationUnit* compilation_unit,
Graph* graph);
};
} // namespace maglev

View File

@ -131,7 +131,7 @@ MaglevCompiler::MaglevCompiler(compiler::JSHeapBroker* broker,
: compilation_data_(broker),
toplevel_compilation_unit_(&compilation_data_, function) {}
Handle<Code> MaglevCompiler::Compile() {
MaybeHandle<Code> MaglevCompiler::Compile() {
// Build graph.
if (FLAG_print_maglev_code || FLAG_code_comments || FLAG_print_maglev_graph ||
FLAG_trace_maglev_regalloc) {
@ -142,6 +142,11 @@ Handle<Code> MaglevCompiler::Compile() {
graph_builder.Build();
// TODO(v8:7700): Clean up after all bytecodes are supported.
if (graph_builder.found_unsupported_bytecode()) {
return {};
}
if (FLAG_print_maglev_graph) {
std::cout << "After graph buiding" << std::endl;
PrintGraph(std::cout, &toplevel_compilation_unit_, graph_builder.graph());
@ -167,8 +172,13 @@ Handle<Code> MaglevCompiler::Compile() {
PrintGraph(std::cout, &toplevel_compilation_unit_, graph_builder.graph());
}
Handle<Code> code = MaglevCodeGenerator::Generate(&toplevel_compilation_unit_,
graph_builder.graph());
Handle<Code> code;
if (!MaglevCodeGenerator::Generate(&toplevel_compilation_unit_,
graph_builder.graph())
.ToHandle(&code)) {
return {};
}
const bool deps_committed_successfully =
broker()->dependencies()->Commit(code);

View File

@ -24,7 +24,7 @@ class MaglevCompiler {
explicit MaglevCompiler(compiler::JSHeapBroker* broker,
Handle<JSFunction> function);
Handle<Code> Compile();
MaybeHandle<Code> Compile();
compiler::JSHeapBroker* broker() const { return compilation_data_.broker; }
Zone* zone() { return &compilation_data_.zone; }

View File

@ -17,6 +17,15 @@ namespace internal {
namespace maglev {
// TODO(v8:7700): Clean up after all bytecodes are supported.
#define MAGLEV_UNIMPLEMENTED_BYTECODE(Name) \
void MaglevGraphBuilder::Visit##Name() { \
std::cerr << "Maglev: Can't compile, bytecode " #Name \
" is not supported\n"; \
found_unsupported_bytecode_ = true; \
this_field_will_be_unused_once_all_bytecodes_are_supported_ = true; \
}
void MaglevGraphBuilder::VisitLdar() { SetAccumulator(LoadRegister(0)); }
void MaglevGraphBuilder::VisitLdaZero() {
@ -41,13 +50,11 @@ void MaglevGraphBuilder::VisitLdaTrue() {
void MaglevGraphBuilder::VisitLdaFalse() {
SetAccumulator(AddNewNode<RootConstant>({}, RootIndex::kFalseValue));
}
void MaglevGraphBuilder::VisitLdaConstant() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaContextSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaImmutableContextSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaCurrentContextSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaImmutableCurrentContextSlot() {
UNREACHABLE();
}
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaConstant)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaContextSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaImmutableContextSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaCurrentContextSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaImmutableCurrentContextSlot)
void MaglevGraphBuilder::VisitStar() {
StoreRegister(
iterator_.GetRegisterOperand(0), GetAccumulator(),
@ -58,13 +65,13 @@ void MaglevGraphBuilder::VisitMov() {
iterator_.GetRegisterOperand(1), LoadRegister(0),
bytecode_analysis().GetOutLivenessFor(iterator_.current_offset()));
}
void MaglevGraphBuilder::VisitPushContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitPopContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestReferenceEqual() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestUndetectable() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestNull() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestUndefined() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestTypeOf() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(PushContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(PopContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestReferenceEqual)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestUndetectable)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestNull)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestUndefined)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestTypeOf)
void MaglevGraphBuilder::VisitLdaGlobal() {
// LdaGlobal <name_index> <slot>
@ -80,21 +87,17 @@ void MaglevGraphBuilder::VisitLdaGlobal() {
SetAccumulator(AddNewNode<LoadGlobal>({context}, name));
MarkPossibleSideEffect();
}
void MaglevGraphBuilder::VisitLdaGlobalInsideTypeof() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaGlobal() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaContextSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaCurrentContextSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaLookupSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaLookupContextSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaLookupGlobalSlot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaLookupSlotInsideTypeof() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaLookupContextSlotInsideTypeof() {
UNREACHABLE();
}
void MaglevGraphBuilder::VisitLdaLookupGlobalSlotInsideTypeof() {
UNREACHABLE();
}
void MaglevGraphBuilder::VisitStaLookupSlot() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaGlobalInsideTypeof)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaGlobal)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaContextSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaCurrentContextSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaLookupSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaLookupContextSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaLookupGlobalSlot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaLookupSlotInsideTypeof)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaLookupContextSlotInsideTypeof)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaLookupGlobalSlotInsideTypeof)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaLookupSlot)
void MaglevGraphBuilder::VisitLdaNamedProperty() {
// LdaNamedProperty <object> <name_index> <slot>
ValueNode* object = LoadRegister(0);
@ -132,41 +135,41 @@ void MaglevGraphBuilder::VisitLdaNamedProperty() {
SetAccumulator(AddNewNode<LoadNamedGeneric>({context, object}, name));
MarkPossibleSideEffect();
}
void MaglevGraphBuilder::VisitLdaNamedPropertyFromSuper() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaKeyedProperty() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLdaModuleVariable() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaModuleVariable() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaNamedProperty() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaNamedOwnProperty() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaKeyedProperty() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaKeyedPropertyAsDefine() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaInArrayLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitStaDataPropertyInLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCollectTypeProfile() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitAdd() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitSub() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitMul() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitDiv() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitMod() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitExp() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseOr() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseXor() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseAnd() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitShiftLeft() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitShiftRight() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitShiftRightLogical() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitAddSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitSubSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitMulSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitDivSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitModSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitExpSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseOrSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseXorSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseAndSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitShiftLeftSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitShiftRightSmi() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitShiftRightLogicalSmi() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaNamedPropertyFromSuper)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaKeyedProperty)
MAGLEV_UNIMPLEMENTED_BYTECODE(LdaModuleVariable)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaModuleVariable)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaNamedProperty)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaNamedOwnProperty)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaKeyedProperty)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaKeyedPropertyAsDefine)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaInArrayLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(StaDataPropertyInLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CollectTypeProfile)
MAGLEV_UNIMPLEMENTED_BYTECODE(Add)
MAGLEV_UNIMPLEMENTED_BYTECODE(Sub)
MAGLEV_UNIMPLEMENTED_BYTECODE(Mul)
MAGLEV_UNIMPLEMENTED_BYTECODE(Div)
MAGLEV_UNIMPLEMENTED_BYTECODE(Mod)
MAGLEV_UNIMPLEMENTED_BYTECODE(Exp)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseOr)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseXor)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseAnd)
MAGLEV_UNIMPLEMENTED_BYTECODE(ShiftLeft)
MAGLEV_UNIMPLEMENTED_BYTECODE(ShiftRight)
MAGLEV_UNIMPLEMENTED_BYTECODE(ShiftRightLogical)
MAGLEV_UNIMPLEMENTED_BYTECODE(AddSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(SubSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(MulSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(DivSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(ModSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(ExpSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseOrSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseXorSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseAndSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(ShiftLeftSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(ShiftRightSmi)
MAGLEV_UNIMPLEMENTED_BYTECODE(ShiftRightLogicalSmi)
void MaglevGraphBuilder::VisitInc() {
// Inc <slot>
@ -178,16 +181,16 @@ void MaglevGraphBuilder::VisitInc() {
SetAccumulator(node);
MarkPossibleSideEffect();
}
void MaglevGraphBuilder::VisitDec() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitNegate() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitBitwiseNot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitToBooleanLogicalNot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitLogicalNot() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTypeOf() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitDeletePropertyStrict() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitDeletePropertySloppy() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitGetSuperConstructor() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallAnyReceiver() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(Dec)
MAGLEV_UNIMPLEMENTED_BYTECODE(Negate)
MAGLEV_UNIMPLEMENTED_BYTECODE(BitwiseNot)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToBooleanLogicalNot)
MAGLEV_UNIMPLEMENTED_BYTECODE(LogicalNot)
MAGLEV_UNIMPLEMENTED_BYTECODE(TypeOf)
MAGLEV_UNIMPLEMENTED_BYTECODE(DeletePropertyStrict)
MAGLEV_UNIMPLEMENTED_BYTECODE(DeletePropertySloppy)
MAGLEV_UNIMPLEMENTED_BYTECODE(GetSuperConstructor)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallAnyReceiver)
// TODO(leszeks): For all of these:
// a) Read feedback and implement inlining
@ -236,19 +239,19 @@ void MaglevGraphBuilder::VisitCallProperty2() {
SetAccumulator(call_property);
MarkPossibleSideEffect();
}
void MaglevGraphBuilder::VisitCallUndefinedReceiver() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallUndefinedReceiver0() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallUndefinedReceiver1() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallUndefinedReceiver2() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallWithSpread() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallRuntime() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallRuntimeForPair() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCallJSRuntime() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitInvokeIntrinsic() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitConstruct() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitConstructWithSpread() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestEqual() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestEqualStrict() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(CallUndefinedReceiver)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallUndefinedReceiver0)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallUndefinedReceiver1)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallUndefinedReceiver2)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallWithSpread)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallRuntime)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallRuntimeForPair)
MAGLEV_UNIMPLEMENTED_BYTECODE(CallJSRuntime)
MAGLEV_UNIMPLEMENTED_BYTECODE(InvokeIntrinsic)
MAGLEV_UNIMPLEMENTED_BYTECODE(Construct)
MAGLEV_UNIMPLEMENTED_BYTECODE(ConstructWithSpread)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestEqual)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestEqualStrict)
void MaglevGraphBuilder::VisitTestLessThan() {
// TestLessThan <src> <slot>
@ -263,33 +266,33 @@ void MaglevGraphBuilder::VisitTestLessThan() {
SetAccumulator(node);
MarkPossibleSideEffect();
}
void MaglevGraphBuilder::VisitTestGreaterThan() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestLessThanOrEqual() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestGreaterThanOrEqual() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestInstanceOf() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitTestIn() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitToName() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitToNumber() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitToNumeric() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitToObject() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitToString() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateRegExpLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateArrayLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateArrayFromIterable() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateEmptyArrayLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateObjectLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateEmptyObjectLiteral() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCloneObject() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitGetTemplateObject() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateClosure() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateBlockContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateCatchContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateFunctionContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateEvalContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateWithContext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateMappedArguments() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateUnmappedArguments() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitCreateRestParameter() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(TestGreaterThan)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestLessThanOrEqual)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestGreaterThanOrEqual)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestInstanceOf)
MAGLEV_UNIMPLEMENTED_BYTECODE(TestIn)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToName)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToNumber)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToNumeric)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToObject)
MAGLEV_UNIMPLEMENTED_BYTECODE(ToString)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateRegExpLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateArrayLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateArrayFromIterable)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateEmptyArrayLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateObjectLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateEmptyObjectLiteral)
MAGLEV_UNIMPLEMENTED_BYTECODE(CloneObject)
MAGLEV_UNIMPLEMENTED_BYTECODE(GetTemplateObject)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateClosure)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateBlockContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateCatchContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateFunctionContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateEvalContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateWithContext)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateMappedArguments)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateUnmappedArguments)
MAGLEV_UNIMPLEMENTED_BYTECODE(CreateRestParameter)
void MaglevGraphBuilder::VisitJumpLoop() {
int target = iterator_.GetJumpTargetOffset();
@ -309,7 +312,7 @@ void MaglevGraphBuilder::VisitJump() {
MergeIntoFrameState(block, iterator_.GetJumpTargetOffset());
DCHECK_LT(next_offset(), bytecode().length());
}
void MaglevGraphBuilder::VisitJumpConstant() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpConstant)
void MaglevGraphBuilder::VisitJumpIfNullConstant() { VisitJumpIfNull(); }
void MaglevGraphBuilder::VisitJumpIfNotNullConstant() { VisitJumpIfNotNull(); }
void MaglevGraphBuilder::VisitJumpIfUndefinedConstant() {
@ -385,37 +388,35 @@ void MaglevGraphBuilder::VisitJumpIfFalse() {
BuildBranchIfTrue(GetAccumulator(), next_offset(),
iterator_.GetJumpTargetOffset());
}
void MaglevGraphBuilder::VisitJumpIfNull() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitJumpIfNotNull() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitJumpIfUndefined() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitJumpIfNotUndefined() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitJumpIfUndefinedOrNull() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitJumpIfJSReceiver() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitSwitchOnSmiNoFeedback() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitForInEnumerate() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitForInPrepare() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitForInContinue() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitForInNext() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitForInStep() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitSetPendingMessage() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitThrow() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitReThrow() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfNull)
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfNotNull)
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfUndefined)
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfNotUndefined)
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfUndefinedOrNull)
MAGLEV_UNIMPLEMENTED_BYTECODE(JumpIfJSReceiver)
MAGLEV_UNIMPLEMENTED_BYTECODE(SwitchOnSmiNoFeedback)
MAGLEV_UNIMPLEMENTED_BYTECODE(ForInEnumerate)
MAGLEV_UNIMPLEMENTED_BYTECODE(ForInPrepare)
MAGLEV_UNIMPLEMENTED_BYTECODE(ForInContinue)
MAGLEV_UNIMPLEMENTED_BYTECODE(ForInNext)
MAGLEV_UNIMPLEMENTED_BYTECODE(ForInStep)
MAGLEV_UNIMPLEMENTED_BYTECODE(SetPendingMessage)
MAGLEV_UNIMPLEMENTED_BYTECODE(Throw)
MAGLEV_UNIMPLEMENTED_BYTECODE(ReThrow)
void MaglevGraphBuilder::VisitReturn() {
FinishBlock<Return>(next_offset(), {GetAccumulator()});
}
void MaglevGraphBuilder::VisitThrowReferenceErrorIfHole() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitThrowSuperNotCalledIfHole() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitThrowSuperAlreadyCalledIfNotHole() {
UNREACHABLE();
}
void MaglevGraphBuilder::VisitThrowIfNotSuperConstructor() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitSwitchOnGeneratorState() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitSuspendGenerator() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitResumeGenerator() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitGetIterator() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitDebugger() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitIncBlockCounter() { UNREACHABLE(); }
void MaglevGraphBuilder::VisitAbort() { UNREACHABLE(); }
MAGLEV_UNIMPLEMENTED_BYTECODE(ThrowReferenceErrorIfHole)
MAGLEV_UNIMPLEMENTED_BYTECODE(ThrowSuperNotCalledIfHole)
MAGLEV_UNIMPLEMENTED_BYTECODE(ThrowSuperAlreadyCalledIfNotHole)
MAGLEV_UNIMPLEMENTED_BYTECODE(ThrowIfNotSuperConstructor)
MAGLEV_UNIMPLEMENTED_BYTECODE(SwitchOnGeneratorState)
MAGLEV_UNIMPLEMENTED_BYTECODE(SuspendGenerator)
MAGLEV_UNIMPLEMENTED_BYTECODE(ResumeGenerator)
MAGLEV_UNIMPLEMENTED_BYTECODE(GetIterator)
MAGLEV_UNIMPLEMENTED_BYTECODE(Debugger)
MAGLEV_UNIMPLEMENTED_BYTECODE(IncBlockCounter)
MAGLEV_UNIMPLEMENTED_BYTECODE(Abort)
#define SHORT_STAR_VISITOR(Name, ...) \
void MaglevGraphBuilder::Visit##Name() { \
StoreRegister( \

View File

@ -111,11 +111,18 @@ class MaglevGraphBuilder {
void Build() {
for (iterator_.Reset(); !iterator_.done(); iterator_.Advance()) {
VisitSingleBytecode();
// TODO(v8:7700): Clean up after all bytecodes are supported.
if (found_unsupported_bytecode()) break;
}
}
Graph* graph() { return &graph_; }
// TODO(v8:7700): Clean up after all bytecodes are supported.
bool found_unsupported_bytecode() const {
return found_unsupported_bytecode_;
}
private:
BasicBlock* CreateEmptyBlock(int offset, BasicBlock* predecessor) {
DCHECK_NULL(current_block_);
@ -425,6 +432,12 @@ class MaglevGraphBuilder {
Graph graph_;
InterpreterFrameState current_interpreter_frame_;
// Allow marking some bytecodes as unsupported during graph building, so that
// we can test maglev incrementally.
// TODO(v8:7700): Clean up after all bytecodes are supported.
bool found_unsupported_bytecode_ = false;
bool this_field_will_be_unused_once_all_bytecodes_are_supported_;
};
} // namespace maglev

View File

@ -284,6 +284,17 @@ inline Handle<CodeT> ToCodeT(Handle<Code> code, Isolate* isolate) {
#endif
}
inline MaybeHandle<CodeT> ToCodeT(MaybeHandle<Code> maybe_code,
Isolate* isolate) {
#ifdef V8_EXTERNAL_CODE_SPACE
Handle<Code> code;
if (maybe_code.ToHandle(&code)) return ToCodeT(code, isolate);
return {};
#else
return maybe_code;
#endif
}
inline Code FromCodeT(CodeT code) {
#ifdef V8_EXTERNAL_CODE_SPACE
return code.code();