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/handles.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-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 {
|
|
|
|
namespace wasm {
|
|
|
|
namespace testing {
|
|
|
|
|
|
|
|
// Decodes the given encoded module.
|
|
|
|
const WasmModule* DecodeWasmModuleForTesting(Isolate* isolate, Zone* zone,
|
2016-09-15 16:19:48 +00:00
|
|
|
ErrorThrower* thrower,
|
2016-09-12 12:26:37 +00:00
|
|
|
const byte* module_start,
|
|
|
|
const byte* module_end,
|
|
|
|
ModuleOrigin origin);
|
|
|
|
|
|
|
|
// Instantiates a module without any imports and exports.
|
|
|
|
const Handle<JSObject> InstantiateModuleForTesting(Isolate* isolate,
|
2016-09-15 16:19:48 +00:00
|
|
|
ErrorThrower* thrower,
|
2016-09-12 12:26:37 +00:00
|
|
|
const WasmModule* module);
|
|
|
|
|
|
|
|
int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance,
|
2016-09-15 16:19:48 +00:00
|
|
|
ErrorThrower* thrower, const char* name,
|
2016-09-12 12:26:37 +00:00
|
|
|
int argc, Handle<Object> argv[],
|
2016-09-12 22:11:12 +00:00
|
|
|
ModuleOrigin origin);
|
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,
|
2016-09-12 22:11:12 +00:00
|
|
|
const byte* module_end, ModuleOrigin origin);
|
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
|
2016-09-15 16:19:48 +00:00
|
|
|
int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower,
|
2016-09-12 12:26:37 +00:00
|
|
|
const WasmModule* module, int function_index,
|
|
|
|
WasmVal* args);
|
2016-09-17 01:30:09 +00:00
|
|
|
|
|
|
|
// Install function map, module symbol for testing
|
|
|
|
void SetupIsolateForWasmModule(Isolate* isolate);
|
2016-09-12 12:26:37 +00:00
|
|
|
} // namespace testing
|
|
|
|
} // namespace wasm
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // V8_WASM_MODULE_RUNNER_H_
|