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}
This commit is contained in:
danno 2017-01-27 03:32:27 -08:00 committed by Commit bot
parent 7046c14d35
commit 5344571580
7 changed files with 48 additions and 8 deletions

View File

@ -47,6 +47,9 @@ declare_args() {
# Enable slow dchecks. # Enable slow dchecks.
v8_enable_slow_dchecks = false 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 # Interpreted regexp engine exists as platform-independent alternative
# based where the regular expression is compiled to a bytecode. # based where the regular expression is compiled to a bytecode.
v8_interpreted_regexp = false v8_interpreted_regexp = false
@ -380,6 +383,10 @@ config("toolchain") {
defines += [ "DEBUG" ] defines += [ "DEBUG" ]
} }
if (v8_enable_verify_csa) {
defines += [ "ENABLE_VERIFY_CSA" ]
}
if (v8_no_inline) { if (v8_no_inline) {
cflags += [ cflags += [
"-fno-inline-functions", "-fno-inline-functions",

View File

@ -51,6 +51,10 @@ endif
ifeq ($(objectprint), on) ifeq ($(objectprint), on)
GYPFLAGS += -Dv8_object_print=1 GYPFLAGS += -Dv8_object_print=1
endif endif
# verifycsa=on
ifeq ($(verifycsa), on)
GYPFLAGS += -Dv8_enable_verify_csa=1
endif
# verifyheap=on # verifyheap=on
ifeq ($(verifyheap), on) ifeq ($(verifyheap), on)
GYPFLAGS += -Dv8_enable_verify_heap=1 GYPFLAGS += -Dv8_enable_verify_heap=1

View File

@ -33,6 +33,8 @@
'v8_enable_gdbjit%': 0, 'v8_enable_gdbjit%': 0,
'v8_enable_verify_csa%': 0,
'v8_object_print%': 0, 'v8_object_print%': 0,
'v8_enable_verify_heap%': 0, 'v8_enable_verify_heap%': 0,
@ -78,6 +80,9 @@
['v8_enable_gdbjit==1', { ['v8_enable_gdbjit==1', {
'defines': ['ENABLE_GDB_JIT_INTERFACE',], 'defines': ['ENABLE_GDB_JIT_INTERFACE',],
}], }],
['v8_enable_verify_csa==1', {
'defines': ['ENABLE_VERIFY_CSA',],
}],
['v8_object_print==1', { ['v8_object_print==1', {
'defines': ['OBJECT_PRINT',], 'defines': ['OBJECT_PRINT',],
}], }],

View File

@ -1662,7 +1662,7 @@ Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
ZoneStats zone_stats(isolate->allocator()); ZoneStats zone_stats(isolate->allocator());
SourcePositionTable source_positions(graph); SourcePositionTable source_positions(graph);
PipelineData data(&zone_stats, &info, graph, schedule, &source_positions); 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<PipelineStatistics> pipeline_statistics; std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats)); pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats));
@ -1797,7 +1797,7 @@ bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage,
(FLAG_turbo_verify_machine_graph != nullptr && (FLAG_turbo_verify_machine_graph != nullptr &&
(!strcmp(FLAG_turbo_verify_machine_graph, "*") || (!strcmp(FLAG_turbo_verify_machine_graph, "*") ||
!strcmp(FLAG_turbo_verify_machine_graph, data->debug_name())))) { !strcmp(FLAG_turbo_verify_machine_graph, data->debug_name())))) {
if (FLAG_trace_csa_verify) { if (FLAG_trace_verify_csa) {
AllowHandleDereference allow_deref; AllowHandleDereference allow_deref;
CompilationInfo* info = data->info(); CompilationInfo* info = data->info();
CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());

View File

@ -534,13 +534,21 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
// Conversions. // Conversions.
Node* BitcastTaggedToWord(Node* a) { Node* BitcastTaggedToWord(Node* a) {
#ifdef ENABLE_VERIFY_CSA
return AddNode(machine()->BitcastTaggedToWord(), a); return AddNode(machine()->BitcastTaggedToWord(), a);
#else
return a;
#endif
} }
Node* BitcastWordToTagged(Node* a) { Node* BitcastWordToTagged(Node* a) {
return AddNode(machine()->BitcastWordToTagged(), a); return AddNode(machine()->BitcastWordToTagged(), a);
} }
Node* BitcastWordToTaggedSigned(Node* a) { Node* BitcastWordToTaggedSigned(Node* a) {
#ifdef ENABLE_VERIFY_CSA
return AddNode(machine()->BitcastWordToTaggedSigned(), a); return AddNode(machine()->BitcastWordToTaggedSigned(), a);
#else
return a;
#endif
} }
Node* TruncateFloat64ToWord32(Node* a) { Node* TruncateFloat64ToWord32(Node* a) {
return AddNode(machine()->TruncateFloat64ToWord32(), a); return AddNode(machine()->TruncateFloat64ToWord32(), a);

View File

@ -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_BOOL(turbo_verify, DEBUG_BOOL, "verify TurboFan graphs at each phase")
DEFINE_STRING(turbo_verify_machine_graph, nullptr, DEFINE_STRING(turbo_verify_machine_graph, nullptr,
"verify TurboFan machine graph before instruction selection") "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") "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, DEFINE_STRING(csa_trap_on_node, nullptr,
"trigger break point when a node with given id is created in " "trigger break point when a node with given id is created in "
"given stub. The format is: StubName,NodeId") "given stub. The format is: StubName,NodeId")

View File

@ -18,6 +18,14 @@ namespace internal {
using namespace compiler; 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 { namespace interpreter {
InterpreterAssemblerTestState::InterpreterAssemblerTestState( InterpreterAssemblerTestState::InterpreterAssemblerTestState(
@ -550,11 +558,12 @@ TARGET_TEST_F(InterpreterAssemblerTest, SmiTag) {
InterpreterAssemblerTestState state(this, bytecode); InterpreterAssemblerTestState state(this, bytecode);
InterpreterAssemblerForTest m(&state, bytecode); InterpreterAssemblerForTest m(&state, bytecode);
Node* value = m.Int32Constant(44); Node* value = m.Int32Constant(44);
EXPECT_THAT(m.SmiTag(value), IsBitcastWordToTaggedSigned(IsIntPtrConstant( EXPECT_THAT(
static_cast<intptr_t>(44) m.SmiTag(value),
<< (kSmiShiftSize + kSmiTagSize)))); IS_BITCAST_WORD_TO_TAGGED_SIGNED(IsIntPtrConstant(
static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize))));
EXPECT_THAT(m.SmiUntag(value), EXPECT_THAT(m.SmiUntag(value),
IsWordSar(IsBitcastTaggedToWord(value), IsWordSar(IS_BITCAST_TAGGED_TO_WORD(value),
IsIntPtrConstant(kSmiShiftSize + kSmiTagSize))); IsIntPtrConstant(kSmiShiftSize + kSmiTagSize)));
} }
} }