Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack/uglify-es depend on new JS frontend bindings #533

Closed
classilla opened this issue Oct 31, 2018 · 9 comments
Closed

webpack/uglify-es depend on new JS frontend bindings #533

classilla opened this issue Oct 31, 2018 · 9 comments

Comments

@classilla
Copy link
Owner

classilla commented Oct 31, 2018

After much analysis I have concluded the issues with current webpack (and uglify, when used to build the front end package) are due to the new front-end bindings introduced in Firefox 51. The symptom is usually this is undefined in the JavaScript console, see

angular/angular-cli#9340 (comment)

Currently affected test sites:
https://www.citibank.com (at account login)
https://cloud.google.com/blog (doesn't work hardly at all)

However, it's probable this affects lots of sites and is likely to affect others as they upgrade their front end blobs.

The new front end bindings are https://bugzilla.mozilla.org/show_bug.cgi?id=1263355

This is a huge undertaking. It isn't clear which part fixes the problem.

@classilla
Copy link
Owner Author

Best guess for the actual error is MSG_DEF(JSMSG_UNEXPECTED_TYPE, 2, JSEXN_TYPEERR, "{0} is {1}"). This appears in a number of places, but the most likely ones are:

builtin/Object.cpp:        JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
builtin/ReflectParse.cpp:            ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
builtin/ReflectParse.cpp:                ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
builtin/ReflectParse.cpp:            ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK,
builtin/SymbolObject.cpp:        ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK,
jscntxt.cpp:                                          JSMSG_UNEXPECTED_TYPE, bytes.get(),
jscntxt.cpp:                                          JSMSG_UNEXPECTED_TYPE, bytes.get(),
jsobj.cpp:        JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,

@classilla
Copy link
Owner Author

It's coming from js::ReportIsNullOrUndefined in jscntxt.cpp.

@classilla
Copy link
Owner Author

I think the change needs to occur in BytecodeEmitter::emitNameOp because that can emit a JSOP_UNDEFINED for this.

@classilla
Copy link
Owner Author

One other possibility is BytecodeEmitter::emitThisLiteral but this bug did a lot of changes to emitNameOp's successor emitGetNameAtLocation, so I think that's more likely where the money is. We just need to figure out how we can get the scope there and we could make an analogous change to emit JSOP_GIMPLICITTHIS if global.

@classilla
Copy link
Owner Author

That didn't seem to help. For the record, we did this, which is probably on second thought a no-op:

diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitt
er.cpp
index df0d8a7b0..5d68b8aa9 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2586,20 +2586,23 @@ BytecodeEmitter::emitNameOp(ParseNode* pn, bool callCont
ext)
         } else {
             if (!emitAtomOp(pn, op))
                 return false;
         }
     }
 
     /* Need to provide |this| value for call */
     if (callContext) {
-        if (op == JSOP_GETNAME || op == JSOP_GETGNAME) {
+        if (op == JSOP_GETNAME) {
             JSOp thisOp = needsImplicitThis() ? JSOP_IMPLICITTHIS : JSOP_GIMPLI
CITTHIS;
             if (!emitAtomOp(pn, thisOp))
                 return false;
+        } else if (op == JSOP_GETGNAME) {
+            if (!emitAtomOp(pn, JSOP_GIMPLICITTHIS))
+                return false;
         } else {
             if (!emit1(JSOP_UNDEFINED))
                 return false;
         }
     }
 
     return true;
 }

@classilla
Copy link
Owner Author

Maybe also BytecodeEmitter::emitCallOrNew ?

@classilla
Copy link
Owner Author

Not fixed by this either:

diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitt
er.cpp
index df0d8a7b0..abadb9ef4 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2586,17 +2586,17 @@ BytecodeEmitter::emitNameOp(ParseNode* pn, bool callCont
ext)
         } else {
             if (!emitAtomOp(pn, op))
                 return false;
         }
     }
 
     /* Need to provide |this| value for call */
     if (callContext) {
-        if (op == JSOP_GETNAME || op == JSOP_GETGNAME) {
+        if (1) { // op == JSOP_GETNAME || op == JSOP_GETGNAME) {
             JSOp thisOp = needsImplicitThis() ? JSOP_IMPLICITTHIS : JSOP_GIMPLI
CITTHIS;
             if (!emitAtomOp(pn, thisOp))
                 return false;
         } else {
             if (!emit1(JSOP_UNDEFINED))
                 return false;
         }
     }

@classilla
Copy link
Owner Author

Nor this:

diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitt
er.cpp
index df0d8a7b0..43a39796b 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -2586,24 +2586,27 @@ BytecodeEmitter::emitNameOp(ParseNode* pn, bool callCont
ext)
         } else {
             if (!emitAtomOp(pn, op))
                 return false;
         }
     }
 
     /* Need to provide |this| value for call */
     if (callContext) {
+#if(0)
         if (op == JSOP_GETNAME || op == JSOP_GETGNAME) {
             JSOp thisOp = needsImplicitThis() ? JSOP_IMPLICITTHIS : JSOP_GIMPLI
CITTHIS;
             if (!emitAtomOp(pn, thisOp))
                 return false;
         } else {
             if (!emit1(JSOP_UNDEFINED))
                 return false;
         }
+#endif
+        if(!emitAtomOp(pn, JSOP_IMPLICITTHIS)) return false;
     }
 
     return true;
 }
 
 bool
 BytecodeEmitter::emitPropLHS(ParseNode* pn)
 {

@rardin
Copy link

rardin commented Aug 26, 2019

Issue 533 no longer seems to impact use of the Citi site, evidently due to changes on the Citi side. I was able to login to my account, pay my bill and print a PDF of the transaction with no problem this morning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants