Commit fa9c25ce authored by titzer's avatar titzer Committed by Commit bot

[wasm] Move all heap-allocated WASM structures into wasm-objects.h.

This CL moves all heap-allocated WASM data structures, both ones
that are bonafide JSObjects and ones that are FixedArrays only, into a
consistent place with consistent layout. Note that not all accessors are complete, and I haven't fully spread the new static typing goodness
to all places in the code.

R=ahaas@chromium.org,rossberg@chromium.org
CC=gdeepti@chromium.org,mtrofin@chromium.org,clemensh@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2490663002
Cr-Commit-Position: refs/heads/master@{#40913}
parent fc97c638
......@@ -1723,7 +1723,6 @@ v8_source_set("v8_base") {
"src/wasm/signature-map.cc",
"src/wasm/signature-map.h",
"src/wasm/wasm-debug.cc",
"src/wasm/wasm-debug.h",
"src/wasm/wasm-external-refs.cc",
"src/wasm/wasm-external-refs.h",
"src/wasm/wasm-interpreter.cc",
......@@ -1735,6 +1734,8 @@ v8_source_set("v8_base") {
"src/wasm/wasm-module-builder.h",
"src/wasm/wasm-module.cc",
"src/wasm/wasm-module.h",
"src/wasm/wasm-objects.cc",
"src/wasm/wasm-objects.h",
"src/wasm/wasm-opcodes.cc",
"src/wasm/wasm-opcodes.h",
"src/wasm/wasm-result.cc",
......
......@@ -73,6 +73,7 @@
#include "src/version.h"
#include "src/vm-state-inl.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-result.h"
namespace v8 {
......@@ -7237,8 +7238,8 @@ MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target,
Local<String> WasmCompiledModule::GetWasmWireBytes() {
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
i::Handle<i::wasm::WasmCompiledModule> compiled_part =
i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0)));
i::Handle<i::WasmCompiledModule> compiled_part =
i::handle(i::WasmCompiledModule::cast(obj->GetInternalField(0)));
i::Handle<i::String> wire_bytes = compiled_part->module_bytes();
return Local<String>::Cast(Utils::ToLocal(wire_bytes));
}
......@@ -7246,8 +7247,8 @@ Local<String> WasmCompiledModule::GetWasmWireBytes() {
WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() {
i::Handle<i::JSObject> obj =
i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
i::Handle<i::wasm::WasmCompiledModule> compiled_part =
i::handle(i::wasm::WasmCompiledModule::cast(obj->GetInternalField(0)));
i::Handle<i::WasmCompiledModule> compiled_part =
i::handle(i::WasmCompiledModule::cast(obj->GetInternalField(0)));
std::unique_ptr<i::ScriptData> script_data =
i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(),
......@@ -7273,11 +7274,11 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
if (!maybe_compiled_part.ToHandle(&compiled_part)) {
return MaybeLocal<WasmCompiledModule>();
}
i::Handle<i::wasm::WasmCompiledModule> compiled_module =
handle(i::wasm::WasmCompiledModule::cast(*compiled_part));
i::Handle<i::WasmCompiledModule> compiled_module =
handle(i::WasmCompiledModule::cast(*compiled_part));
return Local<WasmCompiledModule>::Cast(
Utils::ToLocal(i::wasm::CreateWasmModuleObject(
i_isolate, compiled_module, i::wasm::ModuleOrigin::kWasmOrigin)));
Utils::ToLocal(i::Handle<i::JSObject>::cast(
i::WasmModuleObject::New(i_isolate, compiled_module))));
}
MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
......
......@@ -20,6 +20,7 @@
#include "src/wasm/wasm-js.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-result.h"
typedef uint8_t byte;
......
......@@ -27,7 +27,6 @@
#include "src/log.h"
#include "src/messages.h"
#include "src/snapshot/natives.h"
#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-module.h"
#include "include/v8-debug.h"
......
......@@ -15,8 +15,8 @@
#include "src/safepoint-table.h"
#include "src/string-stream.h"
#include "src/vm-state-inl.h"
#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
namespace v8 {
namespace internal {
......@@ -1520,8 +1520,8 @@ Script* WasmFrame::script() const {
if (wasm::WasmIsAsmJs(*instance, isolate())) {
return *wasm::GetAsmWasmScript(instance);
}
Handle<wasm::WasmDebugInfo> debug_info = wasm::GetDebugInfo(instance);
return wasm::WasmDebugInfo::GetFunctionScript(debug_info, function_index());
Handle<WasmDebugInfo> debug_info = wasm::GetDebugInfo(instance);
return WasmDebugInfo::GetFunctionScript(debug_info, function_index());
}
int WasmFrame::position() const {
......
......@@ -16,8 +16,8 @@
#include "src/interpreter/interpreter.h"
#include "src/isolate-inl.h"
#include "src/runtime/runtime.h"
#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
namespace v8 {
namespace internal {
......@@ -1906,9 +1906,9 @@ RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) {
CHECK(script_val->value()->IsScript());
Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
Handle<wasm::WasmDebugInfo> debug_info =
Handle<WasmDebugInfo> debug_info =
wasm::GetDebugInfo(handle(script->wasm_instance(), isolate));
Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable(
Handle<FixedArray> elements = WasmDebugInfo::GetFunctionOffsetTable(
debug_info, script->wasm_function_index());
return *isolate->factory()->NewJSArrayWithElements(elements);
}
......@@ -1922,10 +1922,10 @@ RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) {
CHECK(script_val->value()->IsScript());
Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
Handle<wasm::WasmDebugInfo> debug_info =
Handle<WasmDebugInfo> debug_info =
wasm::GetDebugInfo(handle(script->wasm_instance(), isolate));
return *wasm::WasmDebugInfo::DisassembleFunction(
debug_info, script->wasm_function_index());
return *WasmDebugInfo::DisassembleFunction(debug_info,
script->wasm_function_index());
}
} // namespace internal
......
......@@ -17,6 +17,7 @@
#include "src/snapshot/code-serializer.h"
#include "src/snapshot/natives.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
namespace v8 {
namespace internal {
......@@ -783,9 +784,8 @@ RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) {
if (!maybe_compiled_module.ToHandle(&compiled_module)) {
return isolate->heap()->undefined_value();
}
return *wasm::CreateWasmModuleObject(
isolate, Handle<wasm::WasmCompiledModule>::cast(compiled_module),
wasm::kWasmOrigin);
return *WasmModuleObject::New(
isolate, Handle<WasmCompiledModule>::cast(compiled_module));
}
RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) {
......
......@@ -13,6 +13,7 @@
#include "src/snapshot/snapshot.h"
#include "src/version.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
namespace v8 {
namespace internal {
......@@ -219,8 +220,8 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
Isolate* isolate, Handle<FixedArray> input) {
Handle<wasm::WasmCompiledModule> compiled_module =
Handle<wasm::WasmCompiledModule>::cast(input);
Handle<WasmCompiledModule> compiled_module =
Handle<WasmCompiledModule>::cast(input);
WasmCompiledModuleSerializer wasm_cs(isolate, 0);
wasm_cs.reference_map()->AddAttachedReference(*isolate->native_context());
wasm_cs.reference_map()->AddAttachedReference(
......@@ -261,10 +262,10 @@ MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
MaybeHandle<HeapObject> obj = deserializer.DeserializeObject(isolate);
if (obj.is_null() || !obj.ToHandleChecked()->IsFixedArray()) return nothing;
Handle<wasm::WasmCompiledModule> compiled_module =
Handle<wasm::WasmCompiledModule>::cast(obj.ToHandleChecked());
Handle<WasmCompiledModule> compiled_module =
Handle<WasmCompiledModule>::cast(obj.ToHandleChecked());
wasm::WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module);
WasmCompiledModule::RecreateModuleWrapper(isolate, compiled_module);
return compiled_module;
}
......
......@@ -1263,7 +1263,6 @@
'wasm/signature-map.cc',
'wasm/signature-map.h',
'wasm/wasm-debug.cc',
'wasm/wasm-debug.h',
'wasm/wasm-external-refs.cc',
'wasm/wasm-external-refs.h',
'wasm/wasm-js.cc',
......@@ -1275,6 +1274,8 @@
'wasm/wasm-module-builder.h',
'wasm/wasm-interpreter.cc',
'wasm/wasm-interpreter.h',
'wasm/wasm-objects.cc',
'wasm/wasm-objects.h',
'wasm/wasm-opcodes.cc',
'wasm/wasm-opcodes.h',
'wasm/wasm-result.cc',
......
......@@ -17,6 +17,7 @@
#include "src/snapshot/code-serializer.h"
#include "src/transitions.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-result.h"
namespace v8 {
......@@ -739,8 +740,8 @@ Maybe<bool> ValueSerializer::WriteJSArrayBufferView(JSArrayBufferView* view) {
}
Maybe<bool> ValueSerializer::WriteWasmModule(Handle<JSObject> object) {
Handle<wasm::WasmCompiledModule> compiled_part(
wasm::WasmCompiledModule::cast(object->GetInternalField(0)), isolate_);
Handle<WasmCompiledModule> compiled_part(
WasmCompiledModule::cast(object->GetInternalField(0)), isolate_);
WasmEncodingTag encoding_tag = WasmEncodingTag::kRawBytes;
WriteTag(SerializationTag::kWasmModule);
WriteRawBytes(&encoding_tag, sizeof(encoding_tag));
......@@ -1508,9 +1509,8 @@ MaybeHandle<JSObject> ValueDeserializer::ReadWasmModule() {
if (WasmCompiledModuleSerializer::DeserializeWasmModule(
isolate_, &script_data, wire_bytes)
.ToHandle(&compiled_part)) {
return wasm::CreateWasmModuleObject(
isolate_, Handle<wasm::WasmCompiledModule>::cast(compiled_part),
wasm::ModuleOrigin::kWasmOrigin);
return WasmModuleObject::New(
isolate_, Handle<WasmCompiledModule>::cast(compiled_part));
}
// If that fails, recompile.
......
......@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/wasm/wasm-debug.h"
#include "src/assert-scope.h"
#include "src/debug/debug.h"
#include "src/factory.h"
#include "src/isolate.h"
#include "src/wasm/module-decoder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
using namespace v8::internal;
using namespace v8::internal::wasm;
......
// 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_DEBUG_H_
#define V8_WASM_DEBUG_H_
#include "src/handles.h"
#include "src/objects.h"
namespace v8 {
namespace internal {
namespace wasm {
class WasmDebugInfo : public FixedArray {
public:
static Handle<WasmDebugInfo> New(Handle<JSObject> wasm);
static bool IsDebugInfo(Object* object);
static WasmDebugInfo* cast(Object* object);
JSObject* wasm_instance();
bool SetBreakPoint(int byte_offset);
// Get the Script for the specified function.
static Script* GetFunctionScript(Handle<WasmDebugInfo> debug_info,
int func_index);
// Disassemble the specified function from this module.
static Handle<String> DisassembleFunction(Handle<WasmDebugInfo> debug_info,
int func_index);
// Get the offset table for the specified function, mapping from byte offsets
// to position in the disassembly.
// Returns an array with three entries per instruction: byte offset, line and
// column.
static Handle<FixedArray> GetFunctionOffsetTable(
Handle<WasmDebugInfo> debug_info, int func_index);
// Get the asm.js source position from a byte offset.
// Must only be called if the associated wasm object was created from asm.js.
static int GetAsmJsSourcePosition(Handle<WasmDebugInfo> debug_info,
int func_index, int byte_offset);
};
} // namespace wasm
} // namespace internal
} // namespace v8
#endif // V8_WASM_DEBUG_H_
This diff is collapsed.
......@@ -25,37 +25,10 @@ class WasmJs {
Handle<Context> context);
// WebAssembly.Table.
static Handle<JSObject> CreateWasmTableObject(
Isolate* isolate, uint32_t initial, bool has_maximum, uint32_t maximum,
Handle<FixedArray>* js_functions);
static bool IsWasmTableObject(Isolate* isolate, Handle<Object> value);
static Handle<FixedArray> GetWasmTableFunctions(Isolate* isolate,
Handle<JSObject> object);
static Handle<FixedArray> AddWasmTableDispatchTable(
Isolate* isolate, Handle<JSObject> table_obj, Handle<JSObject> instance,
int table_index, Handle<FixedArray> dispatch_table);
// WebAssembly.Memory
static Handle<JSObject> CreateWasmMemoryObject(Isolate* isolate,
Handle<JSArrayBuffer> buffer,
bool has_maximum, int maximum);
static bool IsWasmMemoryObject(Isolate* isolate, Handle<Object> value);
static Handle<JSArrayBuffer> GetWasmMemoryArrayBuffer(Isolate* isolate,
Handle<Object> value);
static void SetWasmMemoryArrayBuffer(Isolate* isolate, Handle<Object> value,
Handle<JSArrayBuffer> buffer);
static uint32_t GetWasmMemoryMaximumSize(Isolate* isolate,
Handle<Object> value);
static void SetWasmMemoryInstance(Isolate* isolate, Handle<Object> value,
Handle<JSObject> instance);
};
} // namespace internal
......
This diff is collapsed.
......@@ -19,6 +19,10 @@
namespace v8 {
namespace internal {
class WasmCompiledModule;
class WasmDebugInfo;
class WasmModuleObject;
namespace compiler {
class CallDescriptor;
class WasmCompilationUnit;
......@@ -58,8 +62,6 @@ inline bool IsValidSectionCode(uint8_t byte) {
const char* SectionName(WasmSectionCode code);
class WasmDebugInfo;
// Constants for fixed-size elements within a module.
static const uint32_t kMaxReturnCount = 1;
static const uint8_t kResizableMaximumFlag = 1;
......@@ -170,8 +172,6 @@ struct WasmExport {
enum ModuleOrigin { kWasmOrigin, kAsmJsOrigin };
class WasmCompiledModule;
// Static representation of a module.
struct V8_EXPORT_PRIVATE WasmModule {
static const uint32_t kPageSize = 0x10000; // Page size, 64kb.
......@@ -353,125 +353,6 @@ std::ostream& operator<<(std::ostream& os, const WasmModule& module);
std::ostream& operator<<(std::ostream& os, const WasmFunction& function);
std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name);
class WasmCompiledModule : public FixedArray {
public:
static WasmCompiledModule* cast(Object* fixed_array) {
SLOW_DCHECK(IsWasmCompiledModule(fixed_array));
return reinterpret_cast<WasmCompiledModule*>(fixed_array);
}
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID) \
Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \
\
MaybeHandle<TYPE> maybe_##NAME() const { \
if (has_##NAME()) return NAME(); \
return MaybeHandle<TYPE>(); \
} \
\
TYPE* ptr_to_##NAME() const { \
Object* obj = get(ID); \
if (!obj->Is##TYPE()) return nullptr; \
return TYPE::cast(obj); \
} \
\
void set_##NAME(Handle<TYPE> value) { set_ptr_to_##NAME(*value); } \
\
void set_ptr_to_##NAME(TYPE* value) { set(ID, value); } \
\
bool has_##NAME() const { return get(ID)->Is##TYPE(); } \
\
void reset_##NAME() { set_undefined(ID); }
#define WCM_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME)
#define WCM_SMALL_NUMBER(TYPE, NAME) \
TYPE NAME() const { \
return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \
} \
void set_##NAME(TYPE value) { set(kID_##NAME, Smi::FromInt(value)); }
#define WCM_WEAK_LINK(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME); \
\
Handle<TYPE> NAME() const { \
return handle(TYPE::cast(weak_##NAME()->value())); \
}
#define CORE_WCM_PROPERTY_TABLE(MACRO) \
MACRO(OBJECT, FixedArray, code_table) \
MACRO(OBJECT, Foreign, module_wrapper) \
MACRO(OBJECT, SeqOneByteString, module_bytes) \
MACRO(OBJECT, Script, asm_js_script) \
MACRO(OBJECT, FixedArray, function_tables) \
MACRO(OBJECT, FixedArray, empty_function_tables) \
MACRO(OBJECT, ByteArray, asm_js_offset_tables) \
MACRO(OBJECT, JSArrayBuffer, memory) \
MACRO(SMALL_NUMBER, uint32_t, min_mem_pages) \
MACRO(SMALL_NUMBER, uint32_t, max_mem_pages) \
MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \
MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \
MACRO(WEAK_LINK, JSObject, owning_instance) \
MACRO(WEAK_LINK, JSObject, wasm_module)
#if DEBUG
#define DEBUG_ONLY_TABLE(MACRO) MACRO(SMALL_NUMBER, uint32_t, instance_id)
#else
#define DEBUG_ONLY_TABLE(IGNORE)
uint32_t instance_id() const { return -1; }
#endif
#define WCM_PROPERTY_TABLE(MACRO) \
CORE_WCM_PROPERTY_TABLE(MACRO) \
DEBUG_ONLY_TABLE(MACRO)
private:
enum PropertyIndices {
#define INDICES(IGNORE1, IGNORE2, NAME) kID_##NAME,
WCM_PROPERTY_TABLE(INDICES) Count
#undef INDICES
};
public:
static Handle<WasmCompiledModule> New(
Isolate* isolate, Handle<Managed<WasmModule>> module_wrapper);
static Handle<WasmCompiledModule> Clone(Isolate* isolate,
Handle<WasmCompiledModule> module) {
Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast(
isolate->factory()->CopyFixedArray(module));
ret->InitId();
ret->reset_weak_owning_instance();
ret->reset_weak_next_instance();
ret->reset_weak_prev_instance();
return ret;
}
uint32_t mem_size() const {
return has_memory() ? memory()->byte_length()->Number()
: default_mem_size();
}
uint32_t default_mem_size() const {
return min_mem_pages() * WasmModule::kPageSize;
}
#define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
WCM_PROPERTY_TABLE(DECLARATION)
#undef DECLARATION
static bool IsWasmCompiledModule(Object* obj);
void PrintInstancesChain();
static void RecreateModuleWrapper(Isolate* isolate,
Handle<FixedArray> compiled_module);
private:
void InitId();
DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule);
};
// Extract a function name from the given wasm object.
// Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a
// valid UTF-8 string.
......@@ -522,21 +403,7 @@ Handle<Script> GetAsmWasmScript(Handle<JSObject> instance);
int GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index,
int byte_offset);
// Constructs a single function table as a FixedArray of double size,
// populating it with function signature indices and function indices.
Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index,
const WasmModule* module);
// Populates a function table by replacing function indices with handles to
// the compiled code.
void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size,
const std::vector<Handle<Code>>* code_table);
Handle<JSObject> CreateWasmModuleObject(
Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
ModuleOrigin origin);
V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes(
V8_EXPORT_PRIVATE MaybeHandle<WasmModuleObject> CreateModuleObjectFromBytes(
Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower,
ModuleOrigin origin, Handle<Script> asm_js_script,
const byte* asm_offset_tables_start, const byte* asm_offset_tables_end);
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,6 +11,7 @@
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes.h"
#include "test/cctest/cctest.h"
......@@ -317,9 +318,8 @@ class WasmSerializationTest {
decoding_result.val->CompileFunctions(serialization_isolate,
module_wrapper, &thrower);
CHECK(!compiled_module.is_null());
Handle<JSObject> module_obj = CreateWasmModuleObject(
serialization_isolate, compiled_module.ToHandleChecked(),
ModuleOrigin::kWasmOrigin);
Handle<JSObject> module_obj = WasmModuleObject::New(
serialization_isolate, compiled_module.ToHandleChecked());
v8::Local<v8::Object> v8_module_obj = v8::Utils::ToLocal(module_obj);
CHECK(v8_module_obj->IsWebAssemblyCompiledModule());
......
......@@ -25,6 +25,7 @@
#include "src/wasm/wasm-js.h"
#include "src/wasm/wasm-macro-gen.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/zone/zone.h"
......@@ -206,14 +207,15 @@ class TestingModule : public ModuleEnv {
Handle<JSFunction> WrapCode(uint32_t index) {
// Wrap the code so it can be called as a JS function.
Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main");
Handle<JSObject> module_object = Handle<JSObject>(0, isolate_);
Handle<WasmInstanceObject> instance_obj(0, isolate_);
Handle<Code> code = instance->function_code[index];
WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context());
Handle<Code> ret_code =
compiler::CompileJSToWasmWrapper(isolate_, this, code, index);
Handle<JSFunction> ret = WrapExportCodeAsJSFunction(
isolate_, ret_code, name, this->module->functions[index].sig,
static_cast<int>(index), module_object);
Handle<JSFunction> ret = WasmExportedFunction::New(
isolate_, instance_obj, name, ret_code,
static_cast<int>(this->module->functions[index].sig->parameter_count()),
static_cast<int>(index));
return ret;
}
......
......@@ -12,6 +12,7 @@
#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"
namespace v8 {
......@@ -60,7 +61,7 @@ const Handle<JSObject> InstantiateModuleForTesting(Isolate* isolate,
// Although we decoded the module for some pre-validation, run the bytes
// again through the normal pipeline.
// TODO(wasm): Use {module} instead of decoding the module bytes again.
MaybeHandle<JSObject> module_object = CreateModuleObjectFromBytes(
MaybeHandle<WasmModuleObject> module_object = CreateModuleObjectFromBytes(
isolate, module->module_start, module->module_end, thrower,
ModuleOrigin::kWasmOrigin, Handle<Script>::null(), nullptr, nullptr);
if (module_object.is_null()) {
......
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