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/api.h" | 8 #include "src/api.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 std::vector<WasmExport> export_table; // export table. | 183 std::vector<WasmExport> export_table; // export table. |
184 // We store the semaphore here to extend its lifetime. In <libc-2.21, which we | 184 // We store the semaphore here to extend its lifetime. In <libc-2.21, which we |
185 // use on the try bots, semaphore::Wait() can return while some compilation | 185 // use on the try bots, semaphore::Wait() can return while some compilation |
186 // tasks are still executing semaphore::Signal(). If the semaphore is cleaned | 186 // tasks are still executing semaphore::Signal(). If the semaphore is cleaned |
187 // up right after semaphore::Wait() returns, then this can cause an | 187 // up right after semaphore::Wait() returns, then this can cause an |
188 // invalid-semaphore error in the compilation tasks. | 188 // invalid-semaphore error in the compilation tasks. |
189 // TODO(wasm): Move this semaphore back to CompileInParallel when the try bots | 189 // TODO(wasm): Move this semaphore back to CompileInParallel when the try bots |
190 // switch to libc-2.21 or higher. | 190 // switch to libc-2.21 or higher. |
191 base::SmartPointer<base::Semaphore> pending_tasks; | 191 base::SmartPointer<base::Semaphore> pending_tasks; |
192 | 192 |
193 WasmModule(); | 193 WasmModule() : WasmModule(nullptr) {} |
| 194 explicit WasmModule(byte* module_start); |
194 | 195 |
195 // Get a string stored in the module bytes representing a name. | 196 // Get a string stored in the module bytes representing a name. |
196 WasmName GetName(uint32_t offset, uint32_t length) const { | 197 WasmName GetName(uint32_t offset, uint32_t length) const { |
197 if (length == 0) return {"<?>", 3}; // no name. | 198 if (length == 0) return {"<?>", 3}; // no name. |
198 CHECK(BoundsCheck(offset, offset + length)); | 199 CHECK(BoundsCheck(offset, offset + length)); |
199 DCHECK_GE(static_cast<int>(length), 0); | 200 DCHECK_GE(static_cast<int>(length), 0); |
200 return {reinterpret_cast<const char*>(module_start + offset), | 201 return {reinterpret_cast<const char*>(module_start + offset), |
201 static_cast<int>(length)}; | 202 static_cast<int>(length)}; |
202 } | 203 } |
203 | 204 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // given encoded module. The module should have no imports. | 387 // given encoded module. The module should have no imports. |
387 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 388 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
388 const byte* module_end, bool asm_js = false); | 389 const byte* module_end, bool asm_js = false); |
389 | 390 |
390 } // namespace testing | 391 } // namespace testing |
391 } // namespace wasm | 392 } // namespace wasm |
392 } // namespace internal | 393 } // namespace internal |
393 } // namespace v8 | 394 } // namespace v8 |
394 | 395 |
395 #endif // V8_WASM_MODULE_H_ | 396 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |