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

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: Review changes Created 4 years, 5 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
« no previous file with comments | « src/wasm/wasm-module.h ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 } 1019 }
1020 1020
1021 WasmDebugInfo* GetDebugInfo(JSObject* wasm) { 1021 WasmDebugInfo* GetDebugInfo(JSObject* wasm) {
1022 Object* info = wasm->GetInternalField(kWasmDebugInfo); 1022 Object* info = wasm->GetInternalField(kWasmDebugInfo);
1023 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info); 1023 if (!info->IsUndefined(wasm->GetIsolate())) return WasmDebugInfo::cast(info);
1024 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm)); 1024 Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(handle(wasm));
1025 wasm->SetInternalField(kWasmDebugInfo, *new_info); 1025 wasm->SetInternalField(kWasmDebugInfo, *new_info);
1026 return *new_info; 1026 return *new_info;
1027 } 1027 }
1028 1028
1029 bool UpdateWasmModuleMemory(JSObject* object, Address old_start,
1030 Address new_start, uint32_t old_size,
1031 uint32_t new_size) {
1032 if (!IsWasmObject(object)) {
1033 return false;
1034 }
1035
1036 // Get code table associated with the module js_object
1037 Object* obj = object->GetInternalField(kWasmModuleCodeTable);
1038 Handle<FixedArray> code_table(FixedArray::cast(obj));
1039
1040 // Iterate through the code objects in the code table and update relocation
1041 // information
1042 for (int i = 0; i < code_table->length(); i++) {
1043 obj = code_table->get(i);
1044 Handle<Code> code(Code::cast(obj));
1045
1046 int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) |
1047 RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
1048 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
1049 RelocInfo::Mode mode = it.rinfo()->rmode();
1050 if (RelocInfo::IsWasmMemoryReference(mode) ||
1051 RelocInfo::IsWasmMemorySizeReference(mode)) {
1052 it.rinfo()->update_wasm_memory_reference(old_start, new_start, old_size,
1053 new_size);
1054 }
1055 }
1056 }
1057 return true;
1058 }
1059
1029 namespace testing { 1060 namespace testing {
1030 1061
1031 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, 1062 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
1032 const byte* module_end, bool asm_js) { 1063 const byte* module_end, bool asm_js) {
1033 HandleScope scope(isolate); 1064 HandleScope scope(isolate);
1034 Zone zone(isolate->allocator()); 1065 Zone zone(isolate->allocator());
1035 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); 1066 ErrorThrower thrower(isolate, "CompileAndRunWasmModule");
1036 1067
1037 // Decode the module, but don't verify function bodies, since we'll 1068 // Decode the module, but don't verify function bodies, since we'll
1038 // be compiling them anyway. 1069 // be compiling them anyway.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); 1123 return static_cast<int32_t>(HeapNumber::cast(*result)->value());
1093 } 1124 }
1094 thrower.Error("WASM.compileRun() failed: Return value should be number"); 1125 thrower.Error("WASM.compileRun() failed: Return value should be number");
1095 return -1; 1126 return -1;
1096 } 1127 }
1097 1128
1098 } // namespace testing 1129 } // namespace testing
1099 } // namespace wasm 1130 } // namespace wasm
1100 } // namespace internal 1131 } // namespace internal
1101 } // namespace v8 1132 } // namespace v8
OLDNEW
« 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