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

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
« no previous file with comments | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-opcodes.h » ('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 ca0a9b932afa6009fee85c88f39a72058f7f23ac..db17a38a770b767dbd0f045fd91ff89b4047adbd 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -1026,6 +1026,37 @@ 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(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,
« no previous file with comments | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698