Commit 1b4d90ba authored by ggaren@apple.com's avatar ggaren@apple.com

JavaScriptCore:

        Reviewed by Darin Adler.

        Third step in refactoring JSGlobalObject: Moved data members and 
        functions accessing data members from Interpreter to JSGlobalObject.
        Changed Interpreter member functions to static functions.
        
        This resolves a bug in global object bootstrapping, where the global
        ExecState could be used when uninitialized.
        
        This is a big change, but it's mostly code motion and renaming.
        
        Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports
        a .7% regression, but Shark sees no difference related to this patch,
        and SunSpider reported a .7% speedup from an earlier step in this 
        refactoring, so I think it's fair to call that a wash.

JavaScriptGlue:

        Reviewed by Darin Adler.

        Third step in refactoring JSGlobalObject: Moved data members and data
        member access from Interpreter to JSGlobalObject. Replaced JSInterpreter
        subclass with JSGlobalObject subclass.
        
        * JSRun.cpp:
        (JSRun::JSRun):
        (JSRun::Evaluate):
        (JSRun::CheckSyntax):
        * JSRun.h:
        (JSGlueGlobalObject::JSGlueGlobalObject):
        * JSUtils.cpp:
        (KJSValueToCFTypeInternal):
        * JSValueWrapper.cpp:
        (getThreadGlobalExecState):

WebCore:

        Reviewed by Darin Adler.

        Third step in refactoring JSGlobalObject: Moved data members and data
        member access from Interpreter to JSGlobalObject. Changed Interpreter
        member functions to static functions. Same for the subclass, 
        ScriptInterpreter.
        
        This is a big change, but it's mostly code motion and renaming.

WebKit/mac:

        Reviewed by Darin Adler.

        Third step in refactoring JSGlobalObject: Moved data members and data
        member access from Interpreter to JSGlobalObject.
        
        * WebView/WebFrame.mm:
        (-[WebFrame _attachScriptDebugger]):

WebKit/win:

        Reviewed by Darin Adler.

        Third step in refactoring JSGlobalObject: Moved data members and data
        member access from Interpreter to JSGlobalObject.
        
        * WebFrame.cpp:
        (WebFrame::globalContext):
        (WebFrame::attachScriptDebugger):
        (WebFrame::windowObjectCleared):
        * WebScriptDebugger.cpp:
        (WebScriptDebugger::WebScriptDebugger):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 27856e87
......@@ -25,15 +25,13 @@
*/
#include "config.h"
#include <wtf/Platform.h>
#include "JSBase.h"
#include "APICast.h"
#include <kjs/ExecState.h>
#include <kjs/interpreter.h>
#include <kjs/JSGlobalObject.h>
#include <kjs/JSLock.h>
#include <kjs/interpreter.h>
#include <kjs/object.h>
using namespace KJS;
......@@ -46,7 +44,7 @@ JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef th
UString::Rep* scriptRep = toJS(script);
UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null;
// Interpreter::evaluate sets "this" to the global object if it is NULL
Completion completion = exec->dynamicInterpreter()->evaluate(UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisObject);
Completion completion = Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisObject);
if (completion.complType() == Throw) {
if (exception)
......@@ -68,7 +66,7 @@ bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourc
ExecState* exec = toJS(ctx);
UString::Rep* scriptRep = toJS(script);
UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null;
Completion completion = exec->dynamicInterpreter()->checkSyntax(UString(sourceURLRep), startingLineNumber, UString(scriptRep));
Completion completion = Interpreter::checkSyntax(exec->dynamicGlobalObject()->globalExec(), UString(sourceURLRep), startingLineNumber, UString(scriptRep));
if (completion.complType() == Throw) {
if (exception)
*exception = toRef(completion.value());
......
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006, 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
......@@ -25,11 +25,11 @@
*/
#include "config.h"
#include <wtf/Platform.h>
#include "JSCallbackConstructor.h"
#include "APICast.h"
#include <kjs/JSGlobalObject.h>
#include <kjs/object_object.h>
#include <wtf/Vector.h>
namespace KJS {
......@@ -37,7 +37,7 @@ namespace KJS {
const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0};
JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
: JSObject(exec->lexicalInterpreter()->builtinObjectPrototype())
: JSObject(exec->lexicalGlobalObject()->objectPrototype())
, m_class(jsClass)
, m_callback(callback)
{
......
......@@ -31,6 +31,7 @@
#include "APICast.h"
#include "function.h"
#include "function_object.h"
#include <kjs/JSGlobalObject.h>
#include <wtf/Vector.h>
namespace KJS {
......@@ -38,7 +39,7 @@ namespace KJS {
const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunctionImp::info, 0};
JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name)
: InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)
: InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name)
, m_callback(callback)
{
}
......
......@@ -39,11 +39,9 @@ class JSCallbackObject : public Base
{
public:
JSCallbackObject(ExecState*, JSClassRef, JSValue* prototype, void* data);
JSCallbackObject(JSClassRef, JSValue* prototype, void* data);
JSCallbackObject(JSClassRef);
virtual ~JSCallbackObject();
void init(ExecState*);
virtual UString className() const;
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
......@@ -76,11 +74,9 @@ public:
static const ClassInfo info;
bool inherits(JSClassRef) const;
private:
JSCallbackObject(); // prevent default construction
JSCallbackObject(const JSCallbackObject&);
void init(ExecState*);
static JSValue* cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
static JSValue* staticValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
......
......@@ -47,12 +47,14 @@ JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, JSClassRef jsClass, JS
init(exec);
}
// Global object constructor. FIXME: Move this into a JSGlobalCallbackObject subclass.
template <class Base>
JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, JSValue* prototype, void* data)
: Base(prototype)
, m_privateData(data)
JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
: m_privateData(0)
, m_class(JSClassRetain(jsClass))
{
ASSERT(Base::isGlobalObject());
init(static_cast<JSGlobalObject*>(this)->globalExec());
}
template <class Base>
......
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006, 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
......@@ -25,12 +25,14 @@
*/
#include "config.h"
#include <wtf/Platform.h>
#include "JSClassRef.h"
#include "APICast.h"
#include "JSCallbackObject.h"
#include "JSClassRef.h"
#include "JSObjectRef.h"
#include "identifier.h"
#include <kjs/JSGlobalObject.h>
#include <kjs/identifier.h>
#include <kjs/object_object.h>
using namespace KJS;
......@@ -155,7 +157,7 @@ JSObject* OpaqueJSClass::prototype(JSContextRef ctx)
if (parentClass)
parentPrototype = parentClass->prototype(ctx); // can be null
if (!parentPrototype)
parentPrototype = exec->dynamicInterpreter()->builtinObjectPrototype();
parentPrototype = exec->dynamicGlobalObject()->objectPrototype();
cachedPrototype = new JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction
}
return cachedPrototype;
......
......@@ -33,6 +33,7 @@
#include <kjs/protect.h>
#include <kjs/ustring.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
struct StaticValueEntry {
StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes)
......
......@@ -32,7 +32,6 @@
#include "JSClassRef.h"
#include "JSGlobalObject.h"
#include "completion.h"
#include "interpreter.h"
#include "object.h"
#include <wtf/Platform.h>
......@@ -42,19 +41,17 @@ JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass)
{
JSLock lock;
Interpreter* interpreter = new Interpreter();
ExecState* globalExec = &interpreter->m_globalExec;
JSGlobalContextRef ctx = toGlobalRef(globalExec);
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);
globalObject->init(globalExec);
} else
interpreter->setGlobalObject(new JSGlobalObject());
if (!globalObjectClass) {
JSGlobalObject* globalObject = new JSGlobalObject;
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
JSGlobalObject* globalObject = new JSCallbackObject<JSGlobalObject>(globalObjectClass);
JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec());
JSValue* prototype = globalObjectClass->prototype(ctx);
if (!prototype)
prototype = jsNull();
globalObject->reset(prototype);
return JSGlobalContextRetain(ctx);
}
......@@ -62,7 +59,7 @@ JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
{
JSLock lock;
ExecState* exec = toJS(ctx);
gcProtect(exec->dynamicInterpreter()->globalObject());
gcProtect(exec->dynamicGlobalObject());
return ctx;
}
......@@ -70,11 +67,11 @@ void JSGlobalContextRelease(JSGlobalContextRef ctx)
{
JSLock lock;
ExecState* exec = toJS(ctx);
gcUnprotect(exec->dynamicInterpreter()->globalObject());
gcUnprotect(exec->dynamicGlobalObject());
}
JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
{
ExecState* exec = toJS(ctx);
return toRef(exec->dynamicInterpreter()->globalObject());
return toRef(exec->dynamicGlobalObject());
}
......@@ -36,11 +36,13 @@
#include "JSClassRef.h"
#include "JSGlobalObject.h"
#include "identifier.h"
#include "PropertyNameArray.h"
#include "function.h"
#include "function_object.h"
#include "identifier.h"
#include "internal.h"
#include "object.h"
#include "PropertyNameArray.h"
#include "object_object.h"
using namespace KJS;
......@@ -73,11 +75,11 @@ JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data)
ExecState* exec = toJS(ctx);
if (!jsClass)
return toRef(new JSObject(exec->lexicalInterpreter()->builtinObjectPrototype())); // slightly more efficient
return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient
JSValue* jsPrototype = jsClass->prototype(ctx);
if (!jsPrototype)
jsPrototype = exec->lexicalInterpreter()->builtinObjectPrototype();
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
return toRef(new JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data));
}
......@@ -98,7 +100,7 @@ JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObje
JSValue* jsPrototype = jsClass
? jsClass->prototype(ctx)
: exec->dynamicInterpreter()->builtinObjectPrototype();
: exec->dynamicGlobalObject()->objectPrototype();
JSObject* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor);
constructor->put(exec, exec->propertyNames().prototype, jsPrototype, DontEnum|DontDelete|ReadOnly);
......@@ -120,7 +122,7 @@ JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned pa
args.append(jsString(UString(toJS(parameterNames[i]))));
args.append(jsString(UString(bodyRep)));
JSObject* result = exec->dynamicInterpreter()->builtinFunction()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber);
JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
......@@ -274,7 +276,7 @@ JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObject
JSObject* jsThisObject = toJS(thisObject);
if (!jsThisObject)
jsThisObject = exec->dynamicInterpreter()->globalObject();
jsThisObject = exec->dynamicGlobalObject();
List argList;
for (size_t i = 0; i < argumentCount; i++)
......
2007-12-05 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
Third step in refactoring JSGlobalObject: Moved data members and
functions accessing data members from Interpreter to JSGlobalObject.
Changed Interpreter member functions to static functions.
This resolves a bug in global object bootstrapping, where the global
ExecState could be used when uninitialized.
This is a big change, but it's mostly code motion and renaming.
Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports
a .7% regression, but Shark sees no difference related to this patch,
and SunSpider reported a .7% speedup from an earlier step in this
refactoring, so I think it's fair to call that a wash.
2007-12-05 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler. (Or vice versa.)
......
......@@ -112,22 +112,11 @@ __ZN3KJS10Identifier3addEPKc
__ZN3KJS10Identifier5equalEPKNS_7UString3RepEPKc
__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE
__ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc
__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiPKNS_5UCharEi
__ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiS3_
__ZN3KJS11Interpreter15restoreBuiltinsERKNS_13SavedBuiltinsE
__ZN3KJS11Interpreter15setGlobalObjectEPNS_14JSGlobalObjectE
__ZN3KJS11Interpreter16stopTimeoutCheckEv
__ZN3KJS11Interpreter17startTimeoutCheckEv
__ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEi
__ZN3KJS11Interpreter21shouldPrintExceptionsEv
__ZN3KJS11Interpreter24setShouldPrintExceptionsEb
__ZN3KJS11Interpreter27resetGlobalObjectPropertiesEv
__ZN3KJS11Interpreter6s_hookE
__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
__ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE
__ZN3KJS11InterpreterC1Ev
__ZN3KJS11InterpreterC2Ev
__ZN3KJS11InterpreterD1Ev
__ZN3KJS11InterpreterD2Ev
__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE
__ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE
__ZN3KJS11JSImmediate4typeEPKNS_7JSValueE
__ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE
__ZN3KJS11JSImmediate8toStringEPKNS_7JSValueE
......@@ -139,11 +128,16 @@ __ZN3KJS12DateInstance4infoE
__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
__ZN3KJS12jsNumberCellEd
__ZN3KJS13ArrayInstance4infoE
__ZN3KJS13SavedBuiltinsC1Ev
__ZN3KJS13SavedBuiltinsD1Ev
__ZN3KJS13jsOwnedStringERKNS_7UStringE
__ZN3KJS14JSGlobalObject10globalExecEv
__ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE
__ZN3KJS14JSGlobalObject16stopTimeoutCheckEv
__ZN3KJS14JSGlobalObject17startTimeoutCheckEv
__ZN3KJS14JSGlobalObject4initEv
__ZN3KJS14JSGlobalObject4markEv
__ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE
__ZN3KJS14JSGlobalObject6s_headE
__ZN3KJS14JSGlobalObjectD2Ev
__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
......@@ -192,11 +186,12 @@ __ZN3KJS8Bindings10RootObjectD1Ev
__ZN3KJS8Bindings10throwErrorEPNS_9ExecStateENS_9ErrorTypeEP8NSString
__ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE
__ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE
__ZN3KJS8Bindings24findProtectingRootObjectEPNS_8JSObjectE
__ZN3KJS8Bindings8Instance18didExecuteFunctionEv
__ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE
__ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE
__ZN3KJS8Debugger12sourceUnusedEPNS_9ExecStateEi
__ZN3KJS8Debugger6attachEPNS_11InterpreterE
__ZN3KJS8Debugger6attachEPNS_14JSGlobalObjectE
__ZN3KJS8Debugger9exceptionEPNS_9ExecStateEiiPNS_7JSValueE
__ZN3KJS8DebuggerC2Ev
__ZN3KJS8DebuggerD2Ev
......@@ -219,8 +214,8 @@ __ZN3KJS8JSObject9putDirectERKNS_10IdentifierEPNS_7JSValueEi
__ZN3KJS8JSObject9putDirectERKNS_10IdentifierEii
__ZN3KJS8jsStringEPKc
__ZN3KJS8jsStringERKNS_7UStringE
__ZN3KJS9Collector15numInterpretersEv
__ZN3KJS9Collector15recordExtraCostEm
__ZN3KJS9Collector16numGlobalObjectsEv
__ZN3KJS9Collector19numProtectedObjectsEv
__ZN3KJS9Collector20rootObjectTypeCountsEv
__ZN3KJS9Collector23collectOnMainThreadOnlyEPNS_7JSValueE
......@@ -228,23 +223,18 @@ __ZN3KJS9Collector4sizeEv
__ZN3KJS9Collector7collectEv
__ZN3KJS9Collector7protectEPNS_7JSValueE
__ZN3KJS9Collector9unprotectEPNS_7JSValueE
__ZN3KJS9ExecStateD1Ev
__ZN3KJSeqERKNS_7UStringEPKc
__ZN3WTF10fastCallocEmm
__ZN3WTF10fastMallocEm
__ZN3WTF11fastReallocEPvm
__ZN3WTF16fastZeroedMallocEm
__ZN3WTF8fastFreeEPv
__ZNK3KJS11Interpreter12builtinArrayEv
__ZNK3KJS11Interpreter12globalObjectEv
__ZNK3KJS11Interpreter12saveBuiltinsERNS_13SavedBuiltinsE
__ZNK3KJS11Interpreter15builtinFunctionEv
__ZNK3KJS11Interpreter22builtinObjectPrototypeEv
__ZNK3KJS11Interpreter22builtinStringPrototypeEv
__ZNK3KJS11Interpreter24builtinFunctionPrototypeEv
__ZNK3KJS11PropertyMap3getERKNS_10IdentifierE
__ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE
__ZNK3KJS12DateInstance7getTimeERdRi
__ZNK3KJS13ArrayInstance7getItemEj
__ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE
__ZNK3KJS19InternalFunctionImp14implementsCallEv
__ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv
__ZNK3KJS4List8getSliceEiRS0_
......@@ -266,7 +256,6 @@ __ZNK3KJS7UString5asciiEv
__ZNK3KJS7UString6is8BitEv
__ZNK3KJS7UString8toUInt32EPb
__ZNK3KJS7UString8toUInt32EPbb
__ZNK3KJS8Bindings10RootObject11interpreterEv
__ZNK3KJS8Bindings10RootObject12globalObjectEv
__ZNK3KJS8Bindings8Instance10rootObjectEv
__ZNK3KJS8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
......@@ -284,7 +273,7 @@ __ZNK3KJS8JSObject8toStringEPNS_9ExecStateE
__ZNK3KJS8JSObject9classInfoEv
__ZNK3KJS8JSObject9classNameEv
__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3KJS9ExecState18lexicalInterpreterEv
__ZNK3KJS9ExecState19lexicalGlobalObjectEv
__ZTVN3KJS14JSGlobalObjectE
__ZTVN3KJS14StringInstanceE
__ZTVN3KJS15JSWrapperObjectE
......
......@@ -165,7 +165,7 @@
932F5B6F0822A1C700736975 /* jni_utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 51856D900562EE95008B9D83 /* jni_utility.h */; };
932F5B700822A1C700736975 /* runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 511B0870056468730080E486 /* runtime.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B710822A1C700736975 /* jni_runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 511B0876056468BB0080E486 /* jni_runtime.h */; };
932F5B720822A1C700736975 /* bool_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 704FD35305697E6D003DBED9 /* bool_object.h */; };
932F5B720822A1C700736975 /* bool_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 704FD35305697E6D003DBED9 /* bool_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B730822A1C700736975 /* runtime_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 70B16A270569A10900DB756D /* runtime_object.h */; settings = {ATTRIBUTES = (Private, ); }; };
932F5B740822A1C700736975 /* jni_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 517D52DD056BF2F6003851BD /* jni_class.h */; };
932F5B750822A1C700736975 /* jni_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 517D5348056BFB5D003851BD /* jni_instance.h */; settings = {ATTRIBUTES = (); }; };
......
......@@ -32,6 +32,7 @@
#include "JSGlobalObject.h"
#include "PropertyNameArray.h"
#include "c_utility.h"
#include "interpreter.h"
#include "npruntime_impl.h"
#include "npruntime_priv.h"
#include "object.h"
......@@ -127,9 +128,9 @@ bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCou
List argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
rootObject->interpreter()->startTimeoutCheck();
rootObject->globalObject()->startTimeoutCheck();
JSValue *resultV = funcImp->call (exec, funcImp, argList);
rootObject->interpreter()->stopTimeoutCheck();
rootObject->globalObject()->stopTimeoutCheck();
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
......@@ -183,9 +184,9 @@ bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant*
JSObject *thisObj = const_cast<JSObject*>(obj->imp);
List argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
rootObject->interpreter()->startTimeoutCheck();
rootObject->globalObject()->startTimeoutCheck();
JSValue *resultV = funcImp->call (exec, thisObj, argList);
rootObject->interpreter()->stopTimeoutCheck();
rootObject->globalObject()->stopTimeoutCheck();
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
......@@ -217,9 +218,9 @@ bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant)
NPUTF16* scriptString;
unsigned int UTF16Length;
convertNPStringToUTF16(s, &scriptString, &UTF16Length); // requires free() of returned memory
rootObject->interpreter()->startTimeoutCheck();
Completion completion = rootObject->interpreter()->evaluate(UString(), 0, UString((const UChar*)scriptString,UTF16Length));
rootObject->interpreter()->stopTimeoutCheck();
rootObject->globalObject()->startTimeoutCheck();
Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), UString(), 0, UString(reinterpret_cast<const UChar*>(scriptString), UTF16Length));
rootObject->globalObject()->stopTimeoutCheck();
ComplType type = completion.complType();
JSValue* result;
......
......@@ -115,17 +115,17 @@ void convertValueToNPVariant(ExecState *exec, JSValue *value, NPVariant *result)
OBJECT_TO_NPVARIANT(obj, *result);
}
} else {
Interpreter* originInterpreter = exec->dynamicInterpreter();
RootObject* originRootObject = findRootObject(originInterpreter);
JSGlobalObject* originGlobalObject = exec->dynamicGlobalObject();
RootObject* originRootObject = findRootObject(originGlobalObject);
Interpreter* interpreter = 0;
JSGlobalObject* globalObject = 0;
if (object->isGlobalObject())
interpreter = static_cast<JSGlobalObject*>(object)->interpreter();
globalObject = static_cast<JSGlobalObject*>(object);
if (!interpreter)
interpreter = originInterpreter;
if (!globalObject)
globalObject = originGlobalObject;
RootObject* rootObject = findRootObject(interpreter);
RootObject* rootObject = findRootObject(globalObject);
if (rootObject) {
NPObject* npObject = _NPN_CreateScriptObject(0, object, originRootObject, rootObject);
OBJECT_TO_NPVARIANT(npObject, *result);
......
......@@ -79,7 +79,7 @@ jvalue JavaJSObject::invoke (JSObjectCallContext *context)
}
else {
JSObject *imp = jlong_to_impptr(nativeHandle);
if (!findRootObject(imp)) {
if (!findProtectingRootObject(imp)) {
fprintf (stderr, "%s:%d: Attempt to access JavaScript from destroyed applet, type %d.\n", __FILE__, __LINE__, context->type);
return result;
}
......@@ -147,7 +147,7 @@ JavaJSObject::JavaJSObject(jlong nativeJSObject)
_imp = jlong_to_impptr(nativeJSObject);
ASSERT(_imp);
_rootObject = findRootObject(_imp);
_rootObject = findProtectingRootObject(_imp);
ASSERT(_rootObject);
}
......@@ -178,9 +178,9 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
JSObject *thisObj = const_cast<JSObject*>(_imp);
List argList;
getListFromJArray(args, argList);
rootObject->interpreter()->startTimeoutCheck();
rootObject->globalObject()->startTimeoutCheck();
JSValue *result = funcImp->call(exec, thisObj, argList);
rootObject->interpreter()->stopTimeoutCheck();
rootObject->globalObject()->stopTimeoutCheck();
return convertValueToJObject(result);
}
......@@ -198,9 +198,9 @@ jobject JavaJSObject::eval(jstring script) const
if (!rootObject)
return 0;
rootObject->interpreter()->startTimeoutCheck();
Completion completion = rootObject->interpreter()->evaluate(UString(), 0, JavaString(script).ustring(),thisObj);
rootObject->interpreter()->stopTimeoutCheck();
rootObject->globalObject()->startTimeoutCheck();
Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), UString(), 0, JavaString(script).ustring(),thisObj);
rootObject->globalObject()->stopTimeoutCheck();
ComplType type = completion.complType();
if (type == Normal) {
......@@ -326,7 +326,7 @@ jlong JavaJSObject::createNative(jlong nativeHandle)
if (nativeHandle == UndefinedHandle)
return nativeHandle;
if (findRootObject(jlong_to_impptr(nativeHandle)))
if (findProtectingRootObject(jlong_to_impptr(nativeHandle)))
return nativeHandle;
CreateRootObjectFunction createRootObject = RootObject::createRootObject();
......@@ -339,7 +339,7 @@ jlong JavaJSObject::createNative(jlong nativeHandle)
// otherwise we are being called after creating a JavaJSObject in
// JavaJSObject::convertValueToJObject().
if (rootObject) {
JSObject* globalObject = rootObject->interpreter()->globalObject();
JSObject* globalObject = rootObject->globalObject();
// We call gcProtect here to get the object into the root object's "protect set" which
// is used to test if a native handle is valid as well as getting the root object given the handle.
rootObject->gcProtect(globalObject);
......
......@@ -26,7 +26,6 @@
#include "config.h"
#include "jni_utility.h"
#include "interpreter.h"
#include "list.h"
#include "jni_runtime.h"
#include "runtime_array.h"
......
......@@ -123,7 +123,7 @@ JSValue* ObjcField::valueFromInstance(ExecState* exec, const Instance* instance)
static id convertValueToObjcObject(ExecState* exec, JSValue* value)
{
RefPtr<RootObject> rootObject = findRootObject(exec->dynamicInterpreter());
RefPtr<RootObject> rootObject = findRootObject(exec->dynamicGlobalObject());
if (!rootObject)
return nil;
return [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:rootObject.get() rootObject:rootObject.get()];
......
......@@ -137,17 +137,17 @@ ObjcValue convertValueToObjcValue(ExecState *exec, JSValue *value, ObjcValueType
case ObjcObjectType: {
JSLock lock;
Interpreter *originInterpreter = exec->dynamicInterpreter();
RootObject* originRootObject = findRootObject(originInterpreter);
JSGlobalObject *