From dca02f0c28f91e59e27900736012a54358081f8a Mon Sep 17 00:00:00 2001 From: Clemens Hammacher Date: Fri, 8 Sep 2017 15:42:59 +0200 Subject: [PATCH] [wasm] [cleanup] undef all defined macros in cc files This is a cleanup for a presubmit check that might get enabled soon: https://chromium-review.googlesource.com/c/v8/v8/+/657104 R=ahaas@chromium.org CC=mstarzinger@chromium.org Change-Id: Id431f2d4e8fcbb88a777b63e3fb136fa8ceac70a Reviewed-on: https://chromium-review.googlesource.com/657400 Commit-Queue: Clemens Hammacher Reviewed-by: Andreas Haas Reviewed-by: Michael Starzinger Cr-Commit-Position: refs/heads/master@{#47926} --- src/compiler/wasm-compiler.cc | 13 +++++++---- src/compiler/wasm-linkage.cc | 5 +++++ src/wasm/function-body-decoder.cc | 2 +- src/wasm/module-compiler.cc | 2 ++ src/wasm/module-decoder.cc | 11 ++++------ src/wasm/wasm-interpreter.cc | 6 ++++++ src/wasm/wasm-js.cc | 13 ++++++----- src/wasm/wasm-objects.cc | 7 ------ src/wasm/wasm-opcodes.cc | 36 ++++++++++++++++++++++++++++--- src/wasm/wasm-text.cc | 2 ++ 10 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc index 62b5635e8b..c7dc696af8 100644 --- a/src/compiler/wasm-compiler.cc +++ b/src/compiler/wasm-compiler.cc @@ -38,6 +38,10 @@ #include "src/wasm/wasm-opcodes.h" #include "src/wasm/wasm-text.h" +namespace v8 { +namespace internal { +namespace compiler { + // TODO(titzer): pull WASM_64 up to a common header. #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 #define WASM_64 1 @@ -49,10 +53,6 @@ V8_Fatal(__FILE__, __LINE__, "Unsupported opcode #%d:%s", (opcode), \ wasm::WasmOpcodes::OpcodeName(opcode)); -namespace v8 { -namespace internal { -namespace compiler { - namespace { void MergeControlToEnd(JSGraph* jsgraph, Node* node) { @@ -4418,6 +4418,11 @@ MaybeHandle WasmCompilationUnit::CompileWasmFunction( return unit.FinishCompilation(thrower); } +#undef WASM_64 +#undef FATAL_UNSUPPORTED_OPCODE +#undef ATOMIC_BINOP_LIST +#undef ATOMIC_TERNARY_LIST + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/wasm-linkage.cc b/src/compiler/wasm-linkage.cc index 5e94f35e56..661948d731 100644 --- a/src/compiler/wasm-linkage.cc +++ b/src/compiler/wasm-linkage.cc @@ -338,6 +338,11 @@ CallDescriptor* GetI32WasmCallDescriptorForSimd(Zone* zone, MachineRepresentation::kWord32); } +#undef GP_PARAM_REGISTERS +#undef GP_RETURN_REGISTERS +#undef FP_PARAM_REGISTERS +#undef FP_RETURN_REGISTERS + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc index b798c2b20d..c58504377d 100644 --- a/src/wasm/function-body-decoder.cc +++ b/src/wasm/function-body-decoder.cc @@ -960,7 +960,7 @@ BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, &decoder, start, static_cast(num_locals), zone); } -#undef TRACE +#undef BUILD } // namespace wasm } // namespace internal diff --git a/src/wasm/module-compiler.cc b/src/wasm/module-compiler.cc index 9c646a44ce..3f04d74df1 100644 --- a/src/wasm/module-compiler.cc +++ b/src/wasm/module-compiler.cc @@ -2415,6 +2415,8 @@ class AsyncCompileJob::FinishModule : public CompileStep { }; #undef TRACE +#undef TRACE_CHAIN +#undef TRACE_COMPILE } // namespace wasm } // namespace internal diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc index 5280af7374..270b0e5b70 100644 --- a/src/wasm/module-decoder.cc +++ b/src/wasm/module-decoder.cc @@ -265,13 +265,9 @@ class ModuleDecoder : public Decoder { } // File are named `HASH.{ok,failed}.wasm`. size_t hash = base::hash_range(start_, end_); - char buf[32] = {'\0'}; -#if V8_OS_WIN && _MSC_VER < 1900 -#define snprintf sprintf_s -#endif - snprintf(buf, sizeof(buf) - 1, "%016zx.%s.wasm", hash, - result.ok() ? "ok" : "failed"); - std::string name(buf); + EmbeddedVector buf; + SNPrintF(buf, "%016zx.%s.wasm", hash, result.ok() ? "ok" : "failed"); + std::string name(buf.start()); if (FILE* wasm_file = base::OS::FOpen((path + name).c_str(), "wb")) { if (fwrite(start_, end_ - start_, 1, wasm_file) != 1) { OFStream os(stderr); @@ -316,6 +312,7 @@ class ModuleDecoder : public Decoder { BYTES(kWasmVersion), BYTES(magic_version)); } } +#undef BYTES } void DecodeSection(SectionCode section_code, Vector bytes, diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc index 6c6199eaba..a760f14ed8 100644 --- a/src/wasm/wasm-interpreter.cc +++ b/src/wasm/wasm-interpreter.cc @@ -2005,6 +2005,7 @@ class ThreadImpl { return; PAUSE_IF_BREAK_FLAG(AfterReturn); } +#undef PAUSE_IF_BREAK_FLAG } state_ = WasmInterpreter::PAUSED; @@ -2702,6 +2703,11 @@ WasmInterpreter::HeapObjectsScope::~HeapObjectsScope() { } #undef TRACE +#undef FOREACH_INTERNAL_OPCODE +#undef WASM_CTYPES +#undef FOREACH_SIMPLE_BINOP +#undef FOREACH_OTHER_BINOP +#undef FOREACH_OTHER_UNOP } // namespace wasm } // namespace internal diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc index 8857f1a256..3cfbed364c 100644 --- a/src/wasm/wasm-js.cc +++ b/src/wasm/wasm-js.cc @@ -590,17 +590,16 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo& args) { args.GetReturnValue().Set(Utils::ToLocal(memory_obj)); } -#define NAME_OF_WasmMemoryObject "WebAssembly.Memory" -#define NAME_OF_WasmModuleObject "WebAssembly.Module" -#define NAME_OF_WasmInstanceObject "WebAssembly.Instance" -#define NAME_OF_WasmTableObject "WebAssembly.Table" +constexpr const char* kName_WasmMemoryObject = "WebAssembly.Memory"; +constexpr const char* kName_WasmInstanceObject = "WebAssembly.Instance"; +constexpr const char* kName_WasmTableObject = "WebAssembly.Table"; #define EXTRACT_THIS(var, WasmType) \ i::Handle var; \ { \ i::Handle this_arg = Utils::OpenHandle(*args.This()); \ if (!this_arg->Is##WasmType()) { \ - thrower.TypeError("Receiver is not a " NAME_OF_##WasmType); \ + thrower.TypeError("Receiver is not a %s", kName_##WasmType); \ return; \ } \ var = i::Handle::cast(this_arg); \ @@ -966,5 +965,9 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) { JSObject::AddProperty(webassembly, isolate->factory()->RuntimeError_string(), runtime_error, attributes); } + +#undef ASSIGN +#undef EXTRACT_THIS + } // namespace internal } // namespace v8 diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc index 75e9d3b911..7d00112b44 100644 --- a/src/wasm/wasm-objects.cc +++ b/src/wasm/wasm-objects.cc @@ -22,12 +22,6 @@ if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ } while (false) -// TODO(mostynb@opera.com): this is never used, remove it? -#define TRACE_CHAIN(instance) \ - do { \ - instance->PrintInstancesChain(); \ - } while (false) - namespace v8 { namespace internal { @@ -1525,7 +1519,6 @@ Handle WasmCompiledModule::CompileLazy( } #undef TRACE -#undef TRACE_CHAIN } // namespace internal } // namespace v8 diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc index 10bc69dfb2..1f0312d8bb 100644 --- a/src/wasm/wasm-opcodes.cc +++ b/src/wasm/wasm-opcodes.cc @@ -248,6 +248,34 @@ const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) { } } +#undef CASE_OP +#undef CASE_I32_OP +#undef CASE_I64_OP +#undef CASE_F32_OP +#undef CASE_F64_OP +#undef CASE_F32x4_OP +#undef CASE_I32x4_OP +#undef CASE_I16x8_OP +#undef CASE_I8x16_OP +#undef CASE_S128_OP +#undef CASE_S32x4_OP +#undef CASE_S16x8_OP +#undef CASE_S8x16_OP +#undef CASE_S1x4_OP +#undef CASE_S1x8_OP +#undef CASE_S1x16_OP +#undef CASE_INT_OP +#undef CASE_FLOAT_OP +#undef CASE_ALL_OP +#undef CASE_SIMD_OP +#undef CASE_SIMDI_OP +#undef CASE_SIGN_OP +#undef CASE_UNSIGNED_OP +#undef CASE_ALL_SIGN_OP +#undef CASE_CONVERT_OP +#undef CASE_L32_OP +#undef CASE_U32_OP + bool WasmOpcodes::IsPrefixOpcode(WasmOpcode opcode) { switch (opcode) { #define CHECK_PREFIX(name, opcode) case k##name##Prefix: @@ -305,23 +333,23 @@ bool IsJSCompatibleSignature(const FunctionSig* sig) { namespace { #define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name, - enum WasmOpcodeSig : byte { kSigEnum_None, FOREACH_SIGNATURE(DECLARE_SIG_ENUM) }; +#undef DECLARE_SIG_ENUM #define DECLARE_SIG(name, ...) \ constexpr ValueType kTypes_##name[] = {__VA_ARGS__}; \ constexpr FunctionSig kSig_##name( \ 1, static_cast(arraysize(kTypes_##name)) - 1, kTypes_##name); - FOREACH_SIGNATURE(DECLARE_SIG) +#undef DECLARE_SIG #define DECLARE_SIG_ENTRY(name, ...) &kSig_##name, - constexpr const FunctionSig* kSimpleExprSigs[] = { nullptr, FOREACH_SIGNATURE(DECLARE_SIG_ENTRY)}; +#undef DECLARE_SIG_ENTRY // The following constexpr functions are used to initialize the constant arrays // defined below. They must have exactly one return statement, and no switch. @@ -375,6 +403,8 @@ CONSTEXPR_IF_NOT_GCC_4 std::array kSimdExprSigTable = CONSTEXPR_IF_NOT_GCC_4 std::array kAtomicExprSigTable = base::make_array<256>(GetAtomicOpcodeSigIndex); +#undef CONSTEXPR_IF_NOT_GCC_4 + } // namespace FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) { diff --git a/src/wasm/wasm-text.cc b/src/wasm/wasm-text.cc index e1c74e453b..3ec8043065 100644 --- a/src/wasm/wasm-text.cc +++ b/src/wasm/wasm-text.cc @@ -169,6 +169,7 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes, CASE_CONST(I64, i64, int64_t) CASE_CONST(F32, f32, float) CASE_CONST(F64, f64, double) +#undef CASE_CONST #define CASE_OPCODE(opcode, _, __) case kExpr##opcode: FOREACH_LOAD_MEM_OPCODE(CASE_OPCODE) @@ -202,6 +203,7 @@ void PrintWasmText(const WasmModule* module, const ModuleWireBytes& wire_bytes, FOREACH_ATOMIC_OPCODE(CASE_OPCODE) os << WasmOpcodes::OpcodeName(opcode); break; +#undef CASE_OPCODE default: UNREACHABLE();