Bug 1494930 - Part 2: Correctly generate JSOP_FUNCALL and JSOP_FUNAPPLY. (r=arai)
☠☠ backed out by 63ea63571271 ☠ ☠
authorEric Faust <efaustbmo@gmail.com>
Mon, 01 Oct 2018 20:41:48 -0700
changeset 494872 5fb50ca3776ed1d45fe9ec5634dc267c869082f0
parent 494871 864b718cd7978d9daa418362220e12e2a9aac74d
child 494873 8544285b414588d834cd9147ed06ba02a2a60a03
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1494930
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1494930 - Part 2: Correctly generate JSOP_FUNCALL and JSOP_FUNAPPLY. (r=arai)
js/src/frontend/BinSource-auto.cpp
js/src/frontend/BinSource.yaml
--- a/js/src/frontend/BinSource-auto.cpp
+++ b/js/src/frontend/BinSource-auto.cpp
@@ -3855,16 +3855,28 @@ BinASTParser<Tok>::parseInterfaceCallExp
     MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
 #endif // defined(DEBUG)
 
     BINJS_MOZ_TRY_DECL(callee, parseExpressionOrSuper());
 
     BINJS_MOZ_TRY_DECL(arguments, parseArguments());
 
     auto op = JSOP_CALL;
+
+    // Try to optimize funcall and funapply at the bytecode level
+    if (PropertyName* prop = factory_.maybeDottedProperty(callee)) {
+        if (prop == cx_->names().apply) {
+            op = JSOP_FUNAPPLY;
+            if (parseContext_->isFunctionBox())
+                parseContext_->functionBox()->usesApply = true;
+        } else if (prop == cx_->names().call) {
+            op = JSOP_FUNCALL;
+        }
+    }
+
     // Check for direct calls to `eval`.
     if (factory_.isEvalName(callee, cx_)) {
         if (!parseContext_->varScope().lookupDeclaredNameForAdd(callee->name())
          && !parseContext_->innermostScope()->lookupDeclaredNameForAdd(callee->name())) {
             // This is a direct call to `eval`.
             if (!parseContext_->sc()->hasDirectEval()) {
                 return raiseMissingDirectEvalInAssertedScope();
             }
--- a/js/src/frontend/BinSource.yaml
+++ b/js/src/frontend/BinSource.yaml
@@ -477,16 +477,28 @@ BreakStatement:
                 }
             }
         }
         BINJS_TRY_DECL(result, factory_.newBreakStatement(label ? label->asPropertyName() : nullptr, tokenizer_->pos(start)));
 
 CallExpression:
     build: |
         auto op = JSOP_CALL;
+
+        // Try to optimize funcall and funapply at the bytecode level
+        if (PropertyName* prop = factory_.maybeDottedProperty(callee)) {
+            if (prop == cx_->names().apply) {
+                op = JSOP_FUNAPPLY;
+                if (parseContext_->isFunctionBox())
+                    parseContext_->functionBox()->usesApply = true;
+            } else if (prop == cx_->names().call) {
+                op = JSOP_FUNCALL;
+            }
+        }
+
         // Check for direct calls to `eval`.
         if (factory_.isEvalName(callee, cx_)) {
             if (!parseContext_->varScope().lookupDeclaredNameForAdd(callee->name())
              && !parseContext_->innermostScope()->lookupDeclaredNameForAdd(callee->name())) {
                 // This is a direct call to `eval`.
                 if (!parseContext_->sc()->hasDirectEval()) {
                     return raiseMissingDirectEvalInAssertedScope();
                 }