Commit 292b3548 authored by ishell's avatar ishell Committed by Commit bot

[turbofan] Add --csa-verify flag that enables machine graph verification of code stubs.

The flag must be used only by CodeStubAssemblerGraphsCorrectness cctest for now
and once all the verification issues are fixed the flag will be enabled in debug
mode by default.

BUG=

Review-Url: https://codereview.chromium.org/2551933002
Cr-Commit-Position: refs/heads/master@{#41531}
parent f897e36c
......@@ -1762,10 +1762,15 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage,
info(), data->graph(), data->schedule()));
}
if (FLAG_turbo_verify_machine_graph != nullptr &&
(!strcmp(FLAG_turbo_verify_machine_graph, "*") ||
!strcmp(FLAG_turbo_verify_machine_graph,
data->info()->GetDebugName().get()))) {
// TODO(ishell): Always enable graph verification of stubs in debug mode
// once all the issues are fixed.
bool verify_stub_graph =
DEBUG_BOOL && FLAG_csa_verify && data->info()->IsStub();
if (verify_stub_graph || (FLAG_turbo_verify_machine_graph != nullptr &&
(!strcmp(FLAG_turbo_verify_machine_graph, "*") ||
!strcmp(FLAG_turbo_verify_machine_graph,
data->info()->GetDebugName().get())))) {
Zone temp_zone(data->isolate()->allocator(), ZONE_NAME);
MachineGraphVerifier::Run(data->graph(), data->schedule(), linkage,
&temp_zone);
......
......@@ -444,6 +444,7 @@ DEFINE_BOOL(turbo_asm_deoptimization, false,
DEFINE_BOOL(turbo_verify, DEBUG_BOOL, "verify TurboFan graphs at each phase")
DEFINE_STRING(turbo_verify_machine_graph, nullptr,
"verify TurboFan machine graph before instruction selection")
DEFINE_BOOL(csa_verify, false, "verify TurboFan machine graph of code stubs")
DEFINE_BOOL(turbo_stats, false, "print TurboFan statistics")
DEFINE_BOOL(turbo_stats_nvp, false,
"print TurboFan statistics in machine-readable format")
......
......@@ -1927,5 +1927,44 @@ TEST(BuildAppendJSArrayFastDoubleElementsObject) {
isolate->heap()->undefined_value(), Smi::FromInt(6), 6, 4);
}
TEST(CodeStubAssemblerGraphsCorrectness) {
// The test does not work with interpreter because bytecode handlers taken
// from the snapshot already refer to precompiled stubs from the snapshot
// and there is no way to trigger bytecode handlers recompilation.
if (i::FLAG_ignition || i::FLAG_turbo) return;
i::FLAG_csa_verify = true;
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
{
v8::Isolate::Scope isolate_scope(isolate);
LocalContext env(isolate);
v8::HandleScope scope(isolate);
{
// Enforce recompilation of the following stubs.
i::CodeStub::Major code_stub_keys[] = {
i::CodeStub::LoadIC, i::CodeStub::LoadICTrampoline,
i::CodeStub::LoadGlobalIC, i::CodeStub::LoadGlobalICTrampoline,
i::CodeStub::KeyedLoadICTF, i::CodeStub::KeyedLoadICTrampolineTF,
i::CodeStub::StoreIC, i::CodeStub::StoreICTrampoline,
i::CodeStub::KeyedStoreICTF, i::CodeStub::KeyedStoreICTrampolineTF,
};
i::Heap* heap = i_isolate->heap();
i::Handle<i::UnseededNumberDictionary> dict(heap->code_stubs());
for (size_t i = 0; i < arraysize(code_stub_keys); i++) {
dict = i::UnseededNumberDictionary::DeleteKey(dict, code_stub_keys[i]);
}
heap->SetRootCodeStubs(*dict);
}
// Generate some stubs here.
}
isolate->Dispose();
}
} // namespace internal
} // namespace v8
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