2016-09-12 12:26:37 +00:00
|
|
|
// 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"
|
2016-11-16 16:17:22 +00:00
|
|
|
#include "src/wasm/wasm-objects.h"
|
2016-09-12 12:26:37 +00:00
|
|
|
#include "src/wasm/wasm-result.h"
|
2016-09-20 16:07:25 +00:00
|
|
|
#include "src/zone/zone.h"
|
2016-09-12 12:26:37 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2017-01-27 13:53:13 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
class Handle;
|
|
|
|
|
2016-09-12 12:26:37 +00:00
|
|
|
namespace wasm {
|
|
|
|
namespace testing {
|
|
|
|
|
|
|
|
// Decodes the given encoded module.
|
2017-05-08 12:45:20 +00:00
|
|
|
std::unique_ptr<WasmModule> DecodeWasmModuleForTesting(
|
2016-11-14 19:45:16 +00:00
|
|
|
Isolate* isolate, ErrorThrower* thrower, const byte* module_start,
|
|
|
|
const byte* module_end, ModuleOrigin origin, bool verify_functions = false);
|
2016-09-12 12:26:37 +00:00
|
|
|
|
|
|
|
int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance,
|
2016-09-15 16:19:48 +00:00
|
|
|
ErrorThrower* thrower, const char* name,
|
2017-06-21 09:24:03 +00:00
|
|
|
int argc, Handle<Object> argv[]);
|
2016-09-12 12:26:37 +00:00
|
|
|
|
|
|
|
// 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,
|
2017-06-09 18:37:54 +00:00
|
|
|
const byte* module_end);
|
|
|
|
|
2016-09-12 12:26:37 +00:00
|
|
|
// 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
|
2017-06-12 11:13:15 +00:00
|
|
|
int32_t InterpretWasmModule(Isolate* isolate,
|
|
|
|
Handle<WasmInstanceObject> instance,
|
|
|
|
ErrorThrower* thrower, int32_t function_index,
|
|
|
|
WasmVal* args, bool* possible_nondeterminism);
|
2016-09-17 01:30:09 +00:00
|
|
|
|
2016-09-28 20:55:42 +00:00
|
|
|
// Runs the module instance with arguments.
|
|
|
|
int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance,
|
2017-06-21 09:24:03 +00:00
|
|
|
int argc, Handle<Object> argv[]);
|
2017-06-12 12:31:07 +00:00
|
|
|
|
2016-09-17 01:30:09 +00:00
|
|
|
// Install function map, module symbol for testing
|
|
|
|
void SetupIsolateForWasmModule(Isolate* isolate);
|
2017-06-12 11:13:15 +00:00
|
|
|
|
2016-09-12 12:26:37 +00:00
|
|
|
} // namespace testing
|
|
|
|
} // namespace wasm
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // V8_WASM_MODULE_RUNNER_H_
|