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

Unified Diff: src/assembler.cc

Issue 2349053002: [wasm] calculate wasm mem size base explicitly (Closed)
Patch Set: old_size Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/assembler.cc
diff --git a/src/assembler.cc b/src/assembler.cc
index e97b880ebc38dfabc49c87850047f82569e3be3a..feeef0c5729c380b784bd500dae810bf4e827515 100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -351,17 +351,18 @@ void RelocInfo::update_wasm_memory_reference(
DCHECK(IsWasmMemoryReference(rmode_) || IsWasmMemorySizeReference(rmode_));
if (IsWasmMemoryReference(rmode_)) {
Address updated_reference;
+ DCHECK_GE(wasm_memory_reference(), old_base);
updated_reference = new_base + (wasm_memory_reference() - old_base);
// The reference is not checked here but at runtime. Validity of references
// may change over time.
unchecked_update_wasm_memory_reference(updated_reference,
icache_flush_mode);
} else if (IsWasmMemorySizeReference(rmode_)) {
- uint32_t updated_size_reference;
- DCHECK(old_size == 0 || wasm_memory_size_reference() <= old_size);
- updated_size_reference =
- new_size + (wasm_memory_size_reference() - old_size);
- DCHECK(updated_size_reference <= new_size);
+ uint32_t current_size_reference = wasm_memory_size_reference();
+ DCHECK(old_size == 0 || current_size_reference <= old_size);
+ uint32_t offset = old_size - current_size_reference;
+ DCHECK_GE(new_size, offset);
gdeepti 2016/09/17 01:25:58 I'm confused by this check, could you explain why
Mircea Trofin 2016/09/17 01:40:03 If new_size < offset, then the calculation of upda
gdeepti 2016/09/17 02:24:20 Offset in this case is the offset into memory rela
Mircea Trofin 2016/09/19 18:15:49 It's just checking locally the assumption about th
+ uint32_t updated_size_reference = new_size - offset;
unchecked_update_wasm_memory_size(updated_size_reference,
icache_flush_mode);
} else {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698