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"
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
;
38 // IonCacheIRCompiler compiles CacheIR to IonIC native code.
39 class MOZ_RAII IonCacheIRCompiler
: public CacheIRCompiler
{
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
);
52 void assertFloatRegisterAvailable(FloatRegister reg
);
55 IonICPerfSpewer
& perfSpewer() { return perfSpewer_
; }
56 uint8_t localTracingSlots() const { return localTracingSlots_
; }
59 const CacheIRWriter
& writer_
;
61 IonScript
* ionScript_
;
63 Vector
<CodeOffset
, 4, SystemAllocPolicy
> nextCodeOffsets_
;
64 mozilla::Maybe
<LiveRegisterSet
> liveRegs_
;
65 mozilla::Maybe
<CodeOffset
> stubJitCodeOffset_
;
68 uint8_t localTracingSlots_
;
70 IonICPerfSpewer perfSpewer_
;
73 T
rawPointerStubField(uint32_t offset
);
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
,
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
,
97 void pushStubCodePointer();
99 CACHE_IR_COMPILER_UNSHARED_GENERATED
105 #endif /* jit_IonCacheIRCompiler_h */