Commit 31eca73d authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[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: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55794}
parent 44202a1b
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
module array { module array {
macro ConvertToRelativeIndex(index: Number, length: Number): Number { 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 // https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
...@@ -17,32 +17,32 @@ module array { ...@@ -17,32 +17,32 @@ module array {
const length: Number = GetLengthProperty(context, object); const length: Number = GetLengthProperty(context, object);
// 3. Let relativeTarget be ? ToInteger(target). // 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); // 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0);
// else let to be min(relativeTarget, len). // 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). // 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); // 6. If relativeStart < 0, let from be max((len + relativeStart), 0);
// else let from be min(relativeStart, len). // 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; // 7. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end). // else let relativeEnd be ? ToInteger(end).
let relative_end: Number = length; let relativeEnd: Number = length;
if (arguments[2] != Undefined) { 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); // 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
// else let final be min(relativeEnd, len). // 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). // 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. // 10. If from<to and to<from+count, then.
let direction: Number = 1; let direction: Number = 1;
...@@ -63,15 +63,15 @@ module array { ...@@ -63,15 +63,15 @@ module array {
// a. Let fromKey be ! ToString(from). // a. Let fromKey be ! ToString(from).
// b. Let toKey be ! ToString(to). // b. Let toKey be ! ToString(to).
// c. Let fromPresent be ? HasProperty(O, fromKey). // 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. // d. If fromPresent is true, then.
if (from_present == True) { if (fromPresent == True) {
// i. Let fromVal be ? Get(O, fromKey). // 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). // ii. Perform ? Set(O, toKey, fromVal, true).
SetProperty(context, object, to, from_val); SetProperty(context, object, to, fromVal);
} else { } else {
// i. Perform ? DeletePropertyOrThrow(O, toKey). // i. Perform ? DeletePropertyOrThrow(O, toKey).
DeleteProperty(context, object, to, kStrict); DeleteProperty(context, object, to, kStrict);
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
module array { module array {
macro ArrayForEachTorqueContinuation( macro ArrayForEachTorqueContinuation(
context: Context, o: JSReceiver, len: Number, callbackfn: Callable, context: Context, o: JSReceiver, len: Number, callbackfn: Callable,
thisArg: Object, initial_k: Number): Object { thisArg: Object, initialK: Number): Object {
// 5. Let k be 0. // 5. Let k be 0.
// 6. Repeat, while k < len // 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). // 6a. Let Pk be ! ToString(k).
// k is guaranteed to be a positive integer, hence ToString is // k is guaranteed to be a positive integer, hence ToString is
// side-effect free and HasProperty/GetProperty do the conversion inline. // side-effect free and HasProperty/GetProperty do the conversion inline.
...@@ -33,10 +33,10 @@ module array { ...@@ -33,10 +33,10 @@ module array {
javascript builtin ArrayForEachLoopEagerDeoptContinuation( javascript builtin ArrayForEachLoopEagerDeoptContinuation(
context: Context, receiver: Object, callback: Object, thisArg: Object, context: Context, receiver: Object, callback: Object, thisArg: Object,
initialK: Object, length: Object): 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 // after the ToObject(O) call that ensures we are dealing with a
// JSReceiver. // JSReceiver.
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver); const jsreceiver: JSReceiver = UnsafeCast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation( return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK, context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined); length, Undefined);
...@@ -45,10 +45,10 @@ module array { ...@@ -45,10 +45,10 @@ module array {
javascript builtin ArrayForEachLoopLazyDeoptContinuation( javascript builtin ArrayForEachLoopLazyDeoptContinuation(
context: Context, receiver: Object, callback: Object, thisArg: Object, context: Context, receiver: Object, callback: Object, thisArg: Object,
initialK: Object, length: Object, result: Object): 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 // after the ToObject(O) call that ensures we are dealing with a
// JSReceiver. // JSReceiver.
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver); const jsreceiver: JSReceiver = UnsafeCast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation( return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK, context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined); length, Undefined);
...@@ -60,12 +60,12 @@ module array { ...@@ -60,12 +60,12 @@ module array {
to: Object): Object { to: Object): Object {
try { try {
const callbackfn: Callable = const callbackfn: Callable =
cast<Callable>(callback) otherwise Unexpected; Cast<Callable>(callback) otherwise Unexpected;
const k: Number = cast<Number>(initialK) otherwise Unexpected; const k: Number = Cast<Number>(initialK) otherwise Unexpected;
const number_length: Number = cast<Number>(length) otherwise Unexpected; const numberLength: Number = Cast<Number>(length) otherwise Unexpected;
return ArrayForEachTorqueContinuation( return ArrayForEachTorqueContinuation(
context, receiver, number_length, callbackfn, thisArg, k); context, receiver, numberLength, callbackfn, thisArg, k);
} }
label Unexpected { label Unexpected {
unreachable; unreachable;
...@@ -112,8 +112,8 @@ module array { ...@@ -112,8 +112,8 @@ module array {
Bailout(Smi) { Bailout(Smi) {
let k: Smi = 0; let k: Smi = 0;
try { try {
const smi_len: Smi = cast<Smi>(len) otherwise Slow; const smiLen: Smi = Cast<Smi>(len) otherwise Slow;
const a: JSArray = cast<JSArray>(o) otherwise Slow; const a: JSArray = Cast<JSArray>(o) otherwise Slow;
const map: Map = a.map; const map: Map = a.map;
if (!IsPrototypeInitialArrayPrototype(context, map)) goto Slow; if (!IsPrototypeInitialArrayPrototype(context, map)) goto Slow;
...@@ -122,10 +122,10 @@ module array { ...@@ -122,10 +122,10 @@ module array {
if (IsElementsKindGreaterThan(elementsKind, HOLEY_ELEMENTS)) { if (IsElementsKindGreaterThan(elementsKind, HOLEY_ELEMENTS)) {
VisitAllElements<FixedDoubleArray>( VisitAllElements<FixedDoubleArray>(
context, a, smi_len, callbackfn, thisArg) context, a, smiLen, callbackfn, thisArg)
otherwise Bailout; otherwise Bailout;
} else { } else {
VisitAllElements<FixedArray>(context, a, smi_len, callbackfn, thisArg) VisitAllElements<FixedArray>(context, a, smiLen, callbackfn, thisArg)
otherwise Bailout; otherwise Bailout;
} }
} }
...@@ -154,7 +154,7 @@ module array { ...@@ -154,7 +154,7 @@ module array {
goto TypeError; goto TypeError;
} }
const callbackfn: Callable = 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. // 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined; const thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
...@@ -165,8 +165,8 @@ module array { ...@@ -165,8 +165,8 @@ module array {
return FastArrayForEach(context, o, len, callbackfn, thisArg) return FastArrayForEach(context, o, len, callbackfn, thisArg)
otherwise Bailout; otherwise Bailout;
} }
label Bailout(k_value: Smi) { label Bailout(kValue: Smi) {
k = k_value; k = kValue;
} }
return ArrayForEachTorqueContinuation( return ArrayForEachTorqueContinuation(
......
...@@ -9,7 +9,7 @@ module array { ...@@ -9,7 +9,7 @@ module array {
LoadWithHoleCheck<FixedArray>(elements: FixedArrayBase, index: Smi): Object LoadWithHoleCheck<FixedArray>(elements: FixedArrayBase, index: Smi): Object
labels IfHole { labels IfHole {
const elements: FixedArray = unsafe_cast<FixedArray>(elements); const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements[index]; const element: Object = elements[index];
if (element == Hole) goto IfHole; if (element == Hole) goto IfHole;
return element; return element;
...@@ -18,7 +18,7 @@ module array { ...@@ -18,7 +18,7 @@ module array {
LoadWithHoleCheck<FixedDoubleArray>( LoadWithHoleCheck<FixedDoubleArray>(
elements: FixedArrayBase, index: Smi): Object elements: FixedArrayBase, index: Smi): Object
labels IfHole { labels IfHole {
const elements: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements); const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
const element: float64 = LoadDoubleWithHoleCheck(elements, index) const element: float64 = LoadDoubleWithHoleCheck(elements, index)
otherwise IfHole; otherwise IfHole;
return AllocateHeapNumberWithValue(element); return AllocateHeapNumberWithValue(element);
...@@ -63,7 +63,7 @@ module array { ...@@ -63,7 +63,7 @@ module array {
if (n >= 0) { if (n >= 0) {
// a. If n is -0, let k be +0; else let k be min(n, len - 1). // 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. // 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 { } else {
// a. Let k be len + n. // a. Let k be len + n.
k = length + n; k = length + n;
...@@ -76,12 +76,12 @@ module array { ...@@ -76,12 +76,12 @@ module array {
from: Number): Object from: Number): Object
labels Slow { labels Slow {
EnsureFastJSArray(context, receiver) otherwise 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; const length: Smi = array.length_fast;
if (length == 0) return SmiConstant(-1); 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; const kind: ElementsKind = array.map.elements_kind;
if (IsFastSmiOrTaggedElementsKind(kind)) { if (IsFastSmiOrTaggedElementsKind(kind)) {
return FastArrayLastIndexOf<FixedArray>( return FastArrayLastIndexOf<FixedArray>(
...@@ -100,10 +100,10 @@ module array { ...@@ -100,10 +100,10 @@ module array {
// 7. Repeat, while k >= 0. // 7. Repeat, while k >= 0.
while (k >= 0) { while (k >= 0) {
// a. Let kPresent be ? HasProperty(O, ! ToString(k)). // 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. // b. If kPresent is true, then.
if (k_present == True) { if (kPresent == True) {
// i. Let elementK be ? Get(O, ! ToString(k)). // i. Let elementK be ? Get(O, ! ToString(k)).
const element: Object = GetProperty(context, object, k); const element: Object = GetProperty(context, object, k);
......
...@@ -8,20 +8,20 @@ module array { ...@@ -8,20 +8,20 @@ module array {
LoadElement<FastPackedSmiElements, Smi>( LoadElement<FastPackedSmiElements, Smi>(
elements: FixedArrayBase, index: Smi): Smi { elements: FixedArrayBase, index: Smi): Smi {
const elems: FixedArray = unsafe_cast<FixedArray>(elements); const elems: FixedArray = UnsafeCast<FixedArray>(elements);
return unsafe_cast<Smi>(elems[index]); return UnsafeCast<Smi>(elems[index]);
} }
LoadElement<FastPackedObjectElements, Object>( LoadElement<FastPackedObjectElements, Object>(
elements: FixedArrayBase, index: Smi): Object { elements: FixedArrayBase, index: Smi): Object {
const elems: FixedArray = unsafe_cast<FixedArray>(elements); const elems: FixedArray = UnsafeCast<FixedArray>(elements);
return elems[index]; return elems[index];
} }
LoadElement<FastPackedDoubleElements, float64>( LoadElement<FastPackedDoubleElements, float64>(
elements: FixedArrayBase, index: Smi): float64 { elements: FixedArrayBase, index: Smi): float64 {
try { try {
const elems: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements); const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
return LoadDoubleWithHoleCheck(elems, index) otherwise Hole; return LoadDoubleWithHoleCheck(elems, index) otherwise Hole;
} }
label Hole { label Hole {
...@@ -36,19 +36,19 @@ module array { ...@@ -36,19 +36,19 @@ module array {
StoreElement<FastPackedSmiElements, Smi>( StoreElement<FastPackedSmiElements, Smi>(
elements: FixedArrayBase, index: Smi, value: 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); StoreFixedArrayElementSmi(elems, index, value, SKIP_WRITE_BARRIER);
} }
StoreElement<FastPackedObjectElements, Object>( StoreElement<FastPackedObjectElements, Object>(
elements: FixedArrayBase, index: Smi, value: Object) { elements: FixedArrayBase, index: Smi, value: Object) {
const elems: FixedArray = unsafe_cast<FixedArray>(elements); const elems: FixedArray = UnsafeCast<FixedArray>(elements);
elems[index] = value; elems[index] = value;
} }
StoreElement<FastPackedDoubleElements, float64>( StoreElement<FastPackedDoubleElements, float64>(
elements: FixedArrayBase, index: Smi, value: float64) { elements: FixedArrayBase, index: Smi, value: float64) {
const elems: FixedDoubleArray = unsafe_cast<FixedDoubleArray>(elements); const elems: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
assert(value == Float64SilenceNaN(value)); assert(value == Float64SilenceNaN(value));
StoreFixedDoubleArrayElementWithSmiIndex(elems, index, value); StoreFixedDoubleArrayElementWithSmiIndex(elems, index, value);
...@@ -63,10 +63,10 @@ module array { ...@@ -63,10 +63,10 @@ module array {
let upper: Smi = length - 1; let upper: Smi = length - 1;
while (lower < upper) { while (lower < upper) {
const lower_value: T = LoadElement<Accessor, T>(elements, lower); const lowerValue: T = LoadElement<Accessor, T>(elements, lower);
const upper_value: T = LoadElement<Accessor, T>(elements, upper); const upperValue: T = LoadElement<Accessor, T>(elements, upper);
StoreElement<Accessor, T>(elements, lower, upper_value); StoreElement<Accessor, T>(elements, lower, upperValue);
StoreElement<Accessor, T>(elements, upper, lower_value); StoreElement<Accessor, T>(elements, upper, lowerValue);
++lower; ++lower;
--upper; --upper;
} }
...@@ -90,48 +90,48 @@ module array { ...@@ -90,48 +90,48 @@ module array {
let upper: Number = length - 1; let upper: Number = length - 1;
while (lower < upper) { while (lower < upper) {
let lower_value: Object = Undefined; let lowerValue: Object = Undefined;
let upper_value: Object = Undefined; let upperValue: Object = Undefined;
// b. Let upperP be ! ToString(upper). // b. Let upperP be ! ToString(upper).
// c. Let lowerP be ! ToString(lower). // c. Let lowerP be ! ToString(lower).
// d. Let lowerExists be ? HasProperty(O, lowerP). // 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. // e. If lowerExists is true, then.
if (lower_exists == True) { if (lowerExists == True) {
// i. Let lowerValue be ? Get(O, lowerP). // 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). // 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. // g. If upperExists is true, then.
if (upper_exists == True) { if (upperExists == True) {
// i. Let upperValue be ? Get(O, upperP). // 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 // 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). // 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). // ii. Perform ? Set(O, upperP, lowerValue, true).
SetProperty(context, object, upper, lower_value); SetProperty(context, object, upper, lowerValue);
} else if (lower_exists == False && upper_exists == True) { } else if (lowerExists == False && upperExists == True) {
// i. Perform ? Set(O, lowerP, upperValue, true). // i. Perform ? Set(O, lowerP, upperValue, true).
SetProperty(context, object, lower, upper_value); SetProperty(context, object, lower, upperValue);
// ii. Perform ? DeletePropertyOrThrow(O, upperP). // ii. Perform ? DeletePropertyOrThrow(O, upperP).
DeleteProperty(context, object, upper, kStrict); DeleteProperty(context, object, upper, kStrict);
} else if (lower_exists == True && upper_exists == False) { } else if (lowerExists == True && upperExists == False) {
// i. Perform ? DeletePropertyOrThrow(O, lowerP). // i. Perform ? DeletePropertyOrThrow(O, lowerP).
DeleteProperty(context, object, lower, kStrict); DeleteProperty(context, object, lower, kStrict);
// ii. Perform ? Set(O, upperP, lowerValue, true). // ii. Perform ? Set(O, upperP, lowerValue, true).
SetProperty(context, object, upper, lower_value); SetProperty(context, object, upper, lowerValue);
} }
// l. Increase lower by 1. // l. Increase lower by 1.
...@@ -144,7 +144,7 @@ module array { ...@@ -144,7 +144,7 @@ module array {
} }
macro TryFastPackedArrayReverse(receiver: Object) labels Slow { 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; const kind: ElementsKind = array.map.elements_kind;
if (kind == PACKED_SMI_ELEMENTS) { if (kind == PACKED_SMI_ELEMENTS) {
......
...@@ -10,7 +10,7 @@ module array { ...@@ -10,7 +10,7 @@ module array {
macro Extract<FixedArrayType : type>( macro Extract<FixedArrayType : type>(
elements: FixedArrayBase, first: Smi, count: Smi, elements: FixedArrayBase, first: Smi, count: Smi,
capacity: Smi): FixedArrayType { capacity: Smi): FixedArrayType {
return unsafe_cast<FixedArrayType>( return UnsafeCast<FixedArrayType>(
ExtractFixedArray(elements, first, count, capacity)); ExtractFixedArray(elements, first, count, capacity));
} }
...@@ -18,9 +18,9 @@ module array { ...@@ -18,9 +18,9 @@ module array {
elements: FixedArrayBase, first: Smi, count: Smi, elements: FixedArrayBase, first: Smi, count: Smi,
capacity: Smi): FixedDoubleArray { capacity: Smi): FixedDoubleArray {
if (elements == kEmptyFixedArray) { 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)); ExtractFixedArray(elements, first, count, capacity));
} }
...@@ -47,11 +47,11 @@ module array { ...@@ -47,11 +47,11 @@ module array {
let k: Smi = actualStart; let k: Smi = actualStart;
if (insertCount > 0) { if (insertCount > 0) {
const typedNewElements: FixedArrayType = const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements); UnsafeCast<FixedArrayType>(newElements);
for (let e: Object of args [2: ]) { for (let e: Object of args [2: ]) {
// The argument elements were already validated to be an appropriate // The argument elements were already validated to be an appropriate
// {ElementType} to store in {FixedArrayType}. // {ElementType} to store in {FixedArrayType}.
typedNewElements[k++] = unsafe_cast<ElementType>(e); typedNewElements[k++] = UnsafeCast<ElementType>(e);
} }
} }
...@@ -59,9 +59,9 @@ module array { ...@@ -59,9 +59,9 @@ module array {
let count: Smi = length - actualStart - actualDeleteCount; let count: Smi = length - actualStart - actualDeleteCount;
while (count > 0) { while (count > 0) {
const typedElements: FixedArrayType = const typedElements: FixedArrayType =
unsafe_cast<FixedArrayType>(elements); UnsafeCast<FixedArrayType>(elements);
const typedNewElements: FixedArrayType = const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements); UnsafeCast<FixedArrayType>(newElements);
CopyArrayElement(typedElements, typedNewElements, k - lengthDelta, k); CopyArrayElement(typedElements, typedNewElements, k - lengthDelta, k);
k++; k++;
count--; count--;
...@@ -72,7 +72,7 @@ module array { ...@@ -72,7 +72,7 @@ module array {
// is pre-filled with holes. // is pre-filled with holes.
if (elements == newElements) { if (elements == newElements) {
const typedNewElements: FixedArrayType = const typedNewElements: FixedArrayType =
unsafe_cast<FixedArrayType>(newElements); UnsafeCast<FixedArrayType>(newElements);
const limit: Smi = elements.length; const limit: Smi = elements.length;
while (k < limit) { while (k < limit) {
StoreArrayHole(typedNewElements, k); StoreArrayHole(typedNewElements, k);
...@@ -90,14 +90,14 @@ module array { ...@@ -90,14 +90,14 @@ module array {
actualDeleteCountNumber: Number): Object actualDeleteCountNumber: Number): Object
labels Bailout { labels Bailout {
const originalLength: Smi = const originalLength: Smi =
cast<Smi>(originalLengthNumber) otherwise Bailout; Cast<Smi>(originalLengthNumber) otherwise Bailout;
const actualStart: Smi = cast<Smi>(actualStartNumber) otherwise Bailout; const actualStart: Smi = Cast<Smi>(actualStartNumber) otherwise Bailout;
const actualDeleteCount: Smi = const actualDeleteCount: Smi =
cast<Smi>(actualDeleteCountNumber) otherwise Bailout; Cast<Smi>(actualDeleteCountNumber) otherwise Bailout;
const lengthDelta: Smi = insertCount - actualDeleteCount; const lengthDelta: Smi = insertCount - actualDeleteCount;
const newLength: Smi = originalLength + lengthDelta; 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; const map: Map = a.map;
if (!IsPrototypeInitialArrayPrototype(context, map)) goto Bailout; if (!IsPrototypeInitialArrayPrototype(context, map)) goto Bailout;
...@@ -112,7 +112,7 @@ module array { ...@@ -112,7 +112,7 @@ module array {
for (let e: Object of args [2: ]) { for (let e: Object of args [2: ]) {
if (IsFastSmiElementsKind(elementsKind)) { if (IsFastSmiElementsKind(elementsKind)) {
if (TaggedIsNotSmi(e)) { if (TaggedIsNotSmi(e)) {
const heapObject: HeapObject = unsafe_cast<HeapObject>(e); const heapObject: HeapObject = UnsafeCast<HeapObject>(e);
elementsKind = IsHeapNumber(heapObject) ? elementsKind = IsHeapNumber(heapObject) ?
AllowDoubleElements(elementsKind) : AllowDoubleElements(elementsKind) :
AllowNonNumberElements(elementsKind); AllowNonNumberElements(elementsKind);
...@@ -125,12 +125,12 @@ module array { ...@@ -125,12 +125,12 @@ module array {
} }
if (elementsKind != oldElementsKind) { if (elementsKind != oldElementsKind) {
const smi_elements_kind: Smi = convert<Smi>(convert<int32>(elementsKind)); const smiElementsKind: Smi = Convert<Smi>(Convert<int32>(elementsKind));
TransitionElementsKindWithKind(context, a, smi_elements_kind); TransitionElementsKindWithKind(context, a, smiElementsKind);
} }
// Make sure that the length hasn't been changed by side-effect. // 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; if (originalLength != length) goto Bailout;
const deletedResult: JSArray = const deletedResult: JSArray =
...@@ -343,8 +343,8 @@ module array { ...@@ -343,8 +343,8 @@ module array {
// 0); // 0);
// else let actualStart be min(relativeStart, len). // else let actualStart be min(relativeStart, len).
const actualStart: Number = relativeStart < 0 ? const actualStart: Number = relativeStart < 0 ?
max((len + relativeStart), 0) : Max((len + relativeStart), 0) :
min(relativeStart, len); Min(relativeStart, len);
let insertCount: Smi; let insertCount: Smi;
let actualDeleteCount: Number; let actualDeleteCount: Number;
...@@ -363,18 +363,18 @@ module array { ...@@ -363,18 +363,18 @@ module array {
// 7. Else, // 7. Else,
} else { } else {
// a. Let insertCount be the Number of actual arguments minus 2. // 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). // b. Let dc be ? ToInteger(deleteCount).
const deleteCount: Object = arguments[1]; const deleteCount: Object = arguments[1];
const dc: Number = ToInteger_Inline(context, deleteCount); const dc: Number = ToInteger_Inline(context, deleteCount);
// c. Let actualDeleteCount be min(max(dc, 0), len - actualStart). // 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 // 8. If len + insertCount - actualDeleteCount > 2^53-1, throw a
// Bailout exception. // Bailout exception.
const new_length: Number = len + insertCount - actualDeleteCount; const newLength: Number = len + insertCount - actualDeleteCount;
if (new_length > kMaxSafeInteger) { if (newLength > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength, start); ThrowTypeError(context, kInvalidArrayLength, start);
} }
......
...@@ -9,7 +9,7 @@ module array { ...@@ -9,7 +9,7 @@ module array {
context: Context, receiver: Object, arguments: constexpr Arguments): never context: Context, receiver: Object, arguments: constexpr Arguments): never
labels Slow { labels Slow {
EnsureFastJSArray(context, receiver) otherwise Slow; EnsureFastJSArray(context, receiver) otherwise Slow;
const array: JSArray = unsafe_cast<JSArray>(receiver); const array: JSArray = UnsafeCast<JSArray>(receiver);
EnsureWriteableFastElements(array); EnsureWriteableFastElements(array);
const map: Map = array.map; const map: Map = array.map;
...@@ -18,7 +18,7 @@ module array { ...@@ -18,7 +18,7 @@ module array {
tail ArrayUnshift( tail ArrayUnshift(
context, LoadTargetFromFrame(), Undefined, context, LoadTargetFromFrame(), Undefined,
convert<int32>(arguments.length)); Convert<int32>(arguments.length));
} }
macro GenericArrayUnshift( macro GenericArrayUnshift(
...@@ -31,12 +31,12 @@ module array { ...@@ -31,12 +31,12 @@ module array {
const length: Number = GetLengthProperty(context, object); const length: Number = GetLengthProperty(context, object);
// 3. Let argCount be the number of actual arguments. // 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. // 4. If argCount > 0, then.
if (arg_count > 0) { if (argCount > 0) {
// a. If len + argCount > 2**53 - 1, throw a TypeError exception. // a. If len + argCount > 2**53 - 1, throw a TypeError exception.
if (length + arg_count > kMaxSafeInteger) { if (length + argCount > kMaxSafeInteger) {
ThrowTypeError(context, kInvalidArrayLength); ThrowTypeError(context, kInvalidArrayLength);
} }
...@@ -49,18 +49,18 @@ module array { ...@@ -49,18 +49,18 @@ module array {
const from: Number = k - 1; const from: Number = k - 1;
// ii. Let to be ! ToString(k + argCount - 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). // 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 // iv. If fromPresent is true, then
if (from_present == True) { if (fromPresent == True) {
// 1. Let fromValue be ? Get(O, from). // 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). // 2. Perform ? Set(O, to, fromValue, true).
SetProperty(context, object, to, from_value); SetProperty(context, object, to, fromValue);
} else { } else {
// 1. Perform ? DeletePropertyOrThrow(O, to). // 1. Perform ? DeletePropertyOrThrow(O, to).
DeleteProperty(context, object, to, kStrict); DeleteProperty(context, object, to, kStrict);
...@@ -76,9 +76,9 @@ module array { ...@@ -76,9 +76,9 @@ module array {
// e. Let items be a List whose elements are, in left to right order, // e. Let items be a List whose elements are, in left to right order,
// the arguments that were passed to this function invocation. // the arguments that were passed to this function invocation.
// f. Repeat, while items is not empty // f. Repeat, while items is not empty
while (j < arg_count) { while (j < argCount) {
// ii .Perform ? Set(O, ! ToString(j), E, true). // 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. // iii. Increase j by 1.
++j; ++j;
...@@ -86,11 +86,11 @@ module array { ...@@ -86,11 +86,11 @@ module array {
} }
// 5. Perform ? Set(O, "length", len + argCount, true). // 5. Perform ? Set(O, "length", len + argCount, true).
const new_length: Number = length + arg_count; const newLength: Number = length + argCount;
SetProperty(context, object, kLengthString, new_length); SetProperty(context, object, kLengthString, newLength);
// 6. Return length + arg_count. // 6. Return length + argCount.
return new_length; return newLength;
} }
// https://tc39.github.io/ecma262/#sec-array.prototype.unshift // https://tc39.github.io/ecma262/#sec-array.prototype.unshift
......
...@@ -16,7 +16,7 @@ module array { ...@@ -16,7 +16,7 @@ module array {
macro GetLengthProperty(context: Context, o: Object): Number { macro GetLengthProperty(context: Context, o: Object): Number {
if (BranchIfFastJSArray(o, context)) { if (BranchIfFastJSArray(o, context)) {
const a: JSArray = unsafe_cast<JSArray>(o); const a: JSArray = UnsafeCast<JSArray>(o);
return a.length_fast; return a.length_fast;
} else } else
deferred { deferred {
...@@ -42,7 +42,7 @@ module array { ...@@ -42,7 +42,7 @@ module array {
macro IsJSArray(o: Object): bool { macro IsJSArray(o: Object): bool {
try { try {
const array: JSArray = cast<JSArray>(o) otherwise NotArray; const array: JSArray = Cast<JSArray>(o) otherwise NotArray;
return true; return true;
} }
label NotArray { label NotArray {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,7 +15,7 @@ namespace v8 { ...@@ -15,7 +15,7 @@ namespace v8 {
namespace internal { namespace internal {
namespace torque { 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* kTrueLabelName = "_True";
static constexpr const char* kFalseLabelName = "_False"; static constexpr const char* kFalseLabelName = "_False";
......
...@@ -557,7 +557,7 @@ base::Optional<ParseResult> MakeTypeswitchStatement( ...@@ -557,7 +557,7 @@ base::Optional<ParseResult> MakeTypeswitchStatement(
BlockStatement* case_block; BlockStatement* case_block;
if (i < cases.size() - 1) { if (i < cases.size() - 1) {
value = MakeNode<CallExpression>( 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<Expression*>{value},
std::vector<std::string>{"_NextCase"}); std::vector<std::string>{"_NextCase"});
case_block = MakeNode<BlockStatement>(); case_block = MakeNode<BlockStatement>();
......
...@@ -36,7 +36,7 @@ module test { ...@@ -36,7 +36,7 @@ module test {
} }
macro TestConstexpr1() { macro TestConstexpr1() {
check(from_constexpr<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS))); check(FromConstexpr<bool>(IsFastElementsKind(PACKED_SMI_ELEMENTS)));
} }
macro TestConstexprIf() { macro TestConstexprIf() {
...@@ -46,10 +46,10 @@ module test { ...@@ -46,10 +46,10 @@ module test {
} }
macro TestConstexprReturn() { macro TestConstexprReturn() {
check(from_constexpr<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS))); check(FromConstexpr<bool>(ElementsKindTestHelper3(UINT8_ELEMENTS)));
check(from_constexpr<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS))); check(FromConstexpr<bool>(ElementsKindTestHelper3(UINT16_ELEMENTS)));
check(!from_constexpr<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS))); check(!FromConstexpr<bool>(ElementsKindTestHelper3(UINT32_ELEMENTS)));
check(from_constexpr<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS))); check(FromConstexpr<bool>(!ElementsKindTestHelper3(UINT32_ELEMENTS)));
} }
macro TestGotoLabel(): Boolean { macro TestGotoLabel(): Boolean {
...@@ -177,8 +177,8 @@ module test { ...@@ -177,8 +177,8 @@ module test {
} }
macro TestVariableRedeclaration(context: Context): Boolean { macro TestVariableRedeclaration(context: Context): Boolean {
let var1: int31 = from_constexpr<bool>(42 == 0) ? 0 : 1; let var1: int31 = FromConstexpr<bool>(42 == 0) ? 0 : 1;
let var2: int31 = from_constexpr<bool>(42 == 0) ? 1 : 0; let var2: int31 = FromConstexpr<bool>(42 == 0) ? 1 : 0;
return True; return True;
} }
...@@ -204,7 +204,7 @@ module test { ...@@ -204,7 +204,7 @@ module test {
macro TestUnsafeCast(c: Context, n: Number): Boolean { macro TestUnsafeCast(c: Context, n: Number): Boolean {
if (TaggedIsSmi(n)) { if (TaggedIsSmi(n)) {
let m: Smi = unsafe_cast<Smi>(n); let m: Smi = UnsafeCast<Smi>(n);
check(TestHelperPlus1(c, m) == 11); check(TestHelperPlus1(c, m) == 11);
return True; return True;
...@@ -213,8 +213,8 @@ module test { ...@@ -213,8 +213,8 @@ module test {
} }
macro TestHexLiteral() { macro TestHexLiteral() {
check(convert<intptr>(0xffff) + 1 == 0x10000); check(Convert<intptr>(0xffff) + 1 == 0x10000);
check(convert<intptr>(-0xffff) == -65535); check(Convert<intptr>(-0xffff) == -65535);
} }
macro TestLargeIntegerLiterals(c: Context) { macro TestLargeIntegerLiterals(c: Context) {
...@@ -245,16 +245,16 @@ module test { ...@@ -245,16 +245,16 @@ module test {
macro TestLocalConstBindings() { macro TestLocalConstBindings() {
const x : constexpr int31 = 3; const x : constexpr int31 = 3;
const x_smi : Smi = x; const xSmi : Smi = x;
{ {
const x : Smi = x + from_constexpr<Smi>(1); const x : Smi = x + FromConstexpr<Smi>(1);
check(x == x_smi + 1); check(x == xSmi + 1);
const x_smi : Smi = x; const xSmi : Smi = x;
check(x == x_smi); check(x == xSmi);
check(x == 4); check(x == 4);
} }
check(x_smi == 3); check(xSmi == 3);
check(x == x_smi); check(x == xSmi);
} }
struct TestStructA { struct TestStructA {
...@@ -273,12 +273,12 @@ module test { ...@@ -273,12 +273,12 @@ module test {
} }
macro TestStruct2(): TestStructA { macro TestStruct2(): TestStructA {
return TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 27, 31}; return TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 27, 31};
} }
macro TestStruct3(): TestStructA { macro TestStruct3(): TestStructA {
let a: TestStructA = let a: TestStructA =
TestStructA{unsafe_cast<FixedArray>(kEmptyFixedArray), 13, 5}; TestStructA{UnsafeCast<FixedArray>(kEmptyFixedArray), 13, 5};
let b: TestStructA = a; let b: TestStructA = a;
let c: TestStructA = TestStruct2(); let c: TestStructA = TestStruct2();
a.i = TestStruct1(c); a.i = TestStruct1(c);
...@@ -287,7 +287,7 @@ module test { ...@@ -287,7 +287,7 @@ module test {
d.x = a; d.x = a;
d = TestStructB{a, 7}; d = TestStructB{a, 7};
let e: TestStructA = d.x; 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; f = TestStruct2().i;
return a; return a;
} }
...@@ -415,9 +415,9 @@ module test { ...@@ -415,9 +415,9 @@ module test {
typeswitch (IncrementIfSmi<(Number|FixedArray)>(x)) { typeswitch (IncrementIfSmi<(Number|FixedArray)>(x)) {
case (x : Smi) { case (x : Smi) {
result = result + convert<int32>(x); result = result + Convert<int32>(x);
} case (a : FixedArray) { } case (a : FixedArray) {
result = result + convert<int32>(a.length); result = result + Convert<int32>(a.length);
} case (x : HeapNumber) { } case (x : HeapNumber) {
result = result + 7; result = result + 7;
} }
...@@ -427,10 +427,10 @@ module test { ...@@ -427,10 +427,10 @@ module test {
} }
macro TestTypeswitch() { macro TestTypeswitch() {
check(TypeswitchExample(from_constexpr<Smi>(5)) == 26); check(TypeswitchExample(FromConstexpr<Smi>(5)) == 26);
const a : FixedArray = AllocateZeroedFixedArray(3); const a : FixedArray = AllocateZeroedFixedArray(3);
check(TypeswitchExample(a) == 13); 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 { macro ExampleGenericOverload<A: type>(o : Object) : A {
...@@ -441,10 +441,10 @@ module test { ...@@ -441,10 +441,10 @@ module test {
} }
macro TestGenericOverload() { macro TestGenericOverload() {
const x_smi : Smi = 5; const xSmi : Smi = 5;
const x_object : Object = x_smi; const xObject : Object = xSmi;
check(ExampleGenericOverload<Smi>(x_smi) == 6); check(ExampleGenericOverload<Smi>(xSmi) == 6);
check(unsafe_cast<Smi>(ExampleGenericOverload<Object>(x_object)) == 5); check(UnsafeCast<Smi>(ExampleGenericOverload<Object>(xObject)) == 5);
} }
macro BoolToBranch(x : bool) : never labels Taken, NotTaken { macro BoolToBranch(x : bool) : never labels Taken, NotTaken {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment