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

[wasm] Remove 'using namespace' from cctest/wasm

This required splitting wasm-run-utils.h in header and implementation,
since the anonymous namespace in wasm-run-utils.h is now gone.
This is a reasonable refactoring in itself.

R=titzer@chromium.org
CC=mstarzinger@chromium.org, mostynb@opera.com

Bug: chromium:746958
Change-Id: I0f3b30fef1865cd88eca37b69d0c3a9eb19e77ea
Reviewed-on: https://chromium-review.googlesource.com/647587Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47773}
parent 5931cc94
......@@ -204,6 +204,7 @@ v8_executable("cctest") {
"wasm/test-wasm-interpreter-entry.cc",
"wasm/test-wasm-stack.cc",
"wasm/test-wasm-trap-position.cc",
"wasm/wasm-run-utils.cc",
"wasm/wasm-run-utils.h",
]
......
......@@ -222,6 +222,7 @@
'wasm/test-wasm-interpreter-entry.cc',
'wasm/test-wasm-stack.cc',
'wasm/test-wasm-trap-position.cc',
'wasm/wasm-run-utils.cc',
'wasm/wasm-run-utils.h',
],
'cctest_sources_ia32': [ ### gcmole(arch:ia32) ###
......
......@@ -332,9 +332,10 @@ class ValueHelper {
// Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... }
// Watch out, these macros aren't hygenic; they pollute your scope. Thanks STL.
#define FOR_INPUTS(ctype, itype, var) \
std::vector<ctype> var##_vec = ValueHelper::itype##_vector(); \
for (std::vector<ctype>::iterator var = var##_vec.begin(); \
#define FOR_INPUTS(ctype, itype, var) \
std::vector<ctype> var##_vec = \
::v8::internal::compiler::ValueHelper::itype##_vector(); \
for (std::vector<ctype>::iterator var = var##_vec.begin(); \
var != var##_vec.end(); ++var)
#define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var)
......@@ -362,10 +363,10 @@ static inline void CheckFloatEq(volatile float x, volatile float y) {
}
}
#define CHECK_FLOAT_EQ(lhs, rhs) \
do { \
volatile float tmp = lhs; \
CheckFloatEq(tmp, rhs); \
#define CHECK_FLOAT_EQ(lhs, rhs) \
do { \
volatile float tmp = lhs; \
::v8::internal::compiler::CheckFloatEq(tmp, rhs); \
} while (0)
static inline void CheckDoubleEq(volatile double x, volatile double y) {
......@@ -377,10 +378,10 @@ static inline void CheckDoubleEq(volatile double x, volatile double y) {
}
}
#define CHECK_DOUBLE_EQ(lhs, rhs) \
do { \
volatile double tmp = lhs; \
CheckDoubleEq(tmp, rhs); \
#define CHECK_DOUBLE_EQ(lhs, rhs) \
do { \
volatile double tmp = lhs; \
::v8::internal::compiler::CheckDoubleEq(tmp, rhs); \
} while (0)
} // namespace compiler
......
......@@ -15,9 +15,9 @@
#include "test/cctest/compiler/c-signature.h"
#include "test/cctest/compiler/call-tester.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
namespace v8 {
namespace internal {
namespace wasm {
#define __ assm.
......@@ -40,8 +40,8 @@ TEST(WasmRelocationArmMemoryReference) {
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
CSignature0<int32_t> csig;
CodeRunner<int32_t> runnable(isolate, code, &csig);
compiler::CSignature0<int32_t> csig;
compiler::CodeRunner<int32_t> runnable(isolate, code, &csig);
int32_t ret_value = runnable.Call();
CHECK_EQ(ret_value, imm);
......@@ -95,8 +95,8 @@ TEST(WasmRelocationArmMemorySizeReference) {
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
CSignature0<int32_t> csig;
CodeRunner<int32_t> runnable(isolate, code, &csig);
compiler::CSignature0<int32_t> csig;
compiler::CodeRunner<int32_t> runnable(isolate, code, &csig);
int32_t ret_value = runnable.Call();
CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef));
......@@ -123,4 +123,9 @@ TEST(WasmRelocationArmMemorySizeReference) {
::printf("f() = %d\n\n", ret_value);
#endif
}
#undef __
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -19,9 +19,9 @@
#include "test/cctest/compiler/c-signature.h"
#include "test/cctest/compiler/call-tester.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
namespace v8 {
namespace internal {
namespace wasm {
#define __ masm.
......@@ -45,8 +45,8 @@ TEST(WasmRelocationArm64MemoryReference) {
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
CSignature0<int64_t> csig;
CodeRunner<int64_t> runnable(isolate, code, &csig);
compiler::CSignature0<int64_t> csig;
compiler::CodeRunner<int64_t> runnable(isolate, code, &csig);
int64_t ret_value = runnable.Call();
CHECK_EQ(ret_value, imm);
......@@ -101,8 +101,8 @@ TEST(WasmRelocationArm64MemorySizeReference) {
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
CSignature0<int64_t> csig;
CodeRunner<int64_t> runnable(isolate, code, &csig);
compiler::CSignature0<int64_t> csig;
compiler::CodeRunner<int64_t> runnable(isolate, code, &csig);
int64_t ret_value = runnable.Call();
CHECK_NE(ret_value, 0xdeadbeef);
......@@ -131,3 +131,7 @@ TEST(WasmRelocationArm64MemorySizeReference) {
}
#undef __
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -16,8 +16,9 @@
#include "test/cctest/compiler/c-signature.h"
#include "test/cctest/compiler/call-tester.h"
using namespace v8::internal;
using namespace v8::internal::compiler;
namespace v8 {
namespace internal {
namespace wasm {
#define __ assm.
......@@ -37,14 +38,14 @@ TEST(WasmRelocationIa32MemoryReference) {
__ nop();
__ ret(0);
CSignature0<int32_t> csig;
compiler::CSignature0<int32_t> csig;
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
USE(code);
CodeRunner<int32_t> runnable(isolate, code, &csig);
compiler::CodeRunner<int32_t> runnable(isolate, code, &csig);
int32_t ret_value = runnable.Call();
CHECK_EQ(ret_value, imm);
......@@ -100,14 +101,14 @@ TEST(WasmRelocationIa32MemorySizeReference) {
__ mov(eax, 0xdeadbeef);
__ ret(0);
CSignature0<int32_t> csig;
compiler::CSignature0<int32_t> csig;
CodeDesc desc;
assm.GetCode(isolate, &desc);
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
USE(code);
CodeRunner<int32_t> runnable(isolate, code, &csig);
compiler::CodeRunner<int32_t> runnable(isolate, code, &csig);
int32_t ret_value = runnable.Call();
CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef));
......@@ -139,4 +140,9 @@ TEST(WasmRelocationIa32MemorySizeReference) {
disasm::Disassembler::Disassemble(stdout, begin, end);
#endif
}
#undef __
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -16,6 +16,10 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {
// If the target architecture is 64-bit, enable all tests.
#if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64
#define WASM_64 1
......@@ -1476,7 +1480,7 @@ WASM_EXEC_TEST(I64Ror) {
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
int64_t expected = bits::RotateRight64(*i, *j & 0x3f);
int64_t expected = base::bits::RotateRight64(*i, *j & 0x3f);
CHECK_EQ(expected, r.Call(*i, *j));
}
}
......@@ -1489,7 +1493,7 @@ WASM_EXEC_TEST(I64Rol) {
FOR_UINT64_INPUTS(i) {
FOR_UINT64_INPUTS(j) {
int64_t expected = bits::RotateLeft64(*i, *j & 0x3f);
int64_t expected = base::bits::RotateLeft64(*i, *j & 0x3f);
CHECK_EQ(expected, r.Call(*i, *j));
}
}
......@@ -1668,3 +1672,11 @@ WASM_EXEC_TEST(Regress5874) {
r.Call();
}
// clang-format gets confused about these closing parentheses (wants to change
// the first comment to "// namespace v8". Disable it.
// clang-format off
} // namespace wasm
} // namespace internal
} // namespace v8
// clang-format on
......@@ -15,10 +15,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
// for even shorter tests.
#define B2(a, b) kExprBlock, a, b, kExprEnd
......@@ -298,3 +297,7 @@ TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
CHECK_NE(0, GetMatchingRelocInfoCount(r.builder().GetFunctionCode(0),
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -7,6 +7,10 @@
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {
#define WASM_ATOMICS_OP(op) kAtomicPrefix, static_cast<byte>(op)
#define WASM_ATOMICS_BINOP(op, x, y) x, y, WASM_ATOMICS_OP(op)
#define WASM_ATOMICS_TERNARY_OP(op, x, y, z) x, y, z, WASM_ATOMICS_OP(op)
......@@ -186,3 +190,7 @@ WASM_EXEC_TEST(I32CompareExchange8U) {
}
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -16,11 +16,6 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
......
......@@ -14,10 +14,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
#define BUILD(r, ...) \
do { \
......@@ -84,7 +83,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc,
CHECK_EQ(expected, Smi::ToInt(*result));
} else {
CHECK(result->IsHeapNumber());
CheckFloatEq(expected, HeapNumber::cast(*result)->value());
CHECK_FLOAT_EQ(expected, HeapNumber::cast(*result)->value());
}
}
......@@ -504,3 +503,7 @@ TEST(Run_JSSelectAlign_10) {
RunJSSelectAlignTest(10, 9);
RunJSSelectAlignTest(10, 10);
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -19,10 +19,9 @@
#include "test/common/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-module-runner.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
namespace {
void Cleanup(Isolate* isolate = nullptr) {
......@@ -1170,3 +1169,7 @@ TEST(Run_WasmModule_Buffer_Externalized_Detach) {
}
Cleanup();
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -12,8 +12,9 @@
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::compiler;
namespace v8 {
namespace internal {
namespace wasm {
#define FOREACH_TYPE(TEST_BODY) \
TEST_BODY(int32_t, WASM_I32_ADD) \
......@@ -60,3 +61,7 @@ using namespace v8::internal::compiler;
}
FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY)
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -8,10 +8,9 @@
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
namespace {
......@@ -2199,3 +2198,7 @@ WASM_SIMD_TEST(SimdLoadStoreLoad) {
}
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET ||
// V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -15,10 +15,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
// for even shorter tests.
#define B1(a) WASM_BLOCK(a)
......@@ -1941,11 +1940,13 @@ static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) {
Zone zone(isolate->allocator(), ZONE_NAME);
HandleScope scope(isolate);
// Enable all optional operators.
CommonOperatorBuilder common(&zone);
MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(),
MachineOperatorBuilder::kAllOptionalOps);
Graph graph(&zone);
JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
compiler::CommonOperatorBuilder common(&zone);
compiler::MachineOperatorBuilder machine(
&zone, MachineType::PointerRepresentation(),
compiler::MachineOperatorBuilder::kAllOptionalOps);
compiler::Graph graph(&zone);
compiler::JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr,
&machine);
FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (sig->parameter_count() == 1) {
......@@ -3091,3 +3092,7 @@ WASM_EXEC_TEST(IfInsideUnreachable) {
WASM_IF_ELSE_I(WASM_ONE, WASM_BRV(0, WASM_ONE), WASM_RETURN1(WASM_ONE)));
CHECK_EQ(17, r.Call());
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -15,9 +15,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::wasm;
namespace debug = v8::debug;
namespace v8 {
namespace internal {
namespace wasm {
namespace {
......@@ -422,3 +422,7 @@ TEST(WasmGetLocalsAndStack) {
Handle<Object> args[]{handle(Smi::FromInt(7), isolate)};
CHECK(!Execution::Call(isolate, main_fun_wrapper, global, 1, args).is_null());
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -12,9 +12,9 @@
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::wasm;
namespace debug = v8::debug;
namespace v8 {
namespace internal {
namespace wasm {
/**
* We test the interface from Wasm compiled code to the Wasm interpreter by
......@@ -257,3 +257,7 @@ TEST(TestArgumentPassing_AllTypes) {
CheckCall(i32, i64, f32, f64);
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -9,10 +9,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
using v8::Local;
using v8::Utils;
......@@ -191,3 +190,7 @@ TEST(CollectDetailedWasmStack_WasmError) {
CheckExceptionInfos(isolate, exception, expected_exceptions);
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -10,10 +10,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::base;
using namespace v8::internal;
using namespace v8::internal::compiler;
using namespace v8::internal::wasm;
namespace v8 {
namespace internal {
namespace wasm {
using v8::Local;
using v8::Utils;
......@@ -141,3 +140,7 @@ TEST(IllegalLoad) {
CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
expected_exceptions);
}
} // namespace wasm
} // namespace internal
} // namespace v8
This diff is collapsed.
This diff is collapsed.
......@@ -19,9 +19,9 @@
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
using namespace v8::internal;
using namespace v8::internal::wasm;
using namespace v8::internal::wasm::testing;
namespace v8 {
namespace internal {
namespace wasm {
#define B1(a) WASM_BLOCK(a)
#define B2(a, b) WASM_BLOCK(a, b)
......@@ -2853,3 +2853,7 @@ TEST_F(BytecodeIteratorTest, WithLocalDecls) {
iter.next();
EXPECT_FALSE(iter.has_next());
}
} // namespace wasm
} // namespace internal
} // namespace v8
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