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

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

Issue 2005933003: [wasm] globals size is not a per-instance property. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-function-name-table.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/module-decoder.cc
diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc
index f7d26a5f85645835a23965d52e4cc45db8bd9f3e..417d71fbe71ab44db3deea0d1a6b67c4177fd774 100644
--- a/src/wasm/module-decoder.cc
+++ b/src/wasm/module-decoder.cc
@@ -419,7 +419,9 @@ class ModuleDecoder : public Decoder {
}
done:
- ModuleResult result = toResult(module);
+ CalculateGlobalsOffsets(module);
+ const WasmModule* finished_module = module;
+ ModuleResult result = toResult(finished_module);
if (FLAG_dump_wasm_module) {
DumpModule(module, result);
}
@@ -570,6 +572,22 @@ class ModuleDecoder : public Decoder {
consume_bytes(segment->source_size);
}
+ // Calculate individual global offsets and total size of globals table.
+ void CalculateGlobalsOffsets(WasmModule* module) {
+ uint32_t offset = 0;
+ if (module->globals.size() == 0) {
+ module->globals_size = 0;
+ return;
+ }
+ for (WasmGlobal& global : module->globals) {
+ byte size = WasmOpcodes::MemSize(global.type);
+ offset = (offset + size - 1) & ~(size - 1); // align
+ global.offset = offset;
+ offset += size;
+ }
+ module->globals_size = offset;
+ }
+
// Verifies the body (code) of a given function.
void VerifyFunctionBody(uint32_t func_num, ModuleEnv* menv,
WasmFunction* function) {
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-function-name-table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698