tor-browser

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

SafepointIndex.h (2343B)


      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 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef jit_SafepointIndex_h
      8 #define jit_SafepointIndex_h
      9 
     10 #include <stdint.h>
     11 
     12 #include "jit/IonTypes.h"
     13 
     14 namespace js {
     15 namespace jit {
     16 
     17 class LSafepoint;
     18 class CodegenSafepointIndex;
     19 
     20 // Two-tuple that lets you look up the safepoint entry given the
     21 // displacement of a call instruction within the JIT code.
     22 class SafepointIndex {
     23  // The displacement is the distance from the first byte of the JIT'd code
     24  // to the return address (of the call that the safepoint was generated for).
     25  uint32_t displacement_ = 0;
     26 
     27  // Offset within the safepoint buffer.
     28  uint32_t safepointOffset_ = 0;
     29 
     30 public:
     31  inline explicit SafepointIndex(const CodegenSafepointIndex& csi);
     32 
     33  uint32_t displacement() const { return displacement_; }
     34  uint32_t safepointOffset() const { return safepointOffset_; }
     35 };
     36 
     37 class CodegenSafepointIndex {
     38  uint32_t displacement_ = 0;
     39 
     40  LSafepoint* safepoint_ = nullptr;
     41 
     42 public:
     43  CodegenSafepointIndex(uint32_t displacement, LSafepoint* safepoint)
     44      : displacement_(displacement), safepoint_(safepoint) {}
     45 
     46  LSafepoint* safepoint() const { return safepoint_; }
     47  uint32_t displacement() const { return displacement_; }
     48 
     49  inline SnapshotOffset snapshotOffset() const;
     50  inline bool hasSnapshotOffset() const;
     51 };
     52 
     53 // The OSI point is patched to a call instruction. Therefore, the
     54 // returnPoint for an OSI call is the address immediately following that
     55 // call instruction. The displacement of that point within the assembly
     56 // buffer is the |returnPointDisplacement|.
     57 class OsiIndex {
     58  uint32_t callPointDisplacement_;
     59  uint32_t snapshotOffset_;
     60 
     61 public:
     62  OsiIndex(uint32_t callPointDisplacement, uint32_t snapshotOffset)
     63      : callPointDisplacement_(callPointDisplacement),
     64        snapshotOffset_(snapshotOffset) {}
     65 
     66  uint32_t returnPointDisplacement() const;
     67  uint32_t callPointDisplacement() const { return callPointDisplacement_; }
     68  uint32_t snapshotOffset() const { return snapshotOffset_; }
     69 };
     70 
     71 } /* namespace jit */
     72 } /* namespace js */
     73 
     74 #endif /* jit_SafepointIndex_h */