Chromium Code Reviews| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. | 158 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. |
| 159 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb | 159 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb |
| 160 static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb | 160 static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb |
| 161 | 161 |
| 162 const byte* module_start; // starting address for the module bytes. | 162 const byte* module_start; // starting address for the module bytes. |
| 163 const byte* module_end; // end address for the module bytes. | 163 const byte* module_end; // end address for the module bytes. |
| 164 uint32_t min_mem_pages; // minimum size of the memory in 64k pages. | 164 uint32_t min_mem_pages; // minimum size of the memory in 64k pages. |
| 165 uint32_t max_mem_pages; // maximum size of the memory in 64k pages. | 165 uint32_t max_mem_pages; // maximum size of the memory in 64k pages. |
| 166 bool mem_export; // true if the memory is exported. | 166 bool mem_export; // true if the memory is exported. |
| 167 bool mem_external; // true if the memory is external. | 167 bool mem_external; // true if the memory is external. |
| 168 // TODO(wasm): model the start_function_index as a uint32_t, to be able | |
| 169 // to represent any valid index in the wasm function table. Model its | |
| 170 // presence/absence separately, as a bool. | |
|
titzer
2016/07/12 15:45:52
Can you remove this TODO? I'd rather keep the curr
Mircea Trofin
2016/07/12 16:12:23
Reworded it, we do have a problem, so I'd be remis
| |
| 168 int start_function_index; // start function, if any. | 171 int start_function_index; // start function, if any. |
| 169 ModuleOrigin origin; // origin of the module | 172 ModuleOrigin origin; // origin of the module |
| 170 | 173 |
| 171 std::vector<WasmGlobal> globals; // globals in this module. | 174 std::vector<WasmGlobal> globals; // globals in this module. |
| 172 uint32_t globals_size; // size of globals table. | 175 uint32_t globals_size; // size of globals table. |
| 173 uint32_t indirect_table_size; // size of indirect function | 176 uint32_t indirect_table_size; // size of indirect function |
| 174 // table (includes padding). | 177 // table (includes padding). |
| 175 std::vector<FunctionSig*> signatures; // signatures in this module. | 178 std::vector<FunctionSig*> signatures; // signatures in this module. |
| 176 std::vector<WasmFunction> functions; // functions in this module. | 179 std::vector<WasmFunction> functions; // functions in this module. |
| 177 std::vector<WasmDataSegment> data_segments; // data segments in this module. | 180 std::vector<WasmDataSegment> data_segments; // data segments in this module. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 // Return the binary source bytes of a wasm module. | 355 // Return the binary source bytes of a wasm module. |
| 353 SeqOneByteString* GetWasmBytes(JSObject* wasm); | 356 SeqOneByteString* GetWasmBytes(JSObject* wasm); |
| 354 | 357 |
| 355 // Get the debug info associated with the given wasm object. | 358 // Get the debug info associated with the given wasm object. |
| 356 // If no debug info exists yet, it is created automatically. | 359 // If no debug info exists yet, it is created automatically. |
| 357 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); | 360 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); |
| 358 | 361 |
| 359 // Return the number of functions in the given wasm object. | 362 // Return the number of functions in the given wasm object. |
| 360 int GetNumberOfFunctions(JSObject* wasm); | 363 int GetNumberOfFunctions(JSObject* wasm); |
| 361 | 364 |
| 365 // Create an export JSFunction | |
|
titzer
2016/07/12 15:45:52
s/an/and/
Mircea Trofin
2016/07/12 16:12:23
Done.
| |
| 366 Handle<JSFunction> CreateExport(Isolate* isolate, Handle<Code> export_code, | |
| 367 Handle<String> name, int arity, | |
| 368 Handle<JSObject> module_instance); | |
| 369 | |
| 362 // Check whether the given object is a wasm object. | 370 // Check whether the given object is a wasm object. |
| 363 // This checks the number and type of internal fields, so it's not 100 percent | 371 // This checks the number and type of internal fields, so it's not 100 percent |
| 364 // secure. If it turns out that we need more complete checks, we could add a | 372 // secure. If it turns out that we need more complete checks, we could add a |
| 365 // special marker as internal field, which will definitely never occur anywhere | 373 // special marker as internal field, which will definitely never occur anywhere |
| 366 // else. | 374 // else. |
| 367 bool IsWasmObject(Object* object); | 375 bool IsWasmObject(Object* object); |
| 368 | 376 |
| 369 // Update memory references of code objects associated with the module | 377 // Update memory references of code objects associated with the module |
| 370 bool UpdateWasmModuleMemory(Handle<JSObject> object, Address old_start, | 378 bool UpdateWasmModuleMemory(Handle<JSObject> object, Address old_start, |
| 371 Address new_start, uint32_t old_size, | 379 Address new_start, uint32_t old_size, |
| 372 uint32_t new_size); | 380 uint32_t new_size); |
| 373 | 381 |
| 374 namespace testing { | 382 namespace testing { |
| 375 | 383 |
| 376 // Decode, verify, and run the function labeled "main" in the | 384 // Decode, verify, and run the function labeled "main" in the |
| 377 // given encoded module. The module should have no imports. | 385 // given encoded module. The module should have no imports. |
| 378 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 386 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
| 379 const byte* module_end, bool asm_js = false); | 387 const byte* module_end, bool asm_js = false); |
| 380 | 388 |
| 381 } // namespace testing | 389 } // namespace testing |
| 382 } // namespace wasm | 390 } // namespace wasm |
| 383 } // namespace internal | 391 } // namespace internal |
| 384 } // namespace v8 | 392 } // namespace v8 |
| 385 | 393 |
| 386 #endif // V8_WASM_MODULE_H_ | 394 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |