Bug 847450 - Change FastInvokeGuard to only construct an IonContext if it needs one. r=h4writer
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 05 Mar 2013 11:19:10 +0100
changeset 123798 1183cd0b083af88f526de7da3848f174ef8fccc6
parent 123797 38fb986c0f86c55eb92d5a6d7522040abfa90253
child 123799 94e0b7a6523d4068d6dafff132beba50e9c2718c
push id24067
push userjandemooij@gmail.com
push dateTue, 05 Mar 2013 10:19:54 +0000
treeherdermozilla-inbound@1183cd0b083a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs847450
milestone22.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 847450 - Change FastInvokeGuard to only construct an IonContext if it needs one. r=h4writer
js/src/jsinterpinlines.h
--- a/js/src/jsinterpinlines.h
+++ b/js/src/jsinterpinlines.h
@@ -1116,26 +1116,27 @@ ReportIfNotFunction(JSContext *cx, const
  * Ion directly.
  */
 class FastInvokeGuard
 {
     InvokeArgsGuard args_;
     RootedFunction fun_;
     RootedScript script_;
 #ifdef JS_ION
-    ion::IonContext ictx_;
+    // Constructing an IonContext is pretty expensive due to the TLS access,
+    // so only do this if we have to.
+    mozilla::Maybe<ion::IonContext> ictx_;
     bool useIon_;
 #endif
 
   public:
     FastInvokeGuard(JSContext *cx, const Value &fval)
       : fun_(cx)
       , script_(cx)
 #ifdef JS_ION
-      , ictx_(cx, cx->compartment, NULL)
       , useIon_(ion::IsEnabled(cx))
 #endif
     {
         JS_ASSERT(!InParallelSection());
         initFunction(fval);
     }
 
     void initFunction(const Value &fval) {
@@ -1150,16 +1151,18 @@ class FastInvokeGuard
 
     InvokeArgsGuard &args() {
         return args_;
     }
 
     bool invoke(JSContext *cx) {
 #ifdef JS_ION
         if (useIon_ && fun_) {
+            if (ictx_.empty())
+                ictx_.construct(cx, cx->compartment, (js::ion::TempAllocator *)NULL);
             JS_ASSERT(fun_->nonLazyScript() == script_);
 
             ion::MethodStatus status = ion::CanEnterUsingFastInvoke(cx, script_, args_.length());
             if (status == ion::Method_Error)
                 return false;
             if (status == ion::Method_Compiled) {
                 ion::IonExecStatus result = ion::FastInvoke(cx, fun_, args_);
                 if (IsErrorStatus(result))