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

Unified Diff: src/wasm/wasm-module.h

Issue 2471883003: [wasm] WebAssembly.Memory object can be referenced by multiple Instance objects. (Closed)
Patch Set: Rebase, add Dcheck 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
Index: src/wasm/wasm-module.h
diff --git a/src/wasm/wasm-module.h b/src/wasm/wasm-module.h
index 3ac410476d7c6fc9a6a0752f1b7fccb5016a384d..3e159421c3342cdd699e8387ae59868c3d66f58f 100644
--- a/src/wasm/wasm-module.h
+++ b/src/wasm/wasm-module.h
@@ -554,14 +554,74 @@ Object* GetOwningWasmInstance(Code* code);
MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate,
Handle<JSObject> instance);
+void SetInstanceMemoryObject(Handle<JSObject> instance,
+ Handle<Object> mem_object);
+
int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance);
-int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance,
- uint32_t pages);
+int32_t GrowWebAssemblyMemory(Isolate* isolate, Handle<Object> memory_object,
+ uint32_t pages);
+
+int32_t GrowMemory(Isolate* isolate, Handle<JSObject> instance, uint32_t pages);
void UpdateDispatchTables(Isolate* isolate, Handle<FixedArray> dispatch_tables,
int index, Handle<JSFunction> js_function);
+class WasmInstanceWrapper : public FixedArray {
+ public:
+ static Handle<WasmInstanceWrapper> New(Isolate* isolate,
+ Handle<JSObject> instance);
+ static WasmInstanceWrapper* cast(Object* fixed_array) {
+ SLOW_DCHECK(IsWasmInstanceWrapper(fixed_array));
+ return reinterpret_cast<WasmInstanceWrapper*>(fixed_array);
+ }
+ static bool IsWasmInstanceWrapper(Object* obj);
+ bool has_instance() { return get(kWrapperInstanceObject)->IsWeakCell(); }
+ Handle<JSObject> instance_object() {
+ Object* obj = get(kWrapperInstanceObject);
+ DCHECK(obj->IsWeakCell());
+ WeakCell* cell = WeakCell::cast(obj);
+ DCHECK(cell->value()->IsJSObject());
+ return handle(JSObject::cast(cell->value()));
+ }
+ bool has_next() { return IsWasmInstanceWrapper(get(kNextInstanceWrapper)); }
+ bool has_previous() {
+ return IsWasmInstanceWrapper(get(kPreviousInstanceWrapper));
+ }
+ void set_instance_object(Handle<JSObject> instance, Isolate* isolate);
+ void set_next_wrapper(Object* obj) {
+ DCHECK(IsWasmInstanceWrapper(obj));
+ set(kNextInstanceWrapper, obj);
+ }
+ void set_previous_wrapper(Object* obj) {
+ DCHECK(IsWasmInstanceWrapper(obj));
+ set(kPreviousInstanceWrapper, obj);
+ }
+ Handle<WasmInstanceWrapper> next_wrapper() {
+ Object* obj = get(kNextInstanceWrapper);
+ DCHECK(IsWasmInstanceWrapper(obj));
+ return handle(WasmInstanceWrapper::cast(obj));
+ }
+ Handle<WasmInstanceWrapper> previous_wrapper() {
+ Object* obj = get(kPreviousInstanceWrapper);
+ DCHECK(IsWasmInstanceWrapper(obj));
+ return handle(WasmInstanceWrapper::cast(obj));
+ }
+ void reset_next_wrapper() { set_undefined(kNextInstanceWrapper); }
+ void reset_previous_wrapper() { set_undefined(kPreviousInstanceWrapper); }
+ void reset() {
+ for (int kID = 0; kID < kWrapperPropertyCount; kID++) set_undefined(kID);
+ }
+
+ private:
+ enum {
+ kWrapperInstanceObject,
+ kNextInstanceWrapper,
+ kPreviousInstanceWrapper,
+ kWrapperPropertyCount
+ };
+};
+
namespace testing {
void ValidateInstancesChain(Isolate* isolate, Handle<JSObject> wasm_module,

Powered by Google App Engine
This is Rietveld 408576698