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 {
// https://tc39.github.io/ecma262/#sec-array.prototype.copyWithin
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).
const object: JSReceiver = ToObject_Inline(context, receiver);
......
......@@ -4,8 +4,9 @@
namespace array {
transitioning javascript builtin
ArrayEveryLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
ArrayEveryLoopEagerDeoptContinuation(
js-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
......@@ -25,9 +26,10 @@ namespace array {
}
transitioning javascript builtin
ArrayEveryLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, result: Object): Object {
ArrayEveryLoopLazyDeoptContinuation(
js-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.
......@@ -109,7 +111,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.every
transitioning javascript builtin
ArrayEvery(implicit context: Context)(receiver: Object, ...arguments):
ArrayEvery(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
......
......@@ -4,9 +4,10 @@
namespace array_filter {
transitioning javascript builtin
ArrayFilterLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object, initialTo: Object): Object {
ArrayFilterLoopEagerDeoptContinuation(
js-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.
......@@ -27,9 +28,10 @@ namespace array_filter {
}
transitioning javascript builtin
ArrayFilterLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object, valueK: Object, initialTo: Object,
ArrayFilterLoopLazyDeoptContinuation(
js-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
......@@ -42,9 +44,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;
......@@ -145,7 +147,7 @@ namespace array_filter {
// https://tc39.github.io/ecma262/#sec-array.prototype.filter
transitioning javascript builtin
ArrayFilter(implicit context: Context)(receiver: Object, ...arguments):
ArrayFilter(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
......
......@@ -4,8 +4,9 @@
namespace array_find {
transitioning javascript builtin
ArrayFindLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
ArrayFindLoopEagerDeoptContinuation(
js-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
......@@ -24,9 +25,10 @@ namespace array_find {
}
transitioning javascript builtin
ArrayFindLoopLazyDeoptContinuation(implicit context: Context)(
_receiver: Object, _callback: Object, _thisArg: Object, _initialK: Object,
_length: Object, _result: Object): Object {
ArrayFindLoopLazyDeoptContinuation(
js-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.
......@@ -37,9 +39,10 @@ namespace array_find {
// happens right after the callback and it's returned value must be handled
// before iteration continues.
transitioning javascript builtin
ArrayFindLoopAfterCallbackLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, foundValue: Object, isFound: Object): Object {
ArrayFindLoopAfterCallbackLazyDeoptContinuation(
js-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.
......@@ -116,8 +119,8 @@ namespace array_find {
// https://tc39.github.io/ecma262/#sec-array.prototype.find
transitioning javascript builtin
ArrayPrototypeFind(implicit context: Context)(receiver: Object, ...arguments):
Object {
ArrayPrototypeFind(js-implicit context: Context, receiver: Object)(
...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -4,8 +4,9 @@
namespace array_findindex {
transitioning javascript builtin
ArrayFindIndexLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
ArrayFindIndexLoopEagerDeoptContinuation(
js-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
......@@ -24,9 +25,10 @@ namespace array_findindex {
}
transitioning javascript builtin
ArrayFindIndexLoopLazyDeoptContinuation(implicit context: Context)(
_receiver: Object, _callback: Object, _thisArg: Object, _initialK: Object,
_length: Object, _result: Object): Object {
ArrayFindIndexLoopLazyDeoptContinuation(
js-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.
......@@ -37,10 +39,10 @@ namespace array_findindex {
// happens right after the callback and it's returned value must be handled
// before iteration continues.
transitioning javascript builtin
ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(implicit context:
Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, foundValue: Object, isFound: Object): Object {
ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation(
js-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.
......@@ -118,8 +120,8 @@ namespace array_findindex {
// https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
transitioning javascript builtin
ArrayPrototypeFindIndex(implicit context:
Context)(receiver: Object, ...arguments): Object {
ArrayPrototypeFindIndex(js-implicit context: Context, receiver: Object)(
...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -4,8 +4,9 @@
namespace array_foreach {
transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
ArrayForEachLoopEagerDeoptContinuation(
js-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
......@@ -21,9 +22,10 @@ namespace array_foreach {
}
transitioning javascript builtin
ArrayForEachLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, _result: Object): Object {
ArrayForEachLoopLazyDeoptContinuation(
js-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.
......@@ -90,7 +92,8 @@ namespace array_foreach {
// https://tc39.github.io/ecma262/#sec-array.prototype.foreach
transitioning javascript builtin
ArrayForEach(context: Context, receiver: Object, ...arguments): Object {
ArrayForEach(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -557,7 +557,8 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.join
transitioning javascript builtin
ArrayPrototypeJoin(context: Context, receiver: Object, ...arguments): Object {
ArrayPrototypeJoin(js-implicit context: Context, receiver: Object)(
...arguments): Object {
const separator: Object = arguments[0];
// 1. Let O be ? ToObject(this value).
......@@ -566,8 +567,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>(
......@@ -576,7 +577,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.tolocalestring
transitioning javascript builtin ArrayPrototypeToLocaleString(
context: Context, receiver: Object, ...arguments): Object {
js-implicit context: Context, receiver: Object)(...arguments): Object {
const locales: Object = arguments[0];
const options: Object = arguments[1];
......@@ -586,8 +587,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>(
......@@ -596,7 +597,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-array.prototype.tostring
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).
const array: JSReceiver = ToObject_Inline(context, receiver);
......@@ -617,7 +618,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.join
transitioning javascript builtin TypedArrayPrototypeJoin(
context: Context, receiver: Object, ...arguments): Object {
js-implicit context: Context, receiver: Object)(...arguments): Object {
const separator: Object = arguments[0];
// Spec: ValidateTypedArray is applied to the this value prior to evaluating
......@@ -632,7 +633,7 @@ namespace array_join {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring
transitioning javascript builtin TypedArrayPrototypeToLocaleString(
context: Context, receiver: Object, ...arguments): Object {
js-implicit 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(
context: Context, receiver: Object, ...arguments): Object {
js-implicit context: Context, receiver: Object)(...arguments): Object {
// 1. Let O be ? ToObject(this value).
const object: JSReceiver = ToObject_Inline(context, receiver);
......
......@@ -4,9 +4,10 @@
namespace array_map {
transitioning javascript builtin
ArrayMapLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object): Object {
ArrayMapLoopEagerDeoptContinuation(
js-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.
......@@ -26,9 +27,10 @@ namespace array_map {
}
transitioning javascript builtin
ArrayMapLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, array: Object,
initialK: Object, length: Object, result: Object): Object {
ArrayMapLoopLazyDeoptContinuation(
js-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.
......@@ -222,7 +224,8 @@ namespace array_map {
// https://tc39.github.io/ecma262/#sec-array.prototype.map
transitioning javascript builtin
ArrayMap(implicit context: Context)(receiver: Object, ...arguments): Object {
ArrayMap(js-implicit context: Context, receiver: Object)(...arguments):
Object {
try {
if (IsNullOrUndefined(receiver)) goto NullOrUndefinedError;
......
......@@ -5,7 +5,8 @@
namespace array_of {
// https://tc39.github.io/ecma262/#sec-array.of
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.
const len: Smi = Convert<Smi>(arguments.length);
......
......@@ -4,8 +4,9 @@
namespace array {
transitioning javascript builtin
ArrayReduceRightPreLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, length: Object): Object {
ArrayReduceRightPreLoopEagerDeoptContinuation(
js-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.
......@@ -25,8 +26,9 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceRightLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
ArrayReduceRightLoopEagerDeoptContinuation(
js-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
......@@ -45,8 +47,9 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceRightLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
ArrayReduceRightLoopLazyDeoptContinuation(
js-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
......@@ -139,8 +142,8 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.reduceRight
transitioning javascript builtin
ArrayReduceRight(implicit context: Context)(receiver: Object, ...arguments):
Object {
ArrayReduceRight(js-implicit context: Context, receiver: Object)(
...arguments): Object {
try {
if (IsNullOrUndefined(receiver)) {
goto NullOrUndefinedError;
......
......@@ -4,8 +4,9 @@
namespace array {
transitioning javascript builtin
ArrayReducePreLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, length: Object): Object {
ArrayReducePreLoopEagerDeoptContinuation(
js-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.
......@@ -25,8 +26,9 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
ArrayReduceLoopEagerDeoptContinuation(
js-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
......@@ -45,8 +47,9 @@ namespace array {
}
transitioning javascript builtin
ArrayReduceLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, initialK: Object, length: Object,
ArrayReduceLoopLazyDeoptContinuation(
js-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
......@@ -139,7 +142,7 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.reduce
transitioning javascript builtin
ArrayReduce(implicit context: Context)(receiver: Object, ...arguments):
ArrayReduce(js-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(
context: Context, receiver: Object, ...arguments): Object {
js-implicit 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(
implicit context: Context)(receiver: Object, ...arguments): Object {
js-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(context: Context, receiver: Object, ...arguments):
Object {
ArrayPrototypeSlice(js-implicit context: Context, receiver: Object)(
...arguments): Object {
// Handle array cloning case if the receiver is a fast array.
if (arguments.length == 0) {
typeswitch (receiver) {
......
......@@ -4,8 +4,9 @@
namespace array {
transitioning javascript builtin
ArraySomeLoopEagerDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
ArraySomeLoopEagerDeoptContinuation(
js-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
......@@ -25,9 +26,10 @@ namespace array {
}
transitioning javascript builtin
ArraySomeLoopLazyDeoptContinuation(implicit context: Context)(
receiver: Object, callback: Object, thisArg: Object, initialK: Object,
length: Object, result: Object): Object {
ArraySomeLoopLazyDeoptContinuation(
js-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.
......@@ -109,7 +111,8 @@ namespace array {
// https://tc39.github.io/ecma262/#sec-array.prototype.some
transitioning javascript builtin
ArraySome(implicit context: Context)(receiver: Object, ...arguments): Object {
ArraySome(js-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(context: Context, receiver: Object, ...arguments):
Object {
ArrayPrototypeSplice(js-implicit 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(
context: Context, receiver: Object, ...arguments): Object {
js-implicit context: Context, receiver: Object)(...arguments): Object {
try {
TryFastArrayUnshift(context, receiver, arguments) otherwise Baseline;
}
......
......@@ -3,24 +3,16 @@
// 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(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 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,11 +136,6 @@ 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,10 +20,6 @@ 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,7 +74,8 @@ namespace data_view {
// ES6 section 24.2.4.1 get DataView.prototype.buffer
javascript builtin DataViewPrototypeGetBuffer(
context: Context, receiver: Object, ...arguments): JSArrayBuffer {
js-implicit context: Context,
receiver: Object)(...arguments): JSArrayBuffer {
const dataView: JSDataView =
ValidateDataView(context, receiver, 'get DataView.prototype.buffer');
return dataView.buffer;
......@@ -82,7 +83,7 @@ namespace data_view {
// ES6 section 24.2.4.2 get DataView.prototype.byteLength
javascript builtin DataViewPrototypeGetByteLength(
context: Context, receiver: Object, ...arguments): Number {
js-implicit context: Context, receiver: Object)(...arguments): Number {
const dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_length');
if (WasNeutered(dataView)) {
......@@ -95,7 +96,7 @@ namespace data_view {
// ES6 section 24.2.4.3 get DataView.prototype.byteOffset
javascript builtin DataViewPrototypeGetByteOffset(
context: Context, receiver: Object, ...arguments): Number {
js-implicit context: Context, receiver: Object)(...arguments): Number {
const dataView: JSDataView = ValidateDataView(
context, receiver, 'get DataView.prototype.byte_offset');
if (WasNeutered(dataView)) {
......@@ -415,19 +416,19 @@ namespace data_view {
}
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;
return DataViewGet(context, receiver, offset, Undefined, UINT8_ELEMENTS);
}
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;
return DataViewGet(context, receiver, offset, Undefined, INT8_ELEMENTS);
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -436,7 +437,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -445,7 +446,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -454,7 +455,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -463,7 +464,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -472,7 +473,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -481,7 +482,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -490,7 +491,7 @@ namespace data_view {
}
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 isLittleEndian: Object =
arguments.length > 1 ? arguments[1] : Undefined;
......@@ -717,7 +718,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
return DataViewSet(
......@@ -725,7 +726,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
return DataViewSet(
......@@ -733,7 +734,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -743,7 +744,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -753,7 +754,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -763,7 +764,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -773,7 +774,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -783,7 +784,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -793,7 +794,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......@@ -803,7 +804,7 @@ namespace data_view {
}
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 value: Object = arguments.length > 1 ? arguments[1] : Undefined;
const isLittleEndian: Object =
......
......@@ -8,17 +8,18 @@ namespace extras_utils {
extern runtime PromiseStatus(Context, Object): Smi;
javascript builtin ExtrasUtilsCreatePrivateSymbol(
context: Context, receiver: Object, ...arguments): HeapObject {
js-implicit context: Context,
receiver: Object)(...arguments): HeapObject {
return CreatePrivateSymbol(context, arguments[0]);
}
javascript builtin ExtrasUtilsMarkPromiseAsHandled(
context: Context, receiver: Object, ...arguments): Undefined {
js-implicit context: Context, receiver: Object)(...arguments): Undefined {
return PromiseMarkAsHandled(context, arguments[0]);
}
javascript builtin ExtrasUtilsPromiseState(
context: Context, receiver: Object, ...arguments): Smi {
js-implicit context: Context, receiver: Object)(...arguments): Smi {
return PromiseStatus(context, arguments[0]);
}
}
......@@ -33,8 +33,8 @@ namespace object {
}
transitioning javascript builtin
ObjectFromEntries(implicit context: Context)(receiver: Object, ...arguments):
Object {
ObjectFromEntries(js-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(
implicit context: Context)(_receiver: Object, object: Object): Object {
js-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(
implicit context: Context)(_receiver: Object, object: Object): Object {
js-implicit context: Context)(_receiver: Object, object: Object): Object {
return object::ObjectPreventExtensionsThrow(object);
}
} // namespace object_preventextensions
......@@ -6,17 +6,14 @@
namespace proxy {
extern macro ProxiesCodeStubAssembler::GetProxyConstructorJSNewTarget():
Object;
// ES #sec-proxy-constructor
// https://tc39.github.io/ecma262/#sec-proxy-constructor
transitioning javascript builtin
ProxyConstructor(implicit context: Context)(
_receiver: Object, target: Object, handler: Object): JSProxy {
ProxyConstructor(
js-implicit context: Context, receiver: Object,
newTarget: 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(implicit context: Context)(): Undefined {
ProxyRevoke(js-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(
implicit context: Context)(_receiver: Object, object: Object): Object {
js-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(
implicit context: Context)(_receiver: Object, object: Object): Object {
js-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(
context: Context, receiver: Object, ...arguments): Object {
js-implicit 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(
context: Context, receiver: Object, ...arguments): Boolean {
js-implicit context: Context, receiver: Object)(...arguments): Boolean {
const searchString: Object = arguments[0];
const endPosition: Object = arguments[1];
......
......@@ -22,22 +22,23 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.anchor
transitioning javascript builtin StringPrototypeAnchor(
context: Context, receiver: Object, ...arguments): String {
js-implicit 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(context: Context, receiver: Object, ...arguments): String {
StringPrototypeBig(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeBlink(js-implicit context: Context, receiver: Object)(
...arguments): String {
return CreateHTML(
receiver, 'String.prototype.blink', 'blink', kEmptyString,
kEmptyString);
......@@ -45,56 +46,56 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.bold
transitioning javascript builtin
StringPrototypeBold(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeBold(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeFontcolor(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeFontsize(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeFixed(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeItalics(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeLink(js-implicit 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(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeSmall(js-implicit context: Context, receiver: Object)(
...arguments): String {
return CreateHTML(
receiver, 'String.prototype.small', 'small', kEmptyString,
kEmptyString);
......@@ -102,8 +103,8 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.strike
transitioning javascript builtin
StringPrototypeStrike(context: Context, receiver: Object, ...arguments):
String {
StringPrototypeStrike(js-implicit context: Context, receiver: Object)(
...arguments): String {
return CreateHTML(
receiver, 'String.prototype.strike', 'strike', kEmptyString,
kEmptyString);
......@@ -111,14 +112,16 @@ namespace string_html {
// https://tc39.github.io/ecma262/#sec-string.prototype.sub
transitioning javascript builtin
StringPrototypeSub(context: Context, receiver: Object, ...arguments): String {
StringPrototypeSub(js-implicit 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(context: Context, receiver: Object, ...arguments): String {
StringPrototypeSup(js-implicit 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(
implicit context: Context)(receiver: Object): JSStringIterator {
js-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(
implicit context: Context)(receiver: Object): JSObject {
js-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(
context: Context, receiver: Object, count: Object): String {
js-implicit 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(
implicit context: Context)(receiver: Object, ...arguments): String {
js-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(
context: Context, receiver: Object, ...arguments): Boolean {
js-implicit 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(
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.
const string: String = ToThisString(receiver, 'String.prototype.substring');
const length = string.length_smi;
......
......@@ -7,13 +7,15 @@
namespace string {
// ES6 #sec-string.prototype.tostring
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');
}
// ES6 #sec-string.prototype.valueof
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');
}
......@@ -70,7 +72,8 @@ namespace string {
// ES6 #sec-string.prototype.charat
transitioning javascript builtin StringPrototypeCharAt(
implicit context: Context)(receiver: Object, position: Object): Object {
js-implicit context: Context,
receiver: Object)(position: Object): Object {
try {
GenerateStringAt(receiver, position, 'String.prototype.charAt')
otherwise IfInBounds, IfOutOfBounds;
......@@ -86,7 +89,8 @@ namespace string {
// ES6 #sec-string.prototype.charcodeat
transitioning javascript builtin StringPrototypeCharCodeAt(
implicit context: Context)(receiver: Object, position: Object): Object {
js-implicit context: Context,
receiver: Object)(position: Object): Object {
try {
GenerateStringAt(receiver, position, 'String.prototype.charCodeAt')
otherwise IfInBounds, IfOutOfBounds;
......@@ -102,7 +106,8 @@ namespace string {
// ES6 #sec-string.prototype.codepointat
transitioning javascript builtin StringPrototypeCodePointAt(
implicit context: Context)(receiver: Object, position: Object): Object {
js-implicit context: Context,
receiver: Object)(position: Object): Object {
try {
GenerateStringAt(receiver, position, 'String.prototype.codePointAt')
otherwise IfInBounds, IfOutOfBounds;
......@@ -121,7 +126,7 @@ namespace string {
// ES6 String.prototype.concat(...args)
// ES6 #sec-string.prototype.concat
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.
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(implicit context: Context)(
receiver: Object, ...arguments): Object {
TypedArrayPrototypeEvery(js-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(
context: Context, receiver: Object, ...arguments): Object {
js-implicit 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(implicit context:
Context)(receiver: Object, ...arguments): Object {
TypedArrayPrototypeFind(js-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(implicit context: Context)(
receiver: Object, ...arguments): Object {
TypedArrayPrototypeFindIndex(js-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(implicit context: Context)(
receiver: Object, ...arguments): Object {
TypedArrayPrototypeForEach(js-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(implicit context: Context)(
receiver: Object, ...arguments): Object {
TypedArrayPrototypeReduce(js-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(implicit context: Context)(
receiver: Object, ...arguments): Object {
TypedArrayPrototypeReduceRight(
js-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(
context: Context, receiver: Object, ...arguments): Object {
js-implicit 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(implicit context:
Context)(receiver: Object, ...arguments): Object {
TypedArrayPrototypeSome(js-implicit context: Context, receiver: Object)(
...arguments): Object {
// arguments[0] = callback
// arguments[1] = thisArg.
try {
......
......@@ -5,7 +5,8 @@
namespace typed_array_subarray {
// ES %TypedArray%.prototype.subarray
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';
// 1. Let O be the this value.
......
......@@ -278,7 +278,8 @@ namespace typed_array {
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.sort
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,
// throw a TypeError exception.
const comparefnObj: Object =
......
......@@ -15,6 +15,7 @@
#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 {
......@@ -559,14 +560,18 @@ struct NewExpression : Expression {
std::vector<NameAndExpression> initializers;
};
enum class ImplicitKind { kNoImplicit, kJSImplicit, kImplicit };
struct ParameterList {
std::vector<Identifier*> names;
std::vector<TypeExpression*> types;
size_t implicit_count;
bool has_varargs;
std::string arguments_variable;
ImplicitKind implicit_kind = ImplicitKind::kNoImplicit;
SourcePosition implicit_kind_pos = SourcePosition::Invalid();
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() {
return std::vector<TypeExpression*>(types.begin(),
types.begin() + implicit_count);
......@@ -821,6 +826,11 @@ struct NameAndTypeExpression {
TypeExpression* type;
};
struct ImplicitParameters {
Identifier* kind;
std::vector<NameAndTypeExpression> parameters;
};
struct StructFieldExpression {
NameAndTypeExpression name_and_type;
bool const_qualified;
......@@ -880,7 +890,12 @@ struct MacroDeclaration : CallableNode {
const LabelAndTypesVector& labels)
: CallableNode(kind, pos, transitioning, std::move(name),
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;
};
......@@ -904,7 +919,11 @@ 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, {}) {}
return_type, {}) {
if (parameters.implicit_kind != ImplicitKind::kNoImplicit) {
Error("Intinsics cannot have implicit parameters.");
}
}
};
struct TorqueMacroDeclaration : MacroDeclaration {
......@@ -928,7 +947,21 @@ struct BuiltinDeclaration : CallableNode {
TypeExpression* return_type)
: CallableNode(kind, pos, transitioning, std::move(name),
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;
};
......
......@@ -22,6 +22,7 @@ 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,28 +76,12 @@ 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])) {
......@@ -136,8 +120,7 @@ void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl,
const Signature& signature,
base::Optional<Statement*> body) {
if (signature.parameter_types.types.size() == 0 ||
!(signature.parameter_types.types[0] ==
Declarations::LookupGlobalType(CONTEXT_TYPE_STRING))) {
!(signature.parameter_types.types[0] == TypeOracle::GetContextType())) {
ReportError(
"first parameter to runtime functions has to be the context and have "
"type Context, but found type ",
......
......@@ -159,26 +159,21 @@ Symbol* Lexer::MatchToken(InputPosition* pos, InputPosition end) {
symbol = &pair.second;
}
}
// 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.
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.
for (auto it = keywords_.rbegin(); it != keywords_.rend(); ++it) {
const std::string& keyword = it->first;
if (static_cast<size_t>(end - *pos) < keyword.size()) continue;
if (keyword == std::string(*pos, *pos + keyword.size())) {
*pos += keyword.size();
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();
return &it->second;
}
}
if (pattern_size > 0) return symbol;
return nullptr;
}
......
......@@ -53,6 +53,8 @@ enum class ParseResultHolderBase::TypeId {
kLabelBlockPtr,
kOptionalLabelBlockPtr,
kNameAndTypeExpression,
kImplicitParameters,
kOptionalImplicitParameters,
kNameAndExpression,
kConditionalAnnotation,
kOptionalConditionalAnnotation,
......
......@@ -415,61 +415,128 @@ void ImplementationVisitor::Visit(Builtin* builtin) {
BlockBindings<LocalValue> parameter_bindings(&ValueBindingsManager::Get());
// 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);
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";
}
if (builtin->IsVarArgsJavaScript() || builtin->IsFixedArgsJavaScript()) {
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";
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);
const Type* body_result = Visit(*builtin->body());
if (body_result != TypeOracle::GetNeverType()) {
......
......@@ -128,6 +128,14 @@ 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;
......@@ -376,59 +384,60 @@ base::Optional<ParseResult> MakeSpreadExpression(
return ParseResult{result};
}
template <bool has_varargs>
base::Optional<ParseResult> MakeParameterListFromTypes(
base::Optional<ParseResult> MakeImplicitParameterList(
ParseResultIterator* child_results) {
auto implicit_params =
child_results->NextAs<std::vector<NameAndTypeExpression>>();
auto explicit_types = child_results->NextAs<TypeList>();
ParameterList result;
result.has_varargs = has_varargs;
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.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);
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");
}
return ParseResult{std::move(result)};
parameter_list->names.push_back(param.name);
parameter_list->types.push_back(param.type);
}
template <bool has_varargs>
base::Optional<ParseResult> MakeParameterListFromNameAndTypeList(
template <bool has_varargs, bool has_explicit_parameter_names>
base::Optional<ParseResult> MakeParameterList(
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 (child_results->HasNext()) {
arguments_variable = child_results->NextAs<std::string>();
}
child_results->NextAs<base::Optional<ImplicitParameters>>();
ParameterList result;
for (NameAndTypeExpression& pair : implicit_params) {
if (!IsLowerCamelCase(pair.name->value)) {
NamingConventionError("Parameter", pair.name, "lowerCamelCase");
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_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 (!IsLowerCamelCase(pair.name->value)) {
NamingConventionError("Parameter", pair.name, "lowerCamelCase");
if (has_explicit_parameter_names) {
auto explicit_params =
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)};
}
......@@ -1506,20 +1515,22 @@ 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{
TryOrDefault<std::vector<NameAndTypeExpression>>(
Sequence({Token("("), Token("implicit"),
List<NameAndTypeExpression>(&nameAndType, Token(",")),
Token(")")}))};
Optional<ImplicitParameters>(&implicitParameterList)};
// Result: ParameterList
Symbol typeListMaybeVarArgs = {
Rule({optionalImplicitParameterList, Token("("),
List<TypeExpression*>(Sequence({&type, Token(",")})), Token("..."),
Token(")")},
MakeParameterListFromTypes<true>),
MakeParameterList<true, false>),
Rule({optionalImplicitParameterList, Token("("), typeList, Token(")")},
MakeParameterListFromTypes<false>)};
MakeParameterList<false, false>)};
// Result: LabelAndTypes
Symbol labelParameter = {Rule(
......@@ -1566,15 +1577,15 @@ struct TorqueGrammar : Grammar {
Symbol parameterListNoVararg = {
Rule({optionalImplicitParameterList, Token("("),
List<NameAndTypeExpression>(&nameAndType, Token(",")), Token(")")},
MakeParameterListFromNameAndTypeList<false>)};
MakeParameterList<false, true>)};
// Result: ParameterList
Symbol parameterListAllowVararg = {
Rule({&parameterListNoVararg}),
Rule({optionalImplicitParameterList, Token("("),
NonemptyList<NameAndTypeExpression>(&nameAndType, Token(",")),
Token(","), Token("..."), &identifier, Token(")")},
MakeParameterListFromNameAndTypeList<true>)};
List<NameAndTypeExpression>(Sequence({&nameAndType, Token(",")})),
Token("..."), &identifier, Token(")")},
MakeParameterList<true, true>)};
// Result: Identifier*
Symbol* OneOf(const std::vector<std::string>& alternatives) {
......
......@@ -203,6 +203,14 @@ 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,6 +669,7 @@ 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(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,
// throw a TypeError exception.
const comparefnObj: Object = arguments[0];
......
......@@ -51,6 +51,7 @@ 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
......@@ -88,6 +89,8 @@ 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
syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast js-implicit implicit
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