Commit 4fb05056 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Revert "[torque] introduce separate implicit parameters for JavaScript calling convention"

This reverts commit 6eff6cc9.

Reason for revert: Presubmit failure.

Original change's description:
> [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/+/1658159
> Reviewed-by: Tamer Tas <tmrts@chromium.org>
> Reviewed-by: Simon Zünd <szuend@chromium.org>
> Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62174}

TBR=sigurds@chromium.org,tebbi@chromium.org,tmrts@chromium.org,szuend@chromium.org

Change-Id: Ide206788745bd15677bd60fe32d2476321967069
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9120 v8:7793
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660482Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62175}
parent 6eff6cc9
......@@ -9,7 +9,7 @@ namespace array_copywithin {
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
transitioning javascript builtin ArrayPrototypeCopyWithin(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
......
......@@ -4,9 +4,8 @@
namespace array {
transitioning javascript builtin
ArrayEveryLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
ArrayEveryLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -26,10 +25,9 @@ namespace array {
}
transitioning javascript builtin
ArrayEveryLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object, length: Object,
result: Object): Object {
ArrayEveryLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, result: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -111,7 +109,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.every
transitioning javascript builtin
ArrayEvery(js-implicit context: Context, receiver: Object)(...arguments):
ArrayEvery(implicit context: Context)(receiver: Object, ...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
......
......@@ -4,10 +4,9 @@
namespace array_filter {
transitioning javascript builtin
ArrayFilterLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object, initialTo: Object): Object {
ArrayFilterLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object, initialTo: Object): Object {
// All continuation points in the optimized filter implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -28,10 +27,9 @@ namespace array_filter {
}
transitioning javascript builtin
ArrayFilterLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object, valueK: Object, initialTo: Object,
ArrayFilterLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object, valueK: Object, initialTo: Object,
result: Object): Object {
// All continuation points in the optimized filter implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -44,9 +42,9 @@ namespace array_filter {
const numberLength = Cast<Number>(length) otherwise unreachable;
// 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 the output array. After incrementing k and to, we can glide
// into the loop continuation builtin.
// to pick up at the next step, which is setting the callback result in
// the output array. After incrementing k and to, we can glide into the loop
// continuation builtin.
if (ToBoolean(result)) {
FastCreateDataProperty(outputArray, numberTo, valueK);
numberTo = numberTo + 1;
......@@ -147,7 +145,7 @@ namespace array_filter {
// https://tc39.github.io/ecma262/#sec-array.prototype.filter
transitioning javascript builtin
ArrayFilter(js-implicit context: Context, receiver: Object)(...arguments):
ArrayFilter(implicit context: Context)(receiver: Object, ...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
......
......@@ -4,9 +4,8 @@
namespace array_find {
transitioning javascript builtin
ArrayFindLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
ArrayFindLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object): Object {
// All continuation points in the optimized find implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -25,10 +24,9 @@ namespace array_find {
}
transitioning javascript builtin
ArrayFindLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
_callback: Object, _thisArg: Object, _initialK: Object, _length: Object,
_result: Object): Object {
ArrayFindLoopLazyDeoptContinuation(implicit context: Context)(
_receiver: Object, _callback: Object, _thisArg: Object, _initialK: Object,
_length: Object, _result: Object): Object {
// This deopt continuation point is never actually called, it just
// exists to make stack traces correct from a ThrowTypeError if the
// callback was found to be non-callable.
......@@ -39,10 +37,9 @@ namespace array_find {
// happens right after the callback and it's returned value must be handled
// before iteration continues.
transitioning javascript builtin
ArrayFindLoopAfterCallbackLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object, length: Object,
foundValue: Object, isFound: Object): Object {
ArrayFindLoopAfterCallbackLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, foundValue: Object, isFound: Object): Object {
// All continuation points in the optimized find implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -119,8 +116,8 @@ namespace array_find {
// https://tc39.github.io/ecma262/#sec-array.prototype.find
transitioning javascript builtin
ArrayPrototypeFind(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ArrayPrototypeFind(implicit context: Context)(receiver: Object, ...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -4,9 +4,8 @@
namespace array_findindex {
transitioning javascript builtin
ArrayFindIndexLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
ArrayFindIndexLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object): Object {
// All continuation points in the optimized findIndex implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -25,10 +24,9 @@ namespace array_findindex {
}
transitioning javascript builtin
ArrayFindIndexLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
_callback: Object, _thisArg: Object, _initialK: Object, _length: Object,
_result: Object): Object {
ArrayFindIndexLoopLazyDeoptContinuation(implicit context: Context)(
_receiver: Object, _callback: Object, _thisArg: Object, _initialK: Object,
_length: Object, _result: Object): Object {
// This deopt continuation point is never actually called, it just
// exists to make stack traces correct from a ThrowTypeError if the
// callback was found to be non-callable.
......@@ -39,10 +37,10 @@ namespace array_findindex {
// happens right after the callback and it's returned value must be handled
// before iteration continues.
transitioning javascript builtin
ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object, length: Object,
foundValue: Object, isFound: Object): Object {
ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(implicit context:
Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, foundValue: Object, isFound: Object): Object {
// All continuation points in the optimized findIndex implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -120,8 +118,8 @@ namespace array_findindex {
// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
transitioning javascript builtin
ArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ArrayPrototypeFindIndex(implicit context:
Context)(receiver: Object, ...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -4,9 +4,8 @@
namespace array_foreach {
transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
ArrayForEachLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object): Object {
// All continuation points in the optimized forEach implemntation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -22,10 +21,9 @@ namespace array_foreach {
}
transitioning javascript builtin
ArrayForEachLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object, length: Object,
_result: Object): Object {
ArrayForEachLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, _result: Object): Object {
// All continuation points in the optimized forEach implemntation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -92,8 +90,7 @@ namespace array_foreach {
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach
transitioning javascript builtin
ArrayForEach(js-implicit context: Context, receiver: Object)(...arguments):
Object {
ArrayForEach(context: Context, receiver: Object, ...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -557,8 +557,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.join
transitioning javascript builtin
ArrayPrototypeJoin(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ArrayPrototypeJoin(context: Context, receiver: Object, ...arguments): Object {
const separator: Object = arguments[0];
// 1. Let O be ? ToObject(this value).
......@@ -567,8 +566,8 @@ namespace array_join {
// 2. Let len be ? ToLength(? Get(O, "length")).
const len: Number = GetLengthProperty(o);
// Only handle valid array lengths. Although the spec allows larger
// values, this matches historical V8 behavior.
// Only handle valid array lengths. Although the spec allows larger values,
// this matches historical V8 behavior.
if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength);
return CycleProtectedArrayJoin<JSArray>(
......@@ -577,7 +576,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.tolocalestring
transitioning javascript builtin ArrayPrototypeToLocaleString(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const locales: Object = arguments[0];
const options: Object = arguments[1];
......@@ -587,8 +586,8 @@ namespace array_join {
// 2. Let len be ? ToLength(? Get(O, "length")).
const len: Number = GetLengthProperty(o);
// Only handle valid array lengths. Although the spec allows larger
// values, this matches historical V8 behavior.
// Only handle valid array lengths. Although the spec allows larger values,
// this matches historical V8 behavior.
if (len > kMaxArrayIndex + 1) ThrowTypeError(kInvalidArrayLength);
return CycleProtectedArrayJoin<JSArray>(
......@@ -597,7 +596,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.tostring
transitioning javascript builtin ArrayPrototypeToString(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
// 1. Let array be ? ToObject(this value).
const array: JSReceiver = ToObject_Inline(context, receiver);
......@@ -618,7 +617,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join
transitioning javascript builtin TypedArrayPrototypeJoin(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const separator: Object = arguments[0];
// Spec: ValidateTypedArray is applied to the this value prior to evaluating
......@@ -633,7 +632,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring
transitioning javascript builtin TypedArrayPrototypeToLocaleString(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const locales: Object = arguments[0];
const options: Object = arguments[1];
......
......@@ -131,7 +131,7 @@ namespace array_lastindexof {
// https://tc39.github.io/ecma262/#sec-array.prototype.lastIndexOf
transitioning javascript builtin ArrayPrototypeLastIndexOf(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
......
......@@ -4,10 +4,9 @@
namespace array_map {
transitioning javascript builtin
ArrayMapLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object): Object {
ArrayMapLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object): Object {
// All continuation points in the optimized filter implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -27,10 +26,9 @@ namespace array_map {
}
transitioning javascript builtin
ArrayMapLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, array: Object, initialK: Object,
length: Object, result: Object): Object {
ArrayMapLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object, result: Object): Object {
// All continuation points in the optimized filter implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -224,8 +222,7 @@ namespace array_map {
// https://tc39.github.io/ecma262/#sec-array.prototype.map
transitioning javascript builtin
ArrayMap(js-implicit context: Context, receiver: Object)(...arguments):
Object {
ArrayMap(implicit context: Context)(receiver: Object, ...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) goto NullOrUndefinedError;
......
......@@ -5,8 +5,7 @@
namespace array_of {
// https://tc39.github.io/ecma262/#sec-array.of
transitioning javascript builtin
ArrayOf(js-implicit context: Context, receiver: Object)(...arguments):
Object {
ArrayOf(implicit context: Context)(receiver: Object, ...arguments): Object {
// 1. Let len be the actual number of arguments passed to this function.
const len: Smi = Convert<Smi>(arguments.length);
......
......@@ -4,9 +4,8 @@
namespace array {
transitioning javascript builtin
ArrayReduceRightPreLoopEagerDeoptContinuation(
js-implicit context: Context,
receiver: Object)(callback: Object, length: Object): Object {
ArrayReduceRightPreLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, length: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -26,9 +25,8 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceRightLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
ArrayReduceRightLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
accumulator: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -47,9 +45,8 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceRightLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
ArrayReduceRightLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
result: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -142,8 +139,8 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.reduceRight
transitioning javascript builtin
ArrayReduceRight(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ArrayReduceRight(implicit context: Context)(receiver: Object, ...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -4,9 +4,8 @@
namespace array {
transitioning javascript builtin
ArrayReducePreLoopEagerDeoptContinuation(
js-implicit context: Context,
receiver: Object)(callback: Object, length: Object): Object {
ArrayReducePreLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, length: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -26,9 +25,8 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
ArrayReduceLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
accumulator: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -47,9 +45,8 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, initialK: Object, length: Object,
ArrayReduceLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
result: Object): Object {
// All continuation points in the optimized every implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -142,7 +139,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.reduce
transitioning javascript builtin
ArrayReduce(js-implicit context: Context, receiver: Object)(...arguments):
ArrayReduce(implicit context: Context)(receiver: Object, ...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
......
......@@ -165,7 +165,7 @@ namespace array_reverse {
// https://tc39.github.io/ecma262/#sec-array.prototype.reverse
transitioning javascript builtin ArrayPrototypeReverse(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
try {
TryFastPackedArrayReverse(receiver) otherwise Baseline;
return receiver;
......
......@@ -103,7 +103,7 @@ namespace array_shift {
// https://tc39.github.io/ecma262/#sec-array.prototype.shift
transitioning javascript builtin ArrayPrototypeShift(
js-implicit context: Context, receiver: Object)(...arguments): Object {
implicit context: Context)(receiver: Object, ...arguments): Object {
try {
return TryFastArrayShift(receiver, arguments) otherwise Slow;
}
......
......@@ -122,8 +122,8 @@ namespace array_slice {
// https://tc39.github.io/ecma262/#sec-array.prototype.slice
transitioning javascript builtin
ArrayPrototypeSlice(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ArrayPrototypeSlice(context: Context, receiver: Object, ...arguments):
Object {
// Handle array cloning case if the receiver is a fast array.
if (arguments.length == 0) {
typeswitch (receiver) {
......
......@@ -4,9 +4,8 @@
namespace array {
transitioning javascript builtin
ArraySomeLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object,
ArraySomeLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object): Object {
// All continuation points in the optimized some implementation are
// after the ToObject(O) call that ensures we are dealing with a
......@@ -26,10 +25,9 @@ namespace array {
}
transitioning javascript builtin
ArraySomeLoopLazyDeoptContinuation(
js-implicit context: Context, receiver: Object)(
callback: Object, thisArg: Object, initialK: Object, length: Object,
result: Object): Object {
ArraySomeLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, result: Object): Object {
// All continuation points in the optimized some implementation are
// after the ToObject(O) call that ensures we are dealing with a
// JSReceiver.
......@@ -111,8 +109,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.some
transitioning javascript builtin
ArraySome(js-implicit context: Context, receiver: Object)(...arguments):
Object {
ArraySome(implicit context: Context)(receiver: Object, ...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -350,8 +350,8 @@ namespace array_splice {
// https://tc39.github.io/ecma262/#sec-array.prototype.splice
transitioning javascript builtin
ArrayPrototypeSplice(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ArrayPrototypeSplice(context: Context, receiver: Object, ...arguments):
Object {
// 1. Let O be ? ToObject(this value).
const o: JSReceiver = ToObject(context, receiver);
......
......@@ -93,7 +93,7 @@ namespace array_unshift {
// https://tc39.github.io/ecma262/#sec-array.prototype.unshift
transitioning javascript builtin ArrayPrototypeUnshift(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
try {
TryFastArrayUnshift(context, receiver, arguments) otherwise Baseline;
}
......
......@@ -3,16 +3,24 @@
// found in the LICENSE file.
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
BooleanConstructor(
js-implicit context: Context, receiver: Object, newTarget: Object,
target: JSFunction)(...arguments): Object {
BooleanConstructor(context: Context, receiver: Object, ...arguments): Object {
const value = SelectBooleanConstant(ToBoolean(arguments[0]));
const newTarget = Parameter(NEW_TARGET_INDEX);
if (newTarget == Undefined) {
return value;
}
const target = UnsafeCast<JSFunction>(Parameter(TARGET_INDEX));
const map = GetDerivedMap(target, UnsafeCast<JSReceiver>(newTarget));
const obj = UnsafeCast<JSValue>(AllocateFastOrSlowJSObjectFromMap(map));
......
......@@ -136,6 +136,11 @@ Node* ProxiesCodeStubAssembler::AllocateProxyRevokeFunction(Node* proxy,
proxy_context);
}
Node* ProxiesCodeStubAssembler::GetProxyConstructorJSNewTarget() {
return CodeAssembler::Parameter(static_cast<int>(
Builtin_ProxyConstructor_InterfaceDescriptor::kJSNewTarget));
}
TF_BUILTIN(CallProxy, ProxiesCodeStubAssembler) {
Node* argc = Parameter(Descriptor::kActualArgumentsCount);
Node* argc_ptr = ChangeInt32ToIntPtr(argc);
......
......@@ -20,6 +20,10 @@ class ProxiesCodeStubAssembler : public CodeStubAssembler {
Node* AllocateProxy(Node* target, Node* handler, 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* name, Node* trap_result,
JSProxy::AccessKind access_kind);
......
......@@ -74,8 +74,7 @@ namespace data_view {
// ES6 section 24.2.4.1 get DataView.prototype.buffer
javascript builtin DataViewPrototypeGetBuffer(
js-implicit context: Context,
receiver: Object)(...arguments): JSArrayBuffer {
context: Context, receiver: Object, ...arguments): JSArrayBuffer {
const dataView: JSDataView =
ValidateDataView(context, receiver, 'get DataView.prototype.buffer');
return dataView.buffer;
......@@ -83,7 +82,7 @@ namespace data_view {
// ES6 section 24.2.4.2 get DataView.prototype.byteLength
javascript builtin DataViewPrototypeGetByteLength(
js-implicit context: Context, receiver: Object)(...arguments): Number {
context: Context, receiver: Object, ...arguments): Number {
const dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_length');
if (WasNeutered(dataView)) {
......@@ -96,7 +95,7 @@ namespace data_view {
// ES6 section 24.2.4.3 get DataView.prototype.byteOffset
javascript builtin DataViewPrototypeGetByteOffset(
js-implicit context: Context, receiver: Object)(...arguments): Number {
context: Context, receiver: Object, ...arguments): Number {
const dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_offset');
if (WasNeutered(dataView)) {
......@@ -416,19 +415,19 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetUint8(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
return DataViewGet(context, receiver, offset, Undefined, UINT8_ELEMENTS);
}
transitioning javascript builtin DataViewPrototypeGetInt8(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
return DataViewGet(context, receiver, offset, Undefined, INT8_ELEMENTS);
}
transitioning javascript builtin DataViewPrototypeGetUint16(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -437,7 +436,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetInt16(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -446,7 +445,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetUint32(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -455,7 +454,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetInt32(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -464,7 +463,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetFloat32(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -473,7 +472,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetFloat64(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -482,7 +481,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetBigUint64(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -491,7 +490,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeGetBigInt64(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -718,7 +717,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetUint8(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
return DataViewSet(
......@@ -726,7 +725,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetInt8(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
return DataViewSet(
......@@ -734,7 +733,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetUint16(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -744,7 +743,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetInt16(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -754,7 +753,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetUint32(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -764,7 +763,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetInt32(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -774,7 +773,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetFloat32(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -784,7 +783,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetFloat64(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -794,7 +793,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetBigUint64(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -804,7 +803,7 @@ namespace data_view {
}
transitioning javascript builtin DataViewPrototypeSetBigInt64(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const offset: Object = arguments.length > 0 ? arguments[0] : Undefined;
const value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......
......@@ -8,18 +8,17 @@ namespace extras_utils {
extern runtime PromiseStatus(Context, Object): Smi;
javascript builtin ExtrasUtilsCreatePrivateSymbol(
js-implicit context: Context,
receiver: Object)(...arguments): HeapObject {
context: Context, receiver: Object, ...arguments): HeapObject {
return CreatePrivateSymbol(context, arguments[0]);
}
javascript builtin ExtrasUtilsMarkPromiseAsHandled(
js-implicit context: Context, receiver: Object)(...arguments): Undefined {
context: Context, receiver: Object, ...arguments): Undefined {
return PromiseMarkAsHandled(context, arguments[0]);
}
javascript builtin ExtrasUtilsPromiseState(
js-implicit context: Context, receiver: Object)(...arguments): Smi {
context: Context, receiver: Object, ...arguments): Smi {
return PromiseStatus(context, arguments[0]);
}
}
......@@ -33,8 +33,8 @@ namespace object {
}
transitioning javascript builtin
ObjectFromEntries(js-implicit context: Context, receiver: Object)(
...arguments): Object {
ObjectFromEntries(implicit context: Context)(receiver: Object, ...arguments):
Object {
const iterable: Object = arguments[0];
try {
if (IsNullOrUndefined(iterable)) goto Throw;
......
......@@ -48,7 +48,7 @@ namespace object {
namespace object_isextensible {
// ES6 section 19.1.2.11 Object.isExtensible ( O )
transitioning javascript builtin ObjectIsExtensible(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
implicit context: Context)(_receiver: Object, object: Object): Object {
return object::ObjectIsExtensible(object);
}
} // namespace object_isextensible
......@@ -56,7 +56,7 @@ namespace object_isextensible {
namespace object_preventextensions {
// ES6 section 19.1.2.11 Object.isExtensible ( O )
transitioning javascript builtin ObjectPreventExtensions(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
implicit context: Context)(_receiver: Object, object: Object): Object {
return object::ObjectPreventExtensionsThrow(object);
}
} // namespace object_preventextensions
......@@ -6,14 +6,17 @@
namespace proxy {
extern macro ProxiesCodeStubAssembler::GetProxyConstructorJSNewTarget():
Object;
// ES #sec-proxy-constructor
// https://tc39.github.io/ecma262/#sec-proxy-constructor
transitioning javascript builtin
ProxyConstructor(
js-implicit context: Context, receiver: Object,
newTarget: Object)(target: Object, handler: Object): JSProxy {
ProxyConstructor(implicit context: Context)(
_receiver: Object, target: Object, handler: Object): JSProxy {
try {
// 1. If NewTarget is undefined, throw a TypeError exception.
const newTarget: Object = GetProxyConstructorJSNewTarget();
if (newTarget == Undefined) {
ThrowTypeError(kConstructorNotFunction, 'Proxy');
}
......
......@@ -9,7 +9,7 @@ namespace proxy {
// Proxy Revocation Functions
// https://tc39.github.io/ecma262/#sec-proxy-revocation-functions
transitioning javascript builtin
ProxyRevoke(js-implicit context: Context)(): Undefined {
ProxyRevoke(implicit context: Context)(): Undefined {
// 1. Let p be F.[[RevocableProxy]].
const proxyObject: Object = context[PROXY_SLOT];
......
......@@ -9,7 +9,7 @@ namespace reflect {
// ES6 section 26.1.10 Reflect.isExtensible
transitioning javascript builtin ReflectIsExtensible(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
implicit context: Context)(_receiver: Object, object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.isExtensible');
return object::ObjectIsExtensible(objectJSReceiver);
......@@ -17,7 +17,7 @@ namespace reflect {
// ES6 section 26.1.12 Reflect.preventExtensions
transitioning javascript builtin ReflectPreventExtensions(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
implicit context: Context)(_receiver: Object, object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.preventExtensions');
return object::ObjectPreventExtensionsDontThrow(objectJSReceiver);
......
......@@ -208,7 +208,7 @@ namespace regexp_replace {
}
transitioning javascript builtin RegExpPrototypeReplace(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
const methodName: constexpr string = 'RegExp.prototype.@@replace';
// RegExpPrototypeReplace is a bit of a beast - a summary of dispatch logic:
......
......@@ -28,7 +28,7 @@ namespace string {
// https://tc39.github.io/ecma262/#sec-string.prototype.endswith
transitioning javascript builtin StringPrototypeEndsWith(
js-implicit context: Context, receiver: Object)(...arguments): Boolean {
context: Context, receiver: Object, ...arguments): Boolean {
const searchString: Object = arguments[0];
const endPosition: Object = arguments[1];
......
......@@ -22,23 +22,22 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.anchor
transitioning javascript builtin StringPrototypeAnchor(
js-implicit context: Context, receiver: Object)(...arguments): String {
context: Context, receiver: Object, ...arguments): String {
return CreateHTML(
receiver, 'String.prototype.anchor', 'a', 'name', arguments[0]);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.big
transitioning javascript builtin
StringPrototypeBig(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeBig(context: Context, receiver: Object, ...arguments): String {
return CreateHTML(
receiver, 'String.prototype.big', 'big', kEmptyString, kEmptyString);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.blink
transitioning javascript builtin
StringPrototypeBlink(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeBlink(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.blink', 'blink', kEmptyString,
kEmptyString);
......@@ -46,56 +45,56 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.bold
transitioning javascript builtin
StringPrototypeBold(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeBold(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.bold', 'b', kEmptyString, kEmptyString);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.fontcolor
transitioning javascript builtin
StringPrototypeFontcolor(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeFontcolor(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.fontcolor', 'font', 'color', arguments[0]);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.fontsize
transitioning javascript builtin
StringPrototypeFontsize(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeFontsize(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.fontsize', 'font', 'size', arguments[0]);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.fixed
transitioning javascript builtin
StringPrototypeFixed(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeFixed(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.fixed', 'tt', kEmptyString, kEmptyString);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.italics
transitioning javascript builtin
StringPrototypeItalics(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeItalics(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.italics', 'i', kEmptyString, kEmptyString);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.link
transitioning javascript builtin
StringPrototypeLink(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeLink(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.link', 'a', 'href', arguments[0]);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.small
transitioning javascript builtin
StringPrototypeSmall(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeSmall(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.small', 'small', kEmptyString,
kEmptyString);
......@@ -103,8 +102,8 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.strike
transitioning javascript builtin
StringPrototypeStrike(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeStrike(context: Context, receiver: Object, ...arguments):
String {
return CreateHTML(
receiver, 'String.prototype.strike', 'strike', kEmptyString,
kEmptyString);
......@@ -112,16 +111,14 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.sub
transitioning javascript builtin
StringPrototypeSub(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeSub(context: Context, receiver: Object, ...arguments): String {
return CreateHTML(
receiver, 'String.prototype.sub', 'sub', kEmptyString, kEmptyString);
}
// https://tc39.github.io/ecma262/#sec-string.prototype.sup
transitioning javascript builtin
StringPrototypeSup(js-implicit context: Context, receiver: Object)(
...arguments): String {
StringPrototypeSup(context: Context, receiver: Object, ...arguments): String {
return CreateHTML(
receiver, 'String.prototype.sup', 'sup', kEmptyString, kEmptyString);
}
......
......@@ -17,7 +17,7 @@ namespace string_iterator {
// ES6 #sec-string.prototype-@@iterator
transitioning javascript builtin StringPrototypeIterator(
js-implicit context: Context)(receiver: Object): JSStringIterator {
implicit context: Context)(receiver: Object): JSStringIterator {
const name: String =
ToThisString(receiver, 'String.prototype[Symbol.iterator]');
const index: Smi = 0;
......@@ -26,7 +26,7 @@ namespace string_iterator {
// ES6 #sec-%stringiteratorprototype%.next
transitioning javascript builtin StringIteratorPrototypeNext(
js-implicit context: Context)(receiver: Object): JSObject {
implicit context: Context)(receiver: Object): JSObject {
const iterator = Cast<JSStringIterator>(receiver) otherwise ThrowTypeError(
kIncompatibleMethodReceiver, 'String Iterator.prototype.next',
receiver);
......
......@@ -28,7 +28,7 @@ namespace string_repeat {
// https://tc39.github.io/ecma262/#sec-string.prototype.repeat
transitioning javascript builtin StringPrototypeRepeat(
js-implicit context: Context, receiver: Object)(count: Object): String {
context: Context, receiver: Object, count: Object): String {
// 1. Let O be ? RequireObjectCoercible(this value).
// 2. Let S be ? ToString(O).
const s: String = ToThisString(receiver, kBuiltinName);
......
......@@ -9,7 +9,7 @@ namespace string_slice {
// ES6 #sec-string.prototype.slice ( start, end )
// https://tc39.github.io/ecma262/#sec-string.prototype.slice
transitioning javascript builtin StringPrototypeSlice(
js-implicit context: Context, receiver: Object)(...arguments): String {
implicit context: Context)(receiver: Object, ...arguments): String {
// 1. Let O be ? RequireObjectCoercible(this value).
// 2. Let S be ? ToString(O).
const string: String = ToThisString(receiver, 'String.prototype.slice');
......
......@@ -19,7 +19,7 @@ namespace string {
// https://tc39.github.io/ecma262/#sec-string.prototype.startswith
transitioning javascript builtin StringPrototypeStartsWith(
js-implicit context: Context, receiver: Object)(...arguments): Boolean {
context: Context, receiver: Object, ...arguments): Boolean {
const searchString: Object = arguments[0];
const position: Object = arguments[1];
......
......@@ -28,7 +28,7 @@ namespace string_substring {
// ES6 #sec-string.prototype.substring
transitioning javascript builtin StringPrototypeSubstring(
js-implicit context: Context, receiver: Object)(...arguments): String {
implicit context: Context)(receiver: Object, ...arguments): String {
// Check that {receiver} is coercible to Object and convert it to a String.
const string: String = ToThisString(receiver, 'String.prototype.substring');
const length = string.length_smi;
......
......@@ -7,15 +7,13 @@
namespace string {
// ES6 #sec-string.prototype.tostring
transitioning javascript builtin
StringPrototypeToString(js-implicit context: Context)(receiver: Object):
Object {
StringPrototypeToString(implicit context: Context)(receiver: Object): Object {
return ToThisValue(receiver, kString, 'String.prototype.toString');
}
// ES6 #sec-string.prototype.valueof
transitioning javascript builtin
StringPrototypeValueOf(js-implicit context: Context)(receiver: Object):
Object {
StringPrototypeValueOf(implicit context: Context)(receiver: Object): Object {
return ToThisValue(receiver, kString, 'String.prototype.valueOf');
}
......@@ -72,8 +70,7 @@ namespace string {
// ES6 #sec-string.prototype.charat
transitioning javascript builtin StringPrototypeCharAt(
js-implicit context: Context,
receiver: Object)(position: Object): Object {
implicit context: Context)(receiver: Object, position: Object): Object {
try {
GenerateStringAt(receiver, position, 'String.prototype.charAt')
otherwise IfInBounds, IfOutOfBounds;
......@@ -89,8 +86,7 @@ namespace string {
// ES6 #sec-string.prototype.charcodeat
transitioning javascript builtin StringPrototypeCharCodeAt(
js-implicit context: Context,
receiver: Object)(position: Object): Object {
implicit context: Context)(receiver: Object, position: Object): Object {
try {
GenerateStringAt(receiver, position, 'String.prototype.charCodeAt')
otherwise IfInBounds, IfOutOfBounds;
......@@ -106,8 +102,7 @@ namespace string {
// ES6 #sec-string.prototype.codepointat
transitioning javascript builtin StringPrototypeCodePointAt(
js-implicit context: Context,
receiver: Object)(position: Object): Object {
implicit context: Context)(receiver: Object, position: Object): Object {
try {
GenerateStringAt(receiver, position, 'String.prototype.codePointAt')
otherwise IfInBounds, IfOutOfBounds;
......@@ -126,7 +121,7 @@ namespace string {
// ES6 String.prototype.concat(...args)
// ES6 #sec-string.prototype.concat
transitioning javascript builtin StringPrototypeConcat(
js-implicit context: Context, receiver: Object)(...arguments): Object {
implicit context: Context)(receiver: Object, ...arguments): Object {
// Check that {receiver} is coercible to Object and convert it to a String.
let string: String = ToThisString(receiver, 'String.prototype.concat');
......
......@@ -29,8 +29,8 @@ namespace typed_array_every {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
transitioning javascript builtin
TypedArrayPrototypeEvery(js-implicit context: Context, receiver: Object)(
...arguments): Object {
TypedArrayPrototypeEvery(implicit context: Context)(
receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = thisArg
try {
......
......@@ -10,7 +10,7 @@ namespace typed_array_filter {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter
transitioning javascript builtin TypedArrayPrototypeFilter(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = thisArg
try {
......
......@@ -29,8 +29,8 @@ namespace typed_array_find {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.find
transitioning javascript builtin
TypedArrayPrototypeFind(js-implicit context: Context, receiver: Object)(
...arguments): Object {
TypedArrayPrototypeFind(implicit context:
Context)(receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = thisArg
try {
......
......@@ -29,8 +29,8 @@ namespace typed_array_findindex {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findIndex
transitioning javascript builtin
TypedArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)(
...arguments): Object {
TypedArrayPrototypeFindIndex(implicit context: Context)(
receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = thisArg.
try {
......
......@@ -25,8 +25,8 @@ namespace typed_array_foreach {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.every
transitioning javascript builtin
TypedArrayPrototypeForEach(js-implicit context: Context, receiver: Object)(
...arguments): Object {
TypedArrayPrototypeForEach(implicit context: Context)(
receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = this_arg.
......
......@@ -35,8 +35,8 @@ namespace typed_array_reduce {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduce
transitioning javascript builtin
TypedArrayPrototypeReduce(js-implicit context: Context, receiver: Object)(
...arguments): Object {
TypedArrayPrototypeReduce(implicit context: Context)(
receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = initialValue.
try {
......
......@@ -35,8 +35,8 @@ namespace typed_array_reduceright {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.reduceright
transitioning javascript builtin
TypedArrayPrototypeReduceRight(
js-implicit context: Context, receiver: Object)(...arguments): Object {
TypedArrayPrototypeReduceRight(implicit context: Context)(
receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = initialValue.
try {
......
......@@ -53,7 +53,7 @@ namespace typed_array_slice {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.slice
transitioning javascript builtin TypedArrayPrototypeSlice(
js-implicit context: Context, receiver: Object)(...arguments): Object {
context: Context, receiver: Object, ...arguments): Object {
// arguments[0] = start
// arguments[1] = end
......
......@@ -29,8 +29,8 @@ namespace typed_array_some {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.some
transitioning javascript builtin
TypedArrayPrototypeSome(js-implicit context: Context, receiver: Object)(
...arguments): Object {
TypedArrayPrototypeSome(implicit context:
Context)(receiver: Object, ...arguments): Object {
// arguments[0] = callback
// arguments[1] = thisArg.
try {
......
......@@ -5,8 +5,7 @@
namespace typed_array_subarray {
// ES %TypedArray%.prototype.subarray
transitioning javascript builtin TypedArrayPrototypeSubArray(
js-implicit context: Context,
receiver: Object)(...arguments): JSTypedArray {
context: Context, receiver: Object, ...arguments): JSTypedArray {
const methodName: constexpr string = '%TypedArray%.prototype.subarray';
// 1. Let O be the this value.
......
......@@ -278,8 +278,7 @@ namespace typed_array {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort
transitioning javascript builtin TypedArrayPrototypeSort(
js-implicit context: Context,
receiver: Object)(...arguments): JSTypedArray {
context: Context, receiver: Object, ...arguments): JSTypedArray {
// 1. If comparefn is not undefined and IsCallable(comparefn) is false,
// throw a TypeError exception.
const comparefnObj: Object =
......
......@@ -15,7 +15,6 @@
#include "src/base/optional.h"
#include "src/torque/constants.h"
#include "src/torque/source-positions.h"
#include "src/torque/utils.h"
namespace v8 {
namespace internal {
......@@ -560,18 +559,14 @@ struct NewExpression : Expression {
std::vector<NameAndExpression> initializers;
};
enum class ImplicitKind { kNoImplicit, kJSImplicit, kImplicit };
struct ParameterList {
std::vector<Identifier*> names;
std::vector<TypeExpression*> types;
ImplicitKind implicit_kind = ImplicitKind::kNoImplicit;
SourcePosition implicit_kind_pos = SourcePosition::Invalid();
size_t implicit_count = 0;
bool has_varargs = false;
std::string arguments_variable = "";
size_t implicit_count;
bool has_varargs;
std::string arguments_variable;
static ParameterList Empty() { return {}; }
static ParameterList Empty() { return ParameterList{{}, {}, 0, false, ""}; }
std::vector<TypeExpression*> GetImplicitTypes() {
return std::vector<TypeExpression*>(types.begin(),
types.begin() + implicit_count);
......@@ -826,11 +821,6 @@ struct NameAndTypeExpression {
TypeExpression* type;
};
struct ImplicitParameters {
Identifier* kind;
std::vector<NameAndTypeExpression> parameters;
};
struct StructFieldExpression {
NameAndTypeExpression name_and_type;
bool const_qualified;
......@@ -890,12 +880,7 @@ struct MacroDeclaration : CallableNode {
const LabelAndTypesVector& labels)
: CallableNode(kind, pos, transitioning, std::move(name),
std::move(parameters), return_type, labels),
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);
}
}
op(std::move(op)) {}
base::Optional<std::string> op;
};
......@@ -919,11 +904,7 @@ struct IntrinsicDeclaration : CallableNode {
IntrinsicDeclaration(SourcePosition pos, std::string name,
ParameterList parameters, TypeExpression* return_type)
: CallableNode(kKind, pos, false, std::move(name), std::move(parameters),
return_type, {}) {
if (parameters.implicit_kind != ImplicitKind::kNoImplicit) {
Error("Intinsics cannot have implicit parameters.");
}
}
return_type, {}) {}
};
struct TorqueMacroDeclaration : MacroDeclaration {
......@@ -947,21 +928,7 @@ struct BuiltinDeclaration : CallableNode {
TypeExpression* return_type)
: CallableNode(kind, pos, transitioning, std::move(name),
std::move(parameters), return_type, {}),
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);
}
}
javascript_linkage(javascript_linkage) {}
bool javascript_linkage;
};
......
......@@ -22,7 +22,6 @@ static const char* const BOOL_TYPE_STRING = "bool";
static const char* const VOID_TYPE_STRING = "void";
static const char* const ARGUMENTS_TYPE_STRING = "Arguments";
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 OBJECT_TYPE_STRING = "Object";
static const char* const HEAP_OBJECT_TYPE_STRING = "HeapObject";
......
......@@ -76,12 +76,28 @@ Builtin* DeclarationVisitor::CreateBuiltin(BuiltinDeclaration* decl,
Builtin::Kind kind = !javascript ? Builtin::kStub
: varargs ? Builtin::kVarArgsJavaScript
: 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) {
Error("Rest parameters require ", decl->name,
" 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) {
if (const StructType* type =
StructType::DynamicCast(signature.types()[i])) {
......@@ -120,7 +136,8 @@ void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl,
const Signature& signature,
base::Optional<Statement*> body) {
if (signature.parameter_types.types.size() == 0 ||
!(signature.parameter_types.types[0] == TypeOracle::GetContextType())) {
!(signature.parameter_types.types[0] ==
Declarations::LookupGlobalType(CONTEXT_TYPE_STRING))) {
ReportError(
"first parameter to runtime functions has to be the context and have "
"type Context, but found type ",
......
......@@ -159,21 +159,26 @@ Symbol* Lexer::MatchToken(InputPosition* pos, InputPosition end) {
symbol = &pair.second;
}
}
size_t pattern_size = *pos - token_start;
// Now check for keywords. Prefer keywords over patterns unless the pattern is
// longer. Iterate from the end to ensure that if one keyword is a prefix of
// another, we first try to match the longer one.
// Check if matched pattern coincides with a keyword. Prefer the keyword in
// this case.
if (*pos != token_start) {
auto found_keyword = keywords_.find(std::string(token_start, *pos));
if (found_keyword != keywords_.end()) {
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) {
const std::string& keyword = it->first;
if (static_cast<size_t>(end - token_start) < keyword.size()) continue;
if (keyword.size() >= pattern_size &&
keyword == std::string(token_start, token_start + keyword.size())) {
*pos = token_start + keyword.size();
if (static_cast<size_t>(end - *pos) < keyword.size()) continue;
if (keyword == std::string(*pos, *pos + keyword.size())) {
*pos += keyword.size();
return &it->second;
}
}
if (pattern_size > 0) return symbol;
return nullptr;
}
......
......@@ -53,8 +53,6 @@ enum class ParseResultHolderBase::TypeId {
kLabelBlockPtr,
kOptionalLabelBlockPtr,
kNameAndTypeExpression,
kImplicitParameters,
kOptionalImplicitParameters,
kNameAndExpression,
kConditionalAnnotation,
kOptionalConditionalAnnotation,
......
......@@ -415,16 +415,23 @@ void ImplementationVisitor::Visit(Builtin* builtin) {
BlockBindings<LocalValue> parameter_bindings(&ValueBindingsManager::Get());
if (builtin->IsVarArgsJavaScript() || builtin->IsFixedArgsJavaScript()) {
// 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";
size_t first = 1;
if (builtin->IsVarArgsJavaScript()) {
DCHECK(signature.parameter_types.var_args);
if (signature.ExplicitCount() > 0) {
Error("Cannot mix explicit parameters with varargs.")
.Position(signature.parameter_names[signature.implicit_count]->pos);
}
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 = "
......@@ -432,111 +439,37 @@ void ImplementationVisitor::Visit(Builtin* builtin) {
source_out() << " TorqueStructArguments "
"torque_arguments(GetFrameArguments(arguments_frame, "
"arguments_length));\n";
source_out()
<< " CodeStubArguments arguments(this, torque_arguments);\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);
}
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);
}
}
parameter_bindings.Add(*signature.arguments_variable,
LocalValue{true, VisitResult(arguments_type, range)},
true);
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";
first = 2;
}
} 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) {
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
<< " = "
source_out() << " " << type->GetGeneratedTypeName() << " " << var << " = "
<< "UncheckedCast<" << type->GetGeneratedTNodeTypeName()
<< ">(Parameter(Descriptor::k"
<< CamelifyString(parameter_name) << "));\n";
source_out() << " USE(" << var << ");\n";
}
}
assembler_ = CfgAssembler(parameter_types);
const Type* body_result = Visit(*builtin->body());
if (body_result != TypeOracle::GetNeverType()) {
......
......@@ -128,14 +128,6 @@ V8_EXPORT_PRIVATE const ParseResultTypeId
ParseResultHolder<std::vector<NameAndTypeExpression>>::id =
ParseResultTypeId::kStdVectorOfNameAndTypeExpression;
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
ParseResultHolder<std::vector<NameAndExpression>>::id =
ParseResultTypeId::kStdVectorOfNameAndExpression;
......@@ -384,60 +376,59 @@ base::Optional<ParseResult> MakeSpreadExpression(
return ParseResult{result};
}
base::Optional<ParseResult> MakeImplicitParameterList(
ParseResultIterator* child_results) {
auto kind = child_results->NextAs<Identifier*>();
auto parameters = child_results->NextAs<std::vector<NameAndTypeExpression>>();
return ParseResult{ImplicitParameters{kind, parameters}};
}
void AddParameter(ParameterList* parameter_list, NameAndTypeExpression& param) {
if (!IsLowerCamelCase(param.name->value)) {
NamingConventionError("Parameter", param.name, "lowerCamelCase");
}
parameter_list->names.push_back(param.name);
parameter_list->types.push_back(param.type);
}
template <bool has_varargs, bool has_explicit_parameter_names>
base::Optional<ParseResult> MakeParameterList(
template <bool has_varargs>
base::Optional<ParseResult> MakeParameterListFromTypes(
ParseResultIterator* child_results) {
auto implicit_params =
child_results->NextAs<base::Optional<ImplicitParameters>>();
child_results->NextAs<std::vector<NameAndTypeExpression>>();
auto explicit_types = child_results->NextAs<TypeList>();
ParameterList result;
result.has_varargs = has_varargs;
result.implicit_count = 0;
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_count = implicit_params.size();
for (NameAndTypeExpression& implicit_param : implicit_params) {
if (!IsLowerCamelCase(implicit_param.name->value)) {
NamingConventionError("Parameter", implicit_param.name, "lowerCamelCase");
}
result.implicit_kind_pos = implicit_params->kind->pos;
for (NameAndTypeExpression& implicit_param : implicit_params->parameters) {
AddParameter(&result, implicit_param);
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);
}
if (has_explicit_parameter_names) {
return ParseResult{std::move(result)};
}
template <bool has_varargs>
base::Optional<ParseResult> MakeParameterListFromNameAndTypeList(
ParseResultIterator* child_results) {
auto implicit_params =
child_results->NextAs<std::vector<NameAndTypeExpression>>();
auto explicit_params =
child_results->NextAs<std::vector<NameAndTypeExpression>>();
std::string arguments_variable = "";
if (has_varargs) {
if (child_results->HasNext()) {
arguments_variable = child_results->NextAs<std::string>();
}
for (NameAndTypeExpression& param : explicit_params) {
AddParameter(&result, param);
ParameterList result;
for (NameAndTypeExpression& pair : implicit_params) {
if (!IsLowerCamelCase(pair.name->value)) {
NamingConventionError("Parameter", pair.name, "lowerCamelCase");
}
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(std::move(pair.name));
result.types.push_back(pair.type);
}
for (NameAndTypeExpression& pair : explicit_params) {
if (!IsLowerCamelCase(pair.name->value)) {
NamingConventionError("Parameter", pair.name, "lowerCamelCase");
}
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)};
}
......@@ -1515,22 +1506,20 @@ struct TorqueGrammar : Grammar {
// Result: base::Optional<TypeList>
Symbol* optionalGenericParameters = Optional<TypeList>(&genericParameters);
Symbol implicitParameterList{
Rule({Token("("), OneOf({"implicit", "js-implicit"}),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeImplicitParameterList)};
Symbol* optionalImplicitParameterList{
Optional<ImplicitParameters>(&implicitParameterList)};
TryOrDefault<std::vector<NameAndTypeExpression>>(
Sequence({Token("("), Token("implicit"),
List<NameAndTypeExpression>(&nameAndType, Token(",")),
Token(")")}))};
// Result: ParameterList
Symbol typeListMaybeVarArgs = {
Rule({optionalImplicitParameterList, Token("("),
List<TypeExpression*>(Sequence({&type, Token(",")})), Token("..."),
Token(")")},
MakeParameterList<true, false>),
MakeParameterListFromTypes<true>),
Rule({optionalImplicitParameterList, Token("("), typeList, Token(")")},
MakeParameterList<false, false>)};
MakeParameterListFromTypes<false>)};
// Result: LabelAndTypes
Symbol labelParameter = {Rule(
......@@ -1577,15 +1566,15 @@ struct TorqueGrammar : Grammar {
Symbol parameterListNoVararg = {
Rule({optionalImplicitParameterList, Token("("),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeParameterList<false, true>)};
MakeParameterListFromNameAndTypeList<false>)};
// Result: ParameterList
Symbol parameterListAllowVararg = {
Rule({&parameterListNoVararg}),
Rule({optionalImplicitParameterList, Token("("),
List<NameAndTypeExpression>(Sequence({&nameAndType, Token(",")})),
Token("..."), &identifier, Token(")")},
MakeParameterList<true, true>)};
NonemptyList<NameAndTypeExpression>(&nameAndType, Token(",")),
Token(","), Token("..."), &identifier, Token(")")},
MakeParameterListFromNameAndTypeList<true>)};
// Result: Identifier*
Symbol* OneOf(const std::vector<std::string>& alternatives) {
......
......@@ -203,14 +203,6 @@ class TypeOracle : public ContextualClass<TypeOracle> {
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) {
for (Generic* from_constexpr :
Declarations::LookupGeneric(kFromConstexprMacroName)) {
......
......@@ -669,7 +669,6 @@ struct Signature {
base::Optional<std::string> arguments_variable;
ParameterTypes parameter_types;
size_t implicit_count;
size_t ExplicitCount() const { return types().size() - implicit_count; }
const Type* return_type;
LabelDeclarationVector labels;
bool HasSameTypesAs(
......
......@@ -1369,7 +1369,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.sort
transitioning javascript builtin
ArrayPrototypeSort(js-implicit context: Context, receiver: Object)( ...arguments): Object {
ArrayPrototypeSort(context: Context, receiver: Object, ...arguments): Object {
// 1. If comparefn is not undefined and IsCallable(comparefn) is false,
// throw a TypeError exception.
const comparefnObj: Object = arguments[0];
......
......@@ -51,7 +51,6 @@ def preprocess(input):
r'\1_OtheSaLi', input)
input = re.sub(r'@if\(', r'@iF(', 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
# into a unicode character so that it gets treated as part of the
......@@ -89,8 +88,6 @@ def postprocess(output):
output = re.sub(r'@iF\(', r'@if(', output)
output = re.sub(r'@eXpOrT',
r"@export", output)
output = re.sub(r'jS_iMpLiCiT_',
r"js-implicit ", output)
while True:
old = output
......
......@@ -27,7 +27,7 @@ syn keyword torqueConditional if else typeswitch otherwise
syn match torqueConstant /\v<[A-Z][A-Z0-9_]+>/
syn match torqueConstant /\v<k[A-Z][A-Za-z0-9]*>/
syn keyword torqueFunction macro builtin runtime intrinsic
syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast js-implicit implicit
syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast
syn keyword torqueLabel case
syn keyword torqueMatching try label catch
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