[torque] Fix all current lint errors in Torque code

To make the changes in base.tq work, there were 2 changes needed on
the C++ side:
  - calls to "FromConstexpr" are generated by the compiler for
    implicit conversions.
  - type switch is desugared and uses "Cast"

R=jgruber@chromium.org, tebbi@chromium.org

Change-Id: I085f1a393f93e501e6bbcaeacb0d6568259a4714
Reviewed-on: https://chromium-review.googlesource.com/1219629
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55794}
This commit is contained in:
Simon Zünd 2018-09-11 15:15:02 +02:00 committed by Commit Bot
parent 44202a1b42
commit 31eca73d34
14 changed files with 1022 additions and 1026 deletions

View File

@ -4,7 +4,7 @@
module array {
macro ConvertToRelativeIndex(index: Number, length: Number): Number {
return index < 0 ? max(index + length, 0) : min(index, length);
return index < 0 ? Max(index + length, 0) : Min(index, length);
}
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
@ -17,32 +17,32 @@ module array {
const length: Number = GetLengthProperty(context, object);
// 3. Let relativeTarget be ? ToInteger(target).
const relative_target: Number = ToInteger_Inline(context, arguments[0]);
const relativeTarget: Number = ToInteger_Inline(context, arguments[0]);
// 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0);
// else let to be min(relativeTarget, len).
let to: Number = ConvertToRelativeIndex(relative_target, length);
let to: Number = ConvertToRelativeIndex(relativeTarget, length);
// 5. Let relativeStart be ? ToInteger(start).
const relative_start: Number = ToInteger_Inline(context, arguments[1]);
const relativeStart: Number = ToInteger_Inline(context, arguments[1]);
// 6. If relativeStart < 0, let from be max((len + relativeStart), 0);
// else let from be min(relativeStart, len).
let from: Number = ConvertToRelativeIndex(relative_start, length);
let from: Number = ConvertToRelativeIndex(relativeStart, length);
// 7. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end).
let relative_end: Number = length;
let relativeEnd: Number = length;
if (arguments[2] != Undefined) {
relative_end = ToInteger_Inline(context, arguments[2]);
relativeEnd = ToInteger_Inline(context, arguments[2]);
}
// 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
// else let final be min(relativeEnd, len).
const final: Number = ConvertToRelativeIndex(relative_end, length);
const final: Number = ConvertToRelativeIndex(relativeEnd, length);
// 9. Let count be min(final-from, len-to).
let count: Number = min(final - from, length - to);
let count: Number = Min(final - from, length - to);
// 10. If from<to and to<from+count, then.
let direction: Number = 1;
@ -63,15 +63,15 @@ module array {
// a. Let fromKey be ! ToString(from).
// b. Let toKey be ! ToString(to).
// c. Let fromPresent be ? HasProperty(O, fromKey).
const from_present: Boolean = HasProperty(context, object, from);
const fromPresent: Boolean = HasProperty(context, object, from);
// d. If fromPresent is true, then.
if (from_present == True) {
if (fromPresent == True) {
// i. Let fromVal be ? Get(O, fromKey).
const from_val: Object = GetProperty(context, object, from);
const fromVal: Object = GetProperty(context, object, from);
// ii. Perform ? Set(O, toKey, fromVal, true).
SetProperty(context, object, to, from_val);
SetProperty(context, object, to, fromVal);
} else {
// i. Perform ? DeletePropertyOrThrow(O, toKey).
DeleteProperty(context, object, to, kStrict);

View File

@ -5,10 +5,10 @@
module array {
macro ArrayForEachTorqueContinuation(
context: Context, o: JSReceiver, len: Number, callbackfn: Callable,
thisArg: Object, initial_k: Number): Object {
thisArg: Object, initialK: Number): Object {
// 5. Let k be 0.
// 6. Repeat, while k < len
for (let k: Number = initial_k; k < len; k = k + 1) {
for (let k: Number = initialK; k < len; k = k + 1) {
// 6a. Let Pk be ! ToString(k).
// k is guaranteed to be a positive integer, hence ToString is
// side-effect free and HasProperty/GetProperty do the conversion inline.
@ -33,10 +33,10 @@ module array {
javascript builtin ArrayForEachLoopEagerDeoptContinuation(
context: Context, receiver: Object, callback: Object, thisArg: Object,
initialK: Object, length: Object): Object {
// The unsafe cast is safe because all continuation points in forEach are
// The unsafe Cast is safe because all continuation points in forEach are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
const jsreceiver: JSReceiver = UnsafeCast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined);
@ -45,10 +45,10 @@ module array {
javascript builtin ArrayForEachLoopLazyDeoptContinuation(
context: Context, receiver: Object, callback: Object, thisArg: Object,
initialK: Object, length: Object, result: Object): Object {
// The unsafe cast is safe because all continuation points in forEach are
// The unsafe Cast is safe because all continuation points in forEach are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
const jsreceiver: JSReceiver = UnsafeCast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined);
@ -60,12 +60,12 @@ module array {
to: Object): Object {
try {
const callbackfn: Callable =
cast<Callable>(callback) otherwise Unexpected;
const k: Number = cast<Number>(initialK) otherwise Unexpected;
const number_length: Number = cast<Number>(length) otherwise Unexpected;
Cast<Callable>(callback) otherwise Unexpected;
const k: Number = Cast<Number>(initialK) otherwise Unexpected;
const numberLength: Number = Cast<Number>(length) otherwise Unexpected;
return ArrayForEachTorqueContinuation(
context, receiver, number_length, callbackfn, thisArg, k);
context, receiver, numberLength, callbackfn, thisArg, k);
}
label Unexpected {
unreachable;
@ -112,8 +112,8 @@ module array {
Bailout(Smi) {
let k: Smi = 0;
try {
const smi_len: Smi = cast<Smi>(len) otherwise Slow;
const a: JSArray = cast<JSArray>(o) otherwise Slow;
const smiLen: Smi = Cast<Smi>(len) otherwise Slow;
const a: JSArray = Cast<JSArray>(o) otherwise Slow;
const map: Map = a.map;
if (!IsPrototypeInitialArrayPrototype(context, map)) goto Slow;
@ -122,10 +122,10 @@ module array {
if (IsElementsKindGreaterThan(elementsKind, HOLEY_ELEMENTS)) {
VisitAllElements<FixedDoubleArray>(
context, a, smi_len, callbackfn, thisArg)
context, a, smiLen, callbackfn, thisArg)
otherwise Bailout;
} else {
VisitAllElements<FixedArray>(context, a, smi_len, callbackfn, thisArg)
VisitAllElements<FixedArray>(context, a, smiLen, callbackfn, thisArg)
otherwise Bailout;
}
}
@ -154,7 +154,7 @@ module array {
goto TypeError;
}
const callbackfn: Callable =
cast<Callable>(arguments[0]) otherwise TypeError;
Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
@ -165,8 +165,8 @@ module array {
return FastArrayForEach(context, o, len, callbackfn, thisArg)
otherwise Bailout;
}
label Bailout(k_value: Smi) {
k = k_value;
label Bailout(kValue: Smi) {
k = kValue;
}
return ArrayForEachTorqueContinuation(

View File

@ -9,7 +9,7 @@ module array {
LoadWithHoleCheck<FixedArray>(elements: FixedArrayBase, index: Smi): Object
labels IfHole {
const elements: FixedArray = unsafe_cast<FixedArray>(elements);
const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements[index];
if (element == Hole) goto IfHole;
return element;
@ -18,7 +18,7 @@ module array {
LoadWithHoleCheck<FixedDoubleArray>(
elements: FixedArrayBase, index: Smi): Object
labels IfHole {
const elements: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements);
const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
const element: float64 = LoadDoubleWithHoleCheck(elements, index)
otherwise IfHole;
return AllocateHeapNumberWithValue(element);
@ -63,7 +63,7 @@ module array {
if (n >= 0) {
// a. If n is -0, let k be +0; else let k be min(n, len - 1).
// If n was -0 it got truncated to 0.0, so taking the minimum is fine.
k = min(n, length - 1);
k = Min(n, length - 1);
} else {
// a. Let k be len + n.
k = length + n;
@ -76,12 +76,12 @@ module array {
from: Number): Object
labels Slow {
EnsureFastJSArray(context, receiver) otherwise Slow;
const array: JSArray = unsafe_cast<JSArray>(receiver);
const array: JSArray = UnsafeCast<JSArray>(receiver);
const length: Smi = array.length_fast;
if (length == 0) return SmiConstant(-1);
const fromSmi: Smi = cast<Smi>(from) otherwise Slow;
const fromSmi: Smi = Cast<Smi>(from) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
if (IsFastSmiOrTaggedElementsKind(kind)) {
return FastArrayLastIndexOf<FixedArray>(
@ -100,10 +100,10 @@ module array {
// 7. Repeat, while k >= 0.
while (k >= 0) {
// a. Let kPresent be ? HasProperty(O, ! ToString(k)).
const k_present: Boolean = HasProperty(context, object, k);
const kPresent: Boolean = HasProperty(context, object, k);
// b. If kPresent is true, then.
if (k_present == True) {
if (kPresent == True) {
// i. Let elementK be ? Get(O, ! ToString(k)).
const element: Object = GetProperty(context, object, k);

View File

@ -8,20 +8,20 @@ module array {
LoadElement<FastPackedSmiElements, Smi>(
elements: FixedArrayBase, index: Smi): Smi {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
return unsafe_cast<Smi>(elems[index]);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
return UnsafeCast<Smi>(elems[index]);
}
LoadElement<FastPackedObjectElements, Object>(
elements: FixedArrayBase, index: Smi): Object {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
return elems[index];
}
LoadElement<FastPackedDoubleElements, float64>(
elements: FixedArrayBase, index: Smi): float64 {
try {
const elems: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements);
const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
return LoadDoubleWithHoleCheck(elems, index) otherwise Hole;
}
label Hole {
@ -36,19 +36,19 @@ module array {
StoreElement<FastPackedSmiElements, Smi>(
elements: FixedArrayBase, index: Smi, value: Smi) {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
StoreFixedArrayElementSmi(elems, index, value, SKIP_WRITE_BARRIER);
}
StoreElement<FastPackedObjectElements, Object>(
elements: FixedArrayBase, index: Smi, value: Object) {
const elems: FixedArray = unsafe_cast<FixedArray>(elements);
const elems: FixedArray = UnsafeCast<FixedArray>(elements);
elems[index] = value;
}
StoreElement<FastPackedDoubleElements, float64>(
elements: FixedArrayBase, index: Smi, value: float64) {
const elems: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements);
const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
assert(value == Float64SilenceNaN(value));
StoreFixedDoubleArrayElementWithSmiIndex(elems, index, value);
@ -63,10 +63,10 @@ module array {
let upper: Smi = length - 1;
while (lower < upper) {
const lower_value: T = LoadElement<Accessor, T>(elements, lower);
const upper_value: T = LoadElement<Accessor, T>(elements, upper);
StoreElement<Accessor, T>(elements, lower, upper_value);
StoreElement<Accessor, T>(elements, upper, lower_value);
const lowerValue: T = LoadElement<Accessor, T>(elements, lower);
const upperValue: T = LoadElement<Accessor, T>(elements, upper);
StoreElement<Accessor, T>(elements, lower, upperValue);
StoreElement<Accessor, T>(elements, upper, lowerValue);
++lower;
--upper;
}
@ -90,48 +90,48 @@ module array {
let upper: Number = length - 1;
while (lower < upper) {
let lower_value: Object = Undefined;
let upper_value: Object = Undefined;
let lowerValue: Object = Undefined;
let upperValue: Object = Undefined;
// b. Let upperP be ! ToString(upper).
// c. Let lowerP be ! ToString(lower).
// d. Let lowerExists be ? HasProperty(O, lowerP).
const lower_exists: Boolean = HasProperty(context, object, lower);
const lowerExists: Boolean = HasProperty(context, object, lower);
// e. If lowerExists is true, then.
if (lower_exists == True) {
if (lowerExists == True) {
// i. Let lowerValue be ? Get(O, lowerP).
lower_value = GetProperty(context, object, lower);
lowerValue = GetProperty(context, object, lower);
}
// f. Let upperExists be ? HasProperty(O, upperP).
const upper_exists: Boolean = HasProperty(context, object, upper);
const upperExists: Boolean = HasProperty(context, object, upper);
// g. If upperExists is true, then.
if (upper_exists == True) {
if (upperExists == True) {
// i. Let upperValue be ? Get(O, upperP).
upper_value = GetProperty(context, object, upper);
upperValue = GetProperty(context, object, upper);
}
// h. If lowerExists is true and upperExists is true, then
if (lower_exists == True && upper_exists == True) {
if (lowerExists == True && upperExists == True) {
// i. Perform ? Set(O, lowerP, upperValue, true).
SetProperty(context, object, lower, upper_value);
SetProperty(context, object, lower, upperValue);
// ii. Perform ? Set(O, upperP, lowerValue, true).
SetProperty(context, object, upper, lower_value);
} else if (lower_exists == False && upper_exists == True) {
SetProperty(context, object, upper, lowerValue);
} else if (lowerExists == False && upperExists == True) {
// i. Perform ? Set(O, lowerP, upperValue, true).
SetProperty(context, object, lower, upper_value);
SetProperty(context, object, lower, upperValue);
// ii. Perform ? DeletePropertyOrThrow(O, upperP).
DeleteProperty(context, object, upper, kStrict);
} else if (lower_exists == True && upper_exists == False) {
} else if (lowerExists == True && upperExists == False) {
// i. Perform ? DeletePropertyOrThrow(O, lowerP).
DeleteProperty(context, object, lower, kStrict);
// ii. Perform ? Set(O, upperP, lowerValue, true).
SetProperty(context, object, upper, lower_value);
SetProperty(context, object, upper, lowerValue);
}
// l. Increase lower by 1.
@ -144,7 +144,7 @@ module array {
}
macro TryFastPackedArrayReverse(receiver: Object) labels Slow {
const array: JSArray = cast<JSArray>(receiver) otherwise Slow;
const array: JSArray = Cast<JSArray>(receiver) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
if (kind == PACKED_SMI_ELEMENTS) {

View File

@ -10,7 +10,7 @@ module array {
macro Extract<FixedArrayType : type>(
elements: FixedArrayBase, first: Smi, count: Smi,
capacity: Smi): FixedArrayType {
return unsafe_cast<FixedArrayType>(
return UnsafeCast<FixedArrayType>(
ExtractFixedArray(elements, first, count, capacity));
}
@ -18,9 +18,9 @@ module array {
elements: FixedArrayBase, first: Smi, count: Smi,
capacity: Smi): FixedDoubleArray {
if (elements == kEmptyFixedArray) {
return AllocateZeroedFixedDoubleArray(convert<intptr>(capacity));
return AllocateZeroedFixedDoubleArray(Convert<intptr>(capacity));
}
return unsafe_cast<FixedDoubleArray>(
return UnsafeCast<FixedDoubleArray>(
ExtractFixedArray(elements, first, count, capacity));
}
@ -47,11 +47,11 @@ module array {
let k: Smi = actualStart;
if (insertCount > 0) {
const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements);
UnsafeCast<FixedArrayType>(newElements);
for (let e: Object of args [2: ]) {
// The argument elements were already validated to be an appropriate
// {ElementType} to store in {FixedArrayType}.
typedNewElements[k++] = unsafe_cast<ElementType>(e);
typedNewElements[k++] = UnsafeCast<ElementType>(e);
}
}
@ -59,9 +59,9 @@ module array {
let count: Smi = length - actualStart - actualDeleteCount;
while (count > 0) {
const typedElements: FixedArrayType =
unsafe_cast<FixedArrayType>(elements);
UnsafeCast<FixedArrayType>(elements);
const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements);
UnsafeCast<FixedArrayType>(newElements);
CopyArrayElement(typedElements, typedNewElements, k - lengthDelta, k);
k++;
count--;
@ -72,7 +72,7 @@ module array {
// is pre-filled with holes.
if (elements == newElements) {
const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements);
UnsafeCast<FixedArrayType>(newElements);
const limit: Smi = elements.length;
while (k < limit) {
StoreArrayHole(typedNewElements, k);
@ -90,14 +90,14 @@ module array {
actualDeleteCountNumber: Number): Object
labels Bailout {
const originalLength: Smi =
cast<Smi>(originalLengthNumber) otherwise Bailout;
const actualStart: Smi = cast<Smi>(actualStartNumber) otherwise Bailout;
Cast<Smi>(originalLengthNumber) otherwise Bailout;
const actualStart: Smi = Cast<Smi>(actualStartNumber) otherwise Bailout;
const actualDeleteCount: Smi =
cast<Smi>(actualDeleteCountNumber) otherwise Bailout;
Cast<Smi>(actualDeleteCountNumber) otherwise Bailout;
const lengthDelta: Smi = insertCount - actualDeleteCount;
const newLength: Smi = originalLength + lengthDelta;
const a: JSArray = cast<JSArray>(o) otherwise Bailout;
const a: JSArray = Cast<JSArray>(o) otherwise Bailout;
const map: Map = a.map;
if (!IsPrototypeInitialArrayPrototype(context, map)) goto Bailout;
@ -112,7 +112,7 @@ module array {
for (let e: Object of args [2: ]) {
if (IsFastSmiElementsKind(elementsKind)) {
if (TaggedIsNotSmi(e)) {
const heapObject: HeapObject = unsafe_cast<HeapObject>(e);
const heapObject: HeapObject = UnsafeCast<HeapObject>(e);
elementsKind = IsHeapNumber(heapObject) ?
AllowDoubleElements(elementsKind) :
AllowNonNumberElements(elementsKind);
@ -125,12 +125,12 @@ module array {
}
if (elementsKind != oldElementsKind) {
const smi_elements_kind: Smi = convert<Smi>(convert<int32>(elementsKind));
TransitionElementsKindWithKind(context, a, smi_elements_kind);
const smiElementsKind: Smi = Convert<Smi>(Convert<int32>(elementsKind));
TransitionElementsKindWithKind(context, a, smiElementsKind);
}
// Make sure that the length hasn't been changed by side-effect.
const length: Smi = cast<Smi>(a.length) otherwise Bailout;
const length: Smi = Cast<Smi>(a.length) otherwise Bailout;
if (originalLength != length) goto Bailout;
const deletedResult: JSArray =
@ -343,8 +343,8 @@ module array {
// 0);
// else let actualStart be min(relativeStart, len).
const actualStart: Number = relativeStart < 0 ?
max((len + relativeStart), 0) :
min(relativeStart, len);
Max((len + relativeStart), 0) :
Min(relativeStart, len);
let insertCount: Smi;
let actualDeleteCount: Number;
@ -363,18 +363,18 @@ module array {
// 7. Else,
} else {
// a. Let insertCount be the Number of actual arguments minus 2.
insertCount = convert<Smi>(arguments.length) - 2;
insertCount = Convert<Smi>(arguments.length) - 2;
// b. Let dc be ? ToInteger(deleteCount).
const deleteCount: Object = arguments[1];
const dc: Number = ToInteger_Inline(context, deleteCount);
// c. Let actualDeleteCount be min(max(dc, 0), len - actualStart).
actualDeleteCount = min(max(dc, 0), len - actualStart);
actualDeleteCount = Min(Max(dc, 0), len - actualStart);
}
// 8. If len + insertCount - actualDeleteCount > 2^53-1, throw a
// Bailout exception.
const new_length: Number = len + insertCount - actualDeleteCount;
if (new_length > kMaxSafeInteger) {
const newLength: Number = len + insertCount - actualDeleteCount;
if (newLength > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength, start);
}

View File

@ -9,7 +9,7 @@ module array {
context: Context, receiver: Object, arguments: constexpr Arguments): never
labels Slow {
EnsureFastJSArray(context, receiver) otherwise Slow;
const array: JSArray = unsafe_cast<JSArray>(receiver);
const array: JSArray = UnsafeCast<JSArray>(receiver);
EnsureWriteableFastElements(array);
const map: Map = array.map;
@ -18,7 +18,7 @@ module array {
tail ArrayUnshift(
context, LoadTargetFromFrame(), Undefined,
convert<int32>(arguments.length));
Convert<int32>(arguments.length));
}
macro GenericArrayUnshift(
@ -31,12 +31,12 @@ module array {
const length: Number = GetLengthProperty(context, object);
// 3. Let argCount be the number of actual arguments.
const arg_count: Smi = convert<Smi>(arguments.length);
const argCount: Smi = Convert<Smi>(arguments.length);
// 4. If argCount > 0, then.
if (arg_count > 0) {
if (argCount > 0) {
// a. If len + argCount > 2**53 - 1, throw a TypeError exception.
if (length + arg_count > kMaxSafeInteger) {
if (length + argCount > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength);
}
@ -49,18 +49,18 @@ module array {
const from: Number = k - 1;
// ii. Let to be ! ToString(k + argCount - 1).
const to: Number = k + arg_count - 1;
const to: Number = k + argCount - 1;
// iii. Let fromPresent be ? HasProperty(O, from).
const from_present: Boolean = HasProperty(context, object, from);
const fromPresent: Boolean = HasProperty(context, object, from);
// iv. If fromPresent is true, then
if (from_present == True) {
if (fromPresent == True) {
// 1. Let fromValue be ? Get(O, from).
const from_value: Object = GetProperty(context, object, from);
const fromValue: Object = GetProperty(context, object, from);
// 2. Perform ? Set(O, to, fromValue, true).
SetProperty(context, object, to, from_value);
SetProperty(context, object, to, fromValue);
} else {
// 1. Perform ? DeletePropertyOrThrow(O, to).
DeleteProperty(context, object, to, kStrict);
@ -76,9 +76,9 @@ module array {
// e. Let items be a List whose elements are, in left to right order,
// the arguments that were passed to this function invocation.
// f. Repeat, while items is not empty
while (j < arg_count) {
while (j < argCount) {
// ii .Perform ? Set(O, ! ToString(j), E, true).
SetProperty(context, object, j, arguments[convert<intptr>(j)]);
SetProperty(context, object, j, arguments[Convert<intptr>(j)]);
// iii. Increase j by 1.
++j;
@ -86,11 +86,11 @@ module array {
}
// 5. Perform ? Set(O, "length", len + argCount, true).
const new_length: Number = length + arg_count;
SetProperty(context, object, kLengthString, new_length);
const newLength: Number = length + argCount;
SetProperty(context, object, kLengthString, newLength);
// 6. Return length + arg_count.
return new_length;
// 6. Return length + argCount.
return newLength;
}
// https://tc39.github.io/ecma262/#sec-array.prototype.unshift

View File

@ -16,7 +16,7 @@ module array {
macro GetLengthProperty(context: Context, o: Object): Number {
if (BranchIfFastJSArray(o, context)) {
const a: JSArray = unsafe_cast<JSArray>(o);
const a: JSArray = UnsafeCast<JSArray>(o);
return a.length_fast;
} else
deferred {
@ -42,7 +42,7 @@ module array {
macro IsJSArray(o: Object): bool {
try {
const array: JSArray = cast<JSArray>(o) otherwise NotArray;
const array: JSArray = Cast<JSArray>(o) otherwise NotArray;
return true;
}
label NotArray {

View File

@ -316,10 +316,10 @@ extern operator '+' macro NumberAdd(Number, Number): Number;
extern operator '-' macro NumberSub(Number, Number): Number;
extern macro NumberMin(Number, Number): Number;
extern macro NumberMax(Number, Number): Number;
macro min(x: Number, y: Number): Number {
macro Min(x: Number, y: Number): Number {
return NumberMin(x, y);
}
macro max(x: Number, y: Number): Number {
macro Max(x: Number, y: Number): Number {
return NumberMax(x, y);
}
@ -355,41 +355,41 @@ extern macro HeapObjectToFixedDoubleArray(HeapObject):
FixedDoubleArray labels CastError;
extern macro TaggedToNumber(Object): Number labels CastError;
macro cast_HeapObject<A : type>(o: HeapObject): A labels CastError;
cast_HeapObject<HeapObject>(o: HeapObject): HeapObject labels CastError {
macro CastHeapObject<A : type>(o: HeapObject): A labels CastError;
CastHeapObject<HeapObject>(o: HeapObject): HeapObject labels CastError {
return o;
}
cast_HeapObject<FixedArray>(o: HeapObject): FixedArray labels CastError {
CastHeapObject<FixedArray>(o: HeapObject): FixedArray labels CastError {
return HeapObjectToFixedArray(o) otherwise CastError;
}
cast_HeapObject<FixedDoubleArray>(o: HeapObject):
CastHeapObject<FixedDoubleArray>(o: HeapObject):
FixedDoubleArray labels CastError {
return HeapObjectToFixedDoubleArray(o) otherwise CastError;
}
cast_HeapObject<JSDataView>(o: HeapObject): JSDataView labels CastError {
CastHeapObject<JSDataView>(o: HeapObject): JSDataView labels CastError {
return HeapObjectToJSDataView(o) otherwise CastError;
}
cast_HeapObject<Callable>(o: HeapObject): Callable labels CastError {
CastHeapObject<Callable>(o: HeapObject): Callable labels CastError {
return HeapObjectToCallable(o) otherwise CastError;
}
cast_HeapObject<JSArray>(o: HeapObject): JSArray labels CastError {
CastHeapObject<JSArray>(o: HeapObject): JSArray labels CastError {
return HeapObjectToJSArray(o) otherwise CastError;
}
macro cast<A : type>(o: HeapObject): A labels CastError {
return cast_HeapObject<A>(o) otherwise CastError;
macro Cast<A : type>(o: HeapObject): A labels CastError {
return CastHeapObject<A>(o) otherwise CastError;
}
// cast_HeapObject allows this default-implementation to be non-recursive.
// CastHeapObject 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)
macro Cast<A : type>(o: Object): A labels CastError {
return CastHeapObject<A>(TaggedToHeapObject(o) otherwise CastError)
otherwise CastError;
}
cast<Smi>(o: Object): Smi labels CastError {
Cast<Smi>(o: Object): Smi labels CastError {
return TaggedToSmi(o) otherwise CastError;
}
cast<Number>(o: Object): Number labels CastError {
Cast<Number>(o: Object): Number labels CastError {
return TaggedToNumber(o) otherwise CastError;
}
@ -428,137 +428,137 @@ extern macro StringConstant(constexpr string): String;
extern macro LanguageModeConstant(constexpr LanguageMode): LanguageMode;
extern macro Int32Constant(constexpr ElementsKind): ElementsKind;
macro from_constexpr<A : type>(o: constexpr int31): A;
from_constexpr<intptr>(i: constexpr int31): intptr {
macro FromConstexpr<A : type>(o: constexpr int31): A;
FromConstexpr<intptr>(i: constexpr int31): intptr {
return IntPtrConstant(i);
}
from_constexpr<int31>(i: constexpr int31): int31 {
FromConstexpr<int31>(i: constexpr int31): int31 {
return Int32Constant(i);
}
from_constexpr<int32>(i: constexpr int31): int32 {
FromConstexpr<int32>(i: constexpr int31): int32 {
return Int32Constant(i);
}
from_constexpr<uint32>(i: constexpr int31): uint32 {
FromConstexpr<uint32>(i: constexpr int31): uint32 {
return Unsigned(Int32Constant(i));
}
from_constexpr<uintptr>(i: constexpr int31): uintptr {
FromConstexpr<uintptr>(i: constexpr int31): uintptr {
return ChangeUint32ToWord(i);
}
from_constexpr<Smi>(i: constexpr int31): Smi {
FromConstexpr<Smi>(i: constexpr int31): Smi {
return SmiConstant(i);
}
from_constexpr<Number>(i: constexpr int31): Number {
FromConstexpr<Number>(i: constexpr int31): Number {
return SmiConstant(i);
}
from_constexpr<float64>(i: constexpr int31): float64 {
FromConstexpr<float64>(i: constexpr int31): float64 {
return Float64Constant(i);
}
macro from_constexpr<A : type>(o: constexpr int32): A;
from_constexpr<intptr>(i: constexpr int32): intptr {
macro FromConstexpr<A : type>(o: constexpr int32): A;
FromConstexpr<intptr>(i: constexpr int32): intptr {
return IntPtrConstant(i);
}
from_constexpr<int32>(i: constexpr int32): int32 {
FromConstexpr<int32>(i: constexpr int32): int32 {
return Int32Constant(i);
}
from_constexpr<Number>(i: constexpr int32): Number {
FromConstexpr<Number>(i: constexpr int32): Number {
return NumberConstant(i);
}
macro from_constexpr<A : type>(o: constexpr float64): A;
from_constexpr<Number>(f: constexpr float64): Number {
macro FromConstexpr<A : type>(o: constexpr float64): A;
FromConstexpr<Number>(f: constexpr float64): Number {
return NumberConstant(f);
}
macro from_constexpr<A : type>(b: constexpr bool): A;
from_constexpr<bool>(b: constexpr bool): bool {
macro FromConstexpr<A : type>(b: constexpr bool): A;
FromConstexpr<bool>(b: constexpr bool): bool {
return BoolConstant(b);
}
macro from_constexpr<A : type>(l: constexpr LanguageMode): A;
from_constexpr<LanguageMode>(b: constexpr LanguageMode): LanguageMode {
macro FromConstexpr<A : type>(l: constexpr LanguageMode): A;
FromConstexpr<LanguageMode>(b: constexpr LanguageMode): LanguageMode {
return LanguageModeConstant(b);
}
macro from_constexpr<A : type>(e: constexpr ElementsKind): A;
from_constexpr<ElementsKind>(e: constexpr ElementsKind): ElementsKind {
macro FromConstexpr<A : type>(e: constexpr ElementsKind): A;
FromConstexpr<ElementsKind>(e: constexpr ElementsKind): ElementsKind {
return Int32Constant(e);
}
macro from_constexpr<A : type>(s: constexpr string): A;
from_constexpr<String>(s: constexpr string): String {
macro FromConstexpr<A : type>(s: constexpr string): A;
FromConstexpr<String>(s: constexpr string): String {
return StringConstant(s);
}
from_constexpr<Object>(s: constexpr string): Object {
FromConstexpr<Object>(s: constexpr string): Object {
return StringConstant(s);
}
macro convert<A : type>(i: constexpr int31): A {
macro Convert<A : type>(i: constexpr int31): A {
return i;
}
extern macro ConvertElementsKindToInt(ElementsKind): int32;
macro convert<A : type>(elements_kind: ElementsKind): A;
convert<int32>(elements_kind: ElementsKind): int32 {
return ConvertElementsKindToInt(elements_kind);
macro Convert<A : type>(elementsKind: ElementsKind): A;
Convert<int32>(elementsKind: ElementsKind): int32 {
return ConvertElementsKindToInt(elementsKind);
}
macro convert<A : type>(i: int32): A;
convert<Number>(i: int32): Number {
macro Convert<A : type>(i: int32): A;
Convert<Number>(i: int32): Number {
return ChangeInt32ToTagged(i);
}
convert<intptr>(i: int32): intptr {
Convert<intptr>(i: int32): intptr {
return ChangeInt32ToIntPtr(i);
}
convert<Smi>(i: int32): Smi {
Convert<Smi>(i: int32): Smi {
return SmiFromInt32(i);
}
macro convert<A : type>(ui: uint32): A;
convert<Number>(ui: uint32): Number {
macro Convert<A : type>(ui: uint32): A;
Convert<Number>(ui: uint32): Number {
return ChangeUint32ToTagged(ui);
}
convert<Smi>(ui: uint32): Smi {
Convert<Smi>(ui: uint32): Smi {
return SmiFromInt32(Signed(ui));
}
convert<uintptr>(ui: uint32): uintptr {
Convert<uintptr>(ui: uint32): uintptr {
return ChangeUint32ToWord(ui);
}
macro convert<A : type>(i: intptr): A;
convert<int32>(i: intptr): int32 {
macro Convert<A : type>(i: intptr): A;
Convert<int32>(i: intptr): int32 {
return TruncateIntPtrToInt32(i);
}
convert<Smi>(i: intptr): Smi {
Convert<Smi>(i: intptr): Smi {
return SmiTag(i);
}
macro convert<A : type>(ui: uintptr): A;
convert<uint32>(ui: uintptr): uint32 {
macro Convert<A : type>(ui: uintptr): A;
Convert<uint32>(ui: uintptr): uint32 {
return Unsigned(TruncateIntPtrToInt32(Signed(ui)));
}
macro convert<A : type>(s: Smi): A;
convert<intptr>(s: Smi): intptr {
macro Convert<A : type>(s: Smi): A;
Convert<intptr>(s: Smi): intptr {
return SmiUntag(s);
}
convert<int32>(s: Smi): int32 {
Convert<int32>(s: Smi): int32 {
return SmiToInt32(s);
}
macro convert<A : type>(h: HeapNumber): A;
convert<float64>(h: HeapNumber): float64 {
macro Convert<A : type>(h: HeapNumber): A;
Convert<float64>(h: HeapNumber): float64 {
return LoadHeapNumberValue(h);
}
macro convert<A : type>(n: Number): A;
convert<float64>(n: Number): float64 {
macro Convert<A : type>(n: Number): A;
Convert<float64>(n: Number): float64 {
return ChangeNumberToFloat64(n);
}
macro convert<A : type>(f: float32): A;
convert<float64>(f: float32): float64 {
macro Convert<A : type>(f: float32): A;
Convert<float64>(f: float32): float64 {
return ChangeFloat32ToFloat64(f);
}
macro convert<A : type>(d: float64): A;
convert<Number>(d: float64): Number {
macro Convert<A : type>(d: float64): A;
Convert<Number>(d: float64): Number {
return AllocateHeapNumberWithValue(d);
}
convert<uintptr>(d: float64): uintptr {
Convert<uintptr>(d: float64): uintptr {
return ChangeFloat64ToUintPtr(d);
}
macro convert<A : type>(r: RawPtr): A;
convert<uintptr>(r: RawPtr): uintptr {
macro Convert<A : type>(r: RawPtr): A;
Convert<uintptr>(r: RawPtr): uintptr {
return Unsigned(r);
}
convert<intptr>(r: RawPtr): intptr {
Convert<intptr>(r: RawPtr): intptr {
return Signed(r);
}
@ -578,60 +578,60 @@ extern macro UnsafeCastObjectToJSReceiver(Object): JSReceiver;
extern macro UnsafeCastObjectToJSObject(Object): JSObject;
extern macro UnsafeCastObjectToMap(Object): Map;
macro unsafe_cast<A : type>(n: Number): A;
unsafe_cast<HeapNumber>(n: Number): HeapNumber {
macro UnsafeCast<A : type>(n: Number): A;
UnsafeCast<HeapNumber>(n: Number): HeapNumber {
return UnsafeCastNumberToHeapNumber(n);
}
macro unsafe_cast<A : type>(o: Object): A;
unsafe_cast<Object>(o: Object): Object {
macro UnsafeCast<A : type>(o: Object): A;
UnsafeCast<Object>(o: Object): Object {
return o;
}
unsafe_cast<FixedArray>(o: Object): FixedArray {
UnsafeCast<FixedArray>(o: Object): FixedArray {
return UnsafeCastObjectToFixedArray(o);
}
unsafe_cast<FixedDoubleArray>(o: Object): FixedDoubleArray {
UnsafeCast<FixedDoubleArray>(o: Object): FixedDoubleArray {
return UnsafeCastObjectToFixedDoubleArray(o);
}
unsafe_cast<HeapNumber>(o: Object): HeapNumber {
UnsafeCast<HeapNumber>(o: Object): HeapNumber {
return UnsafeCastObjectToHeapNumber(o);
}
unsafe_cast<Callable>(o: Object): Callable {
UnsafeCast<Callable>(o: Object): Callable {
return UnsafeCastObjectToCallable(o);
}
unsafe_cast<Smi>(o: Object): Smi {
UnsafeCast<Smi>(o: Object): Smi {
return UnsafeCastObjectToSmi(o);
}
unsafe_cast<Number>(o: Object): Number {
UnsafeCast<Number>(o: Object): Number {
return UnsafeCastObjectToNumber(o);
}
unsafe_cast<HeapObject>(o: Object): HeapObject {
UnsafeCast<HeapObject>(o: Object): HeapObject {
return UnsafeCastObjectToHeapObject(o);
}
unsafe_cast<JSArray>(o: Object): JSArray {
UnsafeCast<JSArray>(o: Object): JSArray {
return UnsafeCastObjectToJSArray(o);
}
unsafe_cast<FixedTypedArrayBase>(o: Object): FixedTypedArrayBase {
UnsafeCast<FixedTypedArrayBase>(o: Object): FixedTypedArrayBase {
return UnsafeCastObjectToFixedTypedArrayBase(o);
}
unsafe_cast<NumberDictionary>(o: Object): NumberDictionary {
UnsafeCast<NumberDictionary>(o: Object): NumberDictionary {
return UnsafeCastObjectToNumberDictionary(o);
}
unsafe_cast<JSReceiver>(o: Object): JSReceiver {
UnsafeCast<JSReceiver>(o: Object): JSReceiver {
return UnsafeCastObjectToJSReceiver(o);
}
unsafe_cast<JSObject>(o: Object): JSObject {
UnsafeCast<JSObject>(o: Object): JSObject {
return UnsafeCastObjectToJSObject(o);
}
unsafe_cast<Map>(o: Object): Map {
UnsafeCast<Map>(o: Object): Map {
return UnsafeCastObjectToMap(o);
}
unsafe_cast<FixedArrayBase>(o: Object): FixedArrayBase {
UnsafeCast<FixedArrayBase>(o: Object): FixedArrayBase {
return UnsafeCastObjectToFixedArrayBase(o);
}
const kCOWMap: Map = unsafe_cast<Map>(LoadRoot(kFixedCOWArrayMapRootIndex));
const kCOWMap: Map = UnsafeCast<Map>(LoadRoot(kFixedCOWArrayMapRootIndex));
const kEmptyFixedArray: FixedArrayBase =
unsafe_cast<FixedArrayBase>(LoadRoot(kEmptyFixedArrayRootIndex));
UnsafeCast<FixedArrayBase>(LoadRoot(kEmptyFixedArrayRootIndex));
extern macro BranchIfFastJSArray(Object, Context): never labels Taken, NotTaken;
extern macro BranchIfNotFastJSArray(Object, Context): never labels Taken,
@ -677,7 +677,7 @@ extern operator
'[]=' macro StoreFixedArrayElementSmi(FixedArray, Smi, Object): void;
operator '[]=' macro StoreFixedDoubleArrayNumber(
a: FixedDoubleArray, index: Smi, value: Number): void {
a[index] = convert<float64>(value);
a[index] = Convert<float64>(value);
}
extern macro StoreFixedArrayElementSmi(
@ -775,7 +775,7 @@ LoadElementNoHole<FixedArray>(a: JSArray, index: Smi): Object
labels IfHole {
try {
let elements: FixedArray =
cast<FixedArray>(a.elements) otherwise Unexpected;
Cast<FixedArray>(a.elements) otherwise Unexpected;
let e: Object = elements[index];
if (e == Hole) {
goto IfHole;
@ -791,7 +791,7 @@ LoadElementNoHole<FixedDoubleArray>(a: JSArray, index: Smi): Object
labels IfHole {
try {
let elements: FixedDoubleArray =
cast<FixedDoubleArray>(a.elements) otherwise Unexpected;
Cast<FixedDoubleArray>(a.elements) otherwise Unexpected;
let e: float64 = LoadDoubleWithHoleCheck(elements, index) otherwise IfHole;
return AllocateHeapNumberWithValue(e);
}
@ -823,7 +823,7 @@ macro NumberIsNaN(number: Number): bool {
case (Smi) {
return false;
} case (hn : HeapNumber) {
let value: float64 = convert<float64>(hn);
let value: float64 = Convert<float64>(hn);
return value != value;
}
}

View File

@ -72,7 +72,7 @@ module data_view {
macro ValidateDataView(context: Context,
o: Object, method: String): JSDataView {
try {
return cast<JSDataView>(o) otherwise CastError;
return Cast<JSDataView>(o) otherwise CastError;
}
label CastError {
ThrowTypeError(context, kIncompatibleMethodReceiver, method);
@ -82,35 +82,35 @@ module data_view {
// ES6 section 24.2.4.1 get DataView.prototype.buffer
javascript builtin DataViewPrototypeGetBuffer(
context: Context, receiver: Object, ...arguments): JSArrayBuffer {
let data_view: JSDataView = ValidateDataView(
let dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.buffer');
return data_view.buffer;
return dataView.buffer;
}
// ES6 section 24.2.4.2 get DataView.prototype.byteLength
javascript builtin DataViewPrototypeGetByteLength(
context: Context, receiver: Object, ...arguments): Number {
let data_view: JSDataView = ValidateDataView(
let dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_length');
if (WasNeutered(data_view)) {
if (WasNeutered(dataView)) {
// TODO(bmeurer): According to the ES6 spec, we should throw a TypeError
// here if the JSArrayBuffer of the {data_view} was neutered.
// here if the JSArrayBuffer of the {dataView} was neutered.
return 0;
}
return data_view.byte_length;
return dataView.byte_length;
}
// ES6 section 24.2.4.3 get DataView.prototype.byteOffset
javascript builtin DataViewPrototypeGetByteOffset(
context: Context, receiver: Object, ...arguments): Number {
let data_view: JSDataView = ValidateDataView(
let dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_offset');
if (WasNeutered(data_view)) {
if (WasNeutered(dataView)) {
// TODO(bmeurer): According to the ES6 spec, we should throw a TypeError
// here if the JSArrayBuffer of the {data_view} was neutered.
// here if the JSArrayBuffer of the {dataView} was neutered.
return 0;
}
return data_view.byte_offset;
return dataView.byte_offset;
}
extern macro BitcastInt32ToFloat32(uint32): float32;
@ -126,96 +126,96 @@ module data_view {
macro LoadDataView8(buffer: JSArrayBuffer, offset: intptr,
signed: constexpr bool): Smi {
if constexpr (signed) {
return convert<Smi>(LoadInt8(buffer.backing_store, offset));
return Convert<Smi>(LoadInt8(buffer.backing_store, offset));
} else {
return convert<Smi>(LoadUint8(buffer.backing_store, offset));
return Convert<Smi>(LoadUint8(buffer.backing_store, offset));
}
}
macro LoadDataView16(buffer: JSArrayBuffer, offset: intptr,
requested_little_endian: bool,
requestedLittleEndian: bool,
signed: constexpr bool): Number {
let data_pointer: RawPtr = buffer.backing_store;
let dataPointer: RawPtr = buffer.backing_store;
let b0: int32;
let b1: int32;
let result: int32;
// Sign-extend the most significant byte by loading it as an Int8.
if (requested_little_endian) {
b0 = Signed(LoadUint8(data_pointer, offset));
b1 = LoadInt8(data_pointer, offset + 1);
if (requestedLittleEndian) {
b0 = Signed(LoadUint8(dataPointer, offset));
b1 = LoadInt8(dataPointer, offset + 1);
result = (b1 << 8) + b0;
} else {
b0 = LoadInt8(data_pointer, offset);
b1 = Signed(LoadUint8(data_pointer, offset + 1));
b0 = LoadInt8(dataPointer, offset);
b1 = Signed(LoadUint8(dataPointer, offset + 1));
result = (b0 << 8) + b1;
}
if constexpr (signed) {
return convert<Smi>(result);
return Convert<Smi>(result);
} else {
// Bit-mask the higher bits to prevent sign extension if we're unsigned.
return convert<Smi>(result & 0xFFFF);
return Convert<Smi>(result & 0xFFFF);
}
}
macro LoadDataView32(buffer: JSArrayBuffer, offset: intptr,
requested_little_endian: bool,
requestedLittleEndian: bool,
kind: constexpr ElementsKind): Number {
let data_pointer: RawPtr = buffer.backing_store;
let dataPointer: RawPtr = buffer.backing_store;
let b0: uint32 = LoadUint8(data_pointer, offset);
let b1: uint32 = LoadUint8(data_pointer, offset + 1);
let b2: uint32 = LoadUint8(data_pointer, offset + 2);
let b3: uint32 = LoadUint8(data_pointer, offset + 3);
let b0: uint32 = LoadUint8(dataPointer, offset);
let b1: uint32 = LoadUint8(dataPointer, offset + 1);
let b2: uint32 = LoadUint8(dataPointer, offset + 2);
let b3: uint32 = LoadUint8(dataPointer, offset + 3);
let result: uint32;
if (requested_little_endian) {
if (requestedLittleEndian) {
result = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
} else {
result = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
}
if constexpr (kind == INT32_ELEMENTS) {
return convert<Number>(Signed(result));
return Convert<Number>(Signed(result));
} else if constexpr (kind == UINT32_ELEMENTS) {
return convert<Number>(result);
return Convert<Number>(result);
} else if constexpr (kind == FLOAT32_ELEMENTS) {
let float_res: float64 = convert<float64>(BitcastInt32ToFloat32(result));
return convert<Number>(float_res);
let floatRes: float64 = Convert<float64>(BitcastInt32ToFloat32(result));
return Convert<Number>(floatRes);
} else {
unreachable;
}
}
macro LoadDataViewFloat64(buffer: JSArrayBuffer, offset: intptr,
requested_little_endian: bool): Number {
let data_pointer: RawPtr = buffer.backing_store;
requestedLittleEndian: bool): Number {
let dataPointer: RawPtr = buffer.backing_store;
let b0: uint32 = LoadUint8(data_pointer, offset);
let b1: uint32 = LoadUint8(data_pointer, offset + 1);
let b2: uint32 = LoadUint8(data_pointer, offset + 2);
let b3: uint32 = LoadUint8(data_pointer, offset + 3);
let b4: uint32 = LoadUint8(data_pointer, offset + 4);
let b5: uint32 = LoadUint8(data_pointer, offset + 5);
let b6: uint32 = LoadUint8(data_pointer, offset + 6);
let b7: uint32 = LoadUint8(data_pointer, offset + 7);
let low_word: uint32;
let high_word: uint32;
let b0: uint32 = LoadUint8(dataPointer, offset);
let b1: uint32 = LoadUint8(dataPointer, offset + 1);
let b2: uint32 = LoadUint8(dataPointer, offset + 2);
let b3: uint32 = LoadUint8(dataPointer, offset + 3);
let b4: uint32 = LoadUint8(dataPointer, offset + 4);
let b5: uint32 = LoadUint8(dataPointer, offset + 5);
let b6: uint32 = LoadUint8(dataPointer, offset + 6);
let b7: uint32 = LoadUint8(dataPointer, offset + 7);
let lowWord: uint32;
let highWord: uint32;
if (requested_little_endian) {
low_word = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
high_word = (b7 << 24) | (b6 << 16) | (b5 << 8) | b4;
if (requestedLittleEndian) {
lowWord = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
highWord = (b7 << 24) | (b6 << 16) | (b5 << 8) | b4;
} else {
high_word = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
low_word = (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
highWord = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
lowWord = (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
}
let result: float64 = 0;
result = Float64InsertLowWord32(result, low_word);
result = Float64InsertHighWord32(result, high_word);
result = Float64InsertLowWord32(result, lowWord);
result = Float64InsertHighWord32(result, highWord);
return convert<Number>(result);
return Convert<Number>(result);
}
extern macro AllocateBigInt(intptr): BigInt;
@ -230,12 +230,12 @@ module data_view {
const kOneDigitBigInt: constexpr int31 = 1;
const kTwoDigitBigInt: constexpr int31 = 2;
macro CreateEmptyBigInt(is_positive: bool, length: constexpr int31): BigInt {
macro CreateEmptyBigInt(isPositive: bool, length: constexpr int31): BigInt {
// Allocate a BigInt with the desired length (number of digits).
let result: BigInt = AllocateBigInt(length);
// Write the desired sign and length to the BigInt bitfield.
if (is_positive) {
if (isPositive) {
StoreBigIntBitfield(result,
DataViewEncodeBigIntBits(kPositiveBigInt, length));
} else {
@ -247,143 +247,143 @@ module data_view {
}
// Create a BigInt on a 64-bit architecture from two 32-bit values.
macro MakeBigIntOn64Bit(low_word: uint32, high_word: uint32,
macro MakeBigIntOn64Bit(lowWord: uint32, highWord: uint32,
signed: constexpr bool): BigInt {
// 0n is represented by a zero-length BigInt.
if (low_word == 0 && high_word == 0) {
if (lowWord == 0 && highWord == 0) {
return AllocateBigInt(kZeroDigitBigInt);
}
let is_positive: bool = true;
let high_part: intptr = Signed(convert<uintptr>(high_word));
let low_part: intptr = Signed(convert<uintptr>(low_word));
let raw_value: intptr = (high_part << 32) + low_part;
let isPositive: bool = true;
let highPart: intptr = Signed(Convert<uintptr>(highWord));
let lowPart: intptr = Signed(Convert<uintptr>(lowWord));
let rawValue: intptr = (highPart << 32) + lowPart;
if constexpr (signed) {
if (raw_value < 0) {
is_positive = false;
// We have to store the absolute value of raw_value in the digit.
raw_value = 0 - raw_value;
if (rawValue < 0) {
isPositive = false;
// We have to store the absolute value of rawValue in the digit.
rawValue = 0 - rawValue;
}
}
// Allocate the BigInt and store the absolute value.
let result: BigInt = CreateEmptyBigInt(is_positive, kOneDigitBigInt);
let result: BigInt = CreateEmptyBigInt(isPositive, kOneDigitBigInt);
StoreBigIntDigit(result, 0, Unsigned(raw_value));
StoreBigIntDigit(result, 0, Unsigned(rawValue));
return result;
}
// Create a BigInt on a 32-bit architecture from two 32-bit values.
macro MakeBigIntOn32Bit(low_word: uint32, high_word: uint32,
macro MakeBigIntOn32Bit(lowWord: uint32, highWord: uint32,
signed: constexpr bool): BigInt {
// 0n is represented by a zero-length BigInt.
if (low_word == 0 && high_word == 0) {
if (lowWord == 0 && highWord == 0) {
return AllocateBigInt(kZeroDigitBigInt);
}
// On a 32-bit platform, we might need 1 or 2 digits to store the number.
let need_two_digits: bool = false;
let is_positive: bool = true;
let needTwoDigits: bool = false;
let isPositive: bool = true;
// We need to do some math on low_word and high_word,
// so convert them to int32.
let low_part: int32 = Signed(low_word);
let high_part: int32 = Signed(high_word);
// We need to do some math on lowWord and highWord,
// so Convert them to int32.
let lowPart: int32 = Signed(lowWord);
let highPart: int32 = Signed(highWord);
// If high_word == 0, the number is positive, and we only need 1 digit,
// If highWord == 0, the number is positive, and we only need 1 digit,
// so we don't have anything to do.
// Otherwise, all cases are possible.
if (high_word != 0) {
if (highWord != 0) {
if constexpr (signed) {
// If high_part < 0, the number is always negative.
if (high_part < 0) {
is_positive = false;
// If highPart < 0, the number is always negative.
if (highPart < 0) {
isPositive = false;
// We have to compute the absolute value by hand.
// There will be a negative carry from the low word
// to the high word iff low != 0.
high_part = 0 - high_part;
if (low_part != 0) {
high_part = high_part - 1;
highPart = 0 - highPart;
if (lowPart != 0) {
highPart = highPart - 1;
}
low_part = 0 - low_part;
lowPart = 0 - lowPart;
// Here, high_part could be 0 again so we might have 1 or 2 digits.
if (high_part != 0) {
need_two_digits = true;
// Here, highPart could be 0 again so we might have 1 or 2 digits.
if (highPart != 0) {
needTwoDigits = true;
}
} else {
// In this case, the number is positive, and we need 2 digits.
need_two_digits = true;
needTwoDigits = true;
}
} else {
// In this case, the number is positive (unsigned),
// and we need 2 digits.
need_two_digits = true;
needTwoDigits = true;
}
}
// Allocate the BigInt with the right sign and length.
let result: BigInt;
if (need_two_digits) {
result = CreateEmptyBigInt(is_positive, kTwoDigitBigInt);
if (needTwoDigits) {
result = CreateEmptyBigInt(isPositive, kTwoDigitBigInt);
} else {
result = CreateEmptyBigInt(is_positive, kOneDigitBigInt);
result = CreateEmptyBigInt(isPositive, kOneDigitBigInt);
}
// Finally, write the digit(s) to the BigInt.
StoreBigIntDigit(result, 0, Unsigned(convert<intptr>(low_part)));
StoreBigIntDigit(result, 0, Unsigned(Convert<intptr>(lowPart)));
if (need_two_digits) {
StoreBigIntDigit(result, 1, Unsigned(convert<intptr>(high_part)));
if (needTwoDigits) {
StoreBigIntDigit(result, 1, Unsigned(Convert<intptr>(highPart)));
}
return result;
}
macro MakeBigInt(low_word: uint32, high_word: uint32,
macro MakeBigInt(lowWord: uint32, highWord: uint32,
signed: constexpr bool): BigInt {
// A BigInt digit has the platform word size, so we only need one digit
// on 64-bit platforms but may need two on 32-bit.
if constexpr (Is64()) {
return MakeBigIntOn64Bit(low_word, high_word, signed);
return MakeBigIntOn64Bit(lowWord, highWord, signed);
} else {
return MakeBigIntOn32Bit(low_word, high_word, signed);
return MakeBigIntOn32Bit(lowWord, highWord, signed);
}
}
macro LoadDataViewBigInt(buffer: JSArrayBuffer, offset: intptr,
requested_little_endian: bool,
requestedLittleEndian: bool,
signed: constexpr bool): BigInt {
let data_pointer: RawPtr = buffer.backing_store;
let dataPointer: RawPtr = buffer.backing_store;
let b0: uint32 = LoadUint8(data_pointer, offset);
let b1: uint32 = LoadUint8(data_pointer, offset + 1);
let b2: uint32 = LoadUint8(data_pointer, offset + 2);
let b3: uint32 = LoadUint8(data_pointer, offset + 3);
let b4: uint32 = LoadUint8(data_pointer, offset + 4);
let b5: uint32 = LoadUint8(data_pointer, offset + 5);
let b6: uint32 = LoadUint8(data_pointer, offset + 6);
let b7: uint32 = LoadUint8(data_pointer, offset + 7);
let low_word: uint32;
let high_word: uint32;
let b0: uint32 = LoadUint8(dataPointer, offset);
let b1: uint32 = LoadUint8(dataPointer, offset + 1);
let b2: uint32 = LoadUint8(dataPointer, offset + 2);
let b3: uint32 = LoadUint8(dataPointer, offset + 3);
let b4: uint32 = LoadUint8(dataPointer, offset + 4);
let b5: uint32 = LoadUint8(dataPointer, offset + 5);
let b6: uint32 = LoadUint8(dataPointer, offset + 6);
let b7: uint32 = LoadUint8(dataPointer, offset + 7);
let lowWord: uint32;
let highWord: uint32;
if (requested_little_endian) {
low_word = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
high_word = (b7 << 24) | (b6 << 16) | (b5 << 8) | b4;
if (requestedLittleEndian) {
lowWord = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
highWord = (b7 << 24) | (b6 << 16) | (b5 << 8) | b4;
} else {
high_word = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
low_word = (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
highWord = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
lowWord = (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
}
return MakeBigInt(low_word, high_word, signed);
return MakeBigInt(lowWord, highWord, signed);
}
extern macro ToSmiIndex(Object, Context): Smi labels RangeError;
@ -392,10 +392,10 @@ module data_view {
macro DataViewGet(context: Context,
receiver: Object,
offset: Object,
requested_little_endian: Object,
requestedLittleEndian: Object,
kind: constexpr ElementsKind): Numeric {
let data_view: JSDataView = ValidateDataView(
let dataView: JSDataView = ValidateDataView(
context, receiver, MakeDataViewGetterNameString(kind));
let getIndex: Number;
@ -406,26 +406,26 @@ module data_view {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
}
let littleEndian: bool = ToBoolean(requested_little_endian);
let buffer: JSArrayBuffer = data_view.buffer;
let littleEndian: bool = ToBoolean(requestedLittleEndian);
let buffer: JSArrayBuffer = dataView.buffer;
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(context, kDetachedOperation,
MakeDataViewGetterNameString(kind));
}
let viewOffset: Number = data_view.byte_offset;
let viewSize: Number = data_view.byte_length;
let viewOffset: Number = dataView.byte_offset;
let viewSize: Number = dataView.byte_length;
let elementSize: Number = DataViewElementSize(kind);
if (getIndex + elementSize > viewSize) {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
}
let getIndexFloat: float64 = convert<float64>(getIndex);
let getIndexIntptr: intptr = Signed(convert<uintptr>(getIndexFloat));
let viewOffsetFloat: float64 = convert<float64>(viewOffset);
let viewOffsetIntptr: intptr = Signed(convert<uintptr>(viewOffsetFloat));
let getIndexFloat: float64 = Convert<float64>(getIndex);
let getIndexIntptr: intptr = Signed(Convert<uintptr>(getIndexFloat));
let viewOffsetFloat: float64 = Convert<float64>(viewOffset);
let viewOffsetIntptr: intptr = Signed(Convert<uintptr>(viewOffsetFloat));
let bufferIndex: intptr = getIndexIntptr + viewOffsetIntptr;
@ -475,10 +475,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
UINT16_ELEMENTS);
}
@ -487,10 +487,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
INT16_ELEMENTS);
}
@ -499,10 +499,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
UINT32_ELEMENTS);
}
@ -511,10 +511,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
INT32_ELEMENTS);
}
@ -523,10 +523,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
FLOAT32_ELEMENTS);
}
@ -535,10 +535,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
FLOAT64_ELEMENTS);
}
@ -547,10 +547,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
BIGUINT64_ELEMENTS);
}
@ -559,10 +559,10 @@ module data_view {
let offset: Object = arguments.length > 0 ?
arguments[0] :
Undefined;
let is_little_endian : Object = arguments.length > 1 ?
let isLittleEndian : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
return DataViewGet(context, receiver, offset, is_little_endian,
return DataViewGet(context, receiver, offset, isLittleEndian,
BIGINT64_ELEMENTS);
}
@ -579,77 +579,77 @@ module data_view {
}
macro StoreDataView16(buffer: JSArrayBuffer, offset: intptr, value: uint32,
requested_little_endian: bool) {
let data_pointer: RawPtr = buffer.backing_store;
requestedLittleEndian: bool) {
let dataPointer: RawPtr = buffer.backing_store;
let b0: uint32 = value & 0xFF;
let b1: uint32 = (value >>> 8) & 0xFF;
if (requested_little_endian) {
StoreWord8(data_pointer, offset, b0);
StoreWord8(data_pointer, offset + 1, b1);
if (requestedLittleEndian) {
StoreWord8(dataPointer, offset, b0);
StoreWord8(dataPointer, offset + 1, b1);
} else {
StoreWord8(data_pointer, offset, b1);
StoreWord8(data_pointer, offset + 1, b0);
StoreWord8(dataPointer, offset, b1);
StoreWord8(dataPointer, offset + 1, b0);
}
}
macro StoreDataView32(buffer: JSArrayBuffer, offset: intptr, value: uint32,
requested_little_endian: bool) {
let data_pointer: RawPtr = buffer.backing_store;
requestedLittleEndian: bool) {
let dataPointer: RawPtr = buffer.backing_store;
let b0: uint32 = value & 0xFF;
let b1: uint32 = (value >>> 8) & 0xFF;
let b2: uint32 = (value >>> 16) & 0xFF;
let b3: uint32 = value >>> 24; // We don't need to mask here.
if (requested_little_endian) {
StoreWord8(data_pointer, offset, b0);
StoreWord8(data_pointer, offset + 1, b1);
StoreWord8(data_pointer, offset + 2, b2);
StoreWord8(data_pointer, offset + 3, b3);
if (requestedLittleEndian) {
StoreWord8(dataPointer, offset, b0);
StoreWord8(dataPointer, offset + 1, b1);
StoreWord8(dataPointer, offset + 2, b2);
StoreWord8(dataPointer, offset + 3, b3);
} else {
StoreWord8(data_pointer, offset, b3);
StoreWord8(data_pointer, offset + 1, b2);
StoreWord8(data_pointer, offset + 2, b1);
StoreWord8(data_pointer, offset + 3, b0);
StoreWord8(dataPointer, offset, b3);
StoreWord8(dataPointer, offset + 1, b2);
StoreWord8(dataPointer, offset + 2, b1);
StoreWord8(dataPointer, offset + 3, b0);
}
}
macro StoreDataView64(buffer: JSArrayBuffer, offset: intptr,
low_word: uint32, high_word: uint32,
requested_little_endian: bool) {
let data_pointer: RawPtr = buffer.backing_store;
lowWord: uint32, highWord: uint32,
requestedLittleEndian: bool) {
let dataPointer: RawPtr = buffer.backing_store;
let b0: uint32 = low_word & 0xFF;
let b1: uint32 = (low_word >>> 8) & 0xFF;
let b2: uint32 = (low_word >>> 16) & 0xFF;
let b3: uint32 = low_word >>> 24;
let b0: uint32 = lowWord & 0xFF;
let b1: uint32 = (lowWord >>> 8) & 0xFF;
let b2: uint32 = (lowWord >>> 16) & 0xFF;
let b3: uint32 = lowWord >>> 24;
let b4: uint32 = high_word & 0xFF;
let b5: uint32 = (high_word >>> 8) & 0xFF;
let b6: uint32 = (high_word >>> 16) & 0xFF;
let b7: uint32 = high_word >>> 24;
let b4: uint32 = highWord & 0xFF;
let b5: uint32 = (highWord >>> 8) & 0xFF;
let b6: uint32 = (highWord >>> 16) & 0xFF;
let b7: uint32 = highWord >>> 24;
if (requested_little_endian) {
StoreWord8(data_pointer, offset, b0);
StoreWord8(data_pointer, offset + 1, b1);
StoreWord8(data_pointer, offset + 2, b2);
StoreWord8(data_pointer, offset + 3, b3);
StoreWord8(data_pointer, offset + 4, b4);
StoreWord8(data_pointer, offset + 5, b5);
StoreWord8(data_pointer, offset + 6, b6);
StoreWord8(data_pointer, offset + 7, b7);
if (requestedLittleEndian) {
StoreWord8(dataPointer, offset, b0);
StoreWord8(dataPointer, offset + 1, b1);
StoreWord8(dataPointer, offset + 2, b2);
StoreWord8(dataPointer, offset + 3, b3);
StoreWord8(dataPointer, offset + 4, b4);
StoreWord8(dataPointer, offset + 5, b5);
StoreWord8(dataPointer, offset + 6, b6);
StoreWord8(dataPointer, offset + 7, b7);
} else {
StoreWord8(data_pointer, offset, b7);
StoreWord8(data_pointer, offset + 1, b6);
StoreWord8(data_pointer, offset + 2, b5);
StoreWord8(data_pointer, offset + 3, b4);
StoreWord8(data_pointer, offset + 4, b3);
StoreWord8(data_pointer, offset + 5, b2);
StoreWord8(data_pointer, offset + 6, b1);
StoreWord8(data_pointer, offset + 7, b0);
StoreWord8(dataPointer, offset, b7);
StoreWord8(dataPointer, offset + 1, b6);
StoreWord8(dataPointer, offset + 2, b5);
StoreWord8(dataPointer, offset + 3, b4);
StoreWord8(dataPointer, offset + 4, b3);
StoreWord8(dataPointer, offset + 5, b2);
StoreWord8(dataPointer, offset + 6, b1);
StoreWord8(dataPointer, offset + 7, b0);
}
}
@ -661,53 +661,53 @@ module data_view {
// interested in the 64 lowest ones. This means the lowest BigInt digit
// on 64-bit platforms, and the 2 lowest BigInt digits on 32-bit ones.
macro StoreDataViewBigInt(buffer: JSArrayBuffer, offset: intptr,
bigint_value: BigInt,
requested_little_endian: bool) {
bigIntValue: BigInt,
requestedLittleEndian: bool) {
let length: uintptr = DataViewDecodeBigIntLength(bigint_value);
let sign: uintptr = DataViewDecodeBigIntSign(bigint_value);
let length: uintptr = DataViewDecodeBigIntLength(bigIntValue);
let sign: uintptr = DataViewDecodeBigIntSign(bigIntValue);
// The 32-bit words that will hold the BigInt's value in
// two's complement representation.
let low_word: uint32 = 0;
let high_word: uint32 = 0;
let lowWord: uint32 = 0;
let highWord: uint32 = 0;
// The length is nonzero if and only if the BigInt's value is nonzero.
if (length != 0) {
if constexpr (Is64()) {
// There is always exactly 1 BigInt digit to load in this case.
let value: uintptr = LoadBigIntDigit(bigint_value, 0);
low_word = convert<uint32>(value); // Truncates value to 32 bits.
high_word = convert<uint32>(value >>> 32);
let value: uintptr = LoadBigIntDigit(bigIntValue, 0);
lowWord = Convert<uint32>(value); // Truncates value to 32 bits.
highWord = Convert<uint32>(value >>> 32);
}
else { // There might be either 1 or 2 BigInt digits we need to load.
low_word = convert<uint32>(LoadBigIntDigit(bigint_value, 0));
lowWord = Convert<uint32>(LoadBigIntDigit(bigIntValue, 0));
if (length >= 2) { // Only load the second digit if there is one.
high_word = convert<uint32>(LoadBigIntDigit(bigint_value, 1));
highWord = Convert<uint32>(LoadBigIntDigit(bigIntValue, 1));
}
}
}
if (sign != 0) { // The number is negative, convert it.
high_word = Unsigned(0 - Signed(high_word));
if (low_word != 0) {
high_word = Unsigned(Signed(high_word) - 1);
if (sign != 0) { // The number is negative, Convert it.
highWord = Unsigned(0 - Signed(highWord));
if (lowWord != 0) {
highWord = Unsigned(Signed(highWord) - 1);
}
low_word = Unsigned(0 - Signed(low_word));
lowWord = Unsigned(0 - Signed(lowWord));
}
StoreDataView64(buffer, offset, low_word, high_word,
requested_little_endian);
StoreDataView64(buffer, offset, lowWord, highWord,
requestedLittleEndian);
}
macro DataViewSet(context: Context,
receiver: Object,
offset: Object,
value: Object,
requested_little_endian: Object,
requestedLittleEndian: Object,
kind: constexpr ElementsKind): Object {
let data_view: JSDataView = ValidateDataView(
let dataView: JSDataView = ValidateDataView(
context, receiver, MakeDataViewSetterNameString(kind));
let getIndex: Number;
@ -718,17 +718,17 @@ module data_view {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
}
let littleEndian: bool = ToBoolean(requested_little_endian);
let buffer: JSArrayBuffer = data_view.buffer;
let littleEndian: bool = ToBoolean(requestedLittleEndian);
let buffer: JSArrayBuffer = dataView.buffer;
let bigint_value: BigInt;
let num_value: Number;
let bigIntValue: BigInt;
let numValue: Number;
// According to ES6 section 24.2.1.2 SetViewValue, we must perform
// the conversion before doing the bounds check.
if constexpr (kind == BIGUINT64_ELEMENTS || kind == BIGINT64_ELEMENTS) {
bigint_value = ToBigInt(context, value);
bigIntValue = ToBigInt(context, value);
} else {
num_value = ToNumber(context, value);
numValue = ToNumber(context, value);
}
if (IsDetachedBuffer(buffer)) {
@ -736,49 +736,49 @@ module data_view {
MakeDataViewSetterNameString(kind));
}
let viewOffset: Number = data_view.byte_offset;
let viewSize: Number = data_view.byte_length;
let viewOffset: Number = dataView.byte_offset;
let viewSize: Number = dataView.byte_length;
let elementSize: Number = DataViewElementSize(kind);
if (getIndex + elementSize > viewSize) {
ThrowRangeError(context, kInvalidDataViewAccessorOffset);
}
let getIndexFloat: float64 = convert<float64>(getIndex);
let getIndexIntptr: intptr = Signed(convert<uintptr>(getIndexFloat));
let viewOffsetFloat: float64 = convert<float64>(viewOffset);
let viewOffsetIntptr: intptr = Signed(convert<uintptr>(viewOffsetFloat));
let getIndexFloat: float64 = Convert<float64>(getIndex);
let getIndexIntptr: intptr = Signed(Convert<uintptr>(getIndexFloat));
let viewOffsetFloat: float64 = Convert<float64>(viewOffset);
let viewOffsetIntptr: intptr = Signed(Convert<uintptr>(viewOffsetFloat));
let bufferIndex: intptr = getIndexIntptr + viewOffsetIntptr;
if constexpr (kind == BIGUINT64_ELEMENTS || kind == BIGINT64_ELEMENTS) {
StoreDataViewBigInt(buffer, bufferIndex, bigint_value,
StoreDataViewBigInt(buffer, bufferIndex, bigIntValue,
littleEndian);
}
else {
let double_value: float64 = ChangeNumberToFloat64(num_value);
let doubleValue: float64 = ChangeNumberToFloat64(numValue);
if constexpr (kind == UINT8_ELEMENTS || kind == INT8_ELEMENTS) {
StoreDataView8(buffer, bufferIndex,
TruncateFloat64ToWord32(double_value));
TruncateFloat64ToWord32(doubleValue));
}
else if constexpr (kind == UINT16_ELEMENTS || kind == INT16_ELEMENTS) {
StoreDataView16(buffer, bufferIndex,
TruncateFloat64ToWord32(double_value), littleEndian);
TruncateFloat64ToWord32(doubleValue), littleEndian);
}
else if constexpr (kind == UINT32_ELEMENTS || kind == INT32_ELEMENTS) {
StoreDataView32(buffer, bufferIndex,
TruncateFloat64ToWord32(double_value), littleEndian);
TruncateFloat64ToWord32(doubleValue), littleEndian);
}
else if constexpr (kind == FLOAT32_ELEMENTS) {
let float_value: float32 = TruncateFloat64ToFloat32(double_value);
let floatValue: float32 = TruncateFloat64ToFloat32(doubleValue);
StoreDataView32(buffer, bufferIndex,
BitcastFloat32ToInt32(float_value), littleEndian);
BitcastFloat32ToInt32(floatValue), littleEndian);
}
else if constexpr (kind == FLOAT64_ELEMENTS) {
let low_word: uint32 = Float64ExtractLowWord32(double_value);
let high_word: uint32 = Float64ExtractHighWord32(double_value);
StoreDataView64(buffer, bufferIndex, low_word, high_word,
let lowWord: uint32 = Float64ExtractLowWord32(doubleValue);
let highWord: uint32 = Float64ExtractHighWord32(doubleValue);
StoreDataView64(buffer, bufferIndex, lowWord, highWord,
littleEndian);
}
}
@ -817,11 +817,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, UINT16_ELEMENTS);
isLittleEndian, UINT16_ELEMENTS);
}
javascript builtin DataViewPrototypeSetInt16(
@ -832,11 +832,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, INT16_ELEMENTS);
isLittleEndian, INT16_ELEMENTS);
}
javascript builtin DataViewPrototypeSetUint32(
@ -847,11 +847,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, UINT32_ELEMENTS);
isLittleEndian, UINT32_ELEMENTS);
}
javascript builtin DataViewPrototypeSetInt32(
@ -862,11 +862,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, INT32_ELEMENTS);
isLittleEndian, INT32_ELEMENTS);
}
javascript builtin DataViewPrototypeSetFloat32(
@ -877,11 +877,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, FLOAT32_ELEMENTS);
isLittleEndian, FLOAT32_ELEMENTS);
}
javascript builtin DataViewPrototypeSetFloat64(
@ -892,11 +892,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, FLOAT64_ELEMENTS);
isLittleEndian, FLOAT64_ELEMENTS);
}
javascript builtin DataViewPrototypeSetBigUint64(
@ -907,11 +907,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, BIGUINT64_ELEMENTS);
isLittleEndian, BIGUINT64_ELEMENTS);
}
javascript builtin DataViewPrototypeSetBigInt64(
@ -922,11 +922,11 @@ module data_view {
let value : Object = arguments.length > 1 ?
arguments[1] :
Undefined;
let is_little_endian : Object = arguments.length > 2 ?
let isLittleEndian : Object = arguments.length > 2 ?
arguments[2] :
Undefined;
return DataViewSet(context, receiver, offset, value,
is_little_endian, BIGINT64_ELEMENTS);
isLittleEndian, BIGINT64_ELEMENTS);
}
}

View File

@ -61,7 +61,7 @@ module typed_array {
context: Context, array: JSTypedArray, index: Smi,
value: Object): Object {
const elements: FixedTypedArrayBase =
unsafe_cast<FixedTypedArrayBase>(array.elements);
UnsafeCast<FixedTypedArrayBase>(array.elements);
StoreFixedTypedArrayElementFromTagged(
context, elements, index, value, KindForArrayType<T>(), SMI_PARAMETERS);
return Undefined;
@ -86,37 +86,37 @@ module typed_array {
// InsertionSort is used for smaller arrays.
macro TypedArrayInsertionSort(
context: Context, array: JSTypedArray, from_arg: Smi, to_arg: Smi,
comparefn: Callable, Load: LoadFn, Store: StoreFn)
context: Context, array: JSTypedArray, fromArg: Smi, toArg: Smi,
comparefn: Callable, load: LoadFn, store: StoreFn)
labels Detached {
let from: Smi = from_arg;
let to: Smi = to_arg;
let from: Smi = fromArg;
let to: Smi = toArg;
if (IsDetachedBuffer(array.buffer)) goto Detached;
for (let i: Smi = from + 1; i < to; ++i) {
const element: Object = Load(context, array, i);
const element: Object = load(context, array, i);
let j: Smi = i - 1;
for (; j >= from; --j) {
const tmp: Object = Load(context, array, j);
const tmp: Object = load(context, array, j);
const order: Number = CallCompareWithDetachedCheck(
context, array, comparefn, tmp, element) otherwise Detached;
if (order > 0) {
Store(context, array, j + 1, tmp);
store(context, array, j + 1, tmp);
} else {
break;
}
}
Store(context, array, j + 1, element);
store(context, array, j + 1, element);
}
}
macro TypedArrayQuickSortImpl(
context: Context, array: JSTypedArray, from_arg: Smi, to_arg: Smi,
comparefn: Callable, Load: LoadFn, Store: StoreFn)
context: Context, array: JSTypedArray, fromArg: Smi, toArg: Smi,
comparefn: Callable, load: LoadFn, store: StoreFn)
labels Detached {
let from: Smi = from_arg;
let to: Smi = to_arg;
let from: Smi = fromArg;
let to: Smi = toArg;
while (to - from > 1) {
if (to - from <= 10) {
@ -124,21 +124,21 @@ module typed_array {
// Currently it does not make any difference when the
// benchmarks are run locally.
TypedArrayInsertionSort(
context, array, from, to, comparefn, Load, Store)
context, array, from, to, comparefn, load, store)
otherwise Detached;
break;
}
// TODO(szuend): Check if a more involved third_index calculation is
// TODO(szuend): Check if a more involved thirdIndex calculation is
// worth it for very large arrays.
const third_index: Smi = from + ((to - from) >>> 1);
const thirdIndex: Smi = from + ((to - from) >>> 1);
if (IsDetachedBuffer(array.buffer)) goto Detached;
// Find a pivot as the median of first, last and middle element.
let v0: Object = Load(context, array, from);
let v1: Object = Load(context, array, to - 1);
let v2: Object = Load(context, array, third_index);
let v0: Object = load(context, array, from);
let v1: Object = load(context, array, to - 1);
let v2: Object = load(context, array, thirdIndex);
const c01: Number = CallCompareWithDetachedCheck(
context, array, comparefn, v0, v1) otherwise Detached;
@ -170,80 +170,80 @@ module typed_array {
}
// v0 <= v1 <= v2.
Store(context, array, from, v0);
Store(context, array, to - 1, v2);
store(context, array, from, v0);
store(context, array, to - 1, v2);
const pivot: Object = v1;
let low_end: Smi = from + 1; // Upper bound of elems lower than pivot.
let high_start: Smi = to - 1; // Lower bound of elems greater than pivot.
let lowEnd: Smi = from + 1; // Upper bound of elems lower than pivot.
let highStart: Smi = to - 1; // Lower bound of elems greater than pivot.
let low_end_value: Object = Load(context, array, low_end);
Store(context, array, third_index, low_end_value);
Store(context, array, low_end, pivot);
let lowEndValue: Object = load(context, array, lowEnd);
store(context, array, thirdIndex, lowEndValue);
store(context, array, lowEnd, pivot);
// From low_end to idx are elements equal to pivot.
// From idx to high_start are elements that haven"t been compared yet.
for (let idx: Smi = low_end + 1; idx < high_start; idx++) {
let element: Object = Load(context, array, idx);
// From lowEnd to idx are elements equal to pivot.
// From idx to highStart are elements that haven"t been compared yet.
for (let idx: Smi = lowEnd + 1; idx < highStart; idx++) {
let element: Object = load(context, array, idx);
let order: Number = CallCompareWithDetachedCheck(
context, array, comparefn, element, pivot) otherwise Detached;
if (order < 0) {
low_end_value = Load(context, array, low_end);
Store(context, array, idx, low_end_value);
Store(context, array, low_end, element);
low_end++;
lowEndValue = load(context, array, lowEnd);
store(context, array, idx, lowEndValue);
store(context, array, lowEnd, element);
lowEnd++;
} else if (order > 0) {
let break_for: bool = false;
let breakFor: bool = false;
while (order > 0) {
high_start--;
if (high_start == idx) {
break_for = true;
highStart--;
if (highStart == idx) {
breakFor = true;
break;
}
const top_elem: Object = Load(context, array, high_start);
const topElement: Object = load(context, array, highStart);
order = CallCompareWithDetachedCheck(
context, array, comparefn, top_elem, pivot) otherwise Detached;
context, array, comparefn, topElement, pivot) otherwise Detached;
}
if (break_for) {
if (breakFor) {
break;
}
const high_start_value: Object = Load(context, array, high_start);
Store(context, array, idx, high_start_value);
Store(context, array, high_start, element);
const highStartValue: Object = load(context, array, highStart);
store(context, array, idx, highStartValue);
store(context, array, highStart, element);
if (order < 0) {
element = Load(context, array, idx);
element = load(context, array, idx);
low_end_value = Load(context, array, low_end);
Store(context, array, idx, low_end_value);
Store(context, array, low_end, element);
low_end++;
lowEndValue = load(context, array, lowEnd);
store(context, array, idx, lowEndValue);
store(context, array, lowEnd, element);
lowEnd++;
}
}
}
if ((to - high_start) < (low_end - from)) {
if ((to - highStart) < (lowEnd - from)) {
TypedArrayQuickSort(
context, array, high_start, to, comparefn, Load, Store);
to = low_end;
context, array, highStart, to, comparefn, load, store);
to = lowEnd;
} else {
TypedArrayQuickSort(
context, array, from, low_end, comparefn, Load, Store);
from = high_start;
context, array, from, lowEnd, comparefn, load, store);
from = highStart;
}
}
}
builtin TypedArrayQuickSort(
context: Context, array: JSTypedArray, from: Smi, to: Smi,
comparefn: Callable, Load: LoadFn, Store: StoreFn): JSTypedArray {
comparefn: Callable, load: LoadFn, store: StoreFn): JSTypedArray {
try {
TypedArrayQuickSortImpl(context, array, from, to, comparefn, Load, Store)
TypedArrayQuickSortImpl(context, array, from, to, comparefn, load, store)
otherwise Detached;
}
label Detached {
@ -258,10 +258,10 @@ module typed_array {
context: Context, receiver: Object, ...arguments): JSTypedArray {
// 1. If comparefn is not undefined and IsCallable(comparefn) is false,
// throw a TypeError exception.
const comparefn_obj: Object =
const comparefnObj: Object =
arguments.length > 0 ? arguments[0] : Undefined;
if (comparefn_obj != Undefined && !TaggedIsCallable(comparefn_obj)) {
ThrowTypeError(context, kBadSortComparisonFunction, comparefn_obj);
if (comparefnObj != Undefined && !TaggedIsCallable(comparefnObj)) {
ThrowTypeError(context, kBadSortComparisonFunction, comparefnObj);
}
// 2. Let obj be the this value.
@ -273,7 +273,7 @@ module typed_array {
ValidateTypedArray(context, obj, '%TypedArray%.prototype.sort');
// Default sorting is done in C++ using std::sort
if (comparefn_obj == Undefined) {
if (comparefnObj == Undefined) {
return TypedArraySortFast(context, obj);
}
@ -282,48 +282,48 @@ module typed_array {
try {
const comparefn: Callable =
cast<Callable>(comparefn_obj) otherwise CastError;
Cast<Callable>(comparefnObj) otherwise CastError;
let loadfn: LoadFn;
let storefn: StoreFn;
let elements_kind: ElementsKind = array.elements_kind;
let elementsKind: ElementsKind = array.elements_kind;
if (IsElementsKindGreaterThan(elements_kind, UINT32_ELEMENTS)) {
if (elements_kind == INT32_ELEMENTS) {
if (IsElementsKindGreaterThan(elementsKind, UINT32_ELEMENTS)) {
if (elementsKind == INT32_ELEMENTS) {
loadfn = LoadFixedElement<FixedInt32Array>;
storefn = StoreFixedElement<FixedInt32Array>;
} else if (elements_kind == FLOAT32_ELEMENTS) {
} else if (elementsKind == FLOAT32_ELEMENTS) {
loadfn = LoadFixedElement<FixedFloat32Array>;
storefn = StoreFixedElement<FixedFloat32Array>;
} else if (elements_kind == FLOAT64_ELEMENTS) {
} else if (elementsKind == FLOAT64_ELEMENTS) {
loadfn = LoadFixedElement<FixedFloat64Array>;
storefn = StoreFixedElement<FixedFloat64Array>;
} else if (elements_kind == UINT8_CLAMPED_ELEMENTS) {
} else if (elementsKind == UINT8_CLAMPED_ELEMENTS) {
loadfn = LoadFixedElement<FixedUint8ClampedArray>;
storefn = StoreFixedElement<FixedUint8ClampedArray>;
} else if (elements_kind == BIGUINT64_ELEMENTS) {
} else if (elementsKind == BIGUINT64_ELEMENTS) {
loadfn = LoadFixedElement<FixedBigUint64Array>;
storefn = StoreFixedElement<FixedBigUint64Array>;
} else if (elements_kind == BIGINT64_ELEMENTS) {
} else if (elementsKind == BIGINT64_ELEMENTS) {
loadfn = LoadFixedElement<FixedBigInt64Array>;
storefn = StoreFixedElement<FixedBigInt64Array>;
} else {
unreachable;
}
} else {
if (elements_kind == UINT8_ELEMENTS) {
if (elementsKind == UINT8_ELEMENTS) {
loadfn = LoadFixedElement<FixedUint8Array>;
storefn = StoreFixedElement<FixedUint8Array>;
} else if (elements_kind == INT8_ELEMENTS) {
} else if (elementsKind == INT8_ELEMENTS) {
loadfn = LoadFixedElement<FixedInt8Array>;
storefn = StoreFixedElement<FixedInt8Array>;
} else if (elements_kind == UINT16_ELEMENTS) {
} else if (elementsKind == UINT16_ELEMENTS) {
loadfn = LoadFixedElement<FixedUint16Array>;
storefn = StoreFixedElement<FixedUint16Array>;
} else if (elements_kind == INT16_ELEMENTS) {
} else if (elementsKind == INT16_ELEMENTS) {
loadfn = LoadFixedElement<FixedInt16Array>;
storefn = StoreFixedElement<FixedInt16Array>;
} else if (elements_kind == UINT32_ELEMENTS) {
} else if (elementsKind == UINT32_ELEMENTS) {
loadfn = LoadFixedElement<FixedUint32Array>;
storefn = StoreFixedElement<FixedUint32Array>;
} else {

View File

@ -15,7 +15,7 @@ namespace v8 {
namespace internal {
namespace torque {
static constexpr const char* const kFromConstexprMacroName = "from_constexpr";
static constexpr const char* const kFromConstexprMacroName = "FromConstexpr";
static constexpr const char* kTrueLabelName = "_True";
static constexpr const char* kFalseLabelName = "_False";

View File

@ -557,7 +557,7 @@ base::Optional<ParseResult> MakeTypeswitchStatement(
BlockStatement* case_block;
if (i < cases.size() - 1) {
value = MakeNode<CallExpression>(
"cast", false, std::vector<TypeExpression*>{cases[i].type},
"Cast", false, std::vector<TypeExpression*>{cases[i].type},
std::vector<Expression*>{value},
std::vector<std::string>{"_NextCase"});
case_block = MakeNode<BlockStatement>();

View File

@ -36,7 +36,7 @@ module test {
}
macro TestConstexpr1() {
check(from_constexpr<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
check(FromConstexpr<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
}
macro TestConstexprIf() {
@ -46,10 +46,10 @@ module test {
}
macro TestConstexprReturn() {
check(from_constexpr<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
check(from_constexpr<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
check(!from_constexpr<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(from_constexpr<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(FromConstexpr<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
check(FromConstexpr<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
check(!FromConstexpr<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(FromConstexpr<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
}
macro TestGotoLabel(): Boolean {
@ -177,8 +177,8 @@ module test {
}
macro TestVariableRedeclaration(context: Context): Boolean {
let var1: int31 = from_constexpr<bool>(42 == 0) ? 0 : 1;
let var2: int31 = from_constexpr<bool>(42 == 0) ? 1 : 0;
let var1: int31 = FromConstexpr<bool>(42 == 0) ? 0 : 1;
let var2: int31 = FromConstexpr<bool>(42 == 0) ? 1 : 0;
return True;
}
@ -204,7 +204,7 @@ module test {
macro TestUnsafeCast(c: Context, n: Number): Boolean {
if (TaggedIsSmi(n)) {
let m: Smi = unsafe_cast<Smi>(n);
let m: Smi = UnsafeCast<Smi>(n);
check(TestHelperPlus1(c, m) == 11);
return True;
@ -213,8 +213,8 @@ module test {
}
macro TestHexLiteral() {
check(convert<intptr>(0xffff) + 1 == 0x10000);
check(convert<intptr>(-0xffff) == -65535);
check(Convert<intptr>(0xffff) + 1 == 0x10000);
check(Convert<intptr>(-0xffff) == -65535);
}
macro TestLargeIntegerLiterals(c: Context) {
@ -245,16 +245,16 @@ module test {
macro TestLocalConstBindings() {
const x : constexpr int31 = 3;
const x_smi : Smi = x;
const xSmi : Smi = x;
{
const x : Smi = x + from_constexpr<Smi>(1);
check(x == x_smi + 1);
const x_smi : Smi = x;
check(x == x_smi);
const x : Smi = x + FromConstexpr<Smi>(1);
check(x == xSmi + 1);
const xSmi : Smi = x;
check(x == xSmi);
check(x == 4);
}
check(x_smi == 3);
check(x == x_smi);
check(xSmi == 3);
check(x == xSmi);
}
struct TestStructA {
@ -273,12 +273,12 @@ module test {
}
macro TestStruct2(): TestStructA {
return TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 27, 31};
return TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 27, 31};
}
macro TestStruct3(): TestStructA {
let a: TestStructA =
TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 13, 5};
TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 13, 5};
let b: TestStructA = a;
let c: TestStructA = TestStruct2();
a.i = TestStruct1(c);
@ -287,7 +287,7 @@ module test {
d.x = a;
d = TestStructB{a, 7};
let e: TestStructA = d.x;
let f: Smi = TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 27, 31}.i;
let f: Smi = TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 27, 31}.i;
f = TestStruct2().i;
return a;
}
@ -415,9 +415,9 @@ module test {
typeswitch (IncrementIfSmi<(Number|FixedArray)>(x)) {
case (x : Smi) {
result = result + convert<int32>(x);
result = result + Convert<int32>(x);
} case (a : FixedArray) {
result = result + convert<int32>(a.length);
result = result + Convert<int32>(a.length);
} case (x : HeapNumber) {
result = result + 7;
}
@ -427,10 +427,10 @@ module test {
}
macro TestTypeswitch() {
check(TypeswitchExample(from_constexpr<Smi>(5)) == 26);
check(TypeswitchExample(FromConstexpr<Smi>(5)) == 26);
const a : FixedArray = AllocateZeroedFixedArray(3);
check(TypeswitchExample(a) == 13);
check(TypeswitchExample(from_constexpr<Number>(0.5)) == 27);
check(TypeswitchExample(FromConstexpr<Number>(0.5)) == 27);
}
macro ExampleGenericOverload<A: type>(o : Object) : A {
@ -441,10 +441,10 @@ module test {
}
macro TestGenericOverload() {
const x_smi : Smi = 5;
const x_object : Object = x_smi;
check(ExampleGenericOverload<Smi>(x_smi) == 6);
check(unsafe_cast<Smi>(ExampleGenericOverload<Object>(x_object)) == 5);
const xSmi : Smi = 5;
const xObject : Object = xSmi;
check(ExampleGenericOverload<Smi>(xSmi) == 6);
check(UnsafeCast<Smi>(ExampleGenericOverload<Object>(xObject)) == 5);
}
macro BoolToBranch(x : bool) : never labels Taken, NotTaken {

File diff suppressed because it is too large Load Diff