Bug 1874684 - Part 31: Correctly reject invalid durations in some RoundDuration calls...
[gecko.git] / js / src / jit / IonCacheIRCompiler.h
blob62a4399046a40fbc13a30fca899af06b162130d7
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_IonCacheIRCompiler_h
8 #define jit_IonCacheIRCompiler_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/Maybe.h"
13 #include <stdint.h>
15 #include "jstypes.h"
17 #include "jit/CacheIR.h"
18 #include "jit/CacheIRCompiler.h"
19 #include "jit/CacheIROpsGenerated.h"
20 #include "jit/CacheIRReader.h"
21 #include "jit/Registers.h"
22 #include "jit/RegisterSets.h"
23 #include "js/Vector.h"
25 struct JS_PUBLIC_API JSContext;
27 namespace js {
28 namespace jit {
30 class CacheIRWriter;
31 class CodeOffset;
32 class IonIC;
33 class IonICStub;
34 class IonScript;
35 class JitCode;
36 class MacroAssembler;
38 // IonCacheIRCompiler compiles CacheIR to IonIC native code.
39 class MOZ_RAII IonCacheIRCompiler : public CacheIRCompiler {
40 public:
41 friend class AutoSaveLiveRegisters;
42 friend class AutoCallVM;
44 IonCacheIRCompiler(JSContext* cx, TempAllocator& alloc,
45 const CacheIRWriter& writer, IonIC* ic,
46 IonScript* ionScript, uint32_t stubDataOffset);
48 [[nodiscard]] bool init();
49 JitCode* compile(IonICStub* stub);
51 #ifdef DEBUG
52 void assertFloatRegisterAvailable(FloatRegister reg);
53 #endif
55 IonICPerfSpewer& perfSpewer() { return perfSpewer_; }
56 uint8_t localTracingSlots() const { return localTracingSlots_; }
58 private:
59 const CacheIRWriter& writer_;
60 IonIC* ic_;
61 IonScript* ionScript_;
63 Vector<CodeOffset, 4, SystemAllocPolicy> nextCodeOffsets_;
64 mozilla::Maybe<LiveRegisterSet> liveRegs_;
65 mozilla::Maybe<CodeOffset> stubJitCodeOffset_;
67 bool savedLiveRegs_;
68 uint8_t localTracingSlots_;
70 IonICPerfSpewer perfSpewer_;
72 template <typename T>
73 T rawPointerStubField(uint32_t offset);
75 template <typename T>
76 T rawInt64StubField(uint32_t offset);
78 void enterStubFrame(MacroAssembler& masm, const AutoSaveLiveRegisters&);
79 void storeTracedValue(MacroAssembler& masm, ValueOperand value);
80 void loadTracedValue(MacroAssembler& masm, uint8_t slotIndex,
81 ValueOperand value);
83 template <typename Fn, Fn fn>
84 void callVM(MacroAssembler& masm);
86 [[nodiscard]] bool emitAddAndStoreSlotShared(
87 CacheOp op, ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId,
88 uint32_t newShapeOffset, mozilla::Maybe<uint32_t> numNewSlotsOffset);
90 template <typename IdType>
91 [[nodiscard]] bool emitCallScriptedProxyGetShared(ValOperandId targetId,
92 ObjOperandId receiverId,
93 ObjOperandId handlerId,
94 uint32_t trapOffset,
95 IdType id);
97 void pushStubCodePointer();
99 CACHE_IR_COMPILER_UNSHARED_GENERATED
102 } // namespace jit
103 } // namespace js
105 #endif /* jit_IonCacheIRCompiler_h */