[wasm] Move interpreter to test directory
The interpreter is not used in production code any more, hence move it from src/wasm to test/common/wasm. It's still used in unit tests, cctests, and in fuzzers. Because of this move, a few more methods had to be exported via V8_EXPORT_PRIVATE. R=ahaas@chromium.org, yangguo@chromium.org Bug: v8:10389 Change-Id: If626b940a721146c596fd7df4faaea633e710272 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2257226 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#68480}
This commit is contained in:
parent
aa4e381bda
commit
1d31558f54
14
BUILD.gn
14
BUILD.gn
@ -3197,8 +3197,6 @@ v8_source_set("v8_base_without_compiler") {
|
||||
"src/wasm/wasm-features.h",
|
||||
"src/wasm/wasm-import-wrapper-cache.cc",
|
||||
"src/wasm/wasm-import-wrapper-cache.h",
|
||||
"src/wasm/wasm-interpreter.cc",
|
||||
"src/wasm/wasm-interpreter.h",
|
||||
"src/wasm/wasm-js.cc",
|
||||
"src/wasm/wasm-js.h",
|
||||
"src/wasm/wasm-limits.h",
|
||||
@ -4862,8 +4860,10 @@ v8_source_set("regexp_fuzzer") {
|
||||
v8_fuzzer("regexp_fuzzer") {
|
||||
}
|
||||
|
||||
v8_source_set("wasm_module_runner") {
|
||||
v8_source_set("wasm_test_common") {
|
||||
sources = [
|
||||
"test/common/wasm/wasm-interpreter.cc",
|
||||
"test/common/wasm/wasm-interpreter.h",
|
||||
"test/common/wasm/wasm-module-runner.cc",
|
||||
"test/common/wasm/wasm-module-runner.h",
|
||||
]
|
||||
@ -4888,7 +4888,7 @@ v8_source_set("wasm_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":wasm_module_runner",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
configs = [
|
||||
@ -4906,7 +4906,7 @@ v8_source_set("wasm_async_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":wasm_module_runner",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
configs = [
|
||||
@ -4927,7 +4927,7 @@ v8_source_set("wasm_code_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":wasm_module_runner",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
configs = [
|
||||
@ -4968,7 +4968,7 @@ v8_source_set("wasm_compile_fuzzer") {
|
||||
deps = [
|
||||
":fuzzer_support",
|
||||
":lib_wasm_fuzzer_common",
|
||||
":wasm_module_runner",
|
||||
":wasm_test_common",
|
||||
]
|
||||
|
||||
configs = [
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "src/builtins/accessors.h"
|
||||
#include "src/execution/frames-inl.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -126,19 +126,24 @@ class FutexEmulation : public AllStatic {
|
||||
|
||||
// Same as WaitJs above except it returns 0 (ok), 1 (not equal) and 2 (timed
|
||||
// out) as expected by Wasm.
|
||||
static Object WaitWasm32(Isolate* isolate, Handle<JSArrayBuffer> array_buffer,
|
||||
size_t addr, int32_t value, int64_t rel_timeout_ns);
|
||||
V8_EXPORT_PRIVATE static Object WaitWasm32(Isolate* isolate,
|
||||
Handle<JSArrayBuffer> array_buffer,
|
||||
size_t addr, int32_t value,
|
||||
int64_t rel_timeout_ns);
|
||||
|
||||
// Same as Wait32 above except it checks for an int64_t value in the
|
||||
// array_buffer.
|
||||
static Object WaitWasm64(Isolate* isolate, Handle<JSArrayBuffer> array_buffer,
|
||||
size_t addr, int64_t value, int64_t rel_timeout_ns);
|
||||
V8_EXPORT_PRIVATE static Object WaitWasm64(Isolate* isolate,
|
||||
Handle<JSArrayBuffer> array_buffer,
|
||||
size_t addr, int64_t value,
|
||||
int64_t rel_timeout_ns);
|
||||
|
||||
// Wake |num_waiters_to_wake| threads that are waiting on the given |addr|.
|
||||
// |num_waiters_to_wake| can be kWakeAll, in which case all waiters are
|
||||
// woken. The rest of the waiters will continue to wait. The return value is
|
||||
// the number of woken waiters.
|
||||
static Object Wake(Handle<JSArrayBuffer> array_buffer, size_t addr,
|
||||
V8_EXPORT_PRIVATE static Object Wake(Handle<JSArrayBuffer> array_buffer,
|
||||
size_t addr,
|
||||
uint32_t num_waiters_to_wake);
|
||||
|
||||
// Return the number of threads waiting on |addr|. Should only be used for
|
||||
|
@ -460,8 +460,9 @@ class Heap {
|
||||
|
||||
// Move len non-weak tagged elements from src_slot to dst_slot of dst_object.
|
||||
// The source and destination memory ranges can overlap.
|
||||
void MoveRange(HeapObject dst_object, ObjectSlot dst_slot,
|
||||
ObjectSlot src_slot, int len, WriteBarrierMode mode);
|
||||
V8_EXPORT_PRIVATE void MoveRange(HeapObject dst_object, ObjectSlot dst_slot,
|
||||
ObjectSlot src_slot, int len,
|
||||
WriteBarrierMode mode);
|
||||
|
||||
// Copy len non-weak tagged elements from src_slot to dst_slot of dst_object.
|
||||
// The source and destination memory ranges must not overlap.
|
||||
|
@ -1665,7 +1665,8 @@ class WasmDecoder : public Decoder {
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<uint32_t, uint32_t> StackEffect(const byte* pc) {
|
||||
// TODO(clemensb): This is only used by the interpreter; move there.
|
||||
V8_EXPORT_PRIVATE std::pair<uint32_t, uint32_t> StackEffect(const byte* pc) {
|
||||
WasmOpcode opcode = static_cast<WasmOpcode>(*pc);
|
||||
// Handle "simple" opcodes with a fixed signature first.
|
||||
const FunctionSig* sig = WasmOpcodes::Signature(opcode);
|
||||
|
@ -82,9 +82,10 @@ V8_EXPORT_PRIVATE unsigned OpcodeLength(const byte* pc, const byte* end);
|
||||
// Be cautious with control opcodes: This function only covers their immediate,
|
||||
// local stack effect (e.g. BrIf pops 1, Br pops 0). Those opcodes can have
|
||||
// non-local stack effect though, which are not covered here.
|
||||
std::pair<uint32_t, uint32_t> StackEffect(const WasmModule* module,
|
||||
const FunctionSig* sig,
|
||||
const byte* pc, const byte* end);
|
||||
// TODO(clemensb): This is only used by the interpreter; move there.
|
||||
V8_EXPORT_PRIVATE std::pair<uint32_t, uint32_t> StackEffect(
|
||||
const WasmModule* module, const FunctionSig* sig, const byte* pc,
|
||||
const byte* end);
|
||||
|
||||
// A simple forward iterator for bytecodes.
|
||||
class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
|
||||
|
@ -30,8 +30,10 @@ struct MemoryTracingInfo {
|
||||
|
||||
// Callback for tracing a memory operation for debugging.
|
||||
// Triggered by --wasm-trace-memory.
|
||||
void TraceMemoryOperation(ExecutionTier, const MemoryTracingInfo* info,
|
||||
int func_index, int position, uint8_t* mem_start);
|
||||
V8_EXPORT_PRIVATE void TraceMemoryOperation(ExecutionTier,
|
||||
const MemoryTracingInfo* info,
|
||||
int func_index, int position,
|
||||
uint8_t* mem_start);
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
|
@ -63,7 +63,8 @@ WasmCode* CompileImportWrapper(
|
||||
// Triggered by the WasmCompileLazy builtin. The return value indicates whether
|
||||
// compilation was successful. Lazy compilation can fail only if validation is
|
||||
// also lazy.
|
||||
bool CompileLazy(Isolate*, NativeModule*, int func_index);
|
||||
// TODO(clemensb): Stop calling this from the interpreter, and don't export.
|
||||
V8_EXPORT_PRIVATE bool CompileLazy(Isolate*, NativeModule*, int func_index);
|
||||
|
||||
int GetMaxBackgroundTasks();
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "src/base/macros.h"
|
||||
#include "src/handles/maybe-handles.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "src/wasm/baseline/liftoff-register.h"
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/wasm-code-manager.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-limits.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
|
@ -66,7 +66,7 @@ class Managed;
|
||||
// - object = target instance, if a Wasm function, tuple if imported
|
||||
// - sig_id = signature id of function
|
||||
// - target = entrypoint to Wasm code or import wrapper code
|
||||
class IndirectFunctionTableEntry {
|
||||
class V8_EXPORT_PRIVATE IndirectFunctionTableEntry {
|
||||
public:
|
||||
inline IndirectFunctionTableEntry(Handle<WasmInstanceObject>, int table_index,
|
||||
int entry_index);
|
||||
@ -75,8 +75,7 @@ class IndirectFunctionTableEntry {
|
||||
int entry_index);
|
||||
|
||||
void clear();
|
||||
V8_EXPORT_PRIVATE void Set(int sig_id,
|
||||
Handle<WasmInstanceObject> target_instance,
|
||||
void Set(int sig_id, Handle<WasmInstanceObject> target_instance,
|
||||
int target_func_index);
|
||||
void Set(int sig_id, Address call_target, Object ref);
|
||||
|
||||
@ -366,7 +365,7 @@ class WasmGlobalObject : public JSObject {
|
||||
};
|
||||
|
||||
// Representation of a WebAssembly.Instance JavaScript-level object.
|
||||
class WasmInstanceObject : public JSObject {
|
||||
class V8_EXPORT_PRIVATE WasmInstanceObject : public JSObject {
|
||||
public:
|
||||
DECL_CAST(WasmInstanceObject)
|
||||
|
||||
@ -483,16 +482,15 @@ class WasmInstanceObject : public JSObject {
|
||||
kWasmExternalFunctionsOffset,
|
||||
kManagedObjectMapsOffset};
|
||||
|
||||
V8_EXPORT_PRIVATE const wasm::WasmModule* module();
|
||||
const wasm::WasmModule* module();
|
||||
|
||||
V8_EXPORT_PRIVATE static bool EnsureIndirectFunctionTableWithMinimumSize(
|
||||
static bool EnsureIndirectFunctionTableWithMinimumSize(
|
||||
Handle<WasmInstanceObject> instance, int table_index,
|
||||
uint32_t minimum_size);
|
||||
|
||||
V8_EXPORT_PRIVATE void SetRawMemory(byte* mem_start, size_t mem_size);
|
||||
void SetRawMemory(byte* mem_start, size_t mem_size);
|
||||
|
||||
V8_EXPORT_PRIVATE static Handle<WasmInstanceObject> New(
|
||||
Isolate*, Handle<WasmModuleObject>);
|
||||
static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmModuleObject>);
|
||||
|
||||
Address GetCallTarget(uint32_t func_index);
|
||||
|
||||
@ -526,9 +524,8 @@ class WasmInstanceObject : public JSObject {
|
||||
// cache of the given {instance}, or creates a new {WasmExportedFunction} if
|
||||
// it does not exist yet. The new {WasmExportedFunction} is added to the
|
||||
// cache of the {instance} immediately.
|
||||
V8_EXPORT_PRIVATE static Handle<WasmExternalFunction>
|
||||
GetOrCreateWasmExternalFunction(Isolate* isolate,
|
||||
Handle<WasmInstanceObject> instance,
|
||||
static Handle<WasmExternalFunction> GetOrCreateWasmExternalFunction(
|
||||
Isolate* isolate, Handle<WasmInstanceObject> instance,
|
||||
int function_index);
|
||||
|
||||
static void SetWasmExternalFunction(Isolate* isolate,
|
||||
@ -614,7 +611,7 @@ class WasmExceptionObject : public JSObject {
|
||||
};
|
||||
|
||||
// A Wasm exception that has been thrown out of Wasm code.
|
||||
class WasmExceptionPackage : public JSReceiver {
|
||||
class V8_EXPORT_PRIVATE WasmExceptionPackage : public JSReceiver {
|
||||
public:
|
||||
static Handle<WasmExceptionPackage> New(
|
||||
Isolate* isolate, Handle<WasmExceptionTag> exception_tag,
|
||||
|
@ -406,7 +406,7 @@ v8_source_set("cctest_sources") {
|
||||
"../..:v8_for_testing",
|
||||
"../..:v8_libbase",
|
||||
"../..:v8_libplatform",
|
||||
"../..:wasm_module_runner",
|
||||
"../..:wasm_test_common",
|
||||
"../../tools/debug_helper:v8_debug_helper",
|
||||
"//build/win:default_exe_manifest",
|
||||
]
|
||||
|
@ -9,11 +9,11 @@
|
||||
#include <memory>
|
||||
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/value-helper.h"
|
||||
#include "test/cctest/wasm/wasm-run-utils.h"
|
||||
#include "test/common/wasm/test-signatures.h"
|
||||
#include "test/common/wasm/wasm-interpreter.h"
|
||||
#include "test/common/wasm/wasm-macro-gen.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "src/wasm/wasm-constants.h"
|
||||
#include "src/wasm/wasm-debug-evaluate.h"
|
||||
#include "src/wasm/wasm-debug.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-module-builder.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
@ -27,7 +28,6 @@
|
||||
#include "src/wasm/local-decl-encoder.h"
|
||||
#include "src/wasm/wasm-code-manager.h"
|
||||
#include "src/wasm/wasm-external-refs.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-js.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
@ -36,12 +36,12 @@
|
||||
#include "src/wasm/wasm-tier.h"
|
||||
#include "src/zone/accounting-allocator.h"
|
||||
#include "src/zone/zone.h"
|
||||
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/call-tester.h"
|
||||
#include "test/cctest/compiler/graph-and-builders.h"
|
||||
#include "test/cctest/compiler/value-helper.h"
|
||||
#include "test/common/wasm/flag-utils.h"
|
||||
#include "test/common/wasm/wasm-interpreter.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "test/common/wasm/wasm-interpreter.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <type_traits>
|
||||
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
|
||||
#include "src/base/overflowing-math.h"
|
||||
#include "src/codegen/assembler-inl.h"
|
||||
#include "src/compiler/wasm-compiler.h"
|
@ -42,7 +42,7 @@ struct ControlTransferEntry {
|
||||
using ControlTransferMap = ZoneMap<pc_t, ControlTransferEntry>;
|
||||
|
||||
// An interpreter capable of executing WebAssembly.
|
||||
class V8_EXPORT_PRIVATE WasmInterpreter {
|
||||
class WasmInterpreter {
|
||||
public:
|
||||
// State machine for the interpreter:
|
||||
// +----------------------------------------------------------+
|
@ -11,11 +11,11 @@
|
||||
#include "src/objects/property-descriptor.h"
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-js.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "src/wasm/wasm-result.h"
|
||||
#include "test/common/wasm/wasm-interpreter.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/objects/objects.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "src/wasm/wasm-result.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "src/execution/isolate.h"
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/objects/objects.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-module-builder.h"
|
||||
#include "test/common/wasm/test-signatures.h"
|
||||
#include "test/fuzzer/wasm-fuzzer-common.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "src/objects/objects-inl.h"
|
||||
#include "src/objects/objects.h"
|
||||
#include "src/utils/ostreams.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-module-builder.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-opcodes.h"
|
||||
|
@ -7,11 +7,12 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
#include "src/wasm/wasm-module-builder.h"
|
||||
#include "test/common/wasm/wasm-interpreter.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -392,6 +392,7 @@ v8_source_set("unittests_sources") {
|
||||
"../..:v8_for_testing",
|
||||
"../..:v8_libbase",
|
||||
"../..:v8_libplatform",
|
||||
"../..:wasm_test_common",
|
||||
"../../third_party/inspector_protocol:crdtp_test",
|
||||
"//build/win:default_exe_manifest",
|
||||
"//testing/gmock",
|
||||
|
@ -2,14 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/init/v8.h"
|
||||
#include "test/common/wasm/wasm-interpreter.h"
|
||||
#include "test/common/wasm/wasm-macro-gen.h"
|
||||
#include "test/unittests/test-utils.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
|
||||
#include "src/init/v8.h"
|
||||
#include "src/wasm/wasm-interpreter.h"
|
||||
|
||||
#include "test/common/wasm/wasm-macro-gen.h"
|
||||
|
||||
using testing::MakeMatcher;
|
||||
using testing::Matcher;
|
||||
using testing::MatcherInterface;
|
||||
|
Loading…
Reference in New Issue
Block a user