Streamline JSMainThreadNullState.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 21:42:44 +0000 (21:42 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 21:42:44 +0000 (21:42 +0000)
<https://webkit.org/b/121636>

Reviewed by Anders Carlsson.

JSMainThreadNullState is only used by non-JavaScript bindings and
thus won't ever call didLeaveScriptContext() on destruction.
Specialize the class for its use-case instead of sharing code
with JSMainThreadExecState.

Shrinks the WebCore binary by 82848 bytes.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156118 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSMainThreadExecState.h

index f6560c2f3b4d9bb6a854dc6230d46d27addbba59..c0409ea3fb03113cef6fe70afc96122c43794936 100644 (file)
@@ -1,3 +1,17 @@
+2013-09-19  Andreas Kling  <akling@apple.com>
+
+        Streamline JSMainThreadNullState.
+        <https://webkit.org/b/121636>
+
+        Reviewed by Anders Carlsson.
+
+        JSMainThreadNullState is only used by non-JavaScript bindings and
+        thus won't ever call didLeaveScriptContext() on destruction.
+        Specialize the class for its use-case instead of sharing code
+        with JSMainThreadExecState.
+
+        Shrinks the WebCore binary by 82848 bytes.
+
 2013-09-19  Bear Travis  <betravis@adobe.com>
 
         CSS_SHAPES not supported on AppleWin port
index d12cbebb69a0e3f06caa88f58747d02a6d085367..0b87ecdc2dbae649d8cc8cfa70c444672fdd790c 100644 (file)
@@ -39,6 +39,7 @@ class ScriptExecutionContext;
 
 class JSMainThreadExecState {
     WTF_MAKE_NONCOPYABLE(JSMainThreadExecState);
+    friend class JSMainThreadNullState;
 public:
     static JSC::ExecState* currentState()
     { 
@@ -89,9 +90,23 @@ private:
 
 // Null state prevents origin security checks.
 // Used by non-JavaScript bindings (ObjC, GObject).
-class JSMainThreadNullState : private JSMainThreadExecState {
+class JSMainThreadNullState {
 public:
-    explicit JSMainThreadNullState() : JSMainThreadExecState(0) {};
+    explicit JSMainThreadNullState()
+        : m_previousState(JSMainThreadExecState::s_mainThreadState)
+    {
+        ASSERT(isMainThread());
+        JSMainThreadExecState::s_mainThreadState = nullptr;
+    }
+
+    ~JSMainThreadNullState()
+    {
+        ASSERT(isMainThread());
+        JSMainThreadExecState::s_mainThreadState = m_previousState;
+    }
+
+private:
+    JSC::ExecState* m_previousState;
 };
 
 } // namespace WebCore