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_CacheIRGenerator_h
8 #define jit_CacheIRGenerator_h
10 #include "mozilla/Assertions.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/Maybe.h"
17 #include "NamespaceImports.h"
19 #include "jit/CacheIR.h"
20 #include "jit/CacheIRWriter.h"
21 #include "jit/ICState.h"
23 #include "js/RootingAPI.h"
24 #include "js/ScalarType.h"
25 #include "js/TypeDecls.h"
27 #include "js/ValueArray.h"
28 #include "vm/Opcodes.h"
38 class BoundFunctionObject
;
42 enum class UnaryMathFunction
: uint8_t;
50 enum class InlinableNative
: uint16_t;
52 // Some ops refer to shapes that might be in other zones. Instead of putting
53 // cross-zone pointers in the caches themselves (which would complicate tracing
54 // enormously), these ops instead contain wrappers for objects in the target
55 // zone, which refer to the actual shape via a reserved slot.
56 void LoadShapeWrapperContents(MacroAssembler
& masm
, Register obj
, Register dst
,
59 class MOZ_RAII IRGenerator
{
69 // Important: This pointer may be passed to the profiler. If this is non-null,
70 // it must point to a C string literal with static lifetime, not a heap- or
71 // stack- allocated string.
72 const char* stubName_
= nullptr;
74 IRGenerator(const IRGenerator
&) = delete;
75 IRGenerator
& operator=(const IRGenerator
&) = delete;
77 bool maybeGuardInt32Index(const Value
& index
, ValOperandId indexId
,
78 uint32_t* int32Index
, Int32OperandId
* int32IndexId
);
80 IntPtrOperandId
guardToIntPtrIndex(const Value
& index
, ValOperandId indexId
,
83 ObjOperandId
guardDOMProxyExpandoObjectAndShape(ProxyObject
* obj
,
85 const Value
& expandoVal
,
86 NativeObject
* expandoObj
);
88 void emitIdGuard(ValOperandId valId
, const Value
& idVal
, jsid id
);
90 OperandId
emitNumericGuard(ValOperandId valId
, Scalar::Type type
);
92 StringOperandId
emitToStringGuard(ValOperandId id
, const Value
& v
);
94 void emitCalleeGuard(ObjOperandId calleeId
, JSFunction
* callee
);
96 void emitOptimisticClassGuard(ObjOperandId objId
, JSObject
* obj
,
99 friend class CacheIRSpewer
;
102 explicit IRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
103 CacheKind cacheKind
, ICState state
);
105 const CacheIRWriter
& writerRef() const { return writer
; }
106 CacheKind
cacheKind() const { return cacheKind_
; }
108 // See comment on `stubName_` above.
109 const char* stubName() const { return stubName_
; }
111 static constexpr char* NotAttached
= nullptr;
114 // GetPropIRGenerator generates CacheIR for a GetProp IC.
115 class MOZ_RAII GetPropIRGenerator
: public IRGenerator
{
119 AttachDecision
tryAttachNative(HandleObject obj
, ObjOperandId objId
,
120 HandleId id
, ValOperandId receiverId
);
121 AttachDecision
tryAttachObjectLength(HandleObject obj
, ObjOperandId objId
,
123 AttachDecision
tryAttachTypedArray(HandleObject obj
, ObjOperandId objId
,
125 AttachDecision
tryAttachDataView(HandleObject obj
, ObjOperandId objId
,
127 AttachDecision
tryAttachArrayBufferMaybeShared(HandleObject obj
,
130 AttachDecision
tryAttachRegExp(HandleObject obj
, ObjOperandId objId
,
132 AttachDecision
tryAttachMap(HandleObject obj
, ObjOperandId objId
,
134 AttachDecision
tryAttachSet(HandleObject obj
, ObjOperandId objId
,
136 AttachDecision
tryAttachModuleNamespace(HandleObject obj
, ObjOperandId objId
,
138 AttachDecision
tryAttachWindowProxy(HandleObject obj
, ObjOperandId objId
,
140 AttachDecision
tryAttachCrossCompartmentWrapper(HandleObject obj
,
143 AttachDecision
tryAttachXrayCrossCompartmentWrapper(HandleObject obj
,
146 ValOperandId receiverId
);
147 AttachDecision
tryAttachFunction(HandleObject obj
, ObjOperandId objId
,
149 AttachDecision
tryAttachArgumentsObjectIterator(HandleObject obj
,
153 AttachDecision
tryAttachGenericProxy(Handle
<ProxyObject
*> obj
,
154 ObjOperandId objId
, HandleId id
,
155 bool handleDOMProxies
);
156 AttachDecision
tryAttachDOMProxyExpando(Handle
<ProxyObject
*> obj
,
157 ObjOperandId objId
, HandleId id
,
158 ValOperandId receiverId
);
159 AttachDecision
tryAttachDOMProxyShadowed(Handle
<ProxyObject
*> obj
,
160 ObjOperandId objId
, HandleId id
);
161 AttachDecision
tryAttachDOMProxyUnshadowed(Handle
<ProxyObject
*> obj
,
162 ObjOperandId objId
, HandleId id
,
163 ValOperandId receiverId
);
164 AttachDecision
tryAttachProxy(HandleObject obj
, ObjOperandId objId
,
165 HandleId id
, ValOperandId receiverId
);
167 AttachDecision
tryAttachPrimitive(ValOperandId valId
, HandleId id
);
168 AttachDecision
tryAttachStringChar(ValOperandId valId
, ValOperandId indexId
);
169 AttachDecision
tryAttachStringLength(ValOperandId valId
, HandleId id
);
171 AttachDecision
tryAttachArgumentsObjectArg(HandleObject obj
,
172 ObjOperandId objId
, uint32_t index
,
173 Int32OperandId indexId
);
174 AttachDecision
tryAttachArgumentsObjectArgHole(HandleObject obj
,
177 Int32OperandId indexId
);
178 AttachDecision
tryAttachArgumentsObjectCallee(HandleObject obj
,
182 AttachDecision
tryAttachDenseElement(HandleObject obj
, ObjOperandId objId
,
183 uint32_t index
, Int32OperandId indexId
);
184 AttachDecision
tryAttachDenseElementHole(HandleObject obj
, ObjOperandId objId
,
186 Int32OperandId indexId
);
187 AttachDecision
tryAttachSparseElement(HandleObject obj
, ObjOperandId objId
,
188 uint32_t index
, Int32OperandId indexId
);
189 AttachDecision
tryAttachTypedArrayElement(HandleObject obj
,
192 AttachDecision
tryAttachGenericElement(HandleObject obj
, ObjOperandId objId
,
193 uint32_t index
, Int32OperandId indexId
,
194 ValOperandId receiverId
);
196 AttachDecision
tryAttachProxyElement(HandleObject obj
, ObjOperandId objId
);
198 void attachMegamorphicNativeSlot(ObjOperandId objId
, jsid id
);
200 ValOperandId
getElemKeyValueId() const {
201 MOZ_ASSERT(cacheKind_
== CacheKind::GetElem
||
202 cacheKind_
== CacheKind::GetElemSuper
);
203 return ValOperandId(1);
206 ValOperandId
getSuperReceiverValueId() const {
207 if (cacheKind_
== CacheKind::GetPropSuper
) {
208 return ValOperandId(1);
211 MOZ_ASSERT(cacheKind_
== CacheKind::GetElemSuper
);
212 return ValOperandId(2);
215 bool isSuper() const {
216 return (cacheKind_
== CacheKind::GetPropSuper
||
217 cacheKind_
== CacheKind::GetElemSuper
);
220 // If this is a GetElem cache, emit instructions to guard the incoming Value
222 void maybeEmitIdGuard(jsid id
);
224 void trackAttached(const char* name
/* must be a C string literal */);
227 GetPropIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
228 ICState state
, CacheKind cacheKind
, HandleValue val
,
231 AttachDecision
tryAttachStub();
234 // GetNameIRGenerator generates CacheIR for a GetName IC.
235 class MOZ_RAII GetNameIRGenerator
: public IRGenerator
{
237 Handle
<PropertyName
*> name_
;
239 AttachDecision
tryAttachGlobalNameValue(ObjOperandId objId
, HandleId id
);
240 AttachDecision
tryAttachGlobalNameGetter(ObjOperandId objId
, HandleId id
);
241 AttachDecision
tryAttachEnvironmentName(ObjOperandId objId
, HandleId id
);
243 void trackAttached(const char* name
/* must be a C string literal */);
246 GetNameIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
247 ICState state
, HandleObject env
,
248 Handle
<PropertyName
*> name
);
250 AttachDecision
tryAttachStub();
253 // BindNameIRGenerator generates CacheIR for a BindName IC.
254 class MOZ_RAII BindNameIRGenerator
: public IRGenerator
{
256 Handle
<PropertyName
*> name_
;
258 AttachDecision
tryAttachGlobalName(ObjOperandId objId
, HandleId id
);
259 AttachDecision
tryAttachEnvironmentName(ObjOperandId objId
, HandleId id
);
261 void trackAttached(const char* name
/* must be a C string literal */);
264 BindNameIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
265 ICState state
, HandleObject env
,
266 Handle
<PropertyName
*> name
);
268 AttachDecision
tryAttachStub();
271 // SetPropIRGenerator generates CacheIR for a SetProp IC.
272 class MOZ_RAII SetPropIRGenerator
: public IRGenerator
{
278 enum class DeferType
{ None
, AddSlot
};
281 DeferType deferType_
= DeferType::None
;
283 ValOperandId
setElemKeyValueId() const {
284 MOZ_ASSERT(cacheKind_
== CacheKind::SetElem
);
285 return ValOperandId(1);
288 ValOperandId
rhsValueId() const {
289 if (cacheKind_
== CacheKind::SetProp
) {
290 return ValOperandId(1);
292 MOZ_ASSERT(cacheKind_
== CacheKind::SetElem
);
293 return ValOperandId(2);
296 // If this is a SetElem cache, emit instructions to guard the incoming Value
298 void maybeEmitIdGuard(jsid id
);
300 AttachDecision
tryAttachNativeSetSlot(HandleObject obj
, ObjOperandId objId
,
301 HandleId id
, ValOperandId rhsId
);
302 AttachDecision
tryAttachMegamorphicSetSlot(HandleObject obj
,
303 ObjOperandId objId
, HandleId id
,
305 AttachDecision
tryAttachSetter(HandleObject obj
, ObjOperandId objId
,
306 HandleId id
, ValOperandId rhsId
);
307 AttachDecision
tryAttachSetArrayLength(HandleObject obj
, ObjOperandId objId
,
308 HandleId id
, ValOperandId rhsId
);
309 AttachDecision
tryAttachWindowProxy(HandleObject obj
, ObjOperandId objId
,
310 HandleId id
, ValOperandId rhsId
);
312 AttachDecision
tryAttachSetDenseElement(HandleObject obj
, ObjOperandId objId
,
314 Int32OperandId indexId
,
316 AttachDecision
tryAttachSetTypedArrayElement(HandleObject obj
,
320 AttachDecision
tryAttachSetDenseElementHole(HandleObject obj
,
323 Int32OperandId indexId
,
326 AttachDecision
tryAttachAddOrUpdateSparseElement(HandleObject obj
,
329 Int32OperandId indexId
,
332 AttachDecision
tryAttachGenericProxy(Handle
<ProxyObject
*> obj
,
333 ObjOperandId objId
, HandleId id
,
335 bool handleDOMProxies
);
336 AttachDecision
tryAttachDOMProxyShadowed(Handle
<ProxyObject
*> obj
,
337 ObjOperandId objId
, HandleId id
,
339 AttachDecision
tryAttachDOMProxyUnshadowed(Handle
<ProxyObject
*> obj
,
340 ObjOperandId objId
, HandleId id
,
342 AttachDecision
tryAttachDOMProxyExpando(Handle
<ProxyObject
*> obj
,
343 ObjOperandId objId
, HandleId id
,
345 AttachDecision
tryAttachProxy(HandleObject obj
, ObjOperandId objId
,
346 HandleId id
, ValOperandId rhsId
);
347 AttachDecision
tryAttachProxyElement(HandleObject obj
, ObjOperandId objId
,
349 AttachDecision
tryAttachMegamorphicSetElement(HandleObject obj
,
353 bool canAttachAddSlotStub(HandleObject obj
, HandleId id
);
356 SetPropIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
357 CacheKind cacheKind
, ICState state
, HandleValue lhsVal
,
358 HandleValue idVal
, HandleValue rhsVal
);
360 AttachDecision
tryAttachStub();
361 AttachDecision
tryAttachAddSlotStub(Handle
<Shape
*> oldShape
);
362 void trackAttached(const char* name
/* must be a C string literal */);
364 DeferType
deferType() const { return deferType_
; }
367 // HasPropIRGenerator generates CacheIR for a HasProp IC. Used for
368 // CacheKind::In / CacheKind::HasOwn.
369 class MOZ_RAII HasPropIRGenerator
: public IRGenerator
{
373 AttachDecision
tryAttachDense(HandleObject obj
, ObjOperandId objId
,
374 uint32_t index
, Int32OperandId indexId
);
375 AttachDecision
tryAttachDenseHole(HandleObject obj
, ObjOperandId objId
,
376 uint32_t index
, Int32OperandId indexId
);
377 AttachDecision
tryAttachTypedArray(HandleObject obj
, ObjOperandId objId
,
379 AttachDecision
tryAttachSparse(HandleObject obj
, ObjOperandId objId
,
380 Int32OperandId indexId
);
381 AttachDecision
tryAttachArgumentsObjectArg(HandleObject obj
,
383 Int32OperandId indexId
);
384 AttachDecision
tryAttachNamedProp(HandleObject obj
, ObjOperandId objId
,
385 HandleId key
, ValOperandId keyId
);
386 AttachDecision
tryAttachMegamorphic(ObjOperandId objId
, ValOperandId keyId
);
387 AttachDecision
tryAttachNative(NativeObject
* obj
, ObjOperandId objId
,
388 jsid key
, ValOperandId keyId
,
389 PropertyResult prop
, NativeObject
* holder
);
390 AttachDecision
tryAttachSlotDoesNotExist(NativeObject
* obj
,
391 ObjOperandId objId
, jsid key
,
393 AttachDecision
tryAttachDoesNotExist(HandleObject obj
, ObjOperandId objId
,
394 HandleId key
, ValOperandId keyId
);
395 AttachDecision
tryAttachProxyElement(HandleObject obj
, ObjOperandId objId
,
398 void trackAttached(const char* name
/* must be a C string literal */);
401 // NOTE: Argument order is PROPERTY, OBJECT
402 HasPropIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
403 ICState state
, CacheKind cacheKind
, HandleValue idVal
,
406 AttachDecision
tryAttachStub();
409 class MOZ_RAII CheckPrivateFieldIRGenerator
: public IRGenerator
{
413 AttachDecision
tryAttachNative(NativeObject
* obj
, ObjOperandId objId
,
414 jsid key
, ValOperandId keyId
,
415 PropertyResult prop
);
417 void trackAttached(const char* name
/* must be a C string literal */);
420 CheckPrivateFieldIRGenerator(JSContext
* cx
, HandleScript script
,
421 jsbytecode
* pc
, ICState state
,
422 CacheKind cacheKind
, HandleValue idVal
,
424 AttachDecision
tryAttachStub();
427 class MOZ_RAII InstanceOfIRGenerator
: public IRGenerator
{
429 HandleObject rhsObj_
;
431 void trackAttached(const char* name
/* must be a C string literal */);
434 InstanceOfIRGenerator(JSContext
*, HandleScript
, jsbytecode
*, ICState
,
435 HandleValue
, HandleObject
);
437 AttachDecision
tryAttachStub();
440 class MOZ_RAII TypeOfIRGenerator
: public IRGenerator
{
443 AttachDecision
tryAttachPrimitive(ValOperandId valId
);
444 AttachDecision
tryAttachObject(ValOperandId valId
);
445 void trackAttached(const char* name
/* must be a C string literal */);
448 TypeOfIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
, ICState state
,
451 AttachDecision
tryAttachStub();
454 class MOZ_RAII GetIteratorIRGenerator
: public IRGenerator
{
457 AttachDecision
tryAttachObject(ValOperandId valId
);
458 AttachDecision
tryAttachNullOrUndefined(ValOperandId valId
);
459 AttachDecision
tryAttachGeneric(ValOperandId valId
);
462 GetIteratorIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
463 ICState state
, HandleValue value
);
465 AttachDecision
tryAttachStub();
467 void trackAttached(const char* name
/* must be a C string literal */);
470 class MOZ_RAII OptimizeSpreadCallIRGenerator
: public IRGenerator
{
473 AttachDecision
tryAttachArray();
474 AttachDecision
tryAttachArguments();
475 AttachDecision
tryAttachNotOptimizable();
478 OptimizeSpreadCallIRGenerator(JSContext
* cx
, HandleScript script
,
479 jsbytecode
* pc
, ICState state
,
482 AttachDecision
tryAttachStub();
484 void trackAttached(const char* name
/* must be a C string literal */);
487 enum class StringChar
{ CodeAt
, At
};
488 enum class ScriptedThisResult
{ NoAction
, UninitializedThis
, PlainObjectShape
};
490 class MOZ_RAII CallIRGenerator
: public IRGenerator
{
495 HandleValue thisval_
;
496 HandleValue newTarget_
;
497 HandleValueArray args_
;
499 friend class InlinableNativeIRGenerator
;
501 ScriptedThisResult
getThisShapeForScripted(HandleFunction calleeFunc
,
502 Handle
<JSObject
*> newTarget
,
503 MutableHandle
<Shape
*> result
);
505 ObjOperandId
emitFunCallOrApplyGuard(Int32OperandId argcId
);
506 ObjOperandId
emitFunCallGuard(Int32OperandId argcId
);
507 ObjOperandId
emitFunApplyGuard(Int32OperandId argcId
);
508 mozilla::Maybe
<ObjOperandId
> emitFunApplyArgsGuard(
509 CallFlags::ArgFormat format
);
511 void emitCallScriptedGuards(ObjOperandId calleeObjId
, JSFunction
* calleeFunc
,
512 Int32OperandId argcId
, CallFlags flags
,
513 Shape
* thisShape
, bool isBoundFunction
);
515 AttachDecision
tryAttachFunCall(HandleFunction calleeFunc
);
516 AttachDecision
tryAttachFunApply(HandleFunction calleeFunc
);
517 AttachDecision
tryAttachCallScripted(HandleFunction calleeFunc
);
518 AttachDecision
tryAttachInlinableNative(HandleFunction calleeFunc
,
520 AttachDecision
tryAttachWasmCall(HandleFunction calleeFunc
);
521 AttachDecision
tryAttachCallNative(HandleFunction calleeFunc
);
522 AttachDecision
tryAttachCallHook(HandleObject calleeObj
);
523 AttachDecision
tryAttachBoundFunction(Handle
<BoundFunctionObject
*> calleeObj
);
525 void trackAttached(const char* name
/* must be a C string literal */);
528 CallIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
, JSOp op
,
529 ICState state
, uint32_t argc
, HandleValue callee
,
530 HandleValue thisval
, HandleValue newTarget
,
531 HandleValueArray args
);
533 AttachDecision
tryAttachStub();
536 class MOZ_RAII InlinableNativeIRGenerator
{
537 CallIRGenerator
& generator_
;
538 CacheIRWriter
& writer
;
541 HandleFunction callee_
;
542 HandleValue newTarget_
;
543 HandleValue thisval_
;
544 HandleValueArray args_
;
548 HandleScript
script() const { return generator_
.script_
; }
549 bool isFirstStub() const { return generator_
.isFirstStub_
; }
550 bool ignoresResult() const { return generator_
.op_
== JSOp::CallIgnoresRv
; }
552 void emitNativeCalleeGuard();
553 void emitOptimisticClassGuard(ObjOperandId objId
, JSObject
* obj
,
554 GuardClassKind kind
) {
555 generator_
.emitOptimisticClassGuard(objId
, obj
, kind
);
558 ObjOperandId
emitLoadArgsArray();
560 void initializeInputOperand() {
561 // The input operand is already initialized for FunCall and FunApplyArray.
562 if (flags_
.getArgFormat() == CallFlags::FunCall
||
563 flags_
.getArgFormat() == CallFlags::FunApplyArray
) {
566 (void)writer
.setInputOperandId(0);
569 auto emitToStringGuard(ValOperandId id
, const Value
& v
) {
570 return generator_
.emitToStringGuard(id
, v
);
573 auto emitNumericGuard(ValOperandId valId
, Scalar::Type type
) {
574 return generator_
.emitNumericGuard(valId
, type
);
577 auto guardToIntPtrIndex(const Value
& index
, ValOperandId indexId
,
579 return generator_
.guardToIntPtrIndex(index
, indexId
, supportOOB
);
582 bool canAttachAtomicsReadWriteModify();
584 struct AtomicsReadWriteModifyOperands
{
586 IntPtrOperandId intPtrIndexId
;
587 OperandId numericValueId
;
590 AtomicsReadWriteModifyOperands
emitAtomicsReadWriteModifyOperands();
592 AttachDecision
tryAttachArrayPush();
593 AttachDecision
tryAttachArrayPopShift(InlinableNative native
);
594 AttachDecision
tryAttachArrayJoin();
595 AttachDecision
tryAttachArraySlice();
596 AttachDecision
tryAttachArrayIsArray();
597 AttachDecision
tryAttachDataViewGet(Scalar::Type type
);
598 AttachDecision
tryAttachDataViewSet(Scalar::Type type
);
599 AttachDecision
tryAttachFunctionBind();
600 AttachDecision
tryAttachSpecializedFunctionBind(
601 Handle
<JSObject
*> target
, Handle
<BoundFunctionObject
*> templateObj
);
602 AttachDecision
tryAttachUnsafeGetReservedSlot(InlinableNative native
);
603 AttachDecision
tryAttachUnsafeSetReservedSlot();
604 AttachDecision
tryAttachIsSuspendedGenerator();
605 AttachDecision
tryAttachToObject();
606 AttachDecision
tryAttachToInteger();
607 AttachDecision
tryAttachToLength();
608 AttachDecision
tryAttachIsObject();
609 AttachDecision
tryAttachIsPackedArray();
610 AttachDecision
tryAttachIsCallable();
611 AttachDecision
tryAttachIsConstructor();
612 AttachDecision
tryAttachIsCrossRealmArrayConstructor();
613 AttachDecision
tryAttachGuardToClass(InlinableNative native
);
614 AttachDecision
tryAttachHasClass(const JSClass
* clasp
,
615 bool isPossiblyWrapped
);
616 AttachDecision
tryAttachRegExpMatcherSearcher(InlinableNative native
);
617 AttachDecision
tryAttachRegExpPrototypeOptimizable();
618 AttachDecision
tryAttachRegExpInstanceOptimizable();
619 AttachDecision
tryAttachIntrinsicRegExpBuiltinExec(InlinableNative native
);
620 AttachDecision
tryAttachIntrinsicRegExpExec(InlinableNative native
);
621 AttachDecision
tryAttachGetFirstDollarIndex();
622 AttachDecision
tryAttachSubstringKernel();
623 AttachDecision
tryAttachObjectHasPrototype();
624 AttachDecision
tryAttachString();
625 AttachDecision
tryAttachStringConstructor();
626 AttachDecision
tryAttachStringToStringValueOf();
627 AttachDecision
tryAttachStringChar(StringChar kind
);
628 AttachDecision
tryAttachStringCharCodeAt();
629 AttachDecision
tryAttachStringCharAt();
630 AttachDecision
tryAttachStringFromCharCode();
631 AttachDecision
tryAttachStringFromCodePoint();
632 AttachDecision
tryAttachStringIndexOf();
633 AttachDecision
tryAttachStringStartsWith();
634 AttachDecision
tryAttachStringEndsWith();
635 AttachDecision
tryAttachStringToLowerCase();
636 AttachDecision
tryAttachStringToUpperCase();
637 AttachDecision
tryAttachStringReplaceString();
638 AttachDecision
tryAttachStringSplitString();
639 AttachDecision
tryAttachMathRandom();
640 AttachDecision
tryAttachMathAbs();
641 AttachDecision
tryAttachMathClz32();
642 AttachDecision
tryAttachMathSign();
643 AttachDecision
tryAttachMathImul();
644 AttachDecision
tryAttachMathFloor();
645 AttachDecision
tryAttachMathCeil();
646 AttachDecision
tryAttachMathTrunc();
647 AttachDecision
tryAttachMathRound();
648 AttachDecision
tryAttachMathSqrt();
649 AttachDecision
tryAttachMathFRound();
650 AttachDecision
tryAttachMathHypot();
651 AttachDecision
tryAttachMathATan2();
652 AttachDecision
tryAttachMathFunction(UnaryMathFunction fun
);
653 AttachDecision
tryAttachMathPow();
654 AttachDecision
tryAttachMathMinMax(bool isMax
);
655 AttachDecision
tryAttachSpreadMathMinMax(bool isMax
);
656 AttachDecision
tryAttachIsTypedArray(bool isPossiblyWrapped
);
657 AttachDecision
tryAttachIsTypedArrayConstructor();
658 AttachDecision
tryAttachTypedArrayByteOffset();
659 AttachDecision
tryAttachTypedArrayElementSize();
660 AttachDecision
tryAttachTypedArrayLength(bool isPossiblyWrapped
);
661 AttachDecision
tryAttachArrayBufferByteLength(bool isPossiblyWrapped
);
662 AttachDecision
tryAttachIsConstructing();
663 AttachDecision
tryAttachGetNextMapSetEntryForIterator(bool isMap
);
664 AttachDecision
tryAttachNewArrayIterator();
665 AttachDecision
tryAttachNewStringIterator();
666 AttachDecision
tryAttachNewRegExpStringIterator();
667 AttachDecision
tryAttachArrayIteratorPrototypeOptimizable();
668 AttachDecision
tryAttachObjectCreate();
669 AttachDecision
tryAttachObjectConstructor();
670 AttachDecision
tryAttachArrayConstructor();
671 AttachDecision
tryAttachTypedArrayConstructor();
672 AttachDecision
tryAttachNumber();
673 AttachDecision
tryAttachNumberParseInt();
674 AttachDecision
tryAttachNumberToString();
675 AttachDecision
tryAttachReflectGetPrototypeOf();
676 AttachDecision
tryAttachAtomicsCompareExchange();
677 AttachDecision
tryAttachAtomicsExchange();
678 AttachDecision
tryAttachAtomicsAdd();
679 AttachDecision
tryAttachAtomicsSub();
680 AttachDecision
tryAttachAtomicsAnd();
681 AttachDecision
tryAttachAtomicsOr();
682 AttachDecision
tryAttachAtomicsXor();
683 AttachDecision
tryAttachAtomicsLoad();
684 AttachDecision
tryAttachAtomicsStore();
685 AttachDecision
tryAttachAtomicsIsLockFree();
686 AttachDecision
tryAttachBoolean();
687 AttachDecision
tryAttachBailout();
688 AttachDecision
tryAttachAssertFloat32();
689 AttachDecision
tryAttachAssertRecoveredOnBailout();
690 AttachDecision
tryAttachObjectIs();
691 AttachDecision
tryAttachObjectIsPrototypeOf();
692 AttachDecision
tryAttachObjectToString();
693 AttachDecision
tryAttachBigIntAsIntN();
694 AttachDecision
tryAttachBigIntAsUintN();
695 AttachDecision
tryAttachSetHas();
696 AttachDecision
tryAttachMapHas();
697 AttachDecision
tryAttachMapGet();
698 #ifdef FUZZING_JS_FUZZILLI
699 AttachDecision
tryAttachFuzzilliHash();
702 void trackAttached(const char* name
/* must be a C string literal */) {
703 return generator_
.trackAttached(name
);
707 InlinableNativeIRGenerator(CallIRGenerator
& generator
, HandleFunction callee
,
708 HandleValue newTarget
, HandleValue thisValue
,
709 HandleValueArray args
, CallFlags flags
)
710 : generator_(generator
),
711 writer(generator
.writer
),
714 newTarget_(newTarget
),
717 argc_(args
.length()),
720 AttachDecision
tryAttachStub();
723 class MOZ_RAII CompareIRGenerator
: public IRGenerator
{
728 AttachDecision
tryAttachString(ValOperandId lhsId
, ValOperandId rhsId
);
729 AttachDecision
tryAttachObject(ValOperandId lhsId
, ValOperandId rhsId
);
730 AttachDecision
tryAttachSymbol(ValOperandId lhsId
, ValOperandId rhsId
);
731 AttachDecision
tryAttachStrictDifferentTypes(ValOperandId lhsId
,
733 AttachDecision
tryAttachInt32(ValOperandId lhsId
, ValOperandId rhsId
);
734 AttachDecision
tryAttachNumber(ValOperandId lhsId
, ValOperandId rhsId
);
735 AttachDecision
tryAttachBigInt(ValOperandId lhsId
, ValOperandId rhsId
);
736 AttachDecision
tryAttachAnyNullUndefined(ValOperandId lhsId
,
738 AttachDecision
tryAttachNullUndefined(ValOperandId lhsId
, ValOperandId rhsId
);
739 AttachDecision
tryAttachStringNumber(ValOperandId lhsId
, ValOperandId rhsId
);
740 AttachDecision
tryAttachPrimitiveSymbol(ValOperandId lhsId
,
742 AttachDecision
tryAttachBigIntInt32(ValOperandId lhsId
, ValOperandId rhsId
);
743 AttachDecision
tryAttachBigIntNumber(ValOperandId lhsId
, ValOperandId rhsId
);
744 AttachDecision
tryAttachBigIntString(ValOperandId lhsId
, ValOperandId rhsId
);
746 void trackAttached(const char* name
/* must be a C string literal */);
749 CompareIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
, ICState state
,
750 JSOp op
, HandleValue lhsVal
, HandleValue rhsVal
);
752 AttachDecision
tryAttachStub();
755 class MOZ_RAII ToBoolIRGenerator
: public IRGenerator
{
758 AttachDecision
tryAttachBool();
759 AttachDecision
tryAttachInt32();
760 AttachDecision
tryAttachNumber();
761 AttachDecision
tryAttachString();
762 AttachDecision
tryAttachSymbol();
763 AttachDecision
tryAttachNullOrUndefined();
764 AttachDecision
tryAttachObject();
765 AttachDecision
tryAttachBigInt();
767 void trackAttached(const char* name
/* must be a C string literal */);
770 ToBoolIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
, ICState state
,
773 AttachDecision
tryAttachStub();
776 class MOZ_RAII GetIntrinsicIRGenerator
: public IRGenerator
{
779 void trackAttached(const char* name
/* must be a C string literal */);
782 GetIntrinsicIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
783 ICState state
, HandleValue val
);
785 AttachDecision
tryAttachStub();
788 class MOZ_RAII UnaryArithIRGenerator
: public IRGenerator
{
793 AttachDecision
tryAttachInt32();
794 AttachDecision
tryAttachNumber();
795 AttachDecision
tryAttachBitwise();
796 AttachDecision
tryAttachBigInt();
797 AttachDecision
tryAttachStringInt32();
798 AttachDecision
tryAttachStringNumber();
800 void trackAttached(const char* name
/* must be a C string literal */);
803 UnaryArithIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
804 ICState state
, JSOp op
, HandleValue val
,
807 AttachDecision
tryAttachStub();
810 class MOZ_RAII ToPropertyKeyIRGenerator
: public IRGenerator
{
813 AttachDecision
tryAttachInt32();
814 AttachDecision
tryAttachNumber();
815 AttachDecision
tryAttachString();
816 AttachDecision
tryAttachSymbol();
818 void trackAttached(const char* name
/* must be a C string literal */);
821 ToPropertyKeyIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
822 ICState state
, HandleValue val
);
824 AttachDecision
tryAttachStub();
827 class MOZ_RAII BinaryArithIRGenerator
: public IRGenerator
{
833 void trackAttached(const char* name
/* must be a C string literal */);
835 AttachDecision
tryAttachInt32();
836 AttachDecision
tryAttachDouble();
837 AttachDecision
tryAttachBitwise();
838 AttachDecision
tryAttachStringConcat();
839 AttachDecision
tryAttachStringObjectConcat();
840 AttachDecision
tryAttachBigInt();
841 AttachDecision
tryAttachStringInt32Arith();
844 BinaryArithIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
845 ICState state
, JSOp op
, HandleValue lhs
,
846 HandleValue rhs
, HandleValue res
);
848 AttachDecision
tryAttachStub();
851 class MOZ_RAII NewArrayIRGenerator
: public IRGenerator
{
852 #ifdef JS_CACHEIR_SPEW
855 HandleObject templateObject_
;
856 BaselineFrame
* frame_
;
858 void trackAttached(const char* name
/* must be a C string literal */);
861 NewArrayIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
862 ICState state
, JSOp op
, HandleObject templateObj
,
863 BaselineFrame
* frame
);
865 AttachDecision
tryAttachStub();
866 AttachDecision
tryAttachArrayObject();
869 class MOZ_RAII NewObjectIRGenerator
: public IRGenerator
{
870 #ifdef JS_CACHEIR_SPEW
873 HandleObject templateObject_
;
874 BaselineFrame
* frame_
;
876 void trackAttached(const char* name
/* must be a C string literal */);
879 NewObjectIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
880 ICState state
, JSOp op
, HandleObject templateObj
,
881 BaselineFrame
* frame
);
883 AttachDecision
tryAttachStub();
884 AttachDecision
tryAttachPlainObject();
887 inline bool BytecodeOpCanHaveAllocSite(JSOp op
) {
888 return op
== JSOp::NewArray
|| op
== JSOp::NewObject
|| op
== JSOp::NewInit
;
891 class MOZ_RAII CloseIterIRGenerator
: public IRGenerator
{
893 CompletionKind kind_
;
895 void trackAttached(const char* name
/* must be a C string literal */);
898 CloseIterIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
899 ICState state
, HandleObject iter
, CompletionKind kind
);
901 AttachDecision
tryAttachStub();
902 AttachDecision
tryAttachNoReturnMethod();
903 AttachDecision
tryAttachScriptedReturn();
906 // Retrieve Xray JIT info set by the embedder.
907 extern JS::XrayJitInfo
* GetXrayJitInfo();
912 #endif /* jit_CacheIRGenerator_h */