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

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

Issue 2051043002: Implement Wasm GrowMemory opcode as a wasm runtime call (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review changes Created 4 years, 6 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-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 6e79397c26dfa8a4f62ce7c19b622b1f8799c0bd..e6c3955e232581b6650e454c2cc75f2a0032bc1c 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -1026,6 +1026,38 @@ WasmDebugInfo* GetDebugInfo(JSObject* wasm) {
return *new_info;
}
+bool UpdateWasmModuleMemory(JSObject* object, Address old_start,
+ Address new_start, uint32_t old_size,
+ uint32_t new_size) {
+ if (!IsWasmObject(object)) {
+ return false;
+ }
+
+ // Get code table associated with the module js_object
+ Object* obj = object->GetInternalField(kWasmModuleCodeTable);
+ Handle<FixedArray> code_table;
+ code_table = Handle<FixedArray>(FixedArray::cast(obj));
+
+ // Iterate through the code objects in the code table and update relocation
+ // information
+ for (int i = 0; i < code_table->length(); i++) {
+ obj = code_table->get(i);
+ Handle<Code> code(Code::cast(obj));
+
+ int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) |
+ RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
+ for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
+ RelocInfo::Mode mode = it.rinfo()->rmode();
+ if (RelocInfo::IsWasmMemoryReference(mode) ||
+ RelocInfo::IsWasmMemorySizeReference(mode)) {
+ it.rinfo()->update_wasm_memory_reference(old_start, new_start, old_size,
+ new_size);
+ }
+ }
+ }
+ return true;
+}
+
namespace testing {
int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,

Powered by Google App Engine
This is Rietveld 408576698