#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;
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.
__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc
__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
-__ZN3KJS11Interpreter10globalExecEv
__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiPKNS_5UCharEi
__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiS3_
__ZN3KJS11Interpreter15restoreBuiltinsERKNS_13SavedBuiltinsE
__ZN3KJS11Interpreter21shouldPrintExceptionsEv
__ZN3KJS11Interpreter24setShouldPrintExceptionsEb
__ZN3KJS11Interpreter27resetGlobalObjectPropertiesEv
-__ZN3KJS11Interpreter4markEv
__ZN3KJS11Interpreter6s_hookE
__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE
__ZN3KJS13SavedBuiltinsC1Ev
__ZN3KJS13SavedBuiltinsD1Ev
__ZN3KJS13jsOwnedStringERKNS_7UStringE
+__ZN3KJS14JSGlobalObject10globalExecEv
+__ZN3KJS14JSGlobalObject4markEv
__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZNK3KJS7UString8toUInt32EPb
__ZNK3KJS7UString8toUInt32EPbb
__ZNK3KJS8Bindings10RootObject11interpreterEv
+__ZNK3KJS8Bindings10RootObject12globalObjectEv
__ZNK3KJS8Bindings8Instance10rootObjectEv
__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZNK3KJS8JSObject12defaultValueEPNS_9ExecStateENS_6JSTypeE
__ZNK3KJS8JSObject9classNameEv
__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3KJS9ExecState18lexicalInterpreterEv
+__ZTVN3KJS14JSGlobalObjectE
__ZTVN3KJS14StringInstanceE
__ZTVN3KJS15JSWrapperObjectE
__ZTVN3KJS19InternalFunctionImpE
kjs/identifier.cpp \
kjs/internal.cpp \
kjs/interpreter.cpp \
+ kjs/JSGlobalObject.cpp \
kjs/JSImmediate.cpp \
kjs/JSLock.cpp \
kjs/lexer.cpp \
>\r
</File>\r
<File\r
+ RelativePath="..\..\kjs\JSGlobalObject.cpp"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath="..\..\kjs\JSImmediate.cpp"\r
>\r
</File>\r
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, ); }; };
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>"; };
F692A8620255597D01FF60F7 /* internal.h */,
F692A8630255597D01FF60F7 /* interpreter.cpp */,
F692A8640255597D01FF60F7 /* interpreter.h */,
+ 14DE0D680D02431400AACCA2 /* JSGlobalObject.cpp */,
A8E894330CD0603F00367179 /* JSGlobalObject.h */,
14760863099C633800437128 /* JSImmediate.cpp */,
1483B589099BC1950016E4F0 /* JSImmediate.h */,
932F5BBA0822A1C700736975 /* runtime_object.cpp in Sources */,
932F5BC50822A1C700736975 /* runtime_root.cpp in Sources */,
E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */,
+ 14DE0D690D02431400AACCA2 /* JSGlobalObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
kjs/identifier.cpp
kjs/internal.cpp
kjs/interpreter.cpp
+ kjs/JSGlobalObject.cpp
kjs/JSImmediate.cpp
kjs/JSLock.cpp
kjs/JSWrapperObject.cpp
#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;
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)
if (!rootObject || !rootObject->isValid())
return false;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
// Call the function object.
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()) {
if (!rootObject || !rootObject->isValid())
return false;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
NPUTF16* scriptString;
if (!rootObject || !rootObject->isValid())
return false;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
PrivateIdentifier* i = (PrivateIdentifier*)propertyName;
JSLock lock;
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)
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)))
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)
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();
if (!rootObject || !rootObject->isValid())
return;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
throwError(exec, GeneralError, message);
}
if (!rootObject || !rootObject->isValid())
return false;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
PropertyNameArray propertyNames;
return 0;
// Lookup the function object.
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
Identifier identifier(JavaString(methodName).ustring());
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()));
if (!rootObject)
return;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
_imp->put(exec, Identifier (JavaString(memberName).ustring()), convertJObjectToValue(value));
}
if (!rootObject)
return;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
_imp->deleteProperty(exec, Identifier (JavaString(memberName).ustring()));
}
if (!rootObject)
return 0;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
JSValue *result = _imp->get (exec, (unsigned)index);
if (!rootObject)
return;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
_imp->put(exec, (unsigned)index, convertJObjectToValue(value));
}
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;
}
if (!rootObject)
return 0;
- ExecState* exec = rootObject->interpreter()->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JNIEnv *env = getJNIEnv();
jobject result = 0;
return m_globalObject->interpreter();
}
+JSGlobalObject* RootObject::globalObject() const
+{
+ ASSERT(m_isValid);
+ return m_globalObject;
+}
+
void RootObject::addRuntimeObject(RuntimeObjectImp* object)
{
ASSERT(m_isValid);
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.
--- /dev/null
+/*
+ * 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
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;
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"));
}
Interpreter::Interpreter()
- : m_currentExec(0)
+ : m_globalExec(this, 0, 0, 0)
+ , m_currentExec(0)
, m_globalObject(0)
- , m_globalExec(this, 0, 0, 0)
{
init();
}
#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());
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);
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()
m_ticksUntilNextTimeoutCheck = initialTickCountThreshold;
if (m_timeoutTime && m_timeExecuting > m_timeoutTime) {
- if (shouldInterruptScript())
+ if (m_globalObject->shouldInterruptScript())
return true;
resetTimeoutCheck();
*/
class Interpreter {
friend class Collector;
+ friend class JSGlobalObject;
+
public:
/**
* Creates a new interpreter. The global object must be set via setGlobalObject
* before code is executed with this interpreter.
*/
Interpreter();
-
- virtual ~Interpreter(); // only deref should delete us
+ ~Interpreter();
/**
* Set the interpreter's global object. The supplied object will be used as the global
JSGlobalObject* globalObject() const;
/**
- * Returns the execution state object which can be used to execute
- * scripts using this interpreter at a the "global" level, i.e. one
- * with a execution context that has the global object as the "this"
- * value, and who's scope chain contains only the global object.
- *
- * Note: this pointer remains constant for the life of the interpreter
- * and should not be manually deleted.
- *
- * @return The interpreter global execution state object
- */
- virtual ExecState *globalExec();
-
- /**
* Parses the supplied ECMAScript code and checks for syntax errors.
*
* @param code The code to check
void setCompatMode(CompatMode mode) { m_compatMode = mode; }
CompatMode compatMode() const { return m_compatMode; }
- /**
- * Run the garbage collection. Returns true when at least one object
- * was collected; false otherwise.
- */
- static bool collect();
-
- /**
- * Called during the mark phase of the garbage collector. Subclasses
- * implementing custom mark methods must make sure to chain to this one.
- */
- virtual void mark();
-
static bool shouldPrintExceptions();
static void setShouldPrintExceptions(bool);
void saveBuiltins (SavedBuiltins&) const;
void restoreBuiltins (const SavedBuiltins&);
- /**
- * Determine if the it is 'safe' to execute code in the target interpreter from an
- * object that originated in this interpreter. This check is used to enforce WebCore
- * cross frame security rules. In particular, attempts to access 'bound' objects are
- * not allowed unless isSafeScript returns true.
- */
- virtual bool isSafeScript(const Interpreter*) { return true; }
-
// Chained list of interpreters (ring)
static Interpreter* firstInterpreter() { return s_hook; }
Interpreter* nextInterpreter() const { return next; }
bool timedOut();
-protected:
- virtual bool shouldInterruptScript() const { return true; }
+ ExecState m_globalExec; // This is temporarily public to help with bootstrapping.
+protected:
unsigned m_timeoutTime;
private:
ExecState* m_currentExec;
JSGlobalObject* m_globalObject;
- ExecState m_globalExec;
// Chained list of interpreters (ring) - for collector
static Interpreter* s_hook;
interp->setGlobalObject(global); // global now owns interp.
// add debug() function
- global->put(interp->globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1));
+ global->put(global->globalExec(), "debug", new TestFunctionImp(TestFunctionImp::Debug, 1));
// add "print" for compatibility with the mozilla js shell
- global->put(interp->globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1));
+ global->put(global->globalExec(), "print", new TestFunctionImp(TestFunctionImp::Print, 1));
// add "quit" for compatibility with the mozilla js shell
- global->put(interp->globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0));
+ global->put(global->globalExec(), "quit", new TestFunctionImp(TestFunctionImp::Quit, 0));
// add "gc" for compatibility with the mozilla js shell
- global->put(interp->globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0));
+ global->put(global->globalExec(), "gc", new TestFunctionImp(TestFunctionImp::GC, 0));
// add "version" for compatibility with the mozilla js shell
- global->put(interp->globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1));
- global->put(interp->globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1));
- global->put(interp->globalExec(), "load", new TestFunctionImp(TestFunctionImp::Load, 1));
+ global->put(global->globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1));
+ global->put(global->globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1));
+ global->put(global->globalExec(), "load", new TestFunctionImp(TestFunctionImp::Load, 1));
Interpreter::setShouldPrintExceptions(true);
return global;
+2007-12-02 Geoffrey Garen <ggaren@apple.com>
+
+ 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):
+
2007-11-30 Geoffrey Garen <ggaren@apple.com>
Reviewed by Beth Dakin.
return fGlobalObject;
}
-JSInterpreter* JSRun::GetInterpreter()
-{
- return static_cast<JSInterpreter*>(fGlobalObject->interpreter());
-}
-
Completion JSRun::Evaluate()
{
return fGlobalObject->interpreter()->evaluate(UString(), 0, fSource.data(), fSource.size());
JSInterpreter() : fJSFlags(kJSFlagNone) { }
JSFlags Flags() const { return fJSFlags; }
- protected:
- virtual ~JSInterpreter() { } // only deref on the base class should delete us
-
private:
JSFlags fJSFlags;
};
UString GetSource() const;
JSGlobalObject* GlobalObject() const;
- JSInterpreter* GetInterpreter();
Completion Evaluate();
bool CheckSyntax();
JSFlags Flags() const;
pthread_setspecific(globalObjectKey, globalObject);
}
- ExecState* exec = globalObject->interpreter()->globalExec();
+ ExecState* exec = globalObject->globalExec();
// Discard exceptions -- otherwise an exception would forestall JS
// evaluation throughout the thread
JSRun* ptr = (JSRun*)ref;
if (ptr)
{
- JSObject *globalObject = ptr->GlobalObject();
- result = (JSObjectRef)KJSValueToJSObject(globalObject, ptr->GetInterpreter()->globalExec());
+ JSGlobalObject* globalObject = ptr->GlobalObject();
+ result = (JSObjectRef)KJSValueToJSObject(globalObject, globalObject->globalExec());
}
return result;
}
Completion completion = ptr->Evaluate();
if (completion.isValueCompletion())
{
- result = (JSObjectRef)KJSValueToJSObject(completion.value(), ptr->GetInterpreter()->globalExec());
+ result = (JSObjectRef)KJSValueToJSObject(completion.value(), ptr->GlobalObject()->globalExec());
}
if (completion.complType() == Throw)
+2007-12-02 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Eric Seidel.
+
+ Updated to match the JavaScriptCore change to move virtual methods from
+ Interpreter to JSGlobalObject.
+
+ Moved virtual ScriptInterpreter functions to Window.
+
2007-12-02 Darin Adler <darin@apple.com>
Reviewed by Mitz.
1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; };
1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1403B99609EB13AF00797C7F /* DOMWindow.cpp */; };
1403BA0C09EB18C700797C7F /* JSDOMWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1403BA0B09EB18C700797C7F /* JSDOMWindow.cpp */; };
- 1403BA0F09EB18F900797C7F /* JSDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403BA0E09EB18F800797C7F /* JSDOMWindow.h */; };
+ 1403BA0F09EB18F900797C7F /* JSDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403BA0E09EB18F800797C7F /* JSDOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
14115B5209F84B7100CA4FC1 /* Node.h in Headers */ = {isa = PBXBuildFile; fileRef = 14115B5109F84B7100CA4FC1 /* Node.h */; settings = {ATTRIBUTES = (Private, ); }; };
14115B7209F84CD600CA4FC1 /* JSNodeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14115B7009F84CD600CA4FC1 /* JSNodeFilter.cpp */; };
14115B7309F84CD600CA4FC1 /* JSNodeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 14115B7109F84CD600CA4FC1 /* JSNodeFilter.h */; };
93B70D6F09EB0C7C009D8468 /* kjs_proxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D5309EB0C7C009D8468 /* kjs_proxy.cpp */; };
93B70D7009EB0C7C009D8468 /* kjs_proxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5409EB0C7C009D8468 /* kjs_proxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B70D7509EB0C7C009D8468 /* kjs_window.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93B70D5909EB0C7C009D8468 /* kjs_window.cpp */; };
- 93B70D7609EB0C7C009D8468 /* kjs_window.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5A09EB0C7C009D8468 /* kjs_window.h */; };
+ 93B70D7609EB0C7C009D8468 /* kjs_window.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B70D5A09EB0C7C009D8468 /* kjs_window.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B77A380ADD792500EA4B81 /* FrameLoaderTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B77A370ADD792500EA4B81 /* FrameLoaderTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B780CA09B3B7FE00690162 /* WidgetClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B780C909B3B7FE00690162 /* WidgetClient.h */; };
93C09A530B064DB3005ABD4D /* EventHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C09A520B064DB3005ABD4D /* EventHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
return;
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
+ ExecState* exec = proxy->globalObject()->globalExec();
KJS::JSLock lock;
if (!proxy)
return true;
+ ExecState* exec = proxy->globalObject()->globalExec();
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
KJS::JSLock lock;
if (!proxy)
return;
+ ExecState* exec = proxy->globalObject()->globalExec();
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
KJS::JSLock lock;
if (!proxy)
return true;
+ ExecState* exec = proxy->globalObject()->globalExec();
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
KJS::JSLock lock;
if (!proxy)
return;
+ ExecState* exec = proxy->globalObject()->globalExec();
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
KJS::JSLock lock;
JSLock lock;
+ ExecState* exec = proxy->globalObject()->globalExec();
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
JSValue* lookupNamespaceURIFuncValue = m_customResolver->get(exec, "lookupNamespaceURI");
JSObject* lookupNamespaceURIFunc = 0;
KJSProxy* proxy = frame->scriptProxy();
if (proxy && m_filter->implementsCall()) {
KJS::JSLock lock;
- KJS::ExecState* exec = proxy->interpreter()->globalExec();
+ KJS::ExecState* exec = proxy->globalObject()->globalExec();
KJS::List args;
args.append(toJS(exec, node));
KJS::JSObject* obj = m_filter;
}
}
-ExecState* ScriptInterpreter::globalExec()
-{
- // we need to make sure that any script execution happening in this
- // frame does not destroy it
- m_frame->keepAlive();
- return Interpreter::globalExec();
-}
-
void ScriptInterpreter::updateDOMNodeDocument(Node* node, Document* oldDoc, Document* newDoc)
{
ASSERT(oldDoc != newDoc);
return false;
}
-bool ScriptInterpreter::isGlobalObject(JSValue* v)
-{
- return v->isObject(&Window::info);
-}
-
-bool ScriptInterpreter::isSafeScript(const Interpreter* target)
-{
- return Window::isSafeScript(this, static_cast<const ScriptInterpreter*>(target));
-}
-
-bool ScriptInterpreter::shouldInterruptScript() const
-{
- Page* page = m_frame->page();
-
- // See <rdar://problem/5479443>. We don't think that page can ever be NULL
- // in this case, but if it is, we've gotten into a state where we may have
- // hung the UI, with no way to ask the client whether to cancel execution.
- // For now, our solution is just to cancel execution no matter what,
- // ensuring that we never hang. We might want to consider other solutions
- // if we discover problems with this one.
- ASSERT(page);
- if (!page)
- return true;
-
- return page->chrome()->shouldInterruptJavaScript();
-}
-
JSValue* jsStringOrNull(const String& s)
{
if (s.isNull())
*/
bool wasRunByUserGesture() const;
- virtual ExecState* globalExec();
-
WebCore::Event* getCurrentEvent() const { return m_currentEvent; }
- virtual bool isGlobalObject(JSValue*);
- virtual bool isSafeScript(const Interpreter* target);
-
- virtual bool shouldInterruptScript() const;
-
private:
- virtual ~ScriptInterpreter() { } // only deref on the base class should delete us
WebCore::Frame* m_frame;
WebCore::Event* m_currentEvent;
JSLock lock;
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
+ ExecState* exec = proxy->globalObject()->globalExec();
JSValue* handleEventFuncValue = listener->get(exec, "handleEvent");
JSObject* handleEventFunc = 0;
if (proxy) {
ScriptInterpreter* interpreter = proxy->interpreter();
- ExecState* exec = interpreter->globalExec();
+ ExecState* exec = proxy->globalObject()->globalExec();
JSLock lock;
JSObject* constr = interpreter->builtinFunction();
if (!frame)
return false;
KJSProxy* proxy = frame->scriptProxy();
- ExecState* exec = proxy->interpreter()->globalExec();
+ ExecState* exec = proxy->globalObject()->globalExec();
if (JSValue* runtimeObject = getRuntimeObject(exec, thisImp))
return static_cast<JSObject*>(runtimeObject)->implementsCall();
bool inlineCode = filename.isNull();
ScriptInterpreter* interpreter = static_cast<ScriptInterpreter*>(m_globalObject->interpreter());
- ExecState* exec = interpreter->globalExec();
+ ExecState* exec = m_globalObject->globalExec();
interpreter->setInlineCode(inlineCode);
// so we start the keep alive timer here.
m_frame->keepAlive();
- JSValue* thisNode = KJS::Window::retrieve(m_frame);
+ JSValue* thisNode = Window::retrieve(m_frame);
interpreter->startTimeoutCheck();
Completion comp = interpreter->evaluate(filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode);
void KJSProxy::clear() {
// clear resources allocated by the interpreter, and make it ready to be used by another page
- // We have to keep it, so that the KJS::Window object for the frame remains the same.
+ // We have to keep it, so that the Window object for the frame remains the same.
// (we used to delete and re-create it, previously)
if (m_globalObject)
m_globalObject->clear();
{
initScriptIfNeeded();
JSLock lock;
- return new JSLazyEventListener(functionName, code, KJS::Window::retrieveWindow(m_frame), node, m_handlerLineno);
+ return new JSLazyEventListener(functionName, code, Window::retrieveWindow(m_frame), node, m_handlerLineno);
}
#if ENABLE(SVG)
{
initScriptIfNeeded();
JSLock lock;
- return new JSSVGLazyEventListener(functionName, code, KJS::Window::retrieveWindow(m_frame), node, m_handlerLineno);
+ return new JSSVGLazyEventListener(functionName, code, Window::retrieveWindow(m_frame), node, m_handlerLineno);
}
#endif
ScriptInterpreter* KJSProxy::interpreter()
{
- initScriptIfNeeded();
- ASSERT(m_globalObject);
- return static_cast<ScriptInterpreter*>(m_globalObject->interpreter());
+ initScriptIfNeeded();
+ return static_cast<ScriptInterpreter*>(m_globalObject->interpreter());
}
-void KJSProxy::initScriptIfNeeded()
+void KJSProxy::initScript()
{
if (m_globalObject)
return;
#ifndef kjs_proxy_h
#define kjs_proxy_h
+#include "JSDOMWindow.h"
#include <kjs/protect.h>
#include <wtf/RefPtr.h>
namespace KJS {
+ class JSGlobalObject;
class JSValue;
class ScriptInterpreter;
}
class Event;
class EventListener;
class Frame;
-class JSDOMWindow;
class Node;
class String;
KJSProxy(Frame*);
~KJSProxy();
+ bool haveInterpreter() const { return m_globalObject; }
+ KJS::ScriptInterpreter* interpreter();
+ KJS::JSGlobalObject* globalObject()
+ {
+ initScriptIfNeeded();
+ return m_globalObject;
+ }
+
KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code);
void clear();
EventListener* createHTMLEventHandler(const String& functionName, const String& code, Node*);
EventListener* createSVGEventHandler(const String& functionName, const String& code, Node*);
#endif
void finishedWithEvent(Event*);
- KJS::ScriptInterpreter *interpreter();
void setEventHandlerLineno(int lineno) { m_handlerLineno = lineno; }
- void initScriptIfNeeded();
-
- bool haveInterpreter() const { return m_globalObject; }
-
void clearDocumentWrapper();
private:
+ void initScriptIfNeeded()
+ {
+ if (!m_globalObject)
+ initScript();
+ }
+ void initScript();
+
KJS::ProtectedPtr<JSDOMWindow> m_globalObject;
Frame* m_frame;
int m_handlerLineno;
{
ASSERT(p);
if (KJSProxy *proxy = p->scriptProxy())
- return proxy->interpreter()->globalObject(); // the Global object is the "window"
+ return proxy->globalObject(); // the Global object is the "window"
return jsUndefined(); // This can happen with JS disabled on the domain of that window
}
return false;
}
+ExecState* Window::globalExec()
+{
+ // we need to make sure that any script execution happening in this
+ // frame does not destroy it
+ ASSERT(impl()->frame());
+ impl()->frame()->keepAlive();
+ return JSGlobalObject::globalExec();
+}
+
+bool Window::shouldInterruptScript() const
+{
+ ASSERT(impl()->frame());
+ Page* page = impl()->frame()->page();
+
+ // See <rdar://problem/5479443>. We don't think that page can ever be NULL
+ // in this case, but if it is, we've gotten into a state where we may have
+ // hung the UI, with no way to ask the client whether to cancel execution.
+ // For now, our solution is just to cancel execution no matter what,
+ // ensuring that we never hang. We might want to consider other solutions
+ // if we discover problems with this one.
+ ASSERT(page);
+ if (!page)
+ return true;
+
+ return page->chrome()->shouldInterruptJavaScript();
+}
+
bool Window::isSafeScript(ExecState *exec) const
{
Frame* frame = impl()->frame();
if (JSValue* func = m_func.get()) {
JSLock lock;
if (func->isObject() && static_cast<JSObject*>(func)->implementsCall()) {
- ExecState* exec = interpreter->globalExec();
+ ExecState* exec = window->globalExec();
ASSERT(window == interpreter->globalObject());
List args;
protected:
Window(WebCore::DOMWindow*);
public:
- ~Window();
+ virtual ~Window();
WebCore::DOMWindow* impl() const { return m_impl.get(); }
void disconnectFrame();
/**
void timerFired(DOMWindowTimer*);
- bool isSafeScript(ExecState*) const;
static bool isSafeScript(const ScriptInterpreter *origin, const ScriptInterpreter *target);
Location* location() const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
+
+ virtual ExecState* globalExec();
+ virtual bool shouldInterruptScript() const;
+ virtual bool isSafeScript(ExecState*) const;
enum {
// Attributes
if (!frame)
return;
- KJS::Interpreter *interpreter = frame->scriptProxy()->interpreter();
- KJS::ExecState *exec = interpreter->globalExec();
+ KJS::ExecState *exec = frame->scriptProxy()->globalObject()->globalExec();
// Get (or create) a cached JS object for the DOM node.
KJS::JSObject *scriptImp = static_cast<KJS::JSObject*>(WebCore::toJS(exec, nodeImpl));
if (!root)
return;
- ExecState* exec = root->interpreter()->globalExec();
+ ExecState* exec = root->globalObject()->globalExec();
KJSDidExecuteFunctionPtr func = Instance::didExecuteFunction();
if (func)
- func(exec, root->interpreter()->globalObject());
+ func(exec, root->globalObject());
}
- (void)_setImp:(JSObject*)imp originRootObject:(PassRefPtr<RootObject>)originRootObject rootObject:(PassRefPtr<RootObject>)rootObject
if (!_private->originRootObject->isValid())
return false;
- return _private->originRootObject->interpreter()->isSafeScript(root->interpreter());
+ return _private->originRootObject->globalObject()->isSafeScript(root->globalObject());
}
- (void)dealloc
return nil;
// Look up the function object.
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSLock lock;
if (![self _isSafeScript])
return nil;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSValue *result;
if (![self _isSafeScript])
return;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSLock lock;
if (![self _isSafeScript])
return nil;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSLock lock;
if (![self _isSafeScript])
return;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSLock lock;
return @"Undefined";
JSLock lock;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
id result = convertValueToObjcValue(exec, [self _imp], ObjcObjectType).objectValue;
if (![self _isSafeScript])
return nil;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSLock lock;
if (![self _isSafeScript])
return;
- ExecState* exec = [self _rootObject]->interpreter()->globalExec();
+ ExecState* exec = [self _rootObject]->globalObject()->globalExec();
ASSERT(!exec->hadException());
JSLock lock;
if (ExecState* exec = [self _rootObject]->interpreter()->currentExec()) {
throwError(exec, GeneralError, description);
} else
- throwError([self _rootObject]->interpreter()->globalExec(), GeneralError, description);
+ throwError([self _rootObject]->globalObject()->globalExec(), GeneralError, description);
}
- (JSObjectRef)JSObject
{
if (value->isObject()) {
JSObject* object = static_cast<JSObject*>(value);
- Interpreter* interpreter = rootObject->interpreter();
- ExecState *exec = interpreter->globalExec();
+ ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock;
if (object->classInfo() != &RuntimeObjectImp::info) {
// constructor
WebCoreScriptDebuggerImp(WebCoreScriptDebugger *objc, Interpreter *interp) : _objc(objc) {
_nested = true;
- _current = [_objc _enterFrame:interp->globalExec()];
+ _current = [_objc _enterFrame:interp->globalObject()->globalExec()];
attach(interp);
[[_objc delegate] enteredFrame:_current sourceId:-1 line:-1];
_nested = false;
eval = static_cast<JSObject *>(v);
else
// no "eval" - fallback operates on global exec state
- state = interp->globalExec();
+ state = interp->globalObject()->globalExec();
}
JSValue *savedException = state->exception();
// Create a JSObject bound to this element
JSLock lock;
- ExecState *exec = frame->scriptProxy()->interpreter()->globalExec();
+ ExecState *exec = frame->scriptProxy()->globalObject()->globalExec();
JSValue* jsElementValue = toJS(exec, this);
if (!jsElementValue || !jsElementValue->isObject())
return _NPN_CreateNoScriptObject();
#endif
if (d->m_jscript && d->m_jscript->haveInterpreter())
- static_cast<KJS::Window*>(d->m_jscript->interpreter()->globalObject())->disconnectFrame();
+ static_cast<KJS::Window*>(d->m_jscript->globalObject())->disconnectFrame();
disconnectOwnerElement();
if (!d->m_bindingRootObject) {
JSLock lock;
- d->m_bindingRootObject = KJS::Bindings::RootObject::create(0, scriptProxy()->interpreter()->globalObject());
+ d->m_bindingRootObject = KJS::Bindings::RootObject::create(0, scriptProxy()->globalObject());
}
return d->m_bindingRootObject.get();
}
if (!m_page || !enabled())
return;
- m_scriptContext = toRef(m_page->mainFrame()->scriptProxy()->interpreter()->globalExec());
+ m_scriptContext = toRef(m_page->mainFrame()->scriptProxy()->globalObject()->globalExec());
JSObjectRef global = JSContextGetGlobalObject(m_scriptContext);
ASSERT(global);
return 0;
Frame* frame = [bridge _frame];
- return frame->createRootObject(nativeHandle, frame->scriptProxy()->interpreter()->globalObject());
+ return frame->createRootObject(nativeHandle, frame->scriptProxy()->globalObject());
}
static pthread_t mainThread = 0;
return @"";
JSLock lock;
- return String(result->toString(m_frame->scriptProxy()->interpreter()->globalExec()));
+ return String(result->toString(m_frame->scriptProxy()->globalObject()->globalExec()));
}
- (NSAppleEventDescriptor *)aeDescByEvaluatingJavaScriptFromString:(NSString *)string
if (!result) // FIXME: pass errors
return 0;
JSLock lock;
- return aeDescFromJSValue(m_frame->scriptProxy()->interpreter()->globalExec(), result);
+ return aeDescFromJSValue(m_frame->scriptProxy()->globalObject()->globalExec(), result);
}
- (NSRect)caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity
+2007-12-02 Geoffrey Garen <ggaren@apple.com>
+
+ 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.
+
2007-12-01 Brady Eidson <beidson@apple.com>
Reviewed by Tim
#import <WebKit/DOMHTMLElement.h>
#import <WebKit/DOMNode.h>
#import <WebKit/DOMRange.h>
+#import <JavaScriptCore/APICast.h>
using namespace WebCore;
Frame* coreFrame = core(self);
if (!coreFrame)
return 0;
- return reinterpret_cast<JSGlobalContextRef>(coreFrame->scriptProxy()->interpreter()->globalExec());
+ return toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec());
}
@end