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

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: Rebase 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 00d38ecfa960180e91d44cc5f2f042a6153180c2..d665380c03aa8715c68d2df714df50f5a60bc14e 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -1026,6 +1026,39 @@ WasmDebugInfo* GetDebugInfo(JSObject* wasm) {
return *new_info;
}
+bool UpdateWasmModuleMemory(JSObject* object, byte* old_start, byte* 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++) {
+ Handle<Code> code;
+ obj = code_table->get(i);
+ code = Handle<Code>(Code::cast(obj));
ahaas 2016/06/24 11:10:15 Why don't you just say Handle<Code> code(Code::cas
gdeepti 2016/06/25 00:28:41 Done.
+
+ 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(
+ reinterpret_cast<Address>(old_start),
+ reinterpret_cast<Address>(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