Commit 79b00555 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] introduce JSAny type for user-accessible JavaScript values

This CL introduces a JSAny type for user-exposed JavaScript values and
a few new types to define it. Especially, it splits Symbol into
PrivateSymbol (not exposed) and PublicSymbol (JavaScript exposed
symbols).

The change is mostly mechanical, but a few things are interesting:
- PropertyKey and JSPrimitive were designed to coincide with the spec
  notions of IsPropertyKey() and primitive value, respectively.
- Since Name is an open type, we define AnyName to be the known
  subtypes of Name. This is not too elegant, but by using AnyName
  instead of Name, typeswitch can properly conclude something if a
  subtype of Name is excluded.

Small drive-by changes, which were necessary:
- Allow subtyping on label parameters.
- Fix the formatting of typeswitch, it was broken with union types
  in case types.

Bug: v8:7793
Change-Id: I14b10507f8cf316ad85e048fe8d53d1df5e0bb13
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1735322
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63114}
parent 919ee633
...@@ -8,7 +8,7 @@ struct Arguments { ...@@ -8,7 +8,7 @@ struct Arguments {
const length: intptr; const length: intptr;
} }
extern operator '[]' macro GetArgumentValue(Arguments, intptr): Object; extern operator '[]' macro GetArgumentValue(Arguments, intptr): JSAny;
extern macro GetFrameArguments(FrameWithArguments, intptr): Arguments; extern macro GetFrameArguments(FrameWithArguments, intptr): Arguments;
......
...@@ -9,7 +9,7 @@ namespace array_copywithin { ...@@ -9,7 +9,7 @@ namespace array_copywithin {
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin // https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
transitioning javascript builtin ArrayPrototypeCopyWithin( transitioning javascript builtin ArrayPrototypeCopyWithin(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver); const object: JSReceiver = ToObject_Inline(context, receiver);
...@@ -68,7 +68,7 @@ namespace array_copywithin { ...@@ -68,7 +68,7 @@ namespace array_copywithin {
// d. If fromPresent is true, then. // d. If fromPresent is true, then.
if (fromPresent == True) { if (fromPresent == True) {
// i. Let fromVal be ? Get(O, fromKey). // i. Let fromVal be ? Get(O, fromKey).
const fromVal: Object = GetProperty(object, from); const fromVal: JSAny = GetProperty(object, from);
// ii. Perform ? Set(O, toKey, fromVal, true). // ii. Perform ? Set(O, toKey, fromVal, true).
SetProperty(object, to, fromVal); SetProperty(object, to, fromVal);
......
...@@ -5,15 +5,14 @@ ...@@ -5,15 +5,14 @@
namespace array { namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayEveryLoopEagerDeoptContinuation( ArrayEveryLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
length: Object): Object {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -27,9 +26,9 @@ namespace array { ...@@ -27,9 +26,9 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayEveryLoopLazyDeoptContinuation( ArrayEveryLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, length: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
result: Object): Object { result: JSAny): JSAny {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
...@@ -53,9 +52,9 @@ namespace array { ...@@ -53,9 +52,9 @@ namespace array {
} }
transitioning builtin ArrayEveryLoopContinuation(implicit context: Context)( transitioning builtin ArrayEveryLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
_array: Object, o: JSReceiver, initialK: Number, length: Number, _array: JSAny, o: JSReceiver, initialK: Number, length: Number,
_initialTo: Object): Object { _initialTo: JSAny): JSAny {
// 5. Let k be 0. // 5. Let k be 0.
// 6. Repeat, while k < len // 6. Repeat, while k < len
for (let k: Number = initialK; k < length; k++) { for (let k: Number = initialK; k < length; k++) {
...@@ -69,10 +68,10 @@ namespace array { ...@@ -69,10 +68,10 @@ namespace array {
// 6c. If kPresent is true, then // 6c. If kPresent is true, then
if (kPresent == True) { if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk). // 6c. i. Let kValue be ? Get(O, Pk).
const kValue: Object = GetProperty(o, k); const kValue: JSAny = GetProperty(o, k);
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>). // 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
const result: Object = Call(context, callbackfn, thisArg, kValue, k, o); const result: JSAny = Call(context, callbackfn, thisArg, kValue, k, o);
// iii. If selected is true, then... // iii. If selected is true, then...
if (!ToBoolean(result)) { if (!ToBoolean(result)) {
...@@ -86,7 +85,7 @@ namespace array { ...@@ -86,7 +85,7 @@ namespace array {
} }
transitioning macro FastArrayEvery(implicit context: Context)( transitioning macro FastArrayEvery(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: Object): Object o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): JSAny
labels Bailout(Smi) { labels Bailout(Smi) {
let k: Smi = 0; let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k); const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
...@@ -99,8 +98,8 @@ namespace array { ...@@ -99,8 +98,8 @@ namespace array {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k); if (k >= fastOW.Get().length) goto Bailout(k);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: JSAny = fastOW.LoadElementNoHole(k) otherwise continue;
const result: Object = const result: JSAny =
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
if (!ToBoolean(result)) { if (!ToBoolean(result)) {
return False; return False;
...@@ -111,8 +110,8 @@ namespace array { ...@@ -111,8 +110,8 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.every // https://tc39.github.io/ecma262/#sec-array.prototype.every
transitioning javascript builtin transitioning javascript builtin
ArrayEvery(js-implicit context: Context, receiver: Object)(...arguments): ArrayEvery(js-implicit context: Context, receiver: JSAny)(...arguments):
Object { JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.every'); RequireObjectCoercible(receiver, 'Array.prototype.every');
...@@ -129,7 +128,7 @@ namespace array { ...@@ -129,7 +128,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError; const callbackfn = 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
// Special cases. // Special cases.
try { try {
......
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
namespace array_filter { namespace array_filter {
transitioning javascript builtin transitioning javascript builtin
ArrayFilterLoopEagerDeoptContinuation( ArrayFilterLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, array: Object, initialK: Object, callback: JSAny, thisArg: JSAny, array: JSAny, initialK: JSAny,
length: Object, initialTo: Object): Object { length: JSAny, initialTo: JSAny): JSAny {
// All continuation points in the optimized filter implementation are // All continuation points in the optimized filter implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -29,10 +29,9 @@ namespace array_filter { ...@@ -29,10 +29,9 @@ namespace array_filter {
transitioning javascript builtin transitioning javascript builtin
ArrayFilterLoopLazyDeoptContinuation( ArrayFilterLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, array: Object, initialK: Object, callback: JSAny, thisArg: JSAny, array: JSAny, initialK: JSAny,
length: Object, valueK: Object, initialTo: Object, length: JSAny, valueK: JSAny, initialTo: JSAny, result: JSAny): JSAny {
result: Object): Object {
// All continuation points in the optimized filter implementation are // All continuation points in the optimized filter implementation 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.
...@@ -60,9 +59,9 @@ namespace array_filter { ...@@ -60,9 +59,9 @@ namespace array_filter {
} }
transitioning builtin ArrayFilterLoopContinuation(implicit context: Context)( transitioning builtin ArrayFilterLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
array: JSReceiver, o: JSReceiver, initialK: Number, length: Number, array: JSReceiver, o: JSReceiver, initialK: Number, length: Number,
initialTo: Number): Object { initialTo: Number): JSAny {
let to: Number = initialTo; let to: Number = initialTo;
// 5. Let k be 0. // 5. Let k be 0.
// 6. Repeat, while k < len // 6. Repeat, while k < len
...@@ -77,10 +76,10 @@ namespace array_filter { ...@@ -77,10 +76,10 @@ namespace array_filter {
// 6c. If kPresent is true, then // 6c. If kPresent is true, then
if (kPresent == True) { if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk). // 6c. i. Let kValue be ? Get(O, Pk).
const kValue: Object = GetProperty(o, k); const kValue: JSAny = GetProperty(o, k);
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>). // 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
const result: Object = Call(context, callbackfn, thisArg, kValue, k, o); const result: JSAny = Call(context, callbackfn, thisArg, kValue, k, o);
// iii. If selected is true, then... // iii. If selected is true, then...
if (ToBoolean(result)) { if (ToBoolean(result)) {
...@@ -97,7 +96,7 @@ namespace array_filter { ...@@ -97,7 +96,7 @@ namespace array_filter {
} }
transitioning macro FastArrayFilter(implicit context: Context)( transitioning macro FastArrayFilter(implicit context: Context)(
fastO: FastJSArray, len: Smi, callbackfn: Callable, thisArg: Object, fastO: FastJSArray, len: Smi, callbackfn: Callable, thisArg: JSAny,
output: FastJSArray) labels Bailout(Number, Number) { output: FastJSArray) labels Bailout(Number, Number) {
let k: Smi = 0; let k: Smi = 0;
let to: Smi = 0; let to: Smi = 0;
...@@ -112,8 +111,8 @@ namespace array_filter { ...@@ -112,8 +111,8 @@ namespace array_filter {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k, to); if (k >= fastOW.Get().length) goto Bailout(k, to);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: JSAny = fastOW.LoadElementNoHole(k) otherwise continue;
const result: Object = const result: JSAny =
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
if (ToBoolean(result)) { if (ToBoolean(result)) {
try { try {
...@@ -147,8 +146,8 @@ namespace array_filter { ...@@ -147,8 +146,8 @@ namespace array_filter {
// https://tc39.github.io/ecma262/#sec-array.prototype.filter // https://tc39.github.io/ecma262/#sec-array.prototype.filter
transitioning javascript builtin transitioning javascript builtin
ArrayFilter(js-implicit context: Context, receiver: Object)(...arguments): ArrayFilter(js-implicit context: Context, receiver: JSAny)(...arguments):
Object { JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.filter'); RequireObjectCoercible(receiver, 'Array.prototype.filter');
...@@ -165,7 +164,7 @@ namespace array_filter { ...@@ -165,7 +164,7 @@ namespace array_filter {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError; const callbackfn = 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
let output: JSReceiver; let output: JSReceiver;
// Special cases. // Special cases.
......
...@@ -5,15 +5,14 @@ ...@@ -5,15 +5,14 @@
namespace array_find { namespace array_find {
transitioning javascript builtin transitioning javascript builtin
ArrayFindLoopEagerDeoptContinuation( ArrayFindLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
length: Object): Object {
// All continuation points in the optimized find implementation are // All continuation points in the optimized find implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -26,9 +25,9 @@ namespace array_find { ...@@ -26,9 +25,9 @@ namespace array_find {
transitioning javascript builtin transitioning javascript builtin
ArrayFindLoopLazyDeoptContinuation( ArrayFindLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
_callback: Object, _thisArg: Object, _initialK: Object, _length: Object, _callback: JSAny, _thisArg: JSAny, _initialK: JSAny, _length: JSAny,
_result: Object): Object { _result: JSAny): JSAny {
// This deopt continuation point is never actually called, it just // This deopt continuation point is never actually called, it just
// exists to make stack traces correct from a ThrowTypeError if the // exists to make stack traces correct from a ThrowTypeError if the
// callback was found to be non-callable. // callback was found to be non-callable.
...@@ -40,9 +39,9 @@ namespace array_find { ...@@ -40,9 +39,9 @@ namespace array_find {
// before iteration continues. // before iteration continues.
transitioning javascript builtin transitioning javascript builtin
ArrayFindLoopAfterCallbackLazyDeoptContinuation( ArrayFindLoopAfterCallbackLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, length: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
foundValue: Object, isFound: Object): Object { foundValue: JSAny, isFound: JSAny): JSAny {
// All continuation points in the optimized find implementation are // All continuation points in the optimized find implementation 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.
...@@ -65,8 +64,8 @@ namespace array_find { ...@@ -65,8 +64,8 @@ namespace array_find {
} }
transitioning builtin ArrayFindLoopContinuation(implicit context: Context)( transitioning builtin ArrayFindLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
o: JSReceiver, initialK: Number, length: Number): Object { o: JSReceiver, initialK: Number, length: Number): JSAny {
// 5. Let k be 0. // 5. Let k be 0.
// 6. Repeat, while k < len // 6. Repeat, while k < len
for (let k: Number = initialK; k < length; k++) { for (let k: Number = initialK; k < length; k++) {
...@@ -75,12 +74,11 @@ namespace array_find { ...@@ -75,12 +74,11 @@ namespace array_find {
// side-effect free and HasProperty/GetProperty do the conversion inline. // side-effect free and HasProperty/GetProperty do the conversion inline.
// 6b. i. Let kValue be ? Get(O, Pk). // 6b. i. Let kValue be ? Get(O, Pk).
const value: Object = GetProperty(o, k); const value: JSAny = GetProperty(o, k);
// 6c. Let testResult be ToBoolean(? Call(predicate, T, <<kValue, k, // 6c. Let testResult be ToBoolean(? Call(predicate, T, <<kValue, k,
// O>>)). // O>>)).
const testResult: Object = const testResult: JSAny = Call(context, callbackfn, thisArg, value, k, o);
Call(context, callbackfn, thisArg, value, k, o);
// 6d. If testResult is true, return kValue. // 6d. If testResult is true, return kValue.
if (ToBoolean(testResult)) { if (ToBoolean(testResult)) {
...@@ -93,7 +91,7 @@ namespace array_find { ...@@ -93,7 +91,7 @@ namespace array_find {
} }
transitioning macro FastArrayFind(implicit context: Context)( transitioning macro FastArrayFind(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: Object): Object o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): JSAny
labels Bailout(Smi) { labels Bailout(Smi) {
let k: Smi = 0; let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k); const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
...@@ -107,8 +105,8 @@ namespace array_find { ...@@ -107,8 +105,8 @@ namespace array_find {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k); if (k >= fastOW.Get().length) goto Bailout(k);
const value: Object = fastOW.LoadElementOrUndefined(k); const value: JSAny = fastOW.LoadElementOrUndefined(k);
const testResult: Object = const testResult: JSAny =
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
if (ToBoolean(testResult)) { if (ToBoolean(testResult)) {
return value; return value;
...@@ -119,8 +117,8 @@ namespace array_find { ...@@ -119,8 +117,8 @@ namespace array_find {
// https://tc39.github.io/ecma262/#sec-array.prototype.find // https://tc39.github.io/ecma262/#sec-array.prototype.find
transitioning javascript builtin transitioning javascript builtin
ArrayPrototypeFind(js-implicit context: Context, receiver: Object)( ArrayPrototypeFind(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.find'); RequireObjectCoercible(receiver, 'Array.prototype.find');
...@@ -138,7 +136,7 @@ namespace array_find { ...@@ -138,7 +136,7 @@ namespace array_find {
Cast<Callable>(arguments[0]) otherwise NotCallableError; Cast<Callable>(arguments[0]) otherwise NotCallableError;
// 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
// Special cases. // Special cases.
try { try {
......
...@@ -5,15 +5,14 @@ ...@@ -5,15 +5,14 @@
namespace array_findindex { namespace array_findindex {
transitioning javascript builtin transitioning javascript builtin
ArrayFindIndexLoopEagerDeoptContinuation( ArrayFindIndexLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
length: Object): Object {
// All continuation points in the optimized findIndex implementation are // All continuation points in the optimized findIndex implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -26,9 +25,9 @@ namespace array_findindex { ...@@ -26,9 +25,9 @@ namespace array_findindex {
transitioning javascript builtin transitioning javascript builtin
ArrayFindIndexLoopLazyDeoptContinuation( ArrayFindIndexLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
_callback: Object, _thisArg: Object, _initialK: Object, _length: Object, _callback: JSAny, _thisArg: JSAny, _initialK: JSAny, _length: JSAny,
_result: Object): Object { _result: JSAny): JSAny {
// This deopt continuation point is never actually called, it just // This deopt continuation point is never actually called, it just
// exists to make stack traces correct from a ThrowTypeError if the // exists to make stack traces correct from a ThrowTypeError if the
// callback was found to be non-callable. // callback was found to be non-callable.
...@@ -40,9 +39,9 @@ namespace array_findindex { ...@@ -40,9 +39,9 @@ namespace array_findindex {
// before iteration continues. // before iteration continues.
transitioning javascript builtin transitioning javascript builtin
ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation( ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, length: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
foundValue: Object, isFound: Object): Object { foundValue: JSAny, isFound: JSAny): JSAny {
// All continuation points in the optimized findIndex implementation are // All continuation points in the optimized findIndex implementation 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.
...@@ -66,7 +65,7 @@ namespace array_findindex { ...@@ -66,7 +65,7 @@ namespace array_findindex {
transitioning builtin ArrayFindIndexLoopContinuation(implicit context: transitioning builtin ArrayFindIndexLoopContinuation(implicit context:
Context)( Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
o: JSReceiver, initialK: Number, length: Number): Number { o: JSReceiver, initialK: Number, length: Number): Number {
// 5. Let k be 0. // 5. Let k be 0.
// 6. Repeat, while k < len // 6. Repeat, while k < len
...@@ -76,12 +75,11 @@ namespace array_findindex { ...@@ -76,12 +75,11 @@ namespace array_findindex {
// side-effect free and HasProperty/GetProperty do the conversion inline. // side-effect free and HasProperty/GetProperty do the conversion inline.
// 6b. i. Let kValue be ? Get(O, Pk). // 6b. i. Let kValue be ? Get(O, Pk).
const value: Object = GetProperty(o, k); const value: JSAny = GetProperty(o, k);
// 6c. Let testResult be ToBoolean(? Call(predicate, T, <<kValue, k, // 6c. Let testResult be ToBoolean(? Call(predicate, T, <<kValue, k,
// O>>)). // O>>)).
const testResult: Object = const testResult: JSAny = Call(context, callbackfn, thisArg, value, k, o);
Call(context, callbackfn, thisArg, value, k, o);
// 6d. If testResult is true, return k. // 6d. If testResult is true, return k.
if (ToBoolean(testResult)) { if (ToBoolean(testResult)) {
...@@ -94,7 +92,7 @@ namespace array_findindex { ...@@ -94,7 +92,7 @@ namespace array_findindex {
} }
transitioning macro FastArrayFindIndex(implicit context: Context)( transitioning macro FastArrayFindIndex(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: Object): Number o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): Number
labels Bailout(Smi) { labels Bailout(Smi) {
let k: Smi = 0; let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k); const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
...@@ -108,8 +106,8 @@ namespace array_findindex { ...@@ -108,8 +106,8 @@ namespace array_findindex {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k); if (k >= fastOW.Get().length) goto Bailout(k);
const value: Object = fastOW.LoadElementOrUndefined(k); const value: JSAny = fastOW.LoadElementOrUndefined(k);
const testResult: Object = const testResult: JSAny =
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
if (ToBoolean(testResult)) { if (ToBoolean(testResult)) {
return k; return k;
...@@ -120,8 +118,8 @@ namespace array_findindex { ...@@ -120,8 +118,8 @@ namespace array_findindex {
// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
transitioning javascript builtin transitioning javascript builtin
ArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)( ArrayPrototypeFindIndex(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.findIndex'); RequireObjectCoercible(receiver, 'Array.prototype.findIndex');
...@@ -139,7 +137,7 @@ namespace array_findindex { ...@@ -139,7 +137,7 @@ namespace array_findindex {
Cast<Callable>(arguments[0]) otherwise NotCallableError; Cast<Callable>(arguments[0]) otherwise NotCallableError;
// 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
// Special cases. // Special cases.
try { try {
......
...@@ -5,9 +5,8 @@ ...@@ -5,9 +5,8 @@
namespace array_foreach { namespace array_foreach {
transitioning javascript builtin transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation( ArrayForEachLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
length: Object): Object {
// All continuation points in the optimized forEach implemntation are // All continuation points in the optimized forEach implemntation 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.
...@@ -23,9 +22,9 @@ namespace array_foreach { ...@@ -23,9 +22,9 @@ namespace array_foreach {
transitioning javascript builtin transitioning javascript builtin
ArrayForEachLoopLazyDeoptContinuation( ArrayForEachLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, length: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
_result: Object): Object { _result: JSAny): JSAny {
// All continuation points in the optimized forEach implemntation are // All continuation points in the optimized forEach implemntation 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.
...@@ -40,9 +39,9 @@ namespace array_foreach { ...@@ -40,9 +39,9 @@ namespace array_foreach {
} }
transitioning builtin ArrayForEachLoopContinuation(implicit context: Context)( transitioning builtin ArrayForEachLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
_array: Object, o: JSReceiver, initialK: Number, len: Number, _array: JSAny, o: JSReceiver, initialK: Number, len: Number,
_to: Object): Object { _to: JSAny): JSAny {
// variables {array} and {to} are ignored. // variables {array} and {to} are ignored.
// 5. Let k be 0. // 5. Let k be 0.
...@@ -58,7 +57,7 @@ namespace array_foreach { ...@@ -58,7 +57,7 @@ namespace array_foreach {
// 6c. If kPresent is true, then // 6c. If kPresent is true, then
if (kPresent == True) { if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk). // 6c. i. Let kValue be ? Get(O, Pk).
const kValue: Object = GetProperty(o, k); const kValue: JSAny = GetProperty(o, k);
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>). // 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
Call(context, callbackfn, thisArg, kValue, k, o); Call(context, callbackfn, thisArg, kValue, k, o);
...@@ -70,7 +69,7 @@ namespace array_foreach { ...@@ -70,7 +69,7 @@ namespace array_foreach {
} }
transitioning macro FastArrayForEach(implicit context: Context)( transitioning macro FastArrayForEach(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: Object): Object o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): JSAny
labels Bailout(Smi) { labels Bailout(Smi) {
let k: Smi = 0; let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k); const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
...@@ -83,7 +82,7 @@ namespace array_foreach { ...@@ -83,7 +82,7 @@ namespace array_foreach {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k); if (k >= fastOW.Get().length) goto Bailout(k);
const value: Object = fastOW.LoadElementNoHole(k) const value: JSAny = fastOW.LoadElementNoHole(k)
otherwise continue; otherwise continue;
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
} }
...@@ -92,8 +91,8 @@ namespace array_foreach { ...@@ -92,8 +91,8 @@ namespace array_foreach {
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
transitioning javascript builtin transitioning javascript builtin
ArrayForEach(js-implicit context: Context, receiver: Object)(...arguments): ArrayForEach(js-implicit context: Context, receiver: JSAny)(...arguments):
Object { JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.forEach'); RequireObjectCoercible(receiver, 'Array.prototype.forEach');
...@@ -110,7 +109,7 @@ namespace array_foreach { ...@@ -110,7 +109,7 @@ namespace array_foreach {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError; const callbackfn = 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
// Special cases. // Special cases.
let k: Number = 0; let k: Number = 0;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
namespace array_join { namespace array_join {
type LoadJoinElementFn = builtin(Context, JSReceiver, Number) => Object; type LoadJoinElementFn = builtin(Context, JSReceiver, Number) => JSAny;
// Fast C call to write a fixed array (see Buffer.fixedArray) to a single // Fast C call to write a fixed array (see Buffer.fixedArray) to a single
// string. // string.
...@@ -12,12 +12,12 @@ namespace array_join { ...@@ -12,12 +12,12 @@ namespace array_join {
FixedArray, intptr, String, String): String; FixedArray, intptr, String, String): String;
transitioning builtin LoadJoinElement<T: type>( transitioning builtin LoadJoinElement<T: type>(
context: Context, receiver: JSReceiver, k: Number): Object { context: Context, receiver: JSReceiver, k: Number): JSAny {
return GetProperty(receiver, k); return GetProperty(receiver, k);
} }
transitioning LoadJoinElement<array::DictionaryElements>( transitioning LoadJoinElement<array::DictionaryElements>(
context: Context, receiver: JSReceiver, k: Number): Object { context: Context, receiver: JSReceiver, k: Number): JSAny {
const array: JSArray = UnsafeCast<JSArray>(receiver); const array: JSArray = UnsafeCast<JSArray>(receiver);
const dict: NumberDictionary = UnsafeCast<NumberDictionary>(array.elements); const dict: NumberDictionary = UnsafeCast<NumberDictionary>(array.elements);
try { try {
...@@ -33,15 +33,15 @@ namespace array_join { ...@@ -33,15 +33,15 @@ namespace array_join {
} }
LoadJoinElement<array::FastSmiOrObjectElements>( LoadJoinElement<array::FastSmiOrObjectElements>(
context: Context, receiver: JSReceiver, k: Number): Object { context: Context, receiver: JSReceiver, k: Number): JSAny {
const array: JSArray = UnsafeCast<JSArray>(receiver); const array: JSArray = UnsafeCast<JSArray>(receiver);
const fixedArray: FixedArray = UnsafeCast<FixedArray>(array.elements); const fixedArray: FixedArray = UnsafeCast<FixedArray>(array.elements);
const element: Object = fixedArray.objects[UnsafeCast<Smi>(k)]; const element: Object = fixedArray.objects[UnsafeCast<Smi>(k)];
return element == TheHole ? kEmptyString : element; return element == TheHole ? kEmptyString : UnsafeCast<JSAny>(element);
} }
LoadJoinElement<array::FastDoubleElements>( LoadJoinElement<array::FastDoubleElements>(
context: Context, receiver: JSReceiver, k: Number): Object { context: Context, receiver: JSReceiver, k: Number): JSAny {
const array: JSArray = UnsafeCast<JSArray>(receiver); const array: JSArray = UnsafeCast<JSArray>(receiver);
const fixedDoubleArray: FixedDoubleArray = const fixedDoubleArray: FixedDoubleArray =
UnsafeCast<FixedDoubleArray>(array.elements); UnsafeCast<FixedDoubleArray>(array.elements);
...@@ -51,7 +51,7 @@ namespace array_join { ...@@ -51,7 +51,7 @@ namespace array_join {
} }
builtin LoadJoinTypedElement<T: type>( builtin LoadJoinTypedElement<T: type>(
context: Context, receiver: JSReceiver, k: Number): Object { context: Context, receiver: JSReceiver, k: Number): JSAny {
const typedArray: JSTypedArray = UnsafeCast<JSTypedArray>(receiver); const typedArray: JSTypedArray = UnsafeCast<JSTypedArray>(receiver);
assert(!IsDetachedBuffer(typedArray.buffer)); assert(!IsDetachedBuffer(typedArray.buffer));
return typed_array::LoadFixedTypedArrayElementAsTagged( return typed_array::LoadFixedTypedArrayElementAsTagged(
...@@ -60,14 +60,14 @@ namespace array_join { ...@@ -60,14 +60,14 @@ namespace array_join {
} }
transitioning builtin ConvertToLocaleString( transitioning builtin ConvertToLocaleString(
context: Context, element: Object, locales: Object, context: Context, element: JSAny, locales: JSAny,
options: Object): String { options: JSAny): String {
if (IsNullOrUndefined(element)) return kEmptyString; if (IsNullOrUndefined(element)) return kEmptyString;
const prop: Object = GetProperty(element, 'toLocaleString'); const prop: JSAny = GetProperty(element, 'toLocaleString');
try { try {
const callable: Callable = Cast<Callable>(prop) otherwise TypeError; const callable: Callable = Cast<Callable>(prop) otherwise TypeError;
let result: Object; let result: JSAny;
if (IsNullOrUndefined(locales)) { if (IsNullOrUndefined(locales)) {
result = Call(context, callable, element); result = Call(context, callable, element);
} else if (IsNullOrUndefined(options)) { } else if (IsNullOrUndefined(options)) {
...@@ -257,7 +257,7 @@ namespace array_join { ...@@ -257,7 +257,7 @@ namespace array_join {
transitioning macro ArrayJoinImpl<T: type>(implicit context: Context)( transitioning macro ArrayJoinImpl<T: type>(implicit context: Context)(
receiver: JSReceiver, sep: String, lengthNumber: Number, receiver: JSReceiver, sep: String, lengthNumber: Number,
useToLocaleString: constexpr bool, locales: Object, options: Object, useToLocaleString: constexpr bool, locales: JSAny, options: JSAny,
initialLoadFn: LoadJoinElementFn): String { initialLoadFn: LoadJoinElementFn): String {
const initialMap: Map = receiver.map; const initialMap: Map = receiver.map;
const len: uintptr = Convert<uintptr>(lengthNumber); const len: uintptr = Convert<uintptr>(lengthNumber);
...@@ -283,7 +283,7 @@ namespace array_join { ...@@ -283,7 +283,7 @@ namespace array_join {
} }
// b. Let element be ? Get(O, ! ToString(k)). // b. Let element be ? Get(O, ! ToString(k)).
const element: Object = loadFn(context, receiver, Convert<Number>(k++)); const element: JSAny = loadFn(context, receiver, Convert<Number>(k++));
// c. If element is undefined or null, let next be the empty String; // c. If element is undefined or null, let next be the empty String;
// otherwise, let next be ? ToString(element). // otherwise, let next be ? ToString(element).
...@@ -300,7 +300,7 @@ namespace array_join { ...@@ -300,7 +300,7 @@ namespace array_join {
case (num: Number): { case (num: Number): {
next = NumberToString(num); next = NumberToString(num);
} }
case (obj: HeapObject): { case (obj: JSAny): {
if (IsNullOrUndefined(obj)) continue; if (IsNullOrUndefined(obj)) continue;
next = ToString(context, obj); next = ToString(context, obj);
} }
...@@ -321,11 +321,11 @@ namespace array_join { ...@@ -321,11 +321,11 @@ namespace array_join {
transitioning macro ArrayJoin<T: type>(implicit context: Context)( transitioning macro ArrayJoin<T: type>(implicit context: Context)(
useToLocaleString: constexpr bool, receiver: JSReceiver, sep: String, useToLocaleString: constexpr bool, receiver: JSReceiver, sep: String,
lenNumber: Number, locales: Object, options: Object): Object; lenNumber: Number, locales: JSAny, options: JSAny): JSAny;
transitioning ArrayJoin<JSArray>(implicit context: Context)( transitioning ArrayJoin<JSArray>(implicit context: Context)(
useToLocaleString: constexpr bool, receiver: JSReceiver, sep: String, useToLocaleString: constexpr bool, receiver: JSReceiver, sep: String,
lenNumber: Number, locales: Object, options: Object): Object { lenNumber: Number, locales: JSAny, options: JSAny): JSAny {
const map: Map = receiver.map; const map: Map = receiver.map;
const kind: ElementsKind = map.elements_kind; const kind: ElementsKind = map.elements_kind;
let loadFn: LoadJoinElementFn; let loadFn: LoadJoinElementFn;
...@@ -372,7 +372,7 @@ namespace array_join { ...@@ -372,7 +372,7 @@ namespace array_join {
transitioning ArrayJoin<JSTypedArray>(implicit context: Context)( transitioning ArrayJoin<JSTypedArray>(implicit context: Context)(
useToLocaleString: constexpr bool, receiver: JSReceiver, sep: String, useToLocaleString: constexpr bool, receiver: JSReceiver, sep: String,
lenNumber: Number, locales: Object, options: Object): Object { lenNumber: Number, locales: JSAny, options: JSAny): JSAny {
const map: Map = receiver.map; const map: Map = receiver.map;
const kind: ElementsKind = map.elements_kind; const kind: ElementsKind = map.elements_kind;
let loadFn: LoadJoinElementFn; let loadFn: LoadJoinElementFn;
...@@ -486,7 +486,7 @@ namespace array_join { ...@@ -486,7 +486,7 @@ namespace array_join {
// Removes a receiver from the stack. The FixedArray will automatically shrink // Removes a receiver from the stack. The FixedArray will automatically shrink
// to Heap::kMinJoinStackSize once the stack becomes empty. // to Heap::kMinJoinStackSize once the stack becomes empty.
builtin JoinStackPop(implicit context: Context)( builtin JoinStackPop(implicit context: Context)(
stack: FixedArray, receiver: JSReceiver): Object { stack: FixedArray, receiver: JSReceiver): JSAny {
const len: intptr = stack.length_intptr; const len: intptr = stack.length_intptr;
for (let i: intptr = 0; i < len; i++) { for (let i: intptr = 0; i < len; i++) {
if (stack.objects[i] == receiver) { if (stack.objects[i] == receiver) {
...@@ -526,7 +526,7 @@ namespace array_join { ...@@ -526,7 +526,7 @@ namespace array_join {
transitioning macro CycleProtectedArrayJoin<T: type>(implicit context: transitioning macro CycleProtectedArrayJoin<T: type>(implicit context:
Context)( Context)(
useToLocaleString: constexpr bool, o: JSReceiver, len: Number, useToLocaleString: constexpr bool, o: JSReceiver, len: Number,
sepObj: Object, locales: Object, options: Object): Object { sepObj: JSAny, locales: JSAny, options: JSAny): JSAny {
// 3. If separator is undefined, let sep be the single-element String ",". // 3. If separator is undefined, let sep be the single-element String ",".
// 4. Else, let sep be ? ToString(separator). // 4. Else, let sep be ? ToString(separator).
const sep: String = const sep: String =
...@@ -536,7 +536,7 @@ namespace array_join { ...@@ -536,7 +536,7 @@ namespace array_join {
// the normal join algorithm. // the normal join algorithm.
if (len > 0 && JoinStackPushInline(o)) { if (len > 0 && JoinStackPushInline(o)) {
try { try {
const result: Object = const result: JSAny =
ArrayJoin<T>(useToLocaleString, o, sep, len, locales, options); ArrayJoin<T>(useToLocaleString, o, sep, len, locales, options);
JoinStackPopInline(o); JoinStackPopInline(o);
return result; return result;
...@@ -551,9 +551,9 @@ namespace array_join { ...@@ -551,9 +551,9 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.join // https://tc39.github.io/ecma262/#sec-array.prototype.join
transitioning javascript builtin transitioning javascript builtin
ArrayPrototypeJoin(js-implicit context: Context, receiver: Object)( ArrayPrototypeJoin(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): JSAny {
const separator: Object = arguments[0]; const separator: JSAny = arguments[0];
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const o: JSReceiver = ToObject_Inline(context, receiver); const o: JSReceiver = ToObject_Inline(context, receiver);
...@@ -571,9 +571,9 @@ namespace array_join { ...@@ -571,9 +571,9 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.tolocalestring // https://tc39.github.io/ecma262/#sec-array.prototype.tolocalestring
transitioning javascript builtin ArrayPrototypeToLocaleString( transitioning javascript builtin ArrayPrototypeToLocaleString(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
const locales: Object = arguments[0]; const locales: JSAny = arguments[0];
const options: Object = arguments[1]; const options: JSAny = arguments[1];
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const o: JSReceiver = ToObject_Inline(context, receiver); const o: JSReceiver = ToObject_Inline(context, receiver);
...@@ -591,12 +591,12 @@ namespace array_join { ...@@ -591,12 +591,12 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.tostring // https://tc39.github.io/ecma262/#sec-array.prototype.tostring
transitioning javascript builtin ArrayPrototypeToString( transitioning javascript builtin ArrayPrototypeToString(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
// 1. Let array be ? ToObject(this value). // 1. Let array be ? ToObject(this value).
const array: JSReceiver = ToObject_Inline(context, receiver); const array: JSReceiver = ToObject_Inline(context, receiver);
// 2. Let func be ? Get(array, "join"). // 2. Let func be ? Get(array, "join").
const prop: Object = GetProperty(array, 'join'); const prop: JSAny = GetProperty(array, 'join');
try { try {
// 3. If IsCallable(func) is false, let func be the intrinsic function // 3. If IsCallable(func) is false, let func be the intrinsic function
// %ObjProto_toString%. // %ObjProto_toString%.
...@@ -612,8 +612,8 @@ namespace array_join { ...@@ -612,8 +612,8 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join
transitioning javascript builtin TypedArrayPrototypeJoin( transitioning javascript builtin TypedArrayPrototypeJoin(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
const separator: Object = arguments[0]; const separator: JSAny = arguments[0];
// Spec: ValidateTypedArray is applied to the this value prior to evaluating // Spec: ValidateTypedArray is applied to the this value prior to evaluating
// the algorithm. // the algorithm.
...@@ -627,9 +627,9 @@ namespace array_join { ...@@ -627,9 +627,9 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring
transitioning javascript builtin TypedArrayPrototypeToLocaleString( transitioning javascript builtin TypedArrayPrototypeToLocaleString(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
const locales: Object = arguments[0]; const locales: JSAny = arguments[0];
const options: Object = arguments[1]; const options: JSAny = arguments[1];
// Spec: ValidateTypedArray is applied to the this value prior to evaluating // Spec: ValidateTypedArray is applied to the this value prior to evaluating
// the algorithm. // the algorithm.
......
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
namespace array_lastindexof { namespace array_lastindexof {
macro LoadWithHoleCheck<Elements: type>( macro LoadWithHoleCheck<Elements: type>(
elements: FixedArrayBase, index: Smi): Object elements: FixedArrayBase, index: Smi): JSAny
labels IfHole; labels IfHole;
LoadWithHoleCheck<FixedArray>(implicit context: Context)( LoadWithHoleCheck<FixedArray>(implicit context: Context)(
elements: FixedArrayBase, index: Smi): Object elements: FixedArrayBase, index: Smi): JSAny
labels IfHole { labels IfHole {
const elements: FixedArray = UnsafeCast<FixedArray>(elements); const elements: FixedArray = UnsafeCast<FixedArray>(elements);
const element: Object = elements.objects[index]; const element: Object = elements.objects[index];
if (element == TheHole) goto IfHole; if (element == TheHole) goto IfHole;
return element; return UnsafeCast<JSAny>(element);
} }
LoadWithHoleCheck<FixedDoubleArray>(implicit context: Context)( LoadWithHoleCheck<FixedDoubleArray>(implicit context: Context)(
elements: FixedArrayBase, index: Smi): Object elements: FixedArrayBase, index: Smi): JSAny
labels IfHole { labels IfHole {
const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements); const elements: FixedDoubleArray = UnsafeCast<FixedDoubleArray>(elements);
const element: float64 = LoadDoubleWithHoleCheck(elements, index) const element: float64 = LoadDoubleWithHoleCheck(elements, index)
...@@ -26,7 +26,7 @@ namespace array_lastindexof { ...@@ -26,7 +26,7 @@ namespace array_lastindexof {
} }
macro FastArrayLastIndexOf<Elements: type>( macro FastArrayLastIndexOf<Elements: type>(
context: Context, array: JSArray, from: Smi, searchElement: Object): Smi { context: Context, array: JSArray, from: Smi, searchElement: JSAny): Smi {
const elements: FixedArrayBase = array.elements; const elements: FixedArrayBase = array.elements;
let k: Smi = from; let k: Smi = from;
...@@ -40,7 +40,7 @@ namespace array_lastindexof { ...@@ -40,7 +40,7 @@ namespace array_lastindexof {
while (k >= 0) { while (k >= 0) {
try { try {
const element: Object = LoadWithHoleCheck<Elements>(elements, k) const element: JSAny = LoadWithHoleCheck<Elements>(elements, k)
otherwise Hole; otherwise Hole;
const same: Boolean = StrictEqual(searchElement, element); const same: Boolean = StrictEqual(searchElement, element);
...@@ -80,8 +80,8 @@ namespace array_lastindexof { ...@@ -80,8 +80,8 @@ namespace array_lastindexof {
} }
macro TryFastArrayLastIndexOf( macro TryFastArrayLastIndexOf(
context: Context, receiver: JSReceiver, searchElement: Object, context: Context, receiver: JSReceiver, searchElement: JSAny,
from: Number): Object from: Number): JSAny
labels Slow { labels Slow {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow; const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
const length: Smi = array.length; const length: Smi = array.length;
...@@ -99,8 +99,8 @@ namespace array_lastindexof { ...@@ -99,8 +99,8 @@ namespace array_lastindexof {
} }
transitioning macro GenericArrayLastIndexOf( transitioning macro GenericArrayLastIndexOf(
context: Context, object: JSReceiver, searchElement: Object, context: Context, object: JSReceiver, searchElement: JSAny,
from: Number): Object { from: Number): JSAny {
let k: Number = from; let k: Number = from;
// 7. Repeat, while k >= 0. // 7. Repeat, while k >= 0.
...@@ -111,7 +111,7 @@ namespace array_lastindexof { ...@@ -111,7 +111,7 @@ namespace array_lastindexof {
// b. If kPresent is true, then. // b. If kPresent is true, then.
if (kPresent == True) { if (kPresent == True) {
// i. Let elementK be ? Get(O, ! ToString(k)). // i. Let elementK be ? Get(O, ! ToString(k)).
const element: Object = GetProperty(object, k); const element: JSAny = GetProperty(object, k);
// ii. Let same be the result of performing Strict Equality Comparison // ii. Let same be the result of performing Strict Equality Comparison
// searchElement === elementK. // searchElement === elementK.
...@@ -131,7 +131,7 @@ namespace array_lastindexof { ...@@ -131,7 +131,7 @@ namespace array_lastindexof {
// https://tc39.github.io/ecma262/#sec-array.prototype.lastIndexOf // https://tc39.github.io/ecma262/#sec-array.prototype.lastIndexOf
transitioning javascript builtin ArrayPrototypeLastIndexOf( transitioning javascript builtin ArrayPrototypeLastIndexOf(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver); const object: JSReceiver = ToObject_Inline(context, receiver);
...@@ -144,7 +144,7 @@ namespace array_lastindexof { ...@@ -144,7 +144,7 @@ namespace array_lastindexof {
// Step 4 - 6. // Step 4 - 6.
const from: Number = GetFromIndex(context, length, arguments); const from: Number = GetFromIndex(context, length, arguments);
const searchElement: Object = arguments[0]; const searchElement: JSAny = arguments[0];
try { try {
return TryFastArrayLastIndexOf(context, object, searchElement, from) return TryFastArrayLastIndexOf(context, object, searchElement, from)
......
...@@ -5,15 +5,15 @@ ...@@ -5,15 +5,15 @@
namespace array_map { namespace array_map {
transitioning javascript builtin transitioning javascript builtin
ArrayMapLoopEagerDeoptContinuation( ArrayMapLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, array: Object, initialK: Object, callback: JSAny, thisArg: JSAny, array: JSAny, initialK: JSAny,
length: Object): Object { length: JSAny): JSAny {
// All continuation points in the optimized filter implementation are // All continuation points in the optimized filter implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -28,9 +28,9 @@ namespace array_map { ...@@ -28,9 +28,9 @@ namespace array_map {
transitioning javascript builtin transitioning javascript builtin
ArrayMapLoopLazyDeoptContinuation( ArrayMapLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, array: Object, initialK: Object, callback: JSAny, thisArg: JSAny, array: JSAny, initialK: JSAny,
length: Object, result: Object): Object { length: JSAny, result: JSAny): JSAny {
// All continuation points in the optimized filter implementation are // All continuation points in the optimized filter implementation 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.
...@@ -57,9 +57,9 @@ namespace array_map { ...@@ -57,9 +57,9 @@ namespace array_map {
} }
transitioning builtin ArrayMapLoopContinuation(implicit context: Context)( transitioning builtin ArrayMapLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
array: JSReceiver, o: JSReceiver, initialK: Number, array: JSReceiver, o: JSReceiver, initialK: Number,
length: Number): Object { length: Number): JSAny {
// 6. Let k be 0. // 6. Let k be 0.
// 7. Repeat, while k < len // 7. Repeat, while k < len
for (let k: Number = initialK; k < length; k++) { for (let k: Number = initialK; k < length; k++) {
...@@ -73,10 +73,10 @@ namespace array_map { ...@@ -73,10 +73,10 @@ namespace array_map {
// 7c. If kPresent is true, then: // 7c. If kPresent is true, then:
if (kPresent == True) { if (kPresent == True) {
// i. Let kValue be ? Get(O, Pk). // i. Let kValue be ? Get(O, Pk).
const kValue: Object = GetProperty(o, k); const kValue: JSAny = GetProperty(o, k);
// ii. Let mapped_value be ? Call(callbackfn, T, kValue, k, O). // ii. Let mapped_value be ? Call(callbackfn, T, kValue, k, O).
const mappedValue: Object = const mappedValue: JSAny =
Call(context, callbackfn, thisArg, kValue, k, o); Call(context, callbackfn, thisArg, kValue, k, o);
// iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mapped_value). // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mapped_value).
...@@ -127,12 +127,12 @@ namespace array_map { ...@@ -127,12 +127,12 @@ namespace array_map {
SmiUntag(length), kAllowLargeObjectAllocation); SmiUntag(length), kAllowLargeObjectAllocation);
a = NewJSArray(map, this.fixedArray); a = NewJSArray(map, this.fixedArray);
for (let i: Smi = 0; i < validLength; i++) { for (let i: Smi = 0; i < validLength; i++) {
typeswitch (this.fixedArray.objects[i]) { typeswitch (
UnsafeCast<(Number | TheHole)>(this.fixedArray.objects[i])) {
case (n: Number): { case (n: Number): {
elements.floats[i] = Convert<float64>(n); elements.floats[i] = Convert<float64>(n);
} }
case (h: HeapObject): { case (TheHole): {
assert(h == TheHole);
} }
} }
} }
...@@ -147,7 +147,7 @@ namespace array_map { ...@@ -147,7 +147,7 @@ namespace array_map {
return a; return a;
} }
StoreResult(implicit context: Context)(index: Smi, result: Object) { StoreResult(implicit context: Context)(index: Smi, result: JSAny) {
typeswitch (result) { typeswitch (result) {
case (s: Smi): { case (s: Smi): {
this.fixedArray.objects[index] = s; this.fixedArray.objects[index] = s;
...@@ -156,7 +156,7 @@ namespace array_map { ...@@ -156,7 +156,7 @@ namespace array_map {
this.onlySmis = false; this.onlySmis = false;
this.fixedArray.objects[index] = s; this.fixedArray.objects[index] = s;
} }
case (s: HeapObject): { case (s: JSAnyNotNumber): {
this.onlySmis = false; this.onlySmis = false;
this.onlyNumbers = false; this.onlyNumbers = false;
this.fixedArray.objects[index] = s; this.fixedArray.objects[index] = s;
...@@ -185,7 +185,7 @@ namespace array_map { ...@@ -185,7 +185,7 @@ namespace array_map {
transitioning macro FastArrayMap(implicit context: Context)( transitioning macro FastArrayMap(implicit context: Context)(
fastO: FastJSArrayForRead, len: Smi, callbackfn: Callable, fastO: FastJSArrayForRead, len: Smi, callbackfn: Callable,
thisArg: Object): JSArray thisArg: JSAny): JSArray
labels Bailout(JSArray, Smi) { labels Bailout(JSArray, Smi) {
let k: Smi = 0; let k: Smi = 0;
let fastOW = NewFastJSArrayForReadWitness(fastO); let fastOW = NewFastJSArrayForReadWitness(fastO);
...@@ -201,9 +201,9 @@ namespace array_map { ...@@ -201,9 +201,9 @@ namespace array_map {
if (k >= fastOW.Get().length) goto PrepareBailout(k); if (k >= fastOW.Get().length) goto PrepareBailout(k);
try { try {
const value: Object = fastOW.LoadElementNoHole(k) const value: JSAny = fastOW.LoadElementNoHole(k)
otherwise FoundHole; otherwise FoundHole;
const result: Object = const result: JSAny =
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
vector.StoreResult(k, result); vector.StoreResult(k, result);
} }
...@@ -224,8 +224,7 @@ namespace array_map { ...@@ -224,8 +224,7 @@ namespace array_map {
// https://tc39.github.io/ecma262/#sec-array.prototype.map // https://tc39.github.io/ecma262/#sec-array.prototype.map
transitioning javascript builtin transitioning javascript builtin
ArrayMap(js-implicit context: Context, receiver: Object)(...arguments): ArrayMap(js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
Object {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.map'); RequireObjectCoercible(receiver, 'Array.prototype.map');
...@@ -241,7 +240,7 @@ namespace array_map { ...@@ -241,7 +240,7 @@ namespace array_map {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError; const callbackfn = 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
let array: JSReceiver; let array: JSReceiver;
let k: Number = 0; let k: Number = 0;
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
namespace array_of { namespace array_of {
// https://tc39.github.io/ecma262/#sec-array.of // https://tc39.github.io/ecma262/#sec-array.of
transitioning javascript builtin transitioning javascript builtin
ArrayOf(js-implicit context: Context, receiver: Object)(...arguments): ArrayOf(js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
Object {
// 1. Let len be the actual number of arguments passed to this function. // 1. Let len be the actual number of arguments passed to this function.
const len: Smi = Convert<Smi>(arguments.length); const len: Smi = Convert<Smi>(arguments.length);
...@@ -14,7 +13,7 @@ namespace array_of { ...@@ -14,7 +13,7 @@ namespace array_of {
const items: Arguments = arguments; const items: Arguments = arguments;
// 3. Let C be the this value. // 3. Let C be the this value.
const c: Object = receiver; const c: JSAny = receiver;
let a: JSReceiver; let a: JSReceiver;
...@@ -24,7 +23,7 @@ namespace array_of { ...@@ -24,7 +23,7 @@ namespace array_of {
// a. Let A be ? Construct(C, « len »). // a. Let A be ? Construct(C, « len »).
a = Construct(c, len); a = Construct(c, len);
} }
case (Object): { case (JSAny): {
// a. Let A be ? ArrayCreate(len). // a. Let A be ? ArrayCreate(len).
a = ArrayCreate(len); a = ArrayCreate(len);
} }
...@@ -36,7 +35,7 @@ namespace array_of { ...@@ -36,7 +35,7 @@ namespace array_of {
// 7. Repeat, while k < len // 7. Repeat, while k < len
while (k < len) { while (k < len) {
// a. Let kValue be items[k]. // a. Let kValue be items[k].
const kValue: Object = items[Convert<intptr>(k)]; const kValue: JSAny = items[Convert<intptr>(k)];
// b. Let Pk be ! ToString(k). // b. Let Pk be ! ToString(k).
// c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). // c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue).
......
...@@ -6,13 +6,13 @@ namespace array { ...@@ -6,13 +6,13 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRightPreLoopEagerDeoptContinuation( ArrayReduceRightPreLoopEagerDeoptContinuation(
js-implicit context: Context, js-implicit context: Context,
receiver: Object)(callback: Object, length: Object): Object { receiver: JSAny)(callback: JSAny, length: JSAny): JSAny {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -27,15 +27,15 @@ namespace array { ...@@ -27,15 +27,15 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRightLoopEagerDeoptContinuation( ArrayReduceRightLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, initialK: Object, length: Object, callback: JSAny, initialK: JSAny, length: JSAny,
accumulator: Object): Object { accumulator: JSAny): JSAny {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -48,9 +48,8 @@ namespace array { ...@@ -48,9 +48,8 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRightLoopLazyDeoptContinuation( ArrayReduceRightLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, initialK: Object, length: Object, callback: JSAny, initialK: JSAny, length: JSAny, result: JSAny): JSAny {
result: Object): Object {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
...@@ -67,8 +66,9 @@ namespace array { ...@@ -67,8 +66,9 @@ namespace array {
transitioning builtin ArrayReduceRightLoopContinuation(implicit context: transitioning builtin ArrayReduceRightLoopContinuation(implicit context:
Context)( Context)(
_receiver: JSReceiver, callbackfn: Callable, initialAccumulator: Object, _receiver: JSReceiver, callbackfn: Callable,
o: JSReceiver, initialK: Number, _length: Number): Object { initialAccumulator: JSAny | TheHole, o: JSReceiver, initialK: Number,
_length: Number): JSAny {
let accumulator = initialAccumulator; let accumulator = initialAccumulator;
// 8b and 9. Repeat, while k >= 0 // 8b and 9. Repeat, while k >= 0
...@@ -83,16 +83,20 @@ namespace array { ...@@ -83,16 +83,20 @@ namespace array {
// 8b iii and 9c. If kPresent is true, then // 8b iii and 9c. If kPresent is true, then
if (present == True) { if (present == True) {
// 8b iii and 9c i. Let kValue be ? Get(O, Pk). // 8b iii and 9c i. Let kValue be ? Get(O, Pk).
const value: Object = GetProperty(o, k); const value: JSAny = GetProperty(o, k);
if (accumulator == TheHole) { typeswitch (accumulator) {
// 8b iii 1. case (TheHole): {
accumulator = value; // 8b iii 1.
} else { accumulator = value;
// 9c. ii. Set accumulator to ? Call(callbackfn, undefined, }
// <accumulator, kValue, k, O>). case (accumulatorNotHole: JSAny): {
accumulator = // 9c. ii. Set accumulator to ? Call(callbackfn, undefined,
Call(context, callbackfn, Undefined, accumulator, value, k, o); // <accumulator, kValue, k, O>).
accumulator = Call(
context, callbackfn, Undefined, accumulatorNotHole, value, k,
o);
}
} }
} }
...@@ -102,16 +106,20 @@ namespace array { ...@@ -102,16 +106,20 @@ namespace array {
// 8c. if kPresent is false, throw a TypeError exception. // 8c. if kPresent is false, throw a TypeError exception.
// If the accumulator is discovered with the sentinel hole value, // If the accumulator is discovered with the sentinel hole value,
// this means kPresent is false. // this means kPresent is false.
if (accumulator == TheHole) { typeswitch (accumulator) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight'); case (TheHole): {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight');
}
case (accumulator: JSAny): {
return accumulator;
}
} }
return accumulator;
} }
transitioning macro FastArrayReduceRight(implicit context: Context)( transitioning macro FastArrayReduceRight(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, o: JSReceiver, len: Number, callbackfn: Callable,
initialAccumulator: Object): Object initialAccumulator: JSAny | TheHole): JSAny
labels Bailout(Number, Object) { labels Bailout(Number, JSAny | TheHole) {
let accumulator = initialAccumulator; let accumulator = initialAccumulator;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(len - 1, accumulator); const smiLen = Cast<Smi>(len) otherwise goto Bailout(len - 1, accumulator);
const fastO = Cast<FastJSArrayForRead>(o) const fastO = Cast<FastJSArrayForRead>(o)
...@@ -125,25 +133,32 @@ namespace array { ...@@ -125,25 +133,32 @@ namespace array {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k, accumulator); if (k >= fastOW.Get().length) goto Bailout(k, accumulator);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: JSAny = fastOW.LoadElementNoHole(k) otherwise continue;
if (accumulator == TheHole) { typeswitch (accumulator) {
accumulator = value; case (TheHole): {
} else { accumulator = value;
accumulator = Call( }
context, callbackfn, Undefined, accumulator, value, k, case (accumulatorNotHole: JSAny): {
fastOW.Get()); accumulator = Call(
context, callbackfn, Undefined, accumulatorNotHole, value, k,
fastOW.Get());
}
} }
} }
if (accumulator == TheHole) { typeswitch (accumulator) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight'); case (TheHole): {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduceRight');
}
case (accumulator: JSAny): {
return accumulator;
}
} }
return accumulator;
} }
// https://tc39.github.io/ecma262/#sec-array.prototype.reduceRight // https://tc39.github.io/ecma262/#sec-array.prototype.reduceRight
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRight(js-implicit context: Context, receiver: Object)( ArrayReduceRight(js-implicit context: Context, receiver: JSAny)(...arguments):
...arguments): Object { JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.reduceRight'); RequireObjectCoercible(receiver, 'Array.prototype.reduceRight');
...@@ -163,14 +178,14 @@ namespace array { ...@@ -163,14 +178,14 @@ namespace array {
// exception. (This case is handled at the end of // exception. (This case is handled at the end of
// ArrayReduceRightLoopContinuation). // ArrayReduceRightLoopContinuation).
const initialValue: Object = const initialValue: JSAny | TheHole =
arguments.length > 1 ? arguments[1] : TheHole; arguments.length > 1 ? arguments[1] : TheHole;
try { try {
return FastArrayReduceRight(o, len, callbackfn, initialValue) return FastArrayReduceRight(o, len, callbackfn, initialValue)
otherwise Bailout; otherwise Bailout;
} }
label Bailout(value: Number, accumulator: Object) { label Bailout(value: Number, accumulator: JSAny | TheHole) {
return ArrayReduceRightLoopContinuation( return ArrayReduceRightLoopContinuation(
o, callbackfn, accumulator, o, value, len); o, callbackfn, accumulator, o, value, len);
} }
......
...@@ -6,13 +6,13 @@ namespace array { ...@@ -6,13 +6,13 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReducePreLoopEagerDeoptContinuation( ArrayReducePreLoopEagerDeoptContinuation(
js-implicit context: Context, js-implicit context: Context,
receiver: Object)(callback: Object, length: Object): Object { receiver: JSAny)(callback: JSAny, length: JSAny): JSAny {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -27,15 +27,15 @@ namespace array { ...@@ -27,15 +27,15 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReduceLoopEagerDeoptContinuation( ArrayReduceLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, initialK: Object, length: Object, callback: JSAny, initialK: JSAny, length: JSAny,
accumulator: Object): Object { accumulator: JSAny): JSAny {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -48,9 +48,8 @@ namespace array { ...@@ -48,9 +48,8 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReduceLoopLazyDeoptContinuation( ArrayReduceLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, initialK: Object, length: Object, callback: JSAny, initialK: JSAny, length: JSAny, result: JSAny): JSAny {
result: Object): Object {
// All continuation points in the optimized every implementation are // All continuation points in the optimized every implementation 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.
...@@ -66,8 +65,9 @@ namespace array { ...@@ -66,8 +65,9 @@ namespace array {
} }
transitioning builtin ArrayReduceLoopContinuation(implicit context: Context)( transitioning builtin ArrayReduceLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, initialAccumulator: Object, _receiver: JSReceiver, callbackfn: Callable,
o: JSReceiver, initialK: Number, length: Number): Object { initialAccumulator: JSAny | TheHole, o: JSReceiver, initialK: Number,
length: Number): JSAny {
let accumulator = initialAccumulator; let accumulator = initialAccumulator;
// 8b and 9. Repeat, while k < len // 8b and 9. Repeat, while k < len
...@@ -82,16 +82,20 @@ namespace array { ...@@ -82,16 +82,20 @@ namespace array {
// 6c. If kPresent is true, then // 6c. If kPresent is true, then
if (present == True) { if (present == True) {
// 6c. i. Let kValue be ? Get(O, Pk). // 6c. i. Let kValue be ? Get(O, Pk).
const value: Object = GetProperty(o, k); const value: JSAny = GetProperty(o, k);
if (accumulator == TheHole) { typeswitch (accumulator) {
// 8b. case (TheHole): {
accumulator = value; // 8b.
} else { accumulator = value;
// 9c. ii. Set accumulator to ? Call(callbackfn, undefined, }
// <accumulator, kValue, k, O>). case (accumulatorNotHole: JSAny): {
accumulator = // 9c. ii. Set accumulator to ? Call(callbackfn, undefined,
Call(context, callbackfn, Undefined, accumulator, value, k, o); // <accumulator, kValue, k, O>).
accumulator = Call(
context, callbackfn, Undefined, accumulatorNotHole, value, k,
o);
}
} }
} }
...@@ -101,16 +105,20 @@ namespace array { ...@@ -101,16 +105,20 @@ namespace array {
// 8c. if kPresent is false, throw a TypeError exception. // 8c. if kPresent is false, throw a TypeError exception.
// If the accumulator is discovered with the sentinel hole value, // If the accumulator is discovered with the sentinel hole value,
// this means kPresent is false. // this means kPresent is false.
if (accumulator == TheHole) { typeswitch (accumulator) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce'); case (TheHole): {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce');
}
case (accumulator: JSAny): {
return accumulator;
}
} }
return accumulator;
} }
transitioning macro FastArrayReduce(implicit context: Context)( transitioning macro FastArrayReduce(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, o: JSReceiver, len: Number, callbackfn: Callable,
initialAccumulator: Object): Object initialAccumulator: JSAny | TheHole): JSAny
labels Bailout(Number, Object) { labels Bailout(Number, JSAny | TheHole) {
const k = 0; const k = 0;
let accumulator = initialAccumulator; let accumulator = initialAccumulator;
Cast<Smi>(len) otherwise goto Bailout(k, accumulator); Cast<Smi>(len) otherwise goto Bailout(k, accumulator);
...@@ -125,25 +133,32 @@ namespace array { ...@@ -125,25 +133,32 @@ namespace array {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k, accumulator); if (k >= fastOW.Get().length) goto Bailout(k, accumulator);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: JSAny = fastOW.LoadElementNoHole(k) otherwise continue;
if (accumulator == TheHole) { typeswitch (accumulator) {
accumulator = value; case (TheHole): {
} else { accumulator = value;
accumulator = Call( }
context, callbackfn, Undefined, accumulator, value, k, case (accumulatorNotHole: JSAny): {
fastOW.Get()); accumulator = Call(
context, callbackfn, Undefined, accumulatorNotHole, value, k,
fastOW.Get());
}
} }
} }
if (accumulator == TheHole) { typeswitch (accumulator) {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce'); case (TheHole): {
ThrowTypeError(kReduceNoInitial, 'Array.prototype.reduce');
}
case (accumulator: JSAny): {
return accumulator;
}
} }
return accumulator;
} }
// https://tc39.github.io/ecma262/#sec-array.prototype.reduce // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
transitioning javascript builtin transitioning javascript builtin
ArrayReduce(js-implicit context: Context, receiver: Object)(...arguments): ArrayReduce(js-implicit context: Context, receiver: JSAny)(...arguments):
Object { JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.reduce'); RequireObjectCoercible(receiver, 'Array.prototype.reduce');
...@@ -163,14 +178,14 @@ namespace array { ...@@ -163,14 +178,14 @@ namespace array {
// exception. (This case is handled at the end of // exception. (This case is handled at the end of
// ArrayReduceLoopContinuation). // ArrayReduceLoopContinuation).
const initialValue: Object = const initialValue: JSAny | TheHole =
arguments.length > 1 ? arguments[1] : TheHole; arguments.length > 1 ? arguments[1] : TheHole;
try { try {
return FastArrayReduce(o, len, callbackfn, initialValue) return FastArrayReduce(o, len, callbackfn, initialValue)
otherwise Bailout; otherwise Bailout;
} }
label Bailout(value: Number, accumulator: Object) { label Bailout(value: Number, accumulator: JSAny | TheHole) {
return ArrayReduceLoopContinuation( return ArrayReduceLoopContinuation(
o, callbackfn, accumulator, o, value, len); o, callbackfn, accumulator, o, value, len);
} }
......
...@@ -12,10 +12,10 @@ namespace array_reverse { ...@@ -12,10 +12,10 @@ namespace array_reverse {
return UnsafeCast<Smi>(elements.objects[index]); return UnsafeCast<Smi>(elements.objects[index]);
} }
LoadElement<array::FastPackedObjectElements, Object>( LoadElement<array::FastPackedObjectElements, JSAny>(
implicit context: Context)(elements: FixedArrayBase, index: Smi): Object { implicit context: Context)(elements: FixedArrayBase, index: Smi): JSAny {
const elements: FixedArray = UnsafeCast<FixedArray>(elements); const elements: FixedArray = UnsafeCast<FixedArray>(elements);
return elements.objects[index]; return UnsafeCast<JSAny>(elements.objects[index]);
} }
LoadElement<array::FastPackedDoubleElements, float64>( LoadElement<array::FastPackedDoubleElements, float64>(
...@@ -38,9 +38,9 @@ namespace array_reverse { ...@@ -38,9 +38,9 @@ namespace array_reverse {
StoreFixedArrayElement(elems, index, value, SKIP_WRITE_BARRIER); StoreFixedArrayElement(elems, index, value, SKIP_WRITE_BARRIER);
} }
StoreElement<array::FastPackedObjectElements, Object>( StoreElement<array::FastPackedObjectElements, JSAny>(
implicit context: implicit context:
Context)(elements: FixedArrayBase, index: Smi, value: Object) { Context)(elements: FixedArrayBase, index: Smi, value: JSAny) {
const elements: FixedArray = UnsafeCast<FixedArray>(elements); const elements: FixedArray = UnsafeCast<FixedArray>(elements);
elements.objects[index] = value; elements.objects[index] = value;
} }
...@@ -70,8 +70,8 @@ namespace array_reverse { ...@@ -70,8 +70,8 @@ namespace array_reverse {
} }
} }
transitioning macro GenericArrayReverse(context: Context, receiver: Object): transitioning macro GenericArrayReverse(context: Context, receiver: JSAny):
Object { JSAny {
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver); const object: JSReceiver = ToObject_Inline(context, receiver);
...@@ -89,8 +89,8 @@ namespace array_reverse { ...@@ -89,8 +89,8 @@ namespace array_reverse {
let upper: Number = length - 1; let upper: Number = length - 1;
while (lower < upper) { while (lower < upper) {
let lowerValue: Object = Undefined; let lowerValue: JSAny = Undefined;
let upperValue: Object = Undefined; let upperValue: JSAny = 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).
...@@ -142,7 +142,7 @@ namespace array_reverse { ...@@ -142,7 +142,7 @@ namespace array_reverse {
return object; return object;
} }
macro TryFastPackedArrayReverse(implicit context: Context)(receiver: Object) macro TryFastPackedArrayReverse(implicit context: Context)(receiver: JSAny)
labels Slow { labels Slow {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow; const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
...@@ -153,7 +153,7 @@ namespace array_reverse { ...@@ -153,7 +153,7 @@ namespace array_reverse {
array.elements, array.length); array.elements, array.length);
} else if (kind == PACKED_ELEMENTS) { } else if (kind == PACKED_ELEMENTS) {
array::EnsureWriteableFastElements(array); array::EnsureWriteableFastElements(array);
FastPackedArrayReverse<array::FastPackedObjectElements, Object>( FastPackedArrayReverse<array::FastPackedObjectElements, JSAny>(
array.elements, array.length); array.elements, array.length);
} else if (kind == PACKED_DOUBLE_ELEMENTS) { } else if (kind == PACKED_DOUBLE_ELEMENTS) {
FastPackedArrayReverse<array::FastPackedDoubleElements, float64>( FastPackedArrayReverse<array::FastPackedDoubleElements, float64>(
...@@ -165,7 +165,7 @@ namespace array_reverse { ...@@ -165,7 +165,7 @@ namespace array_reverse {
// https://tc39.github.io/ecma262/#sec-array.prototype.reverse // https://tc39.github.io/ecma262/#sec-array.prototype.reverse
transitioning javascript builtin ArrayPrototypeReverse( transitioning javascript builtin ArrayPrototypeReverse(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
try { try {
TryFastPackedArrayReverse(receiver) otherwise Baseline; TryFastPackedArrayReverse(receiver) otherwise Baseline;
return receiver; return receiver;
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
namespace array_shift { namespace array_shift {
extern builtin ArrayShift(Context, JSFunction, Object, int32): Object; extern builtin ArrayShift(Context, JSFunction, JSAny, int32): JSAny;
macro TryFastArrayShift(implicit context: Context)(receiver: Object): Object macro TryFastArrayShift(implicit context: Context)(receiver: JSAny): JSAny
labels Slow, Runtime { labels Slow, Runtime {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow; const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
let witness = NewFastJSArrayWitness(array); let witness = NewFastJSArrayWitness(array);
...@@ -37,7 +37,7 @@ namespace array_shift { ...@@ -37,7 +37,7 @@ namespace array_shift {
} }
transitioning macro GenericArrayShift(implicit context: transitioning macro GenericArrayShift(implicit context:
Context)(receiver: Object): Object { Context)(receiver: JSAny): JSAny {
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver); const object: JSReceiver = ToObject_Inline(context, receiver);
...@@ -70,7 +70,7 @@ namespace array_shift { ...@@ -70,7 +70,7 @@ namespace array_shift {
// d. If fromPresent is true, then // d. If fromPresent is true, then
if (fromPresent == True) { if (fromPresent == True) {
// i. Let fromVal be ? Get(O, from). // i. Let fromVal be ? Get(O, from).
const fromValue: Object = GetProperty(object, from); const fromValue: JSAny = GetProperty(object, from);
// ii. Perform ? Set(O, to, fromValue, true). // ii. Perform ? Set(O, to, fromValue, true).
SetProperty(object, to, fromValue); SetProperty(object, to, fromValue);
...@@ -95,7 +95,7 @@ namespace array_shift { ...@@ -95,7 +95,7 @@ namespace array_shift {
// https://tc39.github.io/ecma262/#sec-array.prototype.shift // https://tc39.github.io/ecma262/#sec-array.prototype.shift
transitioning javascript builtin ArrayPrototypeShift( transitioning javascript builtin ArrayPrototypeShift(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
try { try {
return TryFastArrayShift(receiver) otherwise Slow, Runtime; return TryFastArrayShift(receiver) otherwise Slow, Runtime;
} }
......
...@@ -63,9 +63,9 @@ namespace array_slice { ...@@ -63,9 +63,9 @@ namespace array_slice {
for (let current: Smi = start; current < to; ++current) { for (let current: Smi = start; current < to; ++current) {
const e: Object = const e: Object =
sloppyElements.objects[current + kSloppyArgumentsParameterMapStart]; sloppyElements.objects[current + kSloppyArgumentsParameterMapStart];
const newElement: Object = e != TheHole ? const newElement: JSAny = UnsafeCast<JSAny>(
argumentsContext[UnsafeCast<Smi>(e)] : e != TheHole ? argumentsContext[UnsafeCast<Smi>(e)] :
unmappedElements.objects[current]; unmappedElements.objects[current]);
// It is safe to skip the write barrier here because resultElements was // It is safe to skip the write barrier here because resultElements was
// allocated together with result in a folded allocation. // allocated together with result in a folded allocation.
// TODO(tebbi): The verification of this fails at the moment due to // TODO(tebbi): The verification of this fails at the moment due to
...@@ -86,7 +86,7 @@ namespace array_slice { ...@@ -86,7 +86,7 @@ namespace array_slice {
} }
macro HandleFastSlice( macro HandleFastSlice(
context: Context, o: Object, startNumber: Number, context: Context, o: JSAny, startNumber: Number,
countNumber: Number): JSArray countNumber: Number): JSArray
labels Bailout { labels Bailout {
const start: Smi = Cast<Smi>(startNumber) otherwise Bailout; const start: Smi = Cast<Smi>(startNumber) otherwise Bailout;
...@@ -114,7 +114,7 @@ namespace array_slice { ...@@ -114,7 +114,7 @@ namespace array_slice {
otherwise Bailout; otherwise Bailout;
} }
} }
case (Object): { case (JSAny): {
} }
} }
goto Bailout; goto Bailout;
...@@ -122,15 +122,15 @@ namespace array_slice { ...@@ -122,15 +122,15 @@ namespace array_slice {
// https://tc39.github.io/ecma262/#sec-array.prototype.slice // https://tc39.github.io/ecma262/#sec-array.prototype.slice
transitioning javascript builtin transitioning javascript builtin
ArrayPrototypeSlice(js-implicit context: Context, receiver: Object)( ArrayPrototypeSlice(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): JSAny {
// Handle array cloning case if the receiver is a fast array. // Handle array cloning case if the receiver is a fast array.
if (arguments.length == 0) { if (arguments.length == 0) {
typeswitch (receiver) { typeswitch (receiver) {
case (a: FastJSArrayForCopy): { case (a: FastJSArrayForCopy): {
return CloneFastJSArray(context, a); return CloneFastJSArray(context, a);
} }
case (Object): { case (JSAny): {
} }
} }
} }
...@@ -142,7 +142,7 @@ namespace array_slice { ...@@ -142,7 +142,7 @@ namespace array_slice {
const len: Number = GetLengthProperty(o); const len: Number = GetLengthProperty(o);
// 3. Let relativeStart be ? ToInteger(start). // 3. Let relativeStart be ? ToInteger(start).
const start: Object = arguments[0]; const start: JSAny = arguments[0];
const relativeStart: Number = ToInteger_Inline(context, start); const relativeStart: Number = ToInteger_Inline(context, start);
// 4. If relativeStart < 0, let k be max((len + relativeStart), 0); // 4. If relativeStart < 0, let k be max((len + relativeStart), 0);
...@@ -152,7 +152,7 @@ namespace array_slice { ...@@ -152,7 +152,7 @@ namespace array_slice {
// 5. If end is undefined, let relativeEnd be len; // 5. If end is undefined, let relativeEnd be len;
// else let relativeEnd be ? ToInteger(end). // else let relativeEnd be ? ToInteger(end).
const end: Object = arguments[1]; const end: JSAny = arguments[1];
const relativeEnd: Number = const relativeEnd: Number =
end == Undefined ? len : ToInteger_Inline(context, end); end == Undefined ? len : ToInteger_Inline(context, end);
...@@ -193,7 +193,7 @@ namespace array_slice { ...@@ -193,7 +193,7 @@ namespace array_slice {
// c. If kPresent is true, then // c. If kPresent is true, then
if (fromPresent == True) { if (fromPresent == True) {
// i. Let kValue be ? Get(O, Pk). // i. Let kValue be ? Get(O, Pk).
const kValue: Object = GetProperty(o, pK); const kValue: JSAny = GetProperty(o, pK);
// ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), kValue). // ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), kValue).
FastCreateDataProperty(a, n, kValue); FastCreateDataProperty(a, n, kValue);
......
...@@ -5,15 +5,14 @@ ...@@ -5,15 +5,14 @@
namespace array { namespace array {
transitioning javascript builtin transitioning javascript builtin
ArraySomeLoopEagerDeoptContinuation( ArraySomeLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny): JSAny {
length: Object): Object {
// All continuation points in the optimized some implementation are // All continuation points in the optimized some implementation 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.
// //
// Also, this great mass of casts is necessary because the signature // Also, this great mass of casts is necessary because the signature
// of Torque javascript builtins requires Object type for all parameters // of Torque javascript builtins requires JSAny type for all parameters
// other than {context}. // other than {context}.
const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable; const jsreceiver = Cast<JSReceiver>(receiver) otherwise unreachable;
const callbackfn = Cast<Callable>(callback) otherwise unreachable; const callbackfn = Cast<Callable>(callback) otherwise unreachable;
...@@ -27,9 +26,9 @@ namespace array { ...@@ -27,9 +26,9 @@ namespace array {
transitioning javascript builtin transitioning javascript builtin
ArraySomeLoopLazyDeoptContinuation( ArraySomeLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)( js-implicit context: Context, receiver: JSAny)(
callback: Object, thisArg: Object, initialK: Object, length: Object, callback: JSAny, thisArg: JSAny, initialK: JSAny, length: JSAny,
result: Object): Object { result: JSAny): JSAny {
// All continuation points in the optimized some implementation are // All continuation points in the optimized some implementation 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.
...@@ -53,9 +52,9 @@ namespace array { ...@@ -53,9 +52,9 @@ namespace array {
} }
transitioning builtin ArraySomeLoopContinuation(implicit context: Context)( transitioning builtin ArraySomeLoopContinuation(implicit context: Context)(
_receiver: JSReceiver, callbackfn: Callable, thisArg: Object, _receiver: JSReceiver, callbackfn: Callable, thisArg: JSAny,
_array: Object, o: JSReceiver, initialK: Number, length: Number, _array: JSAny, o: JSReceiver, initialK: Number, length: Number,
_initialTo: Object): Object { _initialTo: JSAny): JSAny {
// 5. Let k be 0. // 5. Let k be 0.
// 6. Repeat, while k < len // 6. Repeat, while k < len
for (let k: Number = initialK; k < length; k++) { for (let k: Number = initialK; k < length; k++) {
...@@ -69,10 +68,10 @@ namespace array { ...@@ -69,10 +68,10 @@ namespace array {
// 6c. If kPresent is true, then // 6c. If kPresent is true, then
if (kPresent == True) { if (kPresent == True) {
// 6c. i. Let kValue be ? Get(O, Pk). // 6c. i. Let kValue be ? Get(O, Pk).
const kValue: Object = GetProperty(o, k); const kValue: JSAny = GetProperty(o, k);
// 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>). // 6c. ii. Perform ? Call(callbackfn, T, <kValue, k, O>).
const result: Object = Call(context, callbackfn, thisArg, kValue, k, o); const result: JSAny = Call(context, callbackfn, thisArg, kValue, k, o);
// iii. If selected is true, then... // iii. If selected is true, then...
if (ToBoolean(result)) { if (ToBoolean(result)) {
...@@ -86,7 +85,7 @@ namespace array { ...@@ -86,7 +85,7 @@ namespace array {
} }
transitioning macro FastArraySome(implicit context: Context)( transitioning macro FastArraySome(implicit context: Context)(
o: JSReceiver, len: Number, callbackfn: Callable, thisArg: Object): Object o: JSReceiver, len: Number, callbackfn: Callable, thisArg: JSAny): JSAny
labels Bailout(Smi) { labels Bailout(Smi) {
let k: Smi = 0; let k: Smi = 0;
const smiLen = Cast<Smi>(len) otherwise goto Bailout(k); const smiLen = Cast<Smi>(len) otherwise goto Bailout(k);
...@@ -99,8 +98,8 @@ namespace array { ...@@ -99,8 +98,8 @@ namespace array {
// Ensure that we haven't walked beyond a possibly updated length. // Ensure that we haven't walked beyond a possibly updated length.
if (k >= fastOW.Get().length) goto Bailout(k); if (k >= fastOW.Get().length) goto Bailout(k);
const value: Object = fastOW.LoadElementNoHole(k) otherwise continue; const value: JSAny = fastOW.LoadElementNoHole(k) otherwise continue;
const result: Object = const result: JSAny =
Call(context, callbackfn, thisArg, value, k, fastOW.Get()); Call(context, callbackfn, thisArg, value, k, fastOW.Get());
if (ToBoolean(result)) { if (ToBoolean(result)) {
return True; return True;
...@@ -111,8 +110,8 @@ namespace array { ...@@ -111,8 +110,8 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.some // https://tc39.github.io/ecma262/#sec-array.prototype.some
transitioning javascript builtin transitioning javascript builtin
ArraySome(js-implicit context: Context, receiver: Object)(...arguments): ArraySome(js-implicit context: Context, receiver: JSAny)(...arguments):
Object { JSAny {
try { try {
RequireObjectCoercible(receiver, 'Array.prototype.some'); RequireObjectCoercible(receiver, 'Array.prototype.some');
...@@ -129,7 +128,7 @@ namespace array { ...@@ -129,7 +128,7 @@ namespace array {
const callbackfn = Cast<Callable>(arguments[0]) otherwise TypeError; const callbackfn = 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: JSAny = arguments.length > 1 ? arguments[1] : Undefined;
// Special cases. // Special cases.
try { try {
......
...@@ -95,7 +95,7 @@ namespace array_splice { ...@@ -95,7 +95,7 @@ namespace array_splice {
const typedNewElements: FixedArrayType = const typedNewElements: FixedArrayType =
UnsafeCast<FixedArrayType>(a.elements); UnsafeCast<FixedArrayType>(a.elements);
for (let i: intptr = 2; i < args.length; ++i) { for (let i: intptr = 2; i < args.length; ++i) {
const e: Object = args[i]; const e: JSAny = args[i];
// 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++] = UnsafeCast<ElementType>(e); typedNewElements[k++] = UnsafeCast<ElementType>(e);
...@@ -109,7 +109,7 @@ namespace array_splice { ...@@ -109,7 +109,7 @@ namespace array_splice {
transitioning macro FastArraySplice( transitioning macro FastArraySplice(
context: Context, args: Arguments, o: JSReceiver, context: Context, args: Arguments, o: JSReceiver,
originalLengthNumber: Number, actualStartNumber: Number, insertCount: Smi, originalLengthNumber: Number, actualStartNumber: Number, insertCount: Smi,
actualDeleteCountNumber: Number): Object actualDeleteCountNumber: Number): JSAny
labels Bailout { labels Bailout {
const originalLength: Smi = const originalLength: Smi =
Cast<Smi>(originalLengthNumber) otherwise Bailout; Cast<Smi>(originalLengthNumber) otherwise Bailout;
...@@ -132,7 +132,7 @@ namespace array_splice { ...@@ -132,7 +132,7 @@ namespace array_splice {
const oldElementsKind: ElementsKind = elementsKind; const oldElementsKind: ElementsKind = elementsKind;
for (let i: intptr = 2; i < args.length; ++i) { for (let i: intptr = 2; i < args.length; ++i) {
const e: Object = args[i]; const e: JSAny = args[i];
if (IsFastSmiElementsKind(elementsKind)) { if (IsFastSmiElementsKind(elementsKind)) {
if (TaggedIsNotSmi(e)) { if (TaggedIsNotSmi(e)) {
const heapObject: HeapObject = UnsafeCast<HeapObject>(e); const heapObject: HeapObject = UnsafeCast<HeapObject>(e);
...@@ -166,7 +166,7 @@ namespace array_splice { ...@@ -166,7 +166,7 @@ namespace array_splice {
} }
if (IsFastSmiOrTaggedElementsKind(elementsKind)) { if (IsFastSmiOrTaggedElementsKind(elementsKind)) {
FastSplice<FixedArray, Object>( FastSplice<FixedArray, JSAny>(
args, a, length, newLength, actualStart, insertCount, args, a, length, newLength, actualStart, insertCount,
actualDeleteCount); actualDeleteCount);
} else { } else {
...@@ -180,7 +180,7 @@ namespace array_splice { ...@@ -180,7 +180,7 @@ namespace array_splice {
transitioning macro FillDeletedElementsArray( transitioning macro FillDeletedElementsArray(
context: Context, o: JSReceiver, actualStart: Number, context: Context, o: JSReceiver, actualStart: Number,
actualDeleteCount: Number, a: JSReceiver): Object { actualDeleteCount: Number, a: JSReceiver): JSAny {
// 10. Let k be 0. // 10. Let k be 0.
let k: Number = 0; let k: Number = 0;
...@@ -195,7 +195,7 @@ namespace array_splice { ...@@ -195,7 +195,7 @@ namespace array_splice {
// c. If fromPresent is true, then // c. If fromPresent is true, then
if (fromPresent == True) { if (fromPresent == True) {
// i. Let fromValue be ? Get(O, from). // i. Let fromValue be ? Get(O, from).
const fromValue: Object = GetProperty(o, from); const fromValue: JSAny = GetProperty(o, from);
// ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). // ii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(k), fromValue).
FastCreateDataProperty(a, k, fromValue); FastCreateDataProperty(a, k, fromValue);
...@@ -231,7 +231,7 @@ namespace array_splice { ...@@ -231,7 +231,7 @@ namespace array_splice {
// iv. If fromPresent is true, then // iv. If fromPresent is true, then
if (fromPresent == True) { if (fromPresent == True) {
// 1. Let fromValue be ? Get(O, from). // 1. Let fromValue be ? Get(O, from).
const fromValue: Object = GetProperty(o, from); const fromValue: JSAny = GetProperty(o, from);
// 2. Perform ? Set(O, to, fromValue, true). // 2. Perform ? Set(O, to, fromValue, true).
SetProperty(o, to, fromValue); SetProperty(o, to, fromValue);
...@@ -280,7 +280,7 @@ namespace array_splice { ...@@ -280,7 +280,7 @@ namespace array_splice {
// iv. If fromPresent is true, then // iv. If fromPresent is true, then
if (fromPresent == True) { if (fromPresent == True) {
// 1. Let fromValue be ? Get(O, from). // 1. Let fromValue be ? Get(O, from).
const fromValue: Object = GetProperty(o, from); const fromValue: JSAny = GetProperty(o, from);
// 2. Perform ? Set(O, to, fromValue, true). // 2. Perform ? Set(O, to, fromValue, true).
SetProperty(o, to, fromValue); SetProperty(o, to, fromValue);
...@@ -298,8 +298,7 @@ namespace array_splice { ...@@ -298,8 +298,7 @@ namespace array_splice {
transitioning macro SlowSplice( transitioning macro SlowSplice(
context: Context, arguments: Arguments, o: JSReceiver, len: Number, context: Context, arguments: Arguments, o: JSReceiver, len: Number,
actualStart: Number, insertCount: Smi, actualStart: Number, insertCount: Smi, actualDeleteCount: Number): JSAny {
actualDeleteCount: Number): Object {
// 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). // 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount).
const a: JSReceiver = ArraySpeciesCreate(context, o, actualDeleteCount); const a: JSReceiver = ArraySpeciesCreate(context, o, actualDeleteCount);
const itemCount: Number = insertCount; const itemCount: Number = insertCount;
...@@ -332,7 +331,7 @@ namespace array_splice { ...@@ -332,7 +331,7 @@ namespace array_splice {
// element. // element.
if (arguments.length > 2) { if (arguments.length > 2) {
for (let i: intptr = 2; i < arguments.length; ++i) { for (let i: intptr = 2; i < arguments.length; ++i) {
const e: Object = arguments[i]; const e: JSAny = arguments[i];
// b. Perform ? Set(O, ! ToString(k), E, true). // b. Perform ? Set(O, ! ToString(k), E, true).
SetProperty(o, k, e); SetProperty(o, k, e);
...@@ -350,8 +349,8 @@ namespace array_splice { ...@@ -350,8 +349,8 @@ namespace array_splice {
// https://tc39.github.io/ecma262/#sec-array.prototype.splice // https://tc39.github.io/ecma262/#sec-array.prototype.splice
transitioning javascript builtin transitioning javascript builtin
ArrayPrototypeSplice(js-implicit context: Context, receiver: Object)( ArrayPrototypeSplice(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): JSAny {
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const o: JSReceiver = ToObject(context, receiver); const o: JSReceiver = ToObject(context, receiver);
...@@ -359,7 +358,7 @@ namespace array_splice { ...@@ -359,7 +358,7 @@ namespace array_splice {
const len: Number = GetLengthProperty(o); const len: Number = GetLengthProperty(o);
// 3. Let relativeStart be ? ToInteger(start). // 3. Let relativeStart be ? ToInteger(start).
const start: Object = arguments[0]; const start: JSAny = arguments[0];
const relativeStart: Number = ToInteger_Inline(context, start); const relativeStart: Number = ToInteger_Inline(context, start);
// 4. If relativeStart < 0, let actualStart be max((len + relativeStart), // 4. If relativeStart < 0, let actualStart be max((len + relativeStart),
...@@ -388,7 +387,7 @@ namespace array_splice { ...@@ -388,7 +387,7 @@ namespace array_splice {
// 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: JSAny = 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);
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
namespace array_unshift { namespace array_unshift {
extern builtin ArrayUnshift(Context, JSFunction, Object, int32): Object; extern builtin ArrayUnshift(Context, JSFunction, JSAny, int32): JSAny;
transitioning macro GenericArrayUnshift( transitioning macro GenericArrayUnshift(
context: Context, receiver: Object, arguments: Arguments): Number { context: Context, receiver: JSAny, arguments: Arguments): Number {
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver); const object: JSReceiver = ToObject_Inline(context, receiver);
...@@ -40,7 +40,7 @@ namespace array_unshift { ...@@ -40,7 +40,7 @@ namespace array_unshift {
// iv. If fromPresent is true, then // iv. If fromPresent is true, then
if (fromPresent == True) { if (fromPresent == True) {
// 1. Let fromValue be ? Get(O, from). // 1. Let fromValue be ? Get(O, from).
const fromValue: Object = GetProperty(object, from); const fromValue: JSAny = GetProperty(object, from);
// 2. Perform ? Set(O, to, fromValue, true). // 2. Perform ? Set(O, to, fromValue, true).
SetProperty(object, to, fromValue); SetProperty(object, to, fromValue);
...@@ -78,7 +78,7 @@ namespace array_unshift { ...@@ -78,7 +78,7 @@ namespace array_unshift {
// https://tc39.github.io/ecma262/#sec-array.prototype.unshift // https://tc39.github.io/ecma262/#sec-array.prototype.unshift
transitioning javascript builtin ArrayPrototypeUnshift( transitioning javascript builtin ArrayPrototypeUnshift(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
try { try {
const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow; const array: FastJSArray = Cast<FastJSArray>(receiver) otherwise Slow;
array::EnsureWriteableFastElements(array); array::EnsureWriteableFastElements(array);
......
...@@ -32,30 +32,15 @@ namespace array { ...@@ -32,30 +32,15 @@ namespace array {
assert(array.elements.map != kCOWMap); assert(array.elements.map != kCOWMap);
} }
macro IsJSArray(implicit context: Context)(o: Object): bool { macro LoadElementOrUndefined(implicit context:
typeswitch (o) { Context)(a: FixedArray, i: Smi): JSAny {
case (JSArray): { const e = UnsafeCast<(JSAny | TheHole)>(a.objects[i]);
return true; return ReplaceTheHoleWithUndefined(e);
}
case (Object): {
return false;
}
}
}
macro LoadElementOrUndefined(a: FixedArray, i: Smi): Object {
const e: Object = a.objects[i];
return e == TheHole ? Undefined : e;
} }
macro LoadElementOrUndefined(a: FixedDoubleArray, i: Smi): NumberOrUndefined { macro LoadElementOrUndefined(a: FixedDoubleArray, i: Smi): NumberOrUndefined {
try { const f: float64 = LoadDoubleWithHoleCheck(a, i) otherwise return Undefined;
const f: float64 = LoadDoubleWithHoleCheck(a, i) otherwise IfHole; return AllocateHeapNumberWithValue(f);
return AllocateHeapNumberWithValue(f);
}
label IfHole {
return Undefined;
}
} }
macro StoreArrayHole(elements: FixedDoubleArray, k: Smi): void { macro StoreArrayHole(elements: FixedDoubleArray, k: Smi): void {
...@@ -66,5 +51,5 @@ namespace array { ...@@ -66,5 +51,5 @@ namespace array {
elements.objects[k] = TheHole; elements.objects[k] = TheHole;
} }
extern macro SetPropertyLength(implicit context: Context)(Object, Number); extern macro SetPropertyLength(implicit context: Context)(JSAny, Number);
} }
This diff is collapsed.
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
namespace boolean { namespace boolean {
javascript builtin javascript builtin
BooleanConstructor( BooleanConstructor(
js-implicit context: Context, receiver: Object, newTarget: Object, js-implicit context: Context, receiver: JSAny, newTarget: JSAny,
target: JSFunction)(...arguments): Object { target: JSFunction)(...arguments): JSAny {
const value = SelectBooleanConstant(ToBoolean(arguments[0])); const value = SelectBooleanConstant(ToBoolean(arguments[0]));
if (newTarget == Undefined) { if (newTarget == Undefined) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace collections { namespace collections {
@export @export
macro LoadKeyValuePairNoSideEffects(implicit context: Context)(o: Object): macro LoadKeyValuePairNoSideEffects(implicit context: Context)(o: JSAny):
KeyValuePair labels MayHaveSideEffects { KeyValuePair labels MayHaveSideEffects {
typeswitch (o) { typeswitch (o) {
case (a: FastJSArray): { case (a: FastJSArray): {
...@@ -28,7 +28,7 @@ namespace collections { ...@@ -28,7 +28,7 @@ namespace collections {
Undefined Undefined
}; };
} }
case (Object): deferred { case (FixedArrayBase): deferred {
unreachable; unreachable;
} }
} }
...@@ -36,14 +36,14 @@ namespace collections { ...@@ -36,14 +36,14 @@ namespace collections {
case (JSReceiver): { case (JSReceiver): {
goto MayHaveSideEffects; goto MayHaveSideEffects;
} }
case (o: Object): deferred { case (o: JSAny): deferred {
ThrowTypeError(kIteratorValueNotAnObject, o); ThrowTypeError(kIteratorValueNotAnObject, o);
} }
} }
} }
@export @export
transitioning macro LoadKeyValuePair(implicit context: Context)(o: Object): transitioning macro LoadKeyValuePair(implicit context: Context)(o: JSAny):
KeyValuePair { KeyValuePair {
try { try {
return LoadKeyValuePairNoSideEffects(o) otherwise Generic; return LoadKeyValuePairNoSideEffects(o) otherwise Generic;
......
This diff is collapsed.
...@@ -3,23 +3,22 @@ ...@@ -3,23 +3,22 @@
// found in the LICENSE file. // found in the LICENSE file.
namespace extras_utils { namespace extras_utils {
extern runtime CreatePrivateSymbol(Context, Object): HeapObject; extern runtime CreatePrivateSymbol(Context, JSAny): HeapObject;
extern runtime PromiseMarkAsHandled(Context, Object): Undefined; extern runtime PromiseMarkAsHandled(Context, JSAny): Undefined;
extern runtime PromiseStatus(Context, Object): Smi; extern runtime PromiseStatus(Context, JSAny): Smi;
javascript builtin ExtrasUtilsCreatePrivateSymbol( javascript builtin ExtrasUtilsCreatePrivateSymbol(
js-implicit context: Context, js-implicit context: Context, receiver: JSAny)(...arguments): HeapObject {
receiver: Object)(...arguments): HeapObject {
return CreatePrivateSymbol(context, arguments[0]); return CreatePrivateSymbol(context, arguments[0]);
} }
javascript builtin ExtrasUtilsMarkPromiseAsHandled( javascript builtin ExtrasUtilsMarkPromiseAsHandled(
js-implicit context: Context, receiver: Object)(...arguments): Undefined { js-implicit context: Context, receiver: JSAny)(...arguments): Undefined {
return PromiseMarkAsHandled(context, arguments[0]); return PromiseMarkAsHandled(context, arguments[0]);
} }
javascript builtin ExtrasUtilsPromiseState( javascript builtin ExtrasUtilsPromiseState(
js-implicit context: Context, receiver: Object)(...arguments): Smi { js-implicit context: Context, receiver: JSAny)(...arguments): Smi {
return PromiseStatus(context, arguments[0]); return PromiseStatus(context, arguments[0]);
} }
} }
...@@ -51,7 +51,7 @@ namespace internal_coverage { ...@@ -51,7 +51,7 @@ namespace internal_coverage {
} }
builtin IncBlockCounter(implicit context: Context)( builtin IncBlockCounter(implicit context: Context)(
function: JSFunction, coverageArraySlotIndex: Smi): Object { function: JSFunction, coverageArraySlotIndex: Smi): Undefined {
// It's quite possible that a function contains IncBlockCounter bytecodes, // It's quite possible that a function contains IncBlockCounter bytecodes,
// but no coverage info exists. This happens e.g. by selecting the // but no coverage info exists. This happens e.g. by selecting the
// best-effort coverage collection mode, which triggers deletion of all // best-effort coverage collection mode, which triggers deletion of all
......
...@@ -11,13 +11,13 @@ namespace iterator { ...@@ -11,13 +11,13 @@ namespace iterator {
object: JSReceiver; object: JSReceiver;
// iteratorRecord.[[NextMethod]] // iteratorRecord.[[NextMethod]]
next: Object; next: JSAny;
} }
extern macro IteratorBuiltinsAssembler::GetIteratorMethod( extern macro IteratorBuiltinsAssembler::GetIteratorMethod(
implicit context: Context)(Object): Object; implicit context: Context)(JSAny): JSAny;
extern macro IteratorBuiltinsAssembler::GetIterator( extern macro IteratorBuiltinsAssembler::GetIterator(
implicit context: Context)(Object): IteratorRecord; implicit context: Context)(JSAny): IteratorRecord;
extern macro IteratorBuiltinsAssembler::IteratorStep( extern macro IteratorBuiltinsAssembler::IteratorStep(
implicit context: Context)(IteratorRecord): JSReceiver implicit context: Context)(IteratorRecord): JSReceiver
...@@ -27,18 +27,18 @@ namespace iterator { ...@@ -27,18 +27,18 @@ namespace iterator {
labels Done; labels Done;
extern macro IteratorBuiltinsAssembler::IteratorValue( extern macro IteratorBuiltinsAssembler::IteratorValue(
implicit context: Context)(JSReceiver): Object; implicit context: Context)(JSReceiver): JSAny;
extern macro IteratorBuiltinsAssembler::IteratorValue( extern macro IteratorBuiltinsAssembler::IteratorValue(
implicit context: Context)(JSReceiver, Map): Object; implicit context: Context)(JSReceiver, Map): JSAny;
extern macro IteratorBuiltinsAssembler::IteratorCloseOnException( extern macro IteratorBuiltinsAssembler::IteratorCloseOnException(
implicit context: Context)(IteratorRecord, Object): never; implicit context: Context)(IteratorRecord, JSAny): never;
extern macro IteratorBuiltinsAssembler::IterableToList( extern macro IteratorBuiltinsAssembler::IterableToList(
implicit context: Context)(Object, Object): JSArray; implicit context: Context)(JSAny, JSAny): JSArray;
extern builtin IterableToListMayPreserveHoles(implicit context: extern builtin IterableToListMayPreserveHoles(implicit context:
Context)(Object, Object); Context)(JSAny, JSAny);
extern builtin IterableToListWithSymbolLookup(implicit context: extern builtin IterableToListWithSymbolLookup(implicit context:
Context)(Object); Context)(JSAny);
} }
...@@ -7,7 +7,7 @@ namespace math { ...@@ -7,7 +7,7 @@ namespace math {
extern macro Float64Acos(float64): float64; extern macro Float64Acos(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAcos(context: Context, _receiver: Object, x: Object): Number { MathAcos(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Acos(value)); return Convert<Number>(Float64Acos(value));
} }
...@@ -16,7 +16,7 @@ namespace math { ...@@ -16,7 +16,7 @@ namespace math {
extern macro Float64Acosh(float64): float64; extern macro Float64Acosh(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAcosh(context: Context, _receiver: Object, x: Object): Number { MathAcosh(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Acosh(value)); return Convert<Number>(Float64Acosh(value));
} }
...@@ -25,7 +25,7 @@ namespace math { ...@@ -25,7 +25,7 @@ namespace math {
extern macro Float64Asin(float64): float64; extern macro Float64Asin(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAsin(context: Context, _receiver: Object, x: Object): Number { MathAsin(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Asin(value)); return Convert<Number>(Float64Asin(value));
} }
...@@ -34,7 +34,7 @@ namespace math { ...@@ -34,7 +34,7 @@ namespace math {
extern macro Float64Asinh(float64): float64; extern macro Float64Asinh(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAsinh(context: Context, _receiver: Object, x: Object): Number { MathAsinh(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Asinh(value)); return Convert<Number>(Float64Asinh(value));
} }
...@@ -43,7 +43,7 @@ namespace math { ...@@ -43,7 +43,7 @@ namespace math {
extern macro Float64Atan(float64): float64; extern macro Float64Atan(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAtan(context: Context, _receiver: Object, x: Object): Number { MathAtan(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Atan(value)); return Convert<Number>(Float64Atan(value));
} }
...@@ -52,7 +52,7 @@ namespace math { ...@@ -52,7 +52,7 @@ namespace math {
extern macro Float64Atan2(float64, float64): float64; extern macro Float64Atan2(float64, float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAtan2(context: Context, _receiver: Object, y: Object, x: Object): Number { MathAtan2(context: Context, _receiver: JSAny, y: JSAny, x: JSAny): Number {
const yValue = Convert<float64>(ToNumber_Inline(context, y)); const yValue = Convert<float64>(ToNumber_Inline(context, y));
const xValue = Convert<float64>(ToNumber_Inline(context, x)); const xValue = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Atan2(yValue, xValue)); return Convert<Number>(Float64Atan2(yValue, xValue));
...@@ -62,7 +62,7 @@ namespace math { ...@@ -62,7 +62,7 @@ namespace math {
extern macro Float64Atanh(float64): float64; extern macro Float64Atanh(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathAtanh(context: Context, _receiver: Object, x: Object): Number { MathAtanh(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Atanh(value)); return Convert<Number>(Float64Atanh(value));
} }
...@@ -71,7 +71,7 @@ namespace math { ...@@ -71,7 +71,7 @@ namespace math {
extern macro Float64Cbrt(float64): float64; extern macro Float64Cbrt(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathCbrt(context: Context, _receiver: Object, x: Object): Number { MathCbrt(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Cbrt(value)); return Convert<Number>(Float64Cbrt(value));
} }
...@@ -80,7 +80,7 @@ namespace math { ...@@ -80,7 +80,7 @@ namespace math {
extern macro Word32Clz(int32): int32; extern macro Word32Clz(int32): int32;
transitioning javascript builtin transitioning javascript builtin
MathClz32(context: Context, _receiver: Object, x: Object): Number { MathClz32(context: Context, _receiver: JSAny, x: JSAny): Number {
const num = ToNumber_Inline(context, x); const num = ToNumber_Inline(context, x);
let value: int32; let value: int32;
...@@ -100,7 +100,7 @@ namespace math { ...@@ -100,7 +100,7 @@ namespace math {
extern macro Float64Cos(float64): float64; extern macro Float64Cos(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathCos(context: Context, _receiver: Object, x: Object): Number { MathCos(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Cos(value)); return Convert<Number>(Float64Cos(value));
} }
...@@ -109,7 +109,7 @@ namespace math { ...@@ -109,7 +109,7 @@ namespace math {
extern macro Float64Cosh(float64): float64; extern macro Float64Cosh(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathCosh(context: Context, _receiver: Object, x: Object): Number { MathCosh(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Cosh(value)); return Convert<Number>(Float64Cosh(value));
} }
...@@ -118,7 +118,7 @@ namespace math { ...@@ -118,7 +118,7 @@ namespace math {
extern macro Float64Exp(float64): float64; extern macro Float64Exp(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathExp(context: Context, _receiver: Object, x: Object): Number { MathExp(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Exp(value)); return Convert<Number>(Float64Exp(value));
} }
...@@ -127,14 +127,14 @@ namespace math { ...@@ -127,14 +127,14 @@ namespace math {
extern macro Float64Expm1(float64): float64; extern macro Float64Expm1(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathExpm1(context: Context, _receiver: Object, x: Object): Number { MathExpm1(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Expm1(value)); return Convert<Number>(Float64Expm1(value));
} }
// ES6 #sec-math.fround // ES6 #sec-math.fround
transitioning javascript builtin transitioning javascript builtin
MathFround(context: Context, _receiver: Object, x: Object): Number { MathFround(context: Context, _receiver: JSAny, x: JSAny): Number {
const x32 = Convert<float32>(ToNumber_Inline(context, x)); const x32 = Convert<float32>(ToNumber_Inline(context, x));
const x64 = Convert<float64>(x32); const x64 = Convert<float64>(x32);
return Convert<Number>(x64); return Convert<Number>(x64);
...@@ -144,7 +144,7 @@ namespace math { ...@@ -144,7 +144,7 @@ namespace math {
extern macro Float64Log(float64): float64; extern macro Float64Log(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathLog(context: Context, _receiver: Object, x: Object): Number { MathLog(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log(value)); return Convert<Number>(Float64Log(value));
} }
...@@ -153,7 +153,7 @@ namespace math { ...@@ -153,7 +153,7 @@ namespace math {
extern macro Float64Log1p(float64): float64; extern macro Float64Log1p(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathLog1p(context: Context, _receiver: Object, x: Object): Number { MathLog1p(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log1p(value)); return Convert<Number>(Float64Log1p(value));
} }
...@@ -162,7 +162,7 @@ namespace math { ...@@ -162,7 +162,7 @@ namespace math {
extern macro Float64Log10(float64): float64; extern macro Float64Log10(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathLog10(context: Context, _receiver: Object, x: Object): Number { MathLog10(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log10(value)); return Convert<Number>(Float64Log10(value));
} }
...@@ -171,7 +171,7 @@ namespace math { ...@@ -171,7 +171,7 @@ namespace math {
extern macro Float64Log2(float64): float64; extern macro Float64Log2(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathLog2(context: Context, _receiver: Object, x: Object): Number { MathLog2(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log2(value)); return Convert<Number>(Float64Log2(value));
} }
...@@ -180,14 +180,14 @@ namespace math { ...@@ -180,14 +180,14 @@ namespace math {
extern macro Float64Sin(float64): float64; extern macro Float64Sin(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathSin(context: Context, _receiver: Object, x: Object): Number { MathSin(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Sin(value)); return Convert<Number>(Float64Sin(value));
} }
// ES6 #sec-math.sign // ES6 #sec-math.sign
transitioning javascript builtin transitioning javascript builtin
MathSign(context: Context, _receiver: Object, x: Object): Number { MathSign(context: Context, _receiver: JSAny, x: JSAny): Number {
const num = ToNumber_Inline(context, x); const num = ToNumber_Inline(context, x);
const value = Convert<float64>(num); const value = Convert<float64>(num);
...@@ -204,7 +204,7 @@ namespace math { ...@@ -204,7 +204,7 @@ namespace math {
extern macro Float64Sinh(float64): float64; extern macro Float64Sinh(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathSinh(context: Context, _receiver: Object, x: Object): Number { MathSinh(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Sinh(value)); return Convert<Number>(Float64Sinh(value));
} }
...@@ -213,7 +213,7 @@ namespace math { ...@@ -213,7 +213,7 @@ namespace math {
extern macro Float64Sqrt(float64): float64; extern macro Float64Sqrt(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathSqrt(context: Context, _receiver: Object, x: Object): Number { MathSqrt(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Sqrt(value)); return Convert<Number>(Float64Sqrt(value));
} }
...@@ -222,7 +222,7 @@ namespace math { ...@@ -222,7 +222,7 @@ namespace math {
extern macro Float64Tan(float64): float64; extern macro Float64Tan(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathTan(context: Context, _receiver: Object, x: Object): Number { MathTan(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Tan(value)); return Convert<Number>(Float64Tan(value));
} }
...@@ -231,7 +231,7 @@ namespace math { ...@@ -231,7 +231,7 @@ namespace math {
extern macro Float64Tanh(float64): float64; extern macro Float64Tanh(float64): float64;
transitioning javascript builtin transitioning javascript builtin
MathTanh(context: Context, _receiver: Object, x: Object): Number { MathTanh(context: Context, _receiver: JSAny, x: JSAny): Number {
const value = Convert<float64>(ToNumber_Inline(context, x)); const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Tanh(value)); return Convert<Number>(Float64Tanh(value));
} }
...@@ -240,7 +240,7 @@ namespace math { ...@@ -240,7 +240,7 @@ namespace math {
// ES6 #sec-math.hypot // ES6 #sec-math.hypot
transitioning javascript builtin transitioning javascript builtin
MathHypot(js-implicit context: Context, receiver: Object)(...arguments): MathHypot(js-implicit context: Context, receiver: JSAny)(...arguments):
Number { Number {
const length = arguments.length; const length = arguments.length;
if (length == 0) { if (length == 0) {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
namespace object { namespace object {
transitioning macro ObjectFromEntriesFastCase(implicit context: Context)( transitioning macro ObjectFromEntriesFastCase(implicit context: Context)(
iterable: Object): JSObject labels IfSlow { iterable: JSAny): JSObject labels IfSlow {
typeswitch (iterable) { typeswitch (iterable) {
case (array: FastJSArrayWithNoCustomIteration): { case (array: FastJSArrayWithNoCustomIteration): {
const elements: FixedArray = const elements: FixedArray =
...@@ -14,7 +14,7 @@ namespace object { ...@@ -14,7 +14,7 @@ namespace object {
const result: JSObject = NewJSObject(); const result: JSObject = NewJSObject();
for (let k: Smi = 0; k < length; ++k) { for (let k: Smi = 0; k < length; ++k) {
const value: Object = array::LoadElementOrUndefined(elements, k); const value: JSAny = array::LoadElementOrUndefined(elements, k);
const pair: KeyValuePair = const pair: KeyValuePair =
collections::LoadKeyValuePairNoSideEffects(value) collections::LoadKeyValuePairNoSideEffects(value)
otherwise IfSlow; otherwise IfSlow;
...@@ -26,16 +26,16 @@ namespace object { ...@@ -26,16 +26,16 @@ namespace object {
} }
return result; return result;
} }
case (Object): { case (JSAny): {
goto IfSlow; goto IfSlow;
} }
} }
} }
transitioning javascript builtin transitioning javascript builtin
ObjectFromEntries(js-implicit context: Context, receiver: Object)( ObjectFromEntries(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): JSAny {
const iterable: Object = arguments[0]; const iterable: JSAny = arguments[0];
try { try {
if (IsNullOrUndefined(iterable)) goto Throw; if (IsNullOrUndefined(iterable)) goto Throw;
return ObjectFromEntriesFastCase(iterable) otherwise IfSlow; return ObjectFromEntriesFastCase(iterable) otherwise IfSlow;
...@@ -50,7 +50,7 @@ namespace object { ...@@ -50,7 +50,7 @@ namespace object {
const step: JSReceiver = const step: JSReceiver =
iterator::IteratorStep(i, fastIteratorResultMap) iterator::IteratorStep(i, fastIteratorResultMap)
otherwise return result; otherwise return result;
const iteratorValue: Object = const iteratorValue: JSAny =
iterator::IteratorValue(step, fastIteratorResultMap); iterator::IteratorValue(step, fastIteratorResultMap);
const pair: KeyValuePair = const pair: KeyValuePair =
collections::LoadKeyValuePair(iteratorValue); collections::LoadKeyValuePair(iteratorValue);
......
...@@ -4,31 +4,31 @@ ...@@ -4,31 +4,31 @@
namespace runtime { namespace runtime {
extern transitioning runtime extern transitioning runtime
ObjectIsExtensible(implicit context: Context)(Object): Object; ObjectIsExtensible(implicit context: Context)(JSAny): JSAny;
extern transitioning runtime extern transitioning runtime
JSReceiverPreventExtensionsThrow(implicit context: Context)(JSReceiver): JSReceiverPreventExtensionsThrow(implicit context: Context)(JSReceiver):
Object; JSAny;
extern transitioning runtime extern transitioning runtime
JSReceiverPreventExtensionsDontThrow(implicit context: Context)(JSReceiver): JSReceiverPreventExtensionsDontThrow(implicit context: Context)(JSReceiver):
Object; JSAny;
extern transitioning runtime extern transitioning runtime
JSReceiverGetPrototypeOf(implicit context: Context)(JSReceiver): Object; JSReceiverGetPrototypeOf(implicit context: Context)(JSReceiver): JSAny;
extern transitioning runtime extern transitioning runtime
JSReceiverSetPrototypeOfThrow(implicit context: Context)(JSReceiver, Object): JSReceiverSetPrototypeOfThrow(implicit context: Context)(JSReceiver, JSAny):
Object; JSAny;
extern transitioning runtime extern transitioning runtime
JSReceiverSetPrototypeOfDontThrow(implicit context: JSReceiverSetPrototypeOfDontThrow(implicit context:
Context)(JSReceiver, Object): Object; Context)(JSReceiver, JSAny): JSAny;
} // namespace runtime } // namespace runtime
namespace object { namespace object {
transitioning macro transitioning macro
ObjectIsExtensible(implicit context: Context)(object: Object): Object { ObjectIsExtensible(implicit context: Context)(object: JSAny): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False; const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver) const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::ObjectIsExtensible(objectJSReceiver); otherwise return runtime::ObjectIsExtensible(objectJSReceiver);
...@@ -36,8 +36,8 @@ namespace object { ...@@ -36,8 +36,8 @@ namespace object {
} }
transitioning macro transitioning macro
ObjectPreventExtensionsThrow(implicit context: Context)(object: Object): ObjectPreventExtensionsThrow(implicit context: Context)(object: JSAny):
Object { JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return object; const objectJSReceiver = Cast<JSReceiver>(object) otherwise return object;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver) const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverPreventExtensionsThrow( otherwise return runtime::JSReceiverPreventExtensionsThrow(
...@@ -47,8 +47,8 @@ namespace object { ...@@ -47,8 +47,8 @@ namespace object {
} }
transitioning macro transitioning macro
ObjectPreventExtensionsDontThrow(implicit context: Context)(object: Object): ObjectPreventExtensionsDontThrow(implicit context: Context)(object: JSAny):
Object { JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False; const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver) const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverPreventExtensionsDontThrow( otherwise return runtime::JSReceiverPreventExtensionsDontThrow(
...@@ -57,14 +57,14 @@ namespace object { ...@@ -57,14 +57,14 @@ namespace object {
} }
transitioning macro transitioning macro
ObjectGetPrototypeOf(implicit context: Context)(object: Object): Object { ObjectGetPrototypeOf(implicit context: Context)(object: JSAny): JSAny {
const objectJSReceiver: JSReceiver = ToObject_Inline(context, object); const objectJSReceiver: JSReceiver = ToObject_Inline(context, object);
return object::JSReceiverGetPrototypeOf(objectJSReceiver); return object::JSReceiverGetPrototypeOf(objectJSReceiver);
} }
transitioning macro transitioning macro
JSReceiverGetPrototypeOf(implicit context: Context)(object: JSReceiver): JSReceiverGetPrototypeOf(implicit context: Context)(object: JSReceiver):
Object { JSAny {
const objectJSProxy = Cast<JSProxy>(object) const objectJSProxy = Cast<JSProxy>(object)
otherwise return runtime::JSReceiverGetPrototypeOf(object); otherwise return runtime::JSReceiverGetPrototypeOf(object);
return proxy::ProxyGetPrototypeOf(objectJSProxy); return proxy::ProxyGetPrototypeOf(objectJSProxy);
...@@ -72,7 +72,7 @@ namespace object { ...@@ -72,7 +72,7 @@ namespace object {
transitioning macro transitioning macro
ObjectSetPrototypeOfThrow(implicit context: Context)( ObjectSetPrototypeOfThrow(implicit context: Context)(
object: Object, proto: Object): Object { object: JSAny, proto: JSReceiver | Null): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return object; const objectJSReceiver = Cast<JSReceiver>(object) otherwise return object;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver) const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverSetPrototypeOfThrow( otherwise return runtime::JSReceiverSetPrototypeOfThrow(
...@@ -83,7 +83,7 @@ namespace object { ...@@ -83,7 +83,7 @@ namespace object {
transitioning macro transitioning macro
ObjectSetPrototypeOfDontThrow(implicit context: Context)( ObjectSetPrototypeOfDontThrow(implicit context: Context)(
object: Object, proto: Object): Object { object: JSAny, proto: JSReceiver | Null): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False; const objectJSReceiver = Cast<JSReceiver>(object) otherwise return False;
const objectJSProxy = Cast<JSProxy>(objectJSReceiver) const objectJSProxy = Cast<JSProxy>(objectJSReceiver)
otherwise return runtime::JSReceiverSetPrototypeOfDontThrow( otherwise return runtime::JSReceiverSetPrototypeOfDontThrow(
...@@ -95,7 +95,7 @@ namespace object { ...@@ -95,7 +95,7 @@ namespace object {
namespace object_isextensible { namespace object_isextensible {
// ES6 section 19.1.2.11 Object.isExtensible ( O ) // ES6 section 19.1.2.11 Object.isExtensible ( O )
transitioning javascript builtin ObjectIsExtensible( transitioning javascript builtin ObjectIsExtensible(
js-implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: JSAny, object: JSAny): JSAny {
return object::ObjectIsExtensible(object); return object::ObjectIsExtensible(object);
} }
} // namespace object_isextensible } // namespace object_isextensible
...@@ -103,7 +103,7 @@ namespace object_isextensible { ...@@ -103,7 +103,7 @@ namespace object_isextensible {
namespace object_preventextensions { namespace object_preventextensions {
// ES6 section 19.1.2.11 Object.isExtensible ( O ) // ES6 section 19.1.2.11 Object.isExtensible ( O )
transitioning javascript builtin ObjectPreventExtensions( transitioning javascript builtin ObjectPreventExtensions(
js-implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: JSAny, object: JSAny): JSAny {
return object::ObjectPreventExtensionsThrow(object); return object::ObjectPreventExtensionsThrow(object);
} }
} // namespace object_preventextensions } // namespace object_preventextensions
...@@ -111,7 +111,7 @@ namespace object_preventextensions { ...@@ -111,7 +111,7 @@ namespace object_preventextensions {
namespace object_getprototypeof { namespace object_getprototypeof {
// ES6 section 19.1.2.9 Object.getPrototypeOf ( O ) // ES6 section 19.1.2.9 Object.getPrototypeOf ( O )
transitioning javascript builtin ObjectGetPrototypeOf( transitioning javascript builtin ObjectGetPrototypeOf(
js-implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: JSAny, object: JSAny): JSAny {
return object::ObjectGetPrototypeOf(object); return object::ObjectGetPrototypeOf(object);
} }
} // namespace object_getprototypeof } // namespace object_getprototypeof
...@@ -120,7 +120,7 @@ namespace object_setprototypeof { ...@@ -120,7 +120,7 @@ namespace object_setprototypeof {
// ES6 section 19.1.2.21 Object.setPrototypeOf ( O, proto ) // ES6 section 19.1.2.21 Object.setPrototypeOf ( O, proto )
transitioning javascript builtin ObjectSetPrototypeOf( transitioning javascript builtin ObjectSetPrototypeOf(
js-implicit context: js-implicit context:
Context)(_receiver: Object, object: Object, proto: Object): Object { Context)(_receiver: JSAny, object: JSAny, proto: JSAny): JSAny {
// 1. Set O to ? RequireObjectCoercible(O). // 1. Set O to ? RequireObjectCoercible(O).
RequireObjectCoercible(object, 'Object.setPrototypeOf'); RequireObjectCoercible(object, 'Object.setPrototypeOf');
...@@ -130,9 +130,13 @@ namespace object_setprototypeof { ...@@ -130,9 +130,13 @@ namespace object_setprototypeof {
// 4. Let status be ? O.[[SetPrototypeOf]](proto). // 4. Let status be ? O.[[SetPrototypeOf]](proto).
// 5. If status is false, throw a TypeError exception. // 5. If status is false, throw a TypeError exception.
// 6. Return O. // 6. Return O.
if (proto == Null || Is<JSReceiver>(proto)) { typeswitch (proto) {
return object::ObjectSetPrototypeOfThrow(object, proto); case (proto: JSReceiver | Null): {
return object::ObjectSetPrototypeOfThrow(object, proto);
}
case (JSAny): {
ThrowTypeError(kProtoObjectOrNull, proto);
}
} }
ThrowTypeError(kProtoObjectOrNull, proto);
} }
} // namespace object_setprototypeof } // namespace object_setprototypeof
...@@ -10,8 +10,8 @@ namespace proxy { ...@@ -10,8 +10,8 @@ namespace proxy {
// https://tc39.github.io/ecma262/#sec-proxy-constructor // https://tc39.github.io/ecma262/#sec-proxy-constructor
transitioning javascript builtin transitioning javascript builtin
ProxyConstructor( ProxyConstructor(
js-implicit context: Context, receiver: Object, js-implicit context: Context, receiver: JSAny,
newTarget: Object)(target: Object, handler: Object): JSProxy { newTarget: JSAny)(target: JSAny, handler: JSAny): JSProxy {
try { try {
// 1. If NewTarget is undefined, throw a TypeError exception. // 1. If NewTarget is undefined, throw a TypeError exception.
if (newTarget == Undefined) { if (newTarget == Undefined) {
......
...@@ -10,7 +10,7 @@ namespace proxy { ...@@ -10,7 +10,7 @@ namespace proxy {
// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-delete-p // https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-delete-p
transitioning builtin transitioning builtin
ProxyDeleteProperty(implicit context: Context)( ProxyDeleteProperty(implicit context: Context)(
proxy: JSProxy, name: Name, languageMode: LanguageMode): Object { proxy: JSProxy, name: PropertyKey, languageMode: LanguageMode): JSAny {
const kTrapName: constexpr string = 'deleteProperty'; const kTrapName: constexpr string = 'deleteProperty';
// Handle deeply nested proxy. // Handle deeply nested proxy.
PerformStackCheck(); PerformStackCheck();
...@@ -58,7 +58,7 @@ namespace proxy { ...@@ -58,7 +58,7 @@ namespace proxy {
// 15. Return true. // 15. Return true.
return True; return True;
} }
label TrapUndefined(target: Object) { label TrapUndefined(target: JSAny) {
// 7.a. Return ? target.[[Delete]](P). // 7.a. Return ? target.[[Delete]](P).
return DeleteProperty(target, name, languageMode); return DeleteProperty(target, name, languageMode);
} }
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
namespace proxy { namespace proxy {
extern transitioning builtin GetPropertyWithReceiver( extern transitioning builtin GetPropertyWithReceiver(
implicit context: Context)(Object, Name, Object, Smi): Object; implicit context: Context)(JSAny, Name, JSAny, Smi): JSAny;
// ES #sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver // ES #sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
// https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver // https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
transitioning builtin transitioning builtin
ProxyGetProperty(implicit context: Context)( ProxyGetProperty(implicit context: Context)(
proxy: JSProxy, name: Name, receiverValue: Object, proxy: JSProxy, name: PropertyKey, receiverValue: JSAny,
onNonExistent: Smi): Object { onNonExistent: Smi): JSAny {
PerformStackCheck(); PerformStackCheck();
// 1. Assert: IsPropertyKey(P) is true. // 1. Assert: IsPropertyKey(P) is true.
assert(TaggedIsNotSmi(name)); assert(TaggedIsNotSmi(name));
......
...@@ -9,7 +9,7 @@ namespace proxy { ...@@ -9,7 +9,7 @@ namespace proxy {
// ES #sec-proxy-object-internal-methods-and-internal-slots-isextensible // ES #sec-proxy-object-internal-methods-and-internal-slots-isextensible
// https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible // https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible
transitioning builtin transitioning builtin
ProxyGetPrototypeOf(implicit context: Context)(proxy: JSProxy): Object { ProxyGetPrototypeOf(implicit context: Context)(proxy: JSProxy): JSAny {
PerformStackCheck(); PerformStackCheck();
const kTrapName: constexpr string = 'getPrototypeOf'; const kTrapName: constexpr string = 'getPrototypeOf';
try { try {
...@@ -39,7 +39,7 @@ namespace proxy { ...@@ -39,7 +39,7 @@ namespace proxy {
// 9. Let extensibleTarget be ? IsExtensible(target). // 9. Let extensibleTarget be ? IsExtensible(target).
// 10. If extensibleTarget is true, return handlerProto. // 10. If extensibleTarget is true, return handlerProto.
const extensibleTarget: Object = object::ObjectIsExtensible(target); const extensibleTarget: JSAny = object::ObjectIsExtensible(target);
assert(extensibleTarget == True || extensibleTarget == False); assert(extensibleTarget == True || extensibleTarget == False);
if (extensibleTarget == True) { if (extensibleTarget == True) {
return handlerProto; return handlerProto;
...@@ -56,7 +56,7 @@ namespace proxy { ...@@ -56,7 +56,7 @@ namespace proxy {
} }
ThrowTypeError(kProxyGetPrototypeOfNonExtensible); ThrowTypeError(kProxyGetPrototypeOfNonExtensible);
} }
label TrapUndefined(target: Object) { label TrapUndefined(target: JSAny) {
// 6.a. Return ? target.[[GetPrototypeOf]](). // 6.a. Return ? target.[[GetPrototypeOf]]().
return object::ObjectGetPrototypeOf(target); return object::ObjectGetPrototypeOf(target);
} }
......
...@@ -9,7 +9,7 @@ namespace proxy { ...@@ -9,7 +9,7 @@ namespace proxy {
// ES #sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p // ES #sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p
// https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p // https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p
transitioning builtin ProxyHasProperty(implicit context: Context)( transitioning builtin ProxyHasProperty(implicit context: Context)(
proxy: JSProxy, name: Name): Object { proxy: JSProxy, name: PropertyKey): JSAny {
assert(IsJSProxy(proxy)); assert(IsJSProxy(proxy));
PerformStackCheck(); PerformStackCheck();
...@@ -46,7 +46,7 @@ namespace proxy { ...@@ -46,7 +46,7 @@ namespace proxy {
CheckHasTrapResult(target, proxy, name); CheckHasTrapResult(target, proxy, name);
return False; return False;
} }
label TrapUndefined(target: Object) { label TrapUndefined(target: JSAny) {
// 7.a. Return ? target.[[HasProperty]](P). // 7.a. Return ? target.[[HasProperty]](P).
tail HasProperty(target, name); tail HasProperty(target, name);
} }
......
...@@ -9,7 +9,7 @@ namespace proxy { ...@@ -9,7 +9,7 @@ namespace proxy {
// ES #sec-proxy-object-internal-methods-and-internal-slots-isextensible // ES #sec-proxy-object-internal-methods-and-internal-slots-isextensible
// https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible // https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-isextensible
transitioning builtin ProxyIsExtensible(implicit context: transitioning builtin ProxyIsExtensible(implicit context:
Context)(proxy: JSProxy): Object { Context)(proxy: JSProxy): JSAny {
PerformStackCheck(); PerformStackCheck();
const kTrapName: constexpr string = 'isExtensible'; const kTrapName: constexpr string = 'isExtensible';
try { try {
...@@ -45,7 +45,7 @@ namespace proxy { ...@@ -45,7 +45,7 @@ namespace proxy {
// 10. Return booleanTrapResult. // 10. Return booleanTrapResult.
return SelectBooleanConstant(trapResult); return SelectBooleanConstant(trapResult);
} }
label TrapUndefined(target: Object) { label TrapUndefined(target: JSAny) {
// 6.a. Return ? IsExtensible(target). // 6.a. Return ? IsExtensible(target).
return object::ObjectIsExtensible(target); return object::ObjectIsExtensible(target);
} }
......
...@@ -9,8 +9,8 @@ namespace proxy { ...@@ -9,8 +9,8 @@ namespace proxy {
// ES #sec-proxy-object-internal-methods-and-internal-slots-preventextensions // ES #sec-proxy-object-internal-methods-and-internal-slots-preventextensions
// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions // https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-preventextensions
transitioning builtin transitioning builtin
ProxyPreventExtensions(implicit context: Context)( ProxyPreventExtensions(implicit context:
proxy: JSProxy, doThrow: Boolean): Object { Context)(proxy: JSProxy, doThrow: Boolean): JSAny {
PerformStackCheck(); PerformStackCheck();
const kTrapName: constexpr string = 'preventExtensions'; const kTrapName: constexpr string = 'preventExtensions';
try { try {
...@@ -37,7 +37,7 @@ namespace proxy { ...@@ -37,7 +37,7 @@ namespace proxy {
// 8.a. Let extensibleTarget be ? IsExtensible(target). // 8.a. Let extensibleTarget be ? IsExtensible(target).
// 8.b If extensibleTarget is true, throw a TypeError exception. // 8.b If extensibleTarget is true, throw a TypeError exception.
if (ToBoolean(trapResult)) { if (ToBoolean(trapResult)) {
const extensibleTarget: Object = object::ObjectIsExtensible(target); const extensibleTarget: JSAny = object::ObjectIsExtensible(target);
assert(extensibleTarget == True || extensibleTarget == False); assert(extensibleTarget == True || extensibleTarget == False);
if (extensibleTarget == True) { if (extensibleTarget == True) {
ThrowTypeError(kProxyPreventExtensionsExtensible); ThrowTypeError(kProxyPreventExtensionsExtensible);
...@@ -52,7 +52,7 @@ namespace proxy { ...@@ -52,7 +52,7 @@ namespace proxy {
// 9. Return booleanTrapResult. // 9. Return booleanTrapResult.
return True; return True;
} }
label TrapUndefined(target: Object) { label TrapUndefined(target: JSAny) {
// 6.a. Return ? target.[[PreventExtensions]](). // 6.a. Return ? target.[[PreventExtensions]]().
if (doThrow == True) { if (doThrow == True) {
return object::ObjectPreventExtensionsThrow(target); return object::ObjectPreventExtensionsThrow(target);
......
...@@ -12,9 +12,8 @@ namespace proxy { ...@@ -12,9 +12,8 @@ namespace proxy {
// Proxy.revocable(target, handler) // Proxy.revocable(target, handler)
// https://tc39.github.io/ecma262/#sec-proxy.revocable // https://tc39.github.io/ecma262/#sec-proxy.revocable
transitioning javascript builtin transitioning javascript builtin
ProxyRevocable( ProxyRevocable(js-implicit context: Context)(
context: Context, _receiver: Object, target: Object, _receiver: JSAny, target: JSAny, handler: JSAny): JSProxyRevocableResult {
handler: Object): JSProxyRevocableResult {
try { try {
const targetJSReceiver = const targetJSReceiver =
Cast<JSReceiver>(target) otherwise ThrowProxyNonObject; Cast<JSReceiver>(target) otherwise ThrowProxyNonObject;
......
...@@ -19,15 +19,21 @@ namespace proxy { ...@@ -19,15 +19,21 @@ namespace proxy {
// https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver // https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
transitioning builtin transitioning builtin
ProxySetProperty(implicit context: Context)( ProxySetProperty(implicit context: Context)(
proxy: JSProxy, name: Name, value: Object, proxy: JSProxy, name: PropertyKey | PrivateSymbol, value: JSAny,
receiverValue: Object): Object { receiverValue: JSAny): JSAny {
// 1. Assert: IsPropertyKey(P) is true. // 1. Assert: IsPropertyKey(P) is true.
assert(TaggedIsNotSmi(name)); assert(TaggedIsNotSmi(name));
assert(IsName(name)); assert(IsName(name));
if (IsPrivateSymbol(name)) { let key: PropertyKey;
CallThrowTypeErrorIfStrict(kProxyPrivate); typeswitch (name) {
return Undefined; case (PrivateSymbol): {
CallThrowTypeErrorIfStrict(kProxyPrivate);
return Undefined;
}
case (name: PropertyKey): {
key = name;
}
} }
try { try {
...@@ -61,7 +67,7 @@ namespace proxy { ...@@ -61,7 +67,7 @@ namespace proxy {
// exception. // exception.
// 12. Return true. // 12. Return true.
const trapResult = const trapResult =
Call(context, trap, handler, target, name, value, receiverValue); Call(context, trap, handler, target, key, value, receiverValue);
if (ToBoolean(trapResult)) { if (ToBoolean(trapResult)) {
CheckGetSetTrapResult(target, proxy, name, value, kProxySet); CheckGetSetTrapResult(target, proxy, name, value, kProxySet);
return value; return value;
......
...@@ -10,7 +10,7 @@ namespace proxy { ...@@ -10,7 +10,7 @@ namespace proxy {
// https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v // https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v
transitioning builtin transitioning builtin
ProxySetPrototypeOf(implicit context: Context)( ProxySetPrototypeOf(implicit context: Context)(
proxy: JSProxy, proto: Object, doThrow: Boolean): Object { proxy: JSProxy, proto: Null | JSReceiver, doThrow: Boolean): JSAny {
PerformStackCheck(); PerformStackCheck();
const kTrapName: constexpr string = 'setPrototypeOf'; const kTrapName: constexpr string = 'setPrototypeOf';
try { try {
...@@ -63,7 +63,7 @@ namespace proxy { ...@@ -63,7 +63,7 @@ namespace proxy {
} }
ThrowTypeError(kProxySetPrototypeOfNonExtensible); ThrowTypeError(kProxySetPrototypeOfNonExtensible);
} }
label TrapUndefined(target: Object, proto: Object) { label TrapUndefined(target: JSAny, proto: JSReceiver | Null) {
// 7.a. Return ? target.[[SetPrototypeOf]](). // 7.a. Return ? target.[[SetPrototypeOf]]().
if (doThrow == True) { if (doThrow == True) {
return object::ObjectSetPrototypeOfThrow(target, proto); return object::ObjectSetPrototypeOfThrow(target, proto);
......
...@@ -9,7 +9,7 @@ namespace reflect { ...@@ -9,7 +9,7 @@ namespace reflect {
// ES6 section 26.1.10 Reflect.isExtensible // ES6 section 26.1.10 Reflect.isExtensible
transitioning javascript builtin ReflectIsExtensible( transitioning javascript builtin ReflectIsExtensible(
js-implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: JSAny, object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object) const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.isExtensible'); otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.isExtensible');
return object::ObjectIsExtensible(objectJSReceiver); return object::ObjectIsExtensible(objectJSReceiver);
...@@ -17,7 +17,7 @@ namespace reflect { ...@@ -17,7 +17,7 @@ namespace reflect {
// ES6 section 26.1.12 Reflect.preventExtensions // ES6 section 26.1.12 Reflect.preventExtensions
transitioning javascript builtin ReflectPreventExtensions( transitioning javascript builtin ReflectPreventExtensions(
js-implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: JSAny, object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object) const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.preventExtensions'); otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.preventExtensions');
return object::ObjectPreventExtensionsDontThrow(objectJSReceiver); return object::ObjectPreventExtensionsDontThrow(objectJSReceiver);
...@@ -25,7 +25,7 @@ namespace reflect { ...@@ -25,7 +25,7 @@ namespace reflect {
// ES6 section 26.1.8 Reflect.getPrototypeOf // ES6 section 26.1.8 Reflect.getPrototypeOf
transitioning javascript builtin ReflectGetPrototypeOf( transitioning javascript builtin ReflectGetPrototypeOf(
js-implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: JSAny, object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object) const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.getPrototypeOf'); otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.getPrototypeOf');
return object::JSReceiverGetPrototypeOf(objectJSReceiver); return object::JSReceiverGetPrototypeOf(objectJSReceiver);
...@@ -34,16 +34,21 @@ namespace reflect { ...@@ -34,16 +34,21 @@ namespace reflect {
// ES6 section 26.1.14 Reflect.setPrototypeOf // ES6 section 26.1.14 Reflect.setPrototypeOf
transitioning javascript builtin ReflectSetPrototypeOf( transitioning javascript builtin ReflectSetPrototypeOf(
js-implicit context: js-implicit context:
Context)(_receiver: Object, object: Object, proto: Object): Object { Context)(_receiver: JSAny, object: JSAny, proto: JSAny): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.setPrototypeOf'); otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.setPrototypeOf');
if (proto == Null || Is<JSReceiver>(proto)) { typeswitch (proto) {
return object::ObjectSetPrototypeOfDontThrow(objectJSReceiver, proto); case (proto: JSReceiver | Null): {
return object::ObjectSetPrototypeOfDontThrow(objectJSReceiver, proto);
}
case (JSAny): {
ThrowTypeError(kProtoObjectOrNull, proto);
}
} }
ThrowTypeError(kProtoObjectOrNull, proto);
} }
extern transitioning builtin ToName(implicit context: Context)(Object): Name; extern transitioning builtin ToName(implicit context: Context)(Object):
AnyName;
type OnNonExistent constexpr 'OnNonExistent'; type OnNonExistent constexpr 'OnNonExistent';
const kReturnUndefined: constexpr OnNonExistent const kReturnUndefined: constexpr OnNonExistent
generates 'OnNonExistent::kReturnUndefined'; generates 'OnNonExistent::kReturnUndefined';
...@@ -59,8 +64,8 @@ namespace reflect { ...@@ -59,8 +64,8 @@ namespace reflect {
const objectJSReceiver = Cast<JSReceiver>(object) const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.get'); otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.get');
const propertyKey: Object = length > 1 ? arguments[1] : Undefined; const propertyKey: Object = length > 1 ? arguments[1] : Undefined;
const name: Name = ToName(propertyKey); const name: AnyName = ToName(propertyKey);
const receiver: Object = length > 2 ? arguments[2] : objectJSReceiver; const receiver: JSAny = length > 2 ? arguments[2] : objectJSReceiver;
return GetPropertyWithReceiver( return GetPropertyWithReceiver(
objectJSReceiver, name, receiver, SmiConstant(kReturnUndefined)); objectJSReceiver, name, receiver, SmiConstant(kReturnUndefined));
} }
...@@ -68,7 +73,7 @@ namespace reflect { ...@@ -68,7 +73,7 @@ namespace reflect {
// ES6 section 26.1.4 Reflect.deleteProperty // ES6 section 26.1.4 Reflect.deleteProperty
transitioning javascript builtin ReflectDeleteProperty( transitioning javascript builtin ReflectDeleteProperty(
js-implicit context: js-implicit context:
Context)(_receiver: Object, object: Object, key: Object): Object { Context)(_receiver: JSAny, object: JSAny, key: JSAny): JSAny {
const objectJSReceiver = Cast<JSReceiver>(object) const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.deleteProperty'); otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.deleteProperty');
return DeleteProperty(objectJSReceiver, key, kSloppy); return DeleteProperty(objectJSReceiver, key, kSloppy);
......
...@@ -57,7 +57,7 @@ namespace regexp_replace { ...@@ -57,7 +57,7 @@ namespace regexp_replace {
// Element represents the matched substring, which is then passed to the // Element represents the matched substring, which is then passed to the
// replace function. // replace function.
case (elString: String): { case (elString: String): {
const replacementObj: Object = const replacementObj: JSAny =
Call(context, replaceFn, Undefined, elString, matchStart, string); Call(context, replaceFn, Undefined, elString, matchStart, string);
const replacement: String = ToString_Inline(context, replacementObj); const replacement: String = ToString_Inline(context, replacementObj);
matchesElements.objects[i] = replacement; matchesElements.objects[i] = replacement;
...@@ -79,7 +79,7 @@ namespace regexp_replace { ...@@ -79,7 +79,7 @@ namespace regexp_replace {
// The JSArray is expanded into the function args by Reflect.apply(). // The JSArray is expanded into the function args by Reflect.apply().
// TODO(jgruber): Remove indirection through Call->ReflectApply. // TODO(jgruber): Remove indirection through Call->ReflectApply.
const replacementObj: Object = Call( const replacementObj: JSAny = Call(
context, GetReflectApply(), Undefined, replaceFn, Undefined, elArray); context, GetReflectApply(), Undefined, replaceFn, Undefined, elArray);
// Overwrite the i'th element in the results with the string // Overwrite the i'th element in the results with the string
...@@ -172,7 +172,7 @@ namespace regexp_replace { ...@@ -172,7 +172,7 @@ namespace regexp_replace {
} }
transitioning builtin RegExpReplace(implicit context: Context)( transitioning builtin RegExpReplace(implicit context: Context)(
regexp: FastJSRegExp, string: String, replaceValue: Object): String { regexp: FastJSRegExp, string: String, replaceValue: JSAny): String {
// TODO(pwong): Remove assert when all callers (StringPrototypeReplace) are // TODO(pwong): Remove assert when all callers (StringPrototypeReplace) are
// from Torque. // from Torque.
assert(Is<FastJSRegExp>(regexp)); assert(Is<FastJSRegExp>(regexp));
...@@ -184,7 +184,7 @@ namespace regexp_replace { ...@@ -184,7 +184,7 @@ namespace regexp_replace {
RegExpReplaceFastGlobalCallable(regexp, string, replaceFn) : RegExpReplaceFastGlobalCallable(regexp, string, replaceFn) :
StringReplaceNonGlobalRegExpWithFunction(string, regexp, replaceFn); StringReplaceNonGlobalRegExpWithFunction(string, regexp, replaceFn);
} }
case (Object): { case (JSAny): {
const stableRegexp: JSRegExp = regexp; const stableRegexp: JSRegExp = regexp;
const replaceString: String = ToString_Inline(context, replaceValue); const replaceString: String = ToString_Inline(context, replaceValue);
...@@ -208,7 +208,7 @@ namespace regexp_replace { ...@@ -208,7 +208,7 @@ namespace regexp_replace {
} }
transitioning javascript builtin RegExpPrototypeReplace( transitioning javascript builtin RegExpPrototypeReplace(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): Object {
const methodName: constexpr string = 'RegExp.prototype.@@replace'; const methodName: constexpr string = 'RegExp.prototype.@@replace';
// RegExpPrototypeReplace is a bit of a beast - a summary of dispatch logic: // RegExpPrototypeReplace is a bit of a beast - a summary of dispatch logic:
...@@ -229,8 +229,8 @@ namespace regexp_replace { ...@@ -229,8 +229,8 @@ namespace regexp_replace {
// } // }
// } // }
const string: Object = arguments[0]; const string: JSAny = arguments[0];
const replaceValue: Object = arguments[1]; const replaceValue: JSAny = arguments[1];
// Let rx be the this value. // Let rx be the this value.
// If Type(rx) is not Object, throw a TypeError exception. // If Type(rx) is not Object, throw a TypeError exception.
......
...@@ -28,13 +28,13 @@ namespace string { ...@@ -28,13 +28,13 @@ namespace string {
// https://tc39.github.io/ecma262/#sec-string.prototype.endswith // https://tc39.github.io/ecma262/#sec-string.prototype.endswith
transitioning javascript builtin StringPrototypeEndsWith( transitioning javascript builtin StringPrototypeEndsWith(
js-implicit context: Context, receiver: Object)(...arguments): Boolean { js-implicit context: Context, receiver: JSAny)(...arguments): Boolean {
const searchString: Object = arguments[0]; const searchString: JSAny = arguments[0];
const endPosition: Object = arguments[1]; const endPosition: JSAny = arguments[1];
const kBuiltinName: constexpr string = 'String.prototype.endsWith'; const kBuiltinName: constexpr string = 'String.prototype.endsWith';
// 1. Let O be ? RequireObjectCoercible(this value). // 1. Let O be ? RequireObjectCoercible(this value).
const object: Object = RequireObjectCoercible(receiver, kBuiltinName); const object: JSAny = RequireObjectCoercible(receiver, kBuiltinName);
// 2. Let S be ? ToString(O). // 2. Let S be ? ToString(O).
const string: String = ToString_Inline(context, object); const string: String = ToString_Inline(context, object);
......
...@@ -7,8 +7,8 @@ namespace string_html { ...@@ -7,8 +7,8 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-createhtml // https://tc39.github.io/ecma262/#sec-createhtml
transitioning builtin CreateHTML(implicit context: Context)( transitioning builtin CreateHTML(implicit context: Context)(
receiver: Object, methodName: String, tagName: String, attr: String, receiver: JSAny, methodName: String, tagName: String, attr: String,
attrValue: Object): String { attrValue: JSAny): String {
const tagContents: String = ToThisString(receiver, methodName); const tagContents: String = ToThisString(receiver, methodName);
let result = '<' + tagName; let result = '<' + tagName;
if (attr != kEmptyString) { if (attr != kEmptyString) {
...@@ -22,14 +22,14 @@ namespace string_html { ...@@ -22,14 +22,14 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.anchor // https://tc39.github.io/ecma262/#sec-string.prototype.anchor
transitioning javascript builtin StringPrototypeAnchor( transitioning javascript builtin StringPrototypeAnchor(
js-implicit context: Context, receiver: Object)(...arguments): String { js-implicit context: Context, receiver: JSAny)(...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.anchor', 'a', 'name', arguments[0]); receiver, 'String.prototype.anchor', 'a', 'name', arguments[0]);
} }
// https://tc39.github.io/ecma262/#sec-string.prototype.big // https://tc39.github.io/ecma262/#sec-string.prototype.big
transitioning javascript builtin transitioning javascript builtin
StringPrototypeBig(js-implicit context: Context, receiver: Object)( StringPrototypeBig(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.big', 'big', kEmptyString, kEmptyString); receiver, 'String.prototype.big', 'big', kEmptyString, kEmptyString);
...@@ -37,7 +37,7 @@ namespace string_html { ...@@ -37,7 +37,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.blink // https://tc39.github.io/ecma262/#sec-string.prototype.blink
transitioning javascript builtin transitioning javascript builtin
StringPrototypeBlink(js-implicit context: Context, receiver: Object)( StringPrototypeBlink(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.blink', 'blink', kEmptyString, receiver, 'String.prototype.blink', 'blink', kEmptyString,
...@@ -46,7 +46,7 @@ namespace string_html { ...@@ -46,7 +46,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.bold // https://tc39.github.io/ecma262/#sec-string.prototype.bold
transitioning javascript builtin transitioning javascript builtin
StringPrototypeBold(js-implicit context: Context, receiver: Object)( StringPrototypeBold(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.bold', 'b', kEmptyString, kEmptyString); receiver, 'String.prototype.bold', 'b', kEmptyString, kEmptyString);
...@@ -54,7 +54,7 @@ namespace string_html { ...@@ -54,7 +54,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor // https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor
transitioning javascript builtin transitioning javascript builtin
StringPrototypeFontcolor(js-implicit context: Context, receiver: Object)( StringPrototypeFontcolor(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.fontcolor', 'font', 'color', arguments[0]); receiver, 'String.prototype.fontcolor', 'font', 'color', arguments[0]);
...@@ -62,7 +62,7 @@ namespace string_html { ...@@ -62,7 +62,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.fontsize // https://tc39.github.io/ecma262/#sec-string.prototype.fontsize
transitioning javascript builtin transitioning javascript builtin
StringPrototypeFontsize(js-implicit context: Context, receiver: Object)( StringPrototypeFontsize(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.fontsize', 'font', 'size', arguments[0]); receiver, 'String.prototype.fontsize', 'font', 'size', arguments[0]);
...@@ -70,7 +70,7 @@ namespace string_html { ...@@ -70,7 +70,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.fixed // https://tc39.github.io/ecma262/#sec-string.prototype.fixed
transitioning javascript builtin transitioning javascript builtin
StringPrototypeFixed(js-implicit context: Context, receiver: Object)( StringPrototypeFixed(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.fixed', 'tt', kEmptyString, kEmptyString); receiver, 'String.prototype.fixed', 'tt', kEmptyString, kEmptyString);
...@@ -78,7 +78,7 @@ namespace string_html { ...@@ -78,7 +78,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.italics // https://tc39.github.io/ecma262/#sec-string.prototype.italics
transitioning javascript builtin transitioning javascript builtin
StringPrototypeItalics(js-implicit context: Context, receiver: Object)( StringPrototypeItalics(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.italics', 'i', kEmptyString, kEmptyString); receiver, 'String.prototype.italics', 'i', kEmptyString, kEmptyString);
...@@ -86,7 +86,7 @@ namespace string_html { ...@@ -86,7 +86,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.link // https://tc39.github.io/ecma262/#sec-string.prototype.link
transitioning javascript builtin transitioning javascript builtin
StringPrototypeLink(js-implicit context: Context, receiver: Object)( StringPrototypeLink(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.link', 'a', 'href', arguments[0]); receiver, 'String.prototype.link', 'a', 'href', arguments[0]);
...@@ -94,7 +94,7 @@ namespace string_html { ...@@ -94,7 +94,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.small // https://tc39.github.io/ecma262/#sec-string.prototype.small
transitioning javascript builtin transitioning javascript builtin
StringPrototypeSmall(js-implicit context: Context, receiver: Object)( StringPrototypeSmall(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.small', 'small', kEmptyString, receiver, 'String.prototype.small', 'small', kEmptyString,
...@@ -103,7 +103,7 @@ namespace string_html { ...@@ -103,7 +103,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.strike // https://tc39.github.io/ecma262/#sec-string.prototype.strike
transitioning javascript builtin transitioning javascript builtin
StringPrototypeStrike(js-implicit context: Context, receiver: Object)( StringPrototypeStrike(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.strike', 'strike', kEmptyString, receiver, 'String.prototype.strike', 'strike', kEmptyString,
...@@ -112,7 +112,7 @@ namespace string_html { ...@@ -112,7 +112,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.sub // https://tc39.github.io/ecma262/#sec-string.prototype.sub
transitioning javascript builtin transitioning javascript builtin
StringPrototypeSub(js-implicit context: Context, receiver: Object)( StringPrototypeSub(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.sub', 'sub', kEmptyString, kEmptyString); receiver, 'String.prototype.sub', 'sub', kEmptyString, kEmptyString);
...@@ -120,7 +120,7 @@ namespace string_html { ...@@ -120,7 +120,7 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.sup // https://tc39.github.io/ecma262/#sec-string.prototype.sup
transitioning javascript builtin transitioning javascript builtin
StringPrototypeSup(js-implicit context: Context, receiver: Object)( StringPrototypeSup(js-implicit context: Context, receiver: JSAny)(
...arguments): String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.sup', 'sup', kEmptyString, kEmptyString); receiver, 'String.prototype.sup', 'sup', kEmptyString, kEmptyString);
......
...@@ -17,7 +17,7 @@ namespace string_iterator { ...@@ -17,7 +17,7 @@ namespace string_iterator {
// ES6 #sec-string.prototype-@@iterator // ES6 #sec-string.prototype-@@iterator
transitioning javascript builtin StringPrototypeIterator( transitioning javascript builtin StringPrototypeIterator(
js-implicit context: Context)(receiver: Object): JSStringIterator { js-implicit context: Context)(receiver: JSAny): JSStringIterator {
const name: String = const name: String =
ToThisString(receiver, 'String.prototype[Symbol.iterator]'); ToThisString(receiver, 'String.prototype[Symbol.iterator]');
const index: Smi = 0; const index: Smi = 0;
...@@ -26,7 +26,7 @@ namespace string_iterator { ...@@ -26,7 +26,7 @@ namespace string_iterator {
// ES6 #sec-%stringiteratorprototype%.next // ES6 #sec-%stringiteratorprototype%.next
transitioning javascript builtin StringIteratorPrototypeNext( transitioning javascript builtin StringIteratorPrototypeNext(
js-implicit context: Context)(receiver: Object): JSObject { js-implicit context: Context)(receiver: JSAny): JSObject {
const iterator = Cast<JSStringIterator>(receiver) otherwise ThrowTypeError( const iterator = Cast<JSStringIterator>(receiver) otherwise ThrowTypeError(
kIncompatibleMethodReceiver, 'String Iterator.prototype.next', kIncompatibleMethodReceiver, 'String Iterator.prototype.next',
receiver); receiver);
......
...@@ -28,7 +28,7 @@ namespace string_repeat { ...@@ -28,7 +28,7 @@ namespace string_repeat {
// https://tc39.github.io/ecma262/#sec-string.prototype.repeat // https://tc39.github.io/ecma262/#sec-string.prototype.repeat
transitioning javascript builtin StringPrototypeRepeat( transitioning javascript builtin StringPrototypeRepeat(
js-implicit context: Context, receiver: Object)(count: Object): String { js-implicit context: Context, receiver: JSAny)(count: JSAny): String {
// 1. Let O be ? RequireObjectCoercible(this value). // 1. Let O be ? RequireObjectCoercible(this value).
// 2. Let S be ? ToString(O). // 2. Let S be ? ToString(O).
const s: String = ToThisString(receiver, kBuiltinName); const s: String = ToThisString(receiver, kBuiltinName);
......
...@@ -9,7 +9,7 @@ namespace string_slice { ...@@ -9,7 +9,7 @@ namespace string_slice {
// ES6 #sec-string.prototype.slice ( start, end ) // ES6 #sec-string.prototype.slice ( start, end )
// https://tc39.github.io/ecma262/#sec-string.prototype.slice // https://tc39.github.io/ecma262/#sec-string.prototype.slice
transitioning javascript builtin StringPrototypeSlice( transitioning javascript builtin StringPrototypeSlice(
js-implicit context: Context, receiver: Object)(...arguments): String { js-implicit context: Context, receiver: JSAny)(...arguments): String {
// 1. Let O be ? RequireObjectCoercible(this value). // 1. Let O be ? RequireObjectCoercible(this value).
// 2. Let S be ? ToString(O). // 2. Let S be ? ToString(O).
const string: String = ToThisString(receiver, 'String.prototype.slice'); const string: String = ToThisString(receiver, 'String.prototype.slice');
......
...@@ -10,13 +10,13 @@ namespace string { ...@@ -10,13 +10,13 @@ namespace string {
// https://tc39.github.io/ecma262/#sec-string.prototype.startswith // https://tc39.github.io/ecma262/#sec-string.prototype.startswith
transitioning javascript builtin StringPrototypeStartsWith( transitioning javascript builtin StringPrototypeStartsWith(
js-implicit context: Context, receiver: Object)(...arguments): Boolean { js-implicit context: Context, receiver: JSAny)(...arguments): Boolean {
const searchString: Object = arguments[0]; const searchString: JSAny = arguments[0];
const position: Object = arguments[1]; const position: JSAny = arguments[1];
const kBuiltinName: constexpr string = 'String.prototype.startsWith'; const kBuiltinName: constexpr string = 'String.prototype.startsWith';
// 1. Let O be ? RequireObjectCoercible(this value). // 1. Let O be ? RequireObjectCoercible(this value).
const object: Object = RequireObjectCoercible(receiver, kBuiltinName); const object: JSAny = RequireObjectCoercible(receiver, kBuiltinName);
// 2. Let S be ? ToString(O). // 2. Let S be ? ToString(O).
const string: String = ToString_Inline(context, object); const string: String = ToString_Inline(context, object);
......
...@@ -7,7 +7,7 @@ namespace string_substring { ...@@ -7,7 +7,7 @@ namespace string_substring {
extern macro SubString(String, intptr, intptr): String; extern macro SubString(String, intptr, intptr): String;
transitioning macro ToSmiBetweenZeroAnd(implicit context: Context)( transitioning macro ToSmiBetweenZeroAnd(implicit context: Context)(
value: Object, limit: Smi): Smi { value: JSAny, limit: Smi): Smi {
const valueInt: Number = const valueInt: Number =
ToInteger_Inline(context, value, kTruncateMinusZero); ToInteger_Inline(context, value, kTruncateMinusZero);
typeswitch (valueInt) { typeswitch (valueInt) {
...@@ -28,7 +28,7 @@ namespace string_substring { ...@@ -28,7 +28,7 @@ namespace string_substring {
// ES6 #sec-string.prototype.substring // ES6 #sec-string.prototype.substring
transitioning javascript builtin StringPrototypeSubstring( transitioning javascript builtin StringPrototypeSubstring(
js-implicit context: Context, receiver: Object)(...arguments): String { js-implicit context: Context, receiver: JSAny)(...arguments): String {
// Check that {receiver} is coercible to Object and convert it to a String. // Check that {receiver} is coercible to Object and convert it to a String.
const string: String = ToThisString(receiver, 'String.prototype.substring'); const string: String = ToThisString(receiver, 'String.prototype.substring');
const length = string.length_smi; const length = string.length_smi;
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
namespace string { namespace string {
// ES6 #sec-string.prototype.tostring // ES6 #sec-string.prototype.tostring
transitioning javascript builtin transitioning javascript builtin
StringPrototypeToString(js-implicit context: Context)(receiver: Object): StringPrototypeToString(js-implicit context: Context)(receiver: JSAny):
Object { Object {
return ToThisValue(receiver, kString, 'String.prototype.toString'); return ToThisValue(receiver, kString, 'String.prototype.toString');
} }
// ES6 #sec-string.prototype.valueof // ES6 #sec-string.prototype.valueof
transitioning javascript builtin transitioning javascript builtin
StringPrototypeValueOf(js-implicit context: Context)(receiver: Object): StringPrototypeValueOf(js-implicit context: Context)(receiver: JSAny):
Object { Object {
return ToThisValue(receiver, kString, 'String.prototype.valueOf'); return ToThisValue(receiver, kString, 'String.prototype.valueOf');
} }
...@@ -53,7 +53,7 @@ namespace string { ...@@ -53,7 +53,7 @@ namespace string {
} }
transitioning macro GenerateStringAt(implicit context: Context)( transitioning macro GenerateStringAt(implicit context: Context)(
receiver: Object, position: Object, receiver: JSAny, position: JSAny,
methodName: constexpr string): never labels methodName: constexpr string): never labels
IfInBounds(String, intptr, intptr), IfOutOfBounds { IfInBounds(String, intptr, intptr), IfOutOfBounds {
// Check that {receiver} is coercible to Object and convert it to a String. // Check that {receiver} is coercible to Object and convert it to a String.
...@@ -71,8 +71,7 @@ namespace string { ...@@ -71,8 +71,7 @@ namespace string {
// ES6 #sec-string.prototype.charat // ES6 #sec-string.prototype.charat
transitioning javascript builtin StringPrototypeCharAt( transitioning javascript builtin StringPrototypeCharAt(
js-implicit context: Context, js-implicit context: Context, receiver: JSAny)(position: JSAny): Object {
receiver: Object)(position: Object): Object {
try { try {
GenerateStringAt(receiver, position, 'String.prototype.charAt') GenerateStringAt(receiver, position, 'String.prototype.charAt')
otherwise IfInBounds, IfOutOfBounds; otherwise IfInBounds, IfOutOfBounds;
...@@ -88,8 +87,7 @@ namespace string { ...@@ -88,8 +87,7 @@ namespace string {
// ES6 #sec-string.prototype.charcodeat // ES6 #sec-string.prototype.charcodeat
transitioning javascript builtin StringPrototypeCharCodeAt( transitioning javascript builtin StringPrototypeCharCodeAt(
js-implicit context: Context, js-implicit context: Context, receiver: JSAny)(position: JSAny): Object {
receiver: Object)(position: Object): Object {
try { try {
GenerateStringAt(receiver, position, 'String.prototype.charCodeAt') GenerateStringAt(receiver, position, 'String.prototype.charCodeAt')
otherwise IfInBounds, IfOutOfBounds; otherwise IfInBounds, IfOutOfBounds;
...@@ -105,8 +103,7 @@ namespace string { ...@@ -105,8 +103,7 @@ namespace string {
// ES6 #sec-string.prototype.codepointat // ES6 #sec-string.prototype.codepointat
transitioning javascript builtin StringPrototypeCodePointAt( transitioning javascript builtin StringPrototypeCodePointAt(
js-implicit context: Context, js-implicit context: Context, receiver: JSAny)(position: JSAny): Object {
receiver: Object)(position: Object): Object {
try { try {
GenerateStringAt(receiver, position, 'String.prototype.codePointAt') GenerateStringAt(receiver, position, 'String.prototype.codePointAt')
otherwise IfInBounds, IfOutOfBounds; otherwise IfInBounds, IfOutOfBounds;
...@@ -125,7 +122,7 @@ namespace string { ...@@ -125,7 +122,7 @@ namespace string {
// ES6 String.prototype.concat(...args) // ES6 String.prototype.concat(...args)
// ES6 #sec-string.prototype.concat // ES6 #sec-string.prototype.concat
transitioning javascript builtin StringPrototypeConcat( transitioning javascript builtin StringPrototypeConcat(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): Object {
// Check that {receiver} is coercible to Object and convert it to a String. // Check that {receiver} is coercible to Object and convert it to a String.
let string: String = ToThisString(receiver, 'String.prototype.concat'); let string: String = ToThisString(receiver, 'String.prototype.concat');
......
...@@ -122,7 +122,7 @@ namespace typed_array_createtypedarray { ...@@ -122,7 +122,7 @@ namespace typed_array_createtypedarray {
// 22.2.4.2 TypedArray ( length ) // 22.2.4.2 TypedArray ( length )
// ES #sec-typedarray-length // ES #sec-typedarray-length
transitioning macro ConstructByLength(implicit context: Context)( transitioning macro ConstructByLength(implicit context: Context)(
map: Map, length: Object, map: Map, length: JSAny,
elementsInfo: typed_array::TypedArrayElementsInfo): JSTypedArray { elementsInfo: typed_array::TypedArrayElementsInfo): JSTypedArray {
const convertedLength: Number = const convertedLength: Number =
ToInteger_Inline(context, length, kTruncateMinusZero); ToInteger_Inline(context, length, kTruncateMinusZero);
...@@ -141,7 +141,7 @@ namespace typed_array_createtypedarray { ...@@ -141,7 +141,7 @@ namespace typed_array_createtypedarray {
// 22.2.4.4 TypedArray ( object ) // 22.2.4.4 TypedArray ( object )
// ES #sec-typedarray-object // ES #sec-typedarray-object
transitioning macro ConstructByArrayLike(implicit context: Context)( transitioning macro ConstructByArrayLike(implicit context: Context)(
map: Map, arrayLike: HeapObject, initialLength: Object, map: Map, arrayLike: HeapObject, initialLength: JSAny,
elementsInfo: typed_array::TypedArrayElementsInfo, elementsInfo: typed_array::TypedArrayElementsInfo,
bufferConstructor: JSReceiver): JSTypedArray { bufferConstructor: JSReceiver): JSTypedArray {
// The caller has looked up length on arrayLike, which is observable. // The caller has looked up length on arrayLike, which is observable.
...@@ -178,7 +178,7 @@ namespace typed_array_createtypedarray { ...@@ -178,7 +178,7 @@ namespace typed_array_createtypedarray {
// ES #sec-typedarray-object // ES #sec-typedarray-object
transitioning macro ConstructByIterable(implicit context: Context)( transitioning macro ConstructByIterable(implicit context: Context)(
iterable: JSReceiver, iteratorFn: Callable): never iterable: JSReceiver, iteratorFn: Callable): never
labels IfConstructByArrayLike(HeapObject, Object, JSReceiver) { labels IfConstructByArrayLike(JSArray, Number, JSReceiver) {
const array: JSArray = const array: JSArray =
IterableToListMayPreserveHoles(context, iterable, iteratorFn); IterableToListMayPreserveHoles(context, iterable, iteratorFn);
goto IfConstructByArrayLike(array, array.length, GetArrayBufferFunction()); goto IfConstructByArrayLike(array, array.length, GetArrayBufferFunction());
...@@ -188,7 +188,7 @@ namespace typed_array_createtypedarray { ...@@ -188,7 +188,7 @@ namespace typed_array_createtypedarray {
// ES #sec-typedarray-typedarray // ES #sec-typedarray-typedarray
transitioning macro ConstructByTypedArray(implicit context: Context)( transitioning macro ConstructByTypedArray(implicit context: Context)(
srcTypedArray: JSTypedArray): never srcTypedArray: JSTypedArray): never
labels IfConstructByArrayLike(HeapObject, Object, JSReceiver) { labels IfConstructByArrayLike(JSTypedArray, Number, JSReceiver) {
let bufferConstructor: JSReceiver = GetArrayBufferFunction(); let bufferConstructor: JSReceiver = GetArrayBufferFunction();
const srcBuffer: JSArrayBuffer = srcTypedArray.buffer; const srcBuffer: JSArrayBuffer = srcTypedArray.buffer;
// TODO(petermarshall): Throw on detached typedArray. // TODO(petermarshall): Throw on detached typedArray.
...@@ -210,7 +210,7 @@ namespace typed_array_createtypedarray { ...@@ -210,7 +210,7 @@ namespace typed_array_createtypedarray {
// 22.2.4.5 TypedArray ( buffer, byteOffset, length ) // 22.2.4.5 TypedArray ( buffer, byteOffset, length )
// ES #sec-typedarray-buffer-byteoffset-length // ES #sec-typedarray-buffer-byteoffset-length
transitioning macro ConstructByArrayBuffer(implicit context: Context)( transitioning macro ConstructByArrayBuffer(implicit context: Context)(
map: Map, buffer: JSArrayBuffer, byteOffset: Object, length: Object, map: Map, buffer: JSArrayBuffer, byteOffset: JSAny, length: JSAny,
elementsInfo: typed_array::TypedArrayElementsInfo): JSTypedArray { elementsInfo: typed_array::TypedArrayElementsInfo): JSTypedArray {
try { try {
let offset: uintptr = 0; let offset: uintptr = 0;
...@@ -294,7 +294,7 @@ namespace typed_array_createtypedarray { ...@@ -294,7 +294,7 @@ namespace typed_array_createtypedarray {
transitioning macro ConstructByJSReceiver(implicit context: transitioning macro ConstructByJSReceiver(implicit context:
Context)(obj: JSReceiver): never Context)(obj: JSReceiver): never
labels IfConstructByArrayLike(HeapObject, Object, JSReceiver) { labels IfConstructByArrayLike(JSReceiver, Number, JSReceiver) {
try { try {
const iteratorMethod: Object = const iteratorMethod: Object =
GetIteratorMethod(obj) otherwise IfIteratorUndefined; GetIteratorMethod(obj) otherwise IfIteratorUndefined;
...@@ -304,7 +304,7 @@ namespace typed_array_createtypedarray { ...@@ -304,7 +304,7 @@ namespace typed_array_createtypedarray {
otherwise IfConstructByArrayLike; otherwise IfConstructByArrayLike;
} }
label IfIteratorUndefined { label IfIteratorUndefined {
const lengthObj: Object = GetProperty(obj, kLengthString); const lengthObj: JSAny = GetProperty(obj, kLengthString);
const length: Smi = ToSmiLength(lengthObj) const length: Smi = ToSmiLength(lengthObj)
otherwise goto IfInvalidLength(lengthObj); otherwise goto IfInvalidLength(lengthObj);
goto IfConstructByArrayLike(obj, length, GetArrayBufferFunction()); goto IfConstructByArrayLike(obj, length, GetArrayBufferFunction());
...@@ -317,8 +317,8 @@ namespace typed_array_createtypedarray { ...@@ -317,8 +317,8 @@ namespace typed_array_createtypedarray {
// 22.2.4 The TypedArray Constructors // 22.2.4 The TypedArray Constructors
// ES #sec-typedarray-constructors // ES #sec-typedarray-constructors
transitioning builtin CreateTypedArray( transitioning builtin CreateTypedArray(
context: Context, target: JSFunction, newTarget: JSReceiver, arg1: Object, context: Context, target: JSFunction, newTarget: JSReceiver, arg1: JSAny,
arg2: Object, arg3: Object): JSTypedArray { arg2: JSAny, arg3: JSAny): JSTypedArray {
assert(IsConstructor(target)); assert(IsConstructor(target));
// 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, // 4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
// "%TypedArrayPrototype%"). // "%TypedArrayPrototype%").
...@@ -345,16 +345,16 @@ namespace typed_array_createtypedarray { ...@@ -345,16 +345,16 @@ namespace typed_array_createtypedarray {
} }
// The first argument was a number or fell through and is treated as // The first argument was a number or fell through and is treated as
// a number. https://tc39.github.io/ecma262/#sec-typedarray-length // a number. https://tc39.github.io/ecma262/#sec-typedarray-length
case (lengthObj: HeapObject): { case (lengthObj: JSAny): {
goto IfConstructByLength(lengthObj); goto IfConstructByLength(lengthObj);
} }
} }
} }
label IfConstructByLength(length: Object) { label IfConstructByLength(length: JSAny) {
return ConstructByLength(map, length, elementsInfo); return ConstructByLength(map, length, elementsInfo);
} }
label IfConstructByArrayLike( label IfConstructByArrayLike(
arrayLike: HeapObject, length: Object, bufferConstructor: JSReceiver) { arrayLike: JSReceiver, length: Number, bufferConstructor: JSReceiver) {
return ConstructByArrayLike( return ConstructByArrayLike(
map, arrayLike, length, elementsInfo, bufferConstructor); map, arrayLike, length, elementsInfo, bufferConstructor);
} }
...@@ -362,8 +362,8 @@ namespace typed_array_createtypedarray { ...@@ -362,8 +362,8 @@ namespace typed_array_createtypedarray {
transitioning macro TypedArraySpeciesCreate(implicit context: Context)( transitioning macro TypedArraySpeciesCreate(implicit context: Context)(
methodName: constexpr string, numArgs: constexpr int31, methodName: constexpr string, numArgs: constexpr int31,
exemplar: JSTypedArray, arg0: Object, arg1: Object, exemplar: JSTypedArray, arg0: JSAny, arg1: JSAny,
arg2: Object): JSTypedArray { arg2: JSAny): JSTypedArray {
const defaultConstructor = GetDefaultConstructor(exemplar); const defaultConstructor = GetDefaultConstructor(exemplar);
try { try {
...@@ -386,7 +386,7 @@ namespace typed_array_createtypedarray { ...@@ -386,7 +386,7 @@ namespace typed_array_createtypedarray {
// TODO(pwong): Simplify and remove numArgs when varargs are supported in // TODO(pwong): Simplify and remove numArgs when varargs are supported in
// macros. // macros.
let newObj: Object = Undefined; let newObj: JSAny = Undefined;
if constexpr (numArgs == 1) { if constexpr (numArgs == 1) {
newObj = Construct(constructor, arg0); newObj = Construct(constructor, arg0);
} else { } else {
......
...@@ -9,7 +9,7 @@ namespace typed_array_every { ...@@ -9,7 +9,7 @@ namespace typed_array_every {
transitioning macro EveryAllElements(implicit context: Context)( transitioning macro EveryAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: Object): Boolean { thisArg: JSAny): Boolean {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -17,7 +17,7 @@ namespace typed_array_every { ...@@ -17,7 +17,7 @@ namespace typed_array_every {
for (let k: Smi = 0; k < length; k++) { for (let k: Smi = 0; k < length; k++) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
const result = const result =
Call(context, callbackfn, thisArg, value, k, witness.GetStable()); Call(context, callbackfn, thisArg, value, k, witness.GetStable());
if (!ToBoolean(result)) { if (!ToBoolean(result)) {
...@@ -29,7 +29,7 @@ namespace typed_array_every { ...@@ -29,7 +29,7 @@ namespace typed_array_every {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeEvery(js-implicit context: Context, receiver: Object)( TypedArrayPrototypeEvery(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg // arguments[1] = thisArg
......
...@@ -10,7 +10,7 @@ namespace typed_array_filter { ...@@ -10,7 +10,7 @@ namespace typed_array_filter {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter
transitioning javascript builtin TypedArrayPrototypeFilter( transitioning javascript builtin TypedArrayPrototypeFilter(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg // arguments[1] = thisArg
try { try {
...@@ -29,7 +29,7 @@ namespace typed_array_filter { ...@@ -29,7 +29,7 @@ namespace typed_array_filter {
otherwise ThrowTypeError(kCalledNonCallable, arguments[0]); otherwise ThrowTypeError(kCalledNonCallable, arguments[0]);
// 5. If thisArg is present, let T be thisArg; else let T be undefined. // 5. If thisArg is present, let T be thisArg; else let T be undefined.
const thisArg: Object = arguments[1]; const thisArg: JSAny = arguments[1];
// 6. Let kept be a new empty List. // 6. Let kept be a new empty List.
let kept = growable_fixed_array::NewGrowableFixedArray(); let kept = growable_fixed_array::NewGrowableFixedArray();
...@@ -43,11 +43,11 @@ namespace typed_array_filter { ...@@ -43,11 +43,11 @@ namespace typed_array_filter {
// a. Let Pk be ! ToString(k). // a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk). // b. Let kValue be ? Get(O, Pk).
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
// c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O // c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O
// »)). // »)).
const selected: Object = const selected: JSAny =
Call(context, callbackfn, thisArg, value, k, witness.GetStable()); Call(context, callbackfn, thisArg, value, k, witness.GetStable());
// d. If selected is true, then // d. If selected is true, then
......
...@@ -9,7 +9,7 @@ namespace typed_array_find { ...@@ -9,7 +9,7 @@ namespace typed_array_find {
transitioning macro FindAllElements(implicit context: Context)( transitioning macro FindAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: Object): Object { thisArg: JSAny): Object {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -17,7 +17,7 @@ namespace typed_array_find { ...@@ -17,7 +17,7 @@ namespace typed_array_find {
for (let k: Smi = 0; k < length; k++) { for (let k: Smi = 0; k < length; k++) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
const result = const result =
Call(context, callbackfn, thisArg, value, k, witness.GetStable()); Call(context, callbackfn, thisArg, value, k, witness.GetStable());
if (ToBoolean(result)) { if (ToBoolean(result)) {
...@@ -29,7 +29,7 @@ namespace typed_array_find { ...@@ -29,7 +29,7 @@ namespace typed_array_find {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeFind(js-implicit context: Context, receiver: Object)( TypedArrayPrototypeFind(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg // arguments[1] = thisArg
......
...@@ -9,7 +9,7 @@ namespace typed_array_findindex { ...@@ -9,7 +9,7 @@ namespace typed_array_findindex {
transitioning macro FindIndexAllElements(implicit context: Context)( transitioning macro FindIndexAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: Object): Number { thisArg: JSAny): Number {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -17,7 +17,7 @@ namespace typed_array_findindex { ...@@ -17,7 +17,7 @@ namespace typed_array_findindex {
for (let k: Smi = 0; k < length; k++) { for (let k: Smi = 0; k < length; k++) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
const result = const result =
Call(context, callbackfn, thisArg, value, k, witness.GetStable()); Call(context, callbackfn, thisArg, value, k, witness.GetStable());
if (ToBoolean(result)) { if (ToBoolean(result)) {
...@@ -29,7 +29,7 @@ namespace typed_array_findindex { ...@@ -29,7 +29,7 @@ namespace typed_array_findindex {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findIndex // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findIndex
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)( TypedArrayPrototypeFindIndex(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg. // arguments[1] = thisArg.
......
...@@ -9,7 +9,7 @@ namespace typed_array_foreach { ...@@ -9,7 +9,7 @@ namespace typed_array_foreach {
transitioning macro ForEachAllElements(implicit context: Context)( transitioning macro ForEachAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: Object): Object { thisArg: JSAny): Undefined {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -17,7 +17,7 @@ namespace typed_array_foreach { ...@@ -17,7 +17,7 @@ namespace typed_array_foreach {
for (let k: Smi = 0; k < length; k++) { for (let k: Smi = 0; k < length; k++) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
Call(context, callbackfn, thisArg, value, k, witness.GetStable()); Call(context, callbackfn, thisArg, value, k, witness.GetStable());
} }
return Undefined; return Undefined;
...@@ -25,8 +25,8 @@ namespace typed_array_foreach { ...@@ -25,8 +25,8 @@ namespace typed_array_foreach {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeForEach(js-implicit context: Context, receiver: Object)( TypedArrayPrototypeForEach(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): Undefined {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = this_arg. // arguments[1] = this_arg.
......
...@@ -9,7 +9,7 @@ namespace typed_array_reduce { ...@@ -9,7 +9,7 @@ namespace typed_array_reduce {
transitioning macro ReduceAllElements(implicit context: Context)( transitioning macro ReduceAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
initialValue: Object): Object { initialValue: JSAny | TheHole): JSAny {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -18,24 +18,31 @@ namespace typed_array_reduce { ...@@ -18,24 +18,31 @@ namespace typed_array_reduce {
for (let k: Smi = 0; k < length; k++) { for (let k: Smi = 0; k < length; k++) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
if (accumulator == TheHole) { typeswitch (accumulator) {
accumulator = value; case (TheHole): {
} else { accumulator = value;
accumulator = Call( }
context, callbackfn, Undefined, accumulator, value, k, case (accumulatorNotHole: JSAny): {
witness.GetStable()); accumulator = Call(
context, callbackfn, Undefined, accumulatorNotHole, value, k,
witness.GetStable());
}
} }
} }
if (accumulator == TheHole) { typeswitch (accumulator) {
ThrowTypeError(kReduceNoInitial, kBuiltinName); case (TheHole): {
ThrowTypeError(kReduceNoInitial, kBuiltinName);
}
case (accumulator: JSAny): {
return accumulator;
}
} }
return accumulator;
} }
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeReduce(js-implicit context: Context, receiver: Object)( TypedArrayPrototypeReduce(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = initialValue. // arguments[1] = initialValue.
......
...@@ -9,7 +9,7 @@ namespace typed_array_reduceright { ...@@ -9,7 +9,7 @@ namespace typed_array_reduceright {
transitioning macro ReduceRightAllElements(implicit context: Context)( transitioning macro ReduceRightAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
initialValue: Object): Object { initialValue: JSAny | TheHole): JSAny {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -18,25 +18,32 @@ namespace typed_array_reduceright { ...@@ -18,25 +18,32 @@ namespace typed_array_reduceright {
for (let k: Smi = length - 1; k >= 0; k--) { for (let k: Smi = length - 1; k >= 0; k--) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
if (accumulator == TheHole) { typeswitch (accumulator) {
accumulator = value; case (TheHole): {
} else { accumulator = value;
accumulator = Call( }
context, callbackfn, Undefined, accumulator, value, k, case (accumulatorNotHole: JSAny): {
witness.GetStable()); accumulator = Call(
context, callbackfn, Undefined, accumulatorNotHole, value, k,
witness.GetStable());
}
} }
} }
if (accumulator == TheHole) { typeswitch (accumulator) {
ThrowTypeError(kReduceNoInitial, kBuiltinName); case (TheHole): {
ThrowTypeError(kReduceNoInitial, kBuiltinName);
}
case (accumulator: JSAny): {
return accumulator;
}
} }
return accumulator;
} }
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeReduceRight( TypedArrayPrototypeReduceRight(js-implicit context: Context, receiver: JSAny)(
js-implicit context: Context, receiver: Object)(...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = initialValue. // arguments[1] = initialValue.
try { try {
......
...@@ -53,7 +53,7 @@ namespace typed_array_slice { ...@@ -53,7 +53,7 @@ namespace typed_array_slice {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice
transitioning javascript builtin TypedArrayPrototypeSlice( transitioning javascript builtin TypedArrayPrototypeSlice(
js-implicit context: Context, receiver: Object)(...arguments): Object { js-implicit context: Context, receiver: JSAny)(...arguments): Object {
// arguments[0] = start // arguments[0] = start
// arguments[1] = end // arguments[1] = end
......
...@@ -9,7 +9,7 @@ namespace typed_array_some { ...@@ -9,7 +9,7 @@ namespace typed_array_some {
transitioning macro SomeAllElements(implicit context: Context)( transitioning macro SomeAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable, array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
thisArg: Object): Boolean { thisArg: JSAny): Boolean {
let witness = typed_array::NewAttachedJSTypedArrayWitness(array); let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
// TODO(v8:4153): Support huge TypedArrays here. // TODO(v8:4153): Support huge TypedArrays here.
const length = const length =
...@@ -17,7 +17,7 @@ namespace typed_array_some { ...@@ -17,7 +17,7 @@ namespace typed_array_some {
for (let k: Smi = 0; k < length; k++) { for (let k: Smi = 0; k < length; k++) {
// BUG(4895): We should throw on detached buffers rather than simply exit. // BUG(4895): We should throw on detached buffers rather than simply exit.
witness.Recheck() otherwise break; witness.Recheck() otherwise break;
const value: Object = witness.Load(k); const value: JSAny = witness.Load(k);
const result = const result =
Call(context, callbackfn, thisArg, value, k, witness.GetStable()); Call(context, callbackfn, thisArg, value, k, witness.GetStable());
if (ToBoolean(result)) { if (ToBoolean(result)) {
...@@ -29,7 +29,7 @@ namespace typed_array_some { ...@@ -29,7 +29,7 @@ namespace typed_array_some {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some
transitioning javascript builtin transitioning javascript builtin
TypedArrayPrototypeSome(js-implicit context: Context, receiver: Object)( TypedArrayPrototypeSome(js-implicit context: Context, receiver: JSAny)(
...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg. // arguments[1] = thisArg.
......
...@@ -6,7 +6,7 @@ namespace typed_array_subarray { ...@@ -6,7 +6,7 @@ namespace typed_array_subarray {
// ES %TypedArray%.prototype.subarray // ES %TypedArray%.prototype.subarray
transitioning javascript builtin TypedArrayPrototypeSubArray( transitioning javascript builtin TypedArrayPrototypeSubArray(
js-implicit context: Context, js-implicit context: Context,
receiver: Object)(...arguments): JSTypedArray { receiver: JSAny)(...arguments): JSTypedArray {
const methodName: constexpr string = '%TypedArray%.prototype.subarray'; const methodName: constexpr string = '%TypedArray%.prototype.subarray';
// 1. Let O be the this value. // 1. Let O be the this value.
......
...@@ -51,9 +51,9 @@ namespace typed_array { ...@@ -51,9 +51,9 @@ namespace typed_array {
sizeLog2: uintptr; sizeLog2: uintptr;
kind: ElementsKind; kind: ElementsKind;
} }
extern runtime TypedArraySortFast(Context, Object): JSTypedArray; extern runtime TypedArraySortFast(Context, JSAny): JSTypedArray;
extern macro TypedArrayBuiltinsAssembler::ValidateTypedArray( extern macro TypedArrayBuiltinsAssembler::ValidateTypedArray(
Context, Object, constexpr string): JSTypedArray; Context, JSAny, constexpr string): JSTypedArray;
extern macro TypedArrayBuiltinsAssembler::CallCMemcpy( extern macro TypedArrayBuiltinsAssembler::CallCMemcpy(
RawPtr, RawPtr, uintptr): void; RawPtr, RawPtr, uintptr): void;
...@@ -72,10 +72,10 @@ namespace typed_array { ...@@ -72,10 +72,10 @@ namespace typed_array {
extern macro LoadFixedTypedArrayElementAsTagged( extern macro LoadFixedTypedArrayElementAsTagged(
RawPtr, Smi, constexpr ElementsKind): Numeric; RawPtr, Smi, constexpr ElementsKind): Numeric;
extern macro StoreJSTypedArrayElementFromTagged( extern macro StoreJSTypedArrayElementFromTagged(
Context, JSTypedArray, Smi, Object, constexpr ElementsKind); Context, JSTypedArray, Smi, JSAny, constexpr ElementsKind);
type LoadFn = builtin(Context, JSTypedArray, Smi) => Object; type LoadFn = builtin(Context, JSTypedArray, Smi) => JSAny;
type StoreFn = builtin(Context, JSTypedArray, Smi, Object) => Object; type StoreFn = builtin(Context, JSTypedArray, Smi, JSAny) => JSAny;
// AttachedJSTypedArray guards that the array's buffer is not detached. // AttachedJSTypedArray guards that the array's buffer is not detached.
transient type AttachedJSTypedArray extends JSTypedArray; transient type AttachedJSTypedArray extends JSTypedArray;
...@@ -100,7 +100,7 @@ namespace typed_array { ...@@ -100,7 +100,7 @@ namespace typed_array {
this.unstable = %RawDownCast<AttachedJSTypedArray>(this.stable); this.unstable = %RawDownCast<AttachedJSTypedArray>(this.stable);
} }
Load(implicit context: Context)(k: Smi): Object { Load(implicit context: Context)(k: Smi): JSAny {
const lf: LoadFn = this.loadfn; const lf: LoadFn = this.loadfn;
return lf(context, this.unstable, k); return lf(context, this.unstable, k);
} }
...@@ -190,14 +190,14 @@ namespace typed_array { ...@@ -190,14 +190,14 @@ namespace typed_array {
} }
builtin LoadFixedElement<T: type>( builtin LoadFixedElement<T: type>(
_context: Context, array: JSTypedArray, index: Smi): Object { _context: Context, array: JSTypedArray, index: Smi): JSAny {
return LoadFixedTypedArrayElementAsTagged( return LoadFixedTypedArrayElementAsTagged(
array.data_ptr, index, KindForArrayType<T>()); array.data_ptr, index, KindForArrayType<T>());
} }
builtin StoreFixedElement<T: type>( builtin StoreFixedElement<T: type>(
context: Context, typedArray: JSTypedArray, index: Smi, context: Context, typedArray: JSTypedArray, index: Smi,
value: Object): Object { value: JSAny): JSAny {
StoreJSTypedArrayElementFromTagged( StoreJSTypedArrayElementFromTagged(
context, typedArray, index, value, KindForArrayType<T>()); context, typedArray, index, value, KindForArrayType<T>());
return Undefined; return Undefined;
...@@ -205,7 +205,7 @@ namespace typed_array { ...@@ -205,7 +205,7 @@ namespace typed_array {
transitioning macro CallCompare( transitioning macro CallCompare(
implicit context: Context, array: JSTypedArray, implicit context: Context, array: JSTypedArray,
comparefn: Callable)(a: Object, b: Object): Number { comparefn: Callable)(a: JSAny, b: JSAny): Number {
// a. Let v be ? ToNumber(? Call(comparefn, undefined, x, y)). // a. Let v be ? ToNumber(? Call(comparefn, undefined, x, y)).
const v: Number = const v: Number =
ToNumber_Inline(context, Call(context, comparefn, Undefined, a, b)); ToNumber_Inline(context, Call(context, comparefn, Undefined, a, b));
...@@ -238,8 +238,8 @@ namespace typed_array { ...@@ -238,8 +238,8 @@ namespace typed_array {
target.objects[targetIndex] = source.objects[left++]; target.objects[targetIndex] = source.objects[left++];
} else if (left < middle) { } else if (left < middle) {
// If both have elements, we need to compare. // If both have elements, we need to compare.
const leftElement: Object = source.objects[left]; const leftElement = UnsafeCast<JSAny>(source.objects[left]);
const rightElement: Object = source.objects[right]; const rightElement = UnsafeCast<JSAny>(source.objects[right]);
if (CallCompare(leftElement, rightElement) <= 0) { if (CallCompare(leftElement, rightElement) <= 0) {
target.objects[targetIndex] = leftElement; target.objects[targetIndex] = leftElement;
left++; left++;
...@@ -259,7 +259,7 @@ namespace typed_array { ...@@ -259,7 +259,7 @@ namespace typed_array {
transitioning builtin transitioning builtin
TypedArrayMergeSort( TypedArrayMergeSort(
implicit context: Context, array: JSTypedArray, comparefn: Callable)( implicit context: Context, array: JSTypedArray, comparefn: Callable)(
source: FixedArray, from: Smi, to: Smi, target: FixedArray): Object { source: FixedArray, from: Smi, to: Smi, target: FixedArray): JSAny {
assert(to - from > 1); assert(to - from > 1);
const middle: Smi = from + ((to - from) >> 1); const middle: Smi = from + ((to - from) >> 1);
...@@ -277,17 +277,16 @@ namespace typed_array { ...@@ -277,17 +277,16 @@ namespace typed_array {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort
transitioning javascript builtin TypedArrayPrototypeSort( transitioning javascript builtin TypedArrayPrototypeSort(
js-implicit context: Context, js-implicit context: Context,
receiver: Object)(...arguments): JSTypedArray { receiver: JSAny)(...arguments): JSTypedArray {
// 1. If comparefn is not undefined and IsCallable(comparefn) is false, // 1. If comparefn is not undefined and IsCallable(comparefn) is false,
// throw a TypeError exception. // throw a TypeError exception.
const comparefnObj: Object = const comparefnObj: JSAny = arguments.length > 0 ? arguments[0] : Undefined;
arguments.length > 0 ? arguments[0] : Undefined;
if (comparefnObj != Undefined && !TaggedIsCallable(comparefnObj)) { if (comparefnObj != Undefined && !TaggedIsCallable(comparefnObj)) {
ThrowTypeError(kBadSortComparisonFunction, comparefnObj); ThrowTypeError(kBadSortComparisonFunction, comparefnObj);
} }
// 2. Let obj be the this value. // 2. Let obj be the this value.
const obj: Object = receiver; const obj: JSAny = receiver;
// 3. Let buffer be ? ValidateTypedArray(obj). // 3. Let buffer be ? ValidateTypedArray(obj).
// ValidateTypedArray currently returns the array, not the ViewBuffer. // ValidateTypedArray currently returns the array, not the ViewBuffer.
...@@ -363,7 +362,7 @@ namespace typed_array { ...@@ -363,7 +362,7 @@ namespace typed_array {
const work2: FixedArray = AllocateZeroedFixedArray(Convert<intptr>(len)); const work2: FixedArray = AllocateZeroedFixedArray(Convert<intptr>(len));
for (let i: Smi = 0; i < len; ++i) { for (let i: Smi = 0; i < len; ++i) {
const element: Object = loadfn(context, array, i); const element: JSAny = loadfn(context, array, i);
work1.objects[i] = element; work1.objects[i] = element;
work2.objects[i] = element; work2.objects[i] = element;
} }
...@@ -372,7 +371,7 @@ namespace typed_array { ...@@ -372,7 +371,7 @@ namespace typed_array {
// work1 contains the sorted numbers. Write them back. // work1 contains the sorted numbers. Write them back.
for (let i: Smi = 0; i < len; ++i) for (let i: Smi = 0; i < len; ++i)
storefn(context, array, i, work1.objects[i]); storefn(context, array, i, UnsafeCast<JSAny>(work1.objects[i]));
return array; return array;
} }
......
...@@ -133,6 +133,13 @@ bool Object::IsNullOrUndefined() const { ...@@ -133,6 +133,13 @@ bool Object::IsNullOrUndefined() const {
bool Object::IsZero() const { return *this == Smi::zero(); } bool Object::IsZero() const { return *this == Smi::zero(); }
bool Object::IsPublicSymbol() const {
return IsSymbol() && !Symbol::cast(*this).is_private();
}
bool Object::IsPrivateSymbol() const {
return IsSymbol() && Symbol::cast(*this).is_private();
}
bool Object::IsNoSharedNameSentinel() const { bool Object::IsNoSharedNameSentinel() const {
return *this == SharedFunctionInfo::kNoSharedNameSentinel; return *this == SharedFunctionInfo::kNoSharedNameSentinel;
} }
......
...@@ -289,6 +289,8 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> { ...@@ -289,6 +289,8 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> {
V8_INLINE bool IsZero() const; V8_INLINE bool IsZero() const;
V8_INLINE bool IsNoSharedNameSentinel() const; V8_INLINE bool IsNoSharedNameSentinel() const;
V8_INLINE bool IsPrivateSymbol() const;
V8_INLINE bool IsPublicSymbol() const;
enum class Conversion { kToNumber, kToNumeric }; enum class Conversion { kToNumber, kToNumeric };
......
...@@ -28,6 +28,7 @@ static const char* const JS_FUNCTION_TYPE_STRING = "JSFunction"; ...@@ -28,6 +28,7 @@ static const char* const JS_FUNCTION_TYPE_STRING = "JSFunction";
static const char* const MAP_TYPE_STRING = "Map"; static const char* const MAP_TYPE_STRING = "Map";
static const char* const OBJECT_TYPE_STRING = "Object"; static const char* const OBJECT_TYPE_STRING = "Object";
static const char* const HEAP_OBJECT_TYPE_STRING = "HeapObject"; static const char* const HEAP_OBJECT_TYPE_STRING = "HeapObject";
static const char* const JSANY_TYPE_STRING = "JSAny";
static const char* const JSOBJECT_TYPE_STRING = "JSObject"; static const char* const JSOBJECT_TYPE_STRING = "JSObject";
static const char* const SMI_TYPE_STRING = "Smi"; static const char* const SMI_TYPE_STRING = "Smi";
static const char* const TAGGED_TYPE_STRING = "Tagged"; static const char* const TAGGED_TYPE_STRING = "Tagged";
......
...@@ -468,13 +468,13 @@ void ImplementationVisitor::Visit(Builtin* builtin) { ...@@ -468,13 +468,13 @@ void ImplementationVisitor::Visit(Builtin* builtin) {
: "UncheckedCast<Object>(Parameter(Descriptor::kReceiver))") : "UncheckedCast<Object>(Parameter(Descriptor::kReceiver))")
<< ";\n"; << ";\n";
source_out() << "USE(" << generated_name << ");\n"; source_out() << "USE(" << generated_name << ");\n";
expected_type = TypeOracle::GetObjectType(); expected_type = TypeOracle::GetJSAnyType();
} else if (param_name == "newTarget") { } else if (param_name == "newTarget") {
source_out() << " TNode<Object> " << generated_name source_out() << " TNode<Object> " << generated_name
<< " = UncheckedCast<Object>(Parameter(" << " = UncheckedCast<Object>(Parameter("
<< "Descriptor::kJSNewTarget));\n"; << "Descriptor::kJSNewTarget));\n";
source_out() << "USE(" << generated_name << ");\n"; source_out() << "USE(" << generated_name << ");\n";
expected_type = TypeOracle::GetObjectType(); expected_type = TypeOracle::GetJSAnyType();
} else if (param_name == "target") { } else if (param_name == "target") {
source_out() << " TNode<JSFunction> " << generated_name source_out() << " TNode<JSFunction> " << generated_name
<< " = UncheckedCast<JSFunction>(Parameter(" << " = UncheckedCast<JSFunction>(Parameter("
...@@ -2264,9 +2264,10 @@ VisitResult ImplementationVisitor::GenerateCall( ...@@ -2264,9 +2264,10 @@ VisitResult ImplementationVisitor::GenerateCall(
size_t j = 0; size_t j = 0;
for (auto t : callable->signature().labels[i].types) { for (auto t : callable->signature().labels[i].types) {
const Type* parameter_type = label->parameter_types[j]; const Type* parameter_type = label->parameter_types[j];
if (parameter_type != t) { if (!t->IsSubtypeOf(parameter_type)) {
ReportError("mismatch of label parameters (expected ", *t, " got ", ReportError("mismatch of label parameters (label expects ",
parameter_type, " for parameter ", i + 1, ")"); *parameter_type, " but macro produces ", *t,
" for parameter ", i + 1, ")");
} }
j++; j++;
} }
......
...@@ -133,7 +133,7 @@ void CallCsaMacroInstruction::TypeInstruction(Stack<const Type*>* stack, ...@@ -133,7 +133,7 @@ void CallCsaMacroInstruction::TypeInstruction(Stack<const Type*>* stack,
if (catch_block) { if (catch_block) {
Stack<const Type*> catch_stack = *stack; Stack<const Type*> catch_stack = *stack;
catch_stack.Push(TypeOracle::GetObjectType()); catch_stack.Push(TypeOracle::GetJSAnyType());
(*catch_block)->SetInputTypes(catch_stack); (*catch_block)->SetInputTypes(catch_stack);
} }
...@@ -170,7 +170,7 @@ void CallCsaMacroAndBranchInstruction::TypeInstruction( ...@@ -170,7 +170,7 @@ void CallCsaMacroAndBranchInstruction::TypeInstruction(
if (catch_block) { if (catch_block) {
Stack<const Type*> catch_stack = *stack; Stack<const Type*> catch_stack = *stack;
catch_stack.Push(TypeOracle::GetObjectType()); catch_stack.Push(TypeOracle::GetJSAnyType());
(*catch_block)->SetInputTypes(catch_stack); (*catch_block)->SetInputTypes(catch_stack);
} }
...@@ -201,7 +201,7 @@ void CallBuiltinInstruction::TypeInstruction(Stack<const Type*>* stack, ...@@ -201,7 +201,7 @@ void CallBuiltinInstruction::TypeInstruction(Stack<const Type*>* stack,
if (catch_block) { if (catch_block) {
Stack<const Type*> catch_stack = *stack; Stack<const Type*> catch_stack = *stack;
catch_stack.Push(TypeOracle::GetObjectType()); catch_stack.Push(TypeOracle::GetJSAnyType());
(*catch_block)->SetInputTypes(catch_stack); (*catch_block)->SetInputTypes(catch_stack);
} }
...@@ -236,7 +236,7 @@ void CallRuntimeInstruction::TypeInstruction(Stack<const Type*>* stack, ...@@ -236,7 +236,7 @@ void CallRuntimeInstruction::TypeInstruction(Stack<const Type*>* stack,
if (catch_block) { if (catch_block) {
Stack<const Type*> catch_stack = *stack; Stack<const Type*> catch_stack = *stack;
catch_stack.Push(TypeOracle::GetObjectType()); catch_stack.Push(TypeOracle::GetJSAnyType());
(*catch_block)->SetInputTypes(catch_stack); (*catch_block)->SetInputTypes(catch_stack);
} }
......
...@@ -1136,7 +1136,7 @@ base::Optional<ParseResult> MakeCatchBlock(ParseResultIterator* child_results) { ...@@ -1136,7 +1136,7 @@ base::Optional<ParseResult> MakeCatchBlock(ParseResultIterator* child_results) {
ParameterList parameters; ParameterList parameters;
parameters.names.push_back(MakeNode<Identifier>(variable)); parameters.names.push_back(MakeNode<Identifier>(variable));
parameters.types.push_back(MakeNode<BasicTypeExpression>( parameters.types.push_back(MakeNode<BasicTypeExpression>(
std::vector<std::string>{}, "Object", std::vector<TypeExpression*>{})); std::vector<std::string>{}, "JSAny", std::vector<TypeExpression*>{}));
parameters.has_varargs = false; parameters.has_varargs = false;
LabelBlock* result = MakeNode<LabelBlock>( LabelBlock* result = MakeNode<LabelBlock>(
MakeNode<Identifier>(kCatchLabelName), std::move(parameters), body); MakeNode<Identifier>(kCatchLabelName), std::move(parameters), body);
......
...@@ -143,6 +143,10 @@ class TypeOracle : public ContextualClass<TypeOracle> { ...@@ -143,6 +143,10 @@ class TypeOracle : public ContextualClass<TypeOracle> {
return Get().GetBuiltinType(HEAP_OBJECT_TYPE_STRING); return Get().GetBuiltinType(HEAP_OBJECT_TYPE_STRING);
} }
static const Type* GetJSAnyType() {
return Get().GetBuiltinType(JSANY_TYPE_STRING);
}
static const Type* GetJSObjectType() { static const Type* GetJSObjectType() {
return Get().GetBuiltinType(JSOBJECT_TYPE_STRING); return Get().GetBuiltinType(JSOBJECT_TYPE_STRING);
} }
......
...@@ -83,11 +83,11 @@ namespace test { ...@@ -83,11 +83,11 @@ namespace test {
} }
} }
builtin GenericBuiltinTest<T: type>(_c: Context, _param: T): Object { builtin GenericBuiltinTest<T: type>(_c: Context, _param: T): JSAny {
return Null; return Null;
} }
GenericBuiltinTest<Object>(_c: Context, param: Object): Object { GenericBuiltinTest<JSAny>(_c: Context, param: JSAny): JSAny {
return param; return param;
} }
...@@ -95,8 +95,8 @@ namespace test { ...@@ -95,8 +95,8 @@ namespace test {
macro TestBuiltinSpecialization(c: Context) { macro TestBuiltinSpecialization(c: Context) {
check(GenericBuiltinTest<Smi>(c, 0) == Null); check(GenericBuiltinTest<Smi>(c, 0) == Null);
check(GenericBuiltinTest<Smi>(c, 1) == Null); check(GenericBuiltinTest<Smi>(c, 1) == Null);
check(GenericBuiltinTest<Object>(c, Undefined) == Undefined); check(GenericBuiltinTest<JSAny>(c, Undefined) == Undefined);
check(GenericBuiltinTest<Object>(c, Undefined) == Undefined); check(GenericBuiltinTest<JSAny>(c, Undefined) == Undefined);
} }
macro LabelTestHelper4(flag: constexpr bool): never macro LabelTestHelper4(flag: constexpr bool): never
...@@ -202,9 +202,8 @@ namespace test { ...@@ -202,9 +202,8 @@ namespace test {
@export @export
macro TestFunctionPointerToGeneric(c: Context) { macro TestFunctionPointerToGeneric(c: Context) {
const fptr1: builtin(Context, Smi) => Object = GenericBuiltinTest<Smi>; const fptr1: builtin(Context, Smi) => JSAny = GenericBuiltinTest<Smi>;
const fptr2: builtin(Context, Object) => Object = const fptr2: builtin(Context, JSAny) => JSAny = GenericBuiltinTest<JSAny>;
GenericBuiltinTest<Object>;
check(fptr1(c, 0) == Null); check(fptr1(c, 0) == Null);
check(fptr1(c, 1) == Null); check(fptr1(c, 1) == Null);
...@@ -212,7 +211,7 @@ namespace test { ...@@ -212,7 +211,7 @@ namespace test {
check(fptr2(c, Undefined) == Undefined); check(fptr2(c, Undefined) == Undefined);
} }
type ObjectToObject = builtin(Context, Object) => Object; type ObjectToObject = builtin(Context, JSAny) => JSAny;
@export @export
macro TestTypeAlias(x: ObjectToObject): BuiltinPtr { macro TestTypeAlias(x: ObjectToObject): BuiltinPtr {
return x; return x;
...@@ -452,7 +451,7 @@ namespace test { ...@@ -452,7 +451,7 @@ namespace test {
@export @export
macro TestSubtyping(x: Smi) { macro TestSubtyping(x: Smi) {
const _foo: Object = x; const _foo: JSAny = x;
} }
macro IncrementIfSmi<A: type>(x: A): A { macro IncrementIfSmi<A: type>(x: A): A {
...@@ -627,7 +626,7 @@ namespace test { ...@@ -627,7 +626,7 @@ namespace test {
@export @export
macro TestQualifiedAccess(implicit context: Context)() { macro TestQualifiedAccess(implicit context: Context)() {
const s: Smi = 0; const s: Smi = 0;
check(!array::IsJSArray(s)); check(!Is<JSArray>(s));
} }
@export @export
...@@ -685,14 +684,14 @@ namespace test { ...@@ -685,14 +684,14 @@ namespace test {
@export @export
macro TestIterator(implicit context: Context)(o: JSReceiver, map: Map) { macro TestIterator(implicit context: Context)(o: JSReceiver, map: Map) {
try { try {
const t1: Object = iterator::GetIteratorMethod(o); const t1: JSAny = iterator::GetIteratorMethod(o);
const t2: iterator::IteratorRecord = iterator::GetIterator(o); const t2: iterator::IteratorRecord = iterator::GetIterator(o);
const _t3: Object = iterator::IteratorStep(t2) otherwise Fail; const _t3: JSAny = iterator::IteratorStep(t2) otherwise Fail;
const _t4: Object = iterator::IteratorStep(t2, map) otherwise Fail; const _t4: JSAny = iterator::IteratorStep(t2, map) otherwise Fail;
const t5: Object = iterator::IteratorValue(o); const t5: JSAny = iterator::IteratorValue(o);
const _t6: Object = iterator::IteratorValue(o, map); const _t6: JSAny = iterator::IteratorValue(o, map);
const _t7: JSArray = iterator::IterableToList(t1, t1); const _t7: JSArray = iterator::IterableToList(t1, t1);
......
This diff is collapsed.
...@@ -20,18 +20,9 @@ kPercentEscape = r'α'; # Unicode alpha ...@@ -20,18 +20,9 @@ kPercentEscape = r'α'; # Unicode alpha
def preprocess(input): def preprocess(input):
input = re.sub(r'(if\s+)constexpr(\s*\()', r'\1/*COxp*/\2', input) input = re.sub(r'(if\s+)constexpr(\s*\()', r'\1/*COxp*/\2', input)
input = re.sub(r'(\s+)operator\s*(\'[^\']+\')', r'\1/*_OPE \2*/', input) input = re.sub(r'(\s+)operator\s*(\'[^\']+\')', r'\1/*_OPE \2*/', input)
input = re.sub(r'\btypeswitch\s*(\([^{]*\))\s{', r' if /*tPsW*/ \1 {', input)
# Mangle typeswitches to look like switch statements with the extra type input = re.sub(r'\bcase\s*(\([^{]*\))\s*:\s*deferred\s*{', r' if /*cAsEdEfF*/ \1 {', input)
# information and syntax encoded in comments. input = re.sub(r'\bcase\s*(\([^{]*\))\s*:\s*{', r' if /*cA*/ \1 {', input)
input = re.sub(r'(\s+)typeswitch\s*\(', r'\1/*_TYPE*/switch (', input)
input = re.sub(r'(\s+)case\s*\(\s*([^\:]+)\s*\)(\s*)\:\s*deferred',
r'\1case \2: /*_TSXDEFERRED_*/', input)
input = re.sub(r'(\s+)case\s*\(\s*([^\:]+)\s*\)(\s*)\:',
r'\1case \2: /*_TSX*/', input)
input = re.sub(r'(\s+)case\s*\(\s*([^\s]+)\s*\:\s*([^\:]+)\s*\)(\s*)\:\s*deferred',
r'\1case \3: /*_TSVDEFERRED_\2:*/', input)
input = re.sub(r'(\s+)case\s*\(\s*([^\s]+)\s*\:\s*([^\:]+)\s*\)(\s*)\:',
r'\1case \3: /*_TSV\2:*/', input)
# Add extra space around | operators to fix union types later. # Add extra space around | operators to fix union types later.
while True: while True:
...@@ -65,15 +56,9 @@ def postprocess(output): ...@@ -65,15 +56,9 @@ def postprocess(output):
output = re.sub(r'(\S+)\s*: type([,>])', r'\1: type\2', output) output = re.sub(r'(\S+)\s*: type([,>])', r'\1: type\2', output)
output = re.sub(r'(\n\s*)labels( [A-Z])', r'\1 labels\2', output) output = re.sub(r'(\n\s*)labels( [A-Z])', r'\1 labels\2', output)
output = re.sub(r'\/\*_OPE \'([^\']+)\'\*\/', r"operator '\1'", output) output = re.sub(r'\/\*_OPE \'([^\']+)\'\*\/', r"operator '\1'", output)
output = re.sub(r'\/\*_TYPE\*\/(\s*)switch', r'typeswitch', output) output = re.sub(r'\bif\s*\/\*tPsW\*\/', r'typeswitch', output)
output = re.sub(r'case (\w+)\:\s*\/\*_TSXDEFERRED_\*\/', output = re.sub(r'\bif\s*\/\*cA\*\/\s*(\([^{]*\))\s*{', r'case \1: {', output)
r'case (\1): deferred', output) output = re.sub(r'\bif\s*\/\*cAsEdEfF\*\/\s*(\([^{]*\))\s*{', r'case \1: deferred {', output)
output = re.sub(r'case (\w+)\:\s*\/\*_TSX\*\/',
r'case (\1):', output)
output = re.sub(r'case (\w+)\:\s*\/\*_TSVDEFERRED_([^\:]+)\:\*\/',
r'case (\2: \1): deferred', output)
output = re.sub(r'case (\w+)\:\s*\/\*_TSV([^\:]+)\:\*\/',
r'case (\2: \1):', output)
output = re.sub(r'\n_GeNeRaTeS00_\s*\/\*([^@]+)@\*\/', output = re.sub(r'\n_GeNeRaTeS00_\s*\/\*([^@]+)@\*\/',
r"\n generates '\1'", output) r"\n generates '\1'", output)
output = re.sub(r'_GeNeRaTeS00_\s*\/\*([^@]+)@\*\/', output = re.sub(r'_GeNeRaTeS00_\s*\/\*([^@]+)@\*\/',
......
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