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

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

Issue 1634653002: [wasm] register WASM code creation event for profilers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: GetName only checks bounds when there is a memory section since some wasm test cases does not have … Created 4 years, 10 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
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 std::vector<FunctionSig*>* signatures; // signatures in this module. 98 std::vector<FunctionSig*>* signatures; // signatures in this module.
99 std::vector<WasmFunction>* functions; // functions in this module. 99 std::vector<WasmFunction>* functions; // functions in this module.
100 std::vector<WasmDataSegment>* data_segments; // data segments in this module. 100 std::vector<WasmDataSegment>* data_segments; // data segments in this module.
101 std::vector<uint16_t>* function_table; // function table. 101 std::vector<uint16_t>* function_table; // function table.
102 102
103 WasmModule(); 103 WasmModule();
104 ~WasmModule(); 104 ~WasmModule();
105 105
106 // Get a pointer to a string stored in the module bytes representing a name. 106 // Get a pointer to a string stored in the module bytes representing a name.
107 const char* GetName(uint32_t offset) { 107 const char* GetName(uint32_t offset) {
108 if (offset == 0) return "<?>"; // no name.
108 CHECK(BoundsCheck(offset, offset + 1)); 109 CHECK(BoundsCheck(offset, offset + 1));
109 if (offset == 0) return "<?>"; // no name.
110 return reinterpret_cast<const char*>(module_start + offset); 110 return reinterpret_cast<const char*>(module_start + offset);
111 } 111 }
112 112
113 // Checks the given offset range is contained within the module bytes. 113 // Checks the given offset range is contained within the module bytes.
114 bool BoundsCheck(uint32_t start, uint32_t end) { 114 bool BoundsCheck(uint32_t start, uint32_t end) {
115 size_t size = module_end - module_start; 115 size_t size = module_end - module_start;
116 return start < size && end < size; 116 return start < size && end < size;
117 } 117 }
118 118
119 // Creates a new instantiation of the module in the given isolate. 119 // Creates a new instantiation of the module in the given isolate.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 const byte* module_end, bool asm_js = false); 202 const byte* module_end, bool asm_js = false);
203 203
204 // For testing. Decode, verify, and run the last exported function in the 204 // For testing. Decode, verify, and run the last exported function in the
205 // given decoded module. 205 // given decoded module.
206 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); 206 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module);
207 } // namespace wasm 207 } // namespace wasm
208 } // namespace internal 208 } // namespace internal
209 } // namespace v8 209 } // namespace v8
210 210
211 #endif // V8_WASM_MODULE_H_ 211 #endif // V8_WASM_MODULE_H_
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698