Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: src/wasm/wasm-objects.cc

Issue 2512323004: Revert of [wasm] WebAssembly.Memory object can be referenced by multiple Instance objects. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-objects.h ('k') | test/mjsunit/wasm/import-memory.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-objects.cc
diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc
index 53e432f0ebb2ac46bd2fc6962b22a680d7d3fa24..592892cfcb2fb39fcadfb1ff6b07661bb8301789 100644
--- a/src/wasm/wasm-objects.cc
+++ b/src/wasm/wasm-objects.cc
@@ -184,8 +184,6 @@
}
DEFINE_ACCESSORS(WasmMemoryObject, buffer, kArrayBuffer, JSArrayBuffer)
-DEFINE_OPTIONAL_ACCESSORS(WasmMemoryObject, instances_link, kInstancesLink,
- WasmInstanceWrapper)
uint32_t WasmMemoryObject::current_pages() {
return SafeUint32(get_buffer()->byte_length()) / wasm::WasmModule::kPageSize;
@@ -201,26 +199,10 @@
return reinterpret_cast<WasmMemoryObject*>(object);
}
-void WasmMemoryObject::AddInstance(Isolate* isolate,
- Handle<WasmInstanceObject> instance) {
- Handle<WasmInstanceWrapper> instance_wrapper;
- if (has_instances_link()) {
- Handle<WasmInstanceWrapper> current_wrapper(get_instances_link());
- DCHECK(WasmInstanceWrapper::IsWasmInstanceWrapper(*current_wrapper));
- DCHECK(!current_wrapper->has_previous());
- instance_wrapper = WasmInstanceWrapper::New(isolate, instance);
- instance_wrapper->set_next_wrapper(*current_wrapper);
- current_wrapper->set_previous_wrapper(*instance_wrapper);
- } else {
- instance_wrapper = WasmInstanceWrapper::New(isolate, instance);
- }
- set_instances_link(*instance_wrapper);
- instance->set_instance_wrapper(*instance_wrapper);
-}
-
-void WasmMemoryObject::ResetInstancesLink(Isolate* isolate) {
- Handle<Object> undefined = isolate->factory()->undefined_value();
- SetInternalField(kInstancesLink, *undefined);
+void WasmMemoryObject::AddInstance(WasmInstanceObject* instance) {
+ // TODO(gdeepti): This should be a weak list of instance objects
+ // for instances that share memory.
+ SetInternalField(kInstance, instance);
}
DEFINE_ACCESSORS(WasmInstanceObject, compiled_module, kCompiledModule,
@@ -233,8 +215,6 @@
WasmMemoryObject)
DEFINE_OPTIONAL_ACCESSORS(WasmInstanceObject, debug_info, kDebugInfo,
WasmDebugInfo)
-DEFINE_OPTIONAL_ACCESSORS(WasmInstanceObject, instance_wrapper,
- kWasmMemInstanceWrapper, WasmInstanceWrapper)
WasmModuleObject* WasmInstanceObject::module_object() {
return WasmModuleObject::cast(*get_compiled_module()->wasm_module());
@@ -405,34 +385,3 @@
functions[func_index].code_start_offset);
return static_cast<int>(functions[func_index].code_start_offset);
}
-
-Handle<WasmInstanceWrapper> WasmInstanceWrapper::New(
- Isolate* isolate, Handle<WasmInstanceObject> instance) {
- Handle<FixedArray> array =
- isolate->factory()->NewFixedArray(kWrapperPropertyCount, TENURED);
- Handle<WasmInstanceWrapper> instance_wrapper(
- reinterpret_cast<WasmInstanceWrapper*>(*array), isolate);
- instance_wrapper->set_instance_object(instance, isolate);
- return instance_wrapper;
-}
-
-bool WasmInstanceWrapper::IsWasmInstanceWrapper(Object* obj) {
- if (!obj->IsFixedArray()) return false;
- FixedArray* array = FixedArray::cast(obj);
- if (array->length() != kWrapperPropertyCount) return false;
- if (!array->get(kWrapperInstanceObject)->IsWeakCell()) return false;
- Isolate* isolate = array->GetIsolate();
- if (!array->get(kNextInstanceWrapper)->IsUndefined(isolate) &&
- !array->get(kNextInstanceWrapper)->IsFixedArray())
- return false;
- if (!array->get(kPreviousInstanceWrapper)->IsUndefined(isolate) &&
- !array->get(kPreviousInstanceWrapper)->IsFixedArray())
- return false;
- return true;
-}
-
-void WasmInstanceWrapper::set_instance_object(Handle<JSObject> instance,
- Isolate* isolate) {
- Handle<WeakCell> cell = isolate->factory()->NewWeakCell(instance);
- set(kWrapperInstanceObject, *cell);
-}
« no previous file with comments | « src/wasm/wasm-objects.h ('k') | test/mjsunit/wasm/import-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698