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 #ifndef V8_WASM_MODULE_H_ | 5 #ifndef V8_WASM_MODULE_H_ |
6 #define V8_WASM_MODULE_H_ | 6 #define V8_WASM_MODULE_H_ |
7 | 7 |
8 #include "src/wasm/wasm-opcodes.h" | 8 #include "src/wasm/wasm-opcodes.h" |
9 #include "src/wasm/wasm-result.h" | 9 #include "src/wasm/wasm-result.h" |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 static_cast<int>(length)}; | 195 static_cast<int>(length)}; |
196 } | 196 } |
197 | 197 |
198 // Get a string stored in the module bytes representing a function name. | 198 // Get a string stored in the module bytes representing a function name. |
199 WasmName GetName(WasmFunction* function) const { | 199 WasmName GetName(WasmFunction* function) const { |
200 return GetName(function->name_offset, function->name_length); | 200 return GetName(function->name_offset, function->name_length); |
201 } | 201 } |
202 | 202 |
203 // Get a string stored in the module bytes representing a name. | 203 // Get a string stored in the module bytes representing a name. |
204 WasmName GetNameOrNull(uint32_t offset, uint32_t length) const { | 204 WasmName GetNameOrNull(uint32_t offset, uint32_t length) const { |
205 if (length == 0) return {NULL, 0}; // no name. | 205 if (offset == 0 && length == 0) return {NULL, 0}; // no name. |
206 CHECK(BoundsCheck(offset, offset + length)); | 206 CHECK(BoundsCheck(offset, offset + length)); |
207 DCHECK_GE(static_cast<int>(length), 0); | 207 DCHECK_GE(static_cast<int>(length), 0); |
208 return {reinterpret_cast<const char*>(module_start + offset), | 208 return {reinterpret_cast<const char*>(module_start + offset), |
209 static_cast<int>(length)}; | 209 static_cast<int>(length)}; |
210 } | 210 } |
211 | 211 |
212 // Get a string stored in the module bytes representing a function name. | 212 // Get a string stored in the module bytes representing a function name. |
213 WasmName GetNameOrNull(WasmFunction* function) const { | 213 WasmName GetNameOrNull(WasmFunction* function) const { |
214 return GetNameOrNull(function->name_offset, function->name_length); | 214 return GetNameOrNull(function->name_offset, function->name_length); |
215 } | 215 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 // Extract a function name from the given wasm object. | 334 // Extract a function name from the given wasm object. |
335 // Returns undefined if the function is unnamed or the function index is | 335 // Returns undefined if the function is unnamed or the function index is |
336 // invalid. | 336 // invalid. |
337 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); | 337 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); |
338 | 338 |
339 } // namespace wasm | 339 } // namespace wasm |
340 } // namespace internal | 340 } // namespace internal |
341 } // namespace v8 | 341 } // namespace v8 |
342 | 342 |
343 #endif // V8_WASM_MODULE_H_ | 343 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |