Commit 66bf8cbb authored by ggaren@apple.com's avatar ggaren@apple.com

JavaScriptCore:

        Reviewed by Eric Seidel.

        Second step in refactoring JSGlobalObject: moved virtual functions from
        Interpreter to JSGlobalObject.
        
        Layout and JS tests pass. SunSpider reports a .7% speedup -- don't 
        believe his lies.

JavaScriptGlue:

        Reviewed by Eric Seidel.

        Updated to match the JavaScriptCore change to move virtual methods from
        Interpreter to JSGlobalObject.
        
        * JSRun.cpp:
        * JSRun.h:
        * JSValueWrapper.cpp:
        (getThreadGlobalExecState):
        * JavaScriptGlue.cpp:
        (JSRunCopyGlobalObject):
        (JSRunEvaluate):

WebCore:

        Reviewed by Eric Seidel.

        Updated to match the JavaScriptCore change to move virtual methods from
        Interpreter to JSGlobalObject.
        
        Moved virtual ScriptInterpreter functions to Window.

WebKit/mac:

        Reviewed by Eric Seidel.

        Updated to match the JavaScriptCore change to move virtual methods from
        Interpreter to JSGlobalObject.

        * WebView/WebFrame.mm:
        (-[WebFrame globalContext]): Use the toRef function instead of manually
        casting.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28328 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6b16660d
......@@ -27,15 +27,14 @@
#include "config.h"
#include "JSContextRef.h"
#include <wtf/Platform.h>
#include "APICast.h"
#include "JSCallbackObject.h"
#include "JSClassRef.h"
#include "JSGlobalObject.h"
#include "completion.h"
#include "interpreter.h"
#include "object.h"
#include <wtf/Platform.h>
using namespace KJS;
......@@ -44,10 +43,11 @@ JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
JSLock lock;
Interpreter* interpreter = new Interpreter();
ExecState* globalExec = interpreter->globalExec();
ExecState* globalExec = &interpreter->m_globalExec;
JSGlobalContextRef ctx = toGlobalRef(globalExec);
if (globalObjectClass) {
if (globalObjectClass) {
// FIXME: ctx is not fully initialized yet, so this call to prototype() might return an object with a garbage pointer in its prototype chain.
JSObject* prototype = globalObjectClass->prototype(ctx);
JSCallbackObject<JSGlobalObject>* globalObject = new JSCallbackObject<JSGlobalObject>(globalObjectClass, prototype ? prototype : jsNull(), 0);
interpreter->setGlobalObject(globalObject);
......
2007-12-02 Geoffrey Garen <ggaren@apple.com>
Reviewed by Eric Seidel.
Second step in refactoring JSGlobalObject: moved virtual functions from
Interpreter to JSGlobalObject.
Layout and JS tests pass. SunSpider reports a .7% speedup -- don't
believe his lies.
2007-12-01 Alp Toker <alp@atoker.com>
Reviewed by Adam Roben.
......
......@@ -112,7 +112,6 @@ __ZN3KJS10Identifier3addEPKc
__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc
__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
__ZN3KJS11Interpreter10globalExecEv
__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiPKNS_5UCharEi
__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiS3_
__ZN3KJS11Interpreter15restoreBuiltinsERKNS_13SavedBuiltinsE
......@@ -122,7 +121,6 @@ __ZN3KJS11Interpreter17startTimeoutCheckEv
__ZN3KJS11Interpreter21shouldPrintExceptionsEv
__ZN3KJS11Interpreter24setShouldPrintExceptionsEb
__ZN3KJS11Interpreter27resetGlobalObjectPropertiesEv
__ZN3KJS11Interpreter4markEv
__ZN3KJS11Interpreter6s_hookE
__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE
......@@ -144,6 +142,8 @@ __ZN3KJS13ArrayInstance4infoE
__ZN3KJS13SavedBuiltinsC1Ev
__ZN3KJS13SavedBuiltinsD1Ev
__ZN3KJS13jsOwnedStringERKNS_7UStringE
__ZN3KJS14JSGlobalObject10globalExecEv
__ZN3KJS14JSGlobalObject4markEv
__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
......@@ -267,6 +267,7 @@ __ZNK3KJS7UString6is8BitEv
__ZNK3KJS7UString8toUInt32EPb
__ZNK3KJS7UString8toUInt32EPbb
__ZNK3KJS8Bindings10RootObject11interpreterEv
__ZNK3KJS8Bindings10RootObject12globalObjectEv
__ZNK3KJS8Bindings8Instance10rootObjectEv
__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
......@@ -284,6 +285,7 @@ __ZNK3KJS8JSObject9classInfoEv
__ZNK3KJS8JSObject9classNameEv
__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3KJS9ExecState18lexicalInterpreterEv
__ZTVN3KJS14JSGlobalObjectE
__ZTVN3KJS14StringInstanceE
__ZTVN3KJS15JSWrapperObjectE
__ZTVN3KJS19InternalFunctionImpE
......
......@@ -75,6 +75,7 @@ SOURCES += \
kjs/identifier.cpp \
kjs/internal.cpp \
kjs/interpreter.cpp \
kjs/JSGlobalObject.cpp \
kjs/JSImmediate.cpp \
kjs/JSLock.cpp \
kjs/lexer.cpp \
......
......@@ -314,6 +314,10 @@
RelativePath="..\..\kjs\interpreter.h"
>
</File>
<File
RelativePath="..\..\kjs\JSGlobalObject.cpp"
>
</File>
<File
RelativePath="..\..\kjs\JSImmediate.cpp"
>
......
......@@ -80,6 +80,7 @@
14BD5A310A3E91F600BAF59C /* JSContextRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BD5A2A0A3E91F600BAF59C /* JSContextRef.h */; settings = {ATTRIBUTES = (Public, ); }; };
14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */; };
14BD5A360A3E91F600BAF59C /* JavaScriptCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */; };
1CAF34890A6C421700ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34880A6C421700ABE06E /* WebScriptObject.h */; };
5186111E0CC824900081412B /* Deque.h in Headers */ = {isa = PBXBuildFile; fileRef = 5186111D0CC824830081412B /* Deque.h */; settings = {ATTRIBUTES = (Private, ); }; };
51F648D70BB4E2CA0033D760 /* RetainPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F648D60BB4E2CA0033D760 /* RetainPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
......@@ -436,6 +437,7 @@
14BD5A2D0A3E91F600BAF59C /* testapi.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testapi.c; sourceTree = "<group>"; };
14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JavaScriptCore.h; sourceTree = "<group>"; };
14D857740A4696C80032146C /* testapi.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = testapi.js; sourceTree = "<group>"; };
14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObject.cpp; sourceTree = "<group>"; };
1C9051420BA9E8A70081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = JavaScriptCore.xcconfig; sourceTree = "<group>"; };
1C9051440BA9E8A70081E9D0 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
......@@ -987,6 +989,7 @@
F692A8620255597D01FF60F7 /* internal.h */,
F692A8630255597D01FF60F7 /* interpreter.cpp */,
F692A8640255597D01FF60F7 /* interpreter.h */,
14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */,
A8E894330CD0603F00367179 /* JSGlobalObject.h */,
14760863099C633800437128 /* JSImmediate.cpp */,
1483B589099BC1950016E4F0 /* JSImmediate.h */,
......@@ -1549,6 +1552,7 @@
932F5BBA0822A1C700736975 /* runtime_object.cpp in Sources */,
932F5BC50822A1C700736975 /* runtime_root.cpp in Sources */,
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -74,6 +74,7 @@ Source files for JSCore.
kjs/identifier.cpp
kjs/internal.cpp
kjs/interpreter.cpp
kjs/JSGlobalObject.cpp
kjs/JSImmediate.cpp
kjs/JSLock.cpp
kjs/JSWrapperObject.cpp
......
......@@ -29,11 +29,12 @@
#include "NP_jsobject.h"
#include "JSGlobalObject.h"
#include "PropertyNameArray.h"
#include "c_utility.h"
#include "npruntime_impl.h"
#include "npruntime_priv.h"
#include "object.h"
#include "PropertyNameArray.h"
#include "runtime_root.h"
using namespace KJS;
......@@ -80,7 +81,7 @@ static bool _isSafeScript(JavaScriptObject* obj)
if (!obj->originRootObject->isValid() || !obj->rootObject->isValid())
return false;
return obj->originRootObject->interpreter()->isSafeScript(obj->rootObject->interpreter());
return obj->originRootObject->globalObject()->isSafeScript(obj->rootObject->globalObject());
}
NPObject* _NPN_CreateScriptObject(NPP npp, JSObject* imp, PassRefPtr<RootObject> originRootObject, PassRefPtr<RootObject> rootObject)
......@@ -116,7 +117,7 @@ bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCou
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
// Call the function object.
......@@ -166,7 +167,7 @@ bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant*
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
if (func->isNull()) {
......@@ -210,7 +211,7 @@ bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant)
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
NPUTF16* scriptString;
......@@ -251,7 +252,7 @@ bool _NPN_GetProperty(NPP, NPObject* o, NPIdentifier propertyName, NPVariant* va
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
JSLock lock;
......@@ -294,7 +295,7 @@ bool _NPN_SetProperty(NPP, NPObject* o, NPIdentifier propertyName, const NPVaria
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
if (i->isString)
......@@ -321,7 +322,7 @@ bool _NPN_RemoveProperty(NPP, NPObject* o, NPIdentifier propertyName)
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
if (i->isString) {
if (!obj->imp->hasProperty(exec, identifierFromNPIdentifier(i->value.string)))
......@@ -353,7 +354,7 @@ bool _NPN_HasProperty(NPP, NPObject* o, NPIdentifier propertyName)
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
JSLock lock;
if (i->isString)
......@@ -382,7 +383,7 @@ bool _NPN_HasMethod(NPP, NPObject* o, NPIdentifier methodName)
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
return !func->isUndefined();
......@@ -402,7 +403,7 @@ void _NPN_SetException(NPObject* o, const NPUTF8* message)
if (!rootObject || !rootObject->isValid())
return;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
throwError(exec, GeneralError, message);
}
......@@ -419,7 +420,7 @@ bool _NPN_Enumerate(NPP, NPObject *o, NPIdentifier **identifier, uint32_t *count
if (!rootObject || !rootObject->isValid())
return false;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
PropertyNameArray propertyNames;
......
......@@ -165,7 +165,7 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
return 0;
// Lookup the function object.
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
Identifier identifier(JavaString(methodName).ustring());
......@@ -221,7 +221,7 @@ jobject JavaJSObject::getMember(jstring memberName) const
if (!rootObject)
return 0;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
JSValue *result = _imp->get (exec, Identifier (JavaString(memberName).ustring()));
......@@ -237,7 +237,7 @@ void JavaJSObject::setMember(jstring memberName, jobject value) const
if (!rootObject)
return;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
_imp->put(exec, Identifier (JavaString(memberName).ustring()), convertJObjectToValue(value));
}
......@@ -251,7 +251,7 @@ void JavaJSObject::removeMember(jstring memberName) const
if (!rootObject)
return;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
_imp->deleteProperty(exec, Identifier (JavaString(memberName).ustring()));
}
......@@ -269,7 +269,7 @@ jobject JavaJSObject::getSlot(jint index) const
if (!rootObject)
return 0;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
JSValue *result = _imp->get (exec, (unsigned)index);
......@@ -290,7 +290,7 @@ void JavaJSObject::setSlot(jint index, jobject value) const
if (!rootObject)
return;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
_imp->put(exec, (unsigned)index, convertJObjectToValue(value));
}
......@@ -306,7 +306,7 @@ jstring JavaJSObject::toString() const
JSLock lock;
JSObject *thisObj = const_cast<JSObject*>(_imp);
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
return (jstring)convertValueToJValue (exec, thisObj, object_type, "java.lang.String").l;
}
......@@ -357,7 +357,7 @@ jobject JavaJSObject::convertValueToJObject (JSValue *value) const
if (!rootObject)
return 0;
ExecState* exec = rootObject->interpreter()->globalExec();
ExecState* exec = rootObject->globalObject()->globalExec();
JNIEnv *env = getJNIEnv();
jobject result = 0;
......
......@@ -286,6 +286,12 @@ Interpreter* RootObject::interpreter() const
return m_globalObject->interpreter();
}
JSGlobalObject* RootObject::globalObject() const
{
ASSERT(m_isValid);
return m_globalObject;
}
void RootObject::addRuntimeObject(RuntimeObjectImp* object)
{
ASSERT(m_isValid);
......
......@@ -68,6 +68,7 @@ public:
const void* nativeHandle() const;
Interpreter* interpreter() const;
JSGlobalObject* globalObject() const;
#if PLATFORM(MAC)
// Must be called from the thread that will be used to access JavaScript.
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JSGlobalObject.h"
#include "object_object.h"
#include "function_object.h"
#include "array_object.h"
#include "bool_object.h"
#include "string_object.h"
#include "number_object.h"
#include "date_object.h"
#include "regexp_object.h"
#include "error_object.h"
namespace KJS {
static inline void markIfNeeded(JSValue* v)
{
if (v && !v->marked())
v->mark();
}
void JSGlobalObject::mark()
{
JSObject::mark();
if (m_interpreter->m_currentExec)
m_interpreter->m_currentExec->mark();
markIfNeeded(m_interpreter->m_globalExec.exception());
markIfNeeded(m_interpreter->m_Object);
markIfNeeded(m_interpreter->m_Function);
markIfNeeded(m_interpreter->m_Array);
markIfNeeded(m_interpreter->m_Boolean);
markIfNeeded(m_interpreter->m_String);
markIfNeeded(m_interpreter->m_Number);
markIfNeeded(m_interpreter->m_Date);
markIfNeeded(m_interpreter->m_RegExp);
markIfNeeded(m_interpreter->m_Error);
markIfNeeded(m_interpreter->m_ObjectPrototype);
markIfNeeded(m_interpreter->m_FunctionPrototype);
markIfNeeded(m_interpreter->m_ArrayPrototype);
markIfNeeded(m_interpreter->m_BooleanPrototype);
markIfNeeded(m_interpreter->m_StringPrototype);
markIfNeeded(m_interpreter->m_NumberPrototype);
markIfNeeded(m_interpreter->m_DatePrototype);
markIfNeeded(m_interpreter->m_RegExpPrototype);
markIfNeeded(m_interpreter->m_ErrorPrototype);
markIfNeeded(m_interpreter->m_EvalError);
markIfNeeded(m_interpreter->m_RangeError);
markIfNeeded(m_interpreter->m_ReferenceError);
markIfNeeded(m_interpreter->m_SyntaxError);
markIfNeeded(m_interpreter->m_TypeError);
markIfNeeded(m_interpreter->m_UriError);
markIfNeeded(m_interpreter->m_EvalErrorPrototype);
markIfNeeded(m_interpreter->m_RangeErrorPrototype);
markIfNeeded(m_interpreter->m_ReferenceErrorPrototype);
markIfNeeded(m_interpreter->m_SyntaxErrorPrototype);
markIfNeeded(m_interpreter->m_TypeErrorPrototype);
markIfNeeded(m_interpreter->m_UriErrorPrototype);
}
ExecState* JSGlobalObject::globalExec()
{
return &m_interpreter->m_globalExec;
}
} // namespace KJS
......@@ -34,16 +34,18 @@ namespace KJS {
JSGlobalObject() { }
JSGlobalObject(JSValue* proto) : JSObject(proto) { }
Interpreter* interpreter() const { return m_interpreter.get(); }
void setInterpreter(std::auto_ptr<Interpreter> i) { m_interpreter = i; }
virtual void mark();
virtual bool isGlobalObject() const { return true; }
virtual void mark()
{
JSObject::mark();
m_interpreter->mark();
}
virtual ExecState* globalExec();
Interpreter* interpreter() const { return m_interpreter.get(); }
void setInterpreter(std::auto_ptr<Interpreter> i) { m_interpreter = i; }
virtual bool shouldInterruptScript() const { return true; }
virtual bool isSafeScript(const JSGlobalObject*) { return true; }
private:
std::auto_ptr<Interpreter> m_interpreter;
......
......@@ -1047,7 +1047,7 @@ void Collector::reportOutOfMemoryToAllInterpreters()
Interpreter* interpreter = Interpreter::s_hook;
do {
ExecState* exec = interpreter->currentExec() ? interpreter->currentExec() : interpreter->globalExec();
ExecState* exec = interpreter->currentExec() ? interpreter->currentExec() : interpreter->globalObject()->globalExec();
exec->setException(Error::create(exec, GeneralError, "Out of memory"));
......
......@@ -82,9 +82,9 @@ static inline InterpreterMap &interpreterMap()
}
Interpreter::Interpreter()
: m_currentExec(0)
: m_globalExec(this, 0, 0, 0)
, m_currentExec(0)
, m_globalObject(0)
, m_globalExec(this, 0, 0, 0)
{
init();
}
......@@ -308,11 +308,6 @@ void Interpreter::setGlobalObjectProperties()
#endif
}
ExecState* Interpreter::globalExec()
{
return &m_globalExec;
}
Completion Interpreter::checkSyntax(const UString& sourceURL, int startingLineNumber, const UString& code)
{
return checkSyntax(sourceURL, startingLineNumber, code.data(), code.size());
......@@ -385,7 +380,7 @@ Completion Interpreter::evaluate(const UString& sourceURL, int startingLineNumbe
if (shouldPrintExceptions() && res.complType() == Throw) {
JSLock lock;
ExecState* exec = globalExec();
ExecState* exec = m_globalObject->globalExec();
CString f = sourceURL.UTF8String();
CString message = res.value()->toObject(exec)->toString(exec).UTF8String();
int line = res.value()->toObject(exec)->get(exec, "line")->toUInt32(exec);
......@@ -544,79 +539,6 @@ JSObject *Interpreter::builtinURIErrorPrototype() const
return m_UriErrorPrototype;
}
void Interpreter::mark()
{
if (m_currentExec)
m_currentExec->mark();
if (m_globalExec.exception() && !m_globalExec.exception()->marked())
m_globalExec.exception()->mark();
if (m_Object && !m_Object->marked())
m_Object->mark();
if (m_Function && !m_Function->marked())
m_Function->mark();
if (m_Array && !m_Array->marked())
m_Array->mark();
if (m_Boolean && !m_Boolean->marked())
m_Boolean->mark();
if (m_String && !m_String->marked())
m_String->mark();
if (m_Number && !m_Number->marked())
m_Number->mark();
if (m_Date && !m_Date->marked())
m_Date->mark();
if (m_RegExp && !m_RegExp->marked())
m_RegExp->mark();
if (m_Error && !m_Error->marked())
m_Error->mark();
if (m_ObjectPrototype && !m_ObjectPrototype->marked())
m_ObjectPrototype->mark();
if (m_FunctionPrototype && !m_FunctionPrototype->marked())
m_FunctionPrototype->mark();
if (m_ArrayPrototype && !m_ArrayPrototype->marked())
m_ArrayPrototype->mark();
if (m_BooleanPrototype && !m_BooleanPrototype->marked())
m_BooleanPrototype->mark();
if (m_StringPrototype && !m_StringPrototype->marked())
m_StringPrototype->mark();
if (m_NumberPrototype && !m_NumberPrototype->marked())
m_NumberPrototype->mark();
if (m_DatePrototype && !m_DatePrototype->marked())
m_DatePrototype->mark();
if (m_RegExpPrototype && !m_RegExpPrototype->marked())
m_RegExpPrototype->mark();
if (m_ErrorPrototype && !m_ErrorPrototype->marked())
m_ErrorPrototype->mark();
if (m_EvalError && !m_EvalError->marked())
m_EvalError->mark();
if (m_RangeError && !m_RangeError->marked())
m_RangeError->mark();
if (m_ReferenceError && !m_ReferenceError->marked())
m_ReferenceError->mark();
if (m_SyntaxError && !m_SyntaxError->marked())
m_SyntaxError->mark();
if (m_TypeError && !m_TypeError->marked())
m_TypeError->mark();
if (m_UriError && !m_UriError->marked())
m_UriError->mark();
if (m_EvalErrorPrototype && !m_EvalErrorPrototype->marked())
m_EvalErrorPrototype->mark();
if (m_RangeErrorPrototype && !m_RangeErrorPrototype->marked())
m_RangeErrorPrototype->mark();
if (m_ReferenceErrorPrototype && !m_ReferenceErrorPrototype->marked())
m_ReferenceErrorPrototype->mark();
if (m_SyntaxErrorPrototype && !m_SyntaxErrorPrototype->marked())
m_SyntaxErrorPrototype->mark();
if (m_TypeErrorPrototype && !m_TypeErrorPrototype->marked())
m_TypeErrorPrototype->mark();
if (m_UriErrorPrototype && !m_UriErrorPrototype->marked())
m_UriErrorPrototype->mark();
}
static bool printExceptions = false;
bool Interpreter::shouldPrintExceptions()
......@@ -778,7 +700,7 @@ bool Interpreter::checkTimeout()
m_ticksUntilNextTimeoutCheck = initialTickCountThreshold;
if (m_timeoutTime && m_timeExecuting > m_timeoutTime) {
if (shouldInterruptScript())
if (m_globalObject->shouldInterruptScript())
return true;
resetTimeoutCheck();
......
......@@ -78,14 +78,15 @@ namespace KJS {
*/
class Interpreter {
friend class Collector;
friend class JSGlobalObject;
public: