Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: src/wasm/wasm-module.h

Issue 1912103002: [wasm] Store function names in the wasm object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-2
Patch Set: fix gcmole and signed/unsigned comparison issue Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 WasmModule(); 190 WasmModule();
191 191
192 // Get a string stored in the module bytes representing a name. 192 // Get a string stored in the module bytes representing a name.
193 WasmName GetName(uint32_t offset, uint32_t length) const { 193 WasmName GetName(uint32_t offset, uint32_t length) const {
194 if (length == 0) return {"<?>", 3}; // no name. 194 if (length == 0) return {"<?>", 3}; // no name.
195 CHECK(BoundsCheck(offset, offset + length)); 195 CHECK(BoundsCheck(offset, offset + length));
196 return {reinterpret_cast<const char*>(module_start + offset), length}; 196 return {reinterpret_cast<const char*>(module_start + offset), length};
197 } 197 }
198 198
199 // Get a string stored in the module bytes representing a function name.
200 WasmName GetName(WasmFunction* function) const {
201 return GetName(function->name_offset, function->name_length);
202 }
203
199 // Get a string stored in the module bytes representing a name. 204 // Get a string stored in the module bytes representing a name.
200 WasmName GetNameOrNull(uint32_t offset, uint32_t length) const { 205 WasmName GetNameOrNull(uint32_t offset, uint32_t length) const {
201 if (length == 0) return {NULL, 0}; // no name. 206 if (length == 0) return {NULL, 0}; // no name.
202 CHECK(BoundsCheck(offset, offset + length)); 207 CHECK(BoundsCheck(offset, offset + length));
203 return {reinterpret_cast<const char*>(module_start + offset), length}; 208 return {reinterpret_cast<const char*>(module_start + offset), length};
204 } 209 }
205 210
211 // Get a string stored in the module bytes representing a function name.
212 WasmName GetNameOrNull(WasmFunction* function) const {
213 return GetNameOrNull(function->name_offset, function->name_length);
214 }
215
206 // Checks the given offset range is contained within the module bytes. 216 // Checks the given offset range is contained within the module bytes.
207 bool BoundsCheck(uint32_t start, uint32_t end) const { 217 bool BoundsCheck(uint32_t start, uint32_t end) const {
208 size_t size = module_end - module_start; 218 size_t size = module_end - module_start;
209 return start < size && end < size; 219 return start < size && end < size;
210 } 220 }
211 221
212 // Creates a new instantiation of the module in the given isolate. 222 // Creates a new instantiation of the module in the given isolate.
213 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSObject> ffi, 223 MaybeHandle<JSObject> Instantiate(Isolate* isolate, Handle<JSObject> ffi,
214 Handle<JSArrayBuffer> memory); 224 Handle<JSArrayBuffer> memory);
215 }; 225 };
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 323
314 // For testing. Decode, verify, and run the last exported function in the 324 // For testing. Decode, verify, and run the last exported function in the
315 // given encoded module. 325 // given encoded module.
316 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, 326 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
317 const byte* module_end, bool asm_js = false); 327 const byte* module_end, bool asm_js = false);
318 328
319 // For testing. Decode, verify, and run the last exported function in the 329 // For testing. Decode, verify, and run the last exported function in the
320 // given decoded module. 330 // given decoded module.
321 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); 331 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module);
322 332
333 // Extract the function name for the given func_index from the wasm module.
334 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index);
335
323 } // namespace wasm 336 } // namespace wasm
324 } // namespace internal 337 } // namespace internal
325 } // namespace v8 338 } // namespace v8
326 339
327 #endif // V8_WASM_MODULE_H_ 340 #endif // V8_WASM_MODULE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698