Bug 1494930 - Part 3: Don't generate both JSOP_DEFVAR and JSOP_DEFFUN for toplevel functions. (r=arai)
☠☠ backed out by 63ea63571271 ☠ ☠
authorEric Faust <efaustbmo@gmail.com>
Mon, 01 Oct 2018 20:41:48 -0700
changeset 494873 8544285b414588d834cd9147ed06ba02a2a60a03
parent 494872 5fb50ca3776ed1d45fe9ec5634dc267c869082f0
child 494874 275f7949148be2d20a45653e44a0bf4b4ae09a44
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 3: Don't generate both JSOP_DEFVAR and JSOP_DEFFUN for toplevel functions. (r=arai)
js/src/frontend/BinSource.cpp
--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -161,16 +161,22 @@ BinASTParser<Tok>::buildFunctionBox(Gene
     FunctionSyntaxKind syntax,
     ParseNode* name)
 {
     RootedAtom atom(cx_);
     if (name) {
         atom = name->name();
     }
 
+    if (parseContext_ && syntax == FunctionSyntaxKind::Statement) {
+        auto ptr = parseContext_->varScope().lookupDeclaredName(atom);
+        MOZ_ASSERT(ptr);
+        ptr->value()->alterKind(DeclarationKind::BodyLevelFunction);
+    }
+
     // Allocate the function before walking down the tree.
     RootedFunction fun(cx_);
     BINJS_TRY_VAR(fun, AllocNewFunction(cx_, atom, syntax, generatorKind, functionAsyncKind, nullptr));
 
     auto* funbox = alloc_.new_<FunctionBox>(cx_, traceListHead_, fun, /* toStringStart = */ 0,
                                             Directives(parseContext_), /* extraWarning = */ false,
                                             generatorKind, functionAsyncKind);
     if (!funbox) {