]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - interpreter/CachedCall.h
JavaScriptCore-1097.3.tar.gz
[apple/javascriptcore.git] / interpreter / CachedCall.h
index f48f4f4cabd159b6cb8424e1fd02e1af1d140f4a..ea55d90e580fbb65623726baf02575b8a09b98b8 100644 (file)
 #include "Interpreter.h"
 
 namespace JSC {
-    class CachedCall : Noncopyable {
+    class CachedCall {
+        WTF_MAKE_NONCOPYABLE(CachedCall); WTF_MAKE_FAST_ALLOCATED;
     public:
-        CachedCall(CallFrame* callFrame, JSFunction* function, int argCount, JSValue* exception)
+        CachedCall(CallFrame* callFrame, JSFunction* function, int argumentCount)
             : m_valid(false)
             , m_interpreter(callFrame->interpreter())
-            , m_exception(exception)
-            , m_globalObjectScope(callFrame, callFrame->globalData().dynamicGlobalObject ? callFrame->globalData().dynamicGlobalObject : function->scope().node()->globalObject())
+            , m_globalObjectScope(callFrame->globalData(), function->scope()->globalObject.get())
         {
-            m_closure = m_interpreter->prepareForRepeatCall(function->body(), callFrame, function, argCount, function->scope().node(), exception);
-            m_valid = !*exception;
+            ASSERT(!function->isHostFunction());
+            m_closure = m_interpreter->prepareForRepeatCall(function->jsExecutable(), callFrame, function, argumentCount + 1, function->scope());
+            m_valid = !callFrame->hadException();
         }
         
         JSValue call()
         { 
             ASSERT(m_valid);
-            return m_interpreter->execute(m_closure, m_exception);
+            return m_interpreter->execute(m_closure);
         }
-        void setThis(JSValue v) { m_closure.setArgument(0, v); }
-        void setArgument(int n, JSValue v) { m_closure.setArgument(n + 1, v); }
-        CallFrame* newCallFrame() { return m_closure.newCallFrame; }
+        void setThis(JSValue v) { m_closure.setThis(v); }
+        void setArgument(int n, JSValue v) { m_closure.setArgument(n, v); }
+
+        CallFrame* newCallFrame(ExecState* exec)
+        {
+            CallFrame* callFrame = m_closure.newCallFrame;
+            callFrame->setScopeChain(exec->scopeChain());
+            return callFrame;
+        }
+
         ~CachedCall()
         {
             if (m_valid)
@@ -61,7 +69,6 @@ namespace JSC {
     private:
         bool m_valid;
         Interpreter* m_interpreter;
-        JSValue* m_exception;
         DynamicGlobalObjectScope m_globalObjectScope;
         CallFrameClosure m_closure;
     };