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

[cleanup] Replace 'let' with 'const' in array-foreach.tq

This CL replaces 'let' with 'const' where applicable. This will
generate TNodes instead of TVARIABLEs in the resulting CSA code.

R=jgruber@chromium.org

Bug: v8:8015
Change-Id: I806702c1bfa141e4c934a83c34dd49c321e18ce7
Reviewed-on: https://chromium-review.googlesource.com/1169811Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#55033}
parent 17d9c1a3
......@@ -10,15 +10,15 @@ module array {
// 6. Repeat, while k < len
for (let k: Smi = initial_k; k < len; k = k + 1) {
// 6a. Let Pk be ! ToString(k).
let pK: String = ToString_Inline(context, k);
const pK: String = ToString_Inline(context, k);
// 6b. Let kPresent be ? HasProperty(O, Pk).
let kPresent: Oddball = HasProperty(context, o, pK);
const kPresent: Boolean = HasProperty(context, o, pK);
// 6c. If kPresent is true, then
if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk).
let kValue: Object = GetProperty(context, o, pK);
const kValue: Object = GetProperty(context, o, pK);
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
Call(context, callbackfn, thisArg, kValue, k, o);
......@@ -35,7 +35,7 @@ module array {
// 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.
let jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined);
......@@ -47,7 +47,7 @@ module array {
// 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.
let jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
const jsreceiver: JSReceiver = unsafe_cast<JSReceiver>(receiver);
return ArrayForEachLoopContinuation(
context, jsreceiver, callback, thisArg, Undefined, jsreceiver, initialK,
length, Undefined);
......@@ -58,9 +58,10 @@ module array {
array: Object, object: Object, initialK: Object, length: Object,
to: Object): Object {
try {
let callbackfn: Callable = cast<Callable>(callback) otherwise Unexpected;
let k: Smi = cast<Smi>(initialK) otherwise Unexpected;
let number_length: Number = cast<Number>(length) otherwise Unexpected;
const callbackfn: Callable =
cast<Callable>(callback) otherwise Unexpected;
const k: Smi = cast<Smi>(initialK) otherwise Unexpected;
const number_length: Number = cast<Number>(length) otherwise Unexpected;
return ArrayForEachTorqueContinuation(
context, receiver, number_length, callbackfn, thisArg, k);
......@@ -75,7 +76,7 @@ module array {
thisArg: Object): void labels
Bailout(Smi) {
let k: Smi = 0;
let map: Map = a.map;
const map: Map = a.map;
try {
// Build a fast loop over the smi array.
......@@ -86,7 +87,7 @@ module array {
if (k >= a.length) goto Slow;
try {
let value: Object =
const value: Object =
LoadElementNoHole<FixedArrayType>(a, k) otherwise FoundHole;
Call(context, callbackfn, thisArg, value, k, a);
}
......@@ -110,12 +111,12 @@ module array {
Bailout(Smi) {
let k: Smi = 0;
try {
let smi_len: Smi = cast<Smi>(len) otherwise Slow;
let a: JSArray = cast<JSArray>(o) otherwise Slow;
let map: Map = a.map;
const smi_len: 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;
let elementsKind: ElementsKind = map.elements_kind;
const elementsKind: ElementsKind = map.elements_kind;
if (!IsFastElementsKind(elementsKind)) goto Slow;
if (IsElementsKindGreaterThan(elementsKind, HOLEY_ELEMENTS)) {
......@@ -142,20 +143,20 @@ module array {
}
// 1. Let O be ? ToObject(this value).
let o: JSReceiver = ToObject(context, receiver);
const o: JSReceiver = ToObject(context, receiver);
// 2. Let len be ? ToLength(? Get(O, "length")).
let len: Number = GetLengthProperty(context, o);
const len: Number = GetLengthProperty(context, o);
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
if (arguments.length == 0) {
goto TypeError;
}
let callbackfn: Callable =
const callbackfn: Callable =
cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
let thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
const thisArg: Object = arguments.length > 1 ? arguments[1] : Undefined;
// Special cases.
let k: Smi = 0;
......
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