tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WasmCodegenConstants.h (3483B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 *
      4 * Copyright 2021 Mozilla Foundation
      5 *
      6 * Licensed under the Apache License, Version 2.0 (the "License");
      7 * you may not use this file except in compliance with the License.
      8 * You may obtain a copy of the License at
      9 *
     10 *     http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing, software
     13 * distributed under the License is distributed on an "AS IS" BASIS,
     14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 * See the License for the specific language governing permissions and
     16 * limitations under the License.
     17 */
     18 
     19 #ifndef wasm_codegen_constants_h
     20 #define wasm_codegen_constants_h
     21 
     22 #include <stdint.h>
     23 
     24 namespace js {
     25 namespace wasm {
     26 
     27 static const unsigned MaxArgsForJitInlineCall = 8;
     28 static const unsigned MaxResultsForJitEntry = 1;
     29 static const unsigned MaxResultsForJitExit = 1;
     30 static const unsigned MaxResultsForJitInlineCall = MaxResultsForJitEntry;
     31 
     32 // The maximum number of fields in a struct to be optimized by scalar
     33 // replacement.
     34 static const unsigned MaxFieldsScalarReplacementStructs = 10;
     35 
     36 // The maximum number of results of a function call or block that may be
     37 // returned in registers.
     38 static const unsigned MaxRegisterResults = 1;
     39 
     40 // A magic value of the InstanceReg to indicate after a return to the
     41 // interpreter entry stub that an exception has been caught and that we should
     42 // throw.
     43 static const unsigned InterpFailInstanceReg = 0xbad;
     44 
     45 // The following thresholds were derived from a microbenchmark. If we begin to
     46 // ship this optimization for more platforms, we will need to extend this list.
     47 
     48 #if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_ARM64)
     49 static const uint32_t MaxInlineMemoryCopyLength = 64;
     50 static const uint32_t MaxInlineMemoryFillLength = 64;
     51 #elif defined(JS_CODEGEN_X86)
     52 static const uint32_t MaxInlineMemoryCopyLength = 32;
     53 static const uint32_t MaxInlineMemoryFillLength = 32;
     54 #else
     55 // Keep these non-zero to avoid compile errors around always false
     56 // conditionals.
     57 static const uint32_t MaxInlineMemoryCopyLength = 1;
     58 static const uint32_t MaxInlineMemoryFillLength = 1;
     59 #endif
     60 
     61 // The size we round all super type vectors to. All accesses below this length
     62 // can avoid bounds checks. The value of 8 was chosen after a bit of profiling
     63 // with the Dart Barista benchmark.
     64 //
     65 // Keep jit-tests/tests/wasm/gc/casting.js in sync with this constant.
     66 static const uint32_t MinSuperTypeVectorLength = 8;
     67 
     68 // An exported wasm function may have a 'jit entry' stub attached that can be
     69 // called using the JS JIT ABI. This relies on the pointer we store in the
     70 // `NativeJitInfoOrInterpretedScriptSlot` slot of JSFunction to have a
     71 // compatible representation with BaseScript/SelfHostedLazyScript so that
     72 // `masm.loadJitCodeRaw` works.
     73 //
     74 // We store jit entry pointers in an array (see wasm::JumpTable) and store the
     75 // pointer to a function's jit entry in the JSFunction slot. We rely on the
     76 // below offset of each entry in the jump table to be compatible with
     77 // BaseScript/SelfHostedLazyScript.
     78 static const uint32_t JumpTableJitEntryOffset = 0;
     79 
     80 // Some JIT code relies on wasm exported functions not being nursery allocated.
     81 // This assert tracks those locations for future updating, if this changes.
     82 #define STATIC_ASSERT_WASM_FUNCTIONS_TENURED
     83 
     84 }  // namespace wasm
     85 }  // namespace js
     86 
     87 #endif  // wasm_codegen_constants_h