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
);
157 AttachDecision
tryAttachScriptedProxy(Handle
<ProxyObject
*> obj
,
158 ObjOperandId objId
, HandleId id
);
160 AttachDecision
tryAttachDOMProxyExpando(Handle
<ProxyObject
*> obj
,
161 ObjOperandId objId
, HandleId id
,
162 ValOperandId receiverId
);
163 AttachDecision
tryAttachDOMProxyShadowed(Handle
<ProxyObject
*> obj
,
164 ObjOperandId objId
, HandleId id
);
165 AttachDecision
tryAttachDOMProxyUnshadowed(Handle
<ProxyObject
*> obj
,
166 ObjOperandId objId
, HandleId id
,
167 ValOperandId receiverId
);
168 AttachDecision
tryAttachProxy(HandleObject obj
, ObjOperandId objId
,
169 HandleId id
, ValOperandId receiverId
);
171 AttachDecision
tryAttachPrimitive(ValOperandId valId
, HandleId id
);
172 AttachDecision
tryAttachStringChar(ValOperandId valId
, ValOperandId indexId
);
173 AttachDecision
tryAttachStringLength(ValOperandId valId
, HandleId id
);
175 AttachDecision
tryAttachArgumentsObjectArg(HandleObject obj
,
176 ObjOperandId objId
, uint32_t index
,
177 Int32OperandId indexId
);
178 AttachDecision
tryAttachArgumentsObjectArgHole(HandleObject obj
,
181 Int32OperandId indexId
);
182 AttachDecision
tryAttachArgumentsObjectCallee(HandleObject obj
,
186 AttachDecision
tryAttachDenseElement(HandleObject obj
, ObjOperandId objId
,
187 uint32_t index
, Int32OperandId indexId
);
188 AttachDecision
tryAttachDenseElementHole(HandleObject obj
, ObjOperandId objId
,
190 Int32OperandId indexId
);
191 AttachDecision
tryAttachSparseElement(HandleObject obj
, ObjOperandId objId
,
192 uint32_t index
, Int32OperandId indexId
);
193 AttachDecision
tryAttachTypedArrayElement(HandleObject obj
,
196 AttachDecision
tryAttachGenericElement(HandleObject obj
, ObjOperandId objId
,
197 uint32_t index
, Int32OperandId indexId
,
198 ValOperandId receiverId
);
200 AttachDecision
tryAttachProxyElement(HandleObject obj
, ObjOperandId objId
);
202 void attachMegamorphicNativeSlot(ObjOperandId objId
, jsid id
);
204 ValOperandId
getElemKeyValueId() const {
205 MOZ_ASSERT(cacheKind_
== CacheKind::GetElem
||
206 cacheKind_
== CacheKind::GetElemSuper
);
207 return ValOperandId(1);
210 ValOperandId
getSuperReceiverValueId() const {
211 if (cacheKind_
== CacheKind::GetPropSuper
) {
212 return ValOperandId(1);
215 MOZ_ASSERT(cacheKind_
== CacheKind::GetElemSuper
);
216 return ValOperandId(2);
219 bool isSuper() const {
220 return (cacheKind_
== CacheKind::GetPropSuper
||
221 cacheKind_
== CacheKind::GetElemSuper
);
224 // If this is a GetElem cache, emit instructions to guard the incoming Value
226 void maybeEmitIdGuard(jsid id
);
228 void trackAttached(const char* name
/* must be a C string literal */);
231 GetPropIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
232 ICState state
, CacheKind cacheKind
, HandleValue val
,
235 AttachDecision
tryAttachStub();
238 // GetNameIRGenerator generates CacheIR for a GetName IC.
239 class MOZ_RAII GetNameIRGenerator
: public IRGenerator
{
241 Handle
<PropertyName
*> name_
;
243 AttachDecision
tryAttachGlobalNameValue(ObjOperandId objId
, HandleId id
);
244 AttachDecision
tryAttachGlobalNameGetter(ObjOperandId objId
, HandleId id
);
245 AttachDecision
tryAttachEnvironmentName(ObjOperandId objId
, HandleId id
);
247 void trackAttached(const char* name
/* must be a C string literal */);
250 GetNameIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
251 ICState state
, HandleObject env
,
252 Handle
<PropertyName
*> name
);
254 AttachDecision
tryAttachStub();
257 // BindNameIRGenerator generates CacheIR for a BindName IC.
258 class MOZ_RAII BindNameIRGenerator
: public IRGenerator
{
260 Handle
<PropertyName
*> name_
;
262 AttachDecision
tryAttachGlobalName(ObjOperandId objId
, HandleId id
);
263 AttachDecision
tryAttachEnvironmentName(ObjOperandId objId
, HandleId id
);
265 void trackAttached(const char* name
/* must be a C string literal */);
268 BindNameIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
269 ICState state
, HandleObject env
,
270 Handle
<PropertyName
*> name
);
272 AttachDecision
tryAttachStub();
275 // SetPropIRGenerator generates CacheIR for a SetProp IC.
276 class MOZ_RAII SetPropIRGenerator
: public IRGenerator
{
282 enum class DeferType
{ None
, AddSlot
};
285 DeferType deferType_
= DeferType::None
;
287 ValOperandId
setElemKeyValueId() const {
288 MOZ_ASSERT(cacheKind_
== CacheKind::SetElem
);
289 return ValOperandId(1);
292 ValOperandId
rhsValueId() const {
293 if (cacheKind_
== CacheKind::SetProp
) {
294 return ValOperandId(1);
296 MOZ_ASSERT(cacheKind_
== CacheKind::SetElem
);
297 return ValOperandId(2);
300 // If this is a SetElem cache, emit instructions to guard the incoming Value
302 void maybeEmitIdGuard(jsid id
);
304 AttachDecision
tryAttachNativeSetSlot(HandleObject obj
, ObjOperandId objId
,
305 HandleId id
, ValOperandId rhsId
);
306 AttachDecision
tryAttachMegamorphicSetSlot(HandleObject obj
,
307 ObjOperandId objId
, HandleId id
,
309 AttachDecision
tryAttachSetter(HandleObject obj
, ObjOperandId objId
,
310 HandleId id
, ValOperandId rhsId
);
311 AttachDecision
tryAttachSetArrayLength(HandleObject obj
, ObjOperandId objId
,
312 HandleId id
, ValOperandId rhsId
);
313 AttachDecision
tryAttachWindowProxy(HandleObject obj
, ObjOperandId objId
,
314 HandleId id
, ValOperandId rhsId
);
316 AttachDecision
tryAttachSetDenseElement(HandleObject obj
, ObjOperandId objId
,
318 Int32OperandId indexId
,
320 AttachDecision
tryAttachSetTypedArrayElement(HandleObject obj
,
324 AttachDecision
tryAttachSetDenseElementHole(HandleObject obj
,
327 Int32OperandId indexId
,
330 AttachDecision
tryAttachAddOrUpdateSparseElement(HandleObject obj
,
333 Int32OperandId indexId
,
336 AttachDecision
tryAttachGenericProxy(Handle
<ProxyObject
*> obj
,
337 ObjOperandId objId
, HandleId id
,
339 bool handleDOMProxies
);
340 AttachDecision
tryAttachDOMProxyShadowed(Handle
<ProxyObject
*> obj
,
341 ObjOperandId objId
, HandleId id
,
343 AttachDecision
tryAttachDOMProxyUnshadowed(Handle
<ProxyObject
*> obj
,
344 ObjOperandId objId
, HandleId id
,
346 AttachDecision
tryAttachDOMProxyExpando(Handle
<ProxyObject
*> obj
,
347 ObjOperandId objId
, HandleId id
,
349 AttachDecision
tryAttachProxy(HandleObject obj
, ObjOperandId objId
,
350 HandleId id
, ValOperandId rhsId
);
351 AttachDecision
tryAttachProxyElement(HandleObject obj
, ObjOperandId objId
,
353 AttachDecision
tryAttachMegamorphicSetElement(HandleObject obj
,
357 bool canAttachAddSlotStub(HandleObject obj
, HandleId id
);
360 SetPropIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
361 CacheKind cacheKind
, ICState state
, HandleValue lhsVal
,
362 HandleValue idVal
, HandleValue rhsVal
);
364 AttachDecision
tryAttachStub();
365 AttachDecision
tryAttachAddSlotStub(Handle
<Shape
*> oldShape
);
366 void trackAttached(const char* name
/* must be a C string literal */);
368 DeferType
deferType() const { return deferType_
; }
371 // HasPropIRGenerator generates CacheIR for a HasProp IC. Used for
372 // CacheKind::In / CacheKind::HasOwn.
373 class MOZ_RAII HasPropIRGenerator
: public IRGenerator
{
377 AttachDecision
tryAttachDense(HandleObject obj
, ObjOperandId objId
,
378 uint32_t index
, Int32OperandId indexId
);
379 AttachDecision
tryAttachDenseHole(HandleObject obj
, ObjOperandId objId
,
380 uint32_t index
, Int32OperandId indexId
);
381 AttachDecision
tryAttachTypedArray(HandleObject obj
, ObjOperandId objId
,
383 AttachDecision
tryAttachSparse(HandleObject obj
, ObjOperandId objId
,
384 Int32OperandId indexId
);
385 AttachDecision
tryAttachArgumentsObjectArg(HandleObject obj
,
387 Int32OperandId indexId
);
388 AttachDecision
tryAttachNamedProp(HandleObject obj
, ObjOperandId objId
,
389 HandleId key
, ValOperandId keyId
);
390 AttachDecision
tryAttachMegamorphic(ObjOperandId objId
, ValOperandId keyId
);
391 AttachDecision
tryAttachNative(NativeObject
* obj
, ObjOperandId objId
,
392 jsid key
, ValOperandId keyId
,
393 PropertyResult prop
, NativeObject
* holder
);
394 AttachDecision
tryAttachSlotDoesNotExist(NativeObject
* obj
,
395 ObjOperandId objId
, jsid key
,
397 AttachDecision
tryAttachDoesNotExist(HandleObject obj
, ObjOperandId objId
,
398 HandleId key
, ValOperandId keyId
);
399 AttachDecision
tryAttachProxyElement(HandleObject obj
, ObjOperandId objId
,
402 void trackAttached(const char* name
/* must be a C string literal */);
405 // NOTE: Argument order is PROPERTY, OBJECT
406 HasPropIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
,
407 ICState state
, CacheKind cacheKind
, HandleValue idVal
,
410 AttachDecision
tryAttachStub();
413 class MOZ_RAII CheckPrivateFieldIRGenerator
: public IRGenerator
{
417 AttachDecision
tryAttachNative(NativeObject
* obj
, ObjOperandId objId
,
418 jsid key
, ValOperandId keyId
,
419 PropertyResult prop
);
421 void trackAttached(const char* name
/* must be a C string literal */);
424 CheckPrivateFieldIRGenerator(JSContext
* cx
, HandleScript script
,
425 jsbytecode
* pc
, ICState state
,
426 CacheKind cacheKind
, HandleValue idVal
,
428 AttachDecision
tryAttachStub();
431 class MOZ_RAII InstanceOfIRGenerator
: public IRGenerator
{
433 HandleObject rhsObj_
;
435 void trackAttached(const char* name
/* must be a C string literal */);
438 InstanceOfIRGenerator(JSContext
*, HandleScript
, jsbytecode
*, ICState
,
439 HandleValue
, HandleObject
);
441 AttachDecision
tryAttachStub();
444 class MOZ_RAII TypeOfIRGenerator
: public IRGenerator
{
447 AttachDecision
tryAttachPrimitive(ValOperandId valId
);
448 AttachDecision
tryAttachObject(ValOperandId valId
);
449 void trackAttached(const char* name
/* must be a C string literal */);
452 TypeOfIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
, ICState state
,
455 AttachDecision
tryAttachStub();
458 class MOZ_RAII GetIteratorIRGenerator
: public IRGenerator
{
461 AttachDecision
tryAttachObject(ValOperandId valId
);
462 AttachDecision
tryAttachNullOrUndefined(ValOperandId valId
);
463 AttachDecision
tryAttachGeneric(ValOperandId valId
);
466 GetIteratorIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
467 ICState state
, HandleValue value
);
469 AttachDecision
tryAttachStub();
471 void trackAttached(const char* name
/* must be a C string literal */);
474 class MOZ_RAII OptimizeSpreadCallIRGenerator
: public IRGenerator
{
477 AttachDecision
tryAttachArray();
478 AttachDecision
tryAttachArguments();
479 AttachDecision
tryAttachNotOptimizable();
482 OptimizeSpreadCallIRGenerator(JSContext
* cx
, HandleScript script
,
483 jsbytecode
* pc
, ICState state
,
486 AttachDecision
tryAttachStub();
488 void trackAttached(const char* name
/* must be a C string literal */);
491 class MOZ_RAII OptimizeGetIteratorIRGenerator
: public IRGenerator
{
494 AttachDecision
tryAttachArray();
495 AttachDecision
tryAttachNotOptimizable();
498 OptimizeGetIteratorIRGenerator(JSContext
* cx
, HandleScript script
,
499 jsbytecode
* pc
, ICState state
,
502 AttachDecision
tryAttachStub();
504 void trackAttached(const char* name
/* must be a C string literal */);
507 enum class StringChar
{ CharCodeAt
, CodePointAt
, CharAt
};
508 enum class ScriptedThisResult
{ NoAction
, UninitializedThis
, PlainObjectShape
};
510 class MOZ_RAII CallIRGenerator
: public IRGenerator
{
515 HandleValue thisval_
;
516 HandleValue newTarget_
;
517 HandleValueArray args_
;
519 friend class InlinableNativeIRGenerator
;
521 ScriptedThisResult
getThisShapeForScripted(HandleFunction calleeFunc
,
522 Handle
<JSObject
*> newTarget
,
523 MutableHandle
<Shape
*> result
);
525 ObjOperandId
emitFunCallOrApplyGuard(Int32OperandId argcId
);
526 ObjOperandId
emitFunCallGuard(Int32OperandId argcId
);
527 ObjOperandId
emitFunApplyGuard(Int32OperandId argcId
);
528 mozilla::Maybe
<ObjOperandId
> emitFunApplyArgsGuard(
529 CallFlags::ArgFormat format
);
531 void emitCallScriptedGuards(ObjOperandId calleeObjId
, JSFunction
* calleeFunc
,
532 Int32OperandId argcId
, CallFlags flags
,
533 Shape
* thisShape
, bool isBoundFunction
);
535 AttachDecision
tryAttachFunCall(HandleFunction calleeFunc
);
536 AttachDecision
tryAttachFunApply(HandleFunction calleeFunc
);
537 AttachDecision
tryAttachCallScripted(HandleFunction calleeFunc
);
538 AttachDecision
tryAttachInlinableNative(HandleFunction calleeFunc
,
540 AttachDecision
tryAttachWasmCall(HandleFunction calleeFunc
);
541 AttachDecision
tryAttachCallNative(HandleFunction calleeFunc
);
542 AttachDecision
tryAttachCallHook(HandleObject calleeObj
);
543 AttachDecision
tryAttachBoundFunction(Handle
<BoundFunctionObject
*> calleeObj
);
545 void trackAttached(const char* name
/* must be a C string literal */);
548 CallIRGenerator(JSContext
* cx
, HandleScript script
, jsbytecode
* pc
, JSOp op
,
549 ICState state
, uint32_t argc
, HandleValue callee
,
550 HandleValue thisval
, HandleValue newTarget
,
551 HandleValueArray args
);
553 AttachDecision
tryAttachStub();
556 class MOZ_RAII InlinableNativeIRGenerator
{
557 CallIRGenerator
& generator_
;
558 CacheIRWriter
& writer
;
561 HandleFunction callee_
;
562 HandleValue newTarget_
;
563 HandleValue thisval_
;
564 HandleValueArray args_
;
568 HandleScript
script() const { return generator_
.script_
; }
569 bool isFirstStub() const { return generator_
.isFirstStub_
; }
570 bool ignoresResult() const { return generator_
.op_
== JSOp::CallIgnoresRv
; }
572 void emitNativeCalleeGuard();
573 void emitOptimisticClassGuard(ObjOperandId objId
, JSObject
* obj
,
574 GuardClassKind kind
) {
575 generator_
.emitOptimisticClassGuard(objId
, obj
, kind
);
578 ObjOperandId
emitLoadArgsArray();
580 void initializeInputOperand() {
581 // The input operand is already initialized for FunCall and FunApplyArray.
582 if (flags_
.getArgFormat() == CallFlags::FunCall
||
583 flags_
.getArgFormat() == CallFlags::FunApplyArray
) {
586 (void)writer
.setInputOperandId(0);
589 auto emitToStringGuard(ValOperandId id
, const Value
& v
) {
590 return generator_
.emitToStringGuard(id
, v
);
593 auto emitNumericGuard(ValOperandId valId
, Scalar::Type type
) {
594 return generator_
.emitNumericGuard(valId
, type
);
597 auto guardToIntPtrIndex(const Value
& index
, ValOperandId indexId
,
599 return generator_
.guardToIntPtrIndex(index
, indexId
, supportOOB
);
602 bool canAttachAtomicsReadWriteModify();
604 struct AtomicsReadWriteModifyOperands
{
606 IntPtrOperandId intPtrIndexId
;
607 OperandId numericValueId
;
610 AtomicsReadWriteModifyOperands
emitAtomicsReadWriteModifyOperands();
612 AttachDecision
tryAttachArrayPush();
613 AttachDecision
tryAttachArrayPopShift(InlinableNative native
);
614 AttachDecision
tryAttachArrayJoin();
615 AttachDecision
tryAttachArraySlice();
616 AttachDecision
tryAttachArrayIsArray();
617 AttachDecision
tryAttachDataViewGet(Scalar::Type type
);
618 AttachDecision
tryAttachDataViewSet(Scalar::Type type
);
619 AttachDecision
tryAttachFunctionBind();
620 AttachDecision
tryAttachSpecializedFunctionBind(
621 Handle
<JSObject
*> target
, Handle
<BoundFunctionObject
*> templateObj
);
622 AttachDecision
tryAttachUnsafeGetReservedSlot(InlinableNative native
);
623 AttachDecision
tryAttachUnsafeSetReservedSlot();
624 AttachDecision
tryAttachIsSuspendedGenerator();
625 AttachDecision
tryAttachToObject();
626 AttachDecision
tryAttachToInteger();
627 AttachDecision
tryAttachToLength();
628 AttachDecision
tryAttachIsObject();
629 AttachDecision
tryAttachIsPackedArray();
630 AttachDecision
tryAttachIsCallable();
631 AttachDecision
tryAttachIsConstructor();
632 AttachDecision
tryAttachIsCrossRealmArrayConstructor();
633 AttachDecision
tryAttachGuardToClass(InlinableNative native
);
634 AttachDecision
tryAttachHasClass(const JSClass
* clasp
,
635 bool isPossiblyWrapped
);
636 AttachDecision
tryAttachRegExpMatcherSearcher(InlinableNative native
);
637 AttachDecision
tryAttachRegExpSearcherLastLimit();
638 AttachDecision
tryAttachRegExpHasCaptureGroups();
639 AttachDecision
tryAttachRegExpPrototypeOptimizable();
640 AttachDecision
tryAttachRegExpInstanceOptimizable();
641 AttachDecision
tryAttachIntrinsicRegExpBuiltinExec(InlinableNative native
);
642 AttachDecision
tryAttachIntrinsicRegExpExec(InlinableNative native
);
643 AttachDecision
tryAttachGetFirstDollarIndex();
644 AttachDecision
tryAttachSubstringKernel();
645 AttachDecision
tryAttachObjectHasPrototype();
646 AttachDecision
tryAttachString();
647 AttachDecision
tryAttachStringConstructor();
648 AttachDecision
tryAttachStringToStringValueOf();
649 AttachDecision
tryAttachStringChar(StringChar kind
);
650 AttachDecision
tryAttachStringCharCodeAt();
651 AttachDecision
tryAttachStringCodePointAt();
652 AttachDecision
tryAttachStringCharAt();
653 AttachDecision
tryAttachStringFromCharCode();
654 AttachDecision
tryAttachStringFromCodePoint();
655 AttachDecision
tryAttachStringIncludes();
656 AttachDecision
tryAttachStringIndexOf();
657 AttachDecision
tryAttachStringLastIndexOf();
658 AttachDecision
tryAttachStringStartsWith();
659 AttachDecision
tryAttachStringEndsWith();
660 AttachDecision
tryAttachStringToLowerCase();
661 AttachDecision
tryAttachStringToUpperCase();
662 AttachDecision
tryAttachStringTrim();
663 AttachDecision
tryAttachStringTrimStart();
664 AttachDecision
tryAttachStringTrimEnd();
665 AttachDecision
tryAttachStringReplaceString();
666 AttachDecision
tryAttachStringSplitString();
667 AttachDecision
tryAttachMathRandom();
668 AttachDecision
tryAttachMathAbs();
669 AttachDecision
tryAttachMathClz32();
670 AttachDecision
tryAttachMathSign();
671 AttachDecision
tryAttachMathImul();
672 AttachDecision
tryAttachMathFloor();
673 AttachDecision
tryAttachMathCeil();
674 AttachDecision
tryAttachMathTrunc();
675 AttachDecision
tryAttachMathRound();
676 AttachDecision
tryAttachMathSqrt();
677 AttachDecision
tryAttachMathFRound();
678 AttachDecision
tryAttachMathHypot();
679 AttachDecision
tryAttachMathATan2();
680 AttachDecision
tryAttachMathFunction(UnaryMathFunction fun
);
681 AttachDecision
tryAttachMathPow();
682 AttachDecision
tryAttachMathMinMax(bool isMax
);
683 AttachDecision
tryAttachSpreadMathMinMax(bool isMax
);
684 AttachDecision
tryAttachIsTypedArray(bool isPossiblyWrapped
);
685 AttachDecision
tryAttachIsTypedArrayConstructor();
686 AttachDecision
tryAttachTypedArrayByteOffset();
687 AttachDecision
tryAttachTypedArrayElementSize();
688 AttachDecision
tryAttachTypedArrayLength(bool isPossiblyWrapped
);
689 AttachDecision
tryAttachArrayBufferByteLength(bool isPossiblyWrapped
);
690 AttachDecision
tryAttachIsConstructing();
691 AttachDecision
tryAttachGetNextMapSetEntryForIterator(bool isMap
);
692 AttachDecision
tryAttachNewArrayIterator();
693 AttachDecision
tryAttachNewStringIterator();
694 AttachDecision
tryAttachNewRegExpStringIterator();
695 AttachDecision
tryAttachArrayIteratorPrototypeOptimizable();
696 AttachDecision
tryAttachObjectCreate();
697 AttachDecision
tryAttachObjectConstructor();
698 AttachDecision
tryAttachArrayConstructor();
699 AttachDecision
tryAttachTypedArrayConstructor();
700 AttachDecision
tryAttachNumber();
701 AttachDecision
tryAttachNumberParseInt();
702 AttachDecision
tryAttachNumberToString();
703 AttachDecision
tryAttachReflectGetPrototypeOf();
704 AttachDecision
tryAttachAtomicsCompareExchange();
705 AttachDecision
tryAttachAtomicsExchange();
706 AttachDecision
tryAttachAtomicsAdd();
707 AttachDecision
tryAttachAtomicsSub();
708 AttachDecision
tryAttachAtomicsAnd();
709 AttachDecision
tryAttachAtomicsOr();
710 AttachDecision
tryAttachAtomicsXor();
711 AttachDecision
tryAttachAtomicsLoad();
712 AttachDecision
tryAttachAtomicsStore();
713 AttachDecision
tryAttachAtomicsIsLockFree();
714 AttachDecision
tryAttachBoolean();
715 AttachDecision
tryAttachBailout();
716 AttachDecision
tryAttachAssertFloat32();
717 AttachDecision
tryAttachAssertRecoveredOnBailout();
718 AttachDecision
tryAttachObjectIs();
719 AttachDecision
tryAttachObjectIsPrototypeOf();
720 AttachDecision
tryAttachObjectKeys();
721 AttachDecision
tryAttachObjectToString();
722 AttachDecision
tryAttachBigIntAsIntN();
723 AttachDecision
tryAttachBigIntAsUintN();
724 AttachDecision
tryAttachSetHas();
725 AttachDecision
tryAttachSetSize();
726 AttachDecision
tryAttachMapHas();
727 AttachDecision
tryAttachMapGet();
728 #ifdef FUZZING_JS_FUZZILLI
729 AttachDecision
tryAttachFuzzilliHash();
732 void trackAttached(const char* name
/* must be a C string literal */) {
733 return generator_
.trackAttached(name
);
737 InlinableNativeIRGenerator(CallIRGenerator
& generator
, HandleFunction callee
,
738 HandleValue newTarget
, HandleValue thisValue
,
739 HandleValueArray args
, CallFlags flags
)
740 : generator_(generator
),
741 writer(generator
.writer
),
744 newTarget_(newTarget
),
747 argc_(args
.length()),
750 AttachDecision
tryAttachStub();
753 class MOZ_RAII CompareIRGenerator
: public IRGenerator
{
758 AttachDecision
tryAttachString(ValOperandId lhsId
, ValOperandId rhsId
);
759 AttachDecision
tryAttachObject(ValOperandId lhsId
, ValOperandId rhsId
);
760 AttachDecision
tryAttachSymbol(ValOperandId lhsId
, ValOperandId rhsId
);
761 AttachDecision
tryAttachStrictDifferentTypes(ValOperandId lhsId
,
763 AttachDecision
tryAttachInt32(ValOperandId lhsId
, ValOperandId rhsId
);
764 AttachDecision
tryAttachNumber(ValOperandId lhsId
, ValOperandId rhsId
);
765 AttachDecision
tryAttachBigInt(ValOperandId lhsId
, ValOperandId rhsId
);
766 AttachDecision
tryAttachAnyNullUndefined(ValOperandId lhsId
,
768 AttachDecision
tryAttachNullUndefined(ValOperandId lhsId
, ValOperandId rhsId
);
769 AttachDecision
tryAttachStringNumber(ValOperandId lhsId
, ValOperandId rhsId
);
770 AttachDecision
tryAttachPrimitiveSymbol(ValOperandId lhsId
,
772 AttachDecision
tryAttachBigIntInt32(ValOperandId lhsId
, ValOperandId rhsId
);
773 AttachDecision
tryAttachBigIntNumber(ValOperandId lhsId
, ValOperandId rhsId
);
774 AttachDecision
tryAttachBigIntString(ValOperandId lhsId
, ValOperandId rhsId
);
776 void trackAttached(const char* name
/* must be a C string literal */);
779 CompareIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
, ICState state
,
780 JSOp op
, HandleValue lhsVal
, HandleValue rhsVal
);
782 AttachDecision
tryAttachStub();
785 class MOZ_RAII ToBoolIRGenerator
: public IRGenerator
{
788 AttachDecision
tryAttachBool();
789 AttachDecision
tryAttachInt32();
790 AttachDecision
tryAttachNumber();
791 AttachDecision
tryAttachString();
792 AttachDecision
tryAttachSymbol();
793 AttachDecision
tryAttachNullOrUndefined();
794 AttachDecision
tryAttachObject();
795 AttachDecision
tryAttachBigInt();
797 void trackAttached(const char* name
/* must be a C string literal */);
800 ToBoolIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
, ICState state
,
803 AttachDecision
tryAttachStub();
806 class MOZ_RAII GetIntrinsicIRGenerator
: public IRGenerator
{
809 void trackAttached(const char* name
/* must be a C string literal */);
812 GetIntrinsicIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
813 ICState state
, HandleValue val
);
815 AttachDecision
tryAttachStub();
818 class MOZ_RAII UnaryArithIRGenerator
: public IRGenerator
{
823 AttachDecision
tryAttachInt32();
824 AttachDecision
tryAttachNumber();
825 AttachDecision
tryAttachBitwise();
826 AttachDecision
tryAttachBigInt();
827 AttachDecision
tryAttachStringInt32();
828 AttachDecision
tryAttachStringNumber();
830 void trackAttached(const char* name
/* must be a C string literal */);
833 UnaryArithIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
834 ICState state
, JSOp op
, HandleValue val
,
837 AttachDecision
tryAttachStub();
840 class MOZ_RAII ToPropertyKeyIRGenerator
: public IRGenerator
{
843 AttachDecision
tryAttachInt32();
844 AttachDecision
tryAttachNumber();
845 AttachDecision
tryAttachString();
846 AttachDecision
tryAttachSymbol();
848 void trackAttached(const char* name
/* must be a C string literal */);
851 ToPropertyKeyIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
852 ICState state
, HandleValue val
);
854 AttachDecision
tryAttachStub();
857 class MOZ_RAII BinaryArithIRGenerator
: public IRGenerator
{
863 void trackAttached(const char* name
/* must be a C string literal */);
865 AttachDecision
tryAttachInt32();
866 AttachDecision
tryAttachDouble();
867 AttachDecision
tryAttachBitwise();
868 AttachDecision
tryAttachStringConcat();
869 AttachDecision
tryAttachStringObjectConcat();
870 AttachDecision
tryAttachBigInt();
871 AttachDecision
tryAttachStringInt32Arith();
872 AttachDecision
tryAttachStringNumberArith();
875 BinaryArithIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
876 ICState state
, JSOp op
, HandleValue lhs
,
877 HandleValue rhs
, HandleValue res
);
879 AttachDecision
tryAttachStub();
882 class MOZ_RAII NewArrayIRGenerator
: public IRGenerator
{
883 #ifdef JS_CACHEIR_SPEW
886 HandleObject templateObject_
;
887 BaselineFrame
* frame_
;
889 void trackAttached(const char* name
/* must be a C string literal */);
892 NewArrayIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
893 ICState state
, JSOp op
, HandleObject templateObj
,
894 BaselineFrame
* frame
);
896 AttachDecision
tryAttachStub();
897 AttachDecision
tryAttachArrayObject();
900 class MOZ_RAII NewObjectIRGenerator
: public IRGenerator
{
901 #ifdef JS_CACHEIR_SPEW
904 HandleObject templateObject_
;
905 BaselineFrame
* frame_
;
907 void trackAttached(const char* name
/* must be a C string literal */);
910 NewObjectIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
911 ICState state
, JSOp op
, HandleObject templateObj
,
912 BaselineFrame
* frame
);
914 AttachDecision
tryAttachStub();
915 AttachDecision
tryAttachPlainObject();
918 inline bool BytecodeOpCanHaveAllocSite(JSOp op
) {
919 return op
== JSOp::NewArray
|| op
== JSOp::NewObject
|| op
== JSOp::NewInit
;
922 class MOZ_RAII CloseIterIRGenerator
: public IRGenerator
{
924 CompletionKind kind_
;
926 void trackAttached(const char* name
/* must be a C string literal */);
929 CloseIterIRGenerator(JSContext
* cx
, HandleScript
, jsbytecode
* pc
,
930 ICState state
, HandleObject iter
, CompletionKind kind
);
932 AttachDecision
tryAttachStub();
933 AttachDecision
tryAttachNoReturnMethod();
934 AttachDecision
tryAttachScriptedReturn();
937 // Retrieve Xray JIT info set by the embedder.
938 extern JS::XrayJitInfo
* GetXrayJitInfo();
943 #endif /* jit_CacheIRGenerator_h */