Debian Codegraph @

js/src/jit/SafepointIndex.h

raw
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 "mozilla/Assertions.h"
11
12 #include <stdint.h>
13
14 #include "jit/IonTypes.h"
15
16 namespace js {
17 namespace jit {
18
19 class LSafepoint;
20 class CodegenSafepointIndex;
21
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;
28
29 // Offset within the safepoint buffer.
30 uint32_t safepointOffset_ = 0;
31
32 public:
33 inline explicit SafepointIndex(const CodegenSafepointIndex& csi);
34
35 uint32_t displacement() const { return displacement_; }
36 uint32_t safepointOffset() const { return safepointOffset_; }
37 };
38
39 class CodegenSafepointIndex {
40 uint32_t displacement_ = 0;
41
42 LSafepoint* safepoint_ = nullptr;
43
44 public:
45 CodegenSafepointIndex(uint32_t displacement, LSafepoint* safepoint)
46 : displacement_(displacement), safepoint_(safepoint) {}
47
48 LSafepoint* safepoint() const { return safepoint_; }
49 uint32_t displacement() const { return displacement_; }
50
51 inline SnapshotOffset snapshotOffset() const;
52 inline bool hasSnapshotOffset() const;
53 };
54
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|.
59 class OsiIndex {
60 uint32_t callPointDisplacement_;
61 uint32_t snapshotOffset_;
62
63 public:
64 OsiIndex(uint32_t callPointDisplacement, uint32_t snapshotOffset)
65 : callPointDisplacement_(callPointDisplacement),
66 snapshotOffset_(snapshotOffset) {}
67
68 uint32_t returnPointDisplacement() const;
69 uint32_t callPointDisplacement() const { return callPointDisplacement_; }
70 uint32_t snapshotOffset() const { return snapshotOffset_; }
71 };
72
73 } /* namespace jit */
74 } /* namespace js */
75
76 #endif /* jit_SafepointIndex_h */