From 53445715805fdfa5a3fa02cf68ce6adb79b87b1c Mon Sep 17 00:00:00 2001 From: danno Date: Fri, 27 Jan 2017 03:32:27 -0800 Subject: [PATCH] Make enabling of CSA verifier a build-time flag BUG=chromium:685561 Review-Url: https://codereview.chromium.org/2650273006 Cr-Commit-Position: refs/heads/master@{#42734} --- BUILD.gn | 7 +++++++ Makefile | 4 ++++ gypfiles/features.gypi | 5 +++++ src/compiler/pipeline.cc | 4 ++-- src/compiler/raw-machine-assembler.h | 8 ++++++++ src/flag-definitions.h | 11 +++++++++-- .../interpreter-assembler-unittest.cc | 17 +++++++++++++---- 7 files changed, 48 insertions(+), 8 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 16dac8d29c..57bf035f8e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -47,6 +47,9 @@ declare_args() { # Enable slow dchecks. v8_enable_slow_dchecks = false + # Enable code-generation-time checking of types in the CodeStubAssembler. + v8_enable_verify_csa = false + # Interpreted regexp engine exists as platform-independent alternative # based where the regular expression is compiled to a bytecode. v8_interpreted_regexp = false @@ -380,6 +383,10 @@ config("toolchain") { defines += [ "DEBUG" ] } + if (v8_enable_verify_csa) { + defines += [ "ENABLE_VERIFY_CSA" ] + } + if (v8_no_inline) { cflags += [ "-fno-inline-functions", diff --git a/Makefile b/Makefile index 6eeac09a14..299d4aa09c 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,10 @@ endif ifeq ($(objectprint), on) GYPFLAGS += -Dv8_object_print=1 endif +# verifycsa=on +ifeq ($(verifycsa), on) + GYPFLAGS += -Dv8_enable_verify_csa=1 +endif # verifyheap=on ifeq ($(verifyheap), on) GYPFLAGS += -Dv8_enable_verify_heap=1 diff --git a/gypfiles/features.gypi b/gypfiles/features.gypi index f82a59f0f8..6cce64ca20 100644 --- a/gypfiles/features.gypi +++ b/gypfiles/features.gypi @@ -33,6 +33,8 @@ 'v8_enable_gdbjit%': 0, + 'v8_enable_verify_csa%': 0, + 'v8_object_print%': 0, 'v8_enable_verify_heap%': 0, @@ -78,6 +80,9 @@ ['v8_enable_gdbjit==1', { 'defines': ['ENABLE_GDB_JIT_INTERFACE',], }], + ['v8_enable_verify_csa==1', { + 'defines': ['ENABLE_VERIFY_CSA',], + }], ['v8_object_print==1', { 'defines': ['OBJECT_PRINT',], }], diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index 8ef8c538b4..069b1872ee 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -1662,7 +1662,7 @@ Handle 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(FLAG_csa_verify); + data.set_verify_graph(FLAG_verify_csa); std::unique_ptr pipeline_statistics; if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats)); @@ -1797,7 +1797,7 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage, (FLAG_turbo_verify_machine_graph != nullptr && (!strcmp(FLAG_turbo_verify_machine_graph, "*") || !strcmp(FLAG_turbo_verify_machine_graph, data->debug_name())))) { - if (FLAG_trace_csa_verify) { + if (FLAG_trace_verify_csa) { AllowHandleDereference allow_deref; CompilationInfo* info = data->info(); CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); diff --git a/src/compiler/raw-machine-assembler.h b/src/compiler/raw-machine-assembler.h index af36b8c08a..3ed932ee10 100644 --- a/src/compiler/raw-machine-assembler.h +++ b/src/compiler/raw-machine-assembler.h @@ -534,13 +534,21 @@ class V8_EXPORT_PRIVATE RawMachineAssembler { // Conversions. Node* BitcastTaggedToWord(Node* a) { +#ifdef ENABLE_VERIFY_CSA return AddNode(machine()->BitcastTaggedToWord(), a); +#else + return a; +#endif } Node* BitcastWordToTagged(Node* a) { return AddNode(machine()->BitcastWordToTagged(), a); } Node* BitcastWordToTaggedSigned(Node* a) { +#ifdef ENABLE_VERIFY_CSA return AddNode(machine()->BitcastWordToTaggedSigned(), a); +#else + return a; +#endif } Node* TruncateFloat64ToWord32(Node* a) { return AddNode(machine()->TruncateFloat64ToWord32(), a); diff --git a/src/flag-definitions.h b/src/flag-definitions.h index d8ee41385f..2da3918a52 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -452,9 +452,16 @@ 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, DEBUG_BOOL, +#ifdef ENABLE_VERIFY_CSA +DEFINE_BOOL(verify_csa, DEBUG_BOOL, "verify TurboFan machine graph of code stubs") -DEFINE_BOOL(trace_csa_verify, false, "trace code stubs verification") +#else +// Define the flag as read-only-false so that code still compiles even in the +// non-ENABLE_VERIFY_CSA configuration. +DEFINE_BOOL_READONLY(verify_csa, false, + "verify TurboFan machine graph of code stubs") +#endif +DEFINE_BOOL(trace_verify_csa, false, "trace code stubs verification") DEFINE_STRING(csa_trap_on_node, nullptr, "trigger break point when a node with given id is created in " "given stub. The format is: StubName,NodeId") diff --git a/test/unittests/interpreter/interpreter-assembler-unittest.cc b/test/unittests/interpreter/interpreter-assembler-unittest.cc index 40f9a60c17..0d15343cb0 100644 --- a/test/unittests/interpreter/interpreter-assembler-unittest.cc +++ b/test/unittests/interpreter/interpreter-assembler-unittest.cc @@ -18,6 +18,14 @@ namespace internal { using namespace compiler; +#ifdef ENABLE_VERIFY_CSA +#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) IsBitcastWordToTaggedSigned(x) +#define IS_BITCAST_TAGGED_TO_WORD(x) IsBitcastTaggedToWord(x) +#else +#define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) (x) +#define IS_BITCAST_TAGGED_TO_WORD(x) (x) +#endif + namespace interpreter { InterpreterAssemblerTestState::InterpreterAssemblerTestState( @@ -550,11 +558,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, SmiTag) { InterpreterAssemblerTestState state(this, bytecode); InterpreterAssemblerForTest m(&state, bytecode); Node* value = m.Int32Constant(44); - EXPECT_THAT(m.SmiTag(value), IsBitcastWordToTaggedSigned(IsIntPtrConstant( - static_cast(44) - << (kSmiShiftSize + kSmiTagSize)))); + EXPECT_THAT( + m.SmiTag(value), + IS_BITCAST_WORD_TO_TAGGED_SIGNED(IsIntPtrConstant( + static_cast(44) << (kSmiShiftSize + kSmiTagSize)))); EXPECT_THAT(m.SmiUntag(value), - IsWordSar(IsBitcastTaggedToWord(value), + IsWordSar(IS_BITCAST_TAGGED_TO_WORD(value), IsIntPtrConstant(kSmiShiftSize + kSmiTagSize))); } }