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/wasm/wasm-objects.h" | 5 #include "src/wasm/wasm-objects.h" |
6 #include "src/wasm/wasm-module.h" | 6 #include "src/wasm/wasm-module.h" |
7 | 7 |
8 #define TRACE(...) \ | 8 #define TRACE(...) \ |
9 do { \ | 9 do { \ |
10 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ | 10 if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 uint32_t func_index) { | 370 uint32_t func_index) { |
371 DCHECK_GT(module()->functions.size(), func_index); | 371 DCHECK_GT(module()->functions.size(), func_index); |
372 WasmFunction& function = module()->functions[func_index]; | 372 WasmFunction& function = module()->functions[func_index]; |
373 SeqOneByteString* bytes = ptr_to_module_bytes(); | 373 SeqOneByteString* bytes = ptr_to_module_bytes(); |
374 DCHECK_GE(static_cast<size_t>(bytes->length()), function.name_offset); | 374 DCHECK_GE(static_cast<size_t>(bytes->length()), function.name_offset); |
375 DCHECK_GE(static_cast<size_t>(bytes->length() - function.name_offset), | 375 DCHECK_GE(static_cast<size_t>(bytes->length() - function.name_offset), |
376 function.name_length); | 376 function.name_length); |
377 return Vector<const uint8_t>(bytes->GetCharsAddress() + function.name_offset, | 377 return Vector<const uint8_t>(bytes->GetCharsAddress() + function.name_offset, |
378 function.name_length); | 378 function.name_length); |
379 } | 379 } |
| 380 |
| 381 int WasmCompiledModule::GetFunctionOffset(uint32_t func_index) const { |
| 382 std::vector<WasmFunction>& functions = module()->functions; |
| 383 if (static_cast<uint32_t>(func_index) >= functions.size()) return -1; |
| 384 DCHECK_GE(static_cast<uint32_t>(kMaxInt), |
| 385 functions[func_index].code_start_offset); |
| 386 return static_cast<int>(functions[func_index].code_start_offset); |
| 387 } |
OLD | NEW |