Commit e48b5c6d authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][memory64] Fix Liftoff on 32-bit and add cctest

This adds a first execution test for memory64 in the form of a cctest.
Several things are still not working correctly, hence this test only
checks TurboFan on 64-bit systems, and Liftoff.

Bounds checks in Liftoff are fixed to work correctly on 32-bit.
Follow-up CLs will extend the test to also test TurboFan on 32-bit, the
interpreter, and traps. All of those features still have issues.

R=manoskouk@chromium.org

Bug: v8:10949
Change-Id: Ic7edcf3783421634fe2ec99eac6f257c557a29b5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2610968Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72014}
parent d5d45c61
This diff is collapsed.
......@@ -307,6 +307,7 @@ v8_source_set("cctest_sources") {
"wasm/test-run-wasm-exceptions.cc",
"wasm/test-run-wasm-interpreter.cc",
"wasm/test-run-wasm-js.cc",
"wasm/test-run-wasm-memory64.cc",
"wasm/test-run-wasm-module.cc",
"wasm/test-run-wasm-sign-extension.cc",
"wasm/test-run-wasm-simd-liftoff.cc",
......
......@@ -491,21 +491,7 @@
'test-gc/*': [SKIP],
'test-grow-memory/*': [SKIP],
'test-liftoff-inspection/*': [SKIP],
'test-run-wasm-64/*': [SKIP],
'test-run-wasm-asmjs/*': [SKIP],
'test-run-wasm-atomics64/*': [SKIP],
'test-run-wasm-atomics/*': [SKIP],
'test-run-wasm-bulk-memory/*': [SKIP],
'test-run-wasm/*': [SKIP],
'test-run-wasm-exceptions/*': [SKIP],
'test-run-wasm-interpreter/*': [SKIP],
'test-run-wasm-js/*': [SKIP],
'test-run-wasm-module/*': [SKIP],
'test-run-wasm-sign-extension/*': [SKIP],
'test-run-wasm-simd-liftoff/*': [SKIP],
'test-run-wasm-simd-scalar-lowering/*': [SKIP],
'test-run-wasm-simd/*': [SKIP],
'test-run-wasm-wrappers/*': [SKIP],
'test-run-wasm*': [SKIP],
'test-streaming-compilation/*': [SKIP],
'test-wasm-breakpoints/*': [SKIP],
'test-wasm-codegen/*': [SKIP],
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/wasm/wasm-opcodes-inl.h"
#include "test/cctest/cctest.h"
#include "test/cctest/wasm/wasm-run-utils.h"
#include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h"
namespace v8 {
namespace internal {
namespace wasm {
template <typename ReturnType, typename... ParamTypes>
class Memory64Runner : public WasmRunner<ReturnType, ParamTypes...> {
public:
explicit Memory64Runner(TestExecutionTier execution_tier)
: WasmRunner<ReturnType, ParamTypes...>(execution_tier) {
this->builder().EnableFeature(kFeature_memory64);
this->builder().SetMemory64();
}
};
WASM_EXEC_TEST(Load) {
// TODO(clemensb): Implement memory64 in the interpreter.
if (execution_tier == TestExecutionTier::kInterpreter) return;
// TODO(clemensb): Fix memory64 in Turbofan on 32-bit systems.
if (execution_tier == TestExecutionTier::kTurbofan &&
kSystemPointerSize == 4) {
return;
}
Memory64Runner<uint32_t, uint64_t> r(execution_tier);
uint32_t* memory =
r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_LOCAL_GET(0)));
CHECK_EQ(0, r.Call(0));
memory[0] = 0x12345678;
CHECK_EQ(0x12345678, r.Call(0));
CHECK_EQ(0x123456, r.Call(1));
CHECK_EQ(0x1234, r.Call(2));
CHECK_EQ(0x12, r.Call(3));
CHECK_EQ(0x0, r.Call(4));
// TODO(clemensb): Check traps.
}
// TODO(clemensb): Test atomic instructions.
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -187,6 +187,8 @@ class TestingModuleBuilder {
void SetHasSharedMemory() { test_module_->has_shared_memory = true; }
void SetMemory64() { test_module_->is_memory64 = true; }
enum FunctionType { kImport, kWasm };
uint32_t AddFunction(const FunctionSig* sig, const char* name,
FunctionType type);
......@@ -254,6 +256,8 @@ class TestingModuleBuilder {
return runtime_exception_support_;
}
void EnableFeature(WasmFeature feature) { enabled_features_.Add(feature); }
private:
std::shared_ptr<WasmModule> test_module_;
Isolate* isolate_;
......
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