2018-04-16 09:24:22 +00:00
|
|
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2018-05-29 08:34:01 +00:00
|
|
|
type Arguments constexpr 'CodeStubArguments*';
|
2018-04-16 09:24:22 +00:00
|
|
|
type void generates 'void';
|
|
|
|
type never generates 'void';
|
|
|
|
|
2018-05-29 13:31:56 +00:00
|
|
|
type Tagged generates 'TNode<Object>';
|
|
|
|
type Smi extends Tagged generates 'TNode<Smi>';
|
|
|
|
type HeapObject extends Tagged generates 'TNode<HeapObject>';
|
2018-06-07 11:48:26 +00:00
|
|
|
type Object = Smi|HeapObject;
|
2018-06-25 13:28:25 +00:00
|
|
|
type int32 generates 'TNode<Int32T>' constexpr 'int32_t';
|
|
|
|
type uint32 generates 'TNode<Uint32T>' constexpr 'uint32_t';
|
2018-06-07 08:02:33 +00:00
|
|
|
type int64 generates 'TNode<Int64T>' constexpr 'int64_t';
|
2018-05-04 15:04:42 +00:00
|
|
|
type intptr generates 'TNode<IntPtrT>' constexpr 'intptr_t';
|
2018-06-15 12:23:58 +00:00
|
|
|
type uintptr generates 'TNode<UintPtrT>' constexpr 'uintptr_t';
|
2018-06-07 08:02:33 +00:00
|
|
|
type float32 generates 'TNode<Float32T>' constexpr 'float';
|
2018-05-04 15:04:42 +00:00
|
|
|
type float64 generates 'TNode<Float64T>' constexpr 'double';
|
|
|
|
type bool generates 'TNode<BoolT>' constexpr 'bool';
|
2018-07-03 12:02:05 +00:00
|
|
|
type string constexpr 'const char*';
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-06-12 11:11:44 +00:00
|
|
|
type int31 extends int32 generates 'TNode<Int32T>' constexpr 'int31_t';
|
2018-05-04 15:04:42 +00:00
|
|
|
type RawPtr generates 'TNode<RawPtrT>' constexpr 'void*';
|
2018-05-16 14:00:35 +00:00
|
|
|
type AbstractCode extends HeapObject generates 'TNode<AbstractCode>';
|
|
|
|
type Code extends AbstractCode generates 'TNode<Code>';
|
2018-05-09 08:16:07 +00:00
|
|
|
type JSReceiver extends HeapObject generates 'TNode<JSReceiver>';
|
2018-04-16 09:24:22 +00:00
|
|
|
type Context extends HeapObject generates 'TNode<Context>';
|
2018-07-03 12:02:05 +00:00
|
|
|
type String extends HeapObject generates 'TNode<String>';
|
2018-04-16 09:24:22 +00:00
|
|
|
type Oddball extends HeapObject generates 'TNode<Oddball>';
|
2018-05-09 08:16:07 +00:00
|
|
|
type HeapNumber extends HeapObject generates 'TNode<HeapNumber>';
|
2018-06-22 08:26:19 +00:00
|
|
|
type Number = Smi|HeapNumber;
|
2018-06-15 12:23:58 +00:00
|
|
|
type BigInt extends HeapObject generates 'TNode<BigInt>';
|
2018-06-22 08:26:19 +00:00
|
|
|
type Numeric = Number|BigInt;
|
2018-04-16 09:24:22 +00:00
|
|
|
type Boolean extends Oddball generates 'TNode<Oddball>';
|
2018-05-29 13:31:56 +00:00
|
|
|
type JSProxy extends JSReceiver generates 'TNode<JSProxy>';
|
2018-05-29 08:34:01 +00:00
|
|
|
type JSObject extends JSReceiver generates 'TNode<JSObject>';
|
|
|
|
type JSArray extends JSObject generates 'TNode<JSArray>';
|
2018-05-29 13:31:56 +00:00
|
|
|
type JSFunction extends JSObject generates 'TNode<JSFunction>';
|
|
|
|
type JSBoundFunction extends JSObject generates 'TNode<JSBoundFunction>';
|
2018-06-07 11:48:26 +00:00
|
|
|
type Callable = JSFunction|JSBoundFunction|JSProxy;
|
2018-05-09 08:16:07 +00:00
|
|
|
type Map extends HeapObject generates 'TNode<Map>';
|
|
|
|
type FixedArrayBase extends HeapObject generates 'TNode<FixedArrayBase>';
|
2018-04-16 09:24:22 +00:00
|
|
|
type FixedArray extends FixedArrayBase generates 'TNode<FixedArray>';
|
|
|
|
type FixedDoubleArray extends FixedArrayBase generates
|
|
|
|
'TNode<FixedDoubleArray>';
|
2018-05-24 09:25:58 +00:00
|
|
|
type FixedTypedArrayBase extends FixedArrayBase generates
|
|
|
|
'TNode<FixedTypedArrayBase>';
|
|
|
|
type FixedTypedArray extends FixedTypedArrayBase generates
|
|
|
|
'TNode<FixedTypedArray>';
|
2018-06-18 09:33:18 +00:00
|
|
|
type NumberDictionary extends HeapObject generates 'TNode<NumberDictionary>';
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-29 08:34:01 +00:00
|
|
|
type JSArrayBuffer extends JSObject generates 'TNode<JSArrayBuffer>';
|
|
|
|
type JSArrayBufferView extends JSObject generates 'TNode<JSArrayBufferView>';
|
2018-04-25 08:14:09 +00:00
|
|
|
type JSTypedArray extends JSArrayBufferView generates 'TNode<JSTypedArray>';
|
2018-05-24 13:43:57 +00:00
|
|
|
type JSDataView extends JSArrayBufferView generates 'TNode<JSDataView>';
|
2018-04-25 08:14:09 +00:00
|
|
|
|
2018-05-29 08:34:01 +00:00
|
|
|
type InstanceType generates 'TNode<Int32T>' constexpr 'InstanceType';
|
2018-05-04 15:04:42 +00:00
|
|
|
type ElementsKind generates 'TNode<Int32T>' constexpr 'ElementsKind';
|
|
|
|
type LanguageMode generates 'TNode<Smi>' constexpr 'LanguageMode';
|
|
|
|
type ExtractFixedArrayFlags generates
|
2018-05-04 15:55:55 +00:00
|
|
|
'TNode<Smi>' constexpr 'ExtractFixedArrayFlags';
|
2018-06-05 07:54:49 +00:00
|
|
|
type ParameterMode generates 'TNode<Int32T>' constexpr 'ParameterMode';
|
2018-06-07 11:48:26 +00:00
|
|
|
type RootListIndex generates 'TNode<Int32T>' constexpr 'Heap::RootListIndex';
|
2018-08-13 08:43:56 +00:00
|
|
|
type WriteBarrierMode generates 'TNode<Int32T>' constexpr 'WriteBarrierMode';
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-08-07 13:41:32 +00:00
|
|
|
type MessageTemplate constexpr 'MessageTemplate::Template';
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-08-02 14:41:58 +00:00
|
|
|
type ToIntegerTruncationMode constexpr 'ToIntegerTruncationMode';
|
|
|
|
|
2018-06-22 08:26:19 +00:00
|
|
|
const NO_ELEMENTS: constexpr ElementsKind generates 'NO_ELEMENTS';
|
|
|
|
|
|
|
|
const PACKED_SMI_ELEMENTS: constexpr ElementsKind generates
|
2018-08-07 15:49:03 +00:00
|
|
|
'PACKED_SMI_ELEMENTS';
|
2018-06-22 08:26:19 +00:00
|
|
|
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
|
2018-08-07 15:49:03 +00:00
|
|
|
'PACKED_DOUBLE_ELEMENTS';
|
2018-06-22 08:26:19 +00:00
|
|
|
const HOLEY_DOUBLE_ELEMENTS: constexpr ElementsKind generates
|
2018-08-07 15:49:03 +00:00
|
|
|
'HOLEY_DOUBLE_ELEMENTS';
|
2018-06-22 08:26:19 +00:00
|
|
|
const DICTIONARY_ELEMENTS: constexpr ElementsKind generates
|
2018-08-07 15:49:03 +00:00
|
|
|
'DICTIONARY_ELEMENTS';
|
2018-06-22 08:26:19 +00:00
|
|
|
|
|
|
|
const UINT8_ELEMENTS: constexpr ElementsKind generates 'UINT8_ELEMENTS';
|
|
|
|
const INT8_ELEMENTS: constexpr ElementsKind generates 'INT8_ELEMENTS';
|
|
|
|
const UINT16_ELEMENTS: constexpr ElementsKind generates 'UINT16_ELEMENTS';
|
|
|
|
const INT16_ELEMENTS: constexpr ElementsKind generates 'INT16_ELEMENTS';
|
|
|
|
const UINT32_ELEMENTS: constexpr ElementsKind generates 'UINT32_ELEMENTS';
|
|
|
|
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
|
2018-08-07 15:49:03 +00:00
|
|
|
'UINT8_CLAMPED_ELEMENTS';
|
2018-06-22 08:26:19 +00:00
|
|
|
const BIGUINT64_ELEMENTS: constexpr ElementsKind generates 'BIGUINT64_ELEMENTS';
|
|
|
|
const BIGINT64_ELEMENTS: constexpr ElementsKind generates 'BIGINT64_ELEMENTS';
|
2018-05-04 15:04:42 +00:00
|
|
|
|
2018-05-24 09:25:58 +00:00
|
|
|
type FixedUint8Array extends FixedTypedArray;
|
|
|
|
type FixedInt8Array extends FixedTypedArray;
|
|
|
|
type FixedUint16Array extends FixedTypedArray;
|
|
|
|
type FixedInt16Array extends FixedTypedArray;
|
|
|
|
type FixedUint32Array extends FixedTypedArray;
|
|
|
|
type FixedInt32Array extends FixedTypedArray;
|
|
|
|
type FixedFloat32Array extends FixedTypedArray;
|
|
|
|
type FixedFloat64Array extends FixedTypedArray;
|
|
|
|
type FixedUint8ClampedArray extends FixedTypedArray;
|
|
|
|
type FixedBigUint64Array extends FixedTypedArray;
|
|
|
|
type FixedBigInt64Array extends FixedTypedArray;
|
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
const kFixedDoubleArrays: constexpr ExtractFixedArrayFlags generates
|
|
|
|
'ExtractFixedArrayFlag::kFixedDoubleArrays';
|
2018-06-22 08:26:19 +00:00
|
|
|
const kAllFixedArrays: constexpr ExtractFixedArrayFlags generates
|
|
|
|
'ExtractFixedArrayFlag::kAllFixedArrays';
|
2018-08-24 08:38:46 +00:00
|
|
|
const kFixedArrays: constexpr ExtractFixedArrayFlags generates
|
|
|
|
'ExtractFixedArrayFlag::kFixedArrays';
|
2018-06-22 08:26:19 +00:00
|
|
|
|
2018-07-13 11:09:17 +00:00
|
|
|
const kFixedCOWArrayMapRootIndex: constexpr RootListIndex generates
|
|
|
|
'Heap::kFixedCOWArrayMapRootIndex';
|
|
|
|
const kEmptyFixedArrayRootIndex: constexpr RootListIndex generates
|
|
|
|
'Heap::kEmptyFixedArrayRootIndex';
|
2018-06-22 08:26:19 +00:00
|
|
|
|
|
|
|
const kInvalidArrayLength: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kInvalidArrayLength';
|
|
|
|
const kCalledNonCallable: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kCalledNonCallable';
|
|
|
|
const kCalledOnNullOrUndefined: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kCalledOnNullOrUndefined';
|
|
|
|
|
|
|
|
const kMaxSafeInteger: constexpr float64 generates 'kMaxSafeInteger';
|
|
|
|
|
2018-08-02 14:41:58 +00:00
|
|
|
const kTruncateMinusZero: constexpr ToIntegerTruncationMode generates
|
|
|
|
'ToIntegerTruncationMode::kTruncateMinusZero';
|
|
|
|
|
2018-06-22 08:26:19 +00:00
|
|
|
const kNotTypedArray: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kNotTypedArray';
|
|
|
|
const kDetachedOperation: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kDetachedOperation';
|
|
|
|
const kBadSortComparisonFunction: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kBadSortComparisonFunction';
|
|
|
|
const kIncompatibleMethodReceiver: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kIncompatibleMethodReceiver';
|
|
|
|
const kInvalidDataViewAccessorOffset: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kInvalidDataViewAccessorOffset';
|
[array] Throw TypeError for read-only properties on fast-path
This CL changes the NumberDictionary fast-path for Array.p.sort to
throw a TypeError when trying to write to a read-only property.
Previously, the fast-path simply bailed to the slow-path which could
swallow the TypeError by accident. I.e. because the fast-path could
leave the array in an inconsistent state that is already sorted.
Example:
let arr = new Array(10);
Object.defineProperty(arr, 0, {value: 2, writable: false});
Object.defineProperty(arr, 2, {value: 1, writable: false});
arr.sort();
The pre-processing step will move the value 1 to index 1: {0: 2, 1: 1}
When trying to swap those 2 values, the fast-path will write the 2 at
index 1, then try to write the 1 at index 0 and fail, bailing to the
slow-path. As the array looks like {0: 2, 1: 2} its already sorted
and the TypeError will not be thrown.
R=jgruber@chromium.org
Bug: v8:7382, v8:7907
Change-Id: I5d2f2d73478fdca066ce1048dcb2b8301751cb1f
Reviewed-on: https://chromium-review.googlesource.com/1122120
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54150}
2018-07-02 14:56:52 +00:00
|
|
|
const kStrictReadOnlyProperty: constexpr MessageTemplate generates
|
|
|
|
'MessageTemplate::kStrictReadOnlyProperty';
|
2018-06-22 08:26:19 +00:00
|
|
|
|
2018-07-13 11:09:17 +00:00
|
|
|
extern macro TheHoleConstant(): Oddball;
|
|
|
|
extern macro NullConstant(): Oddball;
|
|
|
|
extern macro UndefinedConstant(): Oddball;
|
|
|
|
extern macro TrueConstant(): Boolean;
|
|
|
|
extern macro FalseConstant(): Boolean;
|
2018-08-22 13:17:38 +00:00
|
|
|
extern macro Int32TrueConstant(): bool;
|
|
|
|
extern macro Int32FalseConstant(): bool;
|
2018-09-03 05:40:21 +00:00
|
|
|
extern macro LengthStringConstant(): String;
|
2018-07-13 11:09:17 +00:00
|
|
|
|
|
|
|
const Hole: Oddball = TheHoleConstant();
|
|
|
|
const Null: Oddball = NullConstant();
|
|
|
|
const Undefined: Oddball = UndefinedConstant();
|
|
|
|
const True: Boolean = TrueConstant();
|
|
|
|
const False: Boolean = FalseConstant();
|
2018-09-03 05:40:21 +00:00
|
|
|
const kLengthString: String = LengthStringConstant();
|
2018-07-13 11:09:17 +00:00
|
|
|
|
2018-06-22 08:26:19 +00:00
|
|
|
const true: constexpr bool generates 'true';
|
|
|
|
const false: constexpr bool generates 'false';
|
|
|
|
|
|
|
|
const kStrict: constexpr LanguageMode generates 'LanguageMode::kStrict';
|
|
|
|
const kSloppy: constexpr LanguageMode generates 'LanguageMode::kSloppy';
|
|
|
|
|
|
|
|
const SMI_PARAMETERS: constexpr ParameterMode generates 'SMI_PARAMETERS';
|
|
|
|
const INTPTR_PARAMETERS: constexpr ParameterMode generates 'INTPTR_PARAMETERS';
|
2018-06-05 07:54:49 +00:00
|
|
|
|
2018-08-13 08:43:56 +00:00
|
|
|
const SKIP_WRITE_BARRIER: constexpr WriteBarrierMode
|
2018-09-04 12:30:33 +00:00
|
|
|
generates 'SKIP_WRITE_BARRIER';
|
2018-08-13 08:43:56 +00:00
|
|
|
|
2018-06-15 12:23:58 +00:00
|
|
|
extern macro Is64(): constexpr bool;
|
|
|
|
|
2018-08-22 13:17:38 +00:00
|
|
|
extern macro SelectBooleanConstant(bool): Boolean;
|
|
|
|
|
2018-07-03 12:02:05 +00:00
|
|
|
extern macro Print(constexpr string);
|
|
|
|
extern macro Print(constexpr string, Object);
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro Comment(constexpr string);
|
2018-04-16 09:24:22 +00:00
|
|
|
extern macro Print(Object);
|
|
|
|
extern macro DebugBreak();
|
|
|
|
extern macro ToInteger_Inline(Context, Object): Number;
|
2018-08-02 14:41:58 +00:00
|
|
|
extern macro ToInteger_Inline(
|
|
|
|
Context, Object, constexpr ToIntegerTruncationMode): Number;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern macro ToLength_Inline(Context, Object): Number;
|
2018-04-25 08:14:09 +00:00
|
|
|
extern macro ToNumber_Inline(Context, Object): Number;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern macro ToString_Inline(Context, Object): String;
|
|
|
|
extern macro GetProperty(Context, Object, Object): Object;
|
2018-08-10 06:51:12 +00:00
|
|
|
extern builtin SetProperty(Context, Object, Object, Object);
|
|
|
|
extern builtin DeleteProperty(Context, Object, Object, LanguageMode);
|
2018-08-09 11:44:32 +00:00
|
|
|
extern builtin HasProperty(Context, JSReceiver, Object): Boolean;
|
2018-08-07 15:49:03 +00:00
|
|
|
|
2018-05-29 08:34:01 +00:00
|
|
|
extern macro ThrowRangeError(Context, constexpr MessageTemplate): never;
|
|
|
|
extern macro ThrowTypeError(Context, constexpr MessageTemplate): never;
|
|
|
|
extern macro ThrowTypeError(Context, constexpr MessageTemplate, Object): never;
|
2018-08-07 15:49:03 +00:00
|
|
|
extern macro ThrowTypeError(
|
|
|
|
Context, constexpr MessageTemplate, Object, Object, Object): never;
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro ArraySpeciesCreate(Context, Object, Number): JSReceiver;
|
|
|
|
extern macro InternalArrayCreate(Context, Number): JSArray;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro EnsureArrayPushable(Map): ElementsKind labels Bailout;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-06-07 11:48:26 +00:00
|
|
|
extern builtin ToObject(Context, Object): JSReceiver;
|
2018-08-10 08:35:23 +00:00
|
|
|
extern macro ToObject_Inline(Context, Object): JSReceiver;
|
2018-05-09 08:16:07 +00:00
|
|
|
extern macro IsNullOrUndefined(Object): bool;
|
2018-06-05 07:54:49 +00:00
|
|
|
extern macro IsTheHole(Object): bool;
|
|
|
|
extern macro IsString(HeapObject): bool;
|
|
|
|
extern builtin ToString(Context, Object): String;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern runtime NormalizeElements(Context, JSObject);
|
|
|
|
extern runtime TransitionElementsKindWithKind(Context, JSObject, Smi);
|
|
|
|
extern runtime CreateDataProperty(Context, JSReceiver, Object, Object);
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-06-07 11:48:26 +00:00
|
|
|
extern macro LoadRoot(constexpr RootListIndex): Object;
|
|
|
|
extern macro StoreRoot(constexpr RootListIndex, Object): Object;
|
|
|
|
extern macro LoadAndUntagToWord32Root(constexpr RootListIndex): int32;
|
|
|
|
|
2018-04-16 09:24:22 +00:00
|
|
|
extern runtime StringEqual(Context, String, String): Oddball;
|
2018-06-05 07:54:49 +00:00
|
|
|
extern builtin StringLessThan(Context, String, String): Boolean;
|
|
|
|
|
|
|
|
extern macro StrictEqual(Object, Object): Boolean;
|
|
|
|
extern runtime SmiLexicographicCompare(Context, Object, Object): Number;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '<' macro Int32LessThan(int32, int32): bool;
|
|
|
|
extern operator '>' macro Int32GreaterThan(int32, int32): bool;
|
|
|
|
extern operator '<=' macro Int32LessThanOrEqual(int32, int32): bool;
|
|
|
|
extern operator '>=' macro Int32GreaterThanOrEqual(int32, int32): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '==' macro SmiEqual(Smi, Smi): bool;
|
|
|
|
extern operator '!=' macro SmiNotEqual(Smi, Smi): bool;
|
|
|
|
extern operator '<' macro SmiLessThan(Smi, Smi): bool;
|
|
|
|
extern operator '<=' macro SmiLessThanOrEqual(Smi, Smi): bool;
|
|
|
|
extern operator '>' macro SmiGreaterThan(Smi, Smi): bool;
|
|
|
|
extern operator '>=' macro SmiGreaterThanOrEqual(Smi, Smi): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-13 10:10:44 +00:00
|
|
|
extern operator '==' macro ElementsKindEqual(
|
|
|
|
constexpr ElementsKind, constexpr ElementsKind): constexpr bool;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern operator '==' macro ElementsKindEqual(ElementsKind, ElementsKind): bool;
|
2018-09-04 12:30:33 +00:00
|
|
|
operator '!=' macro ElementsKindNotEqual(
|
|
|
|
k1: ElementsKind, k2: ElementsKind): bool {
|
|
|
|
return !ElementsKindEqual(k1, k2);
|
|
|
|
}
|
2018-05-13 10:10:44 +00:00
|
|
|
extern macro IsFastElementsKind(constexpr ElementsKind): constexpr bool;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro IsDoubleElementsKind(constexpr ElementsKind): constexpr bool;
|
2018-05-13 10:10:44 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro SmiAbove(Smi, Smi): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '==' macro WordEqual(intptr, intptr): bool;
|
2018-06-18 14:16:44 +00:00
|
|
|
extern operator '==' macro WordEqual(uintptr, uintptr): bool;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '!=' macro WordNotEqual(intptr, intptr): bool;
|
2018-06-18 14:16:44 +00:00
|
|
|
extern operator '!=' macro WordNotEqual(uintptr, uintptr): bool;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '<' macro IntPtrLessThan(intptr, intptr): bool;
|
|
|
|
extern operator '>' macro IntPtrGreaterThan(intptr, intptr): bool;
|
|
|
|
extern operator '<=' macro IntPtrLessThanOrEqual(intptr, intptr): bool;
|
|
|
|
extern operator '>=' macro IntPtrGreaterThanOrEqual(intptr, intptr): bool;
|
2018-06-18 14:16:44 +00:00
|
|
|
extern operator '>=' macro UintPtrGreaterThanOrEqual(uintptr, uintptr): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '==' macro Float64Equal(float64, float64): bool;
|
2018-06-08 11:12:59 +00:00
|
|
|
extern operator '!=' macro Float64NotEqual(float64, float64): bool;
|
2018-04-25 08:14:09 +00:00
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern operator
|
|
|
|
'==' macro BranchIfNumberEqual(Number, Number): never labels Taken, NotTaken;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator
|
2018-05-04 15:55:55 +00:00
|
|
|
'<' macro BranchIfNumberLessThan(Number, Number): never labels Taken, NotTaken;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator
|
2018-05-04 15:55:55 +00:00
|
|
|
'<=' macro BranchIfNumberLessThanOrEqual(Number, Number): never labels Taken,
|
|
|
|
NotTaken;
|
2018-09-04 12:30:33 +00:00
|
|
|
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator
|
2018-05-04 15:55:55 +00:00
|
|
|
'>' macro BranchIfNumberGreaterThan(Number, Number): never labels Taken,
|
|
|
|
NotTaken;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator '>=' macro BranchIfNumberGreaterThanOrEqual(Number, Number):
|
2018-05-04 15:55:55 +00:00
|
|
|
never labels Taken,
|
|
|
|
NotTaken;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '==' macro WordEqual(Object, Object): bool;
|
|
|
|
extern operator '!=' macro WordNotEqual(Object, Object): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
|
|
|
extern operator '+' macro SmiAdd(Smi, Smi): Smi;
|
|
|
|
extern operator '-' macro SmiSub(Smi, Smi): Smi;
|
2018-06-06 12:30:08 +00:00
|
|
|
extern operator '&' macro SmiAnd(Smi, Smi): Smi;
|
2018-08-22 13:17:38 +00:00
|
|
|
extern operator '|' macro SmiOr(Smi, Smi): Smi;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '>>>' macro SmiShr(Smi, constexpr int31): Smi;
|
2018-08-22 13:17:38 +00:00
|
|
|
extern operator '<<' macro SmiShl(Smi, constexpr int31): Smi;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
|
|
|
extern operator '+' macro IntPtrAdd(intptr, intptr): intptr;
|
|
|
|
extern operator '-' macro IntPtrSub(intptr, intptr): intptr;
|
2018-06-18 14:16:44 +00:00
|
|
|
extern operator '>>>' macro WordShr(uintptr, uintptr): uintptr;
|
2018-06-15 12:23:58 +00:00
|
|
|
extern operator '<<' macro WordShl(intptr, intptr): intptr;
|
|
|
|
extern operator '&' macro WordAnd(intptr, intptr): intptr;
|
2018-06-25 13:28:25 +00:00
|
|
|
extern operator '&' macro WordAnd(uintptr, uintptr): uintptr;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-06-06 12:30:08 +00:00
|
|
|
extern operator '+' macro Int32Add(int32, int32): int32;
|
2018-06-15 12:23:58 +00:00
|
|
|
extern operator '-' macro Int32Sub(int32, int32): int32;
|
2018-06-06 12:30:08 +00:00
|
|
|
extern operator '*' macro Int32Mul(int32, int32): int32;
|
|
|
|
extern operator '%' macro Int32Mod(int32, int32): int32;
|
2018-06-25 13:28:25 +00:00
|
|
|
extern operator '&' macro Word32And(int32, int32): int32;
|
|
|
|
extern operator '&' macro Word32And(uint32, uint32): uint32;
|
2018-06-19 15:58:56 +00:00
|
|
|
extern operator '==' macro
|
2018-06-22 08:26:19 +00:00
|
|
|
ConstexprInt31Equal(constexpr int31, constexpr int31): constexpr bool;
|
2018-06-15 12:23:58 +00:00
|
|
|
|
2018-06-25 13:28:25 +00:00
|
|
|
extern operator '==' macro Word32Equal(int32, int32): bool;
|
|
|
|
extern operator '==' macro Word32Equal(uint32, uint32): bool;
|
|
|
|
extern operator '!=' macro Word32NotEqual(int32, int32): bool;
|
|
|
|
extern operator '!=' macro Word32NotEqual(uint32, uint32): bool;
|
|
|
|
extern operator '>>>' macro Word32Shr(uint32, uint32): uint32;
|
|
|
|
extern operator '<<' macro Word32Shl(int32, int32): int32;
|
|
|
|
extern operator '<<' macro Word32Shl(uint32, uint32): uint32;
|
|
|
|
extern operator '|' macro Word32Or(int32, int32): int32;
|
|
|
|
extern operator '|' macro Word32Or(uint32, uint32): uint32;
|
2018-06-06 12:30:08 +00:00
|
|
|
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator '+' macro NumberAdd(Number, Number): Number;
|
|
|
|
extern operator '-' macro NumberSub(Number, Number): Number;
|
2018-07-18 18:03:45 +00:00
|
|
|
extern macro NumberMin(Number, Number): Number;
|
|
|
|
extern macro NumberMax(Number, Number): Number;
|
2018-08-07 15:49:03 +00:00
|
|
|
macro min(x: Number, y: Number): Number {
|
|
|
|
return NumberMin(x, y);
|
2018-07-18 18:03:45 +00:00
|
|
|
}
|
2018-08-07 15:49:03 +00:00
|
|
|
macro max(x: Number, y: Number): Number {
|
|
|
|
return NumberMax(x, y);
|
2018-07-18 18:03:45 +00:00
|
|
|
}
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-08-22 13:17:38 +00:00
|
|
|
extern macro SmiMax(Smi, Smi): Smi;
|
|
|
|
extern macro SmiMin(Smi, Smi): Smi;
|
|
|
|
|
2018-05-13 10:10:44 +00:00
|
|
|
extern operator '!' macro ConstexprBoolNot(constexpr bool): constexpr bool;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '!' macro Word32BinaryNot(bool): bool;
|
2018-08-22 13:17:38 +00:00
|
|
|
extern operator '!' macro IsFalse(Boolean): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-09 08:16:07 +00:00
|
|
|
extern operator '.map' macro LoadMap(HeapObject): Map;
|
|
|
|
extern operator '.map=' macro StoreMap(HeapObject, Map);
|
2018-05-29 08:34:01 +00:00
|
|
|
extern operator
|
2018-06-06 15:35:39 +00:00
|
|
|
'.instanceType' macro LoadInstanceType(HeapObject): InstanceType;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
|
|
|
extern operator '.length' macro LoadStringLengthAsWord(String): intptr;
|
|
|
|
|
2018-05-29 08:34:01 +00:00
|
|
|
extern operator '.length' macro GetArgumentsLength(constexpr Arguments): intptr;
|
|
|
|
extern operator
|
2018-06-06 15:35:39 +00:00
|
|
|
'[]' macro GetArgumentValue(constexpr Arguments, intptr): Object;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro TaggedIsSmi(Object): bool;
|
|
|
|
extern macro TaggedIsNotSmi(Object): bool;
|
2018-06-07 11:48:26 +00:00
|
|
|
extern macro TaggedIsPositiveSmi(Object): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-08-07 21:57:19 +00:00
|
|
|
extern macro HeapObjectToJSDataView(HeapObject): JSDataView labels CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
extern macro TaggedToHeapObject(Object): HeapObject labels CastError;
|
|
|
|
extern macro TaggedToSmi(Object): Smi labels CastError;
|
2018-08-07 21:57:19 +00:00
|
|
|
extern macro HeapObjectToJSArray(HeapObject): JSArray labels CastError;
|
|
|
|
extern macro HeapObjectToCallable(HeapObject): Callable labels CastError;
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro HeapObjectToFixedArray(HeapObject): FixedArray labels CastError;
|
2018-08-07 21:57:19 +00:00
|
|
|
extern macro HeapObjectToFixedDoubleArray(HeapObject):
|
2018-06-12 11:11:44 +00:00
|
|
|
FixedDoubleArray labels CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
extern macro TaggedToNumber(Object): Number labels CastError;
|
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
macro cast_HeapObject<A : type>(o: HeapObject): A labels CastError;
|
|
|
|
cast_HeapObject<HeapObject>(o: HeapObject): HeapObject labels CastError {
|
|
|
|
return o;
|
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
cast_HeapObject<FixedArray>(o: HeapObject): FixedArray labels CastError {
|
|
|
|
return HeapObjectToFixedArray(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-09-04 12:30:33 +00:00
|
|
|
cast_HeapObject<FixedDoubleArray>(o: HeapObject):
|
|
|
|
FixedDoubleArray labels CastError {
|
2018-08-07 21:57:19 +00:00
|
|
|
return HeapObjectToFixedDoubleArray(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
cast_HeapObject<JSDataView>(o: HeapObject): JSDataView labels CastError {
|
|
|
|
return HeapObjectToJSDataView(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
cast_HeapObject<Callable>(o: HeapObject): Callable labels CastError {
|
|
|
|
return HeapObjectToCallable(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
cast_HeapObject<JSArray>(o: HeapObject): JSArray labels CastError {
|
|
|
|
return HeapObjectToJSArray(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
|
|
|
|
macro cast<A : type>(o: HeapObject): A labels CastError {
|
|
|
|
return cast_HeapObject<A>(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 {
|
2018-09-04 12:30:33 +00:00
|
|
|
return cast_HeapObject<A>(TaggedToHeapObject(o) otherwise CastError)
|
|
|
|
otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
cast<Smi>(o: Object): Smi labels CastError {
|
|
|
|
return TaggedToSmi(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-08-07 21:57:19 +00:00
|
|
|
cast<Number>(o: Object): Number labels CastError {
|
|
|
|
return TaggedToNumber(o) otherwise CastError;
|
2018-06-06 15:35:39 +00:00
|
|
|
}
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-09 08:16:07 +00:00
|
|
|
extern macro AllocateHeapNumberWithValue(float64): HeapNumber;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro ChangeInt32ToTagged(int32): Number;
|
|
|
|
extern macro ChangeUint32ToTagged(uint32): Number;
|
2018-06-25 13:28:25 +00:00
|
|
|
extern macro Unsigned(int32): uint32;
|
2018-06-15 12:23:58 +00:00
|
|
|
extern macro Unsigned(intptr): uintptr;
|
2018-06-25 13:28:25 +00:00
|
|
|
extern macro Unsigned(RawPtr): uintptr;
|
|
|
|
extern macro Signed(uint32): int32;
|
2018-06-15 12:23:58 +00:00
|
|
|
extern macro Signed(uintptr): intptr;
|
2018-06-25 13:28:25 +00:00
|
|
|
extern macro Signed(RawPtr): intptr;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro TruncateIntPtrToInt32(intptr): int32;
|
|
|
|
extern macro SmiTag(intptr): Smi;
|
|
|
|
extern macro SmiFromInt32(int32): Smi;
|
|
|
|
extern macro SmiUntag(Smi): intptr;
|
|
|
|
extern macro SmiToInt32(Smi): int32;
|
2018-08-02 14:41:58 +00:00
|
|
|
extern macro RoundIntPtrToFloat64(intptr): float64;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro LoadHeapNumberValue(HeapNumber): float64;
|
|
|
|
extern macro ChangeFloat32ToFloat64(float32): float64;
|
|
|
|
extern macro ChangeNumberToFloat64(Number): float64;
|
2018-08-02 14:41:58 +00:00
|
|
|
extern macro ChangeFloat64ToUintPtr(float64): uintptr;
|
2018-08-07 15:49:03 +00:00
|
|
|
extern macro ChangeInt32ToIntPtr(int32): intptr; // Sign-extends.
|
2018-06-25 13:28:25 +00:00
|
|
|
extern macro ChangeUint32ToWord(uint32): uintptr; // Doesn't sign-extend.
|
2018-06-12 11:11:44 +00:00
|
|
|
|
|
|
|
extern macro NumberConstant(constexpr float64): Number;
|
|
|
|
extern macro NumberConstant(constexpr int32): Number;
|
|
|
|
extern macro IntPtrConstant(constexpr int31): intptr;
|
|
|
|
extern macro IntPtrConstant(constexpr int32): intptr;
|
2018-07-03 12:02:05 +00:00
|
|
|
extern macro Int32Constant(constexpr int31): int31;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro Int32Constant(constexpr int32): int32;
|
2018-06-26 13:55:16 +00:00
|
|
|
extern macro Float64Constant(constexpr int31): float64;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro SmiConstant(constexpr int31): Smi;
|
|
|
|
extern macro BoolConstant(constexpr bool): bool;
|
2018-07-03 12:02:05 +00:00
|
|
|
extern macro StringConstant(constexpr string): String;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro LanguageModeConstant(constexpr LanguageMode): LanguageMode;
|
|
|
|
extern macro Int32Constant(constexpr ElementsKind): ElementsKind;
|
|
|
|
|
2018-06-18 09:33:18 +00:00
|
|
|
macro from_constexpr<A : type>(o: constexpr int31): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<intptr>(i: constexpr int31): intptr {
|
|
|
|
return IntPtrConstant(i);
|
|
|
|
}
|
2018-07-03 12:02:05 +00:00
|
|
|
from_constexpr<int31>(i: constexpr int31): int31 {
|
|
|
|
return Int32Constant(i);
|
|
|
|
}
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<int32>(i: constexpr int31): int32 {
|
|
|
|
return Int32Constant(i);
|
|
|
|
}
|
2018-06-25 13:28:25 +00:00
|
|
|
from_constexpr<uint32>(i: constexpr int31): uint32 {
|
|
|
|
return Unsigned(Int32Constant(i));
|
2018-06-15 12:23:58 +00:00
|
|
|
}
|
2018-06-18 14:16:44 +00:00
|
|
|
from_constexpr<uintptr>(i: constexpr int31): uintptr {
|
|
|
|
return ChangeUint32ToWord(i);
|
|
|
|
}
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<Smi>(i: constexpr int31): Smi {
|
|
|
|
return SmiConstant(i);
|
|
|
|
}
|
|
|
|
from_constexpr<Number>(i: constexpr int31): Number {
|
|
|
|
return SmiConstant(i);
|
|
|
|
}
|
2018-06-26 13:55:16 +00:00
|
|
|
from_constexpr<float64>(i: constexpr int31): float64 {
|
|
|
|
return Float64Constant(i);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro from_constexpr<A : type>(o: constexpr int32): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<intptr>(i: constexpr int32): intptr {
|
|
|
|
return IntPtrConstant(i);
|
|
|
|
}
|
|
|
|
from_constexpr<int32>(i: constexpr int32): int32 {
|
2018-06-15 12:30:38 +00:00
|
|
|
return Int32Constant(i);
|
2018-06-12 11:11:44 +00:00
|
|
|
}
|
|
|
|
from_constexpr<Number>(i: constexpr int32): Number {
|
|
|
|
return NumberConstant(i);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro from_constexpr<A : type>(o: constexpr float64): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<Number>(f: constexpr float64): Number {
|
|
|
|
return NumberConstant(f);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro from_constexpr<A : type>(b: constexpr bool): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<bool>(b: constexpr bool): bool {
|
|
|
|
return BoolConstant(b);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro from_constexpr<A : type>(l: constexpr LanguageMode): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<LanguageMode>(b: constexpr LanguageMode): LanguageMode {
|
|
|
|
return LanguageModeConstant(b);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro from_constexpr<A : type>(e: constexpr ElementsKind): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
from_constexpr<ElementsKind>(e: constexpr ElementsKind): ElementsKind {
|
|
|
|
return Int32Constant(e);
|
|
|
|
}
|
2018-07-03 12:02:05 +00:00
|
|
|
macro from_constexpr<A : type>(s: constexpr string): A;
|
|
|
|
from_constexpr<String>(s: constexpr string): String {
|
2018-06-18 15:50:59 +00:00
|
|
|
return StringConstant(s);
|
|
|
|
}
|
2018-07-03 12:02:05 +00:00
|
|
|
from_constexpr<Object>(s: constexpr string): Object {
|
2018-06-18 15:50:59 +00:00
|
|
|
return StringConstant(s);
|
|
|
|
}
|
2018-05-09 08:16:07 +00:00
|
|
|
|
2018-07-03 12:02:05 +00:00
|
|
|
macro convert<A : type>(i: constexpr int31): A {
|
|
|
|
return i;
|
|
|
|
}
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro ConvertElementsKindToInt(ElementsKind): int32;
|
|
|
|
|
|
|
|
macro convert<A : type>(elements_kind: ElementsKind): A;
|
|
|
|
convert<int32>(elements_kind: ElementsKind): int32 {
|
|
|
|
return ConvertElementsKindToInt(elements_kind);
|
|
|
|
}
|
|
|
|
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(i: int32): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<Number>(i: int32): Number {
|
|
|
|
return ChangeInt32ToTagged(i);
|
|
|
|
}
|
2018-06-15 12:23:58 +00:00
|
|
|
convert<intptr>(i: int32): intptr {
|
|
|
|
return ChangeInt32ToIntPtr(i);
|
|
|
|
}
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<Smi>(i: int32): Smi {
|
|
|
|
return SmiFromInt32(i);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(ui: uint32): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<Number>(ui: uint32): Number {
|
|
|
|
return ChangeUint32ToTagged(ui);
|
|
|
|
}
|
2018-06-25 13:28:25 +00:00
|
|
|
convert<Smi>(ui: uint32): Smi {
|
|
|
|
return SmiFromInt32(Signed(ui));
|
2018-06-15 12:23:58 +00:00
|
|
|
}
|
2018-06-25 13:28:25 +00:00
|
|
|
convert<uintptr>(ui: uint32): uintptr {
|
|
|
|
return ChangeUint32ToWord(ui);
|
2018-06-15 12:23:58 +00:00
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(i: intptr): A;
|
2018-06-25 13:28:25 +00:00
|
|
|
convert<int32>(i: intptr): int32 {
|
2018-06-12 11:11:44 +00:00
|
|
|
return TruncateIntPtrToInt32(i);
|
|
|
|
}
|
|
|
|
convert<Smi>(i: intptr): Smi {
|
|
|
|
return SmiTag(i);
|
|
|
|
}
|
2018-06-18 14:16:44 +00:00
|
|
|
macro convert<A : type>(ui: uintptr): A;
|
2018-06-25 13:28:25 +00:00
|
|
|
convert<uint32>(ui: uintptr): uint32 {
|
|
|
|
return Unsigned(TruncateIntPtrToInt32(Signed(ui)));
|
2018-06-18 14:16:44 +00:00
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(s: Smi): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<intptr>(s: Smi): intptr {
|
|
|
|
return SmiUntag(s);
|
|
|
|
}
|
|
|
|
convert<int32>(s: Smi): int32 {
|
|
|
|
return SmiToInt32(s);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(h: HeapNumber): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<float64>(h: HeapNumber): float64 {
|
|
|
|
return LoadHeapNumberValue(h);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(n: Number): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<float64>(n: Number): float64 {
|
|
|
|
return ChangeNumberToFloat64(n);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro convert<A : type>(f: float32): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
convert<float64>(f: float32): float64 {
|
|
|
|
return ChangeFloat32ToFloat64(f);
|
|
|
|
}
|
2018-06-25 13:28:25 +00:00
|
|
|
macro convert<A : type>(d: float64): A;
|
|
|
|
convert<Number>(d: float64): Number {
|
|
|
|
return AllocateHeapNumberWithValue(d);
|
|
|
|
}
|
2018-08-02 14:41:58 +00:00
|
|
|
convert<uintptr>(d: float64): uintptr {
|
|
|
|
return ChangeFloat64ToUintPtr(d);
|
|
|
|
}
|
2018-06-25 13:28:25 +00:00
|
|
|
macro convert<A : type>(r: RawPtr): A;
|
|
|
|
convert<uintptr>(r: RawPtr): uintptr {
|
|
|
|
return Unsigned(r);
|
|
|
|
}
|
|
|
|
convert<intptr>(r: RawPtr): intptr {
|
|
|
|
return Signed(r);
|
|
|
|
}
|
2018-06-12 11:11:44 +00:00
|
|
|
|
|
|
|
extern macro UnsafeCastNumberToHeapNumber(Number): HeapNumber;
|
2018-07-13 11:09:17 +00:00
|
|
|
extern macro UnsafeCastObjectToFixedArrayBase(Object): FixedArrayBase;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro UnsafeCastObjectToFixedArray(Object): FixedArray;
|
|
|
|
extern macro UnsafeCastObjectToFixedDoubleArray(Object): FixedDoubleArray;
|
|
|
|
extern macro UnsafeCastObjectToHeapNumber(Object): HeapNumber;
|
|
|
|
extern macro UnsafeCastObjectToCallable(Object): Callable;
|
|
|
|
extern macro UnsafeCastObjectToSmi(Object): Smi;
|
|
|
|
extern macro UnsafeCastObjectToNumber(Object): Number;
|
|
|
|
extern macro UnsafeCastObjectToHeapObject(Object): HeapObject;
|
|
|
|
extern macro UnsafeCastObjectToJSArray(Object): JSArray;
|
|
|
|
extern macro UnsafeCastObjectToFixedTypedArrayBase(Object): FixedTypedArrayBase;
|
2018-06-18 09:33:18 +00:00
|
|
|
extern macro UnsafeCastObjectToNumberDictionary(Object): NumberDictionary;
|
|
|
|
extern macro UnsafeCastObjectToJSReceiver(Object): JSReceiver;
|
|
|
|
extern macro UnsafeCastObjectToJSObject(Object): JSObject;
|
2018-07-13 11:09:17 +00:00
|
|
|
extern macro UnsafeCastObjectToMap(Object): Map;
|
2018-06-12 11:11:44 +00:00
|
|
|
|
2018-06-18 09:33:18 +00:00
|
|
|
macro unsafe_cast<A : type>(n: Number): A;
|
2018-06-12 11:11:44 +00:00
|
|
|
unsafe_cast<HeapNumber>(n: Number): HeapNumber {
|
|
|
|
return UnsafeCastNumberToHeapNumber(n);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
macro unsafe_cast<A : type>(o: Object): A;
|
2018-09-04 12:30:33 +00:00
|
|
|
unsafe_cast<Object>(o: Object): Object {
|
|
|
|
return o;
|
|
|
|
}
|
2018-06-12 11:11:44 +00:00
|
|
|
unsafe_cast<FixedArray>(o: Object): FixedArray {
|
|
|
|
return UnsafeCastObjectToFixedArray(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<FixedDoubleArray>(o: Object): FixedDoubleArray {
|
|
|
|
return UnsafeCastObjectToFixedDoubleArray(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<HeapNumber>(o: Object): HeapNumber {
|
|
|
|
return UnsafeCastObjectToHeapNumber(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<Callable>(o: Object): Callable {
|
|
|
|
return UnsafeCastObjectToCallable(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<Smi>(o: Object): Smi {
|
|
|
|
return UnsafeCastObjectToSmi(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<Number>(o: Object): Number {
|
|
|
|
return UnsafeCastObjectToNumber(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<HeapObject>(o: Object): HeapObject {
|
|
|
|
return UnsafeCastObjectToHeapObject(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<JSArray>(o: Object): JSArray {
|
|
|
|
return UnsafeCastObjectToJSArray(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<FixedTypedArrayBase>(o: Object): FixedTypedArrayBase {
|
|
|
|
return UnsafeCastObjectToFixedTypedArrayBase(o);
|
|
|
|
}
|
2018-06-18 09:33:18 +00:00
|
|
|
unsafe_cast<NumberDictionary>(o: Object): NumberDictionary {
|
|
|
|
return UnsafeCastObjectToNumberDictionary(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<JSReceiver>(o: Object): JSReceiver {
|
|
|
|
return UnsafeCastObjectToJSReceiver(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<JSObject>(o: Object): JSObject {
|
|
|
|
return UnsafeCastObjectToJSObject(o);
|
|
|
|
}
|
2018-07-13 11:09:17 +00:00
|
|
|
unsafe_cast<Map>(o: Object): Map {
|
|
|
|
return UnsafeCastObjectToMap(o);
|
|
|
|
}
|
|
|
|
unsafe_cast<FixedArrayBase>(o: Object): FixedArrayBase {
|
|
|
|
return UnsafeCastObjectToFixedArrayBase(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
const kCOWMap: Map = unsafe_cast<Map>(LoadRoot(kFixedCOWArrayMapRootIndex));
|
2018-08-07 15:49:03 +00:00
|
|
|
const kEmptyFixedArray: FixedArrayBase =
|
|
|
|
unsafe_cast<FixedArrayBase>(LoadRoot(kEmptyFixedArrayRootIndex));
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:55:55 +00:00
|
|
|
extern macro BranchIfFastJSArray(Object, Context): never labels Taken, NotTaken;
|
|
|
|
extern macro BranchIfNotFastJSArray(Object, Context): never labels Taken,
|
|
|
|
NotTaken;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-08-28 09:14:58 +00:00
|
|
|
macro EnsureFastJSArray(context: Context, object: Object) labels Bailout {
|
|
|
|
if (BranchIfNotFastJSArray(object, context)) goto Bailout;
|
|
|
|
}
|
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro IsPrototypeInitialArrayPrototype(Context, Map): bool;
|
|
|
|
extern macro IsNoElementsProtectorCellInvalid(): bool;
|
|
|
|
extern macro IsArraySpeciesProtectorCellInvalid(): bool;
|
|
|
|
extern macro IsTypedArraySpeciesProtectorCellInvalid(): bool;
|
|
|
|
extern macro IsPromiseSpeciesProtectorCellInvalid(): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-04-25 08:14:09 +00:00
|
|
|
extern operator
|
2018-05-04 15:04:42 +00:00
|
|
|
'.buffer' macro LoadTypedArrayBuffer(JSTypedArray): JSArrayBuffer;
|
2018-04-25 08:14:09 +00:00
|
|
|
|
|
|
|
extern operator '.data_ptr' macro LoadDataPtr(JSTypedArray): RawPtr;
|
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern operator '.elements_kind' macro LoadMapElementsKind(Map): ElementsKind;
|
|
|
|
extern operator
|
|
|
|
'.elements_kind' macro LoadElementsKind(JSTypedArray): ElementsKind;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-29 08:34:01 +00:00
|
|
|
extern operator '.elements' macro LoadElements(JSObject): FixedArrayBase;
|
|
|
|
extern operator '.elements=' macro StoreElements(JSObject, FixedArrayBase);
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-04-25 08:14:09 +00:00
|
|
|
extern operator '.length' macro LoadTypedArrayLength(JSTypedArray): Smi;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator '.length' macro LoadJSArrayLength(JSArray): Number;
|
2018-06-05 07:54:49 +00:00
|
|
|
extern operator '.length_fast' macro LoadFastJSArrayLength(JSArray): Smi;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator '.length=' macro StoreJSArrayLength(JSArray, Smi);
|
|
|
|
|
|
|
|
extern operator '.length' macro LoadFixedArrayBaseLength(FixedArrayBase): Smi;
|
|
|
|
extern operator '[]' macro LoadFixedArrayElement(FixedArray, intptr): Object;
|
|
|
|
extern operator '[]' macro LoadFixedArrayElement(FixedArray, Smi): Object;
|
2018-06-07 11:48:26 +00:00
|
|
|
extern operator
|
2018-08-22 13:17:38 +00:00
|
|
|
'[]' macro LoadFixedArrayElement(FixedArray, constexpr int31): Object;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern operator
|
|
|
|
'[]=' macro StoreFixedArrayElement(FixedArray, intptr, Object): void;
|
|
|
|
extern operator
|
2018-09-04 12:30:33 +00:00
|
|
|
'[]=' macro StoreFixedArrayElement(FixedArray, constexpr int31, Object): void;
|
2018-06-07 11:48:26 +00:00
|
|
|
extern operator
|
2018-04-16 09:24:22 +00:00
|
|
|
'[]=' macro StoreFixedArrayElementSmi(FixedArray, Smi, Object): void;
|
2018-09-04 12:30:33 +00:00
|
|
|
operator '[]=' macro StoreFixedDoubleArrayNumber(
|
|
|
|
a: FixedDoubleArray, index: Smi, value: Number): void {
|
|
|
|
a[index] = convert<float64>(value);
|
|
|
|
}
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro StoreFixedArrayElementSmi(
|
|
|
|
FixedArray, Smi, Object, constexpr WriteBarrierMode): void;
|
2018-08-13 08:43:56 +00:00
|
|
|
|
2018-06-18 09:33:18 +00:00
|
|
|
extern operator '.instance_type' macro LoadMapInstanceType(Map): int32;
|
|
|
|
|
2018-06-05 07:54:49 +00:00
|
|
|
extern macro LoadFixedDoubleArrayElement(FixedDoubleArray, Smi): float64;
|
|
|
|
extern macro Float64SilenceNaN(float64): float64;
|
|
|
|
|
|
|
|
extern macro StoreFixedDoubleArrayElement(
|
|
|
|
FixedDoubleArray, Object, float64, constexpr ParameterMode);
|
|
|
|
macro StoreFixedDoubleArrayElementWithSmiIndex(
|
|
|
|
array: FixedDoubleArray, index: Smi, value: float64) {
|
|
|
|
StoreFixedDoubleArrayElement(array, index, value, SMI_PARAMETERS);
|
|
|
|
}
|
|
|
|
|
2018-06-18 09:33:18 +00:00
|
|
|
extern macro BasicLoadNumberDictionaryElement(NumberDictionary, intptr):
|
2018-08-07 15:49:03 +00:00
|
|
|
Object labels NotData,
|
|
|
|
IfHole;
|
2018-06-18 09:33:18 +00:00
|
|
|
extern macro BasicStoreNumberDictionaryElement(NumberDictionary, intptr, Object)
|
[array] Throw TypeError for read-only properties on fast-path
This CL changes the NumberDictionary fast-path for Array.p.sort to
throw a TypeError when trying to write to a read-only property.
Previously, the fast-path simply bailed to the slow-path which could
swallow the TypeError by accident. I.e. because the fast-path could
leave the array in an inconsistent state that is already sorted.
Example:
let arr = new Array(10);
Object.defineProperty(arr, 0, {value: 2, writable: false});
Object.defineProperty(arr, 2, {value: 1, writable: false});
arr.sort();
The pre-processing step will move the value 1 to index 1: {0: 2, 1: 1}
When trying to swap those 2 values, the fast-path will write the 2 at
index 1, then try to write the 1 at index 0 and fail, bailing to the
slow-path. As the array looks like {0: 2, 1: 2} its already sorted
and the TypeError will not be thrown.
R=jgruber@chromium.org
Bug: v8:7382, v8:7907
Change-Id: I5d2f2d73478fdca066ce1048dcb2b8301751cb1f
Reviewed-on: https://chromium-review.googlesource.com/1122120
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54150}
2018-07-02 14:56:52 +00:00
|
|
|
labels NotData, IfHole, ReadOnly;
|
2018-06-18 09:33:18 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro IsFastElementsKind(ElementsKind): bool;
|
2018-06-12 11:11:44 +00:00
|
|
|
extern macro IsDoubleElementsKind(ElementsKind): bool;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro IsFastSmiOrTaggedElementsKind(ElementsKind): bool;
|
|
|
|
extern macro IsFastSmiElementsKind(ElementsKind): bool;
|
2018-05-09 08:16:07 +00:00
|
|
|
extern macro IsHoleyFastElementsKind(ElementsKind): bool;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
macro AllowDoubleElements(kind: ElementsKind): ElementsKind {
|
|
|
|
if (kind == PACKED_SMI_ELEMENTS) {
|
|
|
|
return PACKED_DOUBLE_ELEMENTS;
|
|
|
|
} else if (kind == HOLEY_SMI_ELEMENTS) {
|
|
|
|
return HOLEY_DOUBLE_ELEMENTS;
|
|
|
|
}
|
|
|
|
return kind;
|
|
|
|
}
|
|
|
|
|
|
|
|
macro AllowNonNumberElements(kind: ElementsKind): ElementsKind {
|
|
|
|
if (kind == PACKED_SMI_ELEMENTS) {
|
|
|
|
return PACKED_ELEMENTS;
|
|
|
|
} else if (kind == HOLEY_SMI_ELEMENTS) {
|
|
|
|
return HOLEY_ELEMENTS;
|
|
|
|
} else if (kind == PACKED_DOUBLE_ELEMENTS) {
|
|
|
|
return PACKED_ELEMENTS;
|
|
|
|
} else if (kind == HOLEY_DOUBLE_ELEMENTS) {
|
|
|
|
return HOLEY_ELEMENTS;
|
|
|
|
}
|
|
|
|
return kind;
|
|
|
|
}
|
|
|
|
|
2018-08-13 15:08:55 +00:00
|
|
|
extern macro AllocateZeroedFixedArray(intptr): FixedArray;
|
|
|
|
extern macro AllocateZeroedFixedDoubleArray(intptr): FixedDoubleArray;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
|
|
|
extern macro CopyFixedArrayElements(
|
2018-05-04 15:04:42 +00:00
|
|
|
constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray,
|
|
|
|
intptr, intptr, intptr): void;
|
2018-04-16 09:24:22 +00:00
|
|
|
extern macro CopyFixedArrayElements(
|
2018-05-04 15:04:42 +00:00
|
|
|
constexpr ElementsKind, FixedArray, constexpr ElementsKind, FixedArray, Smi,
|
|
|
|
Smi, Smi): void;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro AllocateJSArray(constexpr ElementsKind, Map, intptr, Smi): JSArray;
|
|
|
|
extern macro AllocateJSArray(constexpr ElementsKind, Map, Smi, Smi): JSArray;
|
2018-05-09 08:16:07 +00:00
|
|
|
extern macro IsElementsKindGreaterThan(
|
|
|
|
ElementsKind, constexpr ElementsKind): bool;
|
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern operator
|
|
|
|
'[]=' macro StoreFixedDoubleArrayElementSmi(
|
|
|
|
FixedDoubleArray, Smi, float64): void;
|
|
|
|
|
2018-05-09 08:16:07 +00:00
|
|
|
extern macro LoadDoubleWithHoleCheck(FixedDoubleArray, Smi): float64
|
|
|
|
labels IfHole;
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro StoreFixedDoubleArrayHoleSmi(FixedDoubleArray, Smi): void;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-07-16 10:46:01 +00:00
|
|
|
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;
|
2018-08-07 15:49:03 +00:00
|
|
|
extern macro Call(
|
|
|
|
Context, Callable, Object, Object, Object, Object, Object): Object;
|
|
|
|
extern macro Call(
|
|
|
|
Context, Callable, Object, Object, Object, Object, Object, Object): Object;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro ExtractFixedArray(FixedArrayBase, Smi, Smi, Smi): FixedArrayBase;
|
2018-04-16 09:24:22 +00:00
|
|
|
|
|
|
|
extern builtin ExtractFastJSArray(Context, JSArray, Smi, Smi): JSArray;
|
|
|
|
|
2018-05-22 21:18:42 +00:00
|
|
|
macro LoadElementNoHole<T : type>(a: JSArray, index: Smi): Object labels IfHole;
|
2018-05-18 08:23:25 +00:00
|
|
|
|
|
|
|
LoadElementNoHole<FixedArray>(a: JSArray, index: Smi): Object
|
|
|
|
labels IfHole {
|
|
|
|
try {
|
|
|
|
let elements: FixedArray =
|
|
|
|
cast<FixedArray>(a.elements) otherwise Unexpected;
|
|
|
|
let e: Object = elements[index];
|
|
|
|
if (e == Hole) {
|
|
|
|
goto IfHole;
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
label Unexpected {
|
|
|
|
unreachable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadElementNoHole<FixedDoubleArray>(a: JSArray, index: Smi): Object
|
|
|
|
labels IfHole {
|
|
|
|
try {
|
|
|
|
let elements: FixedDoubleArray =
|
|
|
|
cast<FixedDoubleArray>(a.elements) otherwise Unexpected;
|
|
|
|
let e: float64 = LoadDoubleWithHoleCheck(elements, index) otherwise IfHole;
|
|
|
|
return AllocateHeapNumberWithValue(e);
|
|
|
|
}
|
|
|
|
label Unexpected {
|
|
|
|
unreachable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro TransitionElementsKind(
|
|
|
|
JSObject, Map, ElementsKind, ElementsKind): void labels Bailout;
|
|
|
|
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro IsCallable(HeapObject): bool;
|
2018-06-05 07:54:49 +00:00
|
|
|
extern macro IsJSArray(HeapObject): bool;
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro IsJSReceiver(HeapObject): bool;
|
2018-05-04 15:04:42 +00:00
|
|
|
extern macro TaggedIsCallable(Object): bool;
|
|
|
|
extern macro IsDetachedBuffer(JSArrayBuffer): bool;
|
2018-06-08 11:12:59 +00:00
|
|
|
extern macro IsHeapNumber(HeapObject): bool;
|
2018-08-22 13:17:38 +00:00
|
|
|
extern macro IsFixedArray(HeapObject): bool;
|
2018-09-04 12:30:33 +00:00
|
|
|
extern macro IsNumber(Object): bool;
|
2018-06-18 09:33:18 +00:00
|
|
|
extern macro IsExtensibleMap(Map): bool;
|
|
|
|
extern macro IsCustomElementsReceiverInstanceType(int32): bool;
|
2018-08-28 09:14:58 +00:00
|
|
|
extern macro IsFastJSArray(Object, Context): bool;
|
[array] Throw TypeError for read-only properties on fast-path
This CL changes the NumberDictionary fast-path for Array.p.sort to
throw a TypeError when trying to write to a read-only property.
Previously, the fast-path simply bailed to the slow-path which could
swallow the TypeError by accident. I.e. because the fast-path could
leave the array in an inconsistent state that is already sorted.
Example:
let arr = new Array(10);
Object.defineProperty(arr, 0, {value: 2, writable: false});
Object.defineProperty(arr, 2, {value: 1, writable: false});
arr.sort();
The pre-processing step will move the value 1 to index 1: {0: 2, 1: 1}
When trying to swap those 2 values, the fast-path will write the 2 at
index 1, then try to write the 1 at index 0 and fail, bailing to the
slow-path. As the array looks like {0: 2, 1: 2} its already sorted
and the TypeError will not be thrown.
R=jgruber@chromium.org
Bug: v8:7382, v8:7907
Change-Id: I5d2f2d73478fdca066ce1048dcb2b8301751cb1f
Reviewed-on: https://chromium-review.googlesource.com/1122120
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54150}
2018-07-02 14:56:52 +00:00
|
|
|
extern macro Typeof(Object): Object;
|
2018-06-05 07:54:49 +00:00
|
|
|
|
2018-06-08 11:12:59 +00:00
|
|
|
// Return true iff number is NaN.
|
|
|
|
macro NumberIsNaN(number: Number): bool {
|
2018-08-07 21:57:19 +00:00
|
|
|
typeswitch(number) {
|
|
|
|
case (Smi) {
|
|
|
|
return false;
|
|
|
|
} case (hn : HeapNumber) {
|
2018-09-04 12:30:33 +00:00
|
|
|
let value: float64 = convert<float64>(hn);
|
|
|
|
return value != value;
|
|
|
|
}
|
2018-07-18 18:03:45 +00:00
|
|
|
}
|
2018-06-08 11:12:59 +00:00
|
|
|
}
|
2018-06-18 16:06:22 +00:00
|
|
|
|
|
|
|
extern macro BranchIfToBooleanIsTrue(Object): never labels Taken, NotTaken;
|
|
|
|
|
|
|
|
macro ToBoolean(obj: Object): bool {
|
2018-07-02 10:45:24 +00:00
|
|
|
if (BranchIfToBooleanIsTrue(obj)) {
|
2018-06-22 08:26:19 +00:00
|
|
|
return true;
|
2018-07-02 10:45:24 +00:00
|
|
|
} else {
|
2018-06-22 08:26:19 +00:00
|
|
|
return false;
|
2018-06-18 16:06:22 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-02 14:41:58 +00:00
|
|
|
|
|
|
|
macro ToIndex(input: Object, context: Context): Number labels RangeError {
|
|
|
|
if (input == Undefined) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
let value: Number = ToInteger_Inline(context, input, kTruncateMinusZero);
|
|
|
|
if (value < 0 || value > kMaxSafeInteger) {
|
|
|
|
goto RangeError;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|