| 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 = 16384; // = 1 GiB | 25 // Current limit mimics the maximum allowed allocation on an ArrayBuffer |
| 26 // (2GiB - 1 page). |
| 27 constexpr size_t kV8MaxWasmMemoryPages = 32767; // ~ 2 GiB |
| 26 constexpr size_t kV8MaxWasmStringSize = 100000; | 28 constexpr size_t kV8MaxWasmStringSize = 100000; |
| 27 constexpr size_t kV8MaxWasmModuleSize = 1024 * 1024 * 1024; // = 1 GiB | 29 constexpr size_t kV8MaxWasmModuleSize = 1024 * 1024 * 1024; // = 1 GiB |
| 28 constexpr size_t kV8MaxWasmFunctionSize = 128 * 1024; | 30 constexpr size_t kV8MaxWasmFunctionSize = 128 * 1024; |
| 29 constexpr size_t kV8MaxWasmFunctionLocals = 50000; | 31 constexpr size_t kV8MaxWasmFunctionLocals = 50000; |
| 30 constexpr size_t kV8MaxWasmFunctionParams = 1000; | 32 constexpr size_t kV8MaxWasmFunctionParams = 1000; |
| 31 constexpr size_t kV8MaxWasmFunctionMultiReturns = 1000; | 33 constexpr size_t kV8MaxWasmFunctionMultiReturns = 1000; |
| 32 constexpr size_t kV8MaxWasmFunctionReturns = 1; | 34 constexpr size_t kV8MaxWasmFunctionReturns = 1; |
| 33 // Don't use this limit directly, but use the value of FLAG_wasm_max_table_size. | 35 // Don't use this limit directly, but use the value of FLAG_wasm_max_table_size. |
| 34 constexpr size_t kV8MaxWasmTableSize = 10000000; | 36 constexpr size_t kV8MaxWasmTableSize = 10000000; |
| 35 constexpr size_t kV8MaxWasmTableEntries = 10000000; | 37 constexpr size_t kV8MaxWasmTableEntries = 10000000; |
| 36 constexpr size_t kV8MaxWasmTables = 1; | 38 constexpr size_t kV8MaxWasmTables = 1; |
| 37 constexpr size_t kV8MaxWasmMemories = 1; | 39 constexpr size_t kV8MaxWasmMemories = 1; |
| 38 | 40 |
| 39 constexpr size_t kSpecMaxWasmMemoryPages = 65536; | 41 constexpr size_t kSpecMaxWasmMemoryPages = 65536; |
| 40 constexpr size_t kSpecMaxWasmTableSize = 0xFFFFFFFFu; | 42 constexpr size_t kSpecMaxWasmTableSize = 0xFFFFFFFFu; |
| 41 | 43 |
| 42 constexpr uint64_t kWasmMaxHeapOffset = | 44 constexpr uint64_t kWasmMaxHeapOffset = |
| 43 static_cast<uint64_t>( | 45 static_cast<uint64_t>( |
| 44 std::numeric_limits<uint32_t>::max()) // maximum base value | 46 std::numeric_limits<uint32_t>::max()) // maximum base value |
| 45 + std::numeric_limits<uint32_t>::max(); // maximum index value | 47 + std::numeric_limits<uint32_t>::max(); // maximum index value |
| 46 | 48 |
| 47 // Limit the control stack size of the C++ wasm interpreter. | 49 // Limit the control stack size of the C++ wasm interpreter. |
| 48 constexpr size_t kV8MaxWasmInterpretedStackSize = 64 * 1024; | 50 constexpr size_t kV8MaxWasmInterpretedStackSize = 64 * 1024; |
| 49 | 51 |
| 50 } // namespace wasm | 52 } // namespace wasm |
| 51 } // namespace internal | 53 } // namespace internal |
| 52 } // namespace v8 | 54 } // namespace v8 |
| 53 | 55 |
| 54 #endif // V8_WASM_WASM_LIMITS_H_ | 56 #endif // V8_WASM_WASM_LIMITS_H_ |
| OLD | NEW |