Bug 1394490 - Avoid Ion compile for non-syntactic JSOP_FUNCTIONTHIS draft
authorTed Campbell <tcampbell@mozilla.com>
Thu, 31 Aug 2017 15:40:50 -0400
changeset 657506 f73a1f41a0aada6f3252c590b5396a45216adf9d
parent 656655 fb22415719a9d971a2646fa2d1b74e134ca00c3d
child 657507 2c68222aaa722ef973bceefd676e213fe42a07d4
push id77543
push userbmo:tcampbell@mozilla.com
push dateFri, 01 Sep 2017 15:47:07 +0000
bugs1394490
milestone57.0a1
Bug 1394490 - Avoid Ion compile for non-syntactic JSOP_FUNCTIONTHIS Ion does not support non-synactic global environments so don't compile if JSOP_FUNCTIONTHIS needs non-strict non-syntactic fallback. MozReview-Commit-ID: BiDAeQljjJx
js/src/jit/IonBuilder.cpp
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -12443,18 +12443,24 @@ IonBuilder::jsop_functionthis()
     // Hard case: |this| may be a primitive we have to wrap.
     MDefinition* def = current->getSlot(info().thisSlot());
 
     if (def->type() == MIRType::Object) {
         current->push(def);
         return Ok();
     }
 
+    // Beyond this point we may need to access non-syntactic global. Ion doesn't
+    // currently support this so just abort.
+    if (script()->hasNonSyntacticScope())
+        return abort(AbortReason::Disable, "JSOP_FUNCTIONTHIS would need non-syntactic global");
+
     if (IsNullOrUndefined(def->type())) {
-        pushConstant(GetThisValue(&script()->global()));
+        LexicalEnvironmentObject* globalLexical = &script()->global().lexicalEnvironment();
+        pushConstant(globalLexical->thisValue());
         return Ok();
     }
 
     MComputeThis* thisObj = MComputeThis::New(alloc(), def);
     current->add(thisObj);
     current->push(thisObj);
 
     return resumeAfter(thisObj);