[wasm] Remove {WasmCompiledModule} object type.
R=clemensh@chromium.org Change-Id: I01b0b4948973ebbe0386ae8ae08e722ad16bcab8 Reviewed-on: https://chromium-review.googlesource.com/1114616 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#54058}
This commit is contained in:
parent
ded61e98c2
commit
6d20218ed1
@ -316,7 +316,6 @@ Type::bitset BitsetType::Lub(HeapObjectType const& type) {
|
||||
case INTERPRETER_DATA_TYPE:
|
||||
case TUPLE2_TYPE:
|
||||
case TUPLE3_TYPE:
|
||||
case WASM_COMPILED_MODULE_TYPE:
|
||||
case WASM_DEBUG_INFO_TYPE:
|
||||
case WASM_EXPORTED_FUNCTION_DATA_TYPE:
|
||||
case LOAD_HANDLER_TYPE:
|
||||
|
@ -548,7 +548,7 @@ class WasmInstanceObject::BodyDescriptor final : public BodyDescriptorBase {
|
||||
public:
|
||||
static bool IsValidSlot(Map* map, HeapObject* obj, int offset) {
|
||||
if (offset < kMemoryStartOffset) return true;
|
||||
if (offset < kCompiledModuleOffset) return false;
|
||||
if (offset < kModuleObjectOffset) return false;
|
||||
return IsValidSlotImpl(map, obj, offset);
|
||||
}
|
||||
|
||||
|
@ -1540,13 +1540,6 @@ void Tuple3::Tuple3Verify(Isolate* isolate) {
|
||||
VerifyObjectField(kValue3Offset);
|
||||
}
|
||||
|
||||
void WasmCompiledModule::WasmCompiledModuleVerify(Isolate* isolate) {
|
||||
CHECK(IsWasmCompiledModule());
|
||||
VerifyObjectField(kNextInstanceOffset);
|
||||
VerifyObjectField(kPrevInstanceOffset);
|
||||
VerifyObjectField(kOwningInstanceOffset);
|
||||
}
|
||||
|
||||
void WasmDebugInfo::WasmDebugInfoVerify(Isolate* isolate) {
|
||||
CHECK(IsWasmDebugInfo());
|
||||
VerifyObjectField(kInstanceOffset);
|
||||
@ -1586,7 +1579,6 @@ void WasmExportedFunctionData::WasmExportedFunctionDataVerify(
|
||||
void WasmModuleObject::WasmModuleObjectVerify(Isolate* isolate) {
|
||||
CHECK(IsWasmModuleObject());
|
||||
VerifyObjectField(kNativeModuleOffset);
|
||||
VerifyObjectField(kCompiledModuleOffset);
|
||||
VerifyObjectField(kExportWrappersOffset);
|
||||
VerifyObjectField(kManagedModuleOffset);
|
||||
CHECK(managed_module()->IsForeign());
|
||||
|
@ -1672,11 +1672,6 @@ void Tuple3::Tuple3Print(std::ostream& os) { // NOLINT
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
void WasmCompiledModule::WasmCompiledModulePrint(std::ostream& os) { // NOLINT
|
||||
HeapObject::PrintHeader(os, "WasmCompiledModule");
|
||||
os << "\n";
|
||||
}
|
||||
|
||||
void WasmDebugInfo::WasmDebugInfoPrint(std::ostream& os) { // NOLINT
|
||||
HeapObject::PrintHeader(os, "WasmDebugInfo");
|
||||
os << "\n - wasm_instance: " << Brief(wasm_instance());
|
||||
@ -1685,7 +1680,6 @@ void WasmDebugInfo::WasmDebugInfoPrint(std::ostream& os) { // NOLINT
|
||||
|
||||
void WasmInstanceObject::WasmInstanceObjectPrint(std::ostream& os) { // NOLINT
|
||||
HeapObject::PrintHeader(os, "WasmInstanceObject");
|
||||
os << "\n - compiled_module: " << Brief(compiled_module());
|
||||
os << "\n - module_object: " << Brief(module_object());
|
||||
os << "\n - exports_object: " << Brief(exports_object());
|
||||
os << "\n - native_context: " << Brief(native_context());
|
||||
|
@ -103,7 +103,6 @@
|
||||
// - ModuleInfo
|
||||
// - ScriptContextTable
|
||||
// - FixedArrayOfWeakCells
|
||||
// - WasmCompiledModule
|
||||
// - FixedDoubleArray
|
||||
// - Name
|
||||
// - String
|
||||
@ -400,7 +399,6 @@ 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_EXPORTED_FUNCTION_DATA_TYPE) \
|
||||
\
|
||||
@ -587,7 +585,6 @@ 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_EXPORTED_FUNCTION_DATA, WasmExportedFunctionData, \
|
||||
wasm_exported_function_data) \
|
||||
@ -786,7 +783,6 @@ enum InstanceType : uint16_t {
|
||||
STACK_FRAME_INFO_TYPE,
|
||||
TUPLE2_TYPE,
|
||||
TUPLE3_TYPE,
|
||||
WASM_COMPILED_MODULE_TYPE,
|
||||
WASM_DEBUG_INFO_TYPE,
|
||||
WASM_EXPORTED_FUNCTION_DATA_TYPE,
|
||||
|
||||
|
@ -959,24 +959,6 @@ RUNTIME_FUNCTION(Runtime_DeserializeWasmModule) {
|
||||
return *module_object;
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_ValidateWasmInstancesChain) {
|
||||
HandleScope shs(isolate);
|
||||
DCHECK_EQ(2, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(Smi, instance_count, 1);
|
||||
WasmInstanceObject::ValidateInstancesChainForTesting(isolate, module_obj,
|
||||
instance_count->value());
|
||||
return isolate->heap()->ToBoolean(true);
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_ValidateWasmModuleState) {
|
||||
HandleScope shs(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0);
|
||||
WasmModuleObject::ValidateStateForTesting(isolate, module_obj);
|
||||
return isolate->heap()->ToBoolean(true);
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_HeapObjectVerify) {
|
||||
HandleScope shs(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
@ -994,6 +976,18 @@ RUNTIME_FUNCTION(Runtime_HeapObjectVerify) {
|
||||
return isolate->heap()->ToBoolean(true);
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_WasmGetNumberOfInstances) {
|
||||
SealHandleScope shs(isolate);
|
||||
DCHECK_EQ(1, args.length());
|
||||
CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0);
|
||||
int instance_count = 0;
|
||||
WeakArrayList* weak_instance_list = module_obj->weak_instance_list();
|
||||
for (int i = 0; i < weak_instance_list->length(); ++i) {
|
||||
if (weak_instance_list->Get(i)->IsWeakHeapObject()) instance_count++;
|
||||
}
|
||||
return Smi::FromInt(instance_count);
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_WasmNumInterpretedCalls) {
|
||||
DCHECK_EQ(1, args.length());
|
||||
HandleScope scope(isolate);
|
||||
|
@ -556,8 +556,7 @@ namespace internal {
|
||||
F(TraceEnter, 0, 1) \
|
||||
F(TraceExit, 1, 1) \
|
||||
F(UnblockConcurrentRecompilation, 0, 1) \
|
||||
F(ValidateWasmInstancesChain, 2, 1) \
|
||||
F(ValidateWasmModuleState, 1, 1) \
|
||||
F(WasmGetNumberOfInstances, 1, 1) \
|
||||
F(WasmNumInterpretedCalls, 1, 1) \
|
||||
F(WasmTraceMemory, 1, 1) \
|
||||
F(WasmMemoryHasFullGuardRegion, 1, 1)
|
||||
|
@ -229,9 +229,8 @@ class JSToWasmWrapperCache {
|
||||
std::vector<Handle<Code>> code_cache_;
|
||||
};
|
||||
|
||||
// A helper class to simplify instantiating a module from a compiled module.
|
||||
// It closes over the {Isolate}, the {ErrorThrower}, the {WasmCompiledModule},
|
||||
// etc.
|
||||
// A helper class to simplify instantiating a module from a module object.
|
||||
// It closes over the {Isolate}, the {ErrorThrower}, etc.
|
||||
class InstanceBuilder {
|
||||
public:
|
||||
InstanceBuilder(Isolate* isolate, ErrorThrower* thrower,
|
||||
@ -1046,7 +1045,6 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
// Record build time into correct bucket, then build instance.
|
||||
TimedHistogramScope wasm_instantiate_module_time_scope(SELECT_WASM_COUNTER(
|
||||
counters(), module_->origin, wasm_instantiate, module_time));
|
||||
Factory* factory = isolate_->factory();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Allocate the memory array buffer.
|
||||
@ -1082,6 +1080,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
memory_ = AllocateMemory(initial_pages);
|
||||
if (memory_.is_null()) return {}; // failed to allocate memory
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Recompile module if using trap handlers but could not get guarded memory
|
||||
//--------------------------------------------------------------------------
|
||||
@ -1113,42 +1112,14 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Reuse the compiled module (if no owner), otherwise clone.
|
||||
//--------------------------------------------------------------------------
|
||||
wasm::NativeModule* native_module = module_object_->native_module();
|
||||
// Root the old instance, if any, in case later allocation causes GC,
|
||||
// to prevent the finalizer running for the old instance.
|
||||
MaybeHandle<WasmInstanceObject> old_instance;
|
||||
|
||||
TRACE("Starting new module instantiation\n");
|
||||
Handle<WasmCompiledModule> new_compiled_module;
|
||||
{
|
||||
Handle<WasmCompiledModule> original =
|
||||
handle(module_object_->compiled_module(), isolate_);
|
||||
if (original->has_instance()) {
|
||||
old_instance = handle(original->owning_instance(), isolate_);
|
||||
// Clone, but don't insert yet the clone in the instances chain.
|
||||
// We do that last. Since we are holding on to the old instance,
|
||||
// the owner + original state used for cloning and patching
|
||||
// won't be mutated by possible finalizer runs.
|
||||
TRACE("Cloning from %zu\n", native_module->instance_id);
|
||||
new_compiled_module = WasmCompiledModule::Clone(isolate_, original);
|
||||
RecordStats(module_object_->native_module(), counters());
|
||||
} else {
|
||||
// No instance owned the original compiled module.
|
||||
new_compiled_module = original;
|
||||
TRACE("Reusing existing instance %zu\n", native_module->instance_id);
|
||||
}
|
||||
}
|
||||
wasm::NativeModuleModificationScope native_modification_scope(native_module);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Create the WebAssembly.Instance object.
|
||||
//--------------------------------------------------------------------------
|
||||
wasm::NativeModule* native_module = module_object_->native_module();
|
||||
TRACE("New module instantiation for %zu\n", native_module->instance_id);
|
||||
Handle<WasmInstanceObject> instance =
|
||||
WasmInstanceObject::New(isolate_, module_object_, new_compiled_module);
|
||||
Handle<WeakCell> weak_instance = factory->NewWeakCell(instance);
|
||||
WasmInstanceObject::New(isolate_, module_object_);
|
||||
wasm::NativeModuleModificationScope native_modification_scope(native_module);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set up the globals for the new instance.
|
||||
@ -1294,18 +1265,9 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
FlushICache(native_module);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Insert the compiled module into the weak list of compiled modules.
|
||||
// Install a finalizer on the new instance object.
|
||||
//--------------------------------------------------------------------------
|
||||
{
|
||||
if (!old_instance.is_null()) {
|
||||
// Publish the new instance to the instances chain.
|
||||
DisallowHeapAllocation no_gc;
|
||||
new_compiled_module->InsertInChain(*module_object_);
|
||||
}
|
||||
module_object_->set_compiled_module(*new_compiled_module);
|
||||
new_compiled_module->set_weak_owning_instance(*weak_instance);
|
||||
WasmInstanceObject::InstallFinalizer(isolate_, instance);
|
||||
}
|
||||
WasmInstanceObject::InstallFinalizer(isolate_, instance);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Debugging support.
|
||||
|
@ -290,11 +290,6 @@ const char* GetWasmCodeKindAsString(WasmCode::Kind kind) {
|
||||
}
|
||||
|
||||
WasmCode::~WasmCode() {
|
||||
// Depending on finalizer order, the WasmCompiledModule finalizer may be
|
||||
// called first, case in which we release here. If the InstanceFinalizer is
|
||||
// called first, the handlers will be cleared in Reset, as-if the NativeModule
|
||||
// may be later used again (which would be the case if the WasmCompiledModule
|
||||
// were still held by a WasmModuleObject)
|
||||
if (HasTrapHandlerIndex()) {
|
||||
CHECK_LT(trap_handler_index(),
|
||||
static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
|
@ -20,7 +20,6 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
CAST_ACCESSOR(WasmCompiledModule)
|
||||
CAST_ACCESSOR(WasmDebugInfo)
|
||||
CAST_ACCESSOR(WasmExportedFunctionData)
|
||||
CAST_ACCESSOR(WasmGlobalObject)
|
||||
@ -52,12 +51,12 @@ CAST_ACCESSOR(WasmTableObject)
|
||||
// WasmModuleObject
|
||||
ACCESSORS(WasmModuleObject, managed_native_module, Managed<wasm::NativeModule>,
|
||||
kNativeModuleOffset)
|
||||
ACCESSORS(WasmModuleObject, compiled_module, WasmCompiledModule,
|
||||
kCompiledModuleOffset)
|
||||
ACCESSORS(WasmModuleObject, export_wrappers, FixedArray, kExportWrappersOffset)
|
||||
ACCESSORS(WasmModuleObject, managed_module, Managed<wasm::WasmModule>,
|
||||
kManagedModuleOffset)
|
||||
ACCESSORS(WasmModuleObject, script, Script, kScriptOffset)
|
||||
ACCESSORS(WasmModuleObject, weak_instance_list, WeakArrayList,
|
||||
kWeakInstanceListOffset)
|
||||
OPTIONAL_ACCESSORS(WasmModuleObject, asm_js_offset_table, ByteArray,
|
||||
kAsmJsOffsetTableOffset)
|
||||
OPTIONAL_ACCESSORS(WasmModuleObject, breakpoint_infos, FixedArray,
|
||||
@ -156,8 +155,6 @@ PRIMITIVE_ACCESSORS(WasmInstanceObject, indirect_function_table_sig_ids,
|
||||
PRIMITIVE_ACCESSORS(WasmInstanceObject, indirect_function_table_targets,
|
||||
Address*, kIndirectFunctionTableTargetsOffset)
|
||||
|
||||
ACCESSORS(WasmInstanceObject, compiled_module, WasmCompiledModule,
|
||||
kCompiledModuleOffset)
|
||||
ACCESSORS(WasmInstanceObject, module_object, WasmModuleObject,
|
||||
kModuleObjectOffset)
|
||||
ACCESSORS(WasmInstanceObject, exports_object, JSObject, kExportsObjectOffset)
|
||||
@ -220,40 +217,6 @@ OPTIONAL_ACCESSORS(WasmDebugInfo, c_wasm_entry_map, Managed<wasm::SignatureMap>,
|
||||
kCWasmEntryMapOffset)
|
||||
|
||||
#undef OPTIONAL_ACCESSORS
|
||||
|
||||
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, OFFSET, TYPE_CHECK) \
|
||||
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, OFFSET) \
|
||||
WCM_OBJECT_OR_WEAK(TYPE, NAME, OFFSET, value->Is##TYPE())
|
||||
|
||||
#define WCM_WEAK_LINK(TYPE, NAME, OFFSET) \
|
||||
WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, OFFSET, value->IsWeakCell()) \
|
||||
\
|
||||
TYPE* WasmCompiledModule::NAME() const { \
|
||||
DCHECK(!weak_##NAME()->cleared()); \
|
||||
return TYPE::cast(weak_##NAME()->value()); \
|
||||
}
|
||||
|
||||
// WasmCompiledModule
|
||||
WCM_OBJECT(WasmCompiledModule, next_instance, kNextInstanceOffset)
|
||||
WCM_OBJECT(WasmCompiledModule, prev_instance, kPrevInstanceOffset)
|
||||
WCM_WEAK_LINK(WasmInstanceObject, owning_instance, kOwningInstanceOffset)
|
||||
ACCESSORS(WasmCompiledModule, raw_next_instance, Object, kNextInstanceOffset);
|
||||
ACCESSORS(WasmCompiledModule, raw_prev_instance, Object, kPrevInstanceOffset);
|
||||
|
||||
#undef WCM_OBJECT_OR_WEAK
|
||||
#undef WCM_OBJECT
|
||||
#undef WCM_WEAK_LINK
|
||||
#undef READ_PRIMITIVE_FIELD
|
||||
#undef WRITE_PRIMITIVE_FIELD
|
||||
#undef PRIMITIVE_ACCESSORS
|
||||
@ -262,10 +225,6 @@ uint32_t WasmTableObject::current_length() { return functions()->length(); }
|
||||
|
||||
bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; }
|
||||
|
||||
inline bool WasmCompiledModule::has_instance() const {
|
||||
return !weak_owning_instance()->cleared();
|
||||
}
|
||||
|
||||
#include "src/objects/object-macros-undef.h"
|
||||
|
||||
} // namespace internal
|
||||
|
@ -144,103 +144,6 @@ WasmInstanceNativeAllocations* GetNativeAllocations(
|
||||
->raw();
|
||||
}
|
||||
|
||||
// An iterator that returns first the module itself, then all modules linked via
|
||||
// next, then all linked via prev.
|
||||
class CompiledModulesIterator
|
||||
: public v8::base::iterator<std::input_iterator_tag,
|
||||
Handle<WasmCompiledModule>> {
|
||||
public:
|
||||
CompiledModulesIterator(Isolate* isolate,
|
||||
Handle<WasmCompiledModule> start_module, bool at_end)
|
||||
: isolate_(isolate),
|
||||
start_module_(start_module),
|
||||
current_(
|
||||
at_end ? Handle<WasmCompiledModule>::null()
|
||||
: Handle<WasmCompiledModule>::New(*start_module, isolate)) {}
|
||||
|
||||
Handle<WasmCompiledModule> operator*() const {
|
||||
DCHECK(!current_.is_null());
|
||||
return current_;
|
||||
}
|
||||
|
||||
void operator++() { Advance(); }
|
||||
|
||||
bool operator!=(const CompiledModulesIterator& other) {
|
||||
DCHECK(start_module_.is_identical_to(other.start_module_));
|
||||
return !current_.is_identical_to(other.current_);
|
||||
}
|
||||
|
||||
private:
|
||||
void Advance() {
|
||||
DCHECK(!current_.is_null());
|
||||
if (!is_backwards_) {
|
||||
if (current_->has_next_instance()) {
|
||||
*current_.location() = current_->next_instance();
|
||||
return;
|
||||
}
|
||||
// No more modules in next-links, now try the previous-links.
|
||||
is_backwards_ = true;
|
||||
current_ = start_module_;
|
||||
}
|
||||
if (current_->has_prev_instance()) {
|
||||
*current_.location() = current_->prev_instance();
|
||||
return;
|
||||
}
|
||||
current_ = Handle<WasmCompiledModule>::null();
|
||||
}
|
||||
|
||||
friend class CompiledModuleInstancesIterator;
|
||||
Isolate* isolate_;
|
||||
Handle<WasmCompiledModule> start_module_;
|
||||
Handle<WasmCompiledModule> current_;
|
||||
bool is_backwards_ = false;
|
||||
};
|
||||
|
||||
// An iterator based on the CompiledModulesIterator, but it returns all live
|
||||
// instances, not the WasmCompiledModules itself.
|
||||
class CompiledModuleInstancesIterator
|
||||
: public v8::base::iterator<std::input_iterator_tag,
|
||||
Handle<WasmInstanceObject>> {
|
||||
public:
|
||||
CompiledModuleInstancesIterator(Isolate* isolate,
|
||||
Handle<WasmCompiledModule> start_module,
|
||||
bool at_end)
|
||||
: it(isolate, start_module, at_end) {
|
||||
while (NeedToAdvance()) ++it;
|
||||
}
|
||||
|
||||
Handle<WasmInstanceObject> operator*() {
|
||||
return handle(
|
||||
WasmInstanceObject::cast((*it)->weak_owning_instance()->value()),
|
||||
it.isolate_);
|
||||
}
|
||||
|
||||
void operator++() {
|
||||
do {
|
||||
++it;
|
||||
} while (NeedToAdvance());
|
||||
}
|
||||
|
||||
bool operator!=(const CompiledModuleInstancesIterator& other) {
|
||||
return it != other.it;
|
||||
}
|
||||
|
||||
private:
|
||||
bool NeedToAdvance() {
|
||||
return !it.current_.is_null() && !it.current_->has_instance();
|
||||
}
|
||||
CompiledModulesIterator it;
|
||||
};
|
||||
|
||||
v8::base::iterator_range<CompiledModuleInstancesIterator>
|
||||
iterate_compiled_module_instance_chain(Isolate* isolate,
|
||||
Handle<WasmModuleObject> module_object) {
|
||||
Handle<WasmCompiledModule> compiled_module(module_object->compiled_module(),
|
||||
isolate);
|
||||
return {CompiledModuleInstancesIterator(isolate, compiled_module, false),
|
||||
CompiledModuleInstancesIterator(isolate, compiled_module, true)};
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool IsBreakablePosition(wasm::NativeModule* native_module, int func_index,
|
||||
int offset_in_func) {
|
||||
@ -285,24 +188,19 @@ Handle<WasmModuleObject> WasmModuleObject::New(
|
||||
Managed<WasmModule>::FromSharedPtr(isolate, module_size,
|
||||
std::move(shared_module));
|
||||
|
||||
// Create the first {WasmCompiledModule} associated with this
|
||||
// {WasmModuleObject}.
|
||||
Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New(isolate);
|
||||
|
||||
// Now create the {WasmModuleObject}.
|
||||
Handle<JSFunction> module_cons(
|
||||
isolate->native_context()->wasm_module_constructor(), isolate);
|
||||
auto module_object = Handle<WasmModuleObject>::cast(
|
||||
isolate->factory()->NewJSObject(module_cons));
|
||||
module_object->set_compiled_module(*compiled_module);
|
||||
module_object->set_export_wrappers(*export_wrappers);
|
||||
module_object->set_managed_module(*managed_module);
|
||||
if (script->type() == Script::TYPE_WASM) {
|
||||
script->set_wasm_module_object(*module_object);
|
||||
}
|
||||
module_object->set_managed_module(*managed_module);
|
||||
if (!script.is_null()) {
|
||||
module_object->set_script(*script);
|
||||
}
|
||||
module_object->set_script(*script);
|
||||
module_object->set_weak_instance_list(
|
||||
isolate->heap()->empty_weak_array_list());
|
||||
if (!asm_js_offset_table.is_null()) {
|
||||
module_object->set_asm_js_offset_table(*asm_js_offset_table);
|
||||
}
|
||||
@ -342,26 +240,24 @@ bool WasmModuleObject::SetBreakPoint(Handle<WasmModuleObject> module_object,
|
||||
WasmModuleObject::AddBreakpoint(module_object, *position, break_point);
|
||||
|
||||
// Iterate over all instances of this module and tell them to set this new
|
||||
// breakpoint.
|
||||
for (Handle<WasmInstanceObject> instance :
|
||||
iterate_compiled_module_instance_chain(isolate, module_object)) {
|
||||
Handle<WasmDebugInfo> debug_info =
|
||||
WasmInstanceObject::GetOrCreateDebugInfo(instance);
|
||||
WasmDebugInfo::SetBreakpoint(debug_info, func_index, offset_in_func);
|
||||
// breakpoint. We do this using the weak list of all instances.
|
||||
Handle<WeakArrayList> weak_instance_list(module_object->weak_instance_list(),
|
||||
isolate);
|
||||
for (int i = 0; i < weak_instance_list->length(); ++i) {
|
||||
MaybeObject* maybe_instance = weak_instance_list->Get(i);
|
||||
if (maybe_instance->IsWeakHeapObject()) {
|
||||
Handle<WasmInstanceObject> instance(
|
||||
WasmInstanceObject::cast(maybe_instance->ToWeakHeapObject()),
|
||||
isolate);
|
||||
Handle<WasmDebugInfo> debug_info =
|
||||
WasmInstanceObject::GetOrCreateDebugInfo(instance);
|
||||
WasmDebugInfo::SetBreakpoint(debug_info, func_index, offset_in_func);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WasmModuleObject::ValidateStateForTesting(
|
||||
Isolate* isolate, Handle<WasmModuleObject> module_obj) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
WasmCompiledModule* compiled_module = module_obj->compiled_module();
|
||||
CHECK(!compiled_module->has_prev_instance());
|
||||
CHECK(!compiled_module->has_next_instance());
|
||||
CHECK(!compiled_module->has_instance());
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
int GetBreakpointPos(Isolate* isolate, Object* break_point_info_or_undef) {
|
||||
@ -1305,8 +1201,7 @@ Handle<WasmDebugInfo> WasmInstanceObject::GetOrCreateDebugInfo(
|
||||
}
|
||||
|
||||
Handle<WasmInstanceObject> WasmInstanceObject::New(
|
||||
Isolate* isolate, Handle<WasmModuleObject> module_object,
|
||||
Handle<WasmCompiledModule> compiled_module) {
|
||||
Isolate* isolate, Handle<WasmModuleObject> module_object) {
|
||||
Handle<JSFunction> instance_cons(
|
||||
isolate->native_context()->wasm_instance_constructor(), isolate);
|
||||
Handle<JSObject> instance_object =
|
||||
@ -1345,36 +1240,22 @@ Handle<WasmInstanceObject> WasmInstanceObject::New(
|
||||
instance->set_indirect_function_table_size(0);
|
||||
instance->set_indirect_function_table_sig_ids(nullptr);
|
||||
instance->set_indirect_function_table_targets(nullptr);
|
||||
instance->set_compiled_module(*compiled_module);
|
||||
instance->set_native_context(*isolate->native_context());
|
||||
instance->set_module_object(*module_object);
|
||||
instance->set_undefined_value(isolate->heap()->undefined_value());
|
||||
instance->set_null_value(isolate->heap()->null_value());
|
||||
|
||||
return instance;
|
||||
}
|
||||
// Insert the new instance into the modules weak list of instances.
|
||||
// TODO(mstarzinger): Allow to reuse holes in the {WeakArrayList} below.
|
||||
Handle<WeakArrayList> weak_instance_list(module_object->weak_instance_list(),
|
||||
isolate);
|
||||
weak_instance_list = WeakArrayList::AddToEnd(
|
||||
weak_instance_list,
|
||||
MaybeObjectHandle(
|
||||
MaybeObject::MakeWeak(MaybeObject::FromObject(*instance)), isolate));
|
||||
module_object->set_weak_instance_list(*weak_instance_list);
|
||||
|
||||
void WasmInstanceObject::ValidateInstancesChainForTesting(
|
||||
Isolate* isolate, Handle<WasmModuleObject> module_obj, int instance_count) {
|
||||
CHECK_GE(instance_count, 0);
|
||||
DisallowHeapAllocation no_gc;
|
||||
WasmCompiledModule* compiled_module = module_obj->compiled_module();
|
||||
Object* prev = nullptr;
|
||||
int found_instances = compiled_module->has_instance() ? 1 : 0;
|
||||
WasmCompiledModule* current_instance = compiled_module;
|
||||
while (current_instance->has_next_instance()) {
|
||||
CHECK((prev == nullptr && !current_instance->has_prev_instance()) ||
|
||||
current_instance->prev_instance() == prev);
|
||||
CHECK(current_instance->weak_owning_instance()
|
||||
->value()
|
||||
->IsWasmInstanceObject());
|
||||
prev = current_instance;
|
||||
current_instance =
|
||||
WasmCompiledModule::cast(current_instance->next_instance());
|
||||
++found_instances;
|
||||
CHECK_LE(found_instances, instance_count);
|
||||
}
|
||||
CHECK_EQ(found_instances, instance_count);
|
||||
return instance;
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -1385,7 +1266,6 @@ void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) {
|
||||
Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
|
||||
// If a link to shared memory instances exists, update the list of memory
|
||||
// instances before the instance is destroyed.
|
||||
WasmCompiledModule* compiled_module = instance->compiled_module();
|
||||
TRACE("Finalizing %zu {\n",
|
||||
instance->module_object()->native_module()->instance_id);
|
||||
|
||||
@ -1401,24 +1281,9 @@ void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) {
|
||||
handle(instance, isolate));
|
||||
}
|
||||
|
||||
// We want to maintain a link from the {WasmModuleObject} to the first link
|
||||
// within the linked {WasmInstanceObject} list, even if the last instance is
|
||||
// finalized. This allows us to clone new {WasmCompiledModule} objects during
|
||||
// instantiation without having to regenerate the compiled module.
|
||||
WasmModuleObject* module_object = instance->module_object();
|
||||
WasmCompiledModule* current_template = module_object->compiled_module();
|
||||
DCHECK(!current_template->has_prev_instance());
|
||||
if (current_template == compiled_module) {
|
||||
if (compiled_module->has_next_instance()) {
|
||||
module_object->set_compiled_module(compiled_module->next_instance());
|
||||
}
|
||||
}
|
||||
|
||||
// Free raw C++ memory associated with the instance.
|
||||
GetNativeAllocations(instance)->free();
|
||||
|
||||
compiled_module->RemoveFromChain(isolate);
|
||||
|
||||
GlobalHandles::Destroy(reinterpret_cast<Object**>(p));
|
||||
TRACE("}\n");
|
||||
}
|
||||
@ -1496,44 +1361,6 @@ Address WasmExportedFunction::GetWasmCallTarget() {
|
||||
return instance()->GetCallTarget(function_index());
|
||||
}
|
||||
|
||||
Handle<WasmCompiledModule> WasmCompiledModule::New(Isolate* isolate) {
|
||||
Handle<WasmCompiledModule> compiled_module = Handle<WasmCompiledModule>::cast(
|
||||
isolate->factory()->NewStruct(WASM_COMPILED_MODULE_TYPE, TENURED));
|
||||
compiled_module->set_weak_owning_instance(isolate->heap()->empty_weak_cell());
|
||||
return compiled_module;
|
||||
}
|
||||
|
||||
Handle<WasmCompiledModule> WasmCompiledModule::Clone(
|
||||
Isolate* isolate, Handle<WasmCompiledModule> module) {
|
||||
Handle<FixedArray> code_copy;
|
||||
Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast(
|
||||
isolate->factory()->NewStruct(WASM_COMPILED_MODULE_TYPE, TENURED));
|
||||
ret->set_weak_owning_instance(isolate->heap()->empty_weak_cell());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WasmCompiledModule::InsertInChain(WasmModuleObject* module) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
WasmCompiledModule* original = module->compiled_module();
|
||||
set_next_instance(original);
|
||||
original->set_prev_instance(this);
|
||||
}
|
||||
|
||||
void WasmCompiledModule::RemoveFromChain(Isolate* isolate) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
||||
Object* next = raw_next_instance();
|
||||
Object* prev = raw_prev_instance();
|
||||
|
||||
if (!prev->IsUndefined(isolate)) {
|
||||
WasmCompiledModule::cast(prev)->set_raw_next_instance(next);
|
||||
}
|
||||
if (!next->IsUndefined(isolate)) {
|
||||
WasmCompiledModule::cast(next)->set_raw_prev_instance(prev);
|
||||
}
|
||||
}
|
||||
|
||||
#undef TRACE
|
||||
#undef TRACE_IFT
|
||||
} // namespace internal
|
||||
|
@ -36,7 +36,6 @@ class BreakPoint;
|
||||
class JSArrayBuffer;
|
||||
class FixedArrayOfWeakCells;
|
||||
class SeqOneByteString;
|
||||
class WasmCompiledModule;
|
||||
class WasmDebugInfo;
|
||||
class WasmInstanceObject;
|
||||
|
||||
@ -107,11 +106,11 @@ class WasmModuleObject : public JSObject {
|
||||
|
||||
DECL_ACCESSORS(managed_native_module, Managed<wasm::NativeModule>)
|
||||
inline wasm::NativeModule* native_module();
|
||||
DECL_ACCESSORS(compiled_module, WasmCompiledModule)
|
||||
DECL_ACCESSORS(export_wrappers, FixedArray)
|
||||
DECL_ACCESSORS(managed_module, Managed<wasm::WasmModule>)
|
||||
inline wasm::WasmModule* module() const;
|
||||
DECL_ACCESSORS(script, Script)
|
||||
DECL_ACCESSORS(weak_instance_list, WeakArrayList)
|
||||
DECL_OPTIONAL_ACCESSORS(asm_js_offset_table, ByteArray)
|
||||
DECL_OPTIONAL_ACCESSORS(breakpoint_infos, FixedArray)
|
||||
inline void reset_breakpoint_infos();
|
||||
@ -123,10 +122,10 @@ class WasmModuleObject : public JSObject {
|
||||
// Layout description.
|
||||
#define WASM_MODULE_OBJECT_FIELDS(V) \
|
||||
V(kNativeModuleOffset, kPointerSize) \
|
||||
V(kCompiledModuleOffset, kPointerSize) \
|
||||
V(kExportWrappersOffset, kPointerSize) \
|
||||
V(kManagedModuleOffset, kPointerSize) \
|
||||
V(kScriptOffset, kPointerSize) \
|
||||
V(kWeakInstanceListOffset, kPointerSize) \
|
||||
V(kAsmJsOffsetTableOffset, kPointerSize) \
|
||||
V(kBreakPointInfosOffset, kPointerSize) \
|
||||
V(kSize, 0)
|
||||
@ -150,9 +149,6 @@ class WasmModuleObject : public JSObject {
|
||||
static bool SetBreakPoint(Handle<WasmModuleObject>, int* position,
|
||||
Handle<BreakPoint> break_point);
|
||||
|
||||
static void ValidateStateForTesting(Isolate* isolate,
|
||||
Handle<WasmModuleObject> module);
|
||||
|
||||
// Check whether this module was generated from asm.js source.
|
||||
inline bool is_asm_js();
|
||||
|
||||
@ -374,7 +370,6 @@ class WasmInstanceObject : public JSObject {
|
||||
public:
|
||||
DECL_CAST(WasmInstanceObject)
|
||||
|
||||
DECL_ACCESSORS(compiled_module, WasmCompiledModule)
|
||||
DECL_ACCESSORS(module_object, WasmModuleObject)
|
||||
DECL_ACCESSORS(exports_object, JSObject)
|
||||
DECL_ACCESSORS(native_context, Context)
|
||||
@ -408,7 +403,6 @@ class WasmInstanceObject : public JSObject {
|
||||
|
||||
// Layout description.
|
||||
#define WASM_INSTANCE_OBJECT_FIELDS(V) \
|
||||
V(kCompiledModuleOffset, kPointerSize) \
|
||||
V(kModuleObjectOffset, kPointerSize) \
|
||||
V(kExportsObjectOffset, kPointerSize) \
|
||||
V(kNativeContextOffset, kPointerSize) \
|
||||
@ -456,12 +450,7 @@ class WasmInstanceObject : public JSObject {
|
||||
// If no debug info exists yet, it is created automatically.
|
||||
static Handle<WasmDebugInfo> GetOrCreateDebugInfo(Handle<WasmInstanceObject>);
|
||||
|
||||
static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmModuleObject>,
|
||||
Handle<WasmCompiledModule>);
|
||||
|
||||
static void ValidateInstancesChainForTesting(
|
||||
Isolate* isolate, Handle<WasmModuleObject> module_obj,
|
||||
int instance_count);
|
||||
static Handle<WasmInstanceObject> New(Isolate*, Handle<WasmModuleObject>);
|
||||
|
||||
static void InstallFinalizer(Isolate* isolate,
|
||||
Handle<WasmInstanceObject> instance);
|
||||
@ -519,73 +508,6 @@ class WasmExportedFunctionData : public Struct {
|
||||
#undef WASM_EXPORTED_FUNCTION_DATA_FIELDS
|
||||
};
|
||||
|
||||
// This represents the set of wasm compiled functions, together
|
||||
// with all the information necessary for re-specializing them.
|
||||
class WasmCompiledModule : public Struct {
|
||||
public:
|
||||
DECL_CAST(WasmCompiledModule)
|
||||
|
||||
// Dispatched behavior.
|
||||
DECL_PRINTER(WasmCompiledModule)
|
||||
DECL_VERIFIER(WasmCompiledModule)
|
||||
|
||||
// Layout description.
|
||||
#define WASM_COMPILED_MODULE_FIELDS(V) \
|
||||
V(kNextInstanceOffset, kPointerSize) \
|
||||
V(kPrevInstanceOffset, kPointerSize) \
|
||||
V(kOwningInstanceOffset, kPointerSize) \
|
||||
V(kSize, 0)
|
||||
|
||||
DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
|
||||
WASM_COMPILED_MODULE_FIELDS)
|
||||
#undef WASM_COMPILED_MODULE_FIELDS
|
||||
|
||||
#define WCM_OBJECT_OR_WEAK(TYPE, NAME, SETTER_MODIFIER) \
|
||||
public: \
|
||||
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_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, public)
|
||||
|
||||
#define WCM_CONST_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, private)
|
||||
|
||||
#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.
|
||||
WCM_CONST_OBJECT(WasmCompiledModule, next_instance)
|
||||
WCM_CONST_OBJECT(WasmCompiledModule, prev_instance)
|
||||
WCM_WEAK_LINK(WasmInstanceObject, owning_instance)
|
||||
|
||||
public:
|
||||
static Handle<WasmCompiledModule> New(Isolate* isolate);
|
||||
|
||||
static Handle<WasmCompiledModule> Clone(Isolate* isolate,
|
||||
Handle<WasmCompiledModule> module);
|
||||
|
||||
bool has_instance() const;
|
||||
|
||||
void InsertInChain(WasmModuleObject*);
|
||||
void RemoveFromChain(Isolate* isolate);
|
||||
|
||||
DECL_ACCESSORS(raw_next_instance, Object);
|
||||
DECL_ACCESSORS(raw_prev_instance, Object);
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule);
|
||||
};
|
||||
|
||||
class WasmDebugInfo : public Struct {
|
||||
public:
|
||||
DECL_ACCESSORS(wasm_instance, WasmInstanceObject)
|
||||
@ -681,11 +603,6 @@ class WasmDebugInfo : public Struct {
|
||||
};
|
||||
|
||||
#undef DECL_OPTIONAL_ACCESSORS
|
||||
#undef WCM_CONST_OBJECT
|
||||
#undef WCM_LARGE_NUMBER
|
||||
#undef WCM_OBJECT
|
||||
#undef WCM_OBJECT_OR_WEAK
|
||||
#undef WCM_WEAK_LINK
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -120,8 +120,6 @@ void SetBreakpoint(WasmRunnerBase& runner, int function_index, int byte_offset,
|
||||
int code_offset = func_offset + byte_offset;
|
||||
if (expected_set_byte_offset == -1) expected_set_byte_offset = byte_offset;
|
||||
Handle<WasmInstanceObject> instance = runner.builder().instance_object();
|
||||
Handle<WasmCompiledModule> compiled_module(instance->compiled_module(),
|
||||
runner.main_isolate());
|
||||
Handle<WasmModuleObject> module_object(instance->module_object(),
|
||||
runner.main_isolate());
|
||||
static int break_index = 0;
|
||||
|
@ -154,10 +154,6 @@ class WasmSerializationTest {
|
||||
Handle<WasmModuleObject> module_object =
|
||||
maybe_module_object.ToHandleChecked();
|
||||
|
||||
Handle<WasmCompiledModule> compiled_module(
|
||||
module_object->compiled_module(), serialization_isolate);
|
||||
Handle<FixedArray> export_wrappers(module_object->export_wrappers(),
|
||||
serialization_isolate);
|
||||
v8::Local<v8::Object> v8_module_obj =
|
||||
v8::Utils::ToLocal(Handle<JSObject>::cast(module_object));
|
||||
CHECK(v8_module_obj->IsWebAssemblyCompiledModule());
|
||||
|
@ -224,20 +224,14 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
|
||||
Handle<WasmModuleObject> module_object =
|
||||
WasmModuleObject::New(isolate_, export_wrappers, test_module_, env,
|
||||
nullptr, 0, script, Handle<ByteArray>::null());
|
||||
Handle<WasmCompiledModule> compiled_module(module_object->compiled_module(),
|
||||
isolate_);
|
||||
// This method is called when we initialize TestEnvironment. We don't
|
||||
// have a memory yet, so we won't create it here. We'll update the
|
||||
// interpreter when we get a memory. We do have globals, though.
|
||||
native_module_ = module_object->native_module();
|
||||
native_module_->ReserveCodeTableForTesting(kMaxFunctions);
|
||||
|
||||
DCHECK(compiled_module->IsWasmCompiledModule());
|
||||
auto instance =
|
||||
WasmInstanceObject::New(isolate_, module_object, compiled_module);
|
||||
auto instance = WasmInstanceObject::New(isolate_, module_object);
|
||||
instance->set_globals_start(globals_data_);
|
||||
Handle<WeakCell> weak_instance = isolate()->factory()->NewWeakCell(instance);
|
||||
compiled_module->set_weak_owning_instance(*weak_instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ struct ManuallyImportedJSFunction {
|
||||
|
||||
// A Wasm module builder. Globals are pre-set, however, memory and code may be
|
||||
// progressively added by a test. In turn, we piecemeal update the runtime
|
||||
// objects, i.e. {WasmInstanceObject}, {WasmCompiledModule} and, if necessary,
|
||||
// objects, i.e. {WasmInstanceObject}, {WasmModuleObject} and, if necessary,
|
||||
// the interpreter.
|
||||
class TestingModuleBuilder {
|
||||
public:
|
||||
|
@ -27,23 +27,21 @@ var instance4;
|
||||
]).exportFunc();
|
||||
|
||||
module = new WebAssembly.Module(builder.toBuffer());
|
||||
print("Initial module");
|
||||
%ValidateWasmModuleState(module);
|
||||
|
||||
print("Initial instances=0");
|
||||
%ValidateWasmInstancesChain(module, 0);
|
||||
assertEquals(0, %WasmGetNumberOfInstances(module));
|
||||
instance1 = new WebAssembly.Instance(module, {"": {getValue: () => 1}});
|
||||
|
||||
print("Initial instances=1");
|
||||
%ValidateWasmInstancesChain(module, 1);
|
||||
assertEquals(1, %WasmGetNumberOfInstances(module));
|
||||
instance2 = new WebAssembly.Instance(module, {"": {getValue: () => 2}});
|
||||
|
||||
print("Initial instances=2");
|
||||
%ValidateWasmInstancesChain(module, 2);
|
||||
assertEquals(2, %WasmGetNumberOfInstances(module));
|
||||
instance3 = new WebAssembly.Instance(module, {"": {getValue: () => 3}});
|
||||
|
||||
print("Initial instances=3");
|
||||
%ValidateWasmInstancesChain(module, 3);
|
||||
assertEquals(3, %WasmGetNumberOfInstances(module));
|
||||
})();
|
||||
|
||||
(function CompiledModuleInstancesClear1() {
|
||||
@ -51,30 +49,33 @@ var instance4;
|
||||
instance1 = null;
|
||||
})();
|
||||
|
||||
// Note that two GC's are required because weak slots clearing is deferred.
|
||||
gc();
|
||||
gc();
|
||||
print("After gc instances=2");
|
||||
%ValidateWasmInstancesChain(module, 2);
|
||||
assertEquals(2, %WasmGetNumberOfInstances(module));
|
||||
|
||||
(function CompiledModuleInstancesClear3() {
|
||||
assertEquals(3, instance3.exports.f());
|
||||
instance3 = null;
|
||||
})();
|
||||
|
||||
// Note that two GC's are required because weak slots clearing is deferred.
|
||||
gc();
|
||||
gc();
|
||||
print("After gc instances=1");
|
||||
%ValidateWasmInstancesChain(module, 1);
|
||||
assertEquals(1, %WasmGetNumberOfInstances(module));
|
||||
|
||||
(function CompiledModuleInstancesClear2() {
|
||||
assertEquals(2, instance2.exports.f());
|
||||
instance2 = null;
|
||||
})();
|
||||
|
||||
// Note that two GC's are required because weak cells are not cleared
|
||||
// in the same cycle that the instance finalizer is run.
|
||||
// Note that two GC's are required because weak slots clearing is deferred.
|
||||
gc();
|
||||
gc();
|
||||
print("After gc module state");
|
||||
%ValidateWasmModuleState(module);
|
||||
print("After gc instances=0");
|
||||
assertEquals(0, %WasmGetNumberOfInstances(module));
|
||||
|
||||
(function CompiledModuleInstancesInitialize4AndClearModule() {
|
||||
instance4 = new WebAssembly.Instance(module, {"": {getValue: () => 4}});
|
||||
@ -82,6 +83,6 @@ print("After gc module state");
|
||||
module = null;
|
||||
})();
|
||||
|
||||
// Note that the first GC will clear the module, the second the instance.
|
||||
// Note that two GC's are required because weak slots clearing is deferred.
|
||||
gc();
|
||||
gc();
|
||||
|
@ -74,46 +74,45 @@ INSTANCE_TYPES = {
|
||||
170: "STACK_FRAME_INFO_TYPE",
|
||||
171: "TUPLE2_TYPE",
|
||||
172: "TUPLE3_TYPE",
|
||||
173: "WASM_COMPILED_MODULE_TYPE",
|
||||
174: "WASM_DEBUG_INFO_TYPE",
|
||||
175: "WASM_EXPORTED_FUNCTION_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: "ALLOCATION_SITE_TYPE",
|
||||
182: "FIXED_ARRAY_TYPE",
|
||||
183: "BOILERPLATE_DESCRIPTION_TYPE",
|
||||
184: "HASH_TABLE_TYPE",
|
||||
185: "EPHEMERON_HASH_TABLE_TYPE",
|
||||
186: "SCOPE_INFO_TYPE",
|
||||
187: "BLOCK_CONTEXT_TYPE",
|
||||
188: "CATCH_CONTEXT_TYPE",
|
||||
189: "DEBUG_EVALUATE_CONTEXT_TYPE",
|
||||
190: "EVAL_CONTEXT_TYPE",
|
||||
191: "FUNCTION_CONTEXT_TYPE",
|
||||
192: "MODULE_CONTEXT_TYPE",
|
||||
193: "NATIVE_CONTEXT_TYPE",
|
||||
194: "SCRIPT_CONTEXT_TYPE",
|
||||
195: "WITH_CONTEXT_TYPE",
|
||||
196: "WEAK_FIXED_ARRAY_TYPE",
|
||||
197: "DESCRIPTOR_ARRAY_TYPE",
|
||||
198: "TRANSITION_ARRAY_TYPE",
|
||||
199: "CALL_HANDLER_INFO_TYPE",
|
||||
200: "CELL_TYPE",
|
||||
201: "CODE_DATA_CONTAINER_TYPE",
|
||||
202: "FEEDBACK_CELL_TYPE",
|
||||
203: "FEEDBACK_VECTOR_TYPE",
|
||||
204: "LOAD_HANDLER_TYPE",
|
||||
205: "PROPERTY_ARRAY_TYPE",
|
||||
206: "PROPERTY_CELL_TYPE",
|
||||
207: "SHARED_FUNCTION_INFO_TYPE",
|
||||
208: "SMALL_ORDERED_HASH_MAP_TYPE",
|
||||
209: "SMALL_ORDERED_HASH_SET_TYPE",
|
||||
210: "STORE_HANDLER_TYPE",
|
||||
211: "WEAK_CELL_TYPE",
|
||||
212: "WEAK_ARRAY_LIST_TYPE",
|
||||
173: "WASM_DEBUG_INFO_TYPE",
|
||||
174: "WASM_EXPORTED_FUNCTION_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: "ALLOCATION_SITE_TYPE",
|
||||
181: "FIXED_ARRAY_TYPE",
|
||||
182: "BOILERPLATE_DESCRIPTION_TYPE",
|
||||
183: "HASH_TABLE_TYPE",
|
||||
184: "EPHEMERON_HASH_TABLE_TYPE",
|
||||
185: "SCOPE_INFO_TYPE",
|
||||
186: "BLOCK_CONTEXT_TYPE",
|
||||
187: "CATCH_CONTEXT_TYPE",
|
||||
188: "DEBUG_EVALUATE_CONTEXT_TYPE",
|
||||
189: "EVAL_CONTEXT_TYPE",
|
||||
190: "FUNCTION_CONTEXT_TYPE",
|
||||
191: "MODULE_CONTEXT_TYPE",
|
||||
192: "NATIVE_CONTEXT_TYPE",
|
||||
193: "SCRIPT_CONTEXT_TYPE",
|
||||
194: "WITH_CONTEXT_TYPE",
|
||||
195: "WEAK_FIXED_ARRAY_TYPE",
|
||||
196: "DESCRIPTOR_ARRAY_TYPE",
|
||||
197: "TRANSITION_ARRAY_TYPE",
|
||||
198: "CALL_HANDLER_INFO_TYPE",
|
||||
199: "CELL_TYPE",
|
||||
200: "CODE_DATA_CONTAINER_TYPE",
|
||||
201: "FEEDBACK_CELL_TYPE",
|
||||
202: "FEEDBACK_VECTOR_TYPE",
|
||||
203: "LOAD_HANDLER_TYPE",
|
||||
204: "PROPERTY_ARRAY_TYPE",
|
||||
205: "PROPERTY_CELL_TYPE",
|
||||
206: "SHARED_FUNCTION_INFO_TYPE",
|
||||
207: "SMALL_ORDERED_HASH_MAP_TYPE",
|
||||
208: "SMALL_ORDERED_HASH_SET_TYPE",
|
||||
209: "STORE_HANDLER_TYPE",
|
||||
210: "WEAK_CELL_TYPE",
|
||||
211: "WEAK_ARRAY_LIST_TYPE",
|
||||
1024: "JS_PROXY_TYPE",
|
||||
1025: "JS_GLOBAL_OBJECT_TYPE",
|
||||
1026: "JS_GLOBAL_PROXY_TYPE",
|
||||
@ -163,9 +162,9 @@ KNOWN_MAPS = {
|
||||
("RO_SPACE", 0x02201): (138, "FreeSpaceMap"),
|
||||
("RO_SPACE", 0x02259): (132, "MetaMap"),
|
||||
("RO_SPACE", 0x022e1): (131, "NullMap"),
|
||||
("RO_SPACE", 0x02359): (197, "DescriptorArrayMap"),
|
||||
("RO_SPACE", 0x023c1): (182, "FixedArrayMap"),
|
||||
("RO_SPACE", 0x02429): (211, "WeakCellMap"),
|
||||
("RO_SPACE", 0x02359): (196, "DescriptorArrayMap"),
|
||||
("RO_SPACE", 0x023c1): (181, "FixedArrayMap"),
|
||||
("RO_SPACE", 0x02429): (210, "WeakCellMap"),
|
||||
("RO_SPACE", 0x024d1): (152, "OnePointerFillerMap"),
|
||||
("RO_SPACE", 0x02539): (152, "TwoPointerFillerMap"),
|
||||
("RO_SPACE", 0x025d1): (131, "UninitializedMap"),
|
||||
@ -175,62 +174,62 @@ KNOWN_MAPS = {
|
||||
("RO_SPACE", 0x02831): (131, "TheHoleMap"),
|
||||
("RO_SPACE", 0x028f9): (131, "BooleanMap"),
|
||||
("RO_SPACE", 0x02a09): (136, "ByteArrayMap"),
|
||||
("RO_SPACE", 0x02a71): (182, "FixedCOWArrayMap"),
|
||||
("RO_SPACE", 0x02ad9): (184, "HashTableMap"),
|
||||
("RO_SPACE", 0x02a71): (181, "FixedCOWArrayMap"),
|
||||
("RO_SPACE", 0x02ad9): (183, "HashTableMap"),
|
||||
("RO_SPACE", 0x02b41): (128, "SymbolMap"),
|
||||
("RO_SPACE", 0x02ba9): (72, "OneByteStringMap"),
|
||||
("RO_SPACE", 0x02c11): (186, "ScopeInfoMap"),
|
||||
("RO_SPACE", 0x02c79): (207, "SharedFunctionInfoMap"),
|
||||
("RO_SPACE", 0x02c11): (185, "ScopeInfoMap"),
|
||||
("RO_SPACE", 0x02c79): (206, "SharedFunctionInfoMap"),
|
||||
("RO_SPACE", 0x02ce1): (133, "CodeMap"),
|
||||
("RO_SPACE", 0x02d49): (191, "FunctionContextMap"),
|
||||
("RO_SPACE", 0x02db1): (200, "CellMap"),
|
||||
("RO_SPACE", 0x02e19): (206, "GlobalPropertyCellMap"),
|
||||
("RO_SPACE", 0x02d49): (190, "FunctionContextMap"),
|
||||
("RO_SPACE", 0x02db1): (199, "CellMap"),
|
||||
("RO_SPACE", 0x02e19): (205, "GlobalPropertyCellMap"),
|
||||
("RO_SPACE", 0x02e81): (135, "ForeignMap"),
|
||||
("RO_SPACE", 0x02ee9): (198, "TransitionArrayMap"),
|
||||
("RO_SPACE", 0x02f51): (203, "FeedbackVectorMap"),
|
||||
("RO_SPACE", 0x02ee9): (197, "TransitionArrayMap"),
|
||||
("RO_SPACE", 0x02f51): (202, "FeedbackVectorMap"),
|
||||
("RO_SPACE", 0x02ff9): (131, "ArgumentsMarkerMap"),
|
||||
("RO_SPACE", 0x030b9): (131, "ExceptionMap"),
|
||||
("RO_SPACE", 0x03179): (131, "TerminationExceptionMap"),
|
||||
("RO_SPACE", 0x03241): (131, "OptimizedOutMap"),
|
||||
("RO_SPACE", 0x03301): (131, "StaleRegisterMap"),
|
||||
("RO_SPACE", 0x03391): (193, "NativeContextMap"),
|
||||
("RO_SPACE", 0x033f9): (192, "ModuleContextMap"),
|
||||
("RO_SPACE", 0x03461): (190, "EvalContextMap"),
|
||||
("RO_SPACE", 0x034c9): (194, "ScriptContextMap"),
|
||||
("RO_SPACE", 0x03531): (187, "BlockContextMap"),
|
||||
("RO_SPACE", 0x03599): (188, "CatchContextMap"),
|
||||
("RO_SPACE", 0x03601): (195, "WithContextMap"),
|
||||
("RO_SPACE", 0x03669): (189, "DebugEvaluateContextMap"),
|
||||
("RO_SPACE", 0x036d1): (182, "ScriptContextTableMap"),
|
||||
("RO_SPACE", 0x03391): (192, "NativeContextMap"),
|
||||
("RO_SPACE", 0x033f9): (191, "ModuleContextMap"),
|
||||
("RO_SPACE", 0x03461): (189, "EvalContextMap"),
|
||||
("RO_SPACE", 0x034c9): (193, "ScriptContextMap"),
|
||||
("RO_SPACE", 0x03531): (186, "BlockContextMap"),
|
||||
("RO_SPACE", 0x03599): (187, "CatchContextMap"),
|
||||
("RO_SPACE", 0x03601): (194, "WithContextMap"),
|
||||
("RO_SPACE", 0x03669): (188, "DebugEvaluateContextMap"),
|
||||
("RO_SPACE", 0x036d1): (181, "ScriptContextTableMap"),
|
||||
("RO_SPACE", 0x03739): (151, "FeedbackMetadataArrayMap"),
|
||||
("RO_SPACE", 0x037a1): (182, "ArrayListMap"),
|
||||
("RO_SPACE", 0x037a1): (181, "ArrayListMap"),
|
||||
("RO_SPACE", 0x03809): (130, "BigIntMap"),
|
||||
("RO_SPACE", 0x03871): (183, "BoilerplateDescriptionMap"),
|
||||
("RO_SPACE", 0x03871): (182, "BoilerplateDescriptionMap"),
|
||||
("RO_SPACE", 0x038d9): (137, "BytecodeArrayMap"),
|
||||
("RO_SPACE", 0x03941): (201, "CodeDataContainerMap"),
|
||||
("RO_SPACE", 0x03941): (200, "CodeDataContainerMap"),
|
||||
("RO_SPACE", 0x039a9): (150, "FixedDoubleArrayMap"),
|
||||
("RO_SPACE", 0x03a11): (184, "GlobalDictionaryMap"),
|
||||
("RO_SPACE", 0x03a79): (202, "ManyClosuresCellMap"),
|
||||
("RO_SPACE", 0x03ae1): (182, "ModuleInfoMap"),
|
||||
("RO_SPACE", 0x03a11): (183, "GlobalDictionaryMap"),
|
||||
("RO_SPACE", 0x03a79): (201, "ManyClosuresCellMap"),
|
||||
("RO_SPACE", 0x03ae1): (181, "ModuleInfoMap"),
|
||||
("RO_SPACE", 0x03b49): (134, "MutableHeapNumberMap"),
|
||||
("RO_SPACE", 0x03bb1): (184, "NameDictionaryMap"),
|
||||
("RO_SPACE", 0x03c19): (202, "NoClosuresCellMap"),
|
||||
("RO_SPACE", 0x03c81): (184, "NumberDictionaryMap"),
|
||||
("RO_SPACE", 0x03ce9): (202, "OneClosureCellMap"),
|
||||
("RO_SPACE", 0x03d51): (184, "OrderedHashMapMap"),
|
||||
("RO_SPACE", 0x03db9): (184, "OrderedHashSetMap"),
|
||||
("RO_SPACE", 0x03e21): (205, "PropertyArrayMap"),
|
||||
("RO_SPACE", 0x03e89): (199, "SideEffectCallHandlerInfoMap"),
|
||||
("RO_SPACE", 0x03ef1): (199, "SideEffectFreeCallHandlerInfoMap"),
|
||||
("RO_SPACE", 0x03f59): (199, "NextCallSideEffectFreeCallHandlerInfoMap"),
|
||||
("RO_SPACE", 0x03fc1): (184, "SimpleNumberDictionaryMap"),
|
||||
("RO_SPACE", 0x04029): (182, "SloppyArgumentsElementsMap"),
|
||||
("RO_SPACE", 0x04091): (208, "SmallOrderedHashMapMap"),
|
||||
("RO_SPACE", 0x040f9): (209, "SmallOrderedHashSetMap"),
|
||||
("RO_SPACE", 0x04161): (184, "StringTableMap"),
|
||||
("RO_SPACE", 0x041c9): (196, "WeakFixedArrayMap"),
|
||||
("RO_SPACE", 0x04231): (212, "WeakArrayListMap"),
|
||||
("RO_SPACE", 0x04299): (185, "EphemeronHashTableMap"),
|
||||
("RO_SPACE", 0x03bb1): (183, "NameDictionaryMap"),
|
||||
("RO_SPACE", 0x03c19): (201, "NoClosuresCellMap"),
|
||||
("RO_SPACE", 0x03c81): (183, "NumberDictionaryMap"),
|
||||
("RO_SPACE", 0x03ce9): (201, "OneClosureCellMap"),
|
||||
("RO_SPACE", 0x03d51): (183, "OrderedHashMapMap"),
|
||||
("RO_SPACE", 0x03db9): (183, "OrderedHashSetMap"),
|
||||
("RO_SPACE", 0x03e21): (204, "PropertyArrayMap"),
|
||||
("RO_SPACE", 0x03e89): (198, "SideEffectCallHandlerInfoMap"),
|
||||
("RO_SPACE", 0x03ef1): (198, "SideEffectFreeCallHandlerInfoMap"),
|
||||
("RO_SPACE", 0x03f59): (198, "NextCallSideEffectFreeCallHandlerInfoMap"),
|
||||
("RO_SPACE", 0x03fc1): (183, "SimpleNumberDictionaryMap"),
|
||||
("RO_SPACE", 0x04029): (181, "SloppyArgumentsElementsMap"),
|
||||
("RO_SPACE", 0x04091): (207, "SmallOrderedHashMapMap"),
|
||||
("RO_SPACE", 0x040f9): (208, "SmallOrderedHashSetMap"),
|
||||
("RO_SPACE", 0x04161): (183, "StringTableMap"),
|
||||
("RO_SPACE", 0x041c9): (195, "WeakFixedArrayMap"),
|
||||
("RO_SPACE", 0x04231): (211, "WeakArrayListMap"),
|
||||
("RO_SPACE", 0x04299): (184, "EphemeronHashTableMap"),
|
||||
("RO_SPACE", 0x04301): (106, "NativeSourceStringMap"),
|
||||
("RO_SPACE", 0x04369): (64, "StringMap"),
|
||||
("RO_SPACE", 0x043d1): (73, "ConsOneByteStringMap"),
|
||||
@ -284,16 +283,15 @@ KNOWN_MAPS = {
|
||||
("RO_SPACE", 0x0a519): (168, "PrototypeInfoMap"),
|
||||
("RO_SPACE", 0x0a581): (170, "StackFrameInfoMap"),
|
||||
("RO_SPACE", 0x0a5e9): (172, "Tuple3Map"),
|
||||
("RO_SPACE", 0x0a651): (173, "WasmCompiledModuleMap"),
|
||||
("RO_SPACE", 0x0a6b9): (174, "WasmDebugInfoMap"),
|
||||
("RO_SPACE", 0x0a721): (175, "WasmExportedFunctionDataMap"),
|
||||
("RO_SPACE", 0x0a789): (176, "CallableTaskMap"),
|
||||
("RO_SPACE", 0x0a7f1): (177, "CallbackTaskMap"),
|
||||
("RO_SPACE", 0x0a859): (178, "PromiseFulfillReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x0a8c1): (179, "PromiseRejectReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x0a929): (180, "PromiseResolveThenableJobTaskMap"),
|
||||
("RO_SPACE", 0x0a991): (181, "AllocationSiteMap"),
|
||||
("RO_SPACE", 0x0a9f9): (181, "AllocationSiteMap"),
|
||||
("RO_SPACE", 0x0a651): (173, "WasmDebugInfoMap"),
|
||||
("RO_SPACE", 0x0a6b9): (174, "WasmExportedFunctionDataMap"),
|
||||
("RO_SPACE", 0x0a721): (175, "CallableTaskMap"),
|
||||
("RO_SPACE", 0x0a789): (176, "CallbackTaskMap"),
|
||||
("RO_SPACE", 0x0a7f1): (177, "PromiseFulfillReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x0a859): (178, "PromiseRejectReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x0a8c1): (179, "PromiseResolveThenableJobTaskMap"),
|
||||
("RO_SPACE", 0x0a929): (180, "AllocationSiteMap"),
|
||||
("RO_SPACE", 0x0a991): (180, "AllocationSiteMap"),
|
||||
("MAP_SPACE", 0x02201): (1057, "ExternalMap"),
|
||||
("MAP_SPACE", 0x02259): (1072, "JSMessageObjectMap"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user