From 36cf6431951fad2317085447e58eaeb0af2e7ff8 Mon Sep 17 00:00:00 2001 From: Z Duong Nguyen-Huu Date: Fri, 3 May 2019 10:16:18 -0700 Subject: [PATCH] [torque] Allow define javascript buitin with context only We should allow the following code to compile transitioning javascript builtin ProxyRevoke(context: Context): Undefined {...} transitioning javascript builtin ProxyRevoke(implicit context: Context)(): Undefined {...} Bug: v8:9007 Change-Id: I8729b4adc91e6a9fb49a50edf2974d84ec4e10ec Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1591343 Commit-Queue: Z Nguyen-Huu Reviewed-by: Tobias Tebbi Cr-Commit-Position: refs/heads/master@{#61218} --- src/builtins/proxy-revoke.tq | 3 +-- src/torque/declaration-visitor.cc | 2 +- src/torque/implementation-visitor.cc | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/builtins/proxy-revoke.tq b/src/builtins/proxy-revoke.tq index 8ab5d8dd51..400f586b21 100644 --- a/src/builtins/proxy-revoke.tq +++ b/src/builtins/proxy-revoke.tq @@ -8,9 +8,8 @@ namespace proxy { // Proxy Revocation Functions // https://tc39.github.io/ecma262/#sec-proxy-revocation-functions - // TODO(v8:9007) remove receiver in argument since we don't use it transitioning javascript builtin - ProxyRevoke(context: Context, receiver: Object): Undefined { + ProxyRevoke(implicit context: Context)(): Undefined { // 1. Let p be F.[[RevocableProxy]]. const proxyObject: Object = context[PROXY_SLOT]; diff --git a/src/torque/declaration-visitor.cc b/src/torque/declaration-visitor.cc index 60ed1933c8..36ca3cebbb 100644 --- a/src/torque/declaration-visitor.cc +++ b/src/torque/declaration-visitor.cc @@ -65,7 +65,7 @@ Builtin* DeclarationVisitor::CreateBuiltin(BuiltinDeclaration* decl, } if (javascript) { - if (signature.types().size() < 2 || + if (signature.types().size() >= 2 && !(signature.types()[1] == Declarations::LookupGlobalType(OBJECT_TYPE_STRING))) { std::stringstream stream; diff --git a/src/torque/implementation-visitor.cc b/src/torque/implementation-visitor.cc index 13a47172f9..763481c330 100644 --- a/src/torque/implementation-visitor.cc +++ b/src/torque/implementation-visitor.cc @@ -2719,8 +2719,9 @@ void ImplementationVisitor::GenerateBuiltinDefinitions(std::string& file_name) { assert(builtin->IsFixedArgsJavaScript()); // FixedArg javascript builtins need to offer the parameter // count. - assert(builtin->parameter_names().size() >= 2); - new_contents_stream << ", " << (builtin->parameter_names().size() - 2); + int size = static_cast(builtin->parameter_names().size()); + assert(size >= 1); + new_contents_stream << ", " << (std::max(size - 2, 0)); // And the receiver is explicitly declared. new_contents_stream << ", kReceiver"; firstParameterIndex = 2;