Commit 45557b1f authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] format namespaces without indentation

Bug: v8:7793
Change-Id: Id2a93f8ac8c512dbc5cdeb43a97e04d8d6684954
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2196130
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67748}
parent 8b2a3221
......@@ -3,92 +3,91 @@
// found in the LICENSE file.
namespace array {
macro ConvertToRelativeIndex(index: Number, length: Number): Number {
return index < 0 ? Max(index + length, 0) : Min(index, length);
}
macro ConvertToRelativeIndex(index: Number, length: Number): Number {
return index < 0 ? Max(index + length, 0) : Min(index, length);
}
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
transitioning javascript builtin ArrayPrototypeCopyWithin(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
transitioning javascript builtin ArrayPrototypeCopyWithin(
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
// 2. Let len be ? ToLength(? Get(O, "length")).
const length: Number = GetLengthProperty(object);
// 2. Let len be ? ToLength(? Get(O, "length")).
const length: Number = GetLengthProperty(object);
// 3. Let relativeTarget be ? ToInteger(target).
const relativeTarget: Number = ToInteger_Inline(arguments[0]);
// 3. Let relativeTarget be ? ToInteger(target).
const relativeTarget: Number = ToInteger_Inline(arguments[0]);
// 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0);
// else let to be min(relativeTarget, len).
let to: Number = ConvertToRelativeIndex(relativeTarget, length);
// 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0);
// else let to be min(relativeTarget, len).
let to: Number = ConvertToRelativeIndex(relativeTarget, length);
// 5. Let relativeStart be ? ToInteger(start).
const relativeStart: Number = ToInteger_Inline(arguments[1]);
// 5. Let relativeStart be ? ToInteger(start).
const relativeStart: Number = ToInteger_Inline(arguments[1]);
// 6. If relativeStart < 0, let from be max((len + relativeStart), 0);
// else let from be min(relativeStart, len).
let from: Number = ConvertToRelativeIndex(relativeStart, length);
// 6. If relativeStart < 0, let from be max((len + relativeStart), 0);
// else let from be min(relativeStart, len).
let from: Number = ConvertToRelativeIndex(relativeStart, length);
// 7. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end).
let relativeEnd: Number = length;
if (arguments[2] != Undefined) {
relativeEnd = ToInteger_Inline(arguments[2]);
}
// 7. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end).
let relativeEnd: Number = length;
if (arguments[2] != Undefined) {
relativeEnd = ToInteger_Inline(arguments[2]);
}
// 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
// else let final be min(relativeEnd, len).
const final: Number = ConvertToRelativeIndex(relativeEnd, length);
// 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0);
// else let final be min(relativeEnd, len).
const final: Number = ConvertToRelativeIndex(relativeEnd, length);
// 9. Let count be min(final-from, len-to).
let count: Number = Min(final - from, length - to);
// 9. Let count be min(final-from, len-to).
let count: Number = Min(final - from, length - to);
// 10. If from<to and to<from+count, then.
let direction: Number = 1;
// 10. If from<to and to<from+count, then.
let direction: Number = 1;
if (from < to && to < (from + count)) {
// a. Let direction be -1.
direction = -1;
if (from < to && to < (from + count)) {
// a. Let direction be -1.
direction = -1;
// b. Let from be from + count - 1.
from = from + count - 1;
// b. Let from be from + count - 1.
from = from + count - 1;
// c. Let to be to + count - 1.
to = to + count - 1;
}
// c. Let to be to + count - 1.
to = to + count - 1;
}
// 12. Repeat, while count > 0.
while (count > 0) {
// a. Let fromKey be ! ToString(from).
// b. Let toKey be ! ToString(to).
// c. Let fromPresent be ? HasProperty(O, fromKey).
const fromPresent: Boolean = HasProperty(object, from);
// d. If fromPresent is true, then.
if (fromPresent == True) {
// i. Let fromVal be ? Get(O, fromKey).
const fromVal: JSAny = GetProperty(object, from);
// ii. Perform ? Set(O, toKey, fromVal, true).
SetProperty(object, to, fromVal);
} else {
// i. Perform ? DeletePropertyOrThrow(O, toKey).
DeleteProperty(object, to, LanguageMode::kStrict);
}
// f. Let from be from + direction.
from = from + direction;
// g. Let to be to + direction.
to = to + direction;
// h. Let count be count - 1.
--count;
// 12. Repeat, while count > 0.
while (count > 0) {
// a. Let fromKey be ! ToString(from).
// b. Let toKey be ! ToString(to).
// c. Let fromPresent be ? HasProperty(O, fromKey).
const fromPresent: Boolean = HasProperty(object, from);
// d. If fromPresent is true, then.
if (fromPresent == True) {
// i. Let fromVal be ? Get(O, fromKey).
const fromVal: JSAny = GetProperty(object, from);
// ii. Perform ? Set(O, toKey, fromVal, true).
SetProperty(object, to, fromVal);
} else {
// i. Perform ? DeletePropertyOrThrow(O, toKey).
DeleteProperty(object, to, LanguageMode::kStrict);
}
// 13. Return O.
return object;
// f. Let from be from + direction.
from = from + direction;
// g. Let to be to + direction.
to = to + direction;
// h. Let count be count - 1.
--count;
}
// 13. Return O.
return object;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,127 +3,126 @@
// found in the LICENSE file.
namespace array {
transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation(
js-implicit context: NativeContext, receiver: JSAny)(
callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
// All continuation points in the optimized forEach implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable;
const numberK = Cast<Number>(initialK) otherwise unreachable;
const numberLength = Cast<Number>(length) otherwise unreachable;
return ArrayForEachLoopContinuation(
jsreceiver, callbackfn, thisArg, Undefined, jsreceiver, numberK,
numberLength, Undefined);
}
transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation(
js-implicit context: NativeContext, receiver: JSAny)(
callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
// All continuation points in the optimized forEach implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable;
const numberK = Cast<Number>(initialK) otherwise unreachable;
const numberLength = Cast<Number>(length) otherwise unreachable;
return ArrayForEachLoopContinuation(
jsreceiver, callbackfn, thisArg, Undefined, jsreceiver, numberK,
numberLength, Undefined);
}
transitioning javascript builtin
ArrayForEachLoopLazyDeoptContinuation(
js-implicit context: NativeContext, receiver: JSAny)(
callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
_result: JSAny): JSAny {
// All continuation points in the optimized forEach implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable;
const numberK = Cast<Number>(initialK) otherwise unreachable;
const numberLength = Cast<Number>(length) otherwise unreachable;
transitioning javascript builtin
ArrayForEachLoopLazyDeoptContinuation(
js-implicit context: NativeContext, receiver: JSAny)(
callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
_result: JSAny): JSAny {
// All continuation points in the optimized forEach implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable;
const numberK = Cast<Number>(initialK) otherwise unreachable;
const numberLength = Cast<Number>(length) otherwise unreachable;
return ArrayForEachLoopContinuation(
jsreceiver, callbackfn, thisArg, Undefined, jsreceiver, numberK,
numberLength, Undefined);
}
return ArrayForEachLoopContinuation(
jsreceiver, callbackfn, thisArg, Undefined, jsreceiver, numberK,
numberLength, Undefined);
}
transitioning builtin ArrayForEachLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny, _array: JSAny,
o: JSReceiver, initialK: Number, len: Number, _to: JSAny): JSAny {
// variables {array} and {to} are ignored.
transitioning builtin ArrayForEachLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
_array: JSAny, o: JSReceiver, initialK: Number, len: Number,
_to: JSAny): JSAny {
// variables {array} and {to} are ignored.
// 5. Let k be 0.
// 6. Repeat, while k < len
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.
// 5. Let k be 0.
// 6. Repeat, while k < len
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.
// 6b. Let kPresent be ? HasProperty(O, Pk).
const kPresent: Boolean = HasProperty_Inline(o, k);
// 6b. Let kPresent be ? HasProperty(O, Pk).
const kPresent: Boolean = HasProperty_Inline(o, k);
// 6c. If kPresent is true, then
if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk).
const kValue: JSAny = GetProperty(o, k);
// 6c. If kPresent is true, then
if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk).
const kValue: JSAny = GetProperty(o, k);
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
Call(context, callbackfn, thisArg, kValue, k, o);
}
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
Call(context, callbackfn, thisArg, kValue, k, o);
}
// 6d. Increase k by 1. (done by the loop).
}
return Undefined;
}
// 6d. Increase k by 1. (done by the loop).
}
return Undefined;
transitioning macro FastArrayForEach(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): JSAny
labels Bailout(Smi) {
let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
const fastO = Cast<FastJSArray>(o) otherwise goto Bailout(k);
let fastOW = NewFastJSArrayWitness(fastO);
// Build a fast loop over the smi array.
for (; k < smiLen; k++) {
fastOW.Recheck() otherwise goto Bailout(k);
// Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k);
const value: JSAny = fastOW.LoadElementNoHole(k)
otherwise continue;
Call(context, callbackfn, thisArg, value, k, fastOW.Get());
}
return Undefined;
}
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach
transitioning javascript builtin
ArrayForEach(
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
try {
RequireObjectCoercible(receiver, 'Array.prototype.forEach');
// 1. Let O be ? ToObject(this value).
const o: JSReceiver = ToObject_Inline(context, receiver);
// 2. Let len be ? ToLength(? Get(O, "length")).
const len: Number = GetLengthProperty(o);
transitioning macro FastArrayForEach(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): JSAny
labels Bailout(Smi) {
let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
const fastO = Cast<FastJSArray>(o) otherwise goto Bailout(k);
let fastOW = NewFastJSArrayWitness(fastO);
// Build a fast loop over the smi array.
for (; k < smiLen; k++) {
fastOW.Recheck() otherwise goto Bailout(k);
// Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k);
const value: JSAny = fastOW.LoadElementNoHole(k)
otherwise continue;
Call(context, callbackfn, thisArg, value, k, fastOW.Get());
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
if (arguments.length == 0) {
goto TypeError;
}
return Undefined;
}
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments[1];
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach
transitioning javascript builtin
ArrayForEach(js-implicit context: NativeContext, receiver: JSAny)(
...arguments): JSAny {
// Special cases.
let k: Number = 0;
try {
RequireObjectCoercible(receiver, 'Array.prototype.forEach');
// 1. Let O be ? ToObject(this value).
const o: JSReceiver = ToObject_Inline(context, receiver);
// 2. Let len be ? ToLength(? Get(O, "length")).
const len: Number = GetLengthProperty(o);
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
if (arguments.length == 0) {
goto TypeError;
}
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError;
// 4. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: JSAny = arguments[1];
// Special cases.
let k: Number = 0;
try {
return FastArrayForEach(o, len, callbackfn, thisArg)
otherwise Bailout;
} label Bailout(kValue: Smi) deferred {
k = kValue;
}
return ArrayForEachLoopContinuation(
o, callbackfn, thisArg, Undefined, o, k, len, Undefined);
} label TypeError deferred {
ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
return FastArrayForEach(o, len, callbackfn, thisArg)
otherwise Bailout;
} label Bailout(kValue: Smi) deferred {
k = kValue;
}
return ArrayForEachLoopContinuation(
o, callbackfn, thisArg, Undefined, o, k, len, Undefined);
} label TypeError deferred {
ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
}
}
}
This diff is collapsed.
......@@ -3,25 +3,25 @@
// found in the LICENSE file.
namespace runtime {
extern runtime ArrayIsArray(implicit context: Context)(JSAny): JSAny;
extern runtime ArrayIsArray(implicit context: Context)(JSAny): JSAny;
} // namespace runtime
namespace array {
// ES #sec-array.isarray
javascript builtin ArrayIsArray(js-implicit context:
NativeContext)(arg: JSAny): JSAny {
// 1. Return ? IsArray(arg).
typeswitch (arg) {
case (JSArray): {
return True;
}
case (JSProxy): {
// TODO(verwaest): Handle proxies in-place
return runtime::ArrayIsArray(arg);
}
case (JSAny): {
return False;
}
// ES #sec-array.isarray
javascript builtin ArrayIsArray(js-implicit context: NativeContext)(arg: JSAny):
JSAny {
// 1. Return ? IsArray(arg).
typeswitch (arg) {
case (JSArray): {
return True;
}
case (JSProxy): {
// TODO(verwaest): Handle proxies in-place
return runtime::ArrayIsArray(arg);
}
case (JSAny): {
return False;
}
}
}
} // namespace array
This diff is collapsed.
......@@ -3,152 +3,151 @@
// found in the LICENSE file.
namespace array {
macro LoadWithHoleCheck<Elements : type extends FixedArrayBase>(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole;
LoadWithHoleCheck<FixedArray>(implicit context: Context)(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole {
const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements.objects[index];
if (element == TheHole) goto IfHole;
return UnsafeCast<JSAny>(element);
}
LoadWithHoleCheck<FixedDoubleArray>(implicit context: Context)(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole {
const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
const element: float64 = elements.floats[index].Value() otherwise IfHole;
return AllocateHeapNumberWithValue(element);
}
macro LoadWithHoleCheck<Elements : type extends FixedArrayBase>(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole;
LoadWithHoleCheck<FixedArray>(implicit context: Context)(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole {
const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements.objects[index];
if (element == TheHole) goto IfHole;
return UnsafeCast<JSAny>(element);
}
macro FastArrayLastIndexOf<Elements : type extends FixedArrayBase>(
context: Context, array: JSArray, from: Smi, searchElement: JSAny): Smi {
const elements: FixedArrayBase = array.elements;
let k: Smi = from;
// Bug(898785): Due to side-effects in the evaluation of `fromIndex`
// the {from} can be out-of-bounds here, so we need to clamp {k} to
// the {elements} length. We might be reading holes / hole NaNs still
// due to that, but those will be ignored below.
if (k >= elements.length) {
k = elements.length - 1;
}
LoadWithHoleCheck<FixedDoubleArray>(implicit context: Context)(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole {
const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
const element: float64 = elements.floats[index].Value() otherwise IfHole;
return AllocateHeapNumberWithValue(element);
}
while (k >= 0) {
try {
const element: JSAny = LoadWithHoleCheck<Elements>(elements, k)
otherwise Hole;
macro FastArrayLastIndexOf<Elements : type extends FixedArrayBase>(
context: Context, array: JSArray, from: Smi, searchElement: JSAny): Smi {
const elements: FixedArrayBase = array.elements;
let k: Smi = from;
// Bug(898785): Due to side-effects in the evaluation of `fromIndex`
// the {from} can be out-of-bounds here, so we need to clamp {k} to
// the {elements} length. We might be reading holes / hole NaNs still
// due to that, but those will be ignored below.
if (k >= elements.length) {
k = elements.length - 1;
}
const same: Boolean = StrictEqual(searchElement, element);
if (same == True) {
assert(Is<FastJSArray>(array));
return k;
}
} label Hole {} // Do nothing for holes.
while (k >= 0) {
try {
const element: JSAny = LoadWithHoleCheck<Elements>(elements, k)
otherwise Hole;
--k;
}
const same: Boolean = StrictEqual(searchElement, element);
if (same == True) {
assert(Is<FastJSArray>(array));
return k;
}
} label Hole {} // Do nothing for holes.
assert(Is<FastJSArray>(array));
return -1;
--k;
}
transitioning macro
GetFromIndex(context: Context, length: Number, arguments: Arguments): Number {
// 4. If fromIndex is present, let n be ? ToInteger(fromIndex);
// else let n be len - 1.
const n: Number =
arguments.length < 2 ? length - 1 : ToInteger_Inline(arguments[1]);
// 5. If n >= 0, then.
let k: Number = SmiConstant(0);
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);
} else {
// a. Let k be len + n.
k = length + n;
}
return k;
assert(Is<FastJSArray>(array));
return -1;
}
transitioning macro
GetFromIndex(context: Context, length: Number, arguments: Arguments): Number {
// 4. If fromIndex is present, let n be ? ToInteger(fromIndex);
// else let n be len - 1.
const n: Number =
arguments.length < 2 ? length - 1 : ToInteger_Inline(arguments[1]);
// 5. If n >= 0, then.
let k: Number = SmiConstant(0);
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);
} else {
// a. Let k be len + n.
k = length + n;
}
return k;
}
macro TryFastArrayLastIndexOf(
context: Context, receiver: JSReceiver, searchElement: JSAny,
from: Number): JSAny
labels Slow {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
const length: Smi = array.length;
if (length == 0) return SmiConstant(-1);
const fromSmi: Smi = Cast<Smi>(from) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
if (IsFastSmiOrTaggedElementsKind(kind)) {
return FastArrayLastIndexOf<FixedArray>(
context, array, fromSmi, searchElement);
}
assert(IsDoubleElementsKind(kind));
return FastArrayLastIndexOf<FixedDoubleArray>(
macro TryFastArrayLastIndexOf(
context: Context, receiver: JSReceiver, searchElement: JSAny,
from: Number): JSAny
labels Slow {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
const length: Smi = array.length;
if (length == 0) return SmiConstant(-1);
const fromSmi: Smi = Cast<Smi>(from) otherwise Slow;
const kind: ElementsKind = array.map.elements_kind;
if (IsFastSmiOrTaggedElementsKind(kind)) {
return FastArrayLastIndexOf<FixedArray>(
context, array, fromSmi, searchElement);
}
assert(IsDoubleElementsKind(kind));
return FastArrayLastIndexOf<FixedDoubleArray>(
context, array, fromSmi, searchElement);
}
transitioning macro GenericArrayLastIndexOf(
context: Context, object: JSReceiver, searchElement: JSAny,
from: Number): JSAny {
let k: Number = from;
// 7. Repeat, while k >= 0.
while (k >= 0) {
// a. Let kPresent be ? HasProperty(O, ! ToString(k)).
const kPresent: Boolean = HasProperty(object, k);
transitioning macro GenericArrayLastIndexOf(
context: Context, object: JSReceiver, searchElement: JSAny,
from: Number): JSAny {
let k: Number = from;
// b. If kPresent is true, then.
if (kPresent == True) {
// i. Let elementK be ? Get(O, ! ToString(k)).
const element: JSAny = GetProperty(object, k);
// 7. Repeat, while k >= 0.
while (k >= 0) {
// a. Let kPresent be ? HasProperty(O, ! ToString(k)).
const kPresent: Boolean = HasProperty(object, k);
// ii. Let same be the result of performing Strict Equality Comparison
// searchElement === elementK.
const same: Boolean = StrictEqual(searchElement, element);
// b. If kPresent is true, then.
if (kPresent == True) {
// i. Let elementK be ? Get(O, ! ToString(k)).
const element: JSAny = GetProperty(object, k);
// iii. If same is true, return k.
if (same == True) return k;
}
// ii. Let same be the result of performing Strict Equality Comparison
// searchElement === elementK.
const same: Boolean = StrictEqual(searchElement, element);
// c. Decrease k by 1.
--k;
// iii. If same is true, return k.
if (same == True) return k;
}
// 8. Return -1.
return SmiConstant(-1);
// c. Decrease k by 1.
--k;
}
// https://tc39.github.io/ecma262/#sec-array.prototype.lastIndexOf
transitioning javascript builtin ArrayPrototypeLastIndexOf(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
// 8. Return -1.
return SmiConstant(-1);
}
// 2. Let len be ? ToLength(? Get(O, "length")).
const length: Number = GetLengthProperty(object);
// https://tc39.github.io/ecma262/#sec-array.prototype.lastIndexOf
transitioning javascript builtin ArrayPrototypeLastIndexOf(
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
// 3. If len is 0, return -1.
if (length == SmiConstant(0)) return SmiConstant(-1);
// 2. Let len be ? ToLength(? Get(O, "length")).
const length: Number = GetLengthProperty(object);
// Step 4 - 6.
const from: Number = GetFromIndex(context, length, arguments);
// 3. If len is 0, return -1.
if (length == SmiConstant(0)) return SmiConstant(-1);
const searchElement: JSAny = arguments[0];
// Step 4 - 6.
const from: Number = GetFromIndex(context, length, arguments);
try {
return TryFastArrayLastIndexOf(context, object, searchElement, from)
otherwise Baseline;
} label Baseline {
return GenericArrayLastIndexOf(context, object, searchElement, from);
}
const searchElement: JSAny = arguments[0];
try {
return TryFastArrayLastIndexOf(context, object, searchElement, from)
otherwise Baseline;
} label Baseline {
return GenericArrayLastIndexOf(context, object, searchElement, from);
}
}
}
This diff is collapsed.
......@@ -3,53 +3,53 @@
// found in the LICENSE file.
namespace array {
// https://tc39.github.io/ecma262/#sec-array.of
transitioning javascript builtin
ArrayOf(js-implicit context: NativeContext, receiver: JSAny)(...arguments):
JSAny {
// 1. Let len be the actual number of arguments passed to this function.
const len: Smi = Convert<Smi>(arguments.length);
// 2. Let items be the List of arguments passed to this function.
const items: Arguments = arguments;
// 3. Let C be the this value.
const c: JSAny = receiver;
let a: JSReceiver;
// 4. If IsConstructor(C) is true, then
typeswitch (c) {
case (c: Constructor): {
// a. Let A be ? Construct(C, « len »).
a = Construct(c, len);
}
case (JSAny): {
// a. Let A be ? ArrayCreate(len).
a = ArrayCreate(len);
}
// https://tc39.github.io/ecma262/#sec-array.of
transitioning javascript builtin
ArrayOf(
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
// 1. Let len be the actual number of arguments passed to this function.
const len: Smi = Convert<Smi>(arguments.length);
// 2. Let items be the List of arguments passed to this function.
const items: Arguments = arguments;
// 3. Let C be the this value.
const c: JSAny = receiver;
let a: JSReceiver;
// 4. If IsConstructor(C) is true, then
typeswitch (c) {
case (c: Constructor): {
// a. Let A be ? Construct(C, « len »).
a = Construct(c, len);
}
case (JSAny): {
// a. Let A be ? ArrayCreate(len).
a = ArrayCreate(len);
}
}
// 6. Let k be 0.
let k: Smi = 0;
// 6. Let k be 0.
let k: Smi = 0;
// 7. Repeat, while k < len
while (k < len) {
// a. Let kValue be items[k].
const kValue: JSAny = items[Convert<intptr>(k)];
// 7. Repeat, while k < len
while (k < len) {
// a. Let kValue be items[k].
const kValue: JSAny = items[Convert<intptr>(k)];
// b. Let Pk be ! ToString(k).
// c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
FastCreateDataProperty(a, k, kValue);
// b. Let Pk be ! ToString(k).
// c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
FastCreateDataProperty(a, k, kValue);
// d. Increase k by 1.
k++;
}
// d. Increase k by 1.
k++;
}
// 8. Perform ? Set(A, "length", len, true).
array::SetPropertyLength(a, len);
// 8. Perform ? Set(A, "length", len, true).
array::SetPropertyLength(a, len);
// 9. Return A.
return a;
}
// 9. Return A.
return a;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,108 +3,107 @@
// found in the LICENSE file.
namespace array {
extern builtin ArrayShift(Context, JSFunction, JSAny, int32): JSAny;
extern builtin ArrayShift(Context, JSFunction, JSAny, int32): JSAny;
macro TryFastArrayShift(implicit context: Context)(receiver: JSAny): JSAny
labels Slow, Runtime {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
let witness = NewFastJSArrayWitness(array);
macro TryFastArrayShift(implicit context: Context)(receiver: JSAny): JSAny
labels Slow, Runtime {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
let witness = NewFastJSArrayWitness(array);
witness.EnsureArrayPushable() otherwise Slow;
witness.EnsureArrayPushable() otherwise Slow;
if (array.length == 0) {
return Undefined;
}
if (array.length == 0) {
return Undefined;
}
const newLength = array.length - 1;
const newLength = array.length - 1;
// Check that we're not supposed to right-trim the backing store, as
// implemented in elements.cc:ElementsAccessorBase::SetLengthImpl.
if ((newLength + newLength + kMinAddedElementsCapacity) <
array.elements.length) {
goto Runtime;
}
// Check that we're not supposed to right-trim the backing store, as
// implemented in elements.cc:ElementsAccessorBase::SetLengthImpl.
if ((newLength + newLength + kMinAddedElementsCapacity) <
array.elements.length) {
goto Runtime;
}
// Check that we're not supposed to left-trim the backing store, as
// implemented in elements.cc:FastElementsAccessor::MoveElements.
if (newLength > kMaxCopyElements) goto Runtime;
// Check that we're not supposed to left-trim the backing store, as
// implemented in elements.cc:FastElementsAccessor::MoveElements.
if (newLength > kMaxCopyElements) goto Runtime;
const result = witness.LoadElementOrUndefined(0);
witness.ChangeLength(newLength);
witness.MoveElements(0, 1, Convert<intptr>(newLength));
witness.StoreHole(newLength);
return result;
}
const result = witness.LoadElementOrUndefined(0);
witness.ChangeLength(newLength);
witness.MoveElements(0, 1, Convert<intptr>(newLength));
witness.StoreHole(newLength);
return result;
}
transitioning macro GenericArrayShift(implicit context:
Context)(receiver: JSAny): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
transitioning macro GenericArrayShift(implicit context: Context)(
receiver: JSAny): JSAny {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
// 2. Let len be ? ToLength(? Get(O, "length")).
const length: Number = GetLengthProperty(object);
// 2. Let len be ? ToLength(? Get(O, "length")).
const length: Number = GetLengthProperty(object);
// 3. If len is zero, then
if (length == 0) {
// a. Perform ? Set(O, "length", 0, true).
SetProperty(object, kLengthString, Convert<Smi>(0));
// b. Return undefined.
return Undefined;
}
// 3. If len is zero, then
if (length == 0) {
// a. Perform ? Set(O, "length", 0, true).
SetProperty(object, kLengthString, Convert<Smi>(0));
// b. Return undefined.
return Undefined;
}
// 4. Let first be ? Get(O, "0").
const first = GetProperty(object, Convert<Smi>(0));
// 5. Let k be 1.
let k: Number = 1;
// 6. Repeat, while k < len
while (k < length) {
// a. Let from be ! ToString(k).
const from: Number = k;
// b. Let to be ! ToString(k - 1).
const to: Number = k - 1;
// c. Let fromPresent be ? HasProperty(O, from).
const fromPresent: Boolean = HasProperty(object, from);
// d. If fromPresent is true, then
if (fromPresent == True) {
// i. Let fromVal be ? Get(O, from).
const fromValue: JSAny = GetProperty(object, from);
// ii. Perform ? Set(O, to, fromValue, true).
SetProperty(object, to, fromValue);
} else {
// i. Perform ? DeletePropertyOrThrow(O, to).
DeleteProperty(object, to, LanguageMode::kStrict);
}
// f. Increase k by 1.
k++;
// 4. Let first be ? Get(O, "0").
const first = GetProperty(object, Convert<Smi>(0));
// 5. Let k be 1.
let k: Number = 1;
// 6. Repeat, while k < len
while (k < length) {
// a. Let from be ! ToString(k).
const from: Number = k;
// b. Let to be ! ToString(k - 1).
const to: Number = k - 1;
// c. Let fromPresent be ? HasProperty(O, from).
const fromPresent: Boolean = HasProperty(object, from);
// d. If fromPresent is true, then
if (fromPresent == True) {
// i. Let fromVal be ? Get(O, from).
const fromValue: JSAny = GetProperty(object, from);
// ii. Perform ? Set(O, to, fromValue, true).
SetProperty(object, to, fromValue);
} else {
// i. Perform ? DeletePropertyOrThrow(O, to).
DeleteProperty(object, to, LanguageMode::kStrict);
}
// 7. Perform ? DeletePropertyOrThrow(O, ! ToString(len - 1)).
DeleteProperty(object, length - 1, LanguageMode::kStrict);
// f. Increase k by 1.
k++;
}
// 8. Perform ? Set(O, "length", len - 1, true).
SetProperty(object, kLengthString, length - 1);
// 7. Perform ? DeletePropertyOrThrow(O, ! ToString(len - 1)).
DeleteProperty(object, length - 1, LanguageMode::kStrict);
// 9. Return first.
return first;
}
// 8. Perform ? Set(O, "length", len - 1, true).
SetProperty(object, kLengthString, length - 1);
// https://tc39.github.io/ecma262/#sec-array.prototype.shift
transitioning javascript builtin ArrayPrototypeShift(
js-implicit context: NativeContext,
receiver: JSAny)(...arguments): JSAny {
try {
return TryFastArrayShift(receiver) otherwise Slow, Runtime;
} label Slow {
return GenericArrayShift(receiver);
} label Runtime {
tail ArrayShift(
context, LoadTargetFromFrame(), Undefined,
Convert<int32>(arguments.length));
}
// 9. Return first.
return first;
}
// https://tc39.github.io/ecma262/#sec-array.prototype.shift
transitioning javascript builtin ArrayPrototypeShift(
js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
try {
return TryFastArrayShift(receiver) otherwise Slow, Runtime;
} label Slow {
return GenericArrayShift(receiver);
} label Runtime {
tail ArrayShift(
context, LoadTargetFromFrame(), Undefined,
Convert<int32>(arguments.length));
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -1513,8 +1513,8 @@ extern transitioning runtime
CreateDataProperty(implicit context: Context)(JSReceiver, JSAny, JSAny);
namespace runtime {
extern runtime
GetDerivedMap(Context, JSFunction, JSReceiver): Map;
extern runtime
GetDerivedMap(Context, JSFunction, JSReceiver): Map;
}
transitioning builtin FastCreateDataProperty(implicit context: Context)(
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,16 +3,16 @@
// found in the LICENSE file.
namespace console {
extern builtin ConsoleAssert(implicit context:
Context)(JSFunction, JSAny, int32): JSAny;
extern builtin ConsoleAssert(implicit context: Context)(
JSFunction, JSAny, int32): JSAny;
javascript builtin FastConsoleAssert(
js-implicit context: NativeContext, receiver: JSAny, newTarget: JSAny,
target: JSFunction)(...arguments): JSAny {
if (ToBoolean(arguments[0])) {
return Undefined;
} else {
tail ConsoleAssert(target, newTarget, Convert<int32>(arguments.length));
}
javascript builtin FastConsoleAssert(
js-implicit context: NativeContext, receiver: JSAny, newTarget: JSAny,
target: JSFunction)(...arguments): JSAny {
if (ToBoolean(arguments[0])) {
return Undefined;
} else {
tail ConsoleAssert(target, newTarget, Convert<int32>(arguments.length));
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -6,21 +6,21 @@
namespace proxy {
extern macro ProxiesCodeStubAssembler::AllocateProxy(
implicit context: Context)(JSReceiver, JSReceiver): JSProxy;
extern macro ProxiesCodeStubAssembler::AllocateProxy(implicit context: Context)(
JSReceiver, JSReceiver): JSProxy;
extern transitioning macro ProxiesCodeStubAssembler::CheckGetSetTrapResult(
implicit context:
Context)(JSReceiver, JSProxy, Name, Object, constexpr int31);
extern transitioning macro ProxiesCodeStubAssembler::CheckGetSetTrapResult(
implicit context: Context)(
JSReceiver, JSProxy, Name, Object, constexpr int31);
extern transitioning macro ProxiesCodeStubAssembler::CheckDeleteTrapResult(
implicit context: Context)(JSReceiver, JSProxy, Name);
extern transitioning macro ProxiesCodeStubAssembler::CheckDeleteTrapResult(
implicit context: Context)(JSReceiver, JSProxy, Name);
extern transitioning macro ProxiesCodeStubAssembler::CheckHasTrapResult(
implicit context: Context)(JSReceiver, JSProxy, Name);
extern transitioning macro ProxiesCodeStubAssembler::CheckHasTrapResult(
implicit context: Context)(JSReceiver, JSProxy, Name);
const kProxyGet: constexpr int31
generates 'JSProxy::AccessKind::kGet';
const kProxySet: constexpr int31
generates 'JSProxy::AccessKind::kSet';
const kProxyGet: constexpr int31
generates 'JSProxy::AccessKind::kGet';
const kProxySet: constexpr int31
generates 'JSProxy::AccessKind::kSet';
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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