Bug 1639153 - Part 6.2: Establish dependency from tls for x86 callWithABI div/mod...
[gecko.git] / js / src / jit / BaselineCacheIRCompiler.h
blobde3db01e253d7ec8995c2958c05521d2ecc2a215
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_BaselineCacheIRCompiler_h
8 #define jit_BaselineCacheIRCompiler_h
10 #include "mozilla/Maybe.h"
12 #include "gc/Barrier.h"
13 #include "jit/CacheIR.h"
14 #include "jit/CacheIRCompiler.h"
16 namespace js {
17 namespace jit {
19 class ICFallbackStub;
20 class ICStub;
22 enum class BaselineCacheIRStubKind { Regular, Monitored, Updated };
24 ICStub* AttachBaselineCacheIRStub(JSContext* cx, const CacheIRWriter& writer,
25 CacheKind kind,
26 BaselineCacheIRStubKind stubKind,
27 JSScript* outerScript, ICScript* icScript,
28 ICFallbackStub* stub, bool* attached);
30 // BaselineCacheIRCompiler compiles CacheIR to BaselineIC native code.
31 class MOZ_RAII BaselineCacheIRCompiler : public CacheIRCompiler {
32 bool makesGCCalls_;
33 BaselineCacheIRStubKind kind_;
35 void tailCallVMInternal(MacroAssembler& masm, TailCallVMFunctionId id);
37 template <typename Fn, Fn fn>
38 void tailCallVM(MacroAssembler& masm);
40 MOZ_MUST_USE bool callTypeUpdateIC(Register obj, ValueOperand val,
41 Register scratch,
42 LiveGeneralRegisterSet saveRegs);
44 MOZ_MUST_USE bool emitStoreSlotShared(bool isFixed, ObjOperandId objId,
45 uint32_t offsetOffset,
46 ValOperandId rhsId);
47 MOZ_MUST_USE bool emitAddAndStoreSlotShared(
48 CacheOp op, ObjOperandId objId, uint32_t offsetOffset, ValOperandId rhsId,
49 bool changeGroup, uint32_t newGroupOffset, uint32_t newShapeOffset,
50 mozilla::Maybe<uint32_t> numNewSlotsOffset);
52 bool updateArgc(CallFlags flags, Register argcReg, Register scratch);
53 void loadStackObject(ArgumentKind kind, CallFlags flags, size_t stackPushed,
54 Register argcReg, Register dest);
55 void pushArguments(Register argcReg, Register calleeReg, Register scratch,
56 Register scratch2, CallFlags flags, bool isJitCall);
57 void pushStandardArguments(Register argcReg, Register scratch,
58 Register scratch2, bool isJitCall,
59 bool isConstructing);
60 void pushArrayArguments(Register argcReg, Register scratch, Register scratch2,
61 bool isJitCall, bool isConstructing);
62 void pushFunCallArguments(Register argcReg, Register calleeReg,
63 Register scratch, Register scratch2,
64 bool isJitCall);
65 void pushFunApplyArgs(Register argcReg, Register calleeReg, Register scratch,
66 Register scratch2, bool isJitCall);
67 void createThis(Register argcReg, Register calleeReg, Register scratch,
68 CallFlags flags);
69 void updateReturnValue();
71 enum class NativeCallType { Native, ClassHook };
72 bool emitCallNativeShared(NativeCallType callType, ObjOperandId calleeId,
73 Int32OperandId argcId, CallFlags flags,
74 mozilla::Maybe<bool> ignoresReturnValue,
75 mozilla::Maybe<uint32_t> targetOffset);
77 enum class StringCode { CodeUnit, CodePoint };
78 bool emitStringFromCodeResult(Int32OperandId codeId, StringCode stringCode);
80 public:
81 friend class AutoStubFrame;
83 BaselineCacheIRCompiler(JSContext* cx, const CacheIRWriter& writer,
84 uint32_t stubDataOffset,
85 BaselineCacheIRStubKind stubKind);
87 MOZ_MUST_USE bool init(CacheKind kind);
89 template <typename Fn, Fn fn>
90 void callVM(MacroAssembler& masm);
92 JitCode* compile();
94 bool makesGCCalls() const;
96 Address stubAddress(uint32_t offset) const;
98 private:
99 CACHE_IR_COMPILER_UNSHARED_GENERATED
102 } // namespace jit
103 } // namespace js
105 #endif /* jit_BaselineCacheIRCompiler_h */