Commit f6ed92d6 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Turn {WasmCompiledModule} into a proper {Struct}.

This makes sure that the object can be identified by a unique instance
type and hence is not accidentally confused with other FixedArrays on
the heap.

R=clemensh@chromium.org
BUG=v8:7509

Change-Id: I20521cdcabbbddecd89ca8cd4bb203a47e1db0cd
Reviewed-on: https://chromium-review.googlesource.com/946253Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51730}
parent 44bed6a8
......@@ -308,6 +308,7 @@ Type::bitset BitsetType::Lub(i::Map* map) {
case PROTOTYPE_INFO_TYPE:
case TUPLE2_TYPE:
case TUPLE3_TYPE:
case WASM_COMPILED_MODULE_TYPE:
case WASM_DEBUG_INFO_TYPE:
case WASM_SHARED_MODULE_DATA_TYPE:
case LOAD_HANDLER_TYPE:
......
......@@ -32,7 +32,7 @@
#include "src/unicode-inl.h"
#include "src/vm-state-inl.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/utils.h"
#include "src/version.h"
......@@ -1661,7 +1661,7 @@ static int EnumerateWasmModules(Heap* heap,
for (HeapObject* obj = iterator.next(); obj != nullptr;
obj = iterator.next()) {
if (WasmCompiledModule::IsWasmCompiledModule(obj)) {
if (obj->IsWasmCompiledModule()) {
WasmCompiledModule* module = WasmCompiledModule::cast(obj);
if (modules != nullptr) {
modules[wasm_modules_count] = Handle<WasmCompiledModule>(module);
......
......@@ -1430,6 +1430,27 @@ void Tuple3::Tuple3Verify() {
VerifyObjectField(kValue3Offset);
}
void WasmCompiledModule::WasmCompiledModuleVerify() {
CHECK(IsWasmCompiledModule());
VerifyObjectField(ksharedOffset);
VerifyObjectField(knative_contextOffset);
VerifyObjectField(kexport_wrappersOffset);
VerifyObjectField(kweak_exported_functionsOffset);
VerifyObjectField(knext_instanceOffset);
VerifyObjectField(kprev_instanceOffset);
VerifyObjectField(kowning_instanceOffset);
VerifyObjectField(kwasm_moduleOffset);
VerifyObjectField(ksource_positionsOffset);
VerifyObjectField(knative_moduleOffset);
VerifyObjectField(klazy_compile_dataOffset);
VerifyObjectField(kuse_trap_handlerOffset);
VerifyObjectField(knum_imported_functionsOffset);
VerifyObjectField(kcode_tableOffset);
VerifyObjectField(kfunction_tablesOffset);
VerifyObjectField(kempty_function_tablesOffset);
VerifyObjectField(kinstance_idOffset);
}
void WasmDebugInfo::WasmDebugInfoVerify() {
CHECK(IsWasmDebugInfo());
VerifyObjectField(kInstanceOffset);
......
......@@ -1465,6 +1465,12 @@ void Tuple3::Tuple3Print(std::ostream& os) { // NOLINT
os << "\n";
}
void WasmCompiledModule::WasmCompiledModulePrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "WasmCompiledModule");
os << "\n - shared: " << Brief(shared());
os << "\n";
}
void WasmDebugInfo::WasmDebugInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "WasmDebugInfo");
os << "\n - wasm_instance: " << Brief(wasm_instance());
......
......@@ -383,6 +383,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(STACK_FRAME_INFO_TYPE) \
V(TUPLE2_TYPE) \
V(TUPLE3_TYPE) \
V(WASM_COMPILED_MODULE_TYPE) \
V(WASM_DEBUG_INFO_TYPE) \
V(WASM_SHARED_MODULE_DATA_TYPE) \
\
......@@ -540,6 +541,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(STACK_FRAME_INFO, StackFrameInfo, stack_frame_info) \
V(TUPLE2, Tuple2, tuple2) \
V(TUPLE3, Tuple3, tuple3) \
V(WASM_COMPILED_MODULE, WasmCompiledModule, wasm_compiled_module) \
V(WASM_DEBUG_INFO, WasmDebugInfo, wasm_debug_info) \
V(WASM_SHARED_MODULE_DATA, WasmSharedModuleData, wasm_shared_module_data) \
V(CALLABLE_TASK, CallableTask, callable_task) \
......@@ -732,6 +734,7 @@ enum InstanceType : uint16_t {
STACK_FRAME_INFO_TYPE,
TUPLE2_TYPE,
TUPLE3_TYPE,
WASM_COMPILED_MODULE_TYPE,
WASM_DEBUG_INFO_TYPE,
WASM_SHARED_MODULE_DATA_TYPE,
......
......@@ -262,7 +262,7 @@ WasmCompiledModuleSerializer::WasmCompiledModuleSerializer(
}
std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
Isolate* isolate, Handle<FixedArray> input) {
Isolate* isolate, Handle<Struct> input) {
Handle<WasmCompiledModule> compiled_module =
Handle<WasmCompiledModule>::cast(input);
WasmCompiledModuleSerializer wasm_cs(
......@@ -272,9 +272,9 @@ std::unique_ptr<ScriptData> WasmCompiledModuleSerializer::SerializeWasmModule(
return std::unique_ptr<ScriptData>(data);
}
MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
MaybeHandle<Struct> WasmCompiledModuleSerializer::DeserializeWasmModule(
Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes) {
MaybeHandle<FixedArray> nothing;
MaybeHandle<Struct> nothing;
if (!wasm::IsWasmCodegenAllowed(isolate, isolate->native_context())) {
return nothing;
}
......@@ -298,7 +298,7 @@ MaybeHandle<FixedArray> WasmCompiledModuleSerializer::DeserializeWasmModule(
if (!maybe_result.ToHandle(&result)) return nothing;
WasmCompiledModule::ReinitializeAfterDeserialization(isolate, result);
DCHECK(WasmCompiledModule::IsWasmCompiledModule(*result));
DCHECK(result->IsWasmCompiledModule());
return result;
}
......
......@@ -87,9 +87,10 @@ class CodeSerializer : public Serializer<> {
class WasmCompiledModuleSerializer : public CodeSerializer {
public:
// TODO(mstarzinger): Make these typed to {WasmCompiledModule} instead.
static std::unique_ptr<ScriptData> SerializeWasmModule(
Isolate* isolate, Handle<FixedArray> compiled_module);
static MaybeHandle<FixedArray> DeserializeWasmModule(
Isolate* isolate, Handle<Struct> compiled_module);
static MaybeHandle<Struct> DeserializeWasmModule(
Isolate* isolate, ScriptData* data, Vector<const byte> wire_bytes);
protected:
......
......@@ -59,7 +59,7 @@ ObjectDeserializer::DeserializeWasmCompiledModule(
if (!d.Deserialize(isolate).ToHandle(&result))
return MaybeHandle<WasmCompiledModule>();
if (!result->IsFixedArray()) return MaybeHandle<WasmCompiledModule>();
if (!result->IsWasmCompiledModule()) return MaybeHandle<WasmCompiledModule>();
// Cast without type checks, as the module wrapper is not there yet.
return handle(static_cast<WasmCompiledModule*>(*result), isolate);
......
......@@ -14,6 +14,7 @@ namespace internal {
// Has to be the last include (doesn't have include guards)
#include "src/objects/object-macros.h"
CAST_ACCESSOR(WasmCompiledModule)
CAST_ACCESSOR(WasmDebugInfo)
CAST_ACCESSOR(WasmInstanceObject)
CAST_ACCESSOR(WasmMemoryObject)
......@@ -92,58 +93,53 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>,
#undef OPTIONAL_ACCESSORS
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID, TYPE_CHECK, SETTER_MODIFIER) \
TYPE* WasmCompiledModule::maybe_##NAME() const { \
Object* obj = get(ID); \
if (!(TYPE_CHECK)) return nullptr; \
return TYPE::cast(obj); \
} \
\
TYPE* WasmCompiledModule::NAME() const { \
Object* obj = get(ID); \
DCHECK(TYPE_CHECK); \
return TYPE::cast(obj); \
} \
\
bool WasmCompiledModule::has_##NAME() const { \
Object* obj = get(ID); \
return TYPE_CHECK; \
} \
\
void WasmCompiledModule::reset_##NAME() { set_undefined(ID); } \
\
void WasmCompiledModule::set_##NAME(TYPE* value) { set(ID, value); }
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, OFFSET, TYPE_CHECK, SETTER_MODIFIER) \
TYPE* WasmCompiledModule::maybe_##NAME() const { \
Object* value = READ_FIELD(this, OFFSET); \
if (!(TYPE_CHECK)) return nullptr; \
return TYPE::cast(value); \
} \
\
bool WasmCompiledModule::has_##NAME() const { \
Object* value = READ_FIELD(this, OFFSET); \
return TYPE_CHECK; \
} \
\
void WasmCompiledModule::reset_##NAME() { \
WRITE_FIELD(this, OFFSET, GetHeap()->undefined_value()); \
} \
\
ACCESSORS_CHECKED2(WasmCompiledModule, NAME, TYPE, OFFSET, TYPE_CHECK, true)
#define WCM_OBJECT(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, obj->Is##TYPE(), public)
WCM_OBJECT_OR_WEAK(TYPE, NAME, k##NAME##Offset, value->Is##TYPE(), public)
#define WCM_CONST_OBJECT(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, obj->Is##TYPE(), private)
#define WCM_WASM_OBJECT(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, TYPE::Is##TYPE(obj), private)
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME) \
TYPE WasmCompiledModule::NAME() const { \
return static_cast<TYPE>(Smi::ToInt(get(kID_##NAME))); \
} \
\
void WasmCompiledModule::set_##NAME(TYPE value) { \
set(kID_##NAME, Smi::FromInt(value)); \
WCM_OBJECT_OR_WEAK(TYPE, NAME, k##NAME##Offset, value->Is##TYPE(), private)
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME) \
TYPE WasmCompiledModule::NAME() const { \
return static_cast<TYPE>(Smi::ToInt(READ_FIELD(this, k##NAME##Offset))); \
} \
\
void WasmCompiledModule::set_##NAME(TYPE value) { \
WRITE_FIELD(this, k##NAME##Offset, Smi::FromInt(value)); \
}
#define WCM_WEAK_LINK(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME, obj->IsWeakCell(), \
public) \
\
TYPE* WasmCompiledModule::NAME() const { \
DCHECK(!weak_##NAME()->cleared()); \
return TYPE::cast(weak_##NAME()->value()); \
#define WCM_WEAK_LINK(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, k##NAME##Offset, \
value->IsWeakCell(), public) \
\
TYPE* WasmCompiledModule::NAME() const { \
DCHECK(!weak_##NAME()->cleared()); \
return TYPE::cast(weak_##NAME()->value()); \
}
#define DEFINITION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
WCM_PROPERTY_TABLE(DEFINITION)
#undef DECLARATION
ACCESSORS(WasmCompiledModule, raw_next_instance, Object, knext_instanceOffset);
ACCESSORS(WasmCompiledModule, raw_prev_instance, Object, kprev_instanceOffset);
#undef WCM_CONST_OBJECT
#undef WCM_LARGE_NUMBER
......
......@@ -1353,11 +1353,8 @@ Handle<WasmCompiledModule> WasmCompiledModule::New(
Handle<FixedArray> export_wrappers,
const std::vector<GlobalHandleAddress>& function_tables,
bool use_trap_handler) {
Handle<FixedArray> ret =
isolate->factory()->NewFixedArray(PropertyIndices::Count, TENURED);
// WasmCompiledModule::cast would fail since fields are not set yet.
Handle<WasmCompiledModule> compiled_module(
reinterpret_cast<WasmCompiledModule*>(*ret), isolate);
Handle<WasmCompiledModule> compiled_module = Handle<WasmCompiledModule>::cast(
isolate->factory()->NewStruct(WASM_COMPILED_MODULE_TYPE, TENURED));
Handle<WeakCell> weak_native_context =
isolate->factory()->NewWeakCell(isolate->native_context());
compiled_module->set_weak_native_context(*weak_native_context);
......@@ -1429,11 +1426,29 @@ Handle<WasmCompiledModule> WasmCompiledModule::Clone(
handle(module->code_table(), isolate));
}
Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast(
isolate->factory()->CopyFixedArray(module));
ret->reset_weak_owning_instance();
ret->reset_next_instance();
ret->reset_prev_instance();
ret->reset_weak_exported_functions();
isolate->factory()->NewStruct(WASM_COMPILED_MODULE_TYPE, TENURED));
ret->set_shared(module->shared());
ret->set_weak_native_context(module->weak_native_context());
ret->set_export_wrappers(module->export_wrappers());
ret->set_weak_wasm_module(module->weak_wasm_module());
if (FLAG_wasm_jit_to_native) {
ret->set_source_positions(module->source_positions());
ret->set_native_module(module->native_module());
}
if (module->has_lazy_compile_data()) {
ret->set_lazy_compile_data(module->lazy_compile_data());
}
ret->set_use_trap_handler(module->use_trap_handler());
if (!FLAG_wasm_jit_to_native) {
ret->set_num_imported_functions(module->num_imported_functions());
}
ret->set_code_table(module->code_table());
if (module->has_function_tables()) {
ret->set_function_tables(module->function_tables());
}
if (module->has_empty_function_tables()) {
ret->set_empty_function_tables(module->empty_function_tables());
}
if (!FLAG_wasm_jit_to_native) {
ret->InitId();
ret->set_code_table(*code_copy);
......@@ -1496,7 +1511,7 @@ wasm::NativeModule* WasmCompiledModule::GetNativeModule() const {
void WasmCompiledModule::InitId() {
#if DEBUG
static uint32_t instance_id_counter = 0;
set(kID_instance_id, Smi::FromInt(instance_id_counter++));
set_instance_id(instance_id_counter++);
TRACE("New compiled module id: %d\n", instance_id());
#endif
}
......@@ -1580,45 +1595,6 @@ MaybeHandle<String> WasmSharedModuleData::ExtractUtf8StringFromModuleBytes(
static_cast<int>(ref.length()));
}
bool WasmCompiledModule::IsWasmCompiledModule(Object* obj) {
if (!obj->IsFixedArray()) return false;
FixedArray* arr = FixedArray::cast(obj);
if (arr->length() != PropertyIndices::Count) return false;
#define WCM_CHECK_TYPE(NAME, TYPE_CHECK) \
do { \
Object* obj = arr->get(kID_##NAME); \
if (!(TYPE_CHECK)) return false; \
} while (false);
// We're OK with undefined, generally, because maybe we don't
// have a value for that item. For example, we may not have a
// memory, or globals.
// We're not OK with the const numbers being undefined. They are
// expected to be initialized at construction.
#define WCM_CHECK_OBJECT(TYPE, NAME) \
WCM_CHECK_TYPE(NAME, obj->IsUndefined(isolate) || obj->Is##TYPE())
#define WCM_CHECK_CONST_OBJECT(TYPE, NAME) \
WCM_CHECK_TYPE(NAME, obj->IsUndefined(isolate) || obj->Is##TYPE())
#define WCM_CHECK_WASM_OBJECT(TYPE, NAME) \
WCM_CHECK_TYPE(NAME, obj->IsFixedArray() || obj->IsUndefined(isolate))
#define WCM_CHECK_WEAK_LINK(TYPE, NAME) WCM_CHECK_OBJECT(WeakCell, NAME)
#define WCM_CHECK_SMALL_NUMBER(TYPE, NAME) \
WCM_CHECK_TYPE(NAME, obj->IsUndefined(isolate) || obj->IsSmi())
#define WCM_CHECK(KIND, TYPE, NAME) WCM_CHECK_##KIND(TYPE, NAME)
#define WCM_CHECK_SMALL_CONST_NUMBER(TYPE, NAME) \
WCM_CHECK_TYPE(NAME, obj->IsSmi())
#undef WCM_CHECK_TYPE
#undef WCM_CHECK_OBJECT
#undef WCM_CHECK_CONST_OBJECT
#undef WCM_CHECK_WASM_OBJECT
#undef WCM_CHECK_WEAK_LINK
#undef WCM_CHECK_SMALL_NUMBER
#undef WCM_CHECK
#undef WCM_CHECK_SMALL_CONST_NUMBER
// All checks passed.
return true;
}
void WasmCompiledModule::PrintInstancesChain() {
#if DEBUG
if (!FLAG_trace_wasm_instances) return;
......@@ -1647,14 +1623,14 @@ void WasmCompiledModule::RemoveFromChain() {
DisallowHeapAllocation no_gc;
Isolate* isolate = GetIsolate();
Object* next = get(kID_next_instance);
Object* prev = get(kID_prev_instance);
Object* next = raw_next_instance();
Object* prev = raw_prev_instance();
if (!prev->IsUndefined(isolate)) {
WasmCompiledModule::cast(prev)->set(kID_next_instance, next);
WasmCompiledModule::cast(prev)->set_raw_next_instance(next);
}
if (!next->IsUndefined(isolate)) {
WasmCompiledModule::cast(next)->set(kID_prev_instance, prev);
WasmCompiledModule::cast(next)->set_raw_prev_instance(prev);
}
}
......@@ -1668,9 +1644,7 @@ void WasmCompiledModule::ReinitializeAfterDeserialization(
// This method must only be called immediately after deserialization.
// At this point, no module wrapper exists, so the shared module data is
// incomplete.
Handle<WasmSharedModuleData> shared(
static_cast<WasmSharedModuleData*>(compiled_module->get(kID_shared)),
isolate);
Handle<WasmSharedModuleData> shared(compiled_module->shared(), isolate);
if (!FLAG_wasm_jit_to_native) {
WasmSharedModuleData::ReinitializeAfterDeserialization(isolate, shared);
}
......
......@@ -419,31 +419,55 @@ class WasmSharedModuleData : public Struct {
// the tables (signature and functions).
// For tables, we need to hold a reference to the JS Heap object, because
// we embed them as objects, and they may move.
class WasmCompiledModule : public FixedArray {
class WasmCompiledModule : public Struct {
public:
static WasmCompiledModule* cast(Object* fixed_array) {
SLOW_DCHECK(IsWasmCompiledModule(fixed_array));
return reinterpret_cast<WasmCompiledModule*>(fixed_array);
}
DECL_CAST(WasmCompiledModule)
// Dispatched behavior.
DECL_PRINTER(WasmCompiledModule)
DECL_VERIFIER(WasmCompiledModule)
// Layout description.
// TODO(mstarzinger): Rename the below constants to follow the usual naming
// scheme once the WCM_PROPERTY_TABLE has been deprecated.
#define WASM_COMPILED_MODULE_FIELDS(V) \
V(ksharedOffset, kPointerSize) \
V(knative_contextOffset, kPointerSize) \
V(kexport_wrappersOffset, kPointerSize) \
V(kweak_exported_functionsOffset, kPointerSize) \
V(knext_instanceOffset, kPointerSize) \
V(kprev_instanceOffset, kPointerSize) \
V(kowning_instanceOffset, kPointerSize) \
V(kwasm_moduleOffset, kPointerSize) \
V(ksource_positionsOffset, kPointerSize) \
V(knative_moduleOffset, kPointerSize) \
V(klazy_compile_dataOffset, kPointerSize) \
V(kuse_trap_handlerOffset, kPointerSize) \
V(knum_imported_functionsOffset, kPointerSize) \
V(kcode_tableOffset, kPointerSize) \
V(kfunction_tablesOffset, kPointerSize) \
V(kempty_function_tablesOffset, kPointerSize) \
V(kinstance_idOffset, kPointerSize) \
V(kSize, 0)
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID, TYPE_CHECK, SETTER_MODIFIER) \
public: \
inline TYPE* maybe_##NAME() const; \
inline TYPE* NAME() const; \
inline bool has_##NAME() const; \
inline void reset_##NAME(); \
\
SETTER_MODIFIER: \
inline void set_##NAME(TYPE* value);
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
WASM_COMPILED_MODULE_FIELDS)
#undef WASM_COMPILED_MODULE_FIELDS
#define WCM_OBJECT(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, obj->Is##TYPE(), public)
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, SETTER_MODIFIER) \
public: \
inline TYPE* maybe_##NAME() const; \
inline TYPE* NAME() const; \
inline bool has_##NAME() const; \
inline void reset_##NAME(); \
\
SETTER_MODIFIER: \
inline void set_##NAME(TYPE* value, \
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
#define WCM_CONST_OBJECT(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, obj->Is##TYPE(), private)
#define WCM_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, public)
#define WCM_WASM_OBJECT(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, TYPE::Is##TYPE(obj), private)
#define WCM_CONST_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, private)
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME) \
public: \
......@@ -452,32 +476,30 @@ class WasmCompiledModule : public FixedArray {
private: \
inline void set_##NAME(TYPE value);
#define WCM_WEAK_LINK(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME, obj->IsWeakCell(), \
public) \
\
public: \
#define WCM_WEAK_LINK(TYPE, NAME) \
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, public) \
\
public: \
inline TYPE* NAME() const;
// Add values here if they are required for creating new instances or
// for deserialization, and if they are serializable.
// By default, instance values go to WasmInstanceObject, however, if
// we embed the generated code with a value, then we track that value here.
#define CORE_WCM_PROPERTY_TABLE(MACRO) \
MACRO(CONST_OBJECT, WasmSharedModuleData, shared) \
MACRO(WEAK_LINK, Context, native_context) \
MACRO(CONST_OBJECT, FixedArray, export_wrappers) \
MACRO(OBJECT, FixedArray, weak_exported_functions) \
MACRO(WASM_OBJECT, WasmCompiledModule, next_instance) \
MACRO(WASM_OBJECT, WasmCompiledModule, prev_instance) \
MACRO(WEAK_LINK, WasmInstanceObject, owning_instance) \
MACRO(WEAK_LINK, WasmModuleObject, wasm_module) \
MACRO(OBJECT, FixedArray, source_positions) \
MACRO(OBJECT, Foreign, native_module) \
MACRO(OBJECT, FixedArray, lazy_compile_data) \
MACRO(SMALL_CONST_NUMBER, bool, use_trap_handler)
#define GC_WCM_PROPERTY_TABLE(MACRO) \
#define CORE_WCM_PROPERTY_TABLE(MACRO) \
MACRO(CONST_OBJECT, WasmSharedModuleData, shared) \
MACRO(WEAK_LINK, Context, native_context) \
MACRO(CONST_OBJECT, FixedArray, export_wrappers) \
MACRO(OBJECT, FixedArray, weak_exported_functions) \
MACRO(CONST_OBJECT, WasmCompiledModule, next_instance) \
MACRO(CONST_OBJECT, WasmCompiledModule, prev_instance) \
MACRO(WEAK_LINK, WasmInstanceObject, owning_instance) \
MACRO(WEAK_LINK, WasmModuleObject, wasm_module) \
MACRO(OBJECT, FixedArray, source_positions) \
MACRO(OBJECT, Foreign, native_module) \
MACRO(OBJECT, FixedArray, lazy_compile_data) \
/* TODO(mstarzinger): Make {use_trap_handler} smaller. */ \
MACRO(SMALL_CONST_NUMBER, bool, use_trap_handler) \
MACRO(SMALL_CONST_NUMBER, uint32_t, num_imported_functions) \
MACRO(CONST_OBJECT, FixedArray, code_table) \
MACRO(OBJECT, FixedArray, function_tables) \
......@@ -486,9 +508,10 @@ class WasmCompiledModule : public FixedArray {
// TODO(mtrofin): this is unnecessary when we stop needing
// FLAG_wasm_jit_to_native, because we have instance_id on NativeModule.
#if DEBUG
#define DEBUG_ONLY_TABLE(MACRO) MACRO(SMALL_CONST_NUMBER, uint32_t, instance_id)
#define DEBUG_WCM_PROPERTY_TABLE(MACRO) \
MACRO(SMALL_CONST_NUMBER, uint32_t, instance_id)
#else
#define DEBUG_ONLY_TABLE(IGNORE)
#define DEBUG_WCM_PROPERTY_TABLE(IGNORE)
public:
uint32_t instance_id() const { return static_cast<uint32_t>(-1); }
......@@ -496,15 +519,7 @@ class WasmCompiledModule : public FixedArray {
#define WCM_PROPERTY_TABLE(MACRO) \
CORE_WCM_PROPERTY_TABLE(MACRO) \
GC_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
};
DEBUG_WCM_PROPERTY_TABLE(MACRO)
public:
static Handle<WasmCompiledModule> New(
......@@ -525,10 +540,10 @@ class WasmCompiledModule : public FixedArray {
#define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
WCM_PROPERTY_TABLE(DECLARATION)
#undef DECLARATION
DECL_ACCESSORS(raw_next_instance, Object);
DECL_ACCESSORS(raw_prev_instance, Object);
public:
static bool IsWasmCompiledModule(Object* obj);
void PrintInstancesChain();
static void ReinitializeAfterDeserialization(Isolate*,
......@@ -680,6 +695,7 @@ WasmFunctionInfo GetWasmFunctionInfo(Isolate*, Handle<Code>);
#undef DECL_OPTIONAL_ACCESSORS
#undef WCM_CONST_OBJECT
#undef WCM_LARGE_NUMBER
#undef WCM_OBJECT
#undef WCM_OBJECT_OR_WEAK
#undef WCM_SMALL_CONST_NUMBER
#undef WCM_WEAK_LINK
......
......@@ -633,7 +633,7 @@ MaybeHandle<WasmCompiledModule> DeserializeNativeModule(
Isolate* isolate, Vector<const byte> data, Vector<const byte> wire_bytes) {
if (!FLAG_wasm_jit_to_native) {
ScriptData script_data(data.start(), data.length());
Handle<FixedArray> compiled_module;
Handle<Struct> compiled_module;
if (!WasmCompiledModuleSerializer::DeserializeWasmModule(
isolate, &script_data, wire_bytes)
.ToHandle(&compiled_module)) {
......
......@@ -259,7 +259,7 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0);
compiled_module->set_weak_exported_functions(*weak_exported);
DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module));
DCHECK(compiled_module->IsWasmCompiledModule());
script->set_wasm_compiled_module(*compiled_module);
auto instance = WasmInstanceObject::New(isolate_, compiled_module);
instance->wasm_context()->get()->globals_start = globals_data_;
......
......@@ -74,31 +74,32 @@ INSTANCE_TYPES = {
170: "STACK_FRAME_INFO_TYPE",
171: "TUPLE2_TYPE",
172: "TUPLE3_TYPE",
173: "WASM_DEBUG_INFO_TYPE",
174: "WASM_SHARED_MODULE_DATA_TYPE",
175: "CALLABLE_TASK_TYPE",
176: "CALLBACK_TASK_TYPE",
177: "PROMISE_FULFILL_REACTION_JOB_TASK_TYPE",
178: "PROMISE_REJECT_REACTION_JOB_TASK_TYPE",
179: "PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE",
180: "FIXED_ARRAY_TYPE",
181: "BOILERPLATE_DESCRIPTION_TYPE",
182: "DESCRIPTOR_ARRAY_TYPE",
183: "HASH_TABLE_TYPE",
184: "SCOPE_INFO_TYPE",
185: "TRANSITION_ARRAY_TYPE",
186: "CELL_TYPE",
187: "CODE_DATA_CONTAINER_TYPE",
188: "FEEDBACK_CELL_TYPE",
189: "FEEDBACK_VECTOR_TYPE",
190: "LOAD_HANDLER_TYPE",
191: "PROPERTY_ARRAY_TYPE",
192: "PROPERTY_CELL_TYPE",
193: "SHARED_FUNCTION_INFO_TYPE",
194: "SMALL_ORDERED_HASH_MAP_TYPE",
195: "SMALL_ORDERED_HASH_SET_TYPE",
196: "STORE_HANDLER_TYPE",
197: "WEAK_CELL_TYPE",
173: "WASM_COMPILED_MODULE_TYPE",
174: "WASM_DEBUG_INFO_TYPE",
175: "WASM_SHARED_MODULE_DATA_TYPE",
176: "CALLABLE_TASK_TYPE",
177: "CALLBACK_TASK_TYPE",
178: "PROMISE_FULFILL_REACTION_JOB_TASK_TYPE",
179: "PROMISE_REJECT_REACTION_JOB_TASK_TYPE",
180: "PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE",
181: "FIXED_ARRAY_TYPE",
182: "BOILERPLATE_DESCRIPTION_TYPE",
183: "DESCRIPTOR_ARRAY_TYPE",
184: "HASH_TABLE_TYPE",
185: "SCOPE_INFO_TYPE",
186: "TRANSITION_ARRAY_TYPE",
187: "CELL_TYPE",
188: "CODE_DATA_CONTAINER_TYPE",
189: "FEEDBACK_CELL_TYPE",
190: "FEEDBACK_VECTOR_TYPE",
191: "LOAD_HANDLER_TYPE",
192: "PROPERTY_ARRAY_TYPE",
193: "PROPERTY_CELL_TYPE",
194: "SHARED_FUNCTION_INFO_TYPE",
195: "SMALL_ORDERED_HASH_MAP_TYPE",
196: "SMALL_ORDERED_HASH_SET_TYPE",
197: "STORE_HANDLER_TYPE",
198: "WEAK_CELL_TYPE",
1024: "JS_PROXY_TYPE",
1025: "JS_GLOBAL_OBJECT_TYPE",
1026: "JS_GLOBAL_PROXY_TYPE",
......@@ -145,8 +146,8 @@ KNOWN_MAPS = {
0x02201: (138, "FreeSpaceMap"),
0x02259: (132, "MetaMap"),
0x022b1: (131, "NullMap"),
0x02309: (182, "DescriptorArrayMap"),
0x02361: (180, "FixedArrayMap"),
0x02309: (183, "DescriptorArrayMap"),
0x02361: (181, "FixedArrayMap"),
0x023b9: (151, "OnePointerFillerMap"),
0x02411: (151, "TwoPointerFillerMap"),
0x02469: (131, "UninitializedMap"),
......@@ -156,59 +157,59 @@ KNOWN_MAPS = {
0x025c9: (131, "TheHoleMap"),
0x02621: (131, "BooleanMap"),
0x02679: (136, "ByteArrayMap"),
0x026d1: (180, "FixedCOWArrayMap"),
0x02729: (183, "HashTableMap"),
0x026d1: (181, "FixedCOWArrayMap"),
0x02729: (184, "HashTableMap"),
0x02781: (128, "SymbolMap"),
0x027d9: (72, "OneByteStringMap"),
0x02831: (184, "ScopeInfoMap"),
0x02889: (193, "SharedFunctionInfoMap"),
0x02831: (185, "ScopeInfoMap"),
0x02889: (194, "SharedFunctionInfoMap"),
0x028e1: (133, "CodeMap"),
0x02939: (180, "FunctionContextMap"),
0x02991: (186, "CellMap"),
0x029e9: (197, "WeakCellMap"),
0x02a41: (192, "GlobalPropertyCellMap"),
0x02939: (181, "FunctionContextMap"),
0x02991: (187, "CellMap"),
0x029e9: (198, "WeakCellMap"),
0x02a41: (193, "GlobalPropertyCellMap"),
0x02a99: (135, "ForeignMap"),
0x02af1: (185, "TransitionArrayMap"),
0x02b49: (189, "FeedbackVectorMap"),
0x02af1: (186, "TransitionArrayMap"),
0x02b49: (190, "FeedbackVectorMap"),
0x02ba1: (131, "ArgumentsMarkerMap"),
0x02bf9: (131, "ExceptionMap"),
0x02c51: (131, "TerminationExceptionMap"),
0x02ca9: (131, "OptimizedOutMap"),
0x02d01: (131, "StaleRegisterMap"),
0x02d59: (180, "NativeContextMap"),
0x02db1: (180, "ModuleContextMap"),
0x02e09: (180, "EvalContextMap"),
0x02e61: (180, "ScriptContextMap"),
0x02eb9: (180, "BlockContextMap"),
0x02f11: (180, "CatchContextMap"),
0x02f69: (180, "WithContextMap"),
0x02fc1: (180, "DebugEvaluateContextMap"),
0x03019: (180, "ScriptContextTableMap"),
0x03071: (180, "ArrayListMap"),
0x02d59: (181, "NativeContextMap"),
0x02db1: (181, "ModuleContextMap"),
0x02e09: (181, "EvalContextMap"),
0x02e61: (181, "ScriptContextMap"),
0x02eb9: (181, "BlockContextMap"),
0x02f11: (181, "CatchContextMap"),
0x02f69: (181, "WithContextMap"),
0x02fc1: (181, "DebugEvaluateContextMap"),
0x03019: (181, "ScriptContextTableMap"),
0x03071: (181, "ArrayListMap"),
0x030c9: (130, "BigIntMap"),
0x03121: (181, "BoilerplateDescriptionMap"),
0x03121: (182, "BoilerplateDescriptionMap"),
0x03179: (137, "BytecodeArrayMap"),
0x031d1: (187, "CodeDataContainerMap"),
0x031d1: (188, "CodeDataContainerMap"),
0x03229: (1057, "ExternalMap"),
0x03281: (150, "FixedDoubleArrayMap"),
0x032d9: (183, "GlobalDictionaryMap"),
0x03331: (188, "ManyClosuresCellMap"),
0x032d9: (184, "GlobalDictionaryMap"),
0x03331: (189, "ManyClosuresCellMap"),
0x03389: (1072, "JSMessageObjectMap"),
0x033e1: (180, "ModuleInfoMap"),
0x033e1: (181, "ModuleInfoMap"),
0x03439: (134, "MutableHeapNumberMap"),
0x03491: (183, "NameDictionaryMap"),
0x034e9: (188, "NoClosuresCellMap"),
0x03541: (183, "NumberDictionaryMap"),
0x03599: (188, "OneClosureCellMap"),
0x035f1: (183, "OrderedHashMapMap"),
0x03649: (183, "OrderedHashSetMap"),
0x036a1: (191, "PropertyArrayMap"),
0x036f9: (183, "SimpleNumberDictionaryMap"),
0x03751: (180, "SloppyArgumentsElementsMap"),
0x037a9: (194, "SmallOrderedHashMapMap"),
0x03801: (195, "SmallOrderedHashSetMap"),
0x03859: (183, "StringTableMap"),
0x038b1: (183, "WeakHashTableMap"),
0x03491: (184, "NameDictionaryMap"),
0x034e9: (189, "NoClosuresCellMap"),
0x03541: (184, "NumberDictionaryMap"),
0x03599: (189, "OneClosureCellMap"),
0x035f1: (184, "OrderedHashMapMap"),
0x03649: (184, "OrderedHashSetMap"),
0x036a1: (192, "PropertyArrayMap"),
0x036f9: (184, "SimpleNumberDictionaryMap"),
0x03751: (181, "SloppyArgumentsElementsMap"),
0x037a9: (195, "SmallOrderedHashMapMap"),
0x03801: (196, "SmallOrderedHashSetMap"),
0x03859: (184, "StringTableMap"),
0x038b1: (184, "WeakHashTableMap"),
0x03909: (106, "NativeSourceStringMap"),
0x03961: (64, "StringMap"),
0x039b9: (73, "ConsOneByteStringMap"),
......@@ -262,13 +263,14 @@ KNOWN_MAPS = {
0x04a39: (168, "PrototypeInfoMap"),
0x04a91: (170, "StackFrameInfoMap"),
0x04ae9: (172, "Tuple3Map"),
0x04b41: (173, "WasmDebugInfoMap"),
0x04b99: (174, "WasmSharedModuleDataMap"),
0x04bf1: (175, "CallableTaskMap"),
0x04c49: (176, "CallbackTaskMap"),
0x04ca1: (177, "PromiseFulfillReactionJobTaskMap"),
0x04cf9: (178, "PromiseRejectReactionJobTaskMap"),
0x04d51: (179, "PromiseResolveThenableJobTaskMap"),
0x04b41: (173, "WasmCompiledModuleMap"),
0x04b99: (174, "WasmDebugInfoMap"),
0x04bf1: (175, "WasmSharedModuleDataMap"),
0x04c49: (176, "CallableTaskMap"),
0x04ca1: (177, "CallbackTaskMap"),
0x04cf9: (178, "PromiseFulfillReactionJobTaskMap"),
0x04d51: (179, "PromiseRejectReactionJobTaskMap"),
0x04da9: (180, "PromiseResolveThenableJobTaskMap"),
}
# List of known V8 objects.
......
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