OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_WASM_LIMITS_H_ | 5 #ifndef V8_WASM_WASM_LIMITS_H_ |
6 #define V8_WASM_WASM_LIMITS_H_ | 6 #define V8_WASM_WASM_LIMITS_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <cstdint> | 9 #include <cstdint> |
10 #include <limits> | 10 #include <limits> |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 namespace wasm { | 14 namespace wasm { |
15 | 15 |
16 // The following limits are imposed by V8 on WebAssembly modules. | 16 // The following limits are imposed by V8 on WebAssembly modules. |
17 // The limits are agreed upon with other engines for consistency. | 17 // The limits are agreed upon with other engines for consistency. |
18 constexpr size_t kV8MaxWasmTypes = 1000000; | 18 constexpr size_t kV8MaxWasmTypes = 1000000; |
19 constexpr size_t kV8MaxWasmFunctions = 1000000; | 19 constexpr size_t kV8MaxWasmFunctions = 1000000; |
20 constexpr size_t kV8MaxWasmImports = 100000; | 20 constexpr size_t kV8MaxWasmImports = 100000; |
21 constexpr size_t kV8MaxWasmExports = 100000; | 21 constexpr size_t kV8MaxWasmExports = 100000; |
22 constexpr size_t kV8MaxWasmGlobals = 1000000; | 22 constexpr size_t kV8MaxWasmGlobals = 1000000; |
23 constexpr size_t kV8MaxWasmDataSegments = 100000; | 23 constexpr size_t kV8MaxWasmDataSegments = 100000; |
24 // Don't use this limit directly, but use the value of FLAG_wasm_max_mem_pages. | 24 // Don't use this limit directly, but use the value of FLAG_wasm_max_mem_pages. |
25 constexpr size_t kV8MaxWasmMemoryPages = 32768; // = 1 GiB | 25 constexpr size_t kV8MaxWasmMemoryPages = 32768; // = 2GiB pages |
26 constexpr size_t kV8MaxWasmStringSize = 100000; | 26 constexpr size_t kV8MaxWasmStringSize = 100000; |
27 constexpr size_t kV8MaxWasmModuleSize = 1024 * 1024 * 1024; // = 1 GiB | 27 constexpr size_t kV8MaxWasmModuleSize = 1024 * 1024 * 1024 * 2; // = 1 GiB |
28 constexpr size_t kV8MaxWasmFunctionSize = 128 * 1024; | 28 constexpr size_t kV8MaxWasmFunctionSize = 128 * 1024; |
29 constexpr size_t kV8MaxWasmFunctionLocals = 50000; | 29 constexpr size_t kV8MaxWasmFunctionLocals = 50000; |
30 constexpr size_t kV8MaxWasmFunctionParams = 1000; | 30 constexpr size_t kV8MaxWasmFunctionParams = 1000; |
31 constexpr size_t kV8MaxWasmFunctionMultiReturns = 1000; | 31 constexpr size_t kV8MaxWasmFunctionMultiReturns = 1000; |
32 constexpr size_t kV8MaxWasmFunctionReturns = 1; | 32 constexpr size_t kV8MaxWasmFunctionReturns = 1; |
33 // Don't use this limit directly, but use the value of FLAG_wasm_max_table_size. | 33 // Don't use this limit directly, but use the value of FLAG_wasm_max_table_size. |
34 constexpr size_t kV8MaxWasmTableSize = 10000000; | 34 constexpr size_t kV8MaxWasmTableSize = 10000000; |
35 constexpr size_t kV8MaxWasmTableEntries = 10000000; | 35 constexpr size_t kV8MaxWasmTableEntries = 10000000; |
36 constexpr size_t kV8MaxWasmTables = 1; | 36 constexpr size_t kV8MaxWasmTables = 1; |
37 constexpr size_t kV8MaxWasmMemories = 1; | 37 constexpr size_t kV8MaxWasmMemories = 1; |
38 | 38 |
39 constexpr size_t kSpecMaxWasmMemoryPages = 65536; | 39 constexpr size_t kSpecMaxWasmMemoryPages = 65536; |
40 constexpr size_t kSpecMaxWasmTableSize = 0xFFFFFFFFu; | 40 constexpr size_t kSpecMaxWasmTableSize = 0xFFFFFFFFu; |
41 | 41 |
42 constexpr uint64_t kWasmMaxHeapOffset = | 42 constexpr uint64_t kWasmMaxHeapOffset = |
43 static_cast<uint64_t>( | 43 static_cast<uint64_t>( |
44 std::numeric_limits<uint32_t>::max()) // maximum base value | 44 std::numeric_limits<uint32_t>::max()) // maximum base value |
45 + std::numeric_limits<uint32_t>::max(); // maximum index value | 45 + std::numeric_limits<uint32_t>::max(); // maximum index value |
46 | 46 |
47 // Limit the control stack size of the C++ wasm interpreter. | 47 // Limit the control stack size of the C++ wasm interpreter. |
48 constexpr size_t kV8MaxWasmInterpretedStackSize = 64 * 1024; | 48 constexpr size_t kV8MaxWasmInterpretedStackSize = 64 * 1024; |
49 | 49 |
50 } // namespace wasm | 50 } // namespace wasm |
51 } // namespace internal | 51 } // namespace internal |
52 } // namespace v8 | 52 } // namespace v8 |
53 | 53 |
54 #endif // V8_WASM_WASM_LIMITS_H_ | 54 #endif // V8_WASM_WASM_LIMITS_H_ |
OLD | NEW |