Commit b5a9381a authored by ishell's avatar ishell Committed by Commit bot

[interpreter][stubs] Enable graph verification for bytecode handlers and stubs...

[interpreter][stubs] Enable graph verification for bytecode handlers and stubs included into snapshot.

BUG=

Review-Url: https://codereview.chromium.org/2575473002
Cr-Commit-Position: refs/heads/master@{#41676}
parent a989a116
......@@ -108,7 +108,8 @@ Code* BuildWithCodeStubAssemblerCS(Isolate* isolate,
DCHECK_LE(0, descriptor.GetRegisterParameterCount());
compiler::CodeAssemblerState state(isolate, &zone, descriptor, flags, name);
generator(&state);
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
Handle<Code> code =
compiler::CodeAssembler::GenerateCode(&state, FLAG_csa_verify);
PostBuildProfileAndTracing(isolate, *code, name);
return *code;
}
......
......@@ -286,7 +286,7 @@ Handle<Code> HydrogenCodeStub::GenerateRuntimeTailCall(
UNIMPLEMENTED();
break;
}
return compiler::CodeAssembler::GenerateCode(&state);
return compiler::CodeAssembler::GenerateCode(&state, FLAG_csa_verify);
}
template <class Stub>
......
......@@ -437,7 +437,10 @@ Handle<Code> TurboFanCodeStub::GenerateCode() {
compiler::CodeAssemblerState state(isolate(), &zone, descriptor,
GetCodeFlags(), name);
GenerateAssembly(&state);
return compiler::CodeAssembler::GenerateCode(&state);
// TODO(ishell): enable verification once all issues are fixed.
// Enable verification only in mksnapshot.
bool verify_graph = FLAG_csa_verify && FLAG_startup_blob != nullptr;
return compiler::CodeAssembler::GenerateCode(&state, verify_graph);
}
#define ACCESSOR_ASSEMBLER(Name) \
......
......@@ -70,14 +70,17 @@ void CodeAssembler::CallPrologue() {}
void CodeAssembler::CallEpilogue() {}
// static
Handle<Code> CodeAssembler::GenerateCode(CodeAssemblerState* state) {
Handle<Code> CodeAssembler::GenerateCode(CodeAssemblerState* state,
bool verify_graph) {
// TODO(ishell): Remove verify_graph parameter and always enable the
// verification once all the issues are fixed.
DCHECK(!state->code_generated_);
RawMachineAssembler* rasm = state->raw_assembler_.get();
Schedule* schedule = rasm->Export();
Handle<Code> code = Pipeline::GenerateCodeForCodeStub(
rasm->isolate(), rasm->call_descriptor(), rasm->graph(), schedule,
state->flags_, state->name_);
state->flags_, state->name_, verify_graph);
state->code_generated_ = true;
return code;
......
......@@ -190,7 +190,8 @@ class V8_EXPORT_PRIVATE CodeAssembler {
virtual ~CodeAssembler();
static Handle<Code> GenerateCode(CodeAssemblerState* state);
static Handle<Code> GenerateCode(CodeAssemblerState* state,
bool verify_graph = false);
bool Is64() const;
bool IsFloat64RoundUpSupported() const;
......
......@@ -177,6 +177,10 @@ class PipelineData {
PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; }
bool compilation_failed() const { return compilation_failed_; }
void set_compilation_failed() { compilation_failed_ = true; }
bool verify_graph() const { return verify_graph_; }
void set_verify_graph(bool value) { verify_graph_ = value; }
Handle<Code> code() { return code_; }
void set_code(Handle<Code> code) {
DCHECK(code_.is_null());
......@@ -321,6 +325,7 @@ class PipelineData {
ZoneStats* const zone_stats_;
PipelineStatistics* pipeline_statistics_ = nullptr;
bool compilation_failed_ = false;
bool verify_graph_ = false;
Handle<Code> code_ = Handle<Code>::null();
// All objects in the following group of fields are allocated in graph_zone_.
......@@ -1609,11 +1614,14 @@ bool PipelineImpl::OptimizeGraph(Linkage* linkage) {
return ScheduleAndSelectInstructions(linkage, true);
}
// TODO(ishell): Remove verify_graph parameter and always enable the
// verification once all the issues are fixed.
Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
CallDescriptor* call_descriptor,
Graph* graph, Schedule* schedule,
Code::Flags flags,
const char* debug_name) {
const char* debug_name,
bool verify_graph) {
CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags);
if (isolate->serializer_enabled()) info.PrepareForSerializing();
......@@ -1621,6 +1629,7 @@ Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
ZoneStats zone_stats(isolate->allocator());
SourcePositionTable source_positions(graph);
PipelineData data(&zone_stats, &info, graph, schedule, &source_positions);
data.set_verify_graph(verify_graph);
std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats));
......@@ -1750,11 +1759,7 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage,
info(), data->graph(), data->schedule()));
}
// 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();
bool verify_stub_graph = data->verify_graph();
if (verify_stub_graph || (FLAG_turbo_verify_machine_graph != nullptr &&
(!strcmp(FLAG_turbo_verify_machine_graph, "*") ||
!strcmp(FLAG_turbo_verify_machine_graph,
......
......@@ -49,7 +49,8 @@ class Pipeline : public AllStatic {
CallDescriptor* call_descriptor,
Graph* graph, Schedule* schedule,
Code::Flags flags,
const char* debug_name);
const char* debug_name,
bool verify_graph);
// Run the entire pipeline and generate a handle to a code object suitable for
// testing.
......
......@@ -441,7 +441,8 @@ DEFINE_BOOL(turbo_asm, true, "enable TurboFan for asm.js code")
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(csa_verify, DEBUG_BOOL,
"verify TurboFan machine graph of code stubs")
DEFINE_BOOL(trace_csa_verify, false, "trace code stubs verification")
DEFINE_BOOL(turbo_stats, false, "print TurboFan statistics")
DEFINE_BOOL(turbo_stats_nvp, false,
......
......@@ -104,7 +104,11 @@ void Interpreter::InstallBytecodeHandler(Zone* zone, Bytecode bytecode,
Bytecodes::ToString(bytecode), Bytecodes::ReturnCount(bytecode));
InterpreterAssembler assembler(&state, bytecode, operand_scale);
(this->*generator)(&assembler);
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state);
// TODO(ishell): enable verification once all issues are fixed.
// Enable verification only in mksnapshot.
bool verify_graph = FLAG_csa_verify && FLAG_startup_blob != nullptr;
Handle<Code> code =
compiler::CodeAssembler::GenerateCode(&state, verify_graph);
size_t index = GetDispatchTableIndex(bytecode, operand_scale);
dispatch_table_[index] = code->entry();
TraceCodegen(code);
......
......@@ -41,7 +41,7 @@ class CodeAssemblerTester {
Handle<Code> GenerateCode() { return CodeAssembler::GenerateCode(&state_); }
Handle<Code> GenerateCodeCloseAndEscape() {
return scope_.CloseAndEscape(CodeAssembler::GenerateCode(&state_));
return scope_.CloseAndEscape(GenerateCode());
}
private:
......
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