OLD | NEW |
---|---|
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 Loading... | |
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, byte* old_start, byte* new_start, | |
1030 uint32_t old_size, uint32_t new_size) { | |
1031 if (!IsWasmObject(object)) { | |
1032 return false; | |
1033 } | |
1034 | |
1035 // Get code table associated with the module js_object | |
1036 Object* obj = object->GetInternalField(kWasmModuleCodeTable); | |
1037 Handle<FixedArray> code_table; | |
1038 code_table = Handle<FixedArray>(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 Handle<Code> code; | |
1044 obj = code_table->get(i); | |
1045 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.
| |
1046 | |
1047 int mode_mask = RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_REFERENCE) | | |
1048 RelocInfo::ModeMask(RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | |
1049 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | |
1050 RelocInfo::Mode mode = it.rinfo()->rmode(); | |
1051 if (RelocInfo::IsWasmMemoryReference(mode) || | |
1052 RelocInfo::IsWasmMemorySizeReference(mode)) { | |
1053 it.rinfo()->update_wasm_memory_reference( | |
1054 reinterpret_cast<Address>(old_start), | |
1055 reinterpret_cast<Address>(new_start), old_size, new_size); | |
1056 } | |
1057 } | |
1058 } | |
1059 return true; | |
1060 } | |
1061 | |
1029 namespace testing { | 1062 namespace testing { |
1030 | 1063 |
1031 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 1064 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
1032 const byte* module_end, bool asm_js) { | 1065 const byte* module_end, bool asm_js) { |
1033 HandleScope scope(isolate); | 1066 HandleScope scope(isolate); |
1034 Zone zone(isolate->allocator()); | 1067 Zone zone(isolate->allocator()); |
1035 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); | 1068 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); |
1036 | 1069 |
1037 // Decode the module, but don't verify function bodies, since we'll | 1070 // Decode the module, but don't verify function bodies, since we'll |
1038 // be compiling them anyway. | 1071 // be compiling them anyway. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1123 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
1091 } | 1124 } |
1092 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 1125 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
1093 return -1; | 1126 return -1; |
1094 } | 1127 } |
1095 | 1128 |
1096 } // namespace testing | 1129 } // namespace testing |
1097 } // namespace wasm | 1130 } // namespace wasm |
1098 } // namespace internal | 1131 } // namespace internal |
1099 } // namespace v8 | 1132 } // namespace v8 |
OLD | NEW |