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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "src/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 | 9 |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 void LoadDataSegments(Address mem_addr, size_t mem_size) { | 1293 void LoadDataSegments(Address mem_addr, size_t mem_size) { |
1294 Handle<SeqOneByteString> module_bytes = compiled_module_->module_bytes(); | 1294 Handle<SeqOneByteString> module_bytes = compiled_module_->module_bytes(); |
1295 for (const WasmDataSegment& segment : module_->data_segments) { | 1295 for (const WasmDataSegment& segment : module_->data_segments) { |
1296 uint32_t source_size = segment.source_size; | 1296 uint32_t source_size = segment.source_size; |
1297 // Segments of size == 0 are just nops. | 1297 // Segments of size == 0 are just nops. |
1298 if (source_size == 0) continue; | 1298 if (source_size == 0) continue; |
1299 uint32_t dest_offset = EvalUint32InitExpr(segment.dest_addr); | 1299 uint32_t dest_offset = EvalUint32InitExpr(segment.dest_addr); |
1300 if (dest_offset >= mem_size || source_size >= mem_size || | 1300 if (dest_offset >= mem_size || source_size >= mem_size || |
1301 dest_offset > (mem_size - source_size)) { | 1301 dest_offset > (mem_size - source_size)) { |
1302 thrower_->TypeError("data segment (start = %" PRIu32 ", size = %" PRIu32 | 1302 thrower_->TypeError("data segment (start = %" PRIu32 ", size = %" PRIu32 |
1303 ") does not fit into memory " | 1303 ") does not fit into memory (size = %" PRIuS ")", |
1304 "(size = %" PRIu64 ")", | 1304 dest_offset, source_size, mem_size); |
1305 dest_offset, source_size, | |
1306 static_cast<uint64_t>(mem_size)); | |
1307 return; | 1305 return; |
1308 } | 1306 } |
1309 byte* dest = mem_addr + dest_offset; | 1307 byte* dest = mem_addr + dest_offset; |
1310 const byte* src = reinterpret_cast<const byte*>( | 1308 const byte* src = reinterpret_cast<const byte*>( |
1311 module_bytes->GetCharsAddress() + segment.source_offset); | 1309 module_bytes->GetCharsAddress() + segment.source_offset); |
1312 memcpy(dest, src, source_size); | 1310 memcpy(dest, src, source_size); |
1313 } | 1311 } |
1314 } | 1312 } |
1315 | 1313 |
1316 void WriteGlobalValue(WasmGlobal& global, Handle<Object> value) { | 1314 void WriteGlobalValue(WasmGlobal& global, Handle<Object> value) { |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 CHECK_NOT_NULL(result.val); | 2102 CHECK_NOT_NULL(result.val); |
2105 module = const_cast<WasmModule*>(result.val); | 2103 module = const_cast<WasmModule*>(result.val); |
2106 } | 2104 } |
2107 | 2105 |
2108 Handle<WasmModuleWrapper> module_wrapper = | 2106 Handle<WasmModuleWrapper> module_wrapper = |
2109 WasmModuleWrapper::New(isolate, module); | 2107 WasmModuleWrapper::New(isolate, module); |
2110 | 2108 |
2111 compiled_module->set_module_wrapper(module_wrapper); | 2109 compiled_module->set_module_wrapper(module_wrapper); |
2112 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); | 2110 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); |
2113 } | 2111 } |
OLD | NEW |