Index: src/wasm/wasm-js.cc |
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc |
index 254fd7061abf9363a390deec8a8b00d560d5f330..d971e8bebc0456da9d582d34fdd8ca3f4f1e312d 100644 |
--- a/src/wasm/wasm-js.cc |
+++ b/src/wasm/wasm-js.cc |
@@ -737,5 +737,22 @@ void WasmJs::InstallWasmMapsIfNeeded(Isolate* isolate, |
} |
} |
+bool WasmJs::IsWasmMemoryObject(Isolate* isolate, Handle<Object> value) { |
+ if (value->IsJSObject()) { |
+ i::Handle<i::JSObject> object = i::Handle<i::JSObject>::cast(value); |
+ i::Handle<i::Symbol> sym(isolate->context()->wasm_memory_sym(), isolate); |
+ Maybe<bool> has_brand = i::JSObject::HasOwnProperty(object, sym); |
ahaas
2016/10/07 08:23:36
Can sym also be further up the prototype chain? If
titzer
2016/10/07 08:50:52
Definitely don't want to go up the prototype chain
|
+ if (has_brand.IsNothing()) return false; |
+ if (has_brand.ToChecked()) return true; |
+ } |
+ return false; |
+} |
+ |
+Handle<JSArrayBuffer> WasmJs::GetWasmMemoryArrayBuffer(Isolate* isolate, |
+ Handle<Object> value) { |
+ DCHECK(IsWasmMemoryObject(isolate, value)); |
+ Handle<Object> buf(JSObject::cast(*value)->GetInternalField(0), isolate); |
ahaas
2016/10/07 08:23:36
Could we use a constant for index 0?
titzer
2016/10/07 08:50:52
Done.
|
+ return Handle<JSArrayBuffer>::cast(buf); |
+} |
} // namespace internal |
} // namespace v8 |