Commit 6eff6cc9 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] introduce separate implicit parameters for JavaScript calling convention

Implicit parameters for builtins with JavaScript linkage are now separate, using
the keyword "js-implicit". They have to be one of:
- context: Context
- receiver: Object (this in JS)
- target: JSFunction (arguments.callee in JS)
- newTarget: Object (new.target in JS)

Bug: v8:9120 v8:7793

Change-Id: I916f60971bb53d5046b6006725d0ce39291ca55e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1658159Reviewed-by: 's avatarTamer Tas <tmrts@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62174}
parent a66e3e57
...@@ -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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
// 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);
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array { namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayEveryLoopEagerDeoptContinuation(implicit context: Context)( ArrayEveryLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
length: Object): Object { 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
...@@ -25,9 +26,10 @@ namespace array { ...@@ -25,9 +26,10 @@ namespace array {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayEveryLoopLazyDeoptContinuation(implicit context: Context)( ArrayEveryLoopLazyDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
length: Object, result: Object): Object { callback: Object, thisArg: Object, initialK: Object, length: Object,
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.
...@@ -109,7 +111,7 @@ namespace array { ...@@ -109,7 +111,7 @@ 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(implicit context: Context)(receiver: Object, ...arguments): ArrayEvery(js-implicit context: Context, receiver: Object)(...arguments):
Object { Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
namespace array_filter { namespace array_filter {
transitioning javascript builtin transitioning javascript builtin
ArrayFilterLoopEagerDeoptContinuation(implicit context: Context)( ArrayFilterLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, array: Object, js-implicit context: Context, receiver: Object)(
initialK: Object, length: Object, initialTo: Object): Object { callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object, initialTo: 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.
...@@ -27,9 +28,10 @@ namespace array_filter { ...@@ -27,9 +28,10 @@ namespace array_filter {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayFilterLoopLazyDeoptContinuation(implicit context: Context)( ArrayFilterLoopLazyDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, array: Object, js-implicit context: Context, receiver: Object)(
initialK: Object, length: Object, valueK: Object, initialTo: Object, callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object, valueK: Object, initialTo: Object,
result: Object): Object { 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
...@@ -42,9 +44,9 @@ namespace array_filter { ...@@ -42,9 +44,9 @@ namespace array_filter {
const numberLength = Cast<Number>(length) otherwise unreachable; const numberLength = Cast<Number>(length) otherwise unreachable;
// This custom lazy deopt point is right after the callback. filter() needs // This custom lazy deopt point is right after the callback. filter() needs
// to pick up at the next step, which is setting the callback result in // to pick up at the next step, which is setting the callback
// the output array. After incrementing k and to, we can glide into the loop // result in the output array. After incrementing k and to, we can glide
// continuation builtin. // into the loop continuation builtin.
if (ToBoolean(result)) { if (ToBoolean(result)) {
FastCreateDataProperty(outputArray, numberTo, valueK); FastCreateDataProperty(outputArray, numberTo, valueK);
numberTo = numberTo + 1; numberTo = numberTo + 1;
...@@ -145,7 +147,7 @@ namespace array_filter { ...@@ -145,7 +147,7 @@ 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(implicit context: Context)(receiver: Object, ...arguments): ArrayFilter(js-implicit context: Context, receiver: Object)(...arguments):
Object { Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array_find { namespace array_find {
transitioning javascript builtin transitioning javascript builtin
ArrayFindLoopEagerDeoptContinuation(implicit context: Context)( ArrayFindLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
length: Object): Object { 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
...@@ -24,9 +25,10 @@ namespace array_find { ...@@ -24,9 +25,10 @@ namespace array_find {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayFindLoopLazyDeoptContinuation(implicit context: Context)( ArrayFindLoopLazyDeoptContinuation(
_receiver: Object, _callback: Object, _thisArg: Object, _initialK: Object, js-implicit context: Context, receiver: Object)(
_length: Object, _result: Object): Object { _callback: Object, _thisArg: Object, _initialK: Object, _length: Object,
_result: Object): Object {
// 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.
...@@ -37,9 +39,10 @@ namespace array_find { ...@@ -37,9 +39,10 @@ namespace array_find {
// happens right after the callback and it's returned value must be handled // happens right after the callback and it's returned value must be handled
// before iteration continues. // before iteration continues.
transitioning javascript builtin transitioning javascript builtin
ArrayFindLoopAfterCallbackLazyDeoptContinuation(implicit context: Context)( ArrayFindLoopAfterCallbackLazyDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
length: Object, foundValue: Object, isFound: Object): Object { callback: Object, thisArg: Object, initialK: Object, length: Object,
foundValue: Object, isFound: 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.
...@@ -116,8 +119,8 @@ namespace array_find { ...@@ -116,8 +119,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(implicit context: Context)(receiver: Object, ...arguments): ArrayPrototypeFind(js-implicit context: Context, receiver: Object)(
Object { ...arguments): Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError; goto NullOrUndefinedError;
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array_findindex { namespace array_findindex {
transitioning javascript builtin transitioning javascript builtin
ArrayFindIndexLoopEagerDeoptContinuation(implicit context: Context)( ArrayFindIndexLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
length: Object): Object { 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
...@@ -24,9 +25,10 @@ namespace array_findindex { ...@@ -24,9 +25,10 @@ namespace array_findindex {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayFindIndexLoopLazyDeoptContinuation(implicit context: Context)( ArrayFindIndexLoopLazyDeoptContinuation(
_receiver: Object, _callback: Object, _thisArg: Object, _initialK: Object, js-implicit context: Context, receiver: Object)(
_length: Object, _result: Object): Object { _callback: Object, _thisArg: Object, _initialK: Object, _length: Object,
_result: Object): Object {
// 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.
...@@ -37,10 +39,10 @@ namespace array_findindex { ...@@ -37,10 +39,10 @@ namespace array_findindex {
// happens right after the callback and it's returned value must be handled // happens right after the callback and it's returned value must be handled
// before iteration continues. // before iteration continues.
transitioning javascript builtin transitioning javascript builtin
ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(implicit context: ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(
Context)( js-implicit context: Context, receiver: Object)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, callback: Object, thisArg: Object, initialK: Object, length: Object,
length: Object, foundValue: Object, isFound: Object): Object { foundValue: Object, isFound: 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.
...@@ -118,8 +120,8 @@ namespace array_findindex { ...@@ -118,8 +120,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(implicit context: ArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)(
Context)(receiver: Object, ...arguments): Object { ...arguments): Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError; goto NullOrUndefinedError;
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array_foreach { namespace array_foreach {
transitioning javascript builtin transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation(implicit context: Context)( ArrayForEachLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
length: Object): Object { 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
...@@ -21,9 +22,10 @@ namespace array_foreach { ...@@ -21,9 +22,10 @@ namespace array_foreach {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayForEachLoopLazyDeoptContinuation(implicit context: Context)( ArrayForEachLoopLazyDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
length: Object, _result: Object): Object { callback: Object, thisArg: Object, initialK: Object, length: Object,
_result: 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.
...@@ -90,7 +92,8 @@ namespace array_foreach { ...@@ -90,7 +92,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(context: Context, receiver: Object, ...arguments): Object { ArrayForEach(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError; goto NullOrUndefinedError;
......
...@@ -557,7 +557,8 @@ namespace array_join { ...@@ -557,7 +557,8 @@ 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(context: Context, receiver: Object, ...arguments): Object { ArrayPrototypeJoin(js-implicit context: Context, receiver: Object)(
...arguments): Object {
const separator: Object = arguments[0]; const separator: Object = arguments[0];
// 1. Let O be ? ToObject(this value). // 1. Let O be ? ToObject(this value).
...@@ -566,8 +567,8 @@ namespace array_join { ...@@ -566,8 +567,8 @@ namespace array_join {
// 2. Let len be ? ToLength(? Get(O, "length")). // 2. Let len be ? ToLength(? Get(O, "length")).
const len: Number = GetLengthProperty(o); const len: Number = GetLengthProperty(o);
// Only handle valid array lengths. Although the spec allows larger values, // Only handle valid array lengths. Although the spec allows larger
// this matches historical V8 behavior. // values, this matches historical V8 behavior.
if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength); if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength);
return CycleProtectedArrayJoin<JSArray>( return CycleProtectedArrayJoin<JSArray>(
...@@ -576,7 +577,7 @@ namespace array_join { ...@@ -576,7 +577,7 @@ 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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const locales: Object = arguments[0]; const locales: Object = arguments[0];
const options: Object = arguments[1]; const options: Object = arguments[1];
...@@ -586,8 +587,8 @@ namespace array_join { ...@@ -586,8 +587,8 @@ namespace array_join {
// 2. Let len be ? ToLength(? Get(O, "length")). // 2. Let len be ? ToLength(? Get(O, "length")).
const len: Number = GetLengthProperty(o); const len: Number = GetLengthProperty(o);
// Only handle valid array lengths. Although the spec allows larger values, // Only handle valid array lengths. Although the spec allows larger
// this matches historical V8 behavior. // values, this matches historical V8 behavior.
if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength); if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength);
return CycleProtectedArrayJoin<JSArray>( return CycleProtectedArrayJoin<JSArray>(
...@@ -596,7 +597,7 @@ namespace array_join { ...@@ -596,7 +597,7 @@ 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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
// 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);
...@@ -617,7 +618,7 @@ namespace array_join { ...@@ -617,7 +618,7 @@ 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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const separator: Object = arguments[0]; const separator: Object = arguments[0];
// Spec: ValidateTypedArray is applied to the this value prior to evaluating // Spec: ValidateTypedArray is applied to the this value prior to evaluating
...@@ -632,7 +633,7 @@ namespace array_join { ...@@ -632,7 +633,7 @@ 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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const locales: Object = arguments[0]; const locales: Object = arguments[0];
const options: Object = arguments[1]; const options: Object = arguments[1];
......
...@@ -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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
// 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);
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
namespace array_map { namespace array_map {
transitioning javascript builtin transitioning javascript builtin
ArrayMapLoopEagerDeoptContinuation(implicit context: Context)( ArrayMapLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, array: Object, js-implicit context: Context, receiver: Object)(
initialK: Object, length: Object): Object { callback: Object, thisArg: Object, array: Object, initialK: Object,
length: 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.
...@@ -26,9 +27,10 @@ namespace array_map { ...@@ -26,9 +27,10 @@ namespace array_map {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayMapLoopLazyDeoptContinuation(implicit context: Context)( ArrayMapLoopLazyDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, array: Object, js-implicit context: Context, receiver: Object)(
initialK: Object, length: Object, result: Object): Object { callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object, 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.
...@@ -222,7 +224,8 @@ namespace array_map { ...@@ -222,7 +224,8 @@ 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(implicit context: Context)(receiver: Object, ...arguments): Object { ArrayMap(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try { try {
if (IsNullOrUndefined(receiver)) goto NullOrUndefinedError; if (IsNullOrUndefined(receiver)) goto NullOrUndefinedError;
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
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(implicit context: Context)(receiver: Object, ...arguments): Object { ArrayOf(js-implicit context: Context, receiver: Object)(...arguments):
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);
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array { namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRightPreLoopEagerDeoptContinuation(implicit context: Context)( ArrayReduceRightPreLoopEagerDeoptContinuation(
receiver: Object, callback: Object, length: Object): Object { js-implicit context: Context,
receiver: Object)(callback: Object, 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.
...@@ -25,8 +26,9 @@ namespace array { ...@@ -25,8 +26,9 @@ namespace array {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRightLoopEagerDeoptContinuation(implicit context: Context)( ArrayReduceRightLoopEagerDeoptContinuation(
receiver: Object, callback: Object, initialK: Object, length: Object, js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
accumulator: Object): Object { accumulator: 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
...@@ -45,8 +47,9 @@ namespace array { ...@@ -45,8 +47,9 @@ namespace array {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayReduceRightLoopLazyDeoptContinuation(implicit context: Context)( ArrayReduceRightLoopLazyDeoptContinuation(
receiver: Object, callback: Object, initialK: Object, length: Object, js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
result: Object): Object { 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
...@@ -139,8 +142,8 @@ namespace array { ...@@ -139,8 +142,8 @@ namespace array {
// 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(implicit context: Context)(receiver: Object, ...arguments): ArrayReduceRight(js-implicit context: Context, receiver: Object)(
Object { ...arguments): Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError; goto NullOrUndefinedError;
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array { namespace array {
transitioning javascript builtin transitioning javascript builtin
ArrayReducePreLoopEagerDeoptContinuation(implicit context: Context)( ArrayReducePreLoopEagerDeoptContinuation(
receiver: Object, callback: Object, length: Object): Object { js-implicit context: Context,
receiver: Object)(callback: Object, 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.
...@@ -25,8 +26,9 @@ namespace array { ...@@ -25,8 +26,9 @@ namespace array {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayReduceLoopEagerDeoptContinuation(implicit context: Context)( ArrayReduceLoopEagerDeoptContinuation(
receiver: Object, callback: Object, initialK: Object, length: Object, js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
accumulator: Object): Object { accumulator: 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
...@@ -45,8 +47,9 @@ namespace array { ...@@ -45,8 +47,9 @@ namespace array {
} }
transitioning javascript builtin transitioning javascript builtin
ArrayReduceLoopLazyDeoptContinuation(implicit context: Context)( ArrayReduceLoopLazyDeoptContinuation(
receiver: Object, callback: Object, initialK: Object, length: Object, js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
result: Object): Object { 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
...@@ -139,7 +142,7 @@ namespace array { ...@@ -139,7 +142,7 @@ namespace array {
// 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(implicit context: Context)(receiver: Object, ...arguments): ArrayReduce(js-implicit context: Context, receiver: Object)(...arguments):
Object { Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
......
...@@ -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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
try { try {
TryFastPackedArrayReverse(receiver) otherwise Baseline; TryFastPackedArrayReverse(receiver) otherwise Baseline;
return receiver; return receiver;
......
...@@ -103,7 +103,7 @@ namespace array_shift { ...@@ -103,7 +103,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(
implicit context: Context)(receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
try { try {
return TryFastArrayShift(receiver, arguments) otherwise Slow; return TryFastArrayShift(receiver, arguments) otherwise Slow;
} }
......
...@@ -122,8 +122,8 @@ namespace array_slice { ...@@ -122,8 +122,8 @@ 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(context: Context, receiver: Object, ...arguments): ArrayPrototypeSlice(js-implicit context: Context, receiver: Object)(
Object { ...arguments): Object {
// 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) {
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace array { namespace array {
transitioning javascript builtin transitioning javascript builtin
ArraySomeLoopEagerDeoptContinuation(implicit context: Context)( ArraySomeLoopEagerDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
length: Object): Object { 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
...@@ -25,9 +26,10 @@ namespace array { ...@@ -25,9 +26,10 @@ namespace array {
} }
transitioning javascript builtin transitioning javascript builtin
ArraySomeLoopLazyDeoptContinuation(implicit context: Context)( ArraySomeLoopLazyDeoptContinuation(
receiver: Object, callback: Object, thisArg: Object, initialK: Object, js-implicit context: Context, receiver: Object)(
length: Object, result: Object): Object { callback: Object, thisArg: Object, initialK: Object, length: Object,
result: 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.
...@@ -109,7 +111,8 @@ namespace array { ...@@ -109,7 +111,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(implicit context: Context)(receiver: Object, ...arguments): Object { ArraySome(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try { try {
if (IsNullOrUndefined(receiver)) { if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError; goto NullOrUndefinedError;
......
...@@ -350,8 +350,8 @@ namespace array_splice { ...@@ -350,8 +350,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(context: Context, receiver: Object, ...arguments): ArrayPrototypeSplice(js-implicit context: Context, receiver: Object)(
Object { ...arguments): Object {
// 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);
......
...@@ -93,7 +93,7 @@ namespace array_unshift { ...@@ -93,7 +93,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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
try { try {
TryFastArrayUnshift(context, receiver, arguments) otherwise Baseline; TryFastArrayUnshift(context, receiver, arguments) otherwise Baseline;
} }
......
...@@ -3,24 +3,16 @@ ...@@ -3,24 +3,16 @@
// found in the LICENSE file. // found in the LICENSE file.
namespace boolean { namespace boolean {
// TODO(v8:9120): This is a workaround to get access to target and new.target
// in javascript builtins. Requires cleanup once this is fully supported by
// torque.
const NEW_TARGET_INDEX:
constexpr int32 generates 'Descriptor::kJSNewTarget';
const TARGET_INDEX: constexpr int32 generates 'Descriptor::kJSTarget';
extern macro Parameter(constexpr int32): Object;
javascript builtin javascript builtin
BooleanConstructor(context: Context, receiver: Object, ...arguments): Object { BooleanConstructor(
js-implicit context: Context, receiver: Object, newTarget: Object,
target: JSFunction)(...arguments): Object {
const value = SelectBooleanConstant(ToBoolean(arguments[0])); const value = SelectBooleanConstant(ToBoolean(arguments[0]));
const newTarget = Parameter(NEW_TARGET_INDEX);
if (newTarget == Undefined) { if (newTarget == Undefined) {
return value; return value;
} }
const target = UnsafeCast<JSFunction>(Parameter(TARGET_INDEX));
const map = GetDerivedMap(target, UnsafeCast<JSReceiver>(newTarget)); const map = GetDerivedMap(target, UnsafeCast<JSReceiver>(newTarget));
const obj = UnsafeCast<JSValue>(AllocateFastOrSlowJSObjectFromMap(map)); const obj = UnsafeCast<JSValue>(AllocateFastOrSlowJSObjectFromMap(map));
......
...@@ -136,11 +136,6 @@ Node* ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(Node* proxy, ...@@ -136,11 +136,6 @@ Node* ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(Node* proxy,
proxy_context); proxy_context);
} }
Node* ProxiesCodeStubAssembler::GetProxyConstructorJSNewTarget() {
return CodeAssembler::Parameter(static_cast<int>(
Builtin_ProxyConstructor_InterfaceDescriptor::kJSNewTarget));
}
TF_BUILTIN(CallProxy, ProxiesCodeStubAssembler) { TF_BUILTIN(CallProxy, ProxiesCodeStubAssembler) {
Node* argc = Parameter(Descriptor::kActualArgumentsCount); Node* argc = Parameter(Descriptor::kActualArgumentsCount);
Node* argc_ptr = ChangeInt32ToIntPtr(argc); Node* argc_ptr = ChangeInt32ToIntPtr(argc);
......
...@@ -20,10 +20,6 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler { ...@@ -20,10 +20,6 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler {
Node* AllocateProxy(Node* target, Node* handler, Node* context); Node* AllocateProxy(Node* target, Node* handler, Node* context);
Node* AllocateProxyRevokeFunction(Node* proxy, Node* context); Node* AllocateProxyRevokeFunction(Node* proxy, Node* context);
// Get JSNewTarget parameter for ProxyConstructor builtin (Torque).
// TODO(v8:9120): Remove this once torque support exists
Node* GetProxyConstructorJSNewTarget();
Node* CheckGetSetTrapResult(Node* context, Node* target, Node* proxy, Node* CheckGetSetTrapResult(Node* context, Node* target, Node* proxy,
Node* name, Node* trap_result, Node* name, Node* trap_result,
JSProxy::AccessKind access_kind); JSProxy::AccessKind access_kind);
......
...@@ -74,7 +74,8 @@ namespace data_view { ...@@ -74,7 +74,8 @@ namespace data_view {
// ES6 section 24.2.4.1 get DataView.prototype.buffer // ES6 section 24.2.4.1 get DataView.prototype.buffer
javascript builtin DataViewPrototypeGetBuffer( javascript builtin DataViewPrototypeGetBuffer(
context: Context, receiver: Object, ...arguments): JSArrayBuffer { js-implicit context: Context,
receiver: Object)(...arguments): JSArrayBuffer {
const dataView: JSDataView = const dataView: JSDataView =
ValidateDataView(context, receiver, 'get DataView.prototype.buffer'); ValidateDataView(context, receiver, 'get DataView.prototype.buffer');
return dataView.buffer; return dataView.buffer;
...@@ -82,7 +83,7 @@ namespace data_view { ...@@ -82,7 +83,7 @@ namespace data_view {
// ES6 section 24.2.4.2 get DataView.prototype.byteLength // ES6 section 24.2.4.2 get DataView.prototype.byteLength
javascript builtin DataViewPrototypeGetByteLength( javascript builtin DataViewPrototypeGetByteLength(
context: Context, receiver: Object, ...arguments): Number { js-implicit context: Context, receiver: Object)(...arguments): Number {
const dataView: JSDataView = ValidateDataView( const dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_length'); context, receiver, 'get DataView.prototype.byte_length');
if (WasNeutered(dataView)) { if (WasNeutered(dataView)) {
...@@ -95,7 +96,7 @@ namespace data_view { ...@@ -95,7 +96,7 @@ namespace data_view {
// ES6 section 24.2.4.3 get DataView.prototype.byteOffset // ES6 section 24.2.4.3 get DataView.prototype.byteOffset
javascript builtin DataViewPrototypeGetByteOffset( javascript builtin DataViewPrototypeGetByteOffset(
context: Context, receiver: Object, ...arguments): Number { js-implicit context: Context, receiver: Object)(...arguments): Number {
const dataView: JSDataView = ValidateDataView( const dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_offset'); context, receiver, 'get DataView.prototype.byte_offset');
if (WasNeutered(dataView)) { if (WasNeutered(dataView)) {
...@@ -415,19 +416,19 @@ namespace data_view { ...@@ -415,19 +416,19 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetUint8( transitioning javascript builtin DataViewPrototypeGetUint8(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
return DataViewGet(context, receiver, offset, Undefined, UINT8_ELEMENTS); return DataViewGet(context, receiver, offset, Undefined, UINT8_ELEMENTS);
} }
transitioning javascript builtin DataViewPrototypeGetInt8( transitioning javascript builtin DataViewPrototypeGetInt8(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
return DataViewGet(context, receiver, offset, Undefined, INT8_ELEMENTS); return DataViewGet(context, receiver, offset, Undefined, INT8_ELEMENTS);
} }
transitioning javascript builtin DataViewPrototypeGetUint16( transitioning javascript builtin DataViewPrototypeGetUint16(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -436,7 +437,7 @@ namespace data_view { ...@@ -436,7 +437,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetInt16( transitioning javascript builtin DataViewPrototypeGetInt16(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -445,7 +446,7 @@ namespace data_view { ...@@ -445,7 +446,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetUint32( transitioning javascript builtin DataViewPrototypeGetUint32(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -454,7 +455,7 @@ namespace data_view { ...@@ -454,7 +455,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetInt32( transitioning javascript builtin DataViewPrototypeGetInt32(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -463,7 +464,7 @@ namespace data_view { ...@@ -463,7 +464,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetFloat32( transitioning javascript builtin DataViewPrototypeGetFloat32(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -472,7 +473,7 @@ namespace data_view { ...@@ -472,7 +473,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetFloat64( transitioning javascript builtin DataViewPrototypeGetFloat64(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -481,7 +482,7 @@ namespace data_view { ...@@ -481,7 +482,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetBigUint64( transitioning javascript builtin DataViewPrototypeGetBigUint64(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -490,7 +491,7 @@ namespace data_view { ...@@ -490,7 +491,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeGetBigInt64( transitioning javascript builtin DataViewPrototypeGetBigInt64(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined; arguments.length > 1 ? arguments[1] : Undefined;
...@@ -717,7 +718,7 @@ namespace data_view { ...@@ -717,7 +718,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetUint8( transitioning javascript builtin DataViewPrototypeSetUint8(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
return DataViewSet( return DataViewSet(
...@@ -725,7 +726,7 @@ namespace data_view { ...@@ -725,7 +726,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetInt8( transitioning javascript builtin DataViewPrototypeSetInt8(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
return DataViewSet( return DataViewSet(
...@@ -733,7 +734,7 @@ namespace data_view { ...@@ -733,7 +734,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetUint16( transitioning javascript builtin DataViewPrototypeSetUint16(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -743,7 +744,7 @@ namespace data_view { ...@@ -743,7 +744,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetInt16( transitioning javascript builtin DataViewPrototypeSetInt16(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -753,7 +754,7 @@ namespace data_view { ...@@ -753,7 +754,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetUint32( transitioning javascript builtin DataViewPrototypeSetUint32(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -763,7 +764,7 @@ namespace data_view { ...@@ -763,7 +764,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetInt32( transitioning javascript builtin DataViewPrototypeSetInt32(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -773,7 +774,7 @@ namespace data_view { ...@@ -773,7 +774,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetFloat32( transitioning javascript builtin DataViewPrototypeSetFloat32(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -783,7 +784,7 @@ namespace data_view { ...@@ -783,7 +784,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetFloat64( transitioning javascript builtin DataViewPrototypeSetFloat64(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -793,7 +794,7 @@ namespace data_view { ...@@ -793,7 +794,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetBigUint64( transitioning javascript builtin DataViewPrototypeSetBigUint64(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
...@@ -803,7 +804,7 @@ namespace data_view { ...@@ -803,7 +804,7 @@ namespace data_view {
} }
transitioning javascript builtin DataViewPrototypeSetBigInt64( transitioning javascript builtin DataViewPrototypeSetBigInt64(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined; const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined; const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object = const isLittleEndian: Object =
......
...@@ -8,17 +8,18 @@ namespace extras_utils { ...@@ -8,17 +8,18 @@ namespace extras_utils {
extern runtime PromiseStatus(Context, Object): Smi; extern runtime PromiseStatus(Context, Object): Smi;
javascript builtin ExtrasUtilsCreatePrivateSymbol( javascript builtin ExtrasUtilsCreatePrivateSymbol(
context: Context, receiver: Object, ...arguments): HeapObject { js-implicit context: Context,
receiver: Object)(...arguments): HeapObject {
return CreatePrivateSymbol(context, arguments[0]); return CreatePrivateSymbol(context, arguments[0]);
} }
javascript builtin ExtrasUtilsMarkPromiseAsHandled( javascript builtin ExtrasUtilsMarkPromiseAsHandled(
context: Context, receiver: Object, ...arguments): Undefined { js-implicit context: Context, receiver: Object)(...arguments): Undefined {
return PromiseMarkAsHandled(context, arguments[0]); return PromiseMarkAsHandled(context, arguments[0]);
} }
javascript builtin ExtrasUtilsPromiseState( javascript builtin ExtrasUtilsPromiseState(
context: Context, receiver: Object, ...arguments): Smi { js-implicit context: Context, receiver: Object)(...arguments): Smi {
return PromiseStatus(context, arguments[0]); return PromiseStatus(context, arguments[0]);
} }
} }
...@@ -33,8 +33,8 @@ namespace object { ...@@ -33,8 +33,8 @@ namespace object {
} }
transitioning javascript builtin transitioning javascript builtin
ObjectFromEntries(implicit context: Context)(receiver: Object, ...arguments): ObjectFromEntries(js-implicit context: Context, receiver: Object)(
Object { ...arguments): Object {
const iterable: Object = arguments[0]; const iterable: Object = arguments[0];
try { try {
if (IsNullOrUndefined(iterable)) goto Throw; if (IsNullOrUndefined(iterable)) goto Throw;
......
...@@ -48,7 +48,7 @@ namespace object { ...@@ -48,7 +48,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(
implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: Object, object: Object): Object {
return object::ObjectIsExtensible(object); return object::ObjectIsExtensible(object);
} }
} // namespace object_isextensible } // namespace object_isextensible
...@@ -56,7 +56,7 @@ namespace object_isextensible { ...@@ -56,7 +56,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(
implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: Object, object: Object): Object {
return object::ObjectPreventExtensionsThrow(object); return object::ObjectPreventExtensionsThrow(object);
} }
} // namespace object_preventextensions } // namespace object_preventextensions
...@@ -6,17 +6,14 @@ ...@@ -6,17 +6,14 @@
namespace proxy { namespace proxy {
extern macro ProxiesCodeStubAssembler::GetProxyConstructorJSNewTarget():
Object;
// ES #sec-proxy-constructor // ES #sec-proxy-constructor
// https://tc39.github.io/ecma262/#sec-proxy-constructor // https://tc39.github.io/ecma262/#sec-proxy-constructor
transitioning javascript builtin transitioning javascript builtin
ProxyConstructor(implicit context: Context)( ProxyConstructor(
_receiver: Object, target: Object, handler: Object): JSProxy { js-implicit context: Context, receiver: Object,
newTarget: Object)(target: Object, handler: Object): JSProxy {
try { try {
// 1. If NewTarget is undefined, throw a TypeError exception. // 1. If NewTarget is undefined, throw a TypeError exception.
const newTarget: Object = GetProxyConstructorJSNewTarget();
if (newTarget == Undefined) { if (newTarget == Undefined) {
ThrowTypeError(kConstructorNotFunction, 'Proxy'); ThrowTypeError(kConstructorNotFunction, 'Proxy');
} }
......
...@@ -9,7 +9,7 @@ namespace proxy { ...@@ -9,7 +9,7 @@ namespace proxy {
// Proxy Revocation Functions // Proxy Revocation Functions
// https://tc39.github.io/ecma262/#sec-proxy-revocation-functions // https://tc39.github.io/ecma262/#sec-proxy-revocation-functions
transitioning javascript builtin transitioning javascript builtin
ProxyRevoke(implicit context: Context)(): Undefined { ProxyRevoke(js-implicit context: Context)(): Undefined {
// 1. Let p be F.[[RevocableProxy]]. // 1. Let p be F.[[RevocableProxy]].
const proxyObject: Object = context[PROXY_SLOT]; const proxyObject: Object = context[PROXY_SLOT];
......
...@@ -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(
implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: Object, 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(
implicit context: Context)(_receiver: Object, object: Object): Object { js-implicit context: Context)(_receiver: Object, 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);
......
...@@ -208,7 +208,7 @@ namespace regexp_replace { ...@@ -208,7 +208,7 @@ namespace regexp_replace {
} }
transitioning javascript builtin RegExpPrototypeReplace( transitioning javascript builtin RegExpPrototypeReplace(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...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:
......
...@@ -28,7 +28,7 @@ namespace string { ...@@ -28,7 +28,7 @@ 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(
context: Context, receiver: Object, ...arguments): Boolean { js-implicit context: Context, receiver: Object)(...arguments): Boolean {
const searchString: Object = arguments[0]; const searchString: Object = arguments[0];
const endPosition: Object = arguments[1]; const endPosition: Object = arguments[1];
......
...@@ -22,22 +22,23 @@ namespace string_html { ...@@ -22,22 +22,23 @@ 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(
context: Context, receiver: Object, ...arguments): String { js-implicit context: Context, receiver: Object)(...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(context: Context, receiver: Object, ...arguments): String { StringPrototypeBig(js-implicit context: Context, receiver: Object)(
...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.big', 'big', kEmptyString, kEmptyString); receiver, 'String.prototype.big', 'big', kEmptyString, kEmptyString);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeBlink(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.blink', 'blink', kEmptyString, receiver, 'String.prototype.blink', 'blink', kEmptyString,
kEmptyString); kEmptyString);
...@@ -45,56 +46,56 @@ namespace string_html { ...@@ -45,56 +46,56 @@ 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(context: Context, receiver: Object, ...arguments): StringPrototypeBold(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.bold', 'b', kEmptyString, kEmptyString); receiver, 'String.prototype.bold', 'b', kEmptyString, kEmptyString);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeFontcolor(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.fontcolor', 'font', 'color', arguments[0]); receiver, 'String.prototype.fontcolor', 'font', 'color', arguments[0]);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeFontsize(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.fontsize', 'font', 'size', arguments[0]); receiver, 'String.prototype.fontsize', 'font', 'size', arguments[0]);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeFixed(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.fixed', 'tt', kEmptyString, kEmptyString); receiver, 'String.prototype.fixed', 'tt', kEmptyString, kEmptyString);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeItalics(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.italics', 'i', kEmptyString, kEmptyString); receiver, 'String.prototype.italics', 'i', kEmptyString, kEmptyString);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeLink(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.link', 'a', 'href', arguments[0]); receiver, 'String.prototype.link', 'a', 'href', arguments[0]);
} }
// 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(context: Context, receiver: Object, ...arguments): StringPrototypeSmall(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.small', 'small', kEmptyString, receiver, 'String.prototype.small', 'small', kEmptyString,
kEmptyString); kEmptyString);
...@@ -102,8 +103,8 @@ namespace string_html { ...@@ -102,8 +103,8 @@ 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(context: Context, receiver: Object, ...arguments): StringPrototypeStrike(js-implicit context: Context, receiver: Object)(
String { ...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.strike', 'strike', kEmptyString, receiver, 'String.prototype.strike', 'strike', kEmptyString,
kEmptyString); kEmptyString);
...@@ -111,14 +112,16 @@ namespace string_html { ...@@ -111,14 +112,16 @@ 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(context: Context, receiver: Object, ...arguments): String { StringPrototypeSub(js-implicit context: Context, receiver: Object)(
...arguments): String {
return CreateHTML( return CreateHTML(
receiver, 'String.prototype.sub', 'sub', kEmptyString, kEmptyString); receiver, 'String.prototype.sub', 'sub', kEmptyString, kEmptyString);
} }
// 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(context: Context, receiver: Object, ...arguments): String { StringPrototypeSup(js-implicit context: Context, receiver: Object)(
...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(
implicit context: Context)(receiver: Object): JSStringIterator { js-implicit context: Context)(receiver: Object): 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(
implicit context: Context)(receiver: Object): JSObject { js-implicit context: Context)(receiver: Object): 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(
context: Context, receiver: Object, count: Object): String { js-implicit context: Context, receiver: Object)(count: Object): 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(
implicit context: Context)(receiver: Object, ...arguments): String { js-implicit context: Context, receiver: Object)(...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');
......
...@@ -19,7 +19,7 @@ namespace string { ...@@ -19,7 +19,7 @@ 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(
context: Context, receiver: Object, ...arguments): Boolean { js-implicit context: Context, receiver: Object)(...arguments): Boolean {
const searchString: Object = arguments[0]; const searchString: Object = arguments[0];
const position: Object = arguments[1]; const position: Object = arguments[1];
......
...@@ -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(
implicit context: Context)(receiver: Object, ...arguments): String { js-implicit context: Context, receiver: Object)(...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,13 +7,15 @@ ...@@ -7,13 +7,15 @@
namespace string { namespace string {
// ES6 #sec-string.prototype.tostring // ES6 #sec-string.prototype.tostring
transitioning javascript builtin transitioning javascript builtin
StringPrototypeToString(implicit context: Context)(receiver: Object): Object { StringPrototypeToString(js-implicit context: Context)(receiver: 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(implicit context: Context)(receiver: Object): Object { StringPrototypeValueOf(js-implicit context: Context)(receiver: Object):
Object {
return ToThisValue(receiver, kString, 'String.prototype.valueOf'); return ToThisValue(receiver, kString, 'String.prototype.valueOf');
} }
...@@ -70,7 +72,8 @@ namespace string { ...@@ -70,7 +72,8 @@ namespace string {
// ES6 #sec-string.prototype.charat // ES6 #sec-string.prototype.charat
transitioning javascript builtin StringPrototypeCharAt( transitioning javascript builtin StringPrototypeCharAt(
implicit context: Context)(receiver: Object, position: Object): Object { js-implicit context: Context,
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;
...@@ -86,7 +89,8 @@ namespace string { ...@@ -86,7 +89,8 @@ namespace string {
// ES6 #sec-string.prototype.charcodeat // ES6 #sec-string.prototype.charcodeat
transitioning javascript builtin StringPrototypeCharCodeAt( transitioning javascript builtin StringPrototypeCharCodeAt(
implicit context: Context)(receiver: Object, position: Object): Object { js-implicit context: Context,
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;
...@@ -102,7 +106,8 @@ namespace string { ...@@ -102,7 +106,8 @@ namespace string {
// ES6 #sec-string.prototype.codepointat // ES6 #sec-string.prototype.codepointat
transitioning javascript builtin StringPrototypeCodePointAt( transitioning javascript builtin StringPrototypeCodePointAt(
implicit context: Context)(receiver: Object, position: Object): Object { js-implicit context: Context,
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;
...@@ -121,7 +126,7 @@ namespace string { ...@@ -121,7 +126,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(
implicit context: Context)(receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...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');
......
...@@ -29,8 +29,8 @@ namespace typed_array_every { ...@@ -29,8 +29,8 @@ 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(implicit context: Context)( TypedArrayPrototypeEvery(js-implicit context: Context, receiver: Object)(
receiver: Object, ...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg // arguments[1] = thisArg
try { try {
......
...@@ -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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg // arguments[1] = thisArg
try { try {
......
...@@ -29,8 +29,8 @@ namespace typed_array_find { ...@@ -29,8 +29,8 @@ 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(implicit context: TypedArrayPrototypeFind(js-implicit context: Context, receiver: Object)(
Context)(receiver: Object, ...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg // arguments[1] = thisArg
try { try {
......
...@@ -29,8 +29,8 @@ namespace typed_array_findindex { ...@@ -29,8 +29,8 @@ 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(implicit context: Context)( TypedArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)(
receiver: Object, ...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg. // arguments[1] = thisArg.
try { try {
......
...@@ -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(implicit context: Context)( TypedArrayPrototypeForEach(js-implicit context: Context, receiver: Object)(
receiver: Object, ...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = this_arg. // arguments[1] = this_arg.
......
...@@ -35,8 +35,8 @@ namespace typed_array_reduce { ...@@ -35,8 +35,8 @@ namespace typed_array_reduce {
// 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(implicit context: Context)( TypedArrayPrototypeReduce(js-implicit context: Context, receiver: Object)(
receiver: Object, ...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = initialValue. // arguments[1] = initialValue.
try { try {
......
...@@ -35,8 +35,8 @@ namespace typed_array_reduceright { ...@@ -35,8 +35,8 @@ namespace typed_array_reduceright {
// 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(implicit context: Context)( TypedArrayPrototypeReduceRight(
receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: 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(
context: Context, receiver: Object, ...arguments): Object { js-implicit context: Context, receiver: Object)(...arguments): Object {
// arguments[0] = start // arguments[0] = start
// arguments[1] = end // arguments[1] = end
......
...@@ -29,8 +29,8 @@ namespace typed_array_some { ...@@ -29,8 +29,8 @@ 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(implicit context: TypedArrayPrototypeSome(js-implicit context: Context, receiver: Object)(
Context)(receiver: Object, ...arguments): Object { ...arguments): Object {
// arguments[0] = callback // arguments[0] = callback
// arguments[1] = thisArg. // arguments[1] = thisArg.
try { try {
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
namespace typed_array_subarray { namespace typed_array_subarray {
// ES %TypedArray%.prototype.subarray // ES %TypedArray%.prototype.subarray
transitioning javascript builtin TypedArrayPrototypeSubArray( transitioning javascript builtin TypedArrayPrototypeSubArray(
context: Context, receiver: Object, ...arguments): JSTypedArray { js-implicit context: Context,
receiver: Object)(...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.
......
...@@ -278,7 +278,8 @@ namespace typed_array { ...@@ -278,7 +278,8 @@ 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(
context: Context, receiver: Object, ...arguments): JSTypedArray { js-implicit context: Context,
receiver: Object)(...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: Object =
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "src/base/optional.h" #include "src/base/optional.h"
#include "src/torque/constants.h" #include "src/torque/constants.h"
#include "src/torque/source-positions.h" #include "src/torque/source-positions.h"
#include "src/torque/utils.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -559,14 +560,18 @@ struct NewExpression : Expression { ...@@ -559,14 +560,18 @@ struct NewExpression : Expression {
std::vector<NameAndExpression> initializers; std::vector<NameAndExpression> initializers;
}; };
enum class ImplicitKind { kNoImplicit, kJSImplicit, kImplicit };
struct ParameterList { struct ParameterList {
std::vector<Identifier*> names; std::vector<Identifier*> names;
std::vector<TypeExpression*> types; std::vector<TypeExpression*> types;
size_t implicit_count; ImplicitKind implicit_kind = ImplicitKind::kNoImplicit;
bool has_varargs; SourcePosition implicit_kind_pos = SourcePosition::Invalid();
std::string arguments_variable; size_t implicit_count = 0;
bool has_varargs = false;
std::string arguments_variable = "";
static ParameterList Empty() { return ParameterList{{}, {}, 0, false, ""}; } static ParameterList Empty() { return {}; }
std::vector<TypeExpression*> GetImplicitTypes() { std::vector<TypeExpression*> GetImplicitTypes() {
return std::vector<TypeExpression*>(types.begin(), return std::vector<TypeExpression*>(types.begin(),
types.begin() + implicit_count); types.begin() + implicit_count);
...@@ -821,6 +826,11 @@ struct NameAndTypeExpression { ...@@ -821,6 +826,11 @@ struct NameAndTypeExpression {
TypeExpression* type; TypeExpression* type;
}; };
struct ImplicitParameters {
Identifier* kind;
std::vector<NameAndTypeExpression> parameters;
};
struct StructFieldExpression { struct StructFieldExpression {
NameAndTypeExpression name_and_type; NameAndTypeExpression name_and_type;
bool const_qualified; bool const_qualified;
...@@ -880,7 +890,12 @@ struct MacroDeclaration : CallableNode { ...@@ -880,7 +890,12 @@ struct MacroDeclaration : CallableNode {
const LabelAndTypesVector& labels) const LabelAndTypesVector& labels)
: CallableNode(kind, pos, transitioning, std::move(name), : CallableNode(kind, pos, transitioning, std::move(name),
std::move(parameters), return_type, labels), std::move(parameters), return_type, labels),
op(std::move(op)) {} op(std::move(op)) {
if (parameters.implicit_kind == ImplicitKind::kJSImplicit) {
Error("Cannot use \"js-implicit\" with macros, use \"implicit\" instead.")
.Position(parameters.implicit_kind_pos);
}
}
base::Optional<std::string> op; base::Optional<std::string> op;
}; };
...@@ -904,7 +919,11 @@ struct IntrinsicDeclaration : CallableNode { ...@@ -904,7 +919,11 @@ struct IntrinsicDeclaration : CallableNode {
IntrinsicDeclaration(SourcePosition pos, std::string name, IntrinsicDeclaration(SourcePosition pos, std::string name,
ParameterList parameters, TypeExpression* return_type) ParameterList parameters, TypeExpression* return_type)
: CallableNode(kKind, pos, false, std::move(name), std::move(parameters), : CallableNode(kKind, pos, false, std::move(name), std::move(parameters),
return_type, {}) {} return_type, {}) {
if (parameters.implicit_kind != ImplicitKind::kNoImplicit) {
Error("Intinsics cannot have implicit parameters.");
}
}
}; };
struct TorqueMacroDeclaration : MacroDeclaration { struct TorqueMacroDeclaration : MacroDeclaration {
...@@ -928,7 +947,21 @@ struct BuiltinDeclaration : CallableNode { ...@@ -928,7 +947,21 @@ struct BuiltinDeclaration : CallableNode {
TypeExpression* return_type) TypeExpression* return_type)
: CallableNode(kind, pos, transitioning, std::move(name), : CallableNode(kind, pos, transitioning, std::move(name),
std::move(parameters), return_type, {}), std::move(parameters), return_type, {}),
javascript_linkage(javascript_linkage) {} javascript_linkage(javascript_linkage) {
if (parameters.implicit_kind == ImplicitKind::kJSImplicit &&
!javascript_linkage) {
Error(
"\"js-implicit\" is for implicit parameters passed according to the "
"JavaScript calling convention. Use \"implicit\" instead.");
}
if (parameters.implicit_kind == ImplicitKind::kImplicit &&
javascript_linkage) {
Error(
"The JavaScript calling convention implicitly passes a fixed set of "
"values. Use \"js-implicit\" to refer to those.")
.Position(parameters.implicit_kind_pos);
}
}
bool javascript_linkage; bool javascript_linkage;
}; };
......
...@@ -22,6 +22,7 @@ static const char* const BOOL_TYPE_STRING = "bool"; ...@@ -22,6 +22,7 @@ static const char* const BOOL_TYPE_STRING = "bool";
static const char* const VOID_TYPE_STRING = "void"; static const char* const VOID_TYPE_STRING = "void";
static const char* const ARGUMENTS_TYPE_STRING = "Arguments"; static const char* const ARGUMENTS_TYPE_STRING = "Arguments";
static const char* const CONTEXT_TYPE_STRING = "Context"; static const char* const CONTEXT_TYPE_STRING = "Context";
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";
......
...@@ -76,28 +76,12 @@ Builtin* DeclarationVisitor::CreateBuiltin(BuiltinDeclaration* decl, ...@@ -76,28 +76,12 @@ Builtin* DeclarationVisitor::CreateBuiltin(BuiltinDeclaration* decl,
Builtin::Kind kind = !javascript ? Builtin::kStub Builtin::Kind kind = !javascript ? Builtin::kStub
: varargs ? Builtin::kVarArgsJavaScript : varargs ? Builtin::kVarArgsJavaScript
: Builtin::kFixedArgsJavaScript; : Builtin::kFixedArgsJavaScript;
const Type* context_type =
Declarations::LookupGlobalType(CONTEXT_TYPE_STRING);
if (signature.types().size() == 0 ||
!(signature.types()[0] == context_type)) {
Error("First parameter to builtin ", decl->name, " must be of type ",
*context_type);
}
if (varargs && !javascript) { if (varargs && !javascript) {
Error("Rest parameters require ", decl->name, Error("Rest parameters require ", decl->name,
" to be a JavaScript builtin"); " to be a JavaScript builtin");
} }
if (javascript) {
if (signature.types().size() >= 2 &&
!(signature.types()[1] ==
Declarations::LookupGlobalType(OBJECT_TYPE_STRING))) {
Error("Second parameter to javascript builtin ", decl->name, " is ",
*signature.types()[1], " but should be Object");
}
}
for (size_t i = 0; i < signature.types().size(); ++i) { for (size_t i = 0; i < signature.types().size(); ++i) {
if (const StructType* type = if (const StructType* type =
StructType::DynamicCast(signature.types()[i])) { StructType::DynamicCast(signature.types()[i])) {
...@@ -136,8 +120,7 @@ void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl, ...@@ -136,8 +120,7 @@ void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl,
const Signature& signature, const Signature& signature,
base::Optional<Statement*> body) { base::Optional<Statement*> body) {
if (signature.parameter_types.types.size() == 0 || if (signature.parameter_types.types.size() == 0 ||
!(signature.parameter_types.types[0] == !(signature.parameter_types.types[0] == TypeOracle::GetContextType())) {
Declarations::LookupGlobalType(CONTEXT_TYPE_STRING))) {
ReportError( ReportError(
"first parameter to runtime functions has to be the context and have " "first parameter to runtime functions has to be the context and have "
"type Context, but found type ", "type Context, but found type ",
......
...@@ -159,26 +159,21 @@ Symbol* Lexer::MatchToken(InputPosition* pos, InputPosition end) { ...@@ -159,26 +159,21 @@ Symbol* Lexer::MatchToken(InputPosition* pos, InputPosition end) {
symbol = &pair.second; symbol = &pair.second;
} }
} }
// Check if matched pattern coincides with a keyword. Prefer the keyword in size_t pattern_size = *pos - token_start;
// this case.
if (*pos != token_start) { // Now check for keywords. Prefer keywords over patterns unless the pattern is
auto found_keyword = keywords_.find(std::string(token_start, *pos)); // longer. Iterate from the end to ensure that if one keyword is a prefix of
if (found_keyword != keywords_.end()) { // another, we first try to match the longer one.
return &found_keyword->second;
}
return symbol;
}
// Now check for a keyword (that doesn't overlap with a pattern).
// Iterate from the end to ensure that if one keyword is a prefix of another,
// we first try to match the longer one.
for (auto it = keywords_.rbegin(); it != keywords_.rend(); ++it) { for (auto it = keywords_.rbegin(); it != keywords_.rend(); ++it) {
const std::string& keyword = it->first; const std::string& keyword = it->first;
if (static_cast<size_t>(end - *pos) < keyword.size()) continue; if (static_cast<size_t>(end - token_start) < keyword.size()) continue;
if (keyword == std::string(*pos, *pos + keyword.size())) { if (keyword.size() >= pattern_size &&
*pos += keyword.size(); keyword == std::string(token_start, token_start + keyword.size())) {
*pos = token_start + keyword.size();
return &it->second; return &it->second;
} }
} }
if (pattern_size > 0) return symbol;
return nullptr; return nullptr;
} }
......
...@@ -53,6 +53,8 @@ enum class ParseResultHolderBase::TypeId { ...@@ -53,6 +53,8 @@ enum class ParseResultHolderBase::TypeId {
kLabelBlockPtr, kLabelBlockPtr,
kOptionalLabelBlockPtr, kOptionalLabelBlockPtr,
kNameAndTypeExpression, kNameAndTypeExpression,
kImplicitParameters,
kOptionalImplicitParameters,
kNameAndExpression, kNameAndExpression,
kConditionalAnnotation, kConditionalAnnotation,
kOptionalConditionalAnnotation, kOptionalConditionalAnnotation,
......
...@@ -415,61 +415,128 @@ void ImplementationVisitor::Visit(Builtin* builtin) { ...@@ -415,61 +415,128 @@ void ImplementationVisitor::Visit(Builtin* builtin) {
BlockBindings<LocalValue> parameter_bindings(&ValueBindingsManager::Get()); BlockBindings<LocalValue> parameter_bindings(&ValueBindingsManager::Get());
// Context if (builtin->IsVarArgsJavaScript() || builtin->IsFixedArgsJavaScript()) {
const bool context_is_implicit = signature.implicit_count > 0; if (builtin->IsVarArgsJavaScript()) {
std::string parameter0 = DCHECK(signature.parameter_types.var_args);
AddParameter(0, builtin, &parameters, &parameter_types, if (signature.ExplicitCount() > 0) {
&parameter_bindings, context_is_implicit); Error("Cannot mix explicit parameters with varargs.")
source_out() << " TNode<Context> " << parameter0 .Position(signature.parameter_names[signature.implicit_count]->pos);
<< " = UncheckedCast<Context>(Parameter(" }
<< "Descriptor::kContext));\n";
source_out() << " USE(" << parameter0 << ");\n";
size_t first = 1;
if (builtin->IsVarArgsJavaScript()) {
DCHECK(signature.parameter_types.var_args);
source_out()
<< " Node* argc = Parameter(Descriptor::kJSActualArgumentsCount);\n";
std::string parameter1 = AddParameter(
1, builtin, &parameters, &parameter_types, &parameter_bindings, true);
source_out()
<< " TNode<IntPtrT> arguments_length(ChangeInt32ToIntPtr(argc));\n";
source_out() << " TNode<RawPtrT> arguments_frame = "
"UncheckedCast<RawPtrT>(LoadFramePointer());\n";
source_out() << " TorqueStructArguments "
"torque_arguments(GetFrameArguments(arguments_frame, "
"arguments_length));\n";
source_out() << " CodeStubArguments arguments(this, torque_arguments);\n";
source_out() << " TNode<Object> " << parameter1
<< " = arguments.GetReceiver();\n";
source_out() << "USE(" << parameter1 << ");\n";
parameters.Push("torque_arguments.frame");
parameters.Push("torque_arguments.base");
parameters.Push("torque_arguments.length");
const Type* arguments_type = TypeOracle::GetArgumentsType();
StackRange range = parameter_types.PushMany(LowerType(arguments_type));
parameter_bindings.Add(*signature.arguments_variable,
LocalValue{true, VisitResult(arguments_type, range)},
true);
first = 2;
}
for (size_t i = 0; i < signature.parameter_names.size(); ++i) {
if (i < first) continue;
const std::string& parameter_name = signature.parameter_names[i]->value;
const Type* type = signature.types()[i];
const bool mark_as_used = signature.implicit_count > i;
std::string var = AddParameter(i, builtin, &parameters, &parameter_types,
&parameter_bindings, mark_as_used);
source_out() << " " << type->GetGeneratedTypeName() << " " << var << " = "
<< "UncheckedCast<" << type->GetGeneratedTNodeTypeName()
<< ">(Parameter(Descriptor::k"
<< CamelifyString(parameter_name) << "));\n";
source_out() << " USE(" << var << ");\n";
}
source_out()
<< " Node* argc = Parameter(Descriptor::kJSActualArgumentsCount);\n";
source_out()
<< " TNode<IntPtrT> arguments_length(ChangeInt32ToIntPtr(argc));\n";
source_out() << " TNode<RawPtrT> arguments_frame = "
"UncheckedCast<RawPtrT>(LoadFramePointer());\n";
source_out() << " TorqueStructArguments "
"torque_arguments(GetFrameArguments(arguments_frame, "
"arguments_length));\n";
source_out()
<< " CodeStubArguments arguments(this, torque_arguments);\n";
parameters.Push("torque_arguments.frame");
parameters.Push("torque_arguments.base");
parameters.Push("torque_arguments.length");
const Type* arguments_type = TypeOracle::GetArgumentsType();
StackRange range = parameter_types.PushMany(LowerType(arguments_type));
parameter_bindings.Add(
*signature.arguments_variable,
LocalValue{true, VisitResult(arguments_type, range)}, true);
}
for (size_t i = 0; i < signature.implicit_count; ++i) {
const std::string& param_name = signature.parameter_names[i]->value;
SourcePosition param_pos = signature.parameter_names[i]->pos;
std::string generated_name = AddParameter(
i, builtin, &parameters, &parameter_types, &parameter_bindings, true);
const Type* actual_type = signature.parameter_types.types[i];
const Type* expected_type;
if (param_name == "context") {
source_out() << " TNode<Context> " << generated_name
<< " = UncheckedCast<Context>(Parameter("
<< "Descriptor::kContext));\n";
source_out() << " USE(" << generated_name << ");\n";
expected_type = TypeOracle::GetContextType();
} else if (param_name == "receiver") {
source_out()
<< " TNode<Object> " << generated_name << " = "
<< (builtin->IsVarArgsJavaScript()
? "arguments.GetReceiver()"
: "UncheckedCast<Object>(Parameter(Descriptor::kReceiver))")
<< ";\n";
source_out() << "USE(" << generated_name << ");\n";
expected_type = TypeOracle::GetObjectType();
} else if (param_name == "newTarget") {
source_out() << " TNode<Object> " << generated_name
<< " = UncheckedCast<Object>(Parameter("
<< "Descriptor::kJSNewTarget));\n";
source_out() << "USE(" << generated_name << ");\n";
expected_type = TypeOracle::GetObjectType();
} else if (param_name == "target") {
source_out() << " TNode<JSFunction> " << generated_name
<< " = UncheckedCast<JSFunction>(Parameter("
<< "Descriptor::kJSTarget));\n";
source_out() << "USE(" << generated_name << ");\n";
expected_type = TypeOracle::GetJSFunctionType();
} else {
Error(
"Unexpected implicit parameter \"", param_name,
"\" for JavaScript calling convention, "
"expected \"context\", \"receiver\", \"target\", or \"newTarget\"")
.Position(param_pos);
expected_type = actual_type;
}
if (actual_type != expected_type) {
Error("According to JavaScript calling convention, expected parameter ",
param_name, " to have type ", *expected_type, " but found type ",
*actual_type)
.Position(param_pos);
}
}
for (size_t i = signature.implicit_count;
i < signature.parameter_names.size(); ++i) {
const std::string& parameter_name = signature.parameter_names[i]->value;
const Type* type = signature.types()[i];
const bool mark_as_used = signature.implicit_count > i;
std::string var = AddParameter(i, builtin, &parameters, &parameter_types,
&parameter_bindings, mark_as_used);
source_out() << " " << type->GetGeneratedTypeName() << " " << var
<< " = "
<< "UncheckedCast<" << type->GetGeneratedTNodeTypeName()
<< ">(Parameter(Descriptor::k"
<< CamelifyString(parameter_name) << "));\n";
source_out() << " USE(" << var << ");\n";
}
} else {
DCHECK(builtin->IsStub());
// Context
const bool context_is_implicit = signature.implicit_count > 0;
std::string parameter0 =
AddParameter(0, builtin, &parameters, &parameter_types,
&parameter_bindings, context_is_implicit);
source_out() << " TNode<Context> " << parameter0
<< " = UncheckedCast<Context>(Parameter("
<< "Descriptor::kContext));\n";
source_out() << " USE(" << parameter0 << ");\n";
for (size_t i = 1; i < signature.parameter_names.size(); ++i) {
const std::string& parameter_name = signature.parameter_names[i]->value;
const Type* type = signature.types()[i];
const bool mark_as_used = signature.implicit_count > i;
std::string var = AddParameter(i, builtin, &parameters, &parameter_types,
&parameter_bindings, mark_as_used);
source_out() << " " << type->GetGeneratedTypeName() << " " << var
<< " = "
<< "UncheckedCast<" << type->GetGeneratedTNodeTypeName()
<< ">(Parameter(Descriptor::k"
<< CamelifyString(parameter_name) << "));\n";
source_out() << " USE(" << var << ");\n";
}
}
assembler_ = CfgAssembler(parameter_types); assembler_ = CfgAssembler(parameter_types);
const Type* body_result = Visit(*builtin->body()); const Type* body_result = Visit(*builtin->body());
if (body_result != TypeOracle::GetNeverType()) { if (body_result != TypeOracle::GetNeverType()) {
......
...@@ -128,6 +128,14 @@ V8_EXPORT_PRIVATE const ParseResultTypeId ...@@ -128,6 +128,14 @@ V8_EXPORT_PRIVATE const ParseResultTypeId
ParseResultHolder<std::vector<NameAndTypeExpression>>::id = ParseResultHolder<std::vector<NameAndTypeExpression>>::id =
ParseResultTypeId::kStdVectorOfNameAndTypeExpression; ParseResultTypeId::kStdVectorOfNameAndTypeExpression;
template <> template <>
V8_EXPORT_PRIVATE const ParseResultTypeId
ParseResultHolder<ImplicitParameters>::id =
ParseResultTypeId::kImplicitParameters;
template <>
V8_EXPORT_PRIVATE const ParseResultTypeId
ParseResultHolder<base::Optional<ImplicitParameters>>::id =
ParseResultTypeId::kOptionalImplicitParameters;
template <>
V8_EXPORT_PRIVATE const ParseResultTypeId V8_EXPORT_PRIVATE const ParseResultTypeId
ParseResultHolder<std::vector<NameAndExpression>>::id = ParseResultHolder<std::vector<NameAndExpression>>::id =
ParseResultTypeId::kStdVectorOfNameAndExpression; ParseResultTypeId::kStdVectorOfNameAndExpression;
...@@ -376,59 +384,60 @@ base::Optional<ParseResult> MakeSpreadExpression( ...@@ -376,59 +384,60 @@ base::Optional<ParseResult> MakeSpreadExpression(
return ParseResult{result}; return ParseResult{result};
} }
template <bool has_varargs> base::Optional<ParseResult> MakeImplicitParameterList(
base::Optional<ParseResult> MakeParameterListFromTypes(
ParseResultIterator* child_results) { ParseResultIterator* child_results) {
auto implicit_params = auto kind = child_results->NextAs<Identifier*>();
child_results->NextAs<std::vector<NameAndTypeExpression>>(); auto parameters = child_results->NextAs<std::vector<NameAndTypeExpression>>();
auto explicit_types = child_results->NextAs<TypeList>(); return ParseResult{ImplicitParameters{kind, parameters}};
ParameterList result; }
result.has_varargs = has_varargs;
result.implicit_count = implicit_params.size(); void AddParameter(ParameterList* parameter_list, NameAndTypeExpression& param) {
for (NameAndTypeExpression& implicit_param : implicit_params) { if (!IsLowerCamelCase(param.name->value)) {
if (!IsLowerCamelCase(implicit_param.name->value)) { NamingConventionError("Parameter", param.name, "lowerCamelCase");
NamingConventionError("Parameter", implicit_param.name, "lowerCamelCase");
}
result.names.push_back(implicit_param.name);
result.types.push_back(implicit_param.type);
}
for (auto* explicit_type : explicit_types) {
result.types.push_back(explicit_type);
} }
return ParseResult{std::move(result)}; parameter_list->names.push_back(param.name);
parameter_list->types.push_back(param.type);
} }
template <bool has_varargs> template <bool has_varargs, bool has_explicit_parameter_names>
base::Optional<ParseResult> MakeParameterListFromNameAndTypeList( base::Optional<ParseResult> MakeParameterList(
ParseResultIterator* child_results) { ParseResultIterator* child_results) {
auto implicit_params = auto implicit_params =
child_results->NextAs<std::vector<NameAndTypeExpression>>(); child_results->NextAs<base::Optional<ImplicitParameters>>();
auto explicit_params =
child_results->NextAs<std::vector<NameAndTypeExpression>>();
std::string arguments_variable = "";
if (child_results->HasNext()) {
arguments_variable = child_results->NextAs<std::string>();
}
ParameterList result; ParameterList result;
for (NameAndTypeExpression& pair : implicit_params) { result.has_varargs = has_varargs;
if (!IsLowerCamelCase(pair.name->value)) { result.implicit_count = 0;
NamingConventionError("Parameter", pair.name, "lowerCamelCase"); result.implicit_kind = ImplicitKind::kNoImplicit;
if (implicit_params) {
result.implicit_count = implicit_params->parameters.size();
if (implicit_params->kind->value == "implicit") {
result.implicit_kind = ImplicitKind::kImplicit;
} else {
DCHECK_EQ(implicit_params->kind->value, "js-implicit");
result.implicit_kind = ImplicitKind::kJSImplicit;
}
result.implicit_kind_pos = implicit_params->kind->pos;
for (NameAndTypeExpression& implicit_param : implicit_params->parameters) {
AddParameter(&result, implicit_param);
} }
result.names.push_back(std::move(pair.name));
result.types.push_back(pair.type);
} }
for (NameAndTypeExpression& pair : explicit_params) { if (has_explicit_parameter_names) {
if (!IsLowerCamelCase(pair.name->value)) { auto explicit_params =
NamingConventionError("Parameter", pair.name, "lowerCamelCase"); child_results->NextAs<std::vector<NameAndTypeExpression>>();
std::string arguments_variable = "";
if (has_varargs) {
arguments_variable = child_results->NextAs<std::string>();
}
for (NameAndTypeExpression& param : explicit_params) {
AddParameter(&result, param);
}
result.arguments_variable = arguments_variable;
} else {
auto explicit_types = child_results->NextAs<TypeList>();
for (auto* explicit_type : explicit_types) {
result.types.push_back(explicit_type);
} }
result.names.push_back(pair.name);
result.types.push_back(pair.type);
} }
result.implicit_count = implicit_params.size();
result.has_varargs = has_varargs;
result.arguments_variable = arguments_variable;
return ParseResult{std::move(result)}; return ParseResult{std::move(result)};
} }
...@@ -1506,20 +1515,22 @@ struct TorqueGrammar : Grammar { ...@@ -1506,20 +1515,22 @@ struct TorqueGrammar : Grammar {
// Result: base::Optional<TypeList> // Result: base::Optional<TypeList>
Symbol* optionalGenericParameters = Optional<TypeList>(&genericParameters); Symbol* optionalGenericParameters = Optional<TypeList>(&genericParameters);
Symbol implicitParameterList{
Rule({Token("("), OneOf({"implicit", "js-implicit"}),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeImplicitParameterList)};
Symbol* optionalImplicitParameterList{ Symbol* optionalImplicitParameterList{
TryOrDefault<std::vector<NameAndTypeExpression>>( Optional<ImplicitParameters>(&implicitParameterList)};
Sequence({Token("("), Token("implicit"),
List<NameAndTypeExpression>(&nameAndType, Token(",")),
Token(")")}))};
// Result: ParameterList // Result: ParameterList
Symbol typeListMaybeVarArgs = { Symbol typeListMaybeVarArgs = {
Rule({optionalImplicitParameterList, Token("("), Rule({optionalImplicitParameterList, Token("("),
List<TypeExpression*>(Sequence({&type, Token(",")})), Token("..."), List<TypeExpression*>(Sequence({&type, Token(",")})), Token("..."),
Token(")")}, Token(")")},
MakeParameterListFromTypes<true>), MakeParameterList<true, false>),
Rule({optionalImplicitParameterList, Token("("), typeList, Token(")")}, Rule({optionalImplicitParameterList, Token("("), typeList, Token(")")},
MakeParameterListFromTypes<false>)}; MakeParameterList<false, false>)};
// Result: LabelAndTypes // Result: LabelAndTypes
Symbol labelParameter = {Rule( Symbol labelParameter = {Rule(
...@@ -1566,15 +1577,15 @@ struct TorqueGrammar : Grammar { ...@@ -1566,15 +1577,15 @@ struct TorqueGrammar : Grammar {
Symbol parameterListNoVararg = { Symbol parameterListNoVararg = {
Rule({optionalImplicitParameterList, Token("("), Rule({optionalImplicitParameterList, Token("("),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")}, List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeParameterListFromNameAndTypeList<false>)}; MakeParameterList<false, true>)};
// Result: ParameterList // Result: ParameterList
Symbol parameterListAllowVararg = { Symbol parameterListAllowVararg = {
Rule({&parameterListNoVararg}), Rule({&parameterListNoVararg}),
Rule({optionalImplicitParameterList, Token("("), Rule({optionalImplicitParameterList, Token("("),
NonemptyList<NameAndTypeExpression>(&nameAndType, Token(",")), List<NameAndTypeExpression>(Sequence({&nameAndType, Token(",")})),
Token(","), Token("..."), &identifier, Token(")")}, Token("..."), &identifier, Token(")")},
MakeParameterListFromNameAndTypeList<true>)}; MakeParameterList<true, true>)};
// Result: Identifier* // Result: Identifier*
Symbol* OneOf(const std::vector<std::string>& alternatives) { Symbol* OneOf(const std::vector<std::string>& alternatives) {
......
...@@ -203,6 +203,14 @@ class TypeOracle : public ContextualClass<TypeOracle> { ...@@ -203,6 +203,14 @@ class TypeOracle : public ContextualClass<TypeOracle> {
return Get().GetBuiltinType(CONST_INT32_TYPE_STRING); return Get().GetBuiltinType(CONST_INT32_TYPE_STRING);
} }
static const Type* GetContextType() {
return Get().GetBuiltinType(CONTEXT_TYPE_STRING);
}
static const Type* GetJSFunctionType() {
return Get().GetBuiltinType(JS_FUNCTION_TYPE_STRING);
}
static bool IsImplicitlyConvertableFrom(const Type* to, const Type* from) { static bool IsImplicitlyConvertableFrom(const Type* to, const Type* from) {
for (Generic* from_constexpr : for (Generic* from_constexpr :
Declarations::LookupGeneric(kFromConstexprMacroName)) { Declarations::LookupGeneric(kFromConstexprMacroName)) {
......
...@@ -669,6 +669,7 @@ struct Signature { ...@@ -669,6 +669,7 @@ struct Signature {
base::Optional<std::string> arguments_variable; base::Optional<std::string> arguments_variable;
ParameterTypes parameter_types; ParameterTypes parameter_types;
size_t implicit_count; size_t implicit_count;
size_t ExplicitCount() const { return types().size() - implicit_count; }
const Type* return_type; const Type* return_type;
LabelDeclarationVector labels; LabelDeclarationVector labels;
bool HasSameTypesAs( bool HasSameTypesAs(
......
...@@ -1369,7 +1369,7 @@ namespace array { ...@@ -1369,7 +1369,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.sort // https://tc39.github.io/ecma262/#sec-array.prototype.sort
transitioning javascript builtin transitioning javascript builtin
ArrayPrototypeSort(context: Context, receiver: Object, ...arguments): Object { ArrayPrototypeSort(js-implicit context: Context, receiver: Object)( ...arguments): Object {
// 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 = arguments[0]; const comparefnObj: Object = arguments[0];
......
...@@ -51,6 +51,7 @@ def preprocess(input): ...@@ -51,6 +51,7 @@ def preprocess(input):
r'\1_OtheSaLi', input) r'\1_OtheSaLi', input)
input = re.sub(r'@if\(', r'@iF(', input) input = re.sub(r'@if\(', r'@iF(', input)
input = re.sub(r'@export', r'@eXpOrT', input) input = re.sub(r'@export', r'@eXpOrT', input)
input = re.sub(r'js-implicit[ \n]+', r'jS_iMpLiCiT_', input)
# Special handing of '%' for intrinsics, turn the percent # Special handing of '%' for intrinsics, turn the percent
# into a unicode character so that it gets treated as part of the # into a unicode character so that it gets treated as part of the
...@@ -88,6 +89,8 @@ def postprocess(output): ...@@ -88,6 +89,8 @@ def postprocess(output):
output = re.sub(r'@iF\(', r'@if(', output) output = re.sub(r'@iF\(', r'@if(', output)
output = re.sub(r'@eXpOrT', output = re.sub(r'@eXpOrT',
r"@export", output) r"@export", output)
output = re.sub(r'jS_iMpLiCiT_',
r"js-implicit ", output)
while True: while True:
old = output old = output
......
...@@ -27,7 +27,7 @@ syn keyword torqueConditional if else typeswitch otherwise ...@@ -27,7 +27,7 @@ syn keyword torqueConditional if else typeswitch otherwise
syn match torqueConstant /\v<[A-Z][A-Z0-9_]+>/ syn match torqueConstant /\v<[A-Z][A-Z0-9_]+>/
syn match torqueConstant /\v<k[A-Z][A-Za-z0-9]*>/ syn match torqueConstant /\v<k[A-Z][A-Za-z0-9]*>/
syn keyword torqueFunction macro builtin runtime intrinsic syn keyword torqueFunction macro builtin runtime intrinsic
syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast js-implicit implicit
syn keyword torqueLabel case syn keyword torqueLabel case
syn keyword torqueMatching try label catch syn keyword torqueMatching try label catch
syn keyword torqueModifier extern javascript constexpr transitioning transient weak export syn keyword torqueModifier extern javascript constexpr transitioning transient weak export
......
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