| Index: src/wasm/wasm-module.cc
|
| diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
|
| index 07d2ef1113f725ea24bffd1efd64dbd4afa15999..10a12c9eb169b6605f95d0eb99f3197240c638a9 100644
|
| --- a/src/wasm/wasm-module.cc
|
| +++ b/src/wasm/wasm-module.cc
|
| @@ -1003,6 +1003,40 @@ bool IsWasmObject(Handle<JSObject> object) {
|
| ->IsUndefined(object->GetIsolate()));
|
| }
|
|
|
| +bool UpdateWasmModuleMemory(Handle<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));
|
| +
|
| + 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 wasm
|
| } // namespace internal
|
| } // namespace v8
|
|
|