#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)
private:
bool m_valid;
Interpreter* m_interpreter;
- JSValue* m_exception;
DynamicGlobalObjectScope m_globalObjectScope;
CallFrameClosure m_closure;
};