Commit b1e72579 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Make trace flags read only in release builds

This saves us 14.2kB binary size in libv8.so (in release mode), and
probably also improves performance a little bit.

R=titzer@chromium.org

Bug: v8:7109
Change-Id: I345a48369aaf054572a4fd4368bf5cd526ed146a
Reviewed-on: https://chromium-review.googlesource.com/797270Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49905}
parent ea5f23af
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \ #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
V8_EXPORT_PRIVATE extern ctype FLAG_##nam; V8_EXPORT_PRIVATE extern ctype FLAG_##nam;
#define FLAG_READONLY(ftype, ctype, nam, def, cmt) \ #define FLAG_READONLY(ftype, ctype, nam, def, cmt) \
static ctype const FLAG_##nam = def; static constexpr ctype FLAG_##nam = def;
// We want to supply the actual storage and value for the flag variable in the // We want to supply the actual storage and value for the flag variable in the
// .cc file. We only do this for writable flags. // .cc file. We only do this for writable flags.
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
// for MODE_META, so there is no impact on the flags interface. // for MODE_META, so there is no impact on the flags interface.
#elif defined(FLAG_MODE_DEFINE_DEFAULTS) #elif defined(FLAG_MODE_DEFINE_DEFAULTS)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \ #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
static ctype const FLAGDEFAULT_##nam = def; static constexpr ctype FLAGDEFAULT_##nam = def;
// We want to write entries into our meta data table, for internal parsing and // We want to write entries into our meta data table, for internal parsing and
// printing / etc in the flag parser code. We only do this for writable flags. // printing / etc in the flag parser code. We only do this for writable flags.
...@@ -172,6 +172,12 @@ struct MaybeBoolFlag { ...@@ -172,6 +172,12 @@ struct MaybeBoolFlag {
FLAG_ALIAS(STRING, const char*, alias, nam) FLAG_ALIAS(STRING, const char*, alias, nam)
#define DEFINE_ALIAS_ARGS(alias, nam) FLAG_ALIAS(ARGS, JSArguments, alias, nam) #define DEFINE_ALIAS_ARGS(alias, nam) FLAG_ALIAS(ARGS, JSArguments, alias, nam)
#ifdef DEBUG
#define DEFINE_DEBUG_BOOL DEFINE_BOOL
#else
#define DEFINE_DEBUG_BOOL DEFINE_BOOL_READONLY
#endif
// //
// Flags in all modes. // Flags in all modes.
// //
...@@ -473,7 +479,8 @@ DEFINE_BOOL(wasm_disable_structured_cloning, false, ...@@ -473,7 +479,8 @@ DEFINE_BOOL(wasm_disable_structured_cloning, false,
"disable wasm structured cloning") "disable wasm structured cloning")
DEFINE_INT(wasm_num_compilation_tasks, 10, DEFINE_INT(wasm_num_compilation_tasks, 10,
"number of parallel compilation tasks for wasm") "number of parallel compilation tasks for wasm")
DEFINE_BOOL(wasm_trace_native_heap, false, "trace wasm native heap events") DEFINE_DEBUG_BOOL(wasm_trace_native_heap, false,
"trace wasm native heap events")
DEFINE_BOOL(wasm_jit_to_native, false, DEFINE_BOOL(wasm_jit_to_native, false,
"JIT wasm code to native (not JS GC) memory") "JIT wasm code to native (not JS GC) memory")
DEFINE_BOOL(wasm_trace_serialization, false, DEFINE_BOOL(wasm_trace_serialization, false,
...@@ -492,20 +499,23 @@ DEFINE_UINT(wasm_max_mem_pages, v8::internal::wasm::kV8MaxWasmMemoryPages, ...@@ -492,20 +499,23 @@ DEFINE_UINT(wasm_max_mem_pages, v8::internal::wasm::kV8MaxWasmMemoryPages,
"maximum memory size of a wasm instance") "maximum memory size of a wasm instance")
DEFINE_UINT(wasm_max_table_size, v8::internal::wasm::kV8MaxWasmTableSize, DEFINE_UINT(wasm_max_table_size, v8::internal::wasm::kV8MaxWasmTableSize,
"maximum table size of a wasm instance") "maximum table size of a wasm instance")
DEFINE_BOOL(trace_wasm_decoder, false, "trace decoding of wasm code") DEFINE_DEBUG_BOOL(trace_wasm_decoder, false, "trace decoding of wasm code")
DEFINE_BOOL(trace_wasm_decode_time, false, "trace decoding time of wasm code") DEFINE_DEBUG_BOOL(trace_wasm_decode_time, false,
DEFINE_BOOL(trace_wasm_compiler, false, "trace compiling of wasm code") "trace decoding time of wasm code")
DEFINE_BOOL(trace_wasm_interpreter, false, "trace interpretation of wasm code") DEFINE_DEBUG_BOOL(trace_wasm_compiler, false, "trace compiling of wasm code")
DEFINE_BOOL(trace_wasm_streaming, false, DEFINE_DEBUG_BOOL(trace_wasm_interpreter, false,
"trace interpretation of wasm code")
DEFINE_DEBUG_BOOL(trace_wasm_streaming, false,
"trace streaming compilation of wasm code") "trace streaming compilation of wasm code")
DEFINE_INT(trace_wasm_ast_start, 0, DEFINE_INT(trace_wasm_ast_start, 0,
"start function for wasm AST trace (inclusive)") "start function for wasm AST trace (inclusive)")
DEFINE_INT(trace_wasm_ast_end, 0, "end function for wasm AST trace (exclusive)") DEFINE_INT(trace_wasm_ast_end, 0, "end function for wasm AST trace (exclusive)")
DEFINE_BOOL(liftoff, false, DEFINE_BOOL(liftoff, false,
"enable liftoff, the experimental wasm baseline compiler") "enable liftoff, the experimental wasm baseline compiler")
DEFINE_BOOL(trace_liftoff, false, "trace liftoff, the wasm baseline compiler") DEFINE_DEBUG_BOOL(trace_liftoff, false,
"trace liftoff, the wasm baseline compiler")
DEFINE_UINT(skip_compiling_wasm_funcs, 0, "start compiling at function N") DEFINE_UINT(skip_compiling_wasm_funcs, 0, "start compiling at function N")
DEFINE_BOOL(wasm_break_on_decoder_error, false, DEFINE_DEBUG_BOOL(wasm_break_on_decoder_error, false,
"debug break when wasm decoder encounters an error") "debug break when wasm decoder encounters an error")
DEFINE_BOOL(wasm_trace_memory, false, DEFINE_BOOL(wasm_trace_memory, false,
"print all memory updates performed in wasm code") "print all memory updates performed in wasm code")
...@@ -519,7 +529,7 @@ DEFINE_BOOL(trace_asm_scanner, false, ...@@ -519,7 +529,7 @@ DEFINE_BOOL(trace_asm_scanner, false,
DEFINE_BOOL(trace_asm_parser, false, "verbose logging of asm.js parse failures") DEFINE_BOOL(trace_asm_parser, false, "verbose logging of asm.js parse failures")
DEFINE_BOOL(stress_validate_asm, false, "try to validate everything as asm.js") DEFINE_BOOL(stress_validate_asm, false, "try to validate everything as asm.js")
DEFINE_BOOL(dump_wasm_module, false, "dump wasm module bytes") DEFINE_DEBUG_BOOL(dump_wasm_module, false, "dump wasm module bytes")
DEFINE_STRING(dump_wasm_module_path, nullptr, DEFINE_STRING(dump_wasm_module_path, nullptr,
"directory to dump wasm modules to") "directory to dump wasm modules to")
...@@ -551,7 +561,7 @@ DEFINE_BOOL(asm_wasm_lazy_compilation, false, ...@@ -551,7 +561,7 @@ DEFINE_BOOL(asm_wasm_lazy_compilation, false,
DEFINE_IMPLICATION(validate_asm, asm_wasm_lazy_compilation) DEFINE_IMPLICATION(validate_asm, asm_wasm_lazy_compilation)
DEFINE_BOOL(wasm_lazy_compilation, false, DEFINE_BOOL(wasm_lazy_compilation, false,
"enable lazy compilation for all wasm modules") "enable lazy compilation for all wasm modules")
DEFINE_BOOL(trace_wasm_lazy_compilation, false, DEFINE_DEBUG_BOOL(trace_wasm_lazy_compilation, false,
"trace lazy compilation of wasm functions") "trace lazy compilation of wasm functions")
// wasm-interpret-all resets {asm-,}wasm-lazy-compilation. // wasm-interpret-all resets {asm-,}wasm-lazy-compilation.
DEFINE_NEG_IMPLICATION(wasm_interpret_all, asm_wasm_lazy_compilation) DEFINE_NEG_IMPLICATION(wasm_interpret_all, asm_wasm_lazy_compilation)
...@@ -1081,7 +1091,7 @@ DEFINE_BOOL(trace_regexp_parser, false, "trace regexp parsing") ...@@ -1081,7 +1091,7 @@ DEFINE_BOOL(trace_regexp_parser, false, "trace regexp parsing")
DEFINE_BOOL(print_break_location, false, "print source location on debug break") DEFINE_BOOL(print_break_location, false, "print source location on debug break")
// wasm instance management // wasm instance management
DEFINE_BOOL(trace_wasm_instances, false, DEFINE_DEBUG_BOOL(trace_wasm_instances, false,
"trace creation and collection of wasm instances") "trace creation and collection of wasm instances")
// //
...@@ -1285,6 +1295,7 @@ DEFINE_IMPLICATION(unbox_double_fields, track_double_fields) ...@@ -1285,6 +1295,7 @@ DEFINE_IMPLICATION(unbox_double_fields, track_double_fields)
#undef DEFINE_BOOL #undef DEFINE_BOOL
#undef DEFINE_MAYBE_BOOL #undef DEFINE_MAYBE_BOOL
#undef DEFINE_DEBUG_BOOL
#undef DEFINE_INT #undef DEFINE_INT
#undef DEFINE_STRING #undef DEFINE_STRING
#undef DEFINE_FLOAT #undef DEFINE_FLOAT
......
...@@ -19,7 +19,6 @@ namespace v8 { ...@@ -19,7 +19,6 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#if DEBUG
#define TRACE(...) \ #define TRACE(...) \
do { \ do { \
if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \
...@@ -28,10 +27,6 @@ namespace wasm { ...@@ -28,10 +27,6 @@ namespace wasm {
do { \ do { \
if (FLAG_trace_wasm_decoder && (cond)) PrintF(__VA_ARGS__); \ if (FLAG_trace_wasm_decoder && (cond)) PrintF(__VA_ARGS__); \
} while (false) } while (false)
#else
#define TRACE(...)
#define TRACE_IF(...)
#endif
// A {DecodeResult} only stores the failure / success status, but no data. Thus // A {DecodeResult} only stores the failure / success status, but no data. Thus
// we use {nullptr_t} as data value, such that the only valid data stored in // we use {nullptr_t} as data value, such that the only valid data stored in
......
...@@ -22,14 +22,10 @@ namespace wasm { ...@@ -22,14 +22,10 @@ namespace wasm {
struct WasmGlobal; struct WasmGlobal;
struct WasmException; struct WasmException;
#if DEBUG
#define TRACE(...) \ #define TRACE(...) \
do { \ do { \
if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \
} while (false) } while (false)
#else
#define TRACE(...)
#endif
// Return the evaluation of `condition` if validate==true, DCHECK that it's // Return the evaluation of `condition` if validate==true, DCHECK that it's
// true and always return true otherwise. // true and always return true otherwise.
......
...@@ -21,14 +21,11 @@ namespace v8 { ...@@ -21,14 +21,11 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#if DEBUG
#define TRACE(...) \ #define TRACE(...) \
do { \ do { \
if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \
} while (false) } while (false)
#else
#define TRACE(...)
#endif
namespace { namespace {
constexpr char kNameString[] = "name"; constexpr char kNameString[] = "name";
......
...@@ -32,14 +32,10 @@ namespace v8 { ...@@ -32,14 +32,10 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#if DEBUG
#define TRACE(...) \ #define TRACE(...) \
do { \ do { \
if (FLAG_trace_wasm_interpreter) PrintF(__VA_ARGS__); \ if (FLAG_trace_wasm_interpreter) PrintF(__VA_ARGS__); \
} while (false) } while (false)
#else
#define TRACE(...)
#endif
#define FOREACH_INTERNAL_OPCODE(V) V(Breakpoint, 0xFF) #define FOREACH_INTERNAL_OPCODE(V) V(Breakpoint, 0xFF)
......
...@@ -31,21 +31,6 @@ namespace v8 { ...@@ -31,21 +31,6 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#define TRACE(...) \
do { \
if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \
} while (false)
#define TRACE_CHAIN(instance) \
do { \
instance->PrintInstancesChain(); \
} while (false)
#define TRACE_COMPILE(...) \
do { \
if (FLAG_trace_wasm_compiler) PrintF(__VA_ARGS__); \
} while (false)
// static // static
const WasmExceptionSig WasmException::empty_sig_(0, 0, nullptr); const WasmExceptionSig WasmException::empty_sig_(0, 0, nullptr);
...@@ -449,10 +434,6 @@ const char* ExternalKindName(WasmExternalKind kind) { ...@@ -449,10 +434,6 @@ const char* ExternalKindName(WasmExternalKind kind) {
return "unknown"; return "unknown";
} }
#undef TRACE
#undef TRACE_CHAIN
#undef TRACE_COMPILE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -274,11 +274,13 @@ void TestBuildingGraph( ...@@ -274,11 +274,13 @@ void TestBuildingGraph(
DecodeResult result = DecodeResult result =
BuildTFGraph(zone->allocator(), &builder, sig, start, end); BuildTFGraph(zone->allocator(), &builder, sig, start, end);
if (result.failed()) { if (result.failed()) {
#ifdef DEBUG
if (!FLAG_trace_wasm_decoder) { if (!FLAG_trace_wasm_decoder) {
// Retry the compilation with the tracing flag on, to help in debugging. // Retry the compilation with the tracing flag on, to help in debugging.
FLAG_trace_wasm_decoder = true; FLAG_trace_wasm_decoder = true;
result = BuildTFGraph(zone->allocator(), &builder, sig, start, end); result = BuildTFGraph(zone->allocator(), &builder, sig, start, end);
} }
#endif
uint32_t pc = result.error_offset(); uint32_t pc = result.error_offset();
std::ostringstream str; std::ostringstream str;
......
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