Commit 102209bf authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] fix js-implicit for non-vararg signatures

The generation of TFJ declarations for non-vararg JavaScript-linkage
builtins was very broken. Now it works as it should: the explicit
parameters correspond to normal JavaScript parameters.

Bug: v8:7793
Change-Id: I9fa0bdd45f8c4b678d4f0436af3e9b53cba69475
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1769317
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63394}
parent ef2f091f
......@@ -7,7 +7,7 @@ namespace math {
extern macro Float64Acos(float64): float64;
transitioning javascript builtin
MathAcos(context: Context, _receiver: Object, x: Object): Number {
MathAcos(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Acos(value));
}
......@@ -16,7 +16,7 @@ namespace math {
extern macro Float64Acosh(float64): float64;
transitioning javascript builtin
MathAcosh(context: Context, _receiver: Object, x: Object): Number {
MathAcosh(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Acosh(value));
}
......@@ -25,7 +25,7 @@ namespace math {
extern macro Float64Asin(float64): float64;
transitioning javascript builtin
MathAsin(context: Context, _receiver: Object, x: Object): Number {
MathAsin(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Asin(value));
}
......@@ -34,7 +34,7 @@ namespace math {
extern macro Float64Asinh(float64): float64;
transitioning javascript builtin
MathAsinh(context: Context, _receiver: Object, x: Object): Number {
MathAsinh(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Asinh(value));
}
......@@ -43,7 +43,7 @@ namespace math {
extern macro Float64Atan(float64): float64;
transitioning javascript builtin
MathAtan(context: Context, _receiver: Object, x: Object): Number {
MathAtan(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Atan(value));
}
......@@ -52,7 +52,7 @@ namespace math {
extern macro Float64Atan2(float64, float64): float64;
transitioning javascript builtin
MathAtan2(context: Context, _receiver: Object, y: Object, x: Object): Number {
MathAtan2(js-implicit context: Context)(y: Object, x: Object): Number {
const yValue = Convert<float64>(ToNumber_Inline(context, y));
const xValue = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Atan2(yValue, xValue));
......@@ -62,7 +62,7 @@ namespace math {
extern macro Float64Atanh(float64): float64;
transitioning javascript builtin
MathAtanh(context: Context, _receiver: Object, x: Object): Number {
MathAtanh(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Atanh(value));
}
......@@ -71,7 +71,7 @@ namespace math {
extern macro Float64Cbrt(float64): float64;
transitioning javascript builtin
MathCbrt(context: Context, _receiver: Object, x: Object): Number {
MathCbrt(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Cbrt(value));
}
......@@ -80,7 +80,7 @@ namespace math {
extern macro Word32Clz(int32): int32;
transitioning javascript builtin
MathClz32(context: Context, _receiver: Object, x: Object): Number {
MathClz32(js-implicit context: Context)(x: Object): Number {
const num = ToNumber_Inline(context, x);
let value: int32;
......@@ -100,7 +100,7 @@ namespace math {
extern macro Float64Cos(float64): float64;
transitioning javascript builtin
MathCos(context: Context, _receiver: Object, x: Object): Number {
MathCos(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Cos(value));
}
......@@ -109,7 +109,7 @@ namespace math {
extern macro Float64Cosh(float64): float64;
transitioning javascript builtin
MathCosh(context: Context, _receiver: Object, x: Object): Number {
MathCosh(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Cosh(value));
}
......@@ -118,7 +118,7 @@ namespace math {
extern macro Float64Exp(float64): float64;
transitioning javascript builtin
MathExp(context: Context, _receiver: Object, x: Object): Number {
MathExp(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Exp(value));
}
......@@ -127,14 +127,14 @@ namespace math {
extern macro Float64Expm1(float64): float64;
transitioning javascript builtin
MathExpm1(context: Context, _receiver: Object, x: Object): Number {
MathExpm1(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Expm1(value));
}
// ES6 #sec-math.fround
transitioning javascript builtin
MathFround(context: Context, _receiver: Object, x: Object): Number {
MathFround(js-implicit context: Context)(x: Object): Number {
const x32 = Convert<float32>(ToNumber_Inline(context, x));
const x64 = Convert<float64>(x32);
return Convert<Number>(x64);
......@@ -144,7 +144,7 @@ namespace math {
extern macro Float64Log(float64): float64;
transitioning javascript builtin
MathLog(context: Context, _receiver: Object, x: Object): Number {
MathLog(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log(value));
}
......@@ -153,7 +153,7 @@ namespace math {
extern macro Float64Log1p(float64): float64;
transitioning javascript builtin
MathLog1p(context: Context, _receiver: Object, x: Object): Number {
MathLog1p(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log1p(value));
}
......@@ -162,7 +162,7 @@ namespace math {
extern macro Float64Log10(float64): float64;
transitioning javascript builtin
MathLog10(context: Context, _receiver: Object, x: Object): Number {
MathLog10(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log10(value));
}
......@@ -171,7 +171,7 @@ namespace math {
extern macro Float64Log2(float64): float64;
transitioning javascript builtin
MathLog2(context: Context, _receiver: Object, x: Object): Number {
MathLog2(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Log2(value));
}
......@@ -180,14 +180,14 @@ namespace math {
extern macro Float64Sin(float64): float64;
transitioning javascript builtin
MathSin(context: Context, _receiver: Object, x: Object): Number {
MathSin(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Sin(value));
}
// ES6 #sec-math.sign
transitioning javascript builtin
MathSign(context: Context, _receiver: Object, x: Object): Number {
MathSign(js-implicit context: Context)(x: Object): Number {
const num = ToNumber_Inline(context, x);
const value = Convert<float64>(num);
......@@ -204,7 +204,7 @@ namespace math {
extern macro Float64Sinh(float64): float64;
transitioning javascript builtin
MathSinh(context: Context, _receiver: Object, x: Object): Number {
MathSinh(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Sinh(value));
}
......@@ -213,7 +213,7 @@ namespace math {
extern macro Float64Sqrt(float64): float64;
transitioning javascript builtin
MathSqrt(context: Context, _receiver: Object, x: Object): Number {
MathSqrt(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Sqrt(value));
}
......@@ -222,7 +222,7 @@ namespace math {
extern macro Float64Tan(float64): float64;
transitioning javascript builtin
MathTan(context: Context, _receiver: Object, x: Object): Number {
MathTan(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Tan(value));
}
......@@ -231,7 +231,7 @@ namespace math {
extern macro Float64Tanh(float64): float64;
transitioning javascript builtin
MathTanh(context: Context, _receiver: Object, x: Object): Number {
MathTanh(js-implicit context: Context)(x: Object): Number {
const value = Convert<float64>(ToNumber_Inline(context, x));
return Convert<Number>(Float64Tanh(value));
}
......
......@@ -94,8 +94,8 @@ 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 {
transitioning javascript builtin
ObjectIsExtensible(js-implicit context: Context)(object: Object): Object {
return object::ObjectIsExtensible(object);
}
} // namespace object_isextensible
......@@ -103,15 +103,15 @@ 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 {
js-implicit context: Context)(object: Object): Object {
return object::ObjectPreventExtensionsThrow(object);
}
} // namespace object_preventextensions
namespace object_getprototypeof {
// ES6 section 19.1.2.9 Object.getPrototypeOf ( O )
transitioning javascript builtin ObjectGetPrototypeOf(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
transitioning javascript builtin
ObjectGetPrototypeOf(js-implicit context: Context)(object: Object): Object {
return object::ObjectGetPrototypeOf(object);
}
} // namespace object_getprototypeof
......@@ -119,8 +119,7 @@ namespace object_getprototypeof {
namespace object_setprototypeof {
// ES6 section 19.1.2.21 Object.setPrototypeOf ( O, proto )
transitioning javascript builtin ObjectSetPrototypeOf(
js-implicit context:
Context)(_receiver: Object, object: Object, proto: Object): Object {
js-implicit context: Context)(object: Object, proto: Object): Object {
// 1. Set O to ? RequireObjectCoercible(O).
RequireObjectCoercible(object, 'Object.setPrototypeOf');
......
......@@ -12,9 +12,8 @@ namespace proxy {
// Proxy.revocable(target, handler)
// https://tc39.github.io/ecma262/#sec-proxy.revocable
transitioning javascript builtin
ProxyRevocable(
context: Context, _receiver: Object, target: Object,
handler: Object): JSProxyRevocableResult {
ProxyRevocable(js-implicit context: Context)(target: Object, handler: Object):
JSProxyRevocableResult {
try {
const targetJSReceiver =
Cast<JSReceiver>(target) otherwise ThrowProxyNonObject;
......
......@@ -8,8 +8,8 @@ namespace reflect {
generates 'MessageTemplate::kCalledOnNonObject';
// ES6 section 26.1.10 Reflect.isExtensible
transitioning javascript builtin ReflectIsExtensible(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
transitioning javascript builtin
ReflectIsExtensible(js-implicit context: Context)(object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.isExtensible');
return object::ObjectIsExtensible(objectJSReceiver);
......@@ -17,15 +17,15 @@ namespace reflect {
// ES6 section 26.1.12 Reflect.preventExtensions
transitioning javascript builtin ReflectPreventExtensions(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
js-implicit context: Context)(object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.preventExtensions');
return object::ObjectPreventExtensionsDontThrow(objectJSReceiver);
}
// ES6 section 26.1.8 Reflect.getPrototypeOf
transitioning javascript builtin ReflectGetPrototypeOf(
js-implicit context: Context)(_receiver: Object, object: Object): Object {
transitioning javascript builtin
ReflectGetPrototypeOf(js-implicit context: Context)(object: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.getPrototypeOf');
return object::JSReceiverGetPrototypeOf(objectJSReceiver);
......@@ -33,8 +33,7 @@ namespace reflect {
// ES6 section 26.1.14 Reflect.setPrototypeOf
transitioning javascript builtin ReflectSetPrototypeOf(
js-implicit context:
Context)(_receiver: Object, object: Object, proto: Object): Object {
js-implicit context: Context)(object: Object, proto: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.setPrototypeOf');
if (proto == Null || Is<JSReceiver>(proto)) {
......@@ -67,8 +66,7 @@ namespace reflect {
// ES6 section 26.1.4 Reflect.deleteProperty
transitioning javascript builtin ReflectDeleteProperty(
js-implicit context:
Context)(_receiver: Object, object: Object, key: Object): Object {
js-implicit context: Context)(object: Object, key: Object): Object {
const objectJSReceiver = Cast<JSReceiver>(object)
otherwise ThrowTypeError(kCalledOnNonObject, 'Reflect.deleteProperty');
return DeleteProperty(objectJSReceiver, key, kSloppy);
......
......@@ -15,7 +15,7 @@ namespace regexp {
// ES6 21.2.5.10.
// ES #sec-get-regexp.prototype.source
transitioning javascript builtin RegExpPrototypeSourceGetter(
js-implicit context: Context)(receiver: Object): Object {
js-implicit context: Context, receiver: Object)(): Object {
typeswitch (receiver) {
case (receiver: JSRegExp): {
return receiver.source;
......
......@@ -17,7 +17,7 @@ namespace string_iterator {
// ES6 #sec-string.prototype-@@iterator
transitioning javascript builtin StringPrototypeIterator(
js-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(
js-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);
......
......@@ -7,14 +7,14 @@
namespace string {
// ES6 #sec-string.prototype.tostring
transitioning javascript builtin
StringPrototypeToString(js-implicit context: Context)(receiver: 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(js-implicit context: Context)(receiver: Object):
StringPrototypeValueOf(js-implicit context: Context, receiver: Object)():
Object {
return ToThisValue(receiver, kString, 'String.prototype.valueOf');
}
......
......@@ -2645,7 +2645,7 @@ void ImplementationVisitor::GenerateBuiltinDefinitions(
for (auto& declarable : GlobalContext::AllDeclarables()) {
Builtin* builtin = Builtin::DynamicCast(declarable.get());
if (!builtin || builtin->IsExternal()) continue;
int firstParameterIndex = 1;
size_t firstParameterIndex = 1;
bool declareParameters = true;
if (builtin->IsStub()) {
new_contents_stream << "TFS(" << builtin->ExternalName();
......@@ -2656,24 +2656,22 @@ void ImplementationVisitor::GenerateBuiltinDefinitions(
<< ", SharedFunctionInfo::kDontAdaptArgumentsSentinel";
declareParameters = false;
} else {
assert(builtin->IsFixedArgsJavaScript());
DCHECK(builtin->IsFixedArgsJavaScript());
// FixedArg javascript builtins need to offer the parameter
// count.
int size = static_cast<int>(builtin->parameter_names().size());
assert(size >= 1);
new_contents_stream << ", " << (std::max(size - 2, 0));
int parameter_count =
static_cast<int>(builtin->signature().ExplicitCount());
new_contents_stream << ", " << parameter_count;
// And the receiver is explicitly declared.
new_contents_stream << ", kReceiver";
firstParameterIndex = 2;
firstParameterIndex = builtin->signature().implicit_count;
}
}
if (declareParameters) {
int index = 0;
for (const auto& parameter : builtin->parameter_names()) {
if (index >= firstParameterIndex) {
new_contents_stream << ", k" << CamelifyString(parameter->value);
}
index++;
for (size_t i = firstParameterIndex;
i < builtin->parameter_names().size(); ++i) {
Identifier* parameter = builtin->parameter_names()[i];
new_contents_stream << ", k" << CamelifyString(parameter->value);
}
}
new_contents_stream << ") \\\n";
......
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