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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 size_t mem_size; // size of the linear memory. | 229 size_t mem_size; // size of the linear memory. |
230 // -- raw globals ----------------------------------------------------------- | 230 // -- raw globals ----------------------------------------------------------- |
231 byte* globals_start; // start of the globals area. | 231 byte* globals_start; // start of the globals area. |
232 | 232 |
233 explicit WasmModuleInstance(const WasmModule* m) | 233 explicit WasmModuleInstance(const WasmModule* m) |
234 : module(m), | 234 : module(m), |
235 function_code(m->functions.size()), | 235 function_code(m->functions.size()), |
236 mem_start(nullptr), | 236 mem_start(nullptr), |
237 mem_size(0), | 237 mem_size(0), |
238 globals_start(nullptr) {} | 238 globals_start(nullptr) {} |
| 239 void PopulateExportTable(const std::vector<Handle<Code>>& compiled_functions, |
| 240 const std::vector<uint16_t>& functions); |
239 }; | 241 }; |
240 | 242 |
241 // forward declaration. | |
242 class WasmLinker; | |
243 | |
244 // Interface provided to the decoder/graph builder which contains only | 243 // Interface provided to the decoder/graph builder which contains only |
245 // minimal information about the globals, functions, and function tables. | 244 // minimal information about the globals, functions, and function tables. |
246 struct ModuleEnv { | 245 struct ModuleEnv { |
247 const WasmModule* module; | 246 const WasmModule* module; |
248 WasmModuleInstance* instance; | 247 WasmModuleInstance* instance; |
249 WasmLinker* linker; | |
250 ModuleOrigin origin; | 248 ModuleOrigin origin; |
251 | 249 |
252 bool IsValidGlobal(uint32_t index) { | 250 bool IsValidGlobal(uint32_t index) { |
253 return module && index < module->globals.size(); | 251 return module && index < module->globals.size(); |
254 } | 252 } |
255 bool IsValidFunction(uint32_t index) const { | 253 bool IsValidFunction(uint32_t index) const { |
256 return module && index < module->functions.size(); | 254 return module && index < module->functions.size(); |
257 } | 255 } |
258 bool IsValidSignature(uint32_t index) { | 256 bool IsValidSignature(uint32_t index) { |
259 return module && index < module->signatures.size(); | 257 return module && index < module->signatures.size(); |
(...skipping 16 matching lines...) Expand all Loading... |
276 FunctionSig* GetSignature(uint32_t index) { | 274 FunctionSig* GetSignature(uint32_t index) { |
277 DCHECK(IsValidSignature(index)); | 275 DCHECK(IsValidSignature(index)); |
278 return module->signatures[index]; | 276 return module->signatures[index]; |
279 } | 277 } |
280 size_t FunctionTableSize() { | 278 size_t FunctionTableSize() { |
281 return module ? module->function_table.size() : 0; | 279 return module ? module->function_table.size() : 0; |
282 } | 280 } |
283 | 281 |
284 bool asm_js() { return origin == kAsmJsOrigin; } | 282 bool asm_js() { return origin == kAsmJsOrigin; } |
285 | 283 |
286 Handle<Code> GetCodeOrPlaceholder(uint32_t index) const; | |
287 Handle<Code> GetImportCode(uint32_t index); | |
288 Handle<FixedArray> GetFunctionTable(); | 284 Handle<FixedArray> GetFunctionTable(); |
289 | 285 |
290 static compiler::CallDescriptor* GetWasmCallDescriptor(Zone* zone, | 286 static compiler::CallDescriptor* GetWasmCallDescriptor(Zone* zone, |
291 FunctionSig* sig); | 287 FunctionSig* sig, |
| 288 bool internal = false); |
292 static compiler::CallDescriptor* GetI32WasmCallDescriptor( | 289 static compiler::CallDescriptor* GetI32WasmCallDescriptor( |
293 Zone* zone, compiler::CallDescriptor* descriptor); | 290 Zone* zone, compiler::CallDescriptor* descriptor); |
294 compiler::CallDescriptor* GetCallDescriptor(Zone* zone, uint32_t index); | |
295 }; | 291 }; |
296 | 292 |
297 // A helper for printing out the names of functions. | 293 // A helper for printing out the names of functions. |
298 struct WasmFunctionName { | 294 struct WasmFunctionName { |
299 const WasmFunction* function_; | 295 const WasmFunction* function_; |
300 const WasmModule* module_; | 296 const WasmModule* module_; |
301 WasmFunctionName(const WasmFunction* function, const ModuleEnv* menv) | 297 WasmFunctionName(const WasmFunction* function, const ModuleEnv* menv) |
302 : function_(function), module_(menv ? menv->module : nullptr) {} | 298 : function_(function), module_(menv ? menv->module : nullptr) {} |
303 }; | 299 }; |
304 | 300 |
(...skipping 24 matching lines...) Expand all Loading... |
329 // secure. If it turns out that we need more complete checks, we could add a | 325 // secure. If it turns out that we need more complete checks, we could add a |
330 // special marker as internal field, which will definitely never occur anywhere | 326 // special marker as internal field, which will definitely never occur anywhere |
331 // else. | 327 // else. |
332 bool IsWasmObject(Handle<JSObject> object); | 328 bool IsWasmObject(Handle<JSObject> object); |
333 | 329 |
334 } // namespace wasm | 330 } // namespace wasm |
335 } // namespace internal | 331 } // namespace internal |
336 } // namespace v8 | 332 } // namespace v8 |
337 | 333 |
338 #endif // V8_WASM_MODULE_H_ | 334 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |