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

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

Issue 2396433008: [wasm] Add guard regions to end of WebAssembly.Memory buffers (Closed)
Patch Set: Code review feedback Created 4 years, 2 months 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-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index 72482388ed3099febfe994aa1b7a968270c3ab1a..ea2be67e52ba7dcaeee5fcca87a14585bc1a841c 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -228,10 +228,12 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
i::Handle<i::JSArrayBuffer> memory = i::Handle<i::JSArrayBuffer>::null();
- if (args.Length() > 2 && args[2]->IsArrayBuffer()) {
+ if (args.Length() > 2 && args[2]->IsObject()) {
Mircea Trofin 2016/10/28 22:16:29 please separate support for WebAssembly.Memory in
Eric Holk 2016/10/29 00:04:30 Done: https://codereview.chromium.org/2460773003/
Local<Object> obj = Local<Object>::Cast(args[2]);
i::Handle<i::Object> mem_obj = v8::Utils::OpenHandle(*obj);
- memory = i::Handle<i::JSArrayBuffer>(i::JSArrayBuffer::cast(*mem_obj));
+ if (i::WasmJs::IsWasmMemoryObject(i_isolate, mem_obj)) {
+ memory = i::WasmJs::GetWasmMemoryArrayBuffer(i_isolate, mem_obj);
titzer 2016/10/28 16:24:57 Can we split out the WebAssembly.Memory requiremen
Eric Holk 2016/10/28 18:44:40 Sure. I'll add a couple more cases to make sure we
+ }
}
i::MaybeHandle<i::JSObject> instance =
i::wasm::WasmModule::Instantiate(i_isolate, &thrower, i_obj, ffi, memory);
@@ -363,11 +365,10 @@ void WebAssemblyMemory(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- i::Handle<i::JSArrayBuffer> buffer =
- i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared);
size_t size = static_cast<size_t>(i::wasm::WasmModule::kPageSize) *
static_cast<size_t>(initial);
- i::JSArrayBuffer::SetupAllocatingData(buffer, i_isolate, size);
+ i::Handle<i::JSArrayBuffer> buffer =
+ i::wasm::NewArrayBuffer(i_isolate, size, i::FLAG_wasm_guard_pages);
i::Handle<i::JSObject> memory_obj = i::WasmJs::CreateWasmMemoryObject(
i_isolate, buffer, has_maximum.FromJust(), maximum);
« no previous file with comments | « src/objects-inl.h ('k') | src/wasm/wasm-module.h » ('j') | src/wasm/wasm-module.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698