[maglev] Add UNSUPPORTED macro for codegen

Allows incremental test, while some codegen paths are not available.

Bug: v8:7700
Change-Id: Icc24cf8e85464587f9eee6175107093a25b76da9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3512794
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79423}
This commit is contained in:
Victor Gomes 2022-03-09 15:39:28 +01:00 committed by V8 LUCI CQ
parent 4927d9b54f
commit 60ac45f0fb
4 changed files with 34 additions and 8 deletions

View File

@ -72,6 +72,14 @@ class MaglevCodeGenState {
}
MaglevCompilationUnit* compilation_unit() const { return compilation_unit_; }
// TODO(v8:7700): Clean up after all code paths are supported.
void set_found_unsupported_code_paths(bool val) {
found_unsupported_code_paths_ = val;
}
bool found_unsupported_code_paths() const {
return found_unsupported_code_paths_;
}
private:
MaglevCompilationUnit* const compilation_unit_;
SafepointTableBuilder* const safepoint_table_builder_;
@ -79,6 +87,11 @@ class MaglevCodeGenState {
MacroAssembler masm_;
std::vector<DeferredCodeInfo*> deferred_code_;
int vreg_slots_ = 0;
// Allow marking some codegen paths as unsupported, so that we can test maglev
// incrementally.
// TODO(v8:7700): Clean up after all code paths are supported.
bool found_unsupported_code_paths_ = false;
};
// Some helpers for codegen.

View File

@ -323,6 +323,7 @@ class MaglevCodeGeneratorImpl final {
MaybeHandle<Code> Generate() {
EmitCode();
if (code_gen_state_.found_unsupported_code_paths()) return {};
EmitMetadata();
return BuildCodeObject();
}

View File

@ -18,13 +18,16 @@ 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 \
#define MAGLEV_UNIMPLEMENTED(BytecodeName) \
do { \
std::cerr << "Maglev: Can't compile, bytecode " #BytecodeName \
" is not supported\n"; \
found_unsupported_bytecode_ = true; \
this_field_will_be_unused_once_all_bytecodes_are_supported_ = true; \
}
} while (false)
#define MAGLEV_UNIMPLEMENTED_BYTECODE(Name) \
void MaglevGraphBuilder::Visit##Name() { MAGLEV_UNIMPLEMENTED(Name); }
void MaglevGraphBuilder::VisitLdar() { SetAccumulator(LoadRegister(0)); }
@ -164,7 +167,7 @@ void MaglevGraphBuilder::VisitSetNamedProperty() {
}
// TODO(victorgomes): Generic store.
UNREACHABLE();
MAGLEV_UNIMPLEMENTED(VisitSetNamedProperty);
}
MAGLEV_UNIMPLEMENTED_BYTECODE(DefineNamedOwnProperty)

View File

@ -30,6 +30,15 @@ const char* ToString(Opcode opcode) {
#define __ code_gen_state->masm()->
// TODO(v8:7700): Clean up after all code paths are supported.
static bool g_this_field_will_be_unused_once_all_code_paths_are_supported;
#define UNSUPPORTED() \
do { \
std::cerr << "Maglev: Can't compile, unsuppored codegen path.\n"; \
code_gen_state->set_found_unsupported_code_paths(true); \
g_this_field_will_be_unused_once_all_code_paths_are_supported = true; \
} while (false)
namespace {
// ---
@ -576,11 +585,11 @@ void LoadField::GenerateCode(MaglevCodeGenState* code_gen_state,
__ DecompressAnyTagged(ToRegister(result()), input_field_operand);
if (LoadHandler::IsDoubleBits::decode(handler)) {
// TODO(leszeks): Copy out the value, either as a double or a HeapNumber.
UNREACHABLE();
UNSUPPORTED();
}
} else {
// TODO(leszeks): Handle out-of-object properties.
UNREACHABLE();
UNSUPPORTED();
}
}
void LoadField::PrintParams(std::ostream& os,
@ -605,7 +614,7 @@ void StoreField::GenerateCode(MaglevCodeGenState* code_gen_state,
__ StoreTaggedField(operand, value);
} else {
// TODO(victorgomes): Out-of-object properties.
UNREACHABLE();
UNSUPPORTED();
}
}