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

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

Issue 1538543002: Have WasmModule free it's own memory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years 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-module.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 17453dcfba36cfd23c9e7b3695c56861b653c2f2..fd2428080bed37ff77a6b7f89502f4e353454c9f 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -202,19 +202,36 @@ Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, int size,
#if DEBUG
// Double check the API allocator actually zero-initialized the memory.
- for (uint32_t i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
DCHECK_EQ(0, (*backing_store)[i]);
}
#endif
Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
- JSArrayBuffer::Setup(buffer, isolate, true, memory, size);
+ JSArrayBuffer::Setup(buffer, isolate, false, memory, size);
buffer->set_is_neuterable(false);
return buffer;
}
} // namespace
+WasmModule::WasmModule()
+ : globals(nullptr),
+ signatures(nullptr),
+ functions(nullptr),
+ data_segments(nullptr),
+ function_table(nullptr) {}
+
+
+WasmModule::~WasmModule() {
+ if (globals) delete globals;
+ if (signatures) delete signatures;
+ if (functions) delete functions;
+ if (data_segments) delete data_segments;
+ if (function_table) delete function_table;
+}
+
+
// Instantiates a wasm module as a JSObject.
// * allocates a backing store of {mem_size} bytes.
// * installs a named property "memory" for that buffer if exported
@@ -352,7 +369,7 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
}
if (func.exported) {
function = compiler::CompileJSToWasmWrapper(isolate, &module_env, name,
- code, index);
+ code, module, index);
}
}
if (!code.is_null()) {
@@ -478,7 +495,8 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module) {
simulator->Call(main_code->entry(), 4, 0, 0, 0, 0));
#else
// Run the main code as raw machine code.
- int32_t (*raw_func)() = reinterpret_cast<int (*)()>(main_code->entry());
+ int32_t (*raw_func)() = reinterpret_cast<int32_t (*)()>(
+ reinterpret_cast<uintptr_t>(main_code->entry()));
return raw_func();
#endif
} else {
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698