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/. */
7 #ifndef jit_SafepointIndex_h
8 #define jit_SafepointIndex_h
10 #include "mozilla/Assertions.h"
14 #include "jit/IonTypes.h"
20 class CodegenSafepointIndex
;
22 // Two-tuple that lets you look up the safepoint entry given the
23 // displacement of a call instruction within the JIT code.
24 class SafepointIndex
{
25 // The displacement is the distance from the first byte of the JIT'd code
26 // to the return address (of the call that the safepoint was generated for).
27 uint32_t displacement_
= 0;
29 // Offset within the safepoint buffer.
30 uint32_t safepointOffset_
= 0;
33 inline explicit SafepointIndex(const CodegenSafepointIndex
& csi
);
35 uint32_t displacement() const { return displacement_
; }
36 uint32_t safepointOffset() const { return safepointOffset_
; }
39 class CodegenSafepointIndex
{
40 uint32_t displacement_
= 0;
42 LSafepoint
* safepoint_
= nullptr;
45 CodegenSafepointIndex(uint32_t displacement
, LSafepoint
* safepoint
)
46 : displacement_(displacement
), safepoint_(safepoint
) {}
48 LSafepoint
* safepoint() const { return safepoint_
; }
49 uint32_t displacement() const { return displacement_
; }
51 inline SnapshotOffset
snapshotOffset() const;
52 inline bool hasSnapshotOffset() const;
55 // The OSI point is patched to a call instruction. Therefore, the
56 // returnPoint for an OSI call is the address immediately following that
57 // call instruction. The displacement of that point within the assembly
58 // buffer is the |returnPointDisplacement|.
60 uint32_t callPointDisplacement_
;
61 uint32_t snapshotOffset_
;
64 OsiIndex(uint32_t callPointDisplacement
, uint32_t snapshotOffset
)
65 : callPointDisplacement_(callPointDisplacement
),
66 snapshotOffset_(snapshotOffset
) {}
68 uint32_t returnPointDisplacement() const;
69 uint32_t callPointDisplacement() const { return callPointDisplacement_
; }
70 uint32_t snapshotOffset() const { return snapshotOffset_
; }
76 #endif /* jit_SafepointIndex_h */