| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 static_cast<int>(length)}; | 188 static_cast<int>(length)}; |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Get a string stored in the module bytes representing a function name. | 191 // Get a string stored in the module bytes representing a function name. |
| 192 WasmName GetName(WasmFunction* function) const { | 192 WasmName GetName(WasmFunction* function) const { |
| 193 return GetName(function->name_offset, function->name_length); | 193 return GetName(function->name_offset, function->name_length); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Get a string stored in the module bytes representing a name. | 196 // Get a string stored in the module bytes representing a name. |
| 197 WasmName GetNameOrNull(uint32_t offset, uint32_t length) const { | 197 WasmName GetNameOrNull(uint32_t offset, uint32_t length) const { |
| 198 if (length == 0) return {NULL, 0}; // no name. | 198 if (offset == 0 && length == 0) return {NULL, 0}; // no name. |
| 199 CHECK(BoundsCheck(offset, offset + length)); | 199 CHECK(BoundsCheck(offset, offset + length)); |
| 200 DCHECK_GE(static_cast<int>(length), 0); | 200 DCHECK_GE(static_cast<int>(length), 0); |
| 201 return {reinterpret_cast<const char*>(module_start + offset), | 201 return {reinterpret_cast<const char*>(module_start + offset), |
| 202 static_cast<int>(length)}; | 202 static_cast<int>(length)}; |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Get a string stored in the module bytes representing a function name. | 205 // Get a string stored in the module bytes representing a function name. |
| 206 WasmName GetNameOrNull(WasmFunction* function) const { | 206 WasmName GetNameOrNull(WasmFunction* function) const { |
| 207 return GetNameOrNull(function->name_offset, function->name_length); | 207 return GetNameOrNull(function->name_offset, function->name_length); |
| 208 } | 208 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // For testing. Decode, verify, and run the last exported function in the | 318 // For testing. Decode, verify, and run the last exported function in the |
| 319 // given encoded module. | 319 // given encoded module. |
| 320 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 320 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
| 321 const byte* module_end, bool asm_js = false); | 321 const byte* module_end, bool asm_js = false); |
| 322 | 322 |
| 323 // For testing. Decode, verify, and run the last exported function in the | 323 // For testing. Decode, verify, and run the last exported function in the |
| 324 // given decoded module. | 324 // given decoded module. |
| 325 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); | 325 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); |
| 326 | 326 |
| 327 // Extract a function name from the given wasm object. | 327 // Extract a function name from the given wasm object. |
| 328 // Returns undefined if the function is unnamed or the function index is | 328 // Returns a null handle if the function is unnamed or the name is not a valid |
| 329 // invalid. | 329 // UTF-8 string. |
| 330 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); | 330 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, |
| 331 uint32_t func_index); |
| 331 | 332 |
| 332 } // namespace wasm | 333 } // namespace wasm |
| 333 } // namespace internal | 334 } // namespace internal |
| 334 } // namespace v8 | 335 } // namespace v8 |
| 335 | 336 |
| 336 #endif // V8_WASM_MODULE_H_ | 337 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |