1d0a582440
This CL removes unnecessary code duplication in the fuzzer code. Instead of having special testing functions to compile and instantiate a WebAssembly module, we now just call SyncCompile and SyncInstantiate. This also fixed a problem when the fuzzer generated a GrowMemory instruction. BUG=v8:6474 R=clemensh@chromium.org Change-Id: I5f2f23349b5866ea67be20a0826271791e1a013e Reviewed-on: https://chromium-review.googlesource.com/529210 Commit-Queue: Andreas Haas <ahaas@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#45851}
71 lines
2.7 KiB
C++
71 lines
2.7 KiB
C++
// Copyright 2016 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.
|
|
|
|
#ifndef V8_WASM_MODULE_RUNNER_H_
|
|
#define V8_WASM_MODULE_RUNNER_H_
|
|
|
|
#include "src/isolate.h"
|
|
#include "src/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"
|
|
#include "src/zone/zone.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
template <typename T>
|
|
class Handle;
|
|
|
|
namespace wasm {
|
|
namespace testing {
|
|
|
|
// Decodes the given encoded module.
|
|
std::unique_ptr<WasmModule> DecodeWasmModuleForTesting(
|
|
Isolate* isolate, ErrorThrower* thrower, const byte* module_start,
|
|
const byte* module_end, ModuleOrigin origin, bool verify_functions = false);
|
|
|
|
// Instantiates a module without any imports and exports.
|
|
const Handle<WasmInstanceObject> InstantiateModuleForTesting(
|
|
Isolate* isolate, ErrorThrower* thrower, const WasmModule* module,
|
|
const ModuleWireBytes& wire_bytes);
|
|
|
|
int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance,
|
|
ErrorThrower* thrower, const char* name,
|
|
int argc, Handle<Object> argv[],
|
|
ModuleOrigin origin);
|
|
|
|
// Decode, verify, and run the function labeled "main" in the
|
|
// given encoded module. The module should have no imports.
|
|
int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
|
|
const byte* module_end, ModuleOrigin origin);
|
|
|
|
// Interprets the given module, starting at the function specified by
|
|
// {function_index}. The return type of the function has to be int32. The module
|
|
// should not have any imports or exports
|
|
int32_t InterpretWasmModule(Isolate* isolate,
|
|
Handle<WasmInstanceObject> instance,
|
|
ErrorThrower* thrower, int32_t function_index,
|
|
WasmVal* args, bool* possible_nondeterminism);
|
|
|
|
// Compiles WasmModule bytes and return an instance of the compiled module.
|
|
const Handle<WasmInstanceObject> CompileInstantiateWasmModuleForTesting(
|
|
Isolate* isolate, ErrorThrower* thrower, const byte* module_start,
|
|
const byte* module_end, ModuleOrigin origin);
|
|
|
|
// Runs the module instance with arguments.
|
|
int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance,
|
|
int argc, Handle<Object> argv[],
|
|
ModuleOrigin origin);
|
|
// Install function map, module symbol for testing
|
|
void SetupIsolateForWasmModule(Isolate* isolate);
|
|
|
|
} // namespace testing
|
|
} // namespace wasm
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif // V8_WASM_MODULE_RUNNER_H_
|