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

Side by Side 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: Ben's review, fix includes 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/atomic-utils.h" 5 #include "src/base/atomic-utils.h"
6 #include "src/macro-assembler.h" 6 #include "src/macro-assembler.h"
7 #include "src/objects.h" 7 #include "src/objects.h"
8 #include "src/property-descriptor.h" 8 #include "src/property-descriptor.h"
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 bool IsWasmObject(Handle<JSObject> object) { 996 bool IsWasmObject(Handle<JSObject> object) {
997 // TODO(clemensh): Check wasm byte header once we store a copy of the bytes. 997 // TODO(clemensh): Check wasm byte header once we store a copy of the bytes.
998 return object->GetInternalFieldCount() == kWasmModuleInternalFieldCount && 998 return object->GetInternalFieldCount() == kWasmModuleInternalFieldCount &&
999 object->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() && 999 object->GetInternalField(kWasmModuleCodeTable)->IsFixedArray() &&
1000 object->GetInternalField(kWasmMemArrayBuffer)->IsJSArrayBuffer() && 1000 object->GetInternalField(kWasmMemArrayBuffer)->IsJSArrayBuffer() &&
1001 (object->GetInternalField(kWasmFunctionNamesArray)->IsByteArray() || 1001 (object->GetInternalField(kWasmFunctionNamesArray)->IsByteArray() ||
1002 object->GetInternalField(kWasmFunctionNamesArray) 1002 object->GetInternalField(kWasmFunctionNamesArray)
1003 ->IsUndefined(object->GetIsolate())); 1003 ->IsUndefined(object->GetIsolate()));
1004 } 1004 }
1005 1005
1006 bool UpdateWasmModuleMemory(Handle<JSObject> object, byte* old_start,
1007 byte* new_start, uint32_t old_size,
1008 uint32_t new_size) {
1009 if (!IsWasmObject(object)) {
1010 return false;
1011 }
1012
1013 // Get code table associated with the module js_object
1014 Object* obj = object->GetInternalField(kWasmModuleCodeTable);
1015 Handle<FixedArray> code_table;
1016 code_table = Handle<FixedArray>(FixedArray::cast(obj));
1017
1018 // Iterate through the code objects in the code table and update relocation
1019 // information
1020 for (int i = 0; i < code_table->length(); i++) {
1021 Handle<Code> code;
1022 obj = code_table->get(i);
1023 code = Handle<Code>(Code::cast(obj));
1024
1025 int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) |
1026 RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
1027 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
1028 RelocInfo::Mode mode = it.rinfo()->rmode();
1029 if (RelocInfo::IsWasmMemoryReference(mode) ||
1030 RelocInfo::IsWasmMemorySizeReference(mode)) {
1031 it.rinfo()->update_wasm_memory_reference(
1032 reinterpret_cast<Address>(old_start),
1033 reinterpret_cast<Address>(new_start), old_size, new_size);
1034 }
1035 }
1036 }
1037 return true;
1038 }
1039
1006 } // namespace wasm 1040 } // namespace wasm
1007 } // namespace internal 1041 } // namespace internal
1008 } // namespace v8 1042 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698