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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 const size_t kMaxModuleSize = 1024 * 1024 * 1024; | 35 const size_t kMaxModuleSize = 1024 * 1024 * 1024; |
36 const size_t kMaxFunctionSize = 128 * 1024; | 36 const size_t kMaxFunctionSize = 128 * 1024; |
37 const size_t kMaxStringSize = 256; | 37 const size_t kMaxStringSize = 256; |
38 const uint32_t kWasmMagic = 0x6d736100; | 38 const uint32_t kWasmMagic = 0x6d736100; |
39 const uint32_t kWasmVersion = 0x0d; | 39 const uint32_t kWasmVersion = 0x0d; |
40 | 40 |
41 const uint8_t kWasmFunctionTypeForm = 0x60; | 41 const uint8_t kWasmFunctionTypeForm = 0x60; |
42 const uint8_t kWasmAnyFunctionTypeForm = 0x70; | 42 const uint8_t kWasmAnyFunctionTypeForm = 0x70; |
43 | 43 |
| 44 const uint64_t kWasmMaxHeapOffset = |
| 45 static_cast<uint64_t>( |
| 46 std::numeric_limits<uint32_t>::max()) // maximum base value |
| 47 + std::numeric_limits<uint32_t>::max(); // maximum index value |
| 48 |
44 enum WasmSectionCode { | 49 enum WasmSectionCode { |
45 kUnknownSectionCode = 0, // code for unknown sections | 50 kUnknownSectionCode = 0, // code for unknown sections |
46 kTypeSectionCode = 1, // Function signature declarations | 51 kTypeSectionCode = 1, // Function signature declarations |
47 kImportSectionCode = 2, // Import declarations | 52 kImportSectionCode = 2, // Import declarations |
48 kFunctionSectionCode = 3, // Function declarations | 53 kFunctionSectionCode = 3, // Function declarations |
49 kTableSectionCode = 4, // Indirect function table and other tables | 54 kTableSectionCode = 4, // Indirect function table and other tables |
50 kMemorySectionCode = 5, // Memory attributes | 55 kMemorySectionCode = 5, // Memory attributes |
51 kGlobalSectionCode = 6, // Global declarations | 56 kGlobalSectionCode = 6, // Global declarations |
52 kExportSectionCode = 7, // Exports | 57 kExportSectionCode = 7, // Exports |
53 kStartSectionCode = 8, // Start function declaration | 58 kStartSectionCode = 8, // Start function declaration |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 424 |
420 MaybeHandle<JSArrayBuffer> GetInstanceMemory( | 425 MaybeHandle<JSArrayBuffer> GetInstanceMemory( |
421 Isolate* isolate, Handle<WasmInstanceObject> instance); | 426 Isolate* isolate, Handle<WasmInstanceObject> instance); |
422 | 427 |
423 int32_t GetInstanceMemorySize(Isolate* isolate, | 428 int32_t GetInstanceMemorySize(Isolate* isolate, |
424 Handle<WasmInstanceObject> instance); | 429 Handle<WasmInstanceObject> instance); |
425 | 430 |
426 int32_t GrowInstanceMemory(Isolate* isolate, | 431 int32_t GrowInstanceMemory(Isolate* isolate, |
427 Handle<WasmInstanceObject> instance, uint32_t pages); | 432 Handle<WasmInstanceObject> instance, uint32_t pages); |
428 | 433 |
| 434 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, |
| 435 bool enable_guard_regions); |
| 436 |
429 void UpdateDispatchTables(Isolate* isolate, Handle<FixedArray> dispatch_tables, | 437 void UpdateDispatchTables(Isolate* isolate, Handle<FixedArray> dispatch_tables, |
430 int index, Handle<JSFunction> js_function); | 438 int index, Handle<JSFunction> js_function); |
431 | 439 |
432 namespace testing { | 440 namespace testing { |
433 | 441 |
434 void ValidateInstancesChain(Isolate* isolate, | 442 void ValidateInstancesChain(Isolate* isolate, |
435 Handle<WasmModuleObject> module_obj, | 443 Handle<WasmModuleObject> module_obj, |
436 int instance_count); | 444 int instance_count); |
437 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 445 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
438 void ValidateOrphanedInstance(Isolate* isolate, | 446 void ValidateOrphanedInstance(Isolate* isolate, |
439 Handle<WasmInstanceObject> instance); | 447 Handle<WasmInstanceObject> instance); |
440 | 448 |
441 } // namespace testing | 449 } // namespace testing |
442 } // namespace wasm | 450 } // namespace wasm |
443 } // namespace internal | 451 } // namespace internal |
444 } // namespace v8 | 452 } // namespace v8 |
445 | 453 |
446 #endif // V8_WASM_MODULE_H_ | 454 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |