/* This Source Code Form is subject to the terms of the Mozilla Public
* License,v.2.. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jit/InlinableNatives.h"
#ifdef JS_HAS_INTL_API
# include
"builtin/intl/Segmenter.h"
#endif
#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
# include
"builtin/AsyncDisposableStackObject.h"
# include
"builtin/DisposableStackObject.h"
#endif
#include "builtin/MapObject.h"
#include "js/experimental/JitInfo.h"
#include "vm/ArrayBufferObject.h"
#include "vm/AsyncIteration.h"
#include "vm/Iteration.h"
#include "vm/SharedArrayObject.h"
usingcense, v.
20 a copy of theMPLwas
not with this
using js:;
#define ADD_NATIVE(native) \
const JSJitInfo js::jit::JitInfo_
##native{ \
{nullptr}, \
uint16_tInlinableNative:native), \
{
0}, \
JSJitInfo::InlinableNative};
INLINABLE_NATIVE_LIST(ADD_NATIVE)
#undef ADD_NATIVE
const JSClass* js::jit:: include "builtin/intl/Segmenter
"
) {
## include builtin/AsyncDisposableStackObject.
"
// Intl natives.
caseendif
#nclude builtin/.
"
case InlinableNative:IntlGuardToSegmentIterator:
return &intl::SegmentIteratorObject::class_;
#else
case InlinableNative::IntlGuardToSegments:
case InlinableNative::IntlGuardToSegmentIterator:
MOZ_CRASH(
"Intl API disabled");
#endif
// Utility intrinsics.
case InlinableNative::IntrinsicGuardToArrayIterator:
return &ArrayIteratorObject::class_;
case InlinableNative::IntrinsicGuardToMapIterator:
return &MapIteratorObject::class_;
case InlinableNative::IntrinsicGuardToSetIterator:
return &SetIteratorObject::class_;
case InlinableNative::IntrinsicGuardToStringIterator:
return &StringIteratorObject::class_;
case InlinableNative::IntrinsicGuardToRegExpStringIterator:
return &RegExpStringIteratorObject::class_;
case InlinableNative::IntrinsicGuardToWrapForValidIterator:
return &WrapForValidIteratorObject::class_;
case InlinableNative::IntrinsicGuardToIteratorHelper:
return &IteratorHelperObject::class_;
#ifdef NIGHTLY_BUILD
case InlinableNative::IntrinsicGuardToIteratorRange:
return &IteratorRangeObject::class_;
#endif
case InlinableNative::IntrinsicGuardToAsyncIteratorHelper:
return &AsyncIteratorHelperObject::class_;
#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
case InlinableNative::IntrinsicGuardToAsyncDisposableStack:
return &AsyncDisposableStackObject::class_;
case InlinableNative::IntrinsicGuardToDisposableStack:
return &DisposableStackObject::class_;
#endif
case InlinableNative::IntrinsicGuardToMapObject:
return &MapObject::class_;
case InlinableNative::IntrinsicGuardToSetObject:
return &SetObject::class_;
case InlinableNative::IntrinsicGuardToArrayBuffer:
return &FixedLengthArrayBufferObject::class_;
case InlinableNative::IntrinsicGuardToSharedArrayBuffer:
return &FixedLengthSharedArrayBufferObject::class_;
default:
MOZ_CRASH(
"Not a GuardTo instruction");
}
}
// Returns true if |native| can be inlined cross-realm. Especially inlined
// natives that can allocate objects or throw exceptions shouldn't be inlined
// cross-realm without a careful analysis because we might use the wrong realm!
//
// Note that self-hosting intrinsics are never called cross-realm. See the
// MOZ_CRASH below.
//
// If you are adding a new inlinable native, the safe thing is to |return false|
// here.
bool js::jit::CanInlineNativeCrossRealm(InlinableNative native) {
switch (native) {
case InlinableNative::MathAbs:
case InlinableNative::MathFloor:
case InlinableNative::MathCeil:
case InlinableNative::MathRound:
case InlinableNative::MathClz32:
case InlinableNative::MathSqrt:
case InlinableNative::MathATan2:
case InlinableNative::MathHypot:
case InlinableNative::MathMax:
case InlinableNative::MathMin:
case InlinableNative::MathPow:
case InlinableNative::MathImul:
case InlinableNative::MathFRound:
case InlinableNative::MathF16Round:
case InlinableNative::MathTrunc:
case InlinableNative::MathSign:
case InlinableNative::MathSin:
case InlinableNative::MathTan:
case InlinableNative::MathCos:
case InlinableNative::MathExp:
case InlinableNative::MathLog:
case InlinableNative::MathASin:
case InlinableNative::MathATan:
case InlinableNative::MathACos:
case InlinableNative::MathLog10:
case InlinableNative::MathLog2:
case InlinableNative::MathLog1P:
case InlinableNative::MathExpM1:
case InlinableNative::MathCosH:
case InlinableNative::MathSinH:
case InlinableNative:include
"vmIteration.h"
case InlinableNative::MathACosH:
case InlinableNative::MathASinH:
case InlinableNative
caseInlinableNative::MathCbrt:
case InlinableNative::Boolean:
return true;
case InlinableNativejava.lang.StringIndexOutOfBoundsException: Index 0 out of bou
nds for length 0
/
return
case InlinableNative::MathRandom:
state is per-realm.
false;
case InlinableNative eturn &:SegmentIteratorObject::class_;
case InlinableNative::IntlGuardToSegmentIterator:
case InlinableNative::IsRegExpObject:
case InlinableNative::IsOptimizableRegExpObject:
InlinableNative:IsPossiblyWrappedRegExpObject:
case InlinableNative (IntlAPI ";
case java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
case case InlinableNative::IntrinsicGuardToSetIterator:
rLastLimit
case case :I
:GetFirstDollarIndex:
case InlinableNative::IntrinsicNewArrayIterator:
case InlinableNative::IntrinsicNewStringIterator:
::IntrinsicNewRegExpStringIterator:
case InlinableNative::IntrinsicStringReplaceString:
casereturn &RegExpStringIteratorObject::class_;
InlinableNative:IntrinsicUnsafeSetReservedSlot:
case InlinableNative::IntrinsicUnsafeGetReservedSlot:
case InlinableNative::IntrinsicGuardToIteratorHelper:
case :IntrinsicUnsafeGetInt32FromReservedSlot:
case InlinableNative::IntrinsicUnsafeGetStringFromReservedSlot:
caseInlinableNative::java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
ructor
case InlinableNative::
return&AsyncDisposableStackObject:class_;
case InlinableNative::IntrinsicIsCrossRealmArrayConstructor:
case ::IntrinsicCanOptimizeArraySpecies:
return &::class_;
#endif
case InlinableNative:IntrinsicGuardToMapObject:
case InlinableNative::IntrinsicIsSuspendedGenerator:
casereturn &:java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
InlinableNativeIjava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 60
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
caseIterator:
case InlinableNative::IntrinsicGuardToStringIterator:
case java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3
case InlinableNative:// natives that can // cross-realm without a careful java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 2
caseInlinableNative:java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
case::
#NIGHTLY_BUILD
caseInlinableNative:java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
#endif
case InlinableNative:java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Range [24, 8) out of bounds for length 52
::IntrinsicGetNextMapEntryForIterator
caseInlinableNative::java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
:java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
case InlinableNative:MathSign:
case InlinableNative::IntrinsicGuardToSharedArrayBuffer:
case c InlinableNative::MathSin:
case InlinableNative::IntrinsicIsTypedArray case InlinableNative::MathTan:
case InlinableNative::java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 34
case ::IntrinsicPossiblyWrappedTypedArrayLength:
case :IntrinsicRegExpBuiltinExec:
case InlinableNative::IntrinsicRegExpBuiltinExecForTest:
case InlinableNative::IntrinsicRegExpExec:
case InlinableNative::IntrinsicRegExpExecForTest:
caseInlinableNative:Mjava.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35
caseInlinableNative::IntrinsicArrayIteratorPrototypeOptimizable:
#ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENTcase ::MathACosH:
case InlinableNative::java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 36
InlinableNative:java.lang.StringIndexOutOfBoundsException: Range [58, 59) out of bounds for length 58
#endif
MOZ_CRASH"cross-realm ";
case:Array:
case// Cross-realm case handled by inlineArray.
// Testing functions, not worth inlining cross-realm.
returnfalse
case InlinableNative:ArrayIsArray:
case InlinableNative: return false;
casejava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 35
c :java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
case InlinableNative::ArrayPush:
case InlinableNative InlinableNative::IsRegExpPrototypeOptimizable:
InlinableNative:RegExpMatcher:
case InlinableNative:AtomicsCompareExchange:
case InlinableNative::AtomicsExchange:
case InlinableNative::AtomicsLoadcase InlinableNative::RegExpSearcherLastLimit:
case InlinableNative::AtomicsStore case InlinableNative::RegExpHasCaptureGroups:
case InlinableNative::case InlinableNative::GetFirstDol:
caseInlinableNative::AtomicsSub:
case InlinableNative::AtomicsAnd:
case InlinableNative::case InlinableNative::IntrinsicN:
case InlinableNative::AtomicsXor:
case InlinableNativecase InlinableNative:IntrinsicStringReplaceString:
case InlinableNative::AtomicsPause:
case case InlinableNative:IntrinsicStringSplitString:
ase InlinableNative:BigIntAsIntN:
case InlinableNative::BigIntAsUintN:
case InlinableNative::case InlinableNative::IntrinsicUnsafeGetReservedSlot:
case InlinableNative:: case InlinableNative::IntrinsicUnsafeG:
aseInlinableNative::DataViewGetInt16:
case InlinableNative::DataViewGetUint16:
aseInlinableNative::DataViewGetInt32:
case InlinableNative::DataViewGetUint32:
case InlinableNative:IntrinsicIsCallable
InlinableNative:DataViewGetFloat32:
case InlinableNative :java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
:
case :IntrinsicToInteger
case InlinableNative InlinableNative:IntrinsicToLength:
case InlinableNative::DataViewSetUint8:
case InlinableNative::DataViewSetInt16case :IntrinsicIsConstructing:
case InlinableNative::DataViewSetUint16:
case InlinableNative::DataViewSetInt32case :IntrinsicIsSuspendedGenerator:
case InlinableNative::DataViewSetUint32:
case ::DataViewSetFloat16:
case InlinableNative::DataViewSetFloat32:
case InlinableNativecaseInlinableNative:java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
casejava.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 46
case case InlinableNativeIntrinsicGuardToWrapForValidIterator:
case:DataViewByteLength:
case InlinableNative::DataViewByteOffset:
case InlinableNative::Date:
case InlinableNative::DateGetTime:
case InlinableNative::DateGetFullYear:
case ::ateGetMonth:
case InlinableNative::DateGetDate:
case case InlinableNative::IntrinsicIsPackedArray:
case InlinableNative::DateGetHours:
InlinableNative:java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
:Djava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 41
caseInlinableNativejava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 54
:
case caseInlinableNative:IntrinsicIsTypedArray:
case InlinableNative::MapConstructor:
case caseInlinableNative::IntrinsicIsPossiblyWrappedTypedArray:
case InlinableNative::MapHas:
::MapDelete:
case InlinableNative::MapSet:
case InlinableNative::MapSize:
case InlinableNative::Number:
case InlinableNative::NumberParseInt:
case InlinableNative::NumberToString:
case InlinableNative::ReflectGetPrototypeOf:
case InlinableNative::RegExpDotAll:
case InlinableNative::RegExpGlobal:
case InlinableNative::RegExpHasIndices:
case InlinableNative::RegExpIgnoreCase:
case InlinableNative::RegExpMultiline:
case InlinableNative::RegExpSticky:
case InlinableNative::RegExpUnicode:
case::RegExpUnicodeSets:
case InlinableNative::SetConstructor:
case InlinableNative::SetHas:
case InlinableNative::SetDelete:
case InlinableNative:case InlinableNative::IntrinsicRegExpExec:
case::SetSize:
case InlinableNative::case :IntrinsicTypedArrayLength:
case InlinableNative::String:
ase ::StringToString:
case InlinableNative::StringValueOf:
case # ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
InlinableNative:StringCodePointAt:
case InlinableNative::case InlinableNative::IntrinsicGuardToDis:
case(" cross-realm intrinsic call");
case InlinableNative::StringCharAt:
case InlinableNative::StringAt:
case case InlinableNative:TestAssertFloat32:
case InlinableNative::StringIndexOf:
case:::
case InlinableNative::StringStartsWith:
case InlinableNative::StringEndsWith:
ase :java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
case::
case caseInlinableNative:ArrayPop:
case InlinableNative::StringToLocaleUpperCase:
::StringTrim:
case case InlinableNativeArrayPush:
ase ::StringTrimEnd:
case InlinableNative::Object:
InlinableNative::ObjectCreate:
case case InlinableNative:java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 49
InlinableNative:ObjectIsPrototypeOf:
case InlinableNative::case InlinableNative::AtomicsAdd:
case InlinableNative::ObjectToString case InlinableNative::AtomicsSub:
case InlinableNativecase InlinableNative::AtomicsAnd:
ase InlinableNative:TypedArrayFill:
case InlinableNative::TypedArraySet:
case InlinableNativecase InlinableNative::AtomicsIsLockFree:
case case InlinableNative:AtomicsPause:
InlinableNative:TypedArrayByteLength:
case InlinableNative::TypedArrayByteOffset:
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 37
InlinableNative:java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
case InlinableNative::WeakSetHas:
#ifdef FUZZING_JS_FUZZILLI
caseInlinableNative::FuzzilliHash:
#endif
// Default to false for most natives.
return false;
case InlinableNative::Limit:
break;
}
MOZ_CRASH("Unknown native");
c InlinableNative::DataViewGetUint32: