diff options
Diffstat (limited to 'deps/v8/src/builtins/base.tq')
-rw-r--r-- | deps/v8/src/builtins/base.tq | 158 |
1 files changed, 94 insertions, 64 deletions
diff --git a/deps/v8/src/builtins/base.tq b/deps/v8/src/builtins/base.tq index 1c9acdd5c61..1b9d577f101 100644 --- a/deps/v8/src/builtins/base.tq +++ b/deps/v8/src/builtins/base.tq @@ -62,25 +62,25 @@ type ExtractFixedArrayFlags generates 'TNode<Smi>' constexpr 'ExtractFixedArrayFlags'; type ParameterMode generates 'TNode<Int32T>' constexpr 'ParameterMode'; type RootListIndex generates 'TNode<Int32T>' constexpr 'Heap::RootListIndex'; +type WriteBarrierMode generates 'TNode<Int32T>' constexpr 'WriteBarrierMode'; -type MessageTemplate constexpr 'MessageTemplate'; -type HasPropertyLookupMode constexpr 'HasPropertyLookupMode'; +type MessageTemplate constexpr 'MessageTemplate::Template'; type ToIntegerTruncationMode constexpr 'ToIntegerTruncationMode'; const NO_ELEMENTS: constexpr ElementsKind generates 'NO_ELEMENTS'; const PACKED_SMI_ELEMENTS: constexpr ElementsKind generates - 'PACKED_SMI_ELEMENTS'; +'PACKED_SMI_ELEMENTS'; const HOLEY_SMI_ELEMENTS: constexpr ElementsKind generates 'HOLEY_SMI_ELEMENTS'; const PACKED_ELEMENTS: constexpr ElementsKind generates 'PACKED_ELEMENTS'; const HOLEY_ELEMENTS: constexpr ElementsKind generates 'HOLEY_ELEMENTS'; const PACKED_DOUBLE_ELEMENTS: constexpr ElementsKind generates - 'PACKED_DOUBLE_ELEMENTS'; +'PACKED_DOUBLE_ELEMENTS'; const HOLEY_DOUBLE_ELEMENTS: constexpr ElementsKind generates - 'HOLEY_DOUBLE_ELEMENTS'; +'HOLEY_DOUBLE_ELEMENTS'; const DICTIONARY_ELEMENTS: constexpr ElementsKind generates - 'DICTIONARY_ELEMENTS'; +'DICTIONARY_ELEMENTS'; const UINT8_ELEMENTS: constexpr ElementsKind generates 'UINT8_ELEMENTS'; const INT8_ELEMENTS: constexpr ElementsKind generates 'INT8_ELEMENTS'; @@ -91,7 +91,7 @@ const INT32_ELEMENTS: constexpr ElementsKind generates 'INT32_ELEMENTS'; const FLOAT32_ELEMENTS: constexpr ElementsKind generates 'FLOAT32_ELEMENTS'; const FLOAT64_ELEMENTS: constexpr ElementsKind generates 'FLOAT64_ELEMENTS'; const UINT8_CLAMPED_ELEMENTS: constexpr ElementsKind generates - 'UINT8_CLAMPED_ELEMENTS'; +'UINT8_CLAMPED_ELEMENTS'; const BIGUINT64_ELEMENTS: constexpr ElementsKind generates 'BIGUINT64_ELEMENTS'; const BIGINT64_ELEMENTS: constexpr ElementsKind generates 'BIGINT64_ELEMENTS'; @@ -109,6 +109,8 @@ type FixedBigInt64Array extends FixedTypedArray; const kAllFixedArrays: constexpr ExtractFixedArrayFlags generates 'ExtractFixedArrayFlag::kAllFixedArrays'; +const kFixedArrays: constexpr ExtractFixedArrayFlags generates +'ExtractFixedArrayFlag::kFixedArrays'; const kFixedCOWArrayMapRootIndex: constexpr RootListIndex generates 'Heap::kFixedCOWArrayMapRootIndex'; @@ -122,8 +124,6 @@ const kCalledNonCallable: constexpr MessageTemplate generates const kCalledOnNullOrUndefined: constexpr MessageTemplate generates 'MessageTemplate::kCalledOnNullOrUndefined'; -const kHasProperty: constexpr HasPropertyLookupMode generates 'kHasProperty'; - const kMaxSafeInteger: constexpr float64 generates 'kMaxSafeInteger'; const kTruncateMinusZero: constexpr ToIntegerTruncationMode generates @@ -147,6 +147,8 @@ extern macro NullConstant(): Oddball; extern macro UndefinedConstant(): Oddball; extern macro TrueConstant(): Boolean; extern macro FalseConstant(): Boolean; +extern macro Int32TrueConstant(): bool; +extern macro Int32FalseConstant(): bool; const Hole: Oddball = TheHoleConstant(); const Null: Oddball = NullConstant(); @@ -163,8 +165,14 @@ const kSloppy: constexpr LanguageMode generates 'LanguageMode::kSloppy'; const SMI_PARAMETERS: constexpr ParameterMode generates 'SMI_PARAMETERS'; const INTPTR_PARAMETERS: constexpr ParameterMode generates 'INTPTR_PARAMETERS'; + +const SKIP_WRITE_BARRIER: constexpr WriteBarrierMode + generates 'SKIP_WRITE_BARRIER'; + extern macro Is64(): constexpr bool; +extern macro SelectBooleanConstant(bool): Boolean; + extern macro Print(constexpr string); extern macro Print(constexpr string, Object); extern macro Print(Object); @@ -176,25 +184,26 @@ extern macro ToLength_Inline(Context, Object): Number; extern macro ToNumber_Inline(Context, Object): Number; extern macro ToString_Inline(Context, Object): String; extern macro GetProperty(Context, Object, Object): Object; -extern macro HasProperty( - HeapObject, Object, Context, constexpr HasPropertyLookupMode): Oddball; +extern builtin SetProperty(Context, Object, Object, Object); +extern builtin DeleteProperty(Context, Object, Object, LanguageMode); +extern builtin HasProperty(Context, JSReceiver, Object): Boolean; + extern macro ThrowRangeError(Context, constexpr MessageTemplate): never; extern macro ThrowTypeError(Context, constexpr MessageTemplate): never; extern macro ThrowTypeError(Context, constexpr MessageTemplate, Object): never; -extern macro ThrowTypeError(Context, constexpr MessageTemplate, Object, Object, - Object): never; +extern macro ThrowTypeError( + Context, constexpr MessageTemplate, Object, Object, Object): never; extern macro ArraySpeciesCreate(Context, Object, Number): Object; extern macro EnsureArrayPushable(Map): ElementsKind labels Bailout; extern builtin ToObject(Context, Object): JSReceiver; +extern macro ToObject_Inline(Context, Object): JSReceiver; extern macro IsNullOrUndefined(Object): bool; extern macro IsTheHole(Object): bool; extern macro IsString(HeapObject): bool; extern builtin ToString(Context, Object): String; extern runtime CreateDataProperty(Context, Object, Object, Object); -extern runtime SetProperty(Context, Object, Object, Object, LanguageMode); -extern runtime DeleteProperty(Context, Object, Object, LanguageMode); extern macro LoadRoot(constexpr RootListIndex): Object; extern macro StoreRoot(constexpr RootListIndex, Object): Object; @@ -257,7 +266,9 @@ extern operator '!=' macro WordNotEqual(Object, Object): bool; extern operator '+' macro SmiAdd(Smi, Smi): Smi; extern operator '-' macro SmiSub(Smi, Smi): Smi; extern operator '&' macro SmiAnd(Smi, Smi): Smi; +extern operator '|' macro SmiOr(Smi, Smi): Smi; extern operator '>>>' macro SmiShr(Smi, constexpr int31): Smi; +extern operator '<<' macro SmiShl(Smi, constexpr int31): Smi; extern operator '+' macro IntPtrAdd(intptr, intptr): intptr; extern operator '-' macro IntPtrSub(intptr, intptr): intptr; @@ -287,11 +298,21 @@ extern operator '|' macro Word32Or(uint32, uint32): uint32; extern operator '+' macro NumberAdd(Number, Number): Number; extern operator '-' macro NumberSub(Number, Number): Number; -extern operator 'min' macro NumberMin(Number, Number): Number; -extern operator 'max' macro NumberMax(Number, Number): Number; +extern macro NumberMin(Number, Number): Number; +extern macro NumberMax(Number, Number): Number; +macro min(x: Number, y: Number): Number { + return NumberMin(x, y); +} +macro max(x: Number, y: Number): Number { + return NumberMax(x, y); +} + +extern macro SmiMax(Smi, Smi): Smi; +extern macro SmiMin(Smi, Smi): Smi; extern operator '!' macro ConstexprBoolNot(constexpr bool): constexpr bool; extern operator '!' macro Word32BinaryNot(bool): bool; +extern operator '!' macro IsFalse(Boolean): bool; extern operator '.map' macro LoadMap(HeapObject): Map; extern operator '.map=' macro StoreMap(HeapObject, Map); @@ -308,42 +329,50 @@ extern operator 'is<Smi>' macro TaggedIsSmi(Object): bool; extern operator 'isnt<Smi>' macro TaggedIsNotSmi(Object): bool; extern macro TaggedIsPositiveSmi(Object): bool; -extern macro TaggedToJSDataView(Object): JSDataView labels CastError; +extern macro HeapObjectToJSDataView(HeapObject): JSDataView labels CastError; extern macro TaggedToHeapObject(Object): HeapObject labels CastError; extern macro TaggedToSmi(Object): Smi labels CastError; -extern macro TaggedToJSArray(Object): JSArray labels CastError; -extern macro TaggedToCallable(Object): Callable labels CastError; -extern macro ConvertFixedArrayBaseToFixedArray(FixedArrayBase): +extern macro HeapObjectToJSArray(HeapObject): JSArray labels CastError; +extern macro HeapObjectToCallable(HeapObject): Callable labels CastError; +extern macro HeapObjectToFixedArray(HeapObject): FixedArray labels CastError; -extern macro ConvertFixedArrayBaseToFixedDoubleArray(FixedArrayBase): +extern macro HeapObjectToFixedDoubleArray(HeapObject): FixedDoubleArray labels CastError; extern macro TaggedToNumber(Object): Number labels CastError; -macro cast<A : type>(o: Object): A labels CastError; -cast<Number>(o: Object): Number labels CastError { - return TaggedToNumber(o) otherwise CastError; +macro cast_HeapObject<A : type>(o : HeapObject) : A labels CastError; +cast_HeapObject<HeapObject>(o : HeapObject) : HeapObject labels CastError { return o; } +cast_HeapObject<FixedArray>(o: HeapObject): FixedArray labels CastError { + return HeapObjectToFixedArray(o) otherwise CastError; } -cast<HeapObject>(o: Object): HeapObject labels CastError { - return TaggedToHeapObject(o) otherwise CastError; +cast_HeapObject<FixedDoubleArray>(o: HeapObject): FixedDoubleArray labels CastError { + return HeapObjectToFixedDoubleArray(o) otherwise CastError; } -cast<Smi>(o: Object): Smi labels CastError { - return TaggedToSmi(o) otherwise CastError; +cast_HeapObject<JSDataView>(o: HeapObject): JSDataView labels CastError { + return HeapObjectToJSDataView(o) otherwise CastError; +} +cast_HeapObject<Callable>(o: HeapObject): Callable labels CastError { + return HeapObjectToCallable(o) otherwise CastError; } -cast<JSDataView>(o: Object): JSDataView labels CastError { - return TaggedToJSDataView(o) otherwise CastError; +cast_HeapObject<JSArray>(o: HeapObject): JSArray labels CastError { + return HeapObjectToJSArray(o) otherwise CastError; } -cast<Callable>(o: Object): Callable labels CastError { - return TaggedToCallable(o) otherwise CastError; + +macro cast<A : type>(o: HeapObject): A labels CastError { + return cast_HeapObject<A>(o) otherwise CastError; } -cast<JSArray>(o: Object): JSArray labels CastError { - return TaggedToJSArray(o) otherwise CastError; + +// cast_HeapObject allows this default-implementation to be non-recursive. +// Otherwise the generated CSA code might run into infinite recursion. +macro cast<A : type>(o: Object): A labels CastError { + return cast_HeapObject<A>( + TaggedToHeapObject(o) otherwise CastError) otherwise CastError; } -macro cast<A : type>(o: FixedArrayBase): A labels CastError; -cast<FixedArray>(o: FixedArrayBase): FixedArray labels CastError { - return ConvertFixedArrayBaseToFixedArray(o) otherwise CastError; +cast<Smi>(o: Object): Smi labels CastError { + return TaggedToSmi(o) otherwise CastError; } -cast<FixedDoubleArray>(o: FixedArrayBase): FixedDoubleArray labels CastError { - return ConvertFixedArrayBaseToFixedDoubleArray(o) otherwise CastError; +cast<Number>(o: Object): Number labels CastError { + return TaggedToNumber(o) otherwise CastError; } extern macro AllocateHeapNumberWithValue(float64): HeapNumber; @@ -365,7 +394,7 @@ extern macro LoadHeapNumberValue(HeapNumber): float64; extern macro ChangeFloat32ToFloat64(float32): float64; extern macro ChangeNumberToFloat64(Number): float64; extern macro ChangeFloat64ToUintPtr(float64): uintptr; -extern macro ChangeInt32ToIntPtr(int32): intptr; // Sign-extends. +extern macro ChangeInt32ToIntPtr(int32): intptr; // Sign-extends. extern macro ChangeUint32ToWord(uint32): uintptr; // Doesn't sign-extend. extern macro NumberConstant(constexpr float64): Number; @@ -573,8 +602,8 @@ unsafe_cast<FixedArrayBase>(o: Object): FixedArrayBase { } const kCOWMap: Map = unsafe_cast<Map>(LoadRoot(kFixedCOWArrayMapRootIndex)); -const kEmptyFixedArray: FixedArrayBase = unsafe_cast<FixedArrayBase>( - LoadRoot(kEmptyFixedArrayRootIndex)); +const kEmptyFixedArray: FixedArrayBase = + unsafe_cast<FixedArrayBase>(LoadRoot(kEmptyFixedArrayRootIndex)); extern macro BranchIfFastJSArray(Object, Context): never labels Taken, NotTaken; extern macro BranchIfNotFastJSArray(Object, Context): never labels Taken, @@ -607,15 +636,18 @@ extern operator '.length' macro LoadFixedArrayBaseLength(FixedArrayBase): Smi; extern operator '[]' macro LoadFixedArrayElement(FixedArray, intptr): Object; extern operator '[]' macro LoadFixedArrayElement(FixedArray, Smi): Object; extern operator -'[]' macro LoadFixedArrayElementInt(FixedArray, constexpr int31): Object; +'[]' macro LoadFixedArrayElement(FixedArray, constexpr int31): Object; extern operator '[]=' macro StoreFixedArrayElement(FixedArray, intptr, Object): void; extern operator -'[]=' macro StoreFixedArrayElementInt( +'[]=' macro StoreFixedArrayElement( FixedArray, constexpr int31, Object): void; extern operator '[]=' macro StoreFixedArrayElementSmi(FixedArray, Smi, Object): void; +extern macro StoreFixedArrayElementSmi(FixedArray, Smi, Object, + constexpr WriteBarrierMode): void; + extern operator '.instance_type' macro LoadMapInstanceType(Map): int32; extern macro LoadFixedDoubleArrayElement(FixedDoubleArray, Smi): float64; @@ -629,7 +661,8 @@ macro StoreFixedDoubleArrayElementWithSmiIndex( } extern macro BasicLoadNumberDictionaryElement(NumberDictionary, intptr): - Object labels NotData, IfHole; + Object labels NotData, + IfHole; extern macro BasicStoreNumberDictionaryElement(NumberDictionary, intptr, Object) labels NotData, IfHole, ReadOnly; @@ -639,7 +672,8 @@ extern macro IsFastSmiOrTaggedElementsKind(ElementsKind): bool; extern macro IsFastSmiElementsKind(ElementsKind): bool; extern macro IsHoleyFastElementsKind(ElementsKind): bool; -extern macro AllocateFixedArray(constexpr ElementsKind, intptr): FixedArray; +extern macro AllocateZeroedFixedArray(intptr): FixedArray; +extern macro AllocateZeroedFixedDoubleArray(intptr): FixedDoubleArray; extern macro CopyFixedArrayElements( constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray, @@ -660,8 +694,10 @@ extern macro Call(Context, Callable, Object): Object; extern macro Call(Context, Callable, Object, Object): Object; extern macro Call(Context, Callable, Object, Object, Object): Object; extern macro Call(Context, Callable, Object, Object, Object, Object): Object; -extern macro Call(Context, Callable, Object, Object, Object, Object, Object): Object; -extern macro Call(Context, Callable, Object, Object, Object, Object, Object, Object): Object; +extern macro Call( + Context, Callable, Object, Object, Object, Object, Object): Object; +extern macro Call( + Context, Callable, Object, Object, Object, Object, Object, Object): Object; extern macro ExtractFixedArray( FixedArray, Smi, Smi, Smi, constexpr ExtractFixedArrayFlags): FixedArray; @@ -699,32 +735,26 @@ labels IfHole { } } -macro HasPropertyObject( - o: Object, p: Object, c: Context, - f: constexpr HasPropertyLookupMode): Oddball { - try { - return HasProperty((cast<HeapObject>(o) otherwise CastError), p, c, f); - } - label CastError { - return False; - } -} - extern macro IsCallable(HeapObject): bool; extern macro IsJSArray(HeapObject): bool; extern macro TaggedIsCallable(Object): bool; extern macro IsDetachedBuffer(JSArrayBuffer): bool; extern macro IsHeapNumber(HeapObject): bool; +extern macro IsFixedArray(HeapObject): bool; extern macro IsExtensibleMap(Map): bool; extern macro IsCustomElementsReceiverInstanceType(int32): bool; extern macro Typeof(Object): Object; // Return true iff number is NaN. macro NumberIsNaN(number: Number): bool { - if (TaggedIsSmi(number)) return false; - - let value: float64 = convert<float64>(unsafe_cast<HeapNumber>(number)); - return value != value; + typeswitch(number) { + case (Smi) { + return false; + } case (hn : HeapNumber) { + let value: float64 = convert<float64>(hn); + return value != value; + } + } } extern macro BranchIfToBooleanIsTrue(Object): never labels Taken, NotTaken; |