Changeset 28468 in webkit
- Timestamp:
- Dec 5, 2007 6:31:41 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 109 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.cpp
r27730 r28468 26 26 27 27 #include "config.h" 28 29 #include <wtf/Platform.h>30 28 #include "JSBase.h" 31 29 32 30 #include "APICast.h" 33 34 31 #include <kjs/ExecState.h> 32 #include <kjs/JSGlobalObject.h> 33 #include <kjs/JSLock.h> 35 34 #include <kjs/interpreter.h> 36 #include <kjs/JSLock.h>37 35 #include <kjs/object.h> 38 36 … … 47 45 UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; 48 46 // Interpreter::evaluate sets "this" to the global object if it is NULL 49 Completion completion = exec->dynamicInterpreter()->evaluate(UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisObject);47 Completion completion = Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisObject); 50 48 51 49 if (completion.complType() == Throw) { … … 69 67 UString::Rep* scriptRep = toJS(script); 70 68 UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null; 71 Completion completion = exec->dynamicInterpreter()->checkSyntax(UString(sourceURLRep), startingLineNumber, UString(scriptRep));69 Completion completion = Interpreter::checkSyntax(exec->dynamicGlobalObject()->globalExec(), UString(sourceURLRep), startingLineNumber, UString(scriptRep)); 72 70 if (completion.complType() == Throw) { 73 71 if (exception) -
trunk/JavaScriptCore/API/JSCallbackConstructor.cpp
r27730 r28468 1 1 // -*- mode: c++; c-basic-offset: 4 -*- 2 2 /* 3 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 26 26 27 27 #include "config.h" 28 29 #include <wtf/Platform.h>30 28 #include "JSCallbackConstructor.h" 31 29 32 30 #include "APICast.h" 31 #include <kjs/JSGlobalObject.h> 32 #include <kjs/object_object.h> 33 33 #include <wtf/Vector.h> 34 34 … … 38 38 39 39 JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) 40 : JSObject(exec->lexical Interpreter()->builtinObjectPrototype())40 : JSObject(exec->lexicalGlobalObject()->objectPrototype()) 41 41 , m_class(jsClass) 42 42 , m_callback(callback) -
trunk/JavaScriptCore/API/JSCallbackFunction.cpp
r27730 r28468 32 32 #include "function.h" 33 33 #include "function_object.h" 34 #include <kjs/JSGlobalObject.h> 34 35 #include <wtf/Vector.h> 35 36 … … 39 40 40 41 JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name) 41 : InternalFunctionImp( static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)42 : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) 42 43 , m_callback(callback) 43 44 { -
trunk/JavaScriptCore/API/JSCallbackObject.h
r27885 r28468 40 40 public: 41 41 JSCallbackObject(ExecState*, JSClassRef, JSValue* prototype, void* data); 42 JSCallbackObject(JSClassRef , JSValue* prototype, void* data);42 JSCallbackObject(JSClassRef); 43 43 virtual ~JSCallbackObject(); 44 45 void init(ExecState*);46 44 47 45 virtual UString className() const; … … 77 75 78 76 bool inherits(JSClassRef) const; 79 77 80 78 private: 81 JSCallbackObject(); // prevent default construction 82 JSCallbackObject(const JSCallbackObject&); 83 79 void init(ExecState*); 84 80 85 81 static JSValue* cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&); -
trunk/JavaScriptCore/API/JSCallbackObjectFunctions.h
r27885 r28468 48 48 } 49 49 50 template <class Base> 51 JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass, JSValue* prototype, void* data) 52 : Base(prototype)53 , m_privateData(data)50 // Global object constructor. FIXME: Move this into a JSGlobalCallbackObject subclass. 51 template <class Base> 52 JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass) 53 : m_privateData(0) 54 54 , m_class(JSClassRetain(jsClass)) 55 55 { 56 ASSERT(Base::isGlobalObject()); 57 init(static_cast<JSGlobalObject*>(this)->globalExec()); 56 58 } 57 59 -
trunk/JavaScriptCore/API/JSClassRef.cpp
r27763 r28468 1 1 // -*- mode: c++; c-basic-offset: 4 -*- 2 2 /* 3 * Copyright (C) 2006 Apple Computer,Inc. All rights reserved.3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 26 26 27 27 #include "config.h" 28 #include <wtf/Platform.h> 28 #include "JSClassRef.h" 29 29 30 #include "APICast.h" 30 31 #include "JSCallbackObject.h" 31 #include "JSClassRef.h"32 32 #include "JSObjectRef.h" 33 #include "identifier.h" 33 #include <kjs/JSGlobalObject.h> 34 #include <kjs/identifier.h> 35 #include <kjs/object_object.h> 34 36 35 37 using namespace KJS; … … 156 158 parentPrototype = parentClass->prototype(ctx); // can be null 157 159 if (!parentPrototype) 158 parentPrototype = exec->dynamic Interpreter()->builtinObjectPrototype();160 parentPrototype = exec->dynamicGlobalObject()->objectPrototype(); 159 161 cachedPrototype = new JSCallbackObject<JSObject>(exec, prototypeClass, parentPrototype, this); // set ourself as the object's private data, so it can clear our reference on destruction 160 162 } -
trunk/JavaScriptCore/API/JSClassRef.h
r27776 r28468 34 34 #include <kjs/ustring.h> 35 35 #include <wtf/HashMap.h> 36 #include <wtf/RefCounted.h> 36 37 37 38 struct StaticValueEntry { -
trunk/JavaScriptCore/API/JSContextRef.cpp
r28328 r28468 33 33 #include "JSGlobalObject.h" 34 34 #include "completion.h" 35 #include "interpreter.h"36 35 #include "object.h" 37 36 #include <wtf/Platform.h> … … 43 42 JSLock lock; 44 43 45 Interpreter* interpreter = new Interpreter(); 46 ExecState* globalExec = &interpreter->m_globalExec; 47 JSGlobalContextRef ctx = toGlobalRef(globalExec); 44 if (!globalObjectClass) { 45 JSGlobalObject* globalObject = new JSGlobalObject; 46 return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); 47 } 48 48 49 if (globalObjectClass) { 50 // FIXME: ctx is not fully initialized yet, so this call to prototype() might return an object with a garbage pointer in its prototype chain. 51 JSObject* prototype = globalObjectClass->prototype(ctx); 52 JSCallbackObject<JSGlobalObject>* globalObject = new JSCallbackObject<JSGlobalObject>(globalObjectClass, prototype ? prototype : jsNull(), 0); 53 interpreter->setGlobalObject(globalObject); 54 globalObject->init(globalExec); 55 } else 56 interpreter->setGlobalObject(new JSGlobalObject()); 57 49 JSGlobalObject* globalObject = new JSCallbackObject<JSGlobalObject>(globalObjectClass); 50 JSGlobalContextRef ctx = toGlobalRef(globalObject->globalExec()); 51 JSValue* prototype = globalObjectClass->prototype(ctx); 52 if (!prototype) 53 prototype = jsNull(); 54 globalObject->reset(prototype); 58 55 return JSGlobalContextRetain(ctx); 59 56 } … … 63 60 JSLock lock; 64 61 ExecState* exec = toJS(ctx); 65 gcProtect(exec->dynamic Interpreter()->globalObject());62 gcProtect(exec->dynamicGlobalObject()); 66 63 return ctx; 67 64 } … … 71 68 JSLock lock; 72 69 ExecState* exec = toJS(ctx); 73 gcUnprotect(exec->dynamic Interpreter()->globalObject());70 gcUnprotect(exec->dynamicGlobalObject()); 74 71 } 75 72 … … 77 74 { 78 75 ExecState* exec = toJS(ctx); 79 return toRef(exec->dynamic Interpreter()->globalObject());76 return toRef(exec->dynamicGlobalObject()); 80 77 } -
trunk/JavaScriptCore/API/JSObjectRef.cpp
r27763 r28468 37 37 #include "JSGlobalObject.h" 38 38 39 #include "PropertyNameArray.h" 40 #include "function.h" 41 #include "function_object.h" 39 42 #include "identifier.h" 40 #include "function.h"41 43 #include "internal.h" 42 44 #include "object.h" 43 #include " PropertyNameArray.h"45 #include "object_object.h" 44 46 45 47 using namespace KJS; … … 74 76 75 77 if (!jsClass) 76 return toRef(new JSObject(exec->lexical Interpreter()->builtinObjectPrototype())); // slightly more efficient78 return toRef(new JSObject(exec->lexicalGlobalObject()->objectPrototype())); // slightly more efficient 77 79 78 80 JSValue* jsPrototype = jsClass->prototype(ctx); 79 81 if (!jsPrototype) 80 jsPrototype = exec->lexical Interpreter()->builtinObjectPrototype();82 jsPrototype = exec->lexicalGlobalObject()->objectPrototype(); 81 83 82 84 return toRef(new JSCallbackObject<JSObject>(exec, jsClass, jsPrototype, data)); … … 99 101 JSValue* jsPrototype = jsClass 100 102 ? jsClass->prototype(ctx) 101 : exec->dynamic Interpreter()->builtinObjectPrototype();103 : exec->dynamicGlobalObject()->objectPrototype(); 102 104 103 105 JSObject* constructor = new JSCallbackConstructor(exec, jsClass, callAsConstructor); … … 121 123 args.append(jsString(UString(bodyRep))); 122 124 123 JSObject* result = exec->dynamic Interpreter()->builtinFunction()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber);125 JSObject* result = exec->dynamicGlobalObject()->functionConstructor()->construct(exec, args, nameID, UString(sourceURLRep), startingLineNumber); 124 126 if (exec->hadException()) { 125 127 if (exception) … … 275 277 276 278 if (!jsThisObject) 277 jsThisObject = exec->dynamic Interpreter()->globalObject();279 jsThisObject = exec->dynamicGlobalObject(); 278 280 279 281 List argList; -
trunk/JavaScriptCore/ChangeLog
r28463 r28468 1 2007-12-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Third step in refactoring JSGlobalObject: Moved data members and 6 functions accessing data members from Interpreter to JSGlobalObject. 7 Changed Interpreter member functions to static functions. 8 9 This resolves a bug in global object bootstrapping, where the global 10 ExecState could be used when uninitialized. 11 12 This is a big change, but it's mostly code motion and renaming. 13 14 Layout and JS tests, and testjsglue and testapi, pass. SunSpider reports 15 a .7% regression, but Shark sees no difference related to this patch, 16 and SunSpider reported a .7% speedup from an earlier step in this 17 refactoring, so I think it's fair to call that a wash. 18 1 19 2007-12-05 Geoffrey Garen <ggaren@apple.com> 2 20 -
trunk/JavaScriptCore/JavaScriptCore.exp
r28328 r28468 113 113 __ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeE 114 114 __ZN3KJS10throwErrorEPNS_9ExecStateENS_9ErrorTypeEPKc 115 __ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiPKNS_5UCharEi 116 __ZN3KJS11Interpreter11checkSyntaxERKNS_7UStringEiS3_ 117 __ZN3KJS11Interpreter15restoreBuiltinsERKNS_13SavedBuiltinsE 118 __ZN3KJS11Interpreter15setGlobalObjectEPNS_14JSGlobalObjectE 119 __ZN3KJS11Interpreter16stopTimeoutCheckEv 120 __ZN3KJS11Interpreter17startTimeoutCheckEv 115 __ZN3KJS11Interpreter11checkSyntaxEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEi 121 116 __ZN3KJS11Interpreter21shouldPrintExceptionsEv 122 117 __ZN3KJS11Interpreter24setShouldPrintExceptionsEb 123 __ZN3KJS11Interpreter27resetGlobalObjectPropertiesEv 124 __ZN3KJS11Interpreter6s_hookE 125 __ZN3KJS11Interpreter8evaluateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE 126 __ZN3KJS11Interpreter8evaluateERKNS_7UStringEiS3_PNS_7JSValueE 127 __ZN3KJS11InterpreterC1Ev 128 __ZN3KJS11InterpreterC2Ev 129 __ZN3KJS11InterpreterD1Ev 130 __ZN3KJS11InterpreterD2Ev 118 __ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiPKNS_5UCharEiPNS_7JSValueE 119 __ZN3KJS11Interpreter8evaluateEPNS_9ExecStateERKNS_7UStringEiS5_PNS_7JSValueE 131 120 __ZN3KJS11JSImmediate4typeEPKNS_7JSValueE 132 121 __ZN3KJS11JSImmediate8toObjectEPKNS_7JSValueEPNS_9ExecStateE … … 140 129 __ZN3KJS12jsNumberCellEd 141 130 __ZN3KJS13ArrayInstance4infoE 142 __ZN3KJS13SavedBuiltinsC1Ev143 __ZN3KJS13SavedBuiltinsD1Ev144 131 __ZN3KJS13jsOwnedStringERKNS_7UStringE 145 132 __ZN3KJS14JSGlobalObject10globalExecEv 133 __ZN3KJS14JSGlobalObject15restoreBuiltinsERKNS_13SavedBuiltinsE 134 __ZN3KJS14JSGlobalObject16stopTimeoutCheckEv 135 __ZN3KJS14JSGlobalObject17startTimeoutCheckEv 136 __ZN3KJS14JSGlobalObject4initEv 146 137 __ZN3KJS14JSGlobalObject4markEv 138 __ZN3KJS14JSGlobalObject5resetEPNS_7JSValueE 139 __ZN3KJS14JSGlobalObject6s_headE 140 __ZN3KJS14JSGlobalObjectD2Ev 147 141 __ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE 148 142 __ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE … … 193 187 __ZN3KJS8Bindings23convertObjcValueToValueEPNS_9ExecStateEPvNS0_13ObjcValueTypeEPNS0_10RootObjectE 194 188 __ZN3KJS8Bindings23convertValueToObjcValueEPNS_9ExecStateEPNS_7JSValueENS0_13ObjcValueTypeE 189 __ZN3KJS8Bindings24findProtectingRootObjectEPNS_8JSObjectE 195 190 __ZN3KJS8Bindings8Instance18didExecuteFunctionEv 196 191 __ZN3KJS8Bindings8Instance21setDidExecuteFunctionEPFvPNS_9ExecStateEPNS_8JSObjectEE 197 192 __ZN3KJS8Bindings8Instance32createBindingForLanguageInstanceENS1_15BindingLanguageEPvN3WTF10PassRefPtrINS0_10RootObjectEEE 198 193 __ZN3KJS8Debugger12sourceUnusedEPNS_9ExecStateEi 199 __ZN3KJS8Debugger6attachEPNS_1 1InterpreterE194 __ZN3KJS8Debugger6attachEPNS_14JSGlobalObjectE 200 195 __ZN3KJS8Debugger9exceptionEPNS_9ExecStateEiiPNS_7JSValueE 201 196 __ZN3KJS8DebuggerC2Ev … … 220 215 __ZN3KJS8jsStringEPKc 221 216 __ZN3KJS8jsStringERKNS_7UStringE 222 __ZN3KJS9Collector15numInterpretersEv223 217 __ZN3KJS9Collector15recordExtraCostEm 218 __ZN3KJS9Collector16numGlobalObjectsEv 224 219 __ZN3KJS9Collector19numProtectedObjectsEv 225 220 __ZN3KJS9Collector20rootObjectTypeCountsEv … … 229 224 __ZN3KJS9Collector7protectEPNS_7JSValueE 230 225 __ZN3KJS9Collector9unprotectEPNS_7JSValueE 226 __ZN3KJS9ExecStateD1Ev 231 227 __ZN3KJSeqERKNS_7UStringEPKc 232 228 __ZN3WTF10fastCallocEmm … … 235 231 __ZN3WTF16fastZeroedMallocEm 236 232 __ZN3WTF8fastFreeEPv 237 __ZNK3KJS11Interpreter12builtinArrayEv238 __ZNK3KJS11Interpreter12globalObjectEv239 __ZNK3KJS11Interpreter12saveBuiltinsERNS_13SavedBuiltinsE240 __ZNK3KJS11Interpreter15builtinFunctionEv241 __ZNK3KJS11Interpreter22builtinObjectPrototypeEv242 __ZNK3KJS11Interpreter22builtinStringPrototypeEv243 __ZNK3KJS11Interpreter24builtinFunctionPrototypeEv244 233 __ZNK3KJS11PropertyMap3getERKNS_10IdentifierE 245 234 __ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE 246 235 __ZNK3KJS12DateInstance7getTimeERdRi 247 236 __ZNK3KJS13ArrayInstance7getItemEj 237 __ZNK3KJS14JSGlobalObject12saveBuiltinsERNS_13SavedBuiltinsE 248 238 __ZNK3KJS19InternalFunctionImp14implementsCallEv 249 239 __ZNK3KJS19InternalFunctionImp21implementsHasInstanceEv … … 267 257 __ZNK3KJS7UString8toUInt32EPb 268 258 __ZNK3KJS7UString8toUInt32EPbb 269 __ZNK3KJS8Bindings10RootObject11interpreterEv270 259 __ZNK3KJS8Bindings10RootObject12globalObjectEv 271 260 __ZNK3KJS8Bindings8Instance10rootObjectEv … … 285 274 __ZNK3KJS8JSObject9classNameEv 286 275 __ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE 287 __ZNK3KJS9ExecState1 8lexicalInterpreterEv276 __ZNK3KJS9ExecState19lexicalGlobalObjectEv 288 277 __ZTVN3KJS14JSGlobalObjectE 289 278 __ZTVN3KJS14StringInstanceE -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r28434 r28468 166 166 932F5B700822A1C700736975 /* runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 511B0870056468730080E486 /* runtime.h */; settings = {ATTRIBUTES = (Private, ); }; }; 167 167 932F5B710822A1C700736975 /* jni_runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 511B0876056468BB0080E486 /* jni_runtime.h */; }; 168 932F5B720822A1C700736975 /* bool_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 704FD35305697E6D003DBED9 /* bool_object.h */; };168 932F5B720822A1C700736975 /* bool_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 704FD35305697E6D003DBED9 /* bool_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; 169 169 932F5B730822A1C700736975 /* runtime_object.h in Headers */ = {isa = PBXBuildFile; fileRef = 70B16A270569A10900DB756D /* runtime_object.h */; settings = {ATTRIBUTES = (Private, ); }; }; 170 170 932F5B740822A1C700736975 /* jni_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 517D52DD056BF2F6003851BD /* jni_class.h */; }; -
trunk/JavaScriptCore/bindings/NP_jsobject.cpp
r28328 r28468 33 33 #include "PropertyNameArray.h" 34 34 #include "c_utility.h" 35 #include "interpreter.h" 35 36 #include "npruntime_impl.h" 36 37 #include "npruntime_priv.h" … … 128 129 List argList; 129 130 getListFromVariantArgs(exec, args, argCount, rootObject, argList); 130 rootObject-> interpreter()->startTimeoutCheck();131 rootObject->globalObject()->startTimeoutCheck(); 131 132 JSValue *resultV = funcImp->call (exec, funcImp, argList); 132 rootObject-> interpreter()->stopTimeoutCheck();133 rootObject->globalObject()->stopTimeoutCheck(); 133 134 134 135 // Convert and return the result of the function call. … … 184 185 List argList; 185 186 getListFromVariantArgs(exec, args, argCount, rootObject, argList); 186 rootObject-> interpreter()->startTimeoutCheck();187 rootObject->globalObject()->startTimeoutCheck(); 187 188 JSValue *resultV = funcImp->call (exec, thisObj, argList); 188 rootObject-> interpreter()->stopTimeoutCheck();189 rootObject->globalObject()->stopTimeoutCheck(); 189 190 190 191 // Convert and return the result of the function call. … … 218 219 unsigned int UTF16Length; 219 220 convertNPStringToUTF16(s, &scriptString, &UTF16Length); // requires free() of returned memory 220 rootObject-> interpreter()->startTimeoutCheck();221 Completion completion = rootObject->interpreter()->evaluate(UString(), 0, UString((const UChar*)scriptString,UTF16Length));222 rootObject-> interpreter()->stopTimeoutCheck();221 rootObject->globalObject()->startTimeoutCheck(); 222 Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), UString(), 0, UString(reinterpret_cast<const UChar*>(scriptString), UTF16Length)); 223 rootObject->globalObject()->stopTimeoutCheck(); 223 224 ComplType type = completion.complType(); 224 225 -
trunk/JavaScriptCore/bindings/c/c_utility.cpp
r27810 r28468 116 116 } 117 117 } else { 118 Interpreter* originInterpreter = exec->dynamicInterpreter();119 RootObject* originRootObject = findRootObject(origin Interpreter);118 JSGlobalObject* originGlobalObject = exec->dynamicGlobalObject(); 119 RootObject* originRootObject = findRootObject(originGlobalObject); 120 120 121 Interpreter* interpreter= 0;121 JSGlobalObject* globalObject = 0; 122 122 if (object->isGlobalObject()) 123 interpreter = static_cast<JSGlobalObject*>(object)->interpreter();123 globalObject = static_cast<JSGlobalObject*>(object); 124 124 125 if (! interpreter)126 interpreter = originInterpreter;125 if (!globalObject) 126 globalObject = originGlobalObject; 127 127 128 RootObject* rootObject = findRootObject( interpreter);128 RootObject* rootObject = findRootObject(globalObject); 129 129 if (rootObject) { 130 130 NPObject* npObject = _NPN_CreateScriptObject(0, object, originRootObject, rootObject); -
trunk/JavaScriptCore/bindings/jni/jni_jsobject.cpp
r28328 r28468 80 80 else { 81 81 JSObject *imp = jlong_to_impptr(nativeHandle); 82 if (!find RootObject(imp)) {82 if (!findProtectingRootObject(imp)) { 83 83 fprintf (stderr, "%s:%d: Attempt to access JavaScript from destroyed applet, type %d.\n", __FILE__, __LINE__, context->type); 84 84 return result; … … 148 148 149 149 ASSERT(_imp); 150 _rootObject = find RootObject(_imp);150 _rootObject = findProtectingRootObject(_imp); 151 151 ASSERT(_rootObject); 152 152 } … … 179 179 List argList; 180 180 getListFromJArray(args, argList); 181 rootObject-> interpreter()->startTimeoutCheck();181 rootObject->globalObject()->startTimeoutCheck(); 182 182 JSValue *result = funcImp->call(exec, thisObj, argList); 183 rootObject-> interpreter()->stopTimeoutCheck();183 rootObject->globalObject()->stopTimeoutCheck(); 184 184 185 185 return convertValueToJObject(result); … … 199 199 return 0; 200 200 201 rootObject-> interpreter()->startTimeoutCheck();202 Completion completion = rootObject->interpreter()->evaluate(UString(), 0, JavaString(script).ustring(),thisObj);203 rootObject-> interpreter()->stopTimeoutCheck();201 rootObject->globalObject()->startTimeoutCheck(); 202 Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), UString(), 0, JavaString(script).ustring(),thisObj); 203 rootObject->globalObject()->stopTimeoutCheck(); 204 204 ComplType type = completion.complType(); 205 205 … … 327 327 return nativeHandle; 328 328 329 if (find RootObject(jlong_to_impptr(nativeHandle)))329 if (findProtectingRootObject(jlong_to_impptr(nativeHandle))) 330 330 return nativeHandle; 331 331 … … 340 340 // JavaJSObject::convertValueToJObject(). 341 341 if (rootObject) { 342 JSObject* globalObject = rootObject-> interpreter()->globalObject();342 JSObject* globalObject = rootObject->globalObject(); 343 343 // We call gcProtect here to get the object into the root object's "protect set" which 344 344 // is used to test if a native handle is valid as well as getting the root object given the handle. -
trunk/JavaScriptCore/bindings/jni/jni_utility.cpp
r24059 r28468 27 27 #include "jni_utility.h" 28 28 29 #include "interpreter.h"30 29 #include "list.h" 31 30 #include "jni_runtime.h" -
trunk/JavaScriptCore/bindings/objc/objc_runtime.mm
r27413 r28468 124 124 static id convertValueToObjcObject(ExecState* exec, JSValue* value) 125 125 { 126 RefPtr<RootObject> rootObject = findRootObject(exec->dynamic Interpreter());126 RefPtr<RootObject> rootObject = findRootObject(exec->dynamicGlobalObject()); 127 127 if (!rootObject) 128 128 return nil; -
trunk/JavaScriptCore/bindings/objc/objc_utility.mm
r27022 r28468 138 138 JSLock lock; 139 139 140 Interpreter *originInterpreter = exec->dynamicInterpreter();141 RootObject* originRootObject = findRootObject(origin Interpreter);142 143 Interpreter *interpreter= 0;140 JSGlobalObject *originGlobalObject = exec->dynamicGlobalObject(); 141 RootObject* originRootObject = findRootObject(originGlobalObject); 142 143 JSGlobalObject* globalObject = 0; 144 144 if (value->isObject() && static_cast<JSObject*>(value)->isGlobalObject()) 145 interpreter = static_cast<JSGlobalObject*>(value)->interpreter();146 147 if (! interpreter)148 interpreter = originInterpreter;145 globalObject = static_cast<JSGlobalObject*>(value); 146 147 if (!globalObject) 148 globalObject = originGlobalObject; 149 149 150 RootObject* rootObject = findRootObject( interpreter);150 RootObject* rootObject = findRootObject(globalObject); 151 151 result.objectValue = rootObject 152 152 ? [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:originRootObject rootObject:rootObject] -
trunk/JavaScriptCore/bindings/runtime_array.cpp
r27413 r28468 27 27 #include "runtime_array.h" 28 28 29 #include "JSGlobalObject.h" 30 #include "array_object.h" 31 29 32 using namespace KJS; 30 33 … … 32 35 33 36 RuntimeArray::RuntimeArray(ExecState *exec, Bindings::Array *a) 34 : JSObject(exec->lexical Interpreter()->builtinArrayPrototype())37 : JSObject(exec->lexicalGlobalObject()->arrayPrototype()) 35 38 , _array(a) 36 39 { -
trunk/JavaScriptCore/bindings/runtime_method.cpp
r27097 r28468 28 28 29 29 #include "ExecState.h" 30 #include "JSGlobalObject.h" 30 31 #include "runtime_object.h" 31 32 #include "function_object.h" … … 35 36 36 37 RuntimeMethod::RuntimeMethod(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) 37 : InternalFunctionImp (static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), ident)38 : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), ident) 38 39 , _methodList(new MethodList(m)) 39 40 { -
trunk/JavaScriptCore/bindings/runtime_root.cpp
r28328 r28468 51 51 // fix them by adding a JSObject to RootObject dictionary. 52 52 53 RootObject* find RootObject(JSObject* jsObject)53 RootObject* findProtectingRootObject(JSObject* jsObject) 54 54 { 55 55 RootObjectSet::const_iterator end = rootObjectSet()->end(); … … 61 61 } 62 62 63 RootObject* findRootObject( Interpreter* interpreter)63 RootObject* findRootObject(JSGlobalObject* globalObject) 64 64 { 65 65 RootObjectSet::const_iterator end = rootObjectSet()->end(); 66 66 for (RootObjectSet::const_iterator it = rootObjectSet()->begin(); it != end; ++it) { 67 if ((*it)-> interpreter() == interpreter)67 if ((*it)->globalObject() == globalObject) 68 68 return *it; 69 69 } … … 281 281 } 282 282 283 Interpreter* RootObject::interpreter() const284 {285 ASSERT(m_isValid);286 return m_globalObject->interpreter();287 }288 289 283 JSGlobalObject* RootObject::globalObject() const 290 284 { -
trunk/JavaScriptCore/bindings/runtime_root.h
r28328 r28468 49 49 typedef HashCountedSet<JSObject*> ProtectCountSet; 50 50 51 extern RootObject* find RootObject(JSObject*);52 extern RootObject* findRootObject( Interpreter*);51 extern RootObject* findProtectingRootObject(JSObject*); 52 extern RootObject* findRootObject(JSGlobalObject*); 53 53 54 54 class RootObject : public RefCounted<RootObject> { … … 68 68 69 69 const void* nativeHandle() const; 70 Interpreter* interpreter() const;71 70 JSGlobalObject* globalObject() const; 72 71 -
trunk/JavaScriptCore/kjs/ExecState.cpp
r28110 r28468 32 32 namespace KJS { 33 33 34 35 34 // ECMA 10.2 36 ExecState::ExecState( Interpreter* interpreter,JSGlobalObject* globalObject, JSObject* thisV,37 FunctionBodyNode* currentBody, CodeType type, ExecState* callingExec, 35 ExecState::ExecState(JSGlobalObject* globalObject, JSObject* thisV, 36 FunctionBodyNode* currentBody, CodeType type, ExecState* callingExec, ExecState* currentExec, 38 37 FunctionImp* func, const List* args) 39 : m_ interpreter(interpreter)38 : m_globalObject(globalObject) 40 39 , m_exception(0) 41 40 , m_propertyNames(CommonIdentifiers::shared()) 42 , m_savedExecState(interpreter->currentExec()) 41 , m_callingExec(callingExec) 42 , m_savedExec(currentExec) 43 43 , m_currentBody(currentBody) 44 44 , m_function(func) … … 46 46 , m_iterationDepth(0) 47 47 , m_switchDepth(0) 48 , m_codeType(type) 48 49 { 49 m_codeType = type;50 m_callingExecState = callingExec;51 52 50 // create and initialize activation object (ECMA 10.1.6) 53 51 if (type == FunctionCode) { … … 62 60 switch(type) { 63 61 case EvalCode: 64 if (m_callingExec State) {65 m_scopeChain = m_callingExec State->scopeChain();66 m_variable = m_callingExec State->variableObject();67 m_thisVal = m_callingExec State->thisValue();62 if (m_callingExec) { 63 m_scopeChain = m_callingExec->scopeChain(); 64 m_variable = m_callingExec->variableObject(); 65 m_thisVal = m_callingExec->thisValue(); 68 66 break; 69 67 } // else same as GlobalCode 70 68 case GlobalCode: 71 if (globalObject)72 setGlobalObject(globalObject);69 m_scopeChain.push(globalObject); 70 m_thisVal = globalObject; 73 71 break; 74 72 case FunctionCode: … … 81 79 82 80 if (currentBody) 83 m_ interpreter->setCurrentExec(this);81 m_globalObject->setCurrentExec(this); 84 82 } 85 83 86 84 ExecState::~ExecState() 87 85 { 88 m_ interpreter->setCurrentExec(m_savedExecState);86 m_globalObject->setCurrentExec(m_savedExec); 89 87 } 90 88 91 89 void ExecState::mark() 92 90 { 93 for (ExecState* exec = this; exec; exec = exec->m_callingExec State)91 for (ExecState* exec = this; exec; exec = exec->m_callingExec) 94 92 exec->m_scopeChain.mark(); 95 93 } 96 94 97 void ExecState::setGlobalObject(JSGlobalObject* globalObject) 98 { 99 m_scopeChain.clear(); 100 m_scopeChain.push(globalObject); 101 m_thisVal = static_cast<JSObject*>(globalObject); 102 } 103 104 Interpreter* ExecState::lexicalInterpreter() const 95 JSGlobalObject* ExecState::lexicalGlobalObject() const 105 96 { 106 97 if (scopeChain().isEmpty()) 107 return dynamic Interpreter();98 return dynamicGlobalObject(); 108 99 109 100 JSObject* object = scopeChain().bottom(); 110 101 if (object && object->isGlobalObject()) 111 return static_cast<JSGlobalObject*>(object) ->interpreter();102 return static_cast<JSGlobalObject*>(object); 112 103 113 return dynamic Interpreter();104 return dynamicGlobalObject(); 114 105 } 115 106 -
trunk/JavaScriptCore/kjs/ExecState.h
r28110 r28468 57 57 public: 58 58 /** 59 * Returns the interpreter currently running code59 * Returns the global object that was in scope when the current script started executing. 60 60 */ 61 Interpreter* dynamicInterpreter() const { return m_interpreter; }61 JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; } 62 62 63 63 /** 64 * Returns the interpreter associated with the current scope's global object64 * Returns the global object that was in scope when the current body of code was defined. 65 65 */ 66 Interpreter* lexicalInterpreter() const;66 JSGlobalObject* lexicalGlobalObject() const; 67 67 68 68 void setException(JSValue* e) { m_exception = e; } … … 79 79 JSObject* thisValue() const { return m_thisVal; } 80 80 81 ExecState* callingExecState() { return m_callingExec State; }81 ExecState* callingExecState() { return m_callingExec; } 82 82 83 83 JSObject* activationObject() { return m_activation; } … … 99 99 bool inSwitch() const { return (m_switchDepth > 0); } 100 100 101 void setGlobalObject(JSGlobalObject*);102 103 101 void mark(); 104 102 … … 110 108 void updateLocalStorage(); 111 109 112 p rivate:113 ExecState( Interpreter* interp,JSGlobalObject* glob, JSObject* thisV,110 public: 111 ExecState(JSGlobalObject* glob, JSObject* thisV, 114 112 FunctionBodyNode* currentBody, CodeType type = GlobalCode, 115 ExecState* callingExecState = 0, FunctionImp* function = 0, const List* args = 0); 113 ExecState* callingExecState = 0, ExecState* currentExec = 0, 114 FunctionImp* function = 0, const List* args = 0); 116 115 ~ExecState(); 117 116 117 private: 118 118 // ExecStates are always stack-allocated, and the garbage collector 119 119 // marks the stack, so we don't need to protect the objects below from GC. 120 120 121 Interpreter* m_interpreter;121 JSGlobalObject* m_globalObject; 122 122 JSValue* m_exception; 123 123 CommonIdentifiers* m_propertyNames; 124 124 125 ExecState* m_callingExec State;126 ExecState* m_savedExec State;125 ExecState* m_callingExec; 126 ExecState* m_savedExec; 127 127 FunctionBodyNode* m_currentBody; 128 128 -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r28328 r28468 30 30 #include "JSGlobalObject.h" 31 31 32 #include "object_object.h" 33 #include "function_object.h" 32 #include "SavedBuiltins.h" 34 33 #include "array_object.h" 35 34 #include "bool_object.h" 35 #include "date_object.h" 36 #include "debugger.h" 37 #include "error_object.h" 38 #include "function_object.h" 39 #include "math_object.h" 40 #include "number_object.h" 41 #include "object_object.h" 42 #include "regexp_object.h" 36 43 #include "string_object.h" 37 #include "number_object.h"38 #include "date_object.h"39 #include "regexp_object.h"40 #include "error_object.h"41 44 42 45 namespace KJS { 46 47 // Default number of ticks before a timeout check should be done. 48 static const int initialTickCountThreshold = 255; 49 50 // Preferred number of milliseconds between each timeout check 51 static const int preferredScriptCheckTimeInterval = 1000; 43 52 44 53 static inline void markIfNeeded(JSValue* v) … … 47 56 v->mark(); 48 57 } 58 59 // Returns the current time in milliseconds 60 // It doesn't matter what "current time" is here, just as long as 61 // it's possible to measure the time difference correctly. 62 static inline unsigned getCurrentTime() { 63 #if HAVE(SYS_TIME_H) 64 struct timeval tv; 65 gettimeofday(&tv, 0); 66 return tv.tv_sec * 1000 + tv.tv_usec / 1000; 67 #elif PLATFORM(QT) 68 QDateTime t = QDateTime::currentDateTime(); 69 return t.toTime_t() * 1000 + t.time().msec(); 70 #elif PLATFORM(WIN_OS) 71 return timeGetTime(); 72 #else 73 #error Platform does not have getCurrentTime function 74 #endif 75 } 76 77 JSGlobalObject* JSGlobalObject::s_head = 0; 78 79 JSGlobalObject::~JSGlobalObject() 80 { 81 ASSERT(JSLock::currentThreadIsHoldingLock()); 82 83 if (d->debugger) 84 d->debugger->detach(this); 85 86 d->next->d->prev = d->prev; 87 d->prev->d->next = d->next; 88 s_head = d->next; 89 if (s_head == this) 90 s_head = 0; 91 } 92 93 void JSGlobalObject::init() 94 { 95 ASSERT(JSLock::currentThreadIsHoldingLock()); 96 97 d.reset(new JSGlobalObjectData(this)); 98 99 if (s_head) { 100 d->prev = s_head; 101 d->next = s_head->d->next; 102 s_head->d->next->d->prev = this; 103 s_head->d->next = this; 104 } else 105 s_head = d->next = d->prev = this; 106 107 d->compatMode = NativeMode; 108 109 resetTimeoutCheck(); 110 d->timeoutTime = 0; 111 d->timeoutCheckCount = 0; 112 113 d->currentExec = 0; 114 d->recursion = 0; 115 d->debugger = 0; 116 117 reset(prototype()); 118 } 119 120 static inline JSObject* lastInPrototypeChain(JSObject* object) 121 { 122 JSObject* o = object; 123 while (o->prototype()->isObject()) 124 o = static_cast<JSObject*>(o->prototype()); 125 return o; 126 } 127 128 void JSGlobalObject::reset(JSValue* prototype) 129 { 130 // Clear before inititalizing, to avoid marking uninitialized (dangerous) or 131 // stale (wasteful) pointers during possible garbage collection while creating 132 // new objects below. 133 134 ExecState* exec = &d->globalExec; 135 136 // Prototypes 137 d->functionPrototype = 0; 138 d->objectPrototype = 0; 139 140 d->arrayPrototype = 0; 141 d->stringPrototype = 0; 142 d->booleanPrototype = 0; 143 d->numberPrototype = 0; 144 d->datePrototype = 0; 145 d->regExpPrototype = 0; 146 d->errorPrototype = 0; 147 148 d->evalErrorPrototype = 0; 149 d->rangeErrorPrototype = 0; 150 d->referenceErrorPrototype = 0; 151 d->syntaxErrorPrototype = 0; 152 d->typeErrorPrototype = 0; 153 d->URIErrorPrototype = 0; 154 155 // Constructors 156 d->objectConstructor = 0; 157 d->functionConstructor = 0; 158 d->arrayConstructor = 0; 159 d->stringConstructor = 0; 160 d->booleanConstructor = 0; 161 d->numberConstructor = 0; 162 d->dateConstructor = 0; 163 d->regExpConstructor = 0; 164 d->errorConstructor = 0; 165 166 d->evalErrorConstructor = 0; 167 d->rangeErrorConstructor = 0; 168 d->referenceErrorConstructor = 0; 169 d->syntaxErrorConstructor = 0; 170 d->typeErrorConstructor = 0; 171 d->URIErrorConstructor = 0; 172 173 // Prototypes 174 d->functionPrototype = new FunctionPrototype(exec); 175 d->objectPrototype = new ObjectPrototype(exec, d->functionPrototype); 176 d->functionPrototype->setPrototype(d->objectPrototype); 177 178 d->arrayPrototype = new ArrayPrototype(exec, d->objectPrototype); 179 d->stringPrototype = new StringPrototype(exec, d->objectPrototype); 180 d->booleanPrototype = new BooleanPrototype(exec, d->objectPrototype, d->functionPrototype); 181 d->numberPrototype = new NumberPrototype(exec, d->objectPrototype, d->functionPrototype); 182 d->datePrototype = new DatePrototype(exec, d->objectPrototype); 183 d->regExpPrototype = new RegExpPrototype(exec, d->objectPrototype, d->functionPrototype);; 184 d->errorPrototype = new ErrorPrototype(exec, d->objectPrototype, d->functionPrototype); 185 186 d->evalErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, EvalError, "EvalError", "EvalError"); 187 d->rangeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, RangeError, "RangeError", "RangeError"); 188 d->referenceErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError"); 189 d->syntaxErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError"); 190 d->typeErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, TypeError, "TypeError", "TypeError"); 191 d->URIErrorPrototype = new NativeErrorPrototype(exec, d->errorPrototype, URIError, "URIError", "URIError"); 192 193 // Constructors 194 d->objectConstructor = new ObjectObjectImp(exec, d->objectPrototype, d->functionPrototype); 195 d->functionConstructor = new FunctionObjectImp(exec, d->functionPrototype); 196 d->arrayConstructor = new ArrayObjectImp(exec, d->functionPrototype, d->arrayPrototype); 197 d->stringConstructor = new StringObjectImp(exec, d->functionPrototype, d->stringPrototype); 198 d->booleanConstructor = new BooleanObjectImp(exec, d->functionPrototype, d->booleanPrototype); 199 d->numberConstructor = new NumberObjectImp(exec, d->functionPrototype, d->numberPrototype); 200 d->dateConstructor = new DateObjectImp(exec, d->functionPrototype, d->datePrototype); 201 d->regExpConstructor = new RegExpObjectImp(exec, d->functionPrototype, d->regExpPrototype); 202 d->errorConstructor = new ErrorObjectImp(exec, d->functionPrototype, d->errorPrototype); 203 204 d->evalErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->evalErrorPrototype); 205 d->rangeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->rangeErrorPrototype); 206 d->referenceErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->referenceErrorPrototype); 207 d->syntaxErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->syntaxErrorPrototype); 208 d->typeErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->typeErrorPrototype); 209 d->URIErrorConstructor = new NativeErrorImp(exec, d->functionPrototype, d->URIErrorPrototype); 210 211 d->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum); 212 213 d->objectPrototype->put(exec, exec->propertyNames().constructor, d->objectConstructor, DontEnum | DontDelete | ReadOnly); 214 d->functionPrototype->put(exec, exec->propertyNames().constructor, d->functionConstructor, DontEnum | DontDelete | ReadOnly); 215 d->arrayPrototype->put(exec, exec->propertyNames().constructor, d->arrayConstructor, DontEnum | DontDelete | ReadOnly); 216 d->booleanPrototype->put(exec, exec->propertyNames().constructor, d->booleanConstructor, DontEnum | DontDelete | ReadOnly); 217 d->stringPrototype->put(exec, exec->propertyNames().constructor, d->stringConstructor, DontEnum | DontDelete | ReadOnly); 218 d->numberPrototype->put(exec, exec->propertyNames().constructor, d->numberConstructor, DontEnum | DontDelete | ReadOnly); 219 d->datePrototype->put(exec, exec->propertyNames().constructor, d->dateConstructor, DontEnum | DontDelete | ReadOnly); 220 d->regExpPrototype->put(exec, exec->propertyNames().constructor, d->regExpConstructor, DontEnum | DontDelete | ReadOnly); 221 d->errorPrototype->put(exec, exec->propertyNames().constructor, d->errorConstructor, DontEnum | DontDelete | ReadOnly); 222 d->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d->evalErrorConstructor, DontEnum | DontDelete | ReadOnly); 223 d->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly); 224 d->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly); 225 d->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly); 226 d->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d->typeErrorConstructor, DontEnum | DontDelete | ReadOnly); 227 d->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d->URIErrorConstructor, DontEnum | DontDelete | ReadOnly); 228 229 // Set global constructors 230 231 // FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to 232 // see that these values can be put directly without a check for override 233 // properties. 234 235 // FIXME: These properties should be handled by a static hash table. 236 237 putDirect("Object", d->objectConstructor, DontEnum); 238 putDirect("Function", d->functionConstructor, DontEnum); 239 putDirect("Array", d->arrayConstructor, DontEnum); 240 putDirect("Boolean", d->booleanConstructor, DontEnum); 241 putDirect("String", d->stringConstructor, DontEnum); 242 putDirect("Number", d->numberConstructor, DontEnum); 243 putDirect("Date", d->dateConstructor, DontEnum); 244 putDirect("RegExp", d->regExpConstructor, DontEnum); 245 putDirect("Error", d->errorConstructor, DontEnum); 246 putDirect("EvalError", d->evalErrorConstructor, Internal); 247 putDirect("RangeError", d->rangeErrorConstructor, Internal); 248 putDirect("ReferenceError", d->referenceErrorConstructor, Internal); 249 putDirect("SyntaxError", d->syntaxErrorConstructor, Internal); 250 putDirect("TypeError", d->typeErrorConstructor, Internal); 251 putDirect("URIError", d->URIErrorConstructor, Internal); 252 253 // Set global values. 254 255 putDirect("Math", new MathObjectImp(exec, d->objectPrototype), DontEnum); 256 257 putDirect("NaN", jsNaN(), DontEnum | DontDelete); 258 putDirect("Infinity", jsNumber(Inf), DontEnum | DontDelete); 259 putDirect("undefined", jsUndefined(), DontEnum | DontDelete); 260 261 // Set global functions. 262 263 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum); 264 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum); 265 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum); 266 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum); 267 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum); 268 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum); 269 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum); 270 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum); 271 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum); 272 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum); 273 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum); 274 #ifndef NDEBUG 275 putDirectFunction(new GlobalFuncImp(exec, d->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum); 276 #endif 277 278 // Set prototype, and also insert the object prototype at the end of the chain. 279 280 setPrototype(prototype); 281 lastInPrototypeChain(this)->setPrototype(d->objectPrototype); 282 } 283 284 void JSGlobalObject::startTimeoutCheck() 285 { 286 if (!d->timeoutCheckCount) 287 resetTimeoutCheck(); 288 289 ++d->timeoutCheckCount; 290 } 291 292 void JSGlobalObject::stopTimeoutCheck() 293 { 294 --d->timeoutCheckCount; 295 } 296 297 void JSGlobalObject::resetTimeoutCheck() 298 { 299 d->tickCount = 0; 300 d->ticksUntilNextTimeoutCheck = initialTickCountThreshold; 301 d->timeAtLastCheckTimeout = 0; 302 d->timeExecuting = 0; 303 } 304 305 bool JSGlobalObject::checkTimeout() 306 { 307 d->tickCount = 0; 308 309 unsigned currentTime = getCurrentTime(); 310 311 if (!d->timeAtLastCheckTimeout) { 312 // Suspicious amount of looping in a script -- start timing it 313 d->timeAtLastCheckTimeout = currentTime; 314 return false; 315 } 316 317 unsigned timeDiff = currentTime - d->timeAtLastCheckTimeout; 318 319 if (timeDiff == 0) 320 timeDiff = 1; 321 322 d->timeExecuting += timeDiff; 323 d->timeAtLastCheckTimeout = currentTime; 324 325 // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in 326 // preferredScriptCheckTimeInterval 327 d->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d->ticksUntilNextTimeoutCheck; 328 329 // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the 330 // preferred script check time interval. 331 if (d->ticksUntilNextTimeoutCheck == 0) 332 d->ticksUntilNextTimeoutCheck = initialTickCountThreshold; 333 334 if (d->timeoutTime && d->timeExecuting > d->timeoutTime) { 335 if (shouldInterruptScript()) 336 return true; 337 338 resetTimeoutCheck(); 339 } 340 341 return false; 342 } 343 344 void JSGlobalObject::saveBuiltins(SavedBuiltins& builtins) const 345 { 346 if (!builtins._internal) 347 builtins._internal = new SavedBuiltinsInternal; 348 349 builtins._internal->objectConstructor = d->objectConstructor; 350 builtins._internal->functionConstructor = d->functionConstructor; 351 builtins._internal->arrayConstructor = d->arrayConstructor; 352 builtins._internal->booleanConstructor = d->booleanConstructor; 353 builtins._internal->stringConstructor = d->stringConstructor; 354 builtins._internal->numberConstructor = d->numberConstructor; 355 builtins._internal->dateConstructor = d->dateConstructor; 356 builtins._internal->regExpConstructor = d->regExpConstructor; 357 builtins._internal->errorConstructor = d->errorConstructor; 358 builtins._internal->evalErrorConstructor = d->evalErrorConstructor; 359 builtins._internal->rangeErrorConstructor = d->rangeErrorConstructor; 360 builtins._internal->referenceErrorConstructor = d->referenceErrorConstructor; 361 builtins._internal->syntaxErrorConstructor = d->syntaxErrorConstructor; 362 builtins._internal->typeErrorConstructor = d->typeErrorConstructor; 363 builtins._internal->URIErrorConstructor = d->URIErrorConstructor; 364 365 builtins._internal->objectPrototype = d->objectPrototype; 366 builtins._internal->functionPrototype = d->functionPrototype; 367 builtins._internal->arrayPrototype = d->arrayPrototype; 368 builtins._internal->booleanPrototype = d->booleanPrototype; 369 builtins._internal->stringPrototype = d->stringPrototype; 370 builtins._internal->numberPrototype = d->numberPrototype; 371 builtins._internal->datePrototype = d->datePrototype; 372 builtins._internal->regExpPrototype = d->regExpPrototype; 373 builtins._internal->errorPrototype = d->errorPrototype; 374 builtins._internal->evalErrorPrototype = d->evalErrorPrototype; 375 builtins._internal->rangeErrorPrototype = d->rangeErrorPrototype; 376 builtins._internal->referenceErrorPrototype = d->referenceErrorPrototype; 377 builtins._internal->syntaxErrorPrototype = d->syntaxErrorPrototype; 378 builtins._internal->typeErrorPrototype = d->typeErrorPrototype; 379 builtins._internal->URIErrorPrototype = d->URIErrorPrototype; 380 } 381 382 void JSGlobalObject::restoreBuiltins(const SavedBuiltins& builtins) 383 { 384 if (!builtins._internal) 385 return; 386 387 d->objectConstructor = builtins._internal->objectConstructor; 388 d->functionConstructor = builtins._internal->functionConstructor; 389 d->arrayConstructor = builtins._internal->arrayConstructor; 390 d->booleanConstructor = builtins._internal->booleanConstructor; 391 d->stringConstructor = builtins._internal->stringConstructor; 392 d->numberConstructor = builtins._internal->numberConstructor; 393 d->dateConstructor = builtins._internal->dateConstructor; 394 d->regExpConstructor = builtins._internal->regExpConstructor; 395 d->errorConstructor = builtins._internal->errorConstructor; 396 d->evalErrorConstructor = builtins._internal->evalErrorConstructor; 397 d->rangeErrorConstructor = builtins._internal->rangeErrorConstructor; 398 d->referenceErrorConstructor = builtins._internal->referenceErrorConstructor; 399 d->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor; 400 d->typeErrorConstructor = builtins._internal->typeErrorConstructor; 401 d->URIErrorConstructor = builtins._internal->URIErrorConstructor; 402 403 d->objectPrototype = builtins._internal->objectPrototype; 404 d->functionPrototype = builtins._internal->functionPrototype; 405 d->arrayPrototype = builtins._internal->arrayPrototype; 406 d->booleanPrototype = builtins._internal->booleanPrototype; 407 d->stringPrototype = builtins._internal->stringPrototype; 408 d->numberPrototype = builtins._internal->numberPrototype; 409 d->datePrototype = builtins._internal->datePrototype; 410 d->regExpPrototype = builtins._internal->regExpPrototype; 411 d->errorPrototype = builtins._internal->errorPrototype; 412 d->evalErrorPrototype = builtins._internal->evalErrorPrototype; 413 d->rangeErrorPrototype = builtins._internal->rangeErrorPrototype; 414 d->referenceErrorPrototype = builtins._internal->referenceErrorPrototype; 415 d->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype; 416 d->typeErrorPrototype = builtins._internal->typeErrorPrototype; 417 d->URIErrorPrototype = builtins._internal->URIErrorPrototype; 418 } 49 419 50 420 void JSGlobalObject::mark() … … 52 422 JSObject::mark(); 53 423 54 if (m_interpreter->m_currentExec) 55 m_interpreter->m_currentExec->mark(); 56 57 markIfNeeded(m_interpreter->m_globalExec.exception()); 58 59 markIfNeeded(m_interpreter->m_Object); 60 markIfNeeded(m_interpreter->m_Function); 61 markIfNeeded(m_interpreter->m_Array); 62 markIfNeeded(m_interpreter->m_Boolean); 63 markIfNeeded(m_interpreter->m_String); 64 markIfNeeded(m_interpreter->m_Number); 65 markIfNeeded(m_interpreter->m_Date); 66 markIfNeeded(m_interpreter->m_RegExp); 67 markIfNeeded(m_interpreter->m_Error); 68 69 markIfNeeded(m_interpreter->m_ObjectPrototype); 70 markIfNeeded(m_interpreter->m_FunctionPrototype); 71 markIfNeeded(m_interpreter->m_ArrayPrototype); 72 markIfNeeded(m_interpreter->m_BooleanPrototype); 73 markIfNeeded(m_interpreter->m_StringPrototype); 74 markIfNeeded(m_interpreter->m_NumberPrototype); 75 markIfNeeded(m_interpreter->m_DatePrototype); 76 markIfNeeded(m_interpreter->m_RegExpPrototype); 77 markIfNeeded(m_interpreter->m_ErrorPrototype); 78 79 markIfNeeded(m_interpreter->m_EvalError); 80 markIfNeeded(m_interpreter->m_RangeError); 81 markIfNeeded(m_interpreter->m_ReferenceError); 82 markIfNeeded(m_interpreter->m_SyntaxError); 83 markIfNeeded(m_interpreter->m_TypeError); 84 markIfNeeded(m_interpreter->m_UriError); 85 86 markIfNeeded(m_interpreter->m_EvalErrorPrototype); 87 markIfNeeded(m_interpreter->m_RangeErrorPrototype); 88 markIfNeeded(m_interpreter->m_ReferenceErrorPrototype); 89 markIfNeeded(m_interpreter->m_SyntaxErrorPrototype); 90 markIfNeeded(m_interpreter->m_TypeErrorPrototype); 91 markIfNeeded(m_interpreter->m_UriErrorPrototype); 424 if (d->currentExec) 425 d->currentExec->mark(); 426 427 markIfNeeded(d->globalExec.exception()); 428 429 markIfNeeded(d->objectConstructor); 430 markIfNeeded(d->functionConstructor); 431 markIfNeeded(d->arrayConstructor); 432 markIfNeeded(d->booleanConstructor); 433 markIfNeeded(d->stringConstructor); 434 markIfNeeded(d->numberConstructor); 435 markIfNeeded(d->dateConstructor); 436 markIfNeeded(d->regExpConstructor); 437 markIfNeeded(d->errorConstructor); 438 markIfNeeded(d->evalErrorConstructor); 439 markIfNeeded(d->rangeErrorConstructor); 440 markIfNeeded(d->referenceErrorConstructor); 441 markIfNeeded(d->syntaxErrorConstructor); 442 markIfNeeded(d->typeErrorConstructor); 443 markIfNeeded(d->URIErrorConstructor); 444 445 markIfNeeded(d->objectPrototype); 446 markIfNeeded(d->functionPrototype); 447 markIfNeeded(d->arrayPrototype); 448 markIfNeeded(d->booleanPrototype); 449 markIfNeeded(d->stringPrototype); 450 markIfNeeded(d->numberPrototype); 451 markIfNeeded(d->datePrototype); 452 markIfNeeded(d->regExpPrototype); 453 markIfNeeded(d->errorPrototype); 454 markIfNeeded(d->evalErrorPrototype); 455 markIfNeeded(d->rangeErrorPrototype); 456 markIfNeeded(d->referenceErrorPrototype); 457 markIfNeeded(d->syntaxErrorPrototype); 458 markIfNeeded(d->typeErrorPrototype); 459 markIfNeeded(d->URIErrorPrototype); 92 460 } 93 461 94 462 ExecState* JSGlobalObject::globalExec() 95 463 { 96 return & m_interpreter->m_globalExec;464 return &d->globalExec; 97 465 } 98 466 -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r28415 r28468 2 2 /* 3 3 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Apple Inc e. All rights reserved.4 * Copyright (C) 2007 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 28 28 namespace KJS { 29 29 30 class Interpreter; 30 class ArrayObjectImp; 31 class ArrayPrototype; 32 class BooleanObjectImp; 33 class BooleanPrototype; 34 class DateObjectImp; 35 class DatePrototype; 36 class Debugger; 37 class ErrorObjectImp; 38 class ErrorPrototype; 39 class EvalError; 40 class EvalErrorPrototype; 41 class FunctionObjectImp; 42 class FunctionPrototype; 43 class JSGlobalObject; 44 class NativeErrorImp; 45 class NativeErrorPrototype; 46 class NumberObjectImp; 47 class NumberPrototype; 48 class ObjectObjectImp; 49 class ObjectPrototype; 50 class RangeError; 51 class RangeErrorPrototype; 52 class ReferenceError; 53 class ReferenceError; 54 class ReferenceErrorPrototype; 55 class RegExpObjectImp; 56 class RegExpPrototype; 57 class RuntimeMethod; 58 class SavedBuiltins; 59 class ScopeChain; 60 class StringObjectImp; 61 class StringPrototype; 62 class SyntaxErrorPrototype; 63 class TypeError; 64 class TypeErrorPrototype; 65 class UriError; 66 class UriErrorPrototype; 67 68 enum CompatMode { NativeMode, IECompat, NetscapeCompat }; 31 69 32 70 class JSGlobalObject : public JSObject { 71 protected: 72 struct JSGlobalObjectData { 73 JSGlobalObjectData(JSGlobalObject* globalObject) 74 : globalExec(globalObject, globalObject, 0) 75 { 76 } 77 78 JSGlobalObject* next; 79 JSGlobalObject* prev; 80 81 Debugger* debugger; 82 CompatMode compatMode; 83 84 ExecState globalExec; 85 ExecState* currentExec; 86 int recursion; 87 88 unsigned timeoutTime; 89 unsigned timeAtLastCheckTimeout; 90 unsigned timeExecuting; 91 unsigned timeoutCheckCount; 92 unsigned tickCount; 93 unsigned ticksUntilNextTimeoutCheck; 94 95 ObjectObjectImp* objectConstructor; 96 FunctionObjectImp* functionConstructor; 97 ArrayObjectImp* arrayConstructor; 98 BooleanObjectImp* booleanConstructor; 99 StringObjectImp* stringConstructor; 100 NumberObjectImp* numberConstructor; 101 DateObjectImp* dateConstructor; 102 RegExpObjectImp* regExpConstructor; 103 ErrorObjectImp* errorConstructor; 104 NativeErrorImp* evalErrorConstructor; 105 NativeErrorImp* rangeErrorConstructor; 106 NativeErrorImp* referenceErrorConstructor; 107 NativeErrorImp* syntaxErrorConstructor; 108 NativeErrorImp* typeErrorConstructor; 109 NativeErrorImp* URIErrorConstructor; 110 111 ObjectPrototype* objectPrototype; 112 FunctionPrototype* functionPrototype; 113 ArrayPrototype* arrayPrototype; 114 BooleanPrototype* booleanPrototype; 115 StringPrototype* stringPrototype; 116 NumberPrototype* numberPrototype; 117 DatePrototype* datePrototype; 118 RegExpPrototype* regExpPrototype; 119 ErrorPrototype* errorPrototype; 120 NativeErrorPrototype* evalErrorPrototype; 121 NativeErrorPrototype* rangeErrorPrototype; 122 NativeErrorPrototype* referenceErrorPrototype; 123 NativeErrorPrototype* syntaxErrorPrototype; 124 NativeErrorPrototype* typeErrorPrototype; 125 NativeErrorPrototype* URIErrorPrototype; 126 }; 127 33 128 public: 34 JSGlobalObject() { } 35 JSGlobalObject(JSValue* proto) : JSObject(proto) { } 36 37 Interpreter* interpreter() const { return m_interpreter.get(); } 38 void setInterpreter(std::auto_ptr<Interpreter> i) { m_interpreter = i; } 129 JSGlobalObject() 130 { 131 init(); 132 } 133 134 protected: 135 JSGlobalObject(JSValue* proto) 136 : JSObject(proto) 137 { 138 init(); 139 } 140 141 public: 142 virtual ~JSGlobalObject(); 143 144 // Linked list of all global objects. 145 static JSGlobalObject* head() { return s_head; } 146 JSGlobalObject* next() { return d->next; } 147 148 // Resets the global object to contain only built-in properties, sets 149 // the global object's prototype to "prototype," then adds the 150 // default object prototype to the tail of the global object's 151 // prototype chain. 152 void reset(JSValue* prototype); 153 154 // The following accessors return pristine values, even if a script 155 // replaces the global object's associated property. 156 157 ObjectObjectImp* objectConstructor() const { return d->objectConstructor; } 158 FunctionObjectImp* functionConstructor() const { return d->functionConstructor; } 159 ArrayObjectImp* arrayConstructor() const { return d->arrayConstructor; } 160 BooleanObjectImp* booleanConstructor() const { return d->booleanConstructor; } 161 StringObjectImp* stringConstructor() const{ return d->stringConstructor; } 162 NumberObjectImp* numberConstructor() const{ return d->numberConstructor; } 163 DateObjectImp* dateConstructor() const{ return d->dateConstructor; } 164 RegExpObjectImp* regExpConstructor() const { return d->regExpConstructor; } 165 ErrorObjectImp* errorConstructor() const { return d->errorConstructor; } 166 NativeErrorImp* evalErrorConstructor() const { return d->evalErrorConstructor; } 167 NativeErrorImp* rangeErrorConstructor() const { return d->rangeErrorConstructor; } 168 NativeErrorImp* referenceErrorConstructor() const { return d->referenceErrorConstructor; } 169 NativeErrorImp* syntaxErrorConstructor() const { return d->syntaxErrorConstructor; } 170 NativeErrorImp* typeErrorConstructor() const { return d->typeErrorConstructor; } 171 NativeErrorImp* URIErrorConstructor() const { return d->URIErrorConstructor; } 172 173 ObjectPrototype* objectPrototype() const { return d->objectPrototype; } 174 FunctionPrototype* functionPrototype() const { return d->functionPrototype; } 175 ArrayPrototype* arrayPrototype() const { return d->arrayPrototype; } 176 BooleanPrototype* booleanPrototype() const { return d->booleanPrototype; } 177 StringPrototype* stringPrototype() const { return d->stringPrototype; } 178 NumberPrototype* numberPrototype() const { return d->numberPrototype; } 179 DatePrototype* datePrototype() const { return d->datePrototype; } 180 RegExpPrototype* regExpPrototype() const { return d->regExpPrototype; } 181 ErrorPrototype* errorPrototype() const { return d->errorPrototype; } 182 NativeErrorPrototype* evalErrorPrototype() const { return d->evalErrorPrototype; } 183 NativeErrorPrototype* rangeErrorPrototype() const { return d->rangeErrorPrototype; } 184 NativeErrorPrototype* referenceErrorPrototype() const { return d->referenceErrorPrototype; } 185 NativeErrorPrototype* syntaxErrorPrototype() const { return d->syntaxErrorPrototype; } 186 NativeErrorPrototype* typeErrorPrototype() const { return d->typeErrorPrototype; } 187 NativeErrorPrototype* URIErrorPrototype() const { return d->URIErrorPrototype; } 188 189 void saveBuiltins(SavedBuiltins&) const; 190 void restoreBuiltins(const SavedBuiltins&); 191 192 void setTimeoutTime(unsigned timeoutTime) { d->timeoutTime = timeoutTime; } 193 void startTimeoutCheck(); 194 void stopTimeoutCheck(); 195 bool timedOut(); 196 197 Debugger* debugger() const { return d->debugger; } 198 void setDebugger(Debugger* debugger) { d->debugger = debugger; } 199 200 void setCurrentExec(ExecState* exec) { d->currentExec = exec; } 201 ExecState* currentExec() const { return d->currentExec; } 202 203 // FIXME: Let's just pick one compatible behavior and go with it. 204 void setCompatMode(CompatMode mode) { d->compatMode = mode; } 205 CompatMode compatMode() const { return d->compatMode; } 206 207 int recursion() { return d->recursion; } 208 void incRecursion() { ++d->recursion; } 209 void decRecursion() { --d->recursion; } 39 210 40 211 virtual void mark(); … … 48 219 virtual bool isSafeScript(const JSGlobalObject*) const { return true; } 49 220 221 protected: 222 std::auto_ptr<JSGlobalObjectData> d; 223 50 224 private: 51 std::auto_ptr<Interpreter> m_interpreter; 225 void init(); 226 227 bool checkTimeout(); 228 void resetTimeoutCheck(); 229 230 static JSGlobalObject* s_head; 52 231 }; 53 232 233 inline bool JSGlobalObject::timedOut() 234 { 235 d->tickCount++; 236 237 if (d->tickCount != d->ticksUntilNextTimeoutCheck) 238 return false; 239 240 return checkTimeout(); 241 } 242 54 243 } // namespace KJS 55 244 -
trunk/JavaScriptCore/kjs/JSImmediate.cpp
r26688 r28468 37 37 List args; 38 38 args.append(const_cast<JSValue *>(v)); 39 return exec->lexical Interpreter()->builtinBoolean()->construct(exec, args);39 return exec->lexicalGlobalObject()->booleanConstructor()->construct(exec, args); 40 40 } else { 41 41 ASSERT(isNumber(v)); 42 42 List args; 43 43 args.append(const_cast<JSValue *>(v)); 44 return exec->lexical Interpreter()->builtinNumber()->construct(exec, args);44 return exec->lexicalGlobalObject()->numberConstructor()->construct(exec, args); 45 45 } 46 46 } -
trunk/JavaScriptCore/kjs/JSLock.h
r20351 r28468 21 21 */ 22 22 23 #ifndef KJS_ INTERPRETER_LOCK_H24 #define KJS_ INTERPRETER_LOCK_H23 #ifndef KJS_JSLock_h 24 #define KJS_JSLock_h 25 25 26 26 #include <wtf/Assertions.h> … … 79 79 } // namespace 80 80 81 #endif // KJS_ INTERPRETER_LOCK_H81 #endif // KJS_JSLock_h -
trunk/JavaScriptCore/kjs/SavedBuiltins.h
r19901 r28468 27 27 28 28 #include "protect.h" 29 #include "object_object.h" 30 #include "string_object.h" 31 #include "error_object.h" 32 #include "regexp_object.h" 33 #include "array_object.h" 34 #include "bool_object.h" 35 #include "date_object.h" 36 #include "number_object.h" 37 #include "math_object.h" 29 38 30 39 namespace KJS { 31 40 32 class SavedBuiltinsInternal; 41 struct SavedBuiltinsInternal { 42 ProtectedPtr<ObjectObjectImp> objectConstructor; 43 ProtectedPtr<FunctionObjectImp> functionConstructor; 44 ProtectedPtr<ArrayObjectImp> arrayConstructor; 45 ProtectedPtr<BooleanObjectImp> booleanConstructor; 46 ProtectedPtr<StringObjectImp> stringConstructor; 47 ProtectedPtr<NumberObjectImp> numberConstructor; 48 ProtectedPtr<DateObjectImp> dateConstructor; 49 ProtectedPtr<RegExpObjectImp> regExpConstructor; 50 ProtectedPtr<ErrorObjectImp> errorConstructor; 51 ProtectedPtr<NativeErrorImp> evalErrorConstructor; 52 ProtectedPtr<NativeErrorImp> rangeErrorConstructor; 53 ProtectedPtr<NativeErrorImp> referenceErrorConstructor; 54 ProtectedPtr<NativeErrorImp> syntaxErrorConstructor; 55 ProtectedPtr<NativeErrorImp> typeErrorConstructor; 56 ProtectedPtr<NativeErrorImp> URIErrorConstructor; 57 58 ProtectedPtr<ObjectPrototype> objectPrototype; 59 ProtectedPtr<FunctionPrototype> functionPrototype; 60 ProtectedPtr<ArrayPrototype> arrayPrototype; 61 ProtectedPtr<BooleanPrototype> booleanPrototype; 62 ProtectedPtr<StringPrototype> stringPrototype; 63 ProtectedPtr<NumberPrototype> numberPrototype; 64 ProtectedPtr<DatePrototype> datePrototype; 65 ProtectedPtr<RegExpPrototype> regExpPrototype; 66 ProtectedPtr<ErrorPrototype> errorPrototype; 67 ProtectedPtr<NativeErrorPrototype> evalErrorPrototype; 68 ProtectedPtr<NativeErrorPrototype> rangeErrorPrototype; 69 ProtectedPtr<NativeErrorPrototype> referenceErrorPrototype; 70 ProtectedPtr<NativeErrorPrototype> syntaxErrorPrototype; 71 ProtectedPtr<NativeErrorPrototype> typeErrorPrototype; 72 ProtectedPtr<NativeErrorPrototype> URIErrorPrototype; 73 }; 33 74 34 75 class SavedBuiltins { 35 friend class Interpreter;76 friend class JSGlobalObject; 36 77 public: 37 SavedBuiltins(); 38 ~SavedBuiltins(); 78 SavedBuiltins() 79 : _internal(0) 80 { 81 } 82 83 ~SavedBuiltins() 84 { 85 delete _internal; 86 } 87 39 88 private: 40 SavedBuiltinsInternal *_internal; 41 }; 42 43 class SavedBuiltinsInternal { 44 friend class Interpreter; 45 private: 46 ProtectedPtr<ObjectObjectImp> m_Object; 47 ProtectedPtr<FunctionObjectImp> m_Function; 48 ProtectedPtr<ArrayObjectImp> m_Array; 49 ProtectedPtr<BooleanObjectImp> m_Boolean; 50 ProtectedPtr<StringObjectImp> m_String; 51 ProtectedPtr<NumberObjectImp> m_Number; 52 ProtectedPtr<DateObjectImp> m_Date; 53 ProtectedPtr<RegExpObjectImp> m_RegExp; 54 ProtectedPtr<ErrorObjectImp> m_Error; 55 56 ProtectedPtr<ObjectPrototype> m_ObjectPrototype; 57 ProtectedPtr<FunctionPrototype> m_FunctionPrototype; 58 ProtectedPtr<ArrayPrototype> m_ArrayPrototype; 59 ProtectedPtr<BooleanPrototype> m_BooleanPrototype; 60 ProtectedPtr<StringPrototype> m_StringPrototype; 61 ProtectedPtr<NumberPrototype> m_NumberPrototype; 62 ProtectedPtr<DatePrototype> m_DatePrototype; 63 ProtectedPtr<RegExpPrototype> m_RegExpPrototype; 64 ProtectedPtr<ErrorPrototype> m_ErrorPrototype; 65 66 ProtectedPtr<NativeErrorImp> m_EvalError; 67 ProtectedPtr<NativeErrorImp> m_RangeError; 68 ProtectedPtr<NativeErrorImp> m_ReferenceError; 69 ProtectedPtr<NativeErrorImp> m_SyntaxError; 70 ProtectedPtr<NativeErrorImp> m_TypeError; 71 ProtectedPtr<NativeErrorImp> m_UriError; 72 73 ProtectedPtr<NativeErrorPrototype> m_EvalErrorPrototype; 74 ProtectedPtr<NativeErrorPrototype> m_RangeErrorPrototype; 75 ProtectedPtr<NativeErrorPrototype> m_ReferenceErrorPrototype; 76 ProtectedPtr<NativeErrorPrototype> m_SyntaxErrorPrototype; 77 ProtectedPtr<NativeErrorPrototype> m_TypeErrorPrototype; 78 ProtectedPtr<NativeErrorPrototype> m_UriErrorPrototype; 89 SavedBuiltinsInternal* _internal; 79 90 }; 80 91 -
trunk/JavaScriptCore/kjs/array_instance.cpp
r28346 r28468 484 484 : exec(e) 485 485 , compareFunction(cf) 486 , globalObject(e->dynamic Interpreter()->globalObject())486 , globalObject(e->dynamicGlobalObject()) 487 487 { 488 488 } -
trunk/JavaScriptCore/kjs/array_object.cpp
r27608 r28468 226 226 JSValue* ArrayProtoFuncConcat::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) 227 227 { 228 JSObject* arr = static_cast<JSObject*>(exec->lexical Interpreter()->builtinArray()->construct(exec, List::empty()));228 JSObject* arr = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, List::empty())); 229 229 int n = 0; 230 230 JSValue *curArg = thisObj; … … 334 334 335 335 // We return a new array 336 JSObject *resObj = static_cast<JSObject *>(exec->lexical Interpreter()->builtinArray()->construct(exec,List::empty()));336 JSObject *resObj = static_cast<JSObject *>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec,List::empty())); 337 337 JSValue* result = resObj; 338 338 double begin = args[0]->toInteger(exec); … … 421 421 l.append(jObj); 422 422 l.append(minObj); 423 cmp = sortFunction->call(exec, exec->dynamic Interpreter()->globalObject(), l)->toNumber(exec);423 cmp = sortFunction->call(exec, exec->dynamicGlobalObject(), l)->toNumber(exec); 424 424 } else { 425 425 cmp = (jObj->toString(exec) < minObj->toString(exec)) ? -1 : 1; … … 450 450 { 451 451 // 15.4.4.12 - oh boy this is huge 452 JSObject *resObj = static_cast<JSObject *>(exec->lexical Interpreter()->builtinArray()->construct(exec, List::empty()));452 JSObject *resObj = static_cast<JSObject *>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, List::empty())); 453 453 JSValue* result = resObj; 454 454 unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); … … 527 527 return throwError(exec, TypeError); 528 528 529 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamic Interpreter()->globalObject() : args[1]->toObject(exec);530 JSObject *resultArray = static_cast<JSObject*>(exec->lexical Interpreter()->builtinArray()->construct(exec, List::empty()));529 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); 530 JSObject *resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, List::empty())); 531 531 532 532 unsigned filterIndex = 0; … … 560 560 return throwError(exec, TypeError); 561 561 562 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamic Interpreter()->globalObject() : args[1]->toObject(exec);562 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); 563 563 564 564 unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); … … 566 566 List mapArgs; 567 567 mapArgs.append(jsNumber(length)); 568 JSObject* resultArray = static_cast<JSObject*>(exec->lexical Interpreter()->builtinArray()->construct(exec, mapArgs));568 JSObject* resultArray = static_cast<JSObject*>(exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, mapArgs)); 569 569 570 570 for (unsigned k = 0; k < length && !exec->hadException(); ++k) { … … 600 600 return throwError(exec, TypeError); 601 601 602 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamic Interpreter()->globalObject() : args[1]->toObject(exec);602 JSObject *applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); 603 603 604 604 JSValue* result = jsBoolean(true); … … 635 635 return throwError(exec, TypeError); 636 636 637 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamic Interpreter()->globalObject() : args[1]->toObject(exec);637 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); 638 638 639 639 unsigned length = thisObj->get(exec, exec->propertyNames().length)->toUInt32(exec); … … 660 660 return throwError(exec, TypeError); 661 661 662 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamic Interpreter()->globalObject() : args[1]->toObject(exec);662 JSObject* applyThis = args[1]->isUndefinedOrNull() ? exec->dynamicGlobalObject() : args[1]->toObject(exec); 663 663 664 664 JSValue* result = jsBoolean(false); … … 770 770 if (n != args[0]->toNumber(exec)) 771 771 return throwError(exec, RangeError, "Array size is not a small enough positive integer."); 772 return new ArrayInstance(exec->lexical Interpreter()->builtinArrayPrototype(), n);772 return new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), n); 773 773 } 774 774 775 775 // otherwise the array is constructed with the arguments in it 776 return new ArrayInstance(exec->lexical Interpreter()->builtinArrayPrototype(), args);776 return new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), args); 777 777 } 778 778 -
trunk/JavaScriptCore/kjs/bool_object.cpp
r28110 r28468 46 46 : BooleanInstance(objectProto) 47 47 { 48 // The constructor will be added later by Interpreter::Interpreter()49 50 48 putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ToString, 0, exec->propertyNames().toString), DontEnum); 51 49 putDirectFunction(new BooleanProtoFunc(exec, funcProto, BooleanProtoFunc::ValueOf, 0, exec->propertyNames().valueOf), DontEnum); … … 102 100 JSObject *BooleanObjectImp::construct(ExecState *exec, const List &args) 103 101 { 104 BooleanInstance *obj(new BooleanInstance(exec->lexical Interpreter()->builtinBooleanPrototype()));102 BooleanInstance *obj(new BooleanInstance(exec->lexicalGlobalObject()->booleanPrototype())); 105 103 106 104 bool b; -
trunk/JavaScriptCore/kjs/collector.cpp
r28329 r28468 963 963 bool newMemoryFull = (numLiveObjects >= KJS_MEM_LIMIT); 964 964 if (newMemoryFull && newMemoryFull != memoryFull) 965 reportOutOfMemoryToAll Interpreters();965 reportOutOfMemoryToAllExecStates(); 966 966 memoryFull = newMemoryFull; 967 967 … … 974 974 } 975 975 976 size_t Collector::num Interpreters()976 size_t Collector::numGlobalObjects() 977 977 { 978 978 size_t count = 0; 979 if ( Interpreter::s_hook) {980 Interpreter* scr = Interpreter::s_hook;979 if (JSGlobalObject::head()) { 980 JSGlobalObject* o = JSGlobalObject::head(); 981 981 do { 982 982 ++count; 983 scr = scr->next;984 } while ( scr != Interpreter::s_hook);983 o = o->next(); 984 } while (o != JSGlobalObject::head()); 985 985 } 986 986 return count; … … 1042 1042 } 1043 1043 1044 void Collector::reportOutOfMemoryToAllInterpreters() 1045 { 1046 if (!Interpreter::s_hook) 1044 void Collector::reportOutOfMemoryToAllExecStates() 1045 { 1046 JSGlobalObject* o = JSGlobalObject::head(); 1047 if (!o) 1047 1048 return; 1048 1049 1049 Interpreter* interpreter = Interpreter::s_hook;1050 1050 do { 1051 ExecState* exec = interpreter->currentExec() ? interpreter->currentExec() : interpreter->globalObject()->globalExec(); 1052 1051 ExecState* exec = o->currentExec() ? o->currentExec() : o->globalExec(); 1053 1052 exec->setException(Error::create(exec, GeneralError, "Out of memory")); 1054 1055 interpreter = interpreter->next; 1056 } while(interpreter != Interpreter::s_hook); 1053 o = o->next(); 1054 } while(o != JSGlobalObject::head()); 1057 1055 } 1058 1056 -
trunk/JavaScriptCore/kjs/collector.h
r28110 r28468 55 55 static void collectOnMainThreadOnly(JSValue*); 56 56 57 static size_t num Interpreters();57 static size_t numGlobalObjects(); 58 58 static size_t numProtectedObjects(); 59 59 static HashCountedSet<const char*>* rootObjectTypeCounts(); … … 88 88 static size_t mainThreadOnlyObjectCount; 89 89 static bool memoryFull; 90 static void reportOutOfMemoryToAll Interpreters();90 static void reportOutOfMemoryToAllExecStates(); 91 91 }; 92 92 -
trunk/JavaScriptCore/kjs/date_object.cpp
r27947 r28468 503 503 } 504 504 505 DateInstance *ret = new DateInstance(exec->lexical Interpreter()->builtinDatePrototype());505 DateInstance *ret = new DateInstance(exec->lexicalGlobalObject()->datePrototype()); 506 506 ret->setInternalValue(jsNumber(timeClip(value))); 507 507 return ret; … … 1807 1807 1808 1808 // IE returns the full year even in getYear. 1809 if (exec->dynamic Interpreter()->compatMode() == Interpreter::IECompat)1809 if (exec->dynamicGlobalObject()->compatMode() == IECompat) 1810 1810 return jsNumber(1900 + t.year); 1811 1811 return jsNumber(t.year); -
trunk/JavaScriptCore/kjs/debugger.cpp
r17372 r28468 32 32 33 33 namespace KJS { 34 struct Attached Interpreter34 struct AttachedGlobalObject 35 35 { 36 36 public: 37 Attached Interpreter(Interpreter *i, AttachedInterpreter *ai) : interp(i), next(ai) { ++Debugger::debuggersPresent; }38 ~Attached Interpreter() { --Debugger::debuggersPresent; }39 Interpreter *interp;40 Attached Interpreter *next;37 AttachedGlobalObject(JSGlobalObject* o, AttachedGlobalObject* ai) : globalObj(o), next(ai) { ++Debugger::debuggersPresent; } 38 ~AttachedGlobalObject() { --Debugger::debuggersPresent; } 39 JSGlobalObject* globalObj; 40 AttachedGlobalObject* next; 41 41 }; 42 42 … … 56 56 } 57 57 58 void Debugger::attach( Interpreter* interp)58 void Debugger::attach(JSGlobalObject* globalObject) 59 59 { 60 Debugger *other = interp->debugger();60 Debugger* other = globalObject->debugger(); 61 61 if (other == this) 62 62 return; 63 63 if (other) 64 other->detach( interp);65 interp->setDebugger(this);66 rep-> interps = new AttachedInterpreter(interp, rep->interps);64 other->detach(globalObject); 65 globalObject->setDebugger(this); 66 rep->globalObjects = new AttachedGlobalObject(globalObject, rep->globalObjects); 67 67 } 68 68 69 void Debugger::detach( Interpreter* interp)69 void Debugger::detach(JSGlobalObject* globalObj) 70 70 { 71 // iterate the addresses where Attached Interpreterpointers are stored71 // iterate the addresses where AttachedGlobalObject pointers are stored 72 72 // so we can unlink items from the list 73 Attached Interpreter **p = &rep->interps;74 Attached Interpreter*q;73 AttachedGlobalObject **p = &rep->globalObjects; 74 AttachedGlobalObject *q; 75 75 while ((q = *p)) { 76 if (! interp || q->interp == interp) {76 if (!globalObj || q->globalObj == globalObj) { 77 77 *p = q->next; 78 q-> interp->setDebugger(0);78 q->globalObj->setDebugger(0); 79 79 delete q; 80 80 } else … … 82 82 } 83 83 84 if ( interp)85 latestExceptions.remove( interp);84 if (globalObj) 85 latestExceptions.remove(globalObj); 86 86 else 87 87 latestExceptions.clear(); … … 90 90 bool Debugger::hasHandledException(ExecState *exec, JSValue *exception) 91 91 { 92 if (latestExceptions.get(exec->dynamic Interpreter()).get() == exception)92 if (latestExceptions.get(exec->dynamicGlobalObject()).get() == exception) 93 93 return true; 94 94 95 latestExceptions.set(exec->dynamic Interpreter(), exception);95 latestExceptions.set(exec->dynamicGlobalObject(), exception); 96 96 return false; 97 97 } -
trunk/JavaScriptCore/kjs/debugger.h
r15593 r28468 30 30 31 31 class DebuggerImp; 32 class Interpreter;33 32 class ExecState; 34 33 class JSObject; … … 59 58 60 59 /** 61 * Destroys the debugger. If the debugger is attached to any interpreters,60 * Destroys the debugger. If the debugger is attached to any global objects, 62 61 * it is automatically detached. 63 62 */ … … 67 66 68 67 /** 69 * Attaches the debugger to specified interpreter. This will cause this 70 * object to receive notification of events from the interpreter. 71 * 72 * If the interpreter is deleted, the debugger will automatically be 73 * detached. 74 * 75 * Note: only one debugger can be attached to an interpreter at a time. 76 * Attaching another debugger to the same interpreter will cause the 77 * original debugger to be detached from that interpreter. 78 * 79 * @param interp The interpreter to attach to 68 * Attaches the debugger to specified global object. This will cause this 69 * object to receive notification of events during execution. 70 * 71 * If the global object is deleted, it will detach the debugger. 72 * 73 * Note: only one debugger can be attached to a global object at a time. 74 * Attaching another debugger to the same global object will cause the 75 * original debugger to be detached. 76 * 77 * @param The global object to attach to. 80 78 * 81 79 * @see detach() 82 80 */ 83 void attach( Interpreter *interp);84 85 /** 86 * Detach the debugger from a n interpreter87 * 88 * @param interp The interpreterto detach from. If 0, the debugger will be89 * detached from all interpreters to which it is attached.81 void attach(JSGlobalObject*); 82 83 /** 84 * Detach the debugger from a global object. 85 * 86 * @param The global object to detach from. If 0, the debugger will be 87 * detached from all global objects to which it is attached. 90 88 * 91 89 * @see attach() 92 90 */ 93 void detach( Interpreter *interp);91 void detach(JSGlobalObject*); 94 92 95 93 /** … … 216 214 private: 217 215 DebuggerImp *rep; 218 HashMap< Interpreter*, ProtectedPtr<JSValue> > latestExceptions;216 HashMap<JSGlobalObject*, ProtectedPtr<JSValue> > latestExceptions; 219 217 220 218 public: -
trunk/JavaScriptCore/kjs/error_object.cpp
r28110 r28468 25 25 #include "object.h" 26 26 #include "types.h" 27 #include "interpreter.h"28 27 #include "operations.h" 29 28 #include "error_object.h" … … 99 98 JSObject* ErrorObjectImp::construct(ExecState* exec, const List &args) 100 99 { 101 JSObject* proto = static_cast<JSObject*>(exec->lexical Interpreter()->builtinErrorPrototype());100 JSObject* proto = static_cast<JSObject*>(exec->lexicalGlobalObject()->errorPrototype()); 102 101 JSObject* imp = new ErrorInstance(proto); 103 102 JSObject* obj(imp); -
trunk/JavaScriptCore/kjs/function.cpp
r28458 r28468 56 56 57 57 FunctionImp::FunctionImp(ExecState* exec, const Identifier& name, FunctionBodyNode* b, const ScopeChain& sc) 58 : InternalFunctionImp( static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name)58 : InternalFunctionImp(exec->lexicalGlobalObject()->functionPrototype(), name) 59 59 , body(b) 60 60 , _scope(sc) … … 70 70 JSValue* FunctionImp::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) 71 71 { 72 JSGlobalObject* globalObj = exec->dynamicInterpreter()->globalObject();73 74 72 // enter a new execution context 75 ExecState newExec(exec->dynamicInterpreter(), globalObj, thisObj, body.get(), 76 FunctionCode, exec, this, &args); 73 ExecState newExec(exec->dynamicGlobalObject(), thisObj, body.get(), FunctionCode, exec, exec->dynamicGlobalObject()->currentExec(), this, &args); 77 74 if (exec->hadException()) 78 75 newExec.setException(exec->exception()); … … 205 202 proto = static_cast<JSObject*>(p); 206 203 else 207 proto = exec->lexical Interpreter()->builtinObjectPrototype();204 proto = exec->lexicalGlobalObject()->objectPrototype(); 208 205 209 206 JSObject* obj(new JSObject(proto)); … … 300 297 // ECMA 10.1.8 301 298 Arguments::Arguments(ExecState* exec, FunctionImp* func, const List& args, ActivationImp* act) 302 : JSObject(exec->lexical Interpreter()->builtinObjectPrototype()),299 : JSObject(exec->lexicalGlobalObject()->objectPrototype()), 303 300 _activationObject(act), 304 301 indexToNameMap(func, args) … … 745 742 RefPtr<ProgramNode> progNode(parser().parseProgram(UString(), 0, s.data(), s.size(), &sourceId, &errLine, &errMsg)); 746 743 747 Debugger* dbg = exec->dynamic Interpreter()->debugger();744 Debugger* dbg = exec->dynamicGlobalObject()->debugger(); 748 745 if (dbg) { 749 746 bool cont = dbg->sourceParsed(exec, sourceId, UString(), s, 0, errLine, errMsg); … … 756 753 return throwError(exec, SyntaxError, errMsg, errLine, sourceId, NULL); 757 754 758 bool switchGlobal = thisObj && thisObj != exec->dynamic Interpreter()->globalObject();759 755 bool switchGlobal = thisObj && thisObj != exec->dynamicGlobalObject() && thisObj->isGlobalObject(); 756 760 757 // enter a new execution context 761 Interpreter* interpreter = switchGlobal ? static_cast<JSGlobalObject*>(thisObj)->interpreter() : exec->dynamicInterpreter();758 JSGlobalObject* globalObject = switchGlobal ? static_cast<JSGlobalObject*>(thisObj) : exec->dynamicGlobalObject(); 762 759 JSObject* thisVal = static_cast<JSObject*>(exec->thisValue()); 763 ExecState newExec( interpreter, interpreter->globalObject(), thisVal, progNode.get(), EvalCode, exec);760 ExecState newExec(globalObject, thisVal, progNode.get(), EvalCode, exec, globalObject->currentExec()); 764 761 if (exec->hadException()) 765 762 newExec.setException(exec->exception()); -
trunk/JavaScriptCore/kjs/function_object.cpp
r27842 r28468 104 104 JSObject *applyThis; 105 105 if (thisArg->isUndefinedOrNull()) 106 applyThis = exec->dynamic Interpreter()->globalObject();106 applyThis = exec->dynamicGlobalObject(); 107 107 else 108 108 applyThis = thisArg->toObject(exec); … … 134 134 JSObject *callThis; 135 135 if (thisArg->isUndefinedOrNull()) 136 callThis = exec->dynamic Interpreter()->globalObject();136 callThis = exec->dynamicGlobalObject(); 137 137 else 138 138 callThis = thisArg->toObject(exec); … … 192 192 193 193 // notify debugger that source has been parsed 194 Debugger *dbg = exec->dynamic Interpreter()->debugger();194 Debugger *dbg = exec->dynamicGlobalObject()->debugger(); 195 195 if (dbg) { 196 196 // send empty sourceURL to indicate constructed code … … 209 209 210 210 ScopeChain scopeChain; 211 scopeChain.push(exec->lexical Interpreter()->globalObject());211 scopeChain.push(exec->lexicalGlobalObject()); 212 212 213 213 FunctionImp* fimp = new FunctionImp(exec, functionName, functionBody.get(), scopeChain); … … 246 246 List consArgs; 247 247 248 JSObject* objCons = exec->lexical Interpreter()->builtinObject();248 JSObject* objCons = exec->lexicalGlobalObject()->objectConstructor(); 249 249 JSObject* prototype = objCons->construct(exec,List::empty()); 250 250 prototype->put(exec, exec->propertyNames().constructor, fimp, DontEnum|DontDelete|ReadOnly); -
trunk/JavaScriptCore/kjs/grammar.y
r27842 r28468 29 29 #include "object.h" 30 30 #include "types.h" 31 #include "interpreter.h"32 31 #include "nodes.h" 33 32 #include "lexer.h" -
trunk/JavaScriptCore/kjs/internal.cpp
r28110 r28468 81 81 JSObject* StringImp::toObject(ExecState *exec) const 82 82 { 83 return new StringInstance(exec->lexical Interpreter()->builtinStringPrototype(), const_cast<StringImp*>(this));83 return new StringInstance(exec->lexicalGlobalObject()->stringPrototype(), const_cast<StringImp*>(this)); 84 84 } 85 85 … … 119 119 List args; 120 120 args.append(const_cast<NumberImp*>(this)); 121 return static_cast<JSObject *>(exec->lexical Interpreter()->builtinNumber()->construct(exec,args));121 return static_cast<JSObject *>(exec->lexicalGlobalObject()->numberConstructor()->construct(exec,args)); 122 122 } 123 123 -
trunk/JavaScriptCore/kjs/internal.h
r27695 r28468 26 26 27 27 #include "JSType.h" 28 #include "interpreter.h"29 28 #include "object.h" 30 29 #include "protect.h" … … 99 98 // --------------------------------------------------------------------------- 100 99 101 struct Attached Interpreter;100 struct AttachedGlobalObject; 102 101 class DebuggerImp { 103 102 public: 104 103 105 104 DebuggerImp() { 106 interps = 0;105 globalObjects = 0; 107 106 isAborted = false; 108 107 } … … 111 110 bool aborted() const { return isAborted; } 112 111 113 Attached Interpreter *interps;112 AttachedGlobalObject* globalObjects; 114 113 bool isAborted; 115 114 }; -
trunk/JavaScriptCore/kjs/interpreter.cpp
r28328 r28468 4 4 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 5 5 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 6 * Copyright (C) 2003 Apple Computer,Inc.6 * Copyright (C) 2003, 2007 Apple Inc. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 67 67 namespace KJS { 68 68 69 // Default number of ticks before a timeout check should be done. 70 static const int initialTickCountThreshold = 255; 71 72 // Preferred number of milliseconds between each timeout check 73 static const int preferredScriptCheckTimeInterval = 1000; 74 75 Interpreter* Interpreter::s_hook = 0; 76 77 typedef HashMap<JSObject*, Interpreter*> InterpreterMap; 78 static inline InterpreterMap &interpreterMap() 69 Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UString& code) 79 70 { 80 static InterpreterMap* map = new InterpreterMap; 81 return* map; 71 return checkSyntax(exec, sourceURL, startingLineNumber, code.data(), code.size()); 82 72 } 83 73 84 Interpreter::Interpreter() 85 : m_globalExec(this, 0, 0, 0) 86 , m_currentExec(0) 87 , m_globalObject(0) 88 { 89 init(); 90 } 91 92 void Interpreter::init() 93 { 94 JSLock lock; 95 96 m_timeoutTime = 0; 97 m_recursion = 0; 98 m_debugger= 0; 99 100 resetTimeoutCheck(); 101 m_timeoutCheckCount = 0; 102 103 m_compatMode = NativeMode; 104 105 if (s_hook) { 106 prev = s_hook; 107 next = s_hook->next; 108 s_hook->next->prev = this; 109 s_hook->next = this; 110 } else { 111 // This is the first interpreter 112 s_hook = next = prev = this; 113 } 114 115 createObjectsForGlobalObjectProperties(); 116 } 117 118 Interpreter::~Interpreter() 119 { 120 JSLock lock; 121 122 if (m_debugger) 123 m_debugger->detach(this); 124 125 next->prev = prev; 126 prev->next = next; 127 s_hook = next; 128 if (s_hook == this) { 129 // This was the last interpreter 130 s_hook = 0; 131 } 132 } 133 134 JSGlobalObject* Interpreter::globalObject() const 135 { 136 // Now that we delay setting of the global object, people retrieving it before it is set may be in for a nasty surprise 137 ASSERT(m_globalObject); 138 return m_globalObject; 139 } 140 141 void Interpreter::setGlobalObject(JSGlobalObject* globalObject) 142 { 143 ASSERT(!m_globalObject); 144 ASSERT(globalObject); 145 m_globalObject = globalObject; 146 m_globalExec.setGlobalObject(globalObject); 147 148 setGlobalObjectProperties(); 149 } 150 151 void Interpreter::resetGlobalObjectProperties() 152 { 153 ASSERT(m_globalObject); 154 createObjectsForGlobalObjectProperties(); 155 setGlobalObjectProperties(); 156 } 157 158 void Interpreter::createObjectsForGlobalObjectProperties() 159 { 160 // Clear before inititalizing, to avoid marking uninitialized (dangerous) or 161 // stale (wasteful) pointers during initialization. 162 163 // Prototypes 164 m_FunctionPrototype = 0; 165 m_ObjectPrototype = 0; 166 167 m_ArrayPrototype = 0; 168 m_StringPrototype = 0; 169 m_BooleanPrototype = 0; 170 m_NumberPrototype = 0; 171 m_DatePrototype = 0; 172 m_RegExpPrototype = 0; 173 m_ErrorPrototype = 0; 174 175 m_EvalErrorPrototype = 0; 176 m_RangeErrorPrototype = 0; 177 m_ReferenceErrorPrototype = 0; 178 m_SyntaxErrorPrototype = 0; 179 m_TypeErrorPrototype = 0; 180 m_UriErrorPrototype = 0; 181 182 // Constructors 183 m_Object = 0; 184 m_Function = 0; 185 m_Array = 0; 186 m_String = 0; 187 m_Boolean = 0; 188 m_Number = 0; 189 m_Date = 0; 190 m_RegExp = 0; 191 m_Error = 0; 192 193 m_EvalError = 0; 194 m_RangeError = 0; 195 m_ReferenceError = 0; 196 m_SyntaxError = 0; 197 m_TypeError = 0; 198 m_UriError = 0; 199 200 // Prototypes 201 m_FunctionPrototype = new FunctionPrototype(&m_globalExec); 202 m_ObjectPrototype = new ObjectPrototype(&m_globalExec, m_FunctionPrototype); 203 m_FunctionPrototype->setPrototype(m_ObjectPrototype); 204 205 m_ArrayPrototype = new ArrayPrototype(&m_globalExec, m_ObjectPrototype); 206 m_StringPrototype = new StringPrototype(&m_globalExec, m_ObjectPrototype); 207 m_BooleanPrototype = new BooleanPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype); 208 m_NumberPrototype = new NumberPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype); 209 m_DatePrototype = new DatePrototype(&m_globalExec, m_ObjectPrototype); 210 m_RegExpPrototype = new RegExpPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype);; 211 m_ErrorPrototype = new ErrorPrototype(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype); 212 213 m_EvalErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, EvalError, "EvalError", "EvalError"); 214 m_RangeErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, RangeError, "RangeError", "RangeError"); 215 m_ReferenceErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, ReferenceError, "ReferenceError", "ReferenceError"); 216 m_SyntaxErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, SyntaxError, "SyntaxError", "SyntaxError"); 217 m_TypeErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, TypeError, "TypeError", "TypeError"); 218 m_UriErrorPrototype = new NativeErrorPrototype(&m_globalExec, m_ErrorPrototype, URIError, "URIError", "URIError"); 219 220 // Constructors 221 m_Object = new ObjectObjectImp(&m_globalExec, m_ObjectPrototype, m_FunctionPrototype); 222 m_Function = new FunctionObjectImp(&m_globalExec, m_FunctionPrototype); 223 m_Array = new ArrayObjectImp(&m_globalExec, m_FunctionPrototype, m_ArrayPrototype); 224 m_String = new StringObjectImp(&m_globalExec, m_FunctionPrototype, m_StringPrototype); 225 m_Boolean = new BooleanObjectImp(&m_globalExec, m_FunctionPrototype, m_BooleanPrototype); 226 m_Number = new NumberObjectImp(&m_globalExec, m_FunctionPrototype, m_NumberPrototype); 227 m_Date = new DateObjectImp(&m_globalExec, m_FunctionPrototype, m_DatePrototype); 228 m_RegExp = new RegExpObjectImp(&m_globalExec, m_FunctionPrototype, m_RegExpPrototype); 229 m_Error = new ErrorObjectImp(&m_globalExec, m_FunctionPrototype, m_ErrorPrototype); 230 231 m_EvalError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_EvalErrorPrototype); 232 m_RangeError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_RangeErrorPrototype); 233 m_ReferenceError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_ReferenceErrorPrototype); 234 m_SyntaxError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_SyntaxErrorPrototype); 235 m_TypeError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_TypeErrorPrototype); 236 m_UriError = new NativeErrorImp(&m_globalExec, m_FunctionPrototype, m_UriErrorPrototype); 237 238 m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum); 239 m_ObjectPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Object, DontEnum | DontDelete | ReadOnly); 240 m_FunctionPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Function, DontEnum | DontDelete | ReadOnly); 241 m_ArrayPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Array, DontEnum | DontDelete | ReadOnly); 242 m_BooleanPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Boolean, DontEnum | DontDelete | ReadOnly); 243 m_StringPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_String, DontEnum | DontDelete | ReadOnly); 244 m_NumberPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Number, DontEnum | DontDelete | ReadOnly); 245 m_DatePrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Date, DontEnum | DontDelete | ReadOnly); 246 m_RegExpPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RegExp, DontEnum | DontDelete | ReadOnly); 247 m_ErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_Error, DontEnum | DontDelete | ReadOnly); 248 m_EvalErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_EvalError, DontEnum | DontDelete | ReadOnly); 249 m_RangeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_RangeError, DontEnum | DontDelete | ReadOnly); 250 m_ReferenceErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_ReferenceError, DontEnum | DontDelete | ReadOnly); 251 m_SyntaxErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_SyntaxError, DontEnum | DontDelete | ReadOnly); 252 m_TypeErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_TypeError, DontEnum | DontDelete | ReadOnly); 253 m_UriErrorPrototype->put(&m_globalExec, m_globalExec.propertyNames().constructor, m_UriError, DontEnum | DontDelete | ReadOnly); 254 } 255 256 void Interpreter::setGlobalObjectProperties() 257 { 258 ASSERT(m_globalObject); 259 m_globalObject->setInterpreter(std::auto_ptr<Interpreter>(this)); 260 261 // Set global object prototype 262 JSObject* o = m_globalObject; 263 while (o->prototype()->isObject()) 264 o = static_cast<JSObject*>(o->prototype()); 265 o->setPrototype(m_ObjectPrototype); 266 267 // Set global constructors 268 // FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to 269 // see that these values can be put directly without a check for override 270 // properties. 271 // FIXME: These properties should be handled by JSGlobalObject 272 m_globalObject->putDirect("Object", m_Object, DontEnum); 273 m_globalObject->putDirect("Function", m_Function, DontEnum); 274 m_globalObject->putDirect("Array", m_Array, DontEnum); 275 m_globalObject->putDirect("Boolean", m_Boolean, DontEnum); 276 m_globalObject->putDirect("String", m_String, DontEnum); 277 m_globalObject->putDirect("Number", m_Number, DontEnum); 278 m_globalObject->putDirect("Date", m_Date, DontEnum); 279 m_globalObject->putDirect("RegExp", m_RegExp, DontEnum); 280 m_globalObject->putDirect("Error", m_Error, DontEnum); 281 m_globalObject->putDirect("EvalError",m_EvalError, Internal); 282 m_globalObject->putDirect("RangeError",m_RangeError, Internal); 283 m_globalObject->putDirect("ReferenceError",m_ReferenceError, Internal); 284 m_globalObject->putDirect("SyntaxError",m_SyntaxError, Internal); 285 m_globalObject->putDirect("TypeError",m_TypeError, Internal); 286 m_globalObject->putDirect("URIError",m_UriError, Internal); 287 288 // Set global values 289 m_globalObject->putDirect("Math", new MathObjectImp(&m_globalExec, m_ObjectPrototype), DontEnum); 290 m_globalObject->putDirect("NaN", jsNaN(), DontEnum|DontDelete); 291 m_globalObject->putDirect("Infinity", jsNumber(Inf), DontEnum|DontDelete); 292 m_globalObject->putDirect("undefined", jsUndefined(), DontEnum|DontDelete); 293 294 // Set global functions 295 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum); 296 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum); 297 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum); 298 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum); 299 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum); 300 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum); 301 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum); 302 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum); 303 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum); 304 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum); 305 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum); 306 #ifndef NDEBUG 307 m_globalObject->putDirectFunction(new GlobalFuncImp(&m_globalExec, m_FunctionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum); 308 #endif 309 } 310 311 Completion Interpreter::checkSyntax(const UString& sourceURL, int startingLineNumber, const UString& code) 312 { 313 return checkSyntax(sourceURL, startingLineNumber, code.data(), code.size()); 314 } 315 316 Completion Interpreter::checkSyntax(const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength) 74 Completion Interpreter::checkSyntax(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength) 317 75 { 318 76 JSLock lock; … … 322 80 RefPtr<ProgramNode> progNode = parser().parseProgram(sourceURL, startingLineNumber, code, codeLength, 0, &errLine, &errMsg); 323 81 if (!progNode) 324 return Completion(Throw, Error::create( &m_globalExec, SyntaxError, errMsg, errLine, 0, sourceURL));82 return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, 0, sourceURL)); 325 83 return Completion(Normal); 326 84 } 327 85 328 Completion Interpreter::evaluate( const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV)86 Completion Interpreter::evaluate(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV) 329 87 { 330 return evaluate( sourceURL, startingLineNumber, code.data(), code.size(), thisV);88 return evaluate(exec, sourceURL, startingLineNumber, code.data(), code.size(), thisV); 331 89 } 332 90 333 Completion Interpreter::evaluate( const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV)91 Completion Interpreter::evaluate(ExecState* exec, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV) 334 92 { 335 93 JSLock lock; 336 94 337 // prevent against infinite recursion 338 if (m_recursion >= 20) 339 return Completion(Throw, Error::create(&m_globalExec, GeneralError, "Recursion too deep")); 95 JSGlobalObject* globalObject = exec->dynamicGlobalObject(); 96 97 if (globalObject->recursion() >= 20) 98 return Completion(Throw, Error::create(exec, GeneralError, "Recursion too deep")); 340 99 341 100 // parse the source code … … 346 105 347 106 // notify debugger that source has been parsed 348 if ( m_debugger) {349 bool cont = m_debugger->sourceParsed(&m_globalExec, sourceId, sourceURL, UString(code, codeLength), startingLineNumber, errLine, errMsg);107 if (globalObject->debugger()) { 108 bool cont = globalObject->debugger()->sourceParsed(exec, sourceId, sourceURL, UString(code, codeLength), startingLineNumber, errLine, errMsg); 350 109 if (!cont) 351 110 return Completion(Break); … … 354 113 // no program node means a syntax error occurred 355 114 if (!progNode) 356 return Completion(Throw, Error::create( &m_globalExec, SyntaxError, errMsg, errLine, sourceId, sourceURL));115 return Completion(Throw, Error::create(exec, SyntaxError, errMsg, errLine, sourceId, sourceURL)); 357 116 358 m_globalExec.clearException();117 exec->clearException(); 359 118 360 m_recursion++;119 globalObject->incRecursion(); 361 120 362 JSGlobalObject* globalObj = m_globalObject; 363 JSObject* thisObj = globalObj; 121 JSObject* thisObj = globalObject; 364 122 365 123 // "this" must be an object... use same rules as Function.prototype.apply() 366 124 if (thisV && !thisV->isUndefinedOrNull()) 367 thisObj = thisV->toObject( &m_globalExec);125 thisObj = thisV->toObject(exec); 368 126 369 127 Completion res; 370 if ( m_globalExec.hadException())128 if (exec->hadException()) 371 129 // the thisV->toObject() conversion above might have thrown an exception - if so, propagate it 372 res = Completion(Throw, m_globalExec.exception());130 res = Completion(Throw, exec->exception()); 373 131 else { 374 132 // execute the code 375 ExecState newExec( this, globalObj, thisObj, progNode.get());133 ExecState newExec(globalObject, thisObj, progNode.get()); 376 134 res = progNode->execute(&newExec); 377 135 } 378 136 379 m_recursion--;137 globalObject->decRecursion(); 380 138 381 139 if (shouldPrintExceptions() && res.complType() == Throw) { 382 140 JSLock lock; 383 ExecState* exec = m_globalObject->globalExec();141 ExecState* exec = globalObject->globalExec(); 384 142 CString f = sourceURL.UTF8String(); 385 143 CString message = res.value()->toObject(exec)->toString(exec).UTF8String(); … … 393 151 394 152 return res; 395 }396 397 JSObject *Interpreter::builtinObject() const398 {399 return m_Object;400 }401 402 JSObject *Interpreter::builtinFunction() const403 {404 return m_Function;405 }406 407 JSObject *Interpreter::builtinArray() const408 {409 return m_Array;410 }411 412 JSObject *Interpreter::builtinBoolean() const413 {414 return m_Boolean;415 }416 417 JSObject *Interpreter::builtinString() const418 {419 return m_String;420 }421 422 JSObject *Interpreter::builtinNumber() const423 {424 return m_Number;425 }426 427 JSObject *Interpreter::builtinDate() const428 {429 return m_Date;430 }431 432 JSObject *Interpreter::builtinError() const433 {434 return m_Error;435 }436 437 JSObject *Interpreter::builtinObjectPrototype() const438 {439 return m_ObjectPrototype;440 }441 442 JSObject *Interpreter::builtinFunctionPrototype() const443 {444 return m_FunctionPrototype;445 }446 447 JSObject *Interpreter::builtinArrayPrototype() const448 {449 return m_ArrayPrototype;450 }451 452 JSObject *Interpreter::builtinBooleanPrototype() const453 {454 return m_BooleanPrototype;455 }456 457 JSObject *Interpreter::builtinStringPrototype() const458 {459 return m_StringPrototype;460 }461 462 JSObject *Interpreter::builtinNumberPrototype() const463 {464 return m_NumberPrototype;465 }466 467 JSObject *Interpreter::builtinDatePrototype() const468 {469 return m_DatePrototype;470 }471 472 JSObject *Interpreter::builtinRegExpPrototype() const473 {474 return m_RegExpPrototype;475 }476 477 JSObject *Interpreter::builtinErrorPrototype() const478 {479 return m_ErrorPrototype;480 }481 482 JSObject *Interpreter::builtinEvalError() const483 {484 return m_EvalError;485 }486 487 JSObject *Interpreter::builtinRangeError() const488 {489 return m_RangeError;490 }491 492 JSObject *Interpreter::builtinReferenceError() const493 {494 return m_ReferenceError;495 }496 497 JSObject *Interpreter::builtinSyntaxError() const498 {499 return m_SyntaxError;500 }501 502 JSObject *Interpreter::builtinTypeError() const503 {504 return m_TypeError;505 }506 507 JSObject *Interpreter::builtinURIError() const508 {509 return m_UriError;510 }511 512 JSObject *Interpreter::builtinEvalErrorPrototype() const513 {514 return m_EvalErrorPrototype;515 }516 517 JSObject *Interpreter::builtinRangeErrorPrototype() const518 {519 return m_RangeErrorPrototype;520 }521 522 JSObject *Interpreter::builtinReferenceErrorPrototype() const523 {524 return m_ReferenceErrorPrototype;525 }526 527 JSObject *Interpreter::builtinSyntaxErrorPrototype() const528 {529 return m_SyntaxErrorPrototype;530 }531 532 JSObject *Interpreter::builtinTypeErrorPrototype() const533 {534 return m_TypeErrorPrototype;535 }536 537 JSObject *Interpreter::builtinURIErrorPrototype() const538 {539 return m_UriErrorPrototype;540 153 } 541 154 … … 552 165 } 553 166 554 void Interpreter::saveBuiltins (SavedBuiltins& builtins) const 555 { 556 if (!builtins._internal) 557 builtins._internal = new SavedBuiltinsInternal; 558 559 builtins._internal->m_Object = m_Object; 560 builtins._internal->m_Function = m_Function; 561 builtins._internal->m_Array = m_Array; 562 builtins._internal->m_Boolean = m_Boolean; 563 builtins._internal->m_String = m_String; 564 builtins._internal->m_Number = m_Number; 565 builtins._internal->m_Date = m_Date; 566 builtins._internal->m_RegExp = m_RegExp; 567 builtins._internal->m_Error = m_Error; 568 569 builtins._internal->m_ObjectPrototype = m_ObjectPrototype; 570 builtins._internal->m_FunctionPrototype = m_FunctionPrototype; 571 builtins._internal->m_ArrayPrototype = m_ArrayPrototype; 572 builtins._internal->m_BooleanPrototype = m_BooleanPrototype; 573 builtins._internal->m_StringPrototype = m_StringPrototype; 574 builtins._internal->m_NumberPrototype = m_NumberPrototype; 575 builtins._internal->m_DatePrototype = m_DatePrototype; 576 builtins._internal->m_RegExpPrototype = m_RegExpPrototype; 577 builtins._internal->m_ErrorPrototype = m_ErrorPrototype; 578 579 builtins._internal->m_EvalError = m_EvalError; 580 builtins._internal->m_RangeError = m_RangeError; 581 builtins._internal->m_ReferenceError = m_ReferenceError; 582 builtins._internal->m_SyntaxError = m_SyntaxError; 583 builtins._internal->m_TypeError = m_TypeError; 584 builtins._internal->m_UriError = m_UriError; 585 586 builtins._internal->m_EvalErrorPrototype = m_EvalErrorPrototype; 587 builtins._internal->m_RangeErrorPrototype = m_RangeErrorPrototype; 588 builtins._internal->m_ReferenceErrorPrototype = m_ReferenceErrorPrototype; 589 builtins._internal->m_SyntaxErrorPrototype = m_SyntaxErrorPrototype; 590 builtins._internal->m_TypeErrorPrototype = m_TypeErrorPrototype; 591 builtins._internal->m_UriErrorPrototype = m_UriErrorPrototype; 592 } 593 594 void Interpreter::restoreBuiltins (const SavedBuiltins& builtins) 595 { 596 if (!builtins._internal) 597 return; 598 599 m_Object = builtins._internal->m_Object; 600 m_Function = builtins._internal->m_Function; 601 m_Array = builtins._internal->m_Array; 602 m_Boolean = builtins._internal->m_Boolean; 603 m_String = builtins._internal->m_String; 604 m_Number = builtins._internal->m_Number; 605 m_Date = builtins._internal->m_Date; 606 m_RegExp = builtins._internal->m_RegExp; 607 m_Error = builtins._internal->m_Error; 608 609 m_ObjectPrototype = builtins._internal->m_ObjectPrototype; 610 m_FunctionPrototype = builtins._internal->m_FunctionPrototype; 611 m_ArrayPrototype = builtins._internal->m_ArrayPrototype; 612 m_BooleanPrototype = builtins._internal->m_BooleanPrototype; 613 m_StringPrototype = builtins._internal->m_StringPrototype; 614 m_NumberPrototype = builtins._internal->m_NumberPrototype; 615 m_DatePrototype = builtins._internal->m_DatePrototype; 616 m_RegExpPrototype = builtins._internal->m_RegExpPrototype; 617 m_ErrorPrototype = builtins._internal->m_ErrorPrototype; 618 619 m_EvalError = builtins._internal->m_EvalError; 620 m_RangeError = builtins._internal->m_RangeError; 621 m_ReferenceError = builtins._internal->m_ReferenceError; 622 m_SyntaxError = builtins._internal->m_SyntaxError; 623 m_TypeError = builtins._internal->m_TypeError; 624 m_UriError = builtins._internal->m_UriError; 625 626 m_EvalErrorPrototype = builtins._internal->m_EvalErrorPrototype; 627 m_RangeErrorPrototype = builtins._internal->m_RangeErrorPrototype; 628 m_ReferenceErrorPrototype = builtins._internal->m_ReferenceErrorPrototype; 629 m_SyntaxErrorPrototype = builtins._internal->m_SyntaxErrorPrototype; 630 m_TypeErrorPrototype = builtins._internal->m_TypeErrorPrototype; 631 m_UriErrorPrototype = builtins._internal->m_UriErrorPrototype; 632 } 633 634 void Interpreter::startTimeoutCheck() 635 { 636 if (m_timeoutCheckCount == 0) 637 resetTimeoutCheck(); 638 639 m_timeoutCheckCount++; 640 } 641 642 void Interpreter::stopTimeoutCheck() 643 { 644 m_timeoutCheckCount--; 645 } 646 647 void Interpreter::resetTimeoutCheck() 648 { 649 m_tickCount = 0; 650 m_ticksUntilNextTimeoutCheck = initialTickCountThreshold; 651 m_timeAtLastCheckTimeout = 0; 652 m_timeExecuting = 0; 653 } 654 655 // Returns the current time in milliseconds 656 // It doesn't matter what "current time" is here, just as long as 657 // it's possible to measure the time difference correctly. 658 static inline unsigned getCurrentTime() { 659 #if HAVE(SYS_TIME_H) 660 struct timeval tv; 661 gettimeofday(&tv, 0); 662 return tv.tv_sec * 1000 + tv.tv_usec / 1000; 663 #elif PLATFORM(QT) 664 QDateTime t = QDateTime::currentDateTime(); 665 return t.toTime_t() * 1000 + t.time().msec(); 666 #elif PLATFORM(WIN_OS) 667 return timeGetTime(); 668 #else 669 #error Platform does not have getCurrentTime function 670 #endif 671 } 672 673 bool Interpreter::checkTimeout() 674 { 675 m_tickCount = 0; 676 677 unsigned currentTime = getCurrentTime(); 678 679 if (!m_timeAtLastCheckTimeout) { 680 // Suspicious amount of looping in a script -- start timing it 681 m_timeAtLastCheckTimeout = currentTime; 682 return false; 683 } 684 685 unsigned timeDiff = currentTime - m_timeAtLastCheckTimeout; 686 687 if (timeDiff == 0) 688 timeDiff = 1; 689 690 m_timeExecuting += timeDiff; 691 m_timeAtLastCheckTimeout = currentTime; 692 693 // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in 694 // preferredScriptCheckTimeInterval 695 m_ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * m_ticksUntilNextTimeoutCheck; 696 697 // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the 698 // preferred script check time interval. 699 if (m_ticksUntilNextTimeoutCheck == 0) 700 m_ticksUntilNextTimeoutCheck = initialTickCountThreshold; 701 702 if (m_timeoutTime && m_timeExecuting > m_timeoutTime) { 703 if (m_globalObject->shouldInterruptScript()) 704 return true; 705 706 resetTimeoutCheck(); 707 } 708 709 return false; 710 } 711 712 713 SavedBuiltins::SavedBuiltins() : 714 _internal(0) 715 { 716 } 717 718 SavedBuiltins::~SavedBuiltins() 719 { 720 delete _internal; 721 } 722 723 } 167 } // namespace KJS -
trunk/JavaScriptCore/kjs/interpreter.h
r28328 r28468 1 1 /* 2 * This file is part of the KDE libraries3 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 4 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 5 * Copyright (C) 2003 Apple Computer, Inc.4 * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. 6 5 * 7 6 * This library is free software; you can redistribute it and/or … … 22 21 */ 23 22 24 #ifndef _KJS_INTERPRETER_H_ 25 #define _KJS_INTERPRETER_H_ 26 27 #include "ExecState.h" 28 #include "protect.h" 29 #include "types.h" 30 #include "value.h" 31 #include <wtf/RefCounted.h> 23 #ifndef KJS_Interpreter_h 24 #define KJS_Interpreter_h 32 25 33 26 namespace KJS { 34 27 35 class ArrayObjectImp; 36 class ArrayPrototype; 37 class BooleanObjectImp; 38 class BooleanPrototype; 39 class DateObjectImp; 40 class DatePrototype; 41 class Debugger; 42 class ErrorObjectImp; 43 class ErrorPrototype; 44 class EvalError; 45 class EvalErrorPrototype; 46 class FunctionObjectImp; 47 class FunctionPrototype; 48 class JSGlobalObject; 49 class NativeErrorImp; 50 class NativeErrorPrototype; 51 class NumberObjectImp; 52 class NumberPrototype; 53 class ObjectObjectImp; 54 class ObjectPrototype; 55 class RangeError; 56 class RangeErrorPrototype; 57 class ReferenceError; 58 class ReferenceError; 59 class ReferenceErrorPrototype; 60 class RegExpObjectImp; 61 class RegExpPrototype; 62 class RuntimeMethod; 63 class SavedBuiltins; 64 class ScopeChain; 65 class StringObjectImp; 66 class StringPrototype; 67 class SyntaxErrorPrototype; 68 class TypeError; 69 class TypeErrorPrototype; 70 class UriError; 71 class UriErrorPrototype; 28 class Completion; 29 class ExecState; 30 class JSValue; 31 class UString; 32 33 struct UChar; 72 34 73 /**74 * Interpreter objects can be used to evaluate ECMAScript code. Each75 * interpreter has a global object which is used for the purposes of code76 * evaluation, and also provides access to built-in properties such as77 * " Object" and "Number".78 */79 35 class Interpreter { 80 friend class Collector;81 friend class JSGlobalObject;82 83 36 public: 84 /**85 * Creates a new interpreter. The global object must be set via setGlobalObject86 * before code is executed with this interpreter.87 */88 Interpreter();89 ~Interpreter();90 91 /**92 * Set the interpreter's global object. The supplied object will be used as the global93 * object for all scripts executed with this interpreter. During94 * construction, all the standard properties such as "Object" and "Number"95 * will be added to the global object.96 *97 * Note: You should not use the same global object for multiple98 * interpreters.99 *100 * This is due do the fact that the built-in properties are set in the101 * constructor, and if these objects have been modified from another102 * interpreter (e.g. a script modifying String.prototype), the changes will103 * be overridden.104 *105 * @param The object to use as the global object for this interpreter106 */107 void setGlobalObject(JSGlobalObject*);108 109 /**110 * Resets the global object's default properties and adds the default object111 * prototype to its prototype chain.112 */113 void resetGlobalObjectProperties();114 115 /**116 * Returns the object that is used as the global object during all script117 * execution performed by this interpreter118 */119 JSGlobalObject* globalObject() const;120 121 37 /** 122 38 * Parses the supplied ECMAScript code and checks for syntax errors. … … 126 42 * otherwise a throw completion with the syntax error as its value. 127 43 */ 128 Completion checkSyntax(const UString& sourceURL, int startingLineNumber, const UString& code);129 Completion checkSyntax(const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength);44 static Completion checkSyntax(ExecState*, const UString& sourceURL, int startingLineNumber, const UString& code); 45 static Completion checkSyntax(ExecState*, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength); 130 46 131 47 /** … … 144 60 * @return A completion object representing the result of the execution. 145 61 */ 146 Completion evaluate(const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV = 0); 147 Completion evaluate(const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV = 0); 148 149 /** 150 * Returns the builtin "Object" object. This is the object that was set 151 * as a property of the global object during construction; if the property 152 * is replaced by script code, this method will still return the original 153 * object. 154 * 155 * @return The builtin "Object" object 156 */ 157 JSObject *builtinObject() const; 158 159 /** 160 * Returns the builtin "Function" object. 161 */ 162 JSObject *builtinFunction() const; 163 164 /** 165 * Returns the builtin "Array" object. 166 */ 167 JSObject *builtinArray() const; 168 169 /** 170 * Returns the builtin "Boolean" object. 171 */ 172 JSObject *builtinBoolean() const; 173 174 /** 175 * Returns the builtin "String" object. 176 */ 177 JSObject *builtinString() const; 178 179 /** 180 * Returns the builtin "Number" object. 181 */ 182 JSObject *builtinNumber() const; 183 184 /** 185 * Returns the builtin "Date" object. 186 */ 187 JSObject *builtinDate() const; 188 189 /** 190 * Returns the builtin "RegExp" object. 191 */ 192 RegExpObjectImp* builtinRegExp() const { return m_RegExp; } 193 194 /** 195 * Returns the builtin "Error" object. 196 */ 197 JSObject *builtinError() const; 198 199 /** 200 * Returns the builtin "Object.prototype" object. 201 */ 202 JSObject *builtinObjectPrototype() const; 203 204 /** 205 * Returns the builtin "Function.prototype" object. 206 */ 207 JSObject *builtinFunctionPrototype() const; 208 209 /** 210 * Returns the builtin "Array.prototype" object. 211 */ 212 JSObject *builtinArrayPrototype() const; 213 214 /** 215 * Returns the builtin "Boolean.prototype" object. 216 */ 217 JSObject *builtinBooleanPrototype() const; 218 219 /** 220 * Returns the builtin "String.prototype" object. 221 */ 222 JSObject *builtinStringPrototype() const; 223 224 /** 225 * Returns the builtin "Number.prototype" object. 226 */ 227 JSObject *builtinNumberPrototype() const; 228 229 /** 230 * Returns the builtin "Date.prototype" object. 231 */ 232 JSObject *builtinDatePrototype() const; 233 234 /** 235 * Returns the builtin "RegExp.prototype" object. 236 */ 237 JSObject *builtinRegExpPrototype() const; 238 239 /** 240 * Returns the builtin "Error.prototype" object. 241 */ 242 JSObject *builtinErrorPrototype() const; 243 244 /** 245 * The initial value of "Error" global property 246 */ 247 JSObject *builtinEvalError() const; 248 JSObject *builtinRangeError() const; 249 JSObject *builtinReferenceError() const; 250 JSObject *builtinSyntaxError() const; 251 JSObject *builtinTypeError() const; 252 JSObject *builtinURIError() const; 253 254 JSObject *builtinEvalErrorPrototype() const; 255 JSObject *builtinRangeErrorPrototype() const; 256 JSObject *builtinReferenceErrorPrototype() const; 257 JSObject *builtinSyntaxErrorPrototype() const; 258 JSObject *builtinTypeErrorPrototype() const; 259 JSObject *builtinURIErrorPrototype() const; 260 261 enum CompatMode { NativeMode, IECompat, NetscapeCompat }; 262 /** 263 * Call this to enable a compatibility mode with another browser. 264 * (by default konqueror is in "native mode"). 265 * Currently, in KJS, this only changes the behavior of Date::getYear() 266 * which returns the full year under IE. 267 */ 268 void setCompatMode(CompatMode mode) { m_compatMode = mode; } 269 CompatMode compatMode() const { return m_compatMode; } 62 static Completion evaluate(ExecState*, const UString& sourceURL, int startingLineNumber, const UString& code, JSValue* thisV = 0); 63 static Completion evaluate(ExecState*, const UString& sourceURL, int startingLineNumber, const UChar* code, int codeLength, JSValue* thisV = 0); 270 64 271 65 static bool shouldPrintExceptions(); 272 66 static void setShouldPrintExceptions(bool); 273 274 void saveBuiltins (SavedBuiltins&) const;275 void restoreBuiltins (const SavedBuiltins&);276 277 // Chained list of interpreters (ring)278 static Interpreter* firstInterpreter() { return s_hook; }279 Interpreter* nextInterpreter() const { return next; }280 Interpreter* prevInterpreter() const { return prev; }281 282 Debugger* debugger() const { return m_debugger; }283 void setDebugger(Debugger* d) { m_debugger = d; }284 285 void setCurrentExec(ExecState* exec) { m_currentExec = exec; }286 ExecState* currentExec() const { return m_currentExec; }287 288 void setTimeoutTime(unsigned timeoutTime) { m_timeoutTime = timeoutTime; }289 290 void startTimeoutCheck();291 void stopTimeoutCheck();292 293 bool timedOut();294 295 ExecState m_globalExec; // This is temporarily public to help with bootstrapping.296 297 protected:298 unsigned m_timeoutTime;299 300 private:301 void init();302 303 void createObjectsForGlobalObjectProperties();304 void setGlobalObjectProperties();305 306 void resetTimeoutCheck();307 bool checkTimeout();308 309 // Uncopyable310 Interpreter(const Interpreter&);311 Interpreter operator=(const Interpreter&);312 313 ExecState* m_currentExec;314 JSGlobalObject* m_globalObject;315 316 // Chained list of interpreters (ring) - for collector317 static Interpreter* s_hook;318 Interpreter *next, *prev;319 320 int m_recursion;321 322 Debugger* m_debugger;323 CompatMode m_compatMode;324 325 unsigned m_timeAtLastCheckTimeout;326 unsigned m_timeExecuting;327 unsigned m_timeoutCheckCount;328 329 unsigned m_tickCount;330 unsigned m_ticksUntilNextTimeoutCheck;331 332 333 ObjectObjectImp* m_Object;334 FunctionObjectImp* m_Function;335 ArrayObjectImp* m_Array;336 BooleanObjectImp* m_Boolean;337 StringObjectImp* m_String;338 NumberObjectImp* m_Number;339 DateObjectImp* m_Date;340 RegExpObjectImp* m_RegExp;341 ErrorObjectImp* m_Error;342 343 ObjectPrototype* m_ObjectPrototype;344 FunctionPrototype* m_FunctionPrototype;345 ArrayPrototype* m_ArrayPrototype;346 BooleanPrototype* m_BooleanPrototype;347 StringPrototype* m_StringPrototype;348 NumberPrototype* m_NumberPrototype;349 DatePrototype* m_DatePrototype;350 RegExpPrototype* m_RegExpPrototype;351 ErrorPrototype* m_ErrorPrototype;352 353 NativeErrorImp* m_EvalError;354 NativeErrorImp* m_RangeError;355 NativeErrorImp* m_ReferenceError;356 NativeErrorImp* m_SyntaxError;357 NativeErrorImp* m_TypeError;358 NativeErrorImp* m_UriError;359 360 NativeErrorPrototype* m_EvalErrorPrototype;361 NativeErrorPrototype* m_RangeErrorPrototype;362 NativeErrorPrototype* m_ReferenceErrorPrototype;363 NativeErrorPrototype* m_SyntaxErrorPrototype;364 NativeErrorPrototype* m_TypeErrorPrototype;365 NativeErrorPrototype* m_UriErrorPrototype;366 67 }; 367 68 368 inline bool Interpreter::timedOut() 369 { 370 m_tickCount++; 371 372 if (m_tickCount != m_ticksUntilNextTimeoutCheck) 373 return false; 374 375 return checkTimeout(); 376 } 377 378 } // namespace 69 } // namespace KJS 379 70 380 #endif // _KJS_INTERPRETER_H_71 #endif // KJS_Interpreter_h -
trunk/JavaScriptCore/kjs/lexer.cpp
r27861 r28468 26 26 27 27 #include "function.h" 28 #include "interpreter.h"29 28 #include "nodes.h" 30 29 #include <ctype.h> -
trunk/JavaScriptCore/kjs/lookup.h
r27609 r28468 26 26 #include "function.h" 27 27 #include "identifier.h" 28 #include "interpreter.h"29 28 #include "JSGlobalObject.h" 30 29 #include "object.h" … … 269 268 /** 270 269 * This template method retrieves or create an object that is unique 271 * (for a given interpreter) The first time this is called (for a given270 * (for a given global object) The first time this is called (for a given 272 271 * property name), the Object will be constructed, and set as a property 273 * of the interpreter's global object. Later calls will simply retrieve274 * that cached object.Note that the object constructor must take 1 argument, exec.272 * of the global object. Later calls will simply retrieve that cached object. 273 * Note that the object constructor must take 1 argument, exec. 275 274 */ 276 275 template <class ClassCtor> 277 276 inline JSObject* cacheGlobalObject(ExecState* exec, const Identifier& propertyName) 278 277 { 279 JSGlobalObject* globalObject = exec->lexical Interpreter()->globalObject();278 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 280 279 JSValue* obj = globalObject->getDirect(propertyName); 281 280 if (obj) { … … 316 315 bool getOwnPropertySlot(KJS::ExecState* , const KJS::Identifier&, KJS::PropertySlot&); \ 317 316 ClassPrototype(KJS::ExecState* exec) \ 318 : KJS::JSObject(exec->lexical Interpreter()->builtinObjectPrototype()) { } \317 : KJS::JSObject(exec->lexicalGlobalObject()->objectPrototype()) { } \ 319 318 \ 320 319 }; … … 352 351 } \ 353 352 ClassFunction(KJS::ExecState* exec, int len, const KJS::Identifier& name) \ 354 : KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexical Interpreter()->builtinFunctionPrototype()), name) \353 : KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexicalGlobalObject()->functionPrototype()), name) \ 355 354 { \ 356 355 put(exec, exec->propertyNames().length, KJS::jsNumber(len), KJS::DontDelete | KJS::ReadOnly | KJS::DontEnum); \ -
trunk/JavaScriptCore/kjs/nodes.cpp
r28458 r28468 360 360 } 361 361 } 362 Debugger* dbg = exec->dynamic Interpreter()->debugger();362 Debugger* dbg = exec->dynamicGlobalObject()->debugger(); 363 363 if (dbg && !dbg->hasHandledException(exec, exceptionValue)) { 364 364 bool cont = dbg->exception(exec, currentSourceId(exec), m_line, exceptionValue); … … 393 393 bool StatementNode::hitStatement(ExecState* exec) 394 394 { 395 Debugger *dbg = exec->dynamic Interpreter()->debugger();395 Debugger *dbg = exec->dynamicGlobalObject()->debugger(); 396 396 if (dbg) 397 397 return dbg->atStatement(exec, currentSourceId(exec), firstLine(), lastLine()); … … 491 491 JSValue* RegExpNode::evaluate(ExecState* exec) 492 492 { 493 return exec->lexical Interpreter()->builtinRegExp()->createRegExpImp(exec, m_regExp);493 return exec->lexicalGlobalObject()->regExpConstructor()->createRegExpImp(exec, m_regExp); 494 494 } 495 495 … … 615 615 JSValue *ElementNode::evaluate(ExecState *exec) 616 616 { 617 JSObject *array = exec->lexical Interpreter()->builtinArray()->construct(exec, List::empty());617 JSObject *array = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, List::empty()); 618 618 int length = 0; 619 619 for (ElementNode *n = this; n; n = n->next.get()) { … … 646 646 length = opt ? array->get(exec, exec->propertyNames().length)->toInt32(exec) : 0; 647 647 } else { 648 JSValue *newArr = exec->lexical Interpreter()->builtinArray()->construct(exec,List::empty());648 JSValue *newArr = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec,List::empty()); 649 649 array = static_cast<JSObject*>(newArr); 650 650 length = 0; … … 671 671 return list->evaluate(exec); 672 672 673 return exec->lexical Interpreter()->builtinObject()->construct(exec,List::empty());673 return exec->lexicalGlobalObject()->objectConstructor()->construct(exec,List::empty()); 674 674 } 675 675 … … 686 686 JSValue *PropertyListNode::evaluate(ExecState *exec) 687 687 { 688 JSObject *obj = exec->lexical Interpreter()->builtinObject()->construct(exec, List::empty());688 JSObject *obj = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, List::empty()); 689 689 690 690 for (PropertyListNode *p = this; p; p = p->next.get()) { … … 946 946 KJS_CHECKEXCEPTIONVALUE 947 947 948 JSObject *thisObj = exec->dynamic Interpreter()->globalObject();948 JSObject *thisObj = exec->dynamicGlobalObject(); 949 949 950 950 return func->call(exec, thisObj, argList); … … 1001 1001 // that in host objects you always get a valid object for this. 1002 1002 if (thisObj->isActivation()) 1003 thisObj = exec->dynamic Interpreter()->globalObject();1003 thisObj = exec->dynamicGlobalObject(); 1004 1004 1005 1005 return func->call(exec, thisObj, argList); … … 1062 1062 KJS_CHECKEXCEPTIONVALUE 1063 1063 1064 return func->call(exec, exec->dynamic Interpreter()->globalObject(), argList);1064 return func->call(exec, exec->dynamicGlobalObject(), argList); 1065 1065 } 1066 1066 … … 3784 3784 exec->popIteration(); 3785 3785 3786 if (exec->dynamic Interpreter()->timedOut())3786 if (exec->dynamicGlobalObject()->timedOut()) 3787 3787 return Completion(Interrupted); 3788 3788 … … 3837 3837 exec->popIteration(); 3838 3838 3839 if (exec->dynamic Interpreter()->timedOut())3839 if (exec->dynamicGlobalObject()->timedOut()) 3840 3840 return Completion(Interrupted); 3841 3841 … … 3903 3903 } 3904 3904 3905 if (exec->dynamic Interpreter()->timedOut())3905 if (exec->dynamicGlobalObject()->timedOut()) 3906 3906 return Completion(Interrupted); 3907 3907 … … 4581 4581 processDeclarations(exec); 4582 4582 4583 if (Debugger* dbg = exec->dynamic Interpreter()->debugger()) {4583 if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { 4584 4584 if (!dbg->callEvent(exec, sourceId(), lineNo(), exec->function(), *exec->arguments())) { 4585 4585 dbg->imp()->abort(); … … 4590 4590 Completion completion = BlockNode::execute(exec); 4591 4591 4592 if (Debugger* dbg = exec->dynamic Interpreter()->debugger()) {4592 if (Debugger* dbg = exec->dynamicGlobalObject()->debugger()) { 4593 4593 if (completion.complType() == Throw) 4594 4594 exec->setException(completion.value()); … … 4621 4621 FunctionImp *func = new FunctionImp(exec, ident, body.get(), exec->scopeChain()); 4622 4622 4623 JSObject *proto = exec->lexical Interpreter()->builtinObject()->construct(exec, List::empty());4623 JSObject *proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, List::empty()); 4624 4624 proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum); 4625 4625 func->put(exec, exec->propertyNames().prototype, proto, Internal|DontDelete); … … 4657 4657 4658 4658 FunctionImp* func = new FunctionImp(exec, ident, body.get(), exec->scopeChain()); 4659 JSObject* proto = exec->lexical Interpreter()->builtinObject()->construct(exec, List::empty());4659 JSObject* proto = exec->lexicalGlobalObject()->objectConstructor()->construct(exec, List::empty()); 4660 4660 proto->put(exec, exec->propertyNames().constructor, func, ReadOnly | DontDelete | DontEnum); 4661 4661 func->put(exec, exec->propertyNames().prototype, proto, Internal | DontDelete); -
trunk/JavaScriptCore/kjs/number_object.cpp
r27413 r28468 464 464 JSObject *NumberObjectImp::construct(ExecState *exec, const List &args) 465 465 { 466 JSObject *proto = exec->lexical Interpreter()->builtinNumberPrototype();466 JSObject *proto = exec->lexicalGlobalObject()->numberPrototype(); 467 467 NumberInstance *obj(new NumberInstance(proto)); 468 468 -
trunk/JavaScriptCore/kjs/object.cpp
r28110 r28468 69 69 70 70 #if KJS_MAX_STACK > 0 71 static int depth = 0; // sum of all concurrent interpreters71 static int depth = 0; // sum of all extant function calls 72 72 73 73 #if JAVASCRIPT_CALL_TRACING … … 366 366 { 367 367 /* Prefer String for Date objects */ 368 if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) {368 if ((hint == StringType) || (hint != NumberType && _proto == exec->lexicalGlobalObject()->datePrototype())) { 369 369 if (JSValue* v = tryGetAndCallProperty(exec, this, exec->propertyNames().toString)) 370 370 return v; … … 600 600 switch (errtype) { 601 601 case EvalError: 602 cons = exec->lexical Interpreter()->builtinEvalError();602 cons = exec->lexicalGlobalObject()->evalErrorConstructor(); 603 603 break; 604 604 case RangeError: 605 cons = exec->lexical Interpreter()->builtinRangeError();605 cons = exec->lexicalGlobalObject()->rangeErrorConstructor(); 606 606 break; 607 607 case ReferenceError: 608 cons = exec->lexical Interpreter()->builtinReferenceError();608 cons = exec->lexicalGlobalObject()->referenceErrorConstructor(); 609 609 break; 610 610 case SyntaxError: 611 cons = exec->lexical Interpreter()->builtinSyntaxError();611 cons = exec->lexicalGlobalObject()->syntaxErrorConstructor(); 612 612 break; 613 613 case TypeError: 614 cons = exec->lexical Interpreter()->builtinTypeError();614 cons = exec->lexicalGlobalObject()->typeErrorConstructor(); 615 615 break; 616 616 case URIError: 617 cons = exec->lexical Interpreter()->builtinURIError();617 cons = exec->lexicalGlobalObject()->URIErrorConstructor(); 618 618 break; 619 619 default: 620 cons = exec->lexical Interpreter()->builtinError();620 cons = exec->lexicalGlobalObject()->errorConstructor(); 621 621 break; 622 622 } -
trunk/JavaScriptCore/kjs/object.h
r28110 r28468 26 26 #define KJS_OBJECT_H 27 27 28 #include "CommonIdentifiers.h" 29 #include "ExecState.h" 28 30 #include "JSType.h" 29 #include "CommonIdentifiers.h" 30 #include "interpreter.h" 31 #include "list.h" 31 32 #include "property_map.h" 32 33 #include "property_slot.h" -
trunk/JavaScriptCore/kjs/object_object.cpp
r20310 r28468 182 182 case NullType: 183 183 case UndefinedType: 184 return new JSObject(exec->lexical Interpreter()->builtinObjectPrototype());184 return new JSObject(exec->lexicalGlobalObject()->objectPrototype()); 185 185 default: 186 186 ASSERT_NOT_REACHED(); -
trunk/JavaScriptCore/kjs/regexp.h
r27777 r28468 24 24 25 25 #include "ustring.h" 26 #include <pcre .h>26 #include <pcre/pcre.h> 27 27 #include <sys/types.h> 28 28 #include <wtf/OwnArrayPtr.h> -
trunk/JavaScriptCore/kjs/regexp_object.cpp
r27702 r28468 26 26 #include "error_object.h" 27 27 #include "internal.h" 28 #include "interpreter.h"29 28 #include "object.h" 30 29 #include "operations.h" … … 187 186 bool RegExpImp::match(ExecState* exec, const List& args) 188 187 { 189 RegExpObjectImp* regExpObj = exec->lexical Interpreter()->builtinRegExp();188 RegExpObjectImp* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); 190 189 191 190 UString input; … … 231 230 { 232 231 return match(exec, args) 233 ? exec->lexical Interpreter()->builtinRegExp()->arrayOfMatches(exec)232 ? exec->lexicalGlobalObject()->regExpConstructor()->arrayOfMatches(exec) 234 233 : jsNull(); 235 234 } … … 322 321 { 323 322 unsigned lastNumSubpatterns = d->lastNumSubPatterns; 324 ArrayInstance* arr = new ArrayInstance(exec->lexical Interpreter()->builtinArrayPrototype(), lastNumSubpatterns + 1);323 ArrayInstance* arr = new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), lastNumSubpatterns + 1); 325 324 for (unsigned i = 0; i <= lastNumSubpatterns; ++i) { 326 325 int start = d->lastOvector[2 * i]; … … 456 455 { 457 456 return regExp->isValid() 458 ? new RegExpImp(static_cast<RegExpPrototype*>(exec->lexical Interpreter()->builtinRegExpPrototype()), regExp)457 ? new RegExpImp(static_cast<RegExpPrototype*>(exec->lexicalGlobalObject()->regExpPrototype()), regExp) 459 458 : throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); 460 459 } -
trunk/JavaScriptCore/kjs/string_object.cpp
r28110 r28468 334 334 bool global = reg->global(); 335 335 336 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexical Interpreter()->builtinRegExp());336 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalGlobalObject()->regExpConstructor()); 337 337 338 338 int lastIndex = 0; … … 375 375 args.append(sourceVal); 376 376 377 substitutedReplacement = replacementFunction->call(exec, exec->dynamic Interpreter()->globalObject(),377 substitutedReplacement = replacementFunction->call(exec, exec->dynamicGlobalObject(), 378 378 args)->toString(exec); 379 379 } else … … 425 425 args.append(sourceVal); 426 426 427 replacementString = replacementFunction->call(exec, exec->dynamic Interpreter()->globalObject(),427 replacementString = replacementFunction->call(exec, exec->dynamicGlobalObject(), 428 428 args)->toString(exec); 429 429 } … … 549 549 reg = tmpReg = new RegExp(a0->toString(exec)); 550 550 } 551 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexical Interpreter()->builtinRegExp());551 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalGlobalObject()->regExpConstructor()); 552 552 int pos; 553 553 int matchLength; … … 578 578 result = jsNull(); 579 579 } else { 580 result = exec->lexical Interpreter()->builtinArray()->construct(exec, list);580 result = exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list); 581 581 } 582 582 } … … 605 605 reg = tmpReg = new RegExp(a0->toString(exec)); 606 606 } 607 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexical Interpreter()->builtinRegExp());607 RegExpObjectImp* regExpObj = static_cast<RegExpObjectImp*>(exec->lexicalGlobalObject()->regExpConstructor()); 608 608 int pos; 609 609 int matchLength; … … 661 661 JSValue* a1 = args[1]; 662 662 663 JSObject *constructor = exec->lexical Interpreter()->builtinArray();663 JSObject *constructor = exec->lexicalGlobalObject()->arrayConstructor(); 664 664 JSObject *res = static_cast<JSObject *>(constructor->construct(exec,List::empty())); 665 665 JSValue* result = res; … … 1019 1019 JSObject *StringObjectImp::construct(ExecState *exec, const List &args) 1020 1020 { 1021 JSObject *proto = exec->lexical Interpreter()->builtinStringPrototype();1021 JSObject *proto = exec->lexicalGlobalObject()->stringPrototype(); 1022 1022 if (args.size() == 0) 1023 1023 return new StringInstance(proto); -
trunk/JavaScriptCore/kjs/testkjs.cpp
r28328 r28468 28 28 #include "Parser.h" 29 29 #include "collector.h" 30 #include "interpreter.h" 30 31 #include "nodes.h" 31 32 #include "object.h" … … 165 166 166 167 stopWatch.start(); 167 exec->dynamicInterpreter()->evaluate(fileName, 0, script.data());168 Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), fileName, 0, script.data()); 168 169 stopWatch.stop(); 169 170 … … 177 178 return throwError(exec, GeneralError, "Could not open file."); 178 179 179 exec->dynamicInterpreter()->evaluate(fileName, 0, script.data());180 Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), fileName, 0, script.data()); 180 181 181 182 return jsUndefined(); … … 225 226 { 226 227 GlobalImp* global = new GlobalImp; 227 Interpreter* interp = new Interpreter;228 interp->setGlobalObject(global); // global now owns interp.229 228 230 229 // add debug() function … … 276 275 prettyPrintScript(fileName, script); 277 276 else { 278 Completion completion = globalObject->interpreter()->evaluate(fileName, 0, script.data());277 Completion completion = Interpreter::evaluate(globalObject->globalExec(), fileName, 0, script.data()); 279 278 success = success && completion.complType() != Throw; 280 279 } -
trunk/JavaScriptGlue/ChangeLog
r28328 r28468 1 2007-12-04 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Third step in refactoring JSGlobalObject: Moved data members and data 6 member access from Interpreter to JSGlobalObject. Replaced JSInterpreter 7 subclass with JSGlobalObject subclass. 8 9 * JSRun.cpp: 10 (JSRun::JSRun): 11 (JSRun::Evaluate): 12 (JSRun::CheckSyntax): 13 * JSRun.h: 14 (JSGlueGlobalObject::JSGlueGlobalObject): 15 * JSUtils.cpp: 16 (KJSValueToCFTypeInternal): 17 * JSValueWrapper.cpp: 18 (getThreadGlobalExecState): 19 1 20 2007-12-02 Geoffrey Garen <ggaren@apple.com> 2 21 -
trunk/JavaScriptGlue/JSRun.cpp
r28328 r28468 33 33 : JSBase(kJSRunTypeID), 34 34 fSource(CFStringToUString(source)), 35 fGlobalObject(new JSGl obalObject()),35 fGlobalObject(new JSGlueGlobalObject(inFlags)), 36 36 fFlags(inFlags) 37 37 { 38 Interpreter* interpreter = new JSInterpreter(fGlobalObject, inFlags);39 interpreter->setGlobalObject(fGlobalObject); // fGlobalObject now owns interpreter40 38 } 41 39 … … 61 59 Completion JSRun::Evaluate() 62 60 { 63 return fGlobalObject->interpreter()->evaluate(UString(), 0, fSource.data(), fSource.size());61 return Interpreter::evaluate(fGlobalObject->globalExec(), UString(), 0, fSource.data(), fSource.size()); 64 62 } 65 63 66 64 bool JSRun::CheckSyntax() 67 65 { 68 return fGlobalObject->interpreter()->checkSyntax(UString(), 0, fSource.data(), fSource.size()).complType() != Throw;66 return Interpreter::checkSyntax(fGlobalObject->globalExec(), UString(), 0, fSource.data(), fSource.size()).complType() != Throw; 69 67 } -
trunk/JavaScriptGlue/JSRun.h
r28328 r28468 33 33 #include "JSUtils.h" 34 34 35 class JS Interpreter : public Interpreter{35 class JSGlueGlobalObject : public JSGlobalObject { 36 36 public: 37 JSInterpreter(JSGlobalObject *global, JSFlags flags) : fJSFlags(flags) { setGlobalObject(global); } 38 JSInterpreter(JSGlobalObject *global) : fJSFlags(kJSFlagNone) { setGlobalObject(global); } 39 JSInterpreter() : fJSFlags(kJSFlagNone) { } 37 JSGlueGlobalObject(JSFlags flags) : fJSFlags(flags) { } 38 JSGlueGlobalObject() : fJSFlags(kJSFlagNone) { } 40 39 JSFlags Flags() const { return fJSFlags; } 41 40 -
trunk/JavaScriptGlue/JSUtils.cpp
r28082 r28468 274 274 { 275 275 isArray = true; 276 JS Interpreter* intrepreter = (JSInterpreter*)exec->dynamicInterpreter();277 if ( intrepreter && (intrepreter->Flags() & kJSFlagConvertAssociativeArray)) {276 JSGlueGlobalObject* globalObject = static_cast<JSGlueGlobalObject*>(exec->dynamicGlobalObject()); 277 if (globalObject && (globalObject->Flags() & kJSFlagConvertAssociativeArray)) { 278 278 PropertyNameArray propNames; 279 279 object->getPropertyNames(exec, propNames); -
trunk/JavaScriptGlue/JSValueWrapper.cpp
r28328 r28468 80 80 JSGlobalObject* globalObject = static_cast<JSGlobalObject*>(pthread_getspecific(globalObjectKey)); 81 81 if (!globalObject) { 82 globalObject = new JSGlobalObject; 83 Interpreter* interpreter = new JSInterpreter; 84 interpreter->setGlobalObject(globalObject); // globalObject now owns interpreter 85 82 globalObject = new JSGlueGlobalObject; 86 83 gcProtect(globalObject); 87 84 pthread_setspecific(globalObjectKey, globalObject); -
trunk/WebCore/ChangeLog
r28464 r28468 1 2007-12-04 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Third step in refactoring JSGlobalObject: Moved data members and data 6 member access from Interpreter to JSGlobalObject. Changed Interpreter 7 member functions to static functions. Same for the subclass, 8 ScriptInterpreter. 9 10 This is a big change, but it's mostly code motion and renaming. 11 1 12 2007-12-05 Darin Adler <darin@apple.com> 2 13 -
trunk/WebCore/WebCore.base.exp
r28330 r28468 473 473 __ZN7WebCore8IntPointC1ERK8_NSPoint 474 474 __ZN7WebCore8KJSProxy10initScriptEv 475 __ZN7WebCore8KJSProxy11interpreterEv476 475 __ZN7WebCore8Settings14setJavaEnabledEb 477 476 __ZN7WebCore8Settings16setUsesPageCacheEb -
trunk/WebCore/bindings/js/JSCSSRuleCustom.cpp
r21896 r28468 49 49 return KJS::jsNull(); 50 50 51 KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter()); 52 KJS::DOMObject* ret = interp->getDOMObject(rule); 51 KJS::DOMObject* ret = KJS::ScriptInterpreter::getDOMObject(rule); 53 52 54 53 if (ret) … … 79 78 } 80 79 81 interp->putDOMObject(rule, ret);80 KJS::ScriptInterpreter::putDOMObject(rule, ret); 82 81 return ret; 83 82 } -
trunk/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
r25619 r28468 108 108 // Make the SVG 'filter' attribute undetectable, to avoid confusion with the IE 'filter' attribute. 109 109 if (propertyName == "filter") 110 return new StringInstanceThatMasqueradesAsUndefined(exec->lexical Interpreter()->builtinStringPrototype(), thisObj->impl()->getPropertyValue(prop));110 return new StringInstanceThatMasqueradesAsUndefined(exec->lexicalGlobalObject()->stringPrototype(), thisObj->impl()->getPropertyValue(prop)); 111 111 112 112 return jsString(thisObj->impl()->getPropertyValue(prop)); -
trunk/WebCore/bindings/js/JSCSSValueCustom.cpp
r26400 r28468 48 48 return KJS::jsNull(); 49 49 50 KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter()); 51 KJS::DOMObject* ret = interp->getDOMObject(value); 50 KJS::DOMObject* ret = KJS::ScriptInterpreter::getDOMObject(value); 52 51 53 52 if (ret) … … 67 66 ret = new JSCSSValue(exec, value); 68 67 69 interp->putDOMObject(value, ret);68 KJS::ScriptInterpreter::putDOMObject(value, ret); 70 69 return ret; 71 70 } -
trunk/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp
r28328 r28468 55 55 if (!proxy) 56 56 return; 57 58 ScriptInterpreter* interpreter = proxy->interpreter();59 ExecState* exec = proxy->globalObject()->globalExec();57 58 JSGlobalObject* globalObject = proxy->globalObject(); 59 ExecState* exec = globalObject->globalExec(); 60 60 61 61 KJS::JSLock lock; … … 80 80 args.append(toJS(exec, resultSet)); 81 81 82 interpreter->startTimeoutCheck();82 globalObject->startTimeoutCheck(); 83 83 if (handleEventFunc) 84 84 handleEventFunc->call(exec, m_callback, args); 85 85 else 86 86 m_callback->call(exec, m_callback, args); 87 interpreter->stopTimeoutCheck();87 globalObject->stopTimeoutCheck(); 88 88 89 89 if (exec->hadException()) { -
trunk/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
r28328 r28468 56 56 return true; 57 57 58 ExecState* exec = proxy->globalObject()->globalExec();59 ScriptInterpreter* interpreter = proxy->interpreter();58 JSGlobalObject* globalObject = proxy->globalObject(); 59 ExecState* exec = globalObject->globalExec(); 60 60 61 61 KJS::JSLock lock; … … 81 81 82 82 JSValue *result; 83 interpreter->startTimeoutCheck();83 globalObject->startTimeoutCheck(); 84 84 if (handleEventFunc) 85 85 result = handleEventFunc->call(exec, m_callback, args); 86 86 else 87 87 result = m_callback->call(exec, m_callback, args); 88 interpreter->stopTimeoutCheck();88 globalObject->stopTimeoutCheck(); 89 89 90 90 if (exec->hadException()) { -
trunk/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
r28328 r28468 55 55 return; 56 56 57 ExecState* exec = proxy->globalObject()->globalExec();58 ScriptInterpreter* interpreter = proxy->interpreter();57 JSGlobalObject* globalObject = proxy->globalObject(); 58 ExecState* exec = globalObject->globalExec(); 59 59 60 60 KJS::JSLock lock; … … 78 78 args.append(toJS(exec, transaction)); 79 79 80 interpreter->startTimeoutCheck();80 globalObject->startTimeoutCheck(); 81 81 if (handleEventFunc) 82 82 handleEventFunc->call(exec, m_callback, args); 83 83 else 84 84 m_callback->call(exec, m_callback, args); 85 interpreter->stopTimeoutCheck();85 globalObject->stopTimeoutCheck(); 86 86 87 87 if (exec->hadException()) { -
trunk/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp
r28328 r28468 55 55 return true; 56 56 57 ExecState* exec = proxy->globalObject()->globalExec();58 ScriptInterpreter* interpreter = proxy->interpreter();57 JSGlobalObject* globalObject = proxy->globalObject(); 58 ExecState* exec = globalObject->globalExec(); 59 59 60 60 KJS::JSLock lock; … … 79 79 80 80 JSValue *result; 81 interpreter->startTimeoutCheck();81 globalObject->startTimeoutCheck(); 82 82 if (handleEventFunc) 83 83 result = handleEventFunc->call(exec, m_callback, args); 84 84 else 85 85 result = m_callback->call(exec, m_callback, args); 86 interpreter->stopTimeoutCheck();86 globalObject->stopTimeoutCheck(); 87 87 88 88 if (exec->hadException()) { -
trunk/WebCore/bindings/js/JSCustomVoidCallback.cpp
r28328 r28468 57 57 return; 58 58 59 ExecState* exec = proxy->globalObject()->globalExec();60 ScriptInterpreter* interpreter = proxy->interpreter();59 JSGlobalObject* globalObject = proxy->globalObject(); 60 ExecState* exec = globalObject->globalExec(); 61 61 62 62 KJS::JSLock lock; … … 79 79 List args; 80 80 81 interpreter->startTimeoutCheck();81 globalObject->startTimeoutCheck(); 82 82 if (handleEventFunc) 83 83 handleEventFunc->call(exec, m_callback, args); 84 84 else 85 85 m_callback->call(exec, m_callback, args); 86 interpreter->stopTimeoutCheck();86 globalObject->stopTimeoutCheck(); 87 87 88 88 if (exec->hadException()) { -
trunk/WebCore/bindings/js/JSCustomXPathNSResolver.cpp
r28328 r28468 80 80 JSLock lock; 81 81 82 ExecState* exec = proxy->globalObject()->globalExec();83 ScriptInterpreter* interpreter = proxy->interpreter();84 82 JSGlobalObject* globalObject = proxy->globalObject(); 83 ExecState* exec = globalObject->globalExec(); 84 85 85 JSValue* lookupNamespaceURIFuncValue = m_customResolver->get(exec, "lookupNamespaceURI"); 86 86 JSObject* lookupNamespaceURIFunc = 0; … … 105 105 String result; 106 106 JSValue* retval; 107 interpreter->startTimeoutCheck();107 globalObject->startTimeoutCheck(); 108 108 if (lookupNamespaceURIFunc) 109 109 retval = lookupNamespaceURIFunc->call(exec, m_customResolver, args); 110 110 else 111 111 retval = m_customResolver->call(exec, m_customResolver, args); 112 interpreter->stopTimeoutCheck();112 globalObject->stopTimeoutCheck(); 113 113 114 114 if (exec->hadException()) { -
trunk/WebCore/bindings/js/JSDOMExceptionConstructor.cpp
r27413 r28468 28 28 29 29 #include "ExceptionCode.h" 30 #include <kjs/object_object.h> 30 31 31 32 #include "JSDOMExceptionConstructor.lut.h" … … 59 60 JSDOMExceptionConstructor::JSDOMExceptionConstructor(ExecState* exec) 60 61 { 61 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());62 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 62 63 } 63 64 -
trunk/WebCore/bindings/js/JSDocumentCustom.cpp
r28110 r28468 21 21 #include "JSDocument.h" 22 22 23 #include "DOMWindow.h" 23 24 #include "Document.h" 24 25 #include "Frame.h" 25 26 #include "FrameLoader.h" 26 27 #include "HTMLDocument.h" 28 #include "JSDOMWindow.h" 27 29 #include "JSHTMLDocument.h" 28 30 #include "kjs_binding.h" 29 #include "kjs_ window.h"31 #include "kjs_proxy.h" 30 32 31 33 #if ENABLE(SVG) … … 65 67 // IE and Mozilla both resolve the URL relative to the source frame, 66 68 // not the target frame. 67 Frame* activeFrame = static_cast< ScriptInterpreter*>(exec->dynamicInterpreter())->frame();69 Frame* activeFrame = static_cast<JSDOMWindow*>(exec->dynamicGlobalObject())->impl()->frame(); 68 70 if (activeFrame) 69 71 str = activeFrame->document()->completeURL(str); 70 72 71 bool userGesture = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture();73 bool userGesture = activeFrame->scriptProxy()->processingUserGesture(); 72 74 frame->loader()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), false, userGesture); 73 75 } … … 78 80 return jsNull(); 79 81 80 ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter()); 81 JSDocument* ret = static_cast<JSDocument*>(interp->getDOMObject(doc)); 82 JSDocument* ret = static_cast<JSDocument*>(ScriptInterpreter::getDOMObject(doc)); 82 83 if (ret) 83 84 return ret; … … 104 105 } 105 106 106 interp->putDOMObject(doc, ret);107 ScriptInterpreter::putDOMObject(doc, ret); 107 108 108 109 return ret; -
trunk/WebCore/bindings/js/JSEventCustom.cpp
r27277 r28468 50 50 #include "kjs_events.h" 51 51 52 using namespace KJS; 53 52 54 namespace WebCore { 53 55 54 KJS::JSValue* JSEvent::clipboardData(KJS::ExecState* exec) const56 JSValue* JSEvent::clipboardData(ExecState* exec) const 55 57 { 56 return impl()->isClipboardEvent() ? toJS(exec, impl()->clipboardData()) : KJS::jsUndefined();58 return impl()->isClipboardEvent() ? toJS(exec, impl()->clipboardData()) : jsUndefined(); 57 59 } 58 60 59 KJS::JSValue* toJS(KJS::ExecState* exec, Event* event)61 JSValue* toJS(ExecState* exec, Event* event) 60 62 { 61 KJS::JSLock lock;63 JSLock lock; 62 64 63 65 if (!event) 64 return KJS::jsNull();66 return jsNull(); 65 67 66 KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter());67 68 68 KJS::DOMObject* ret = interp->getDOMObject(event);69 DOMObject* ret = ScriptInterpreter::getDOMObject(event); 69 70 if (ret) 70 71 return ret; … … 89 90 ret = new JSEvent(exec, event); 90 91 91 interp->putDOMObject(event, ret);92 ScriptInterpreter::putDOMObject(event, ret); 92 93 return ret; 93 94 } -
trunk/WebCore/bindings/js/JSHTMLAudioElementConstructor.cpp
r27277 r28468 41 41 : m_doc(d) 42 42 { 43 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());43 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 44 44 put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum); 45 45 } -
trunk/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
r28327 r28468 33 33 #include <wtf/Vector.h> 34 34 35 using namespace KJS; 36 35 37 namespace WebCore { 36 38 37 static KJS::JSValue* getNamedItems(KJS::ExecState* exec, HTMLCollection* impl, const KJS::Identifier& propertyName)39 static JSValue* getNamedItems(ExecState* exec, HTMLCollection* impl, const Identifier& propertyName) 38 40 { 39 41 Vector<RefPtr<Node> > namedItems; … … 41 43 42 44 if (namedItems.isEmpty()) 43 return KJS::jsUndefined();45 return jsUndefined(); 44 46 45 47 if (namedItems.size() == 1) … … 51 53 // HTMLCollections are strange objects, they support both get and call, 52 54 // so that document.forms.item(0) and document.forms(0) both work. 53 KJS::JSValue* JSHTMLCollection::callAsFunction(KJS::ExecState* exec, KJS::JSObject*, const KJS::List& args)55 JSValue* JSHTMLCollection::callAsFunction(ExecState* exec, JSObject*, const List& args) 54 56 { 55 57 if (args.size() < 1) 56 return KJS::jsUndefined();58 return jsUndefined(); 57 59 58 60 // Do not use thisObj here. It can be the JSHTMLDocument, in the document.forms(i) case. … … 64 66 // Support for document.all(<index>) etc. 65 67 bool ok; 66 KJS::UString string = args[0]->toString(exec);68 UString string = args[0]->toString(exec); 67 69 unsigned index = string.toUInt32(&ok, false); 68 70 if (ok) … … 70 72 71 73 // Support for document.images('<name>') etc. 72 return getNamedItems(exec, collection, KJS::Identifier(string));74 return getNamedItems(exec, collection, Identifier(string)); 73 75 } 74 76 75 77 // The second arg, if set, is the index of the item we want 76 78 bool ok; 77 KJS::UString string = args[0]->toString(exec);79 UString string = args[0]->toString(exec); 78 80 unsigned index = args[1]->toString(exec).toUInt32(&ok, false); 79 81 if (ok) { … … 88 90 } 89 91 90 return KJS::jsUndefined();92 return jsUndefined(); 91 93 } 92 94 … … 96 98 } 97 99 98 bool JSHTMLCollection::canGetItemsForName( KJS::ExecState* exec, HTMLCollection* thisObj, const KJS::Identifier& propertyName)100 bool JSHTMLCollection::canGetItemsForName(ExecState* exec, HTMLCollection* thisObj, const Identifier& propertyName) 99 101 { 100 102 return !getNamedItems(exec, thisObj, propertyName)->isUndefined(); 101 103 } 102 104 103 KJS::JSValue* JSHTMLCollection::nameGetter(KJS::ExecState* exec, KJS::JSObject* originalObject, const KJS::Identifier& propertyName, const KJS::PropertySlot& slot)105 JSValue* JSHTMLCollection::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot) 104 106 { 105 107 JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(slot.slotBase()); … … 107 109 } 108 110 109 KJS::JSValue* JSHTMLCollection::item(KJS::ExecState* exec, const KJS::List& args)111 JSValue* JSHTMLCollection::item(ExecState* exec, const List& args) 110 112 { 111 113 bool ok; … … 113 115 if (ok) 114 116 return toJS(exec, impl()->item(index)); 115 return getNamedItems(exec, impl(), KJS::Identifier(args[0]->toString(exec)));117 return getNamedItems(exec, impl(), Identifier(args[0]->toString(exec))); 116 118 } 117 119 118 KJS::JSValue* JSHTMLCollection::namedItem(KJS::ExecState* exec, const KJS::List& args)120 JSValue* JSHTMLCollection::namedItem(ExecState* exec, const List& args) 119 121 { 120 return getNamedItems(exec, impl(), KJS::Identifier(args[0]->toString(exec)));122 return getNamedItems(exec, impl(), Identifier(args[0]->toString(exec))); 121 123 } 122 124 123 KJS::JSValue* toJS(KJS::ExecState* exec, HTMLCollection* collection)125 JSValue* toJS(ExecState* exec, HTMLCollection* collection) 124 126 { 125 127 if (!collection) 126 return KJS::jsNull();128 return jsNull(); 127 129 128 KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter()); 129 KJS::DOMObject* ret = interp->getDOMObject(collection); 130 DOMObject* ret = ScriptInterpreter::getDOMObject(collection); 130 131 131 132 if (ret) … … 144 145 } 145 146 146 interp->putDOMObject(collection, ret);147 ScriptInterpreter::putDOMObject(collection, ret); 147 148 return ret; 148 149 } -
trunk/WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
r25754 r28468 33 33 : m_doc(d) 34 34 { 35 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());35 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 36 36 put(exec, exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum); 37 37 } -
trunk/WebCore/bindings/js/JSNamedNodesCollection.cpp
r27413 r28468 44 44 : m_nodes(nodes) 45 45 { 46 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());46 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 47 47 } 48 48 -
trunk/WebCore/bindings/js/JSNodeCustom.cpp
r28110 r28468 61 61 #endif 62 62 63 using namespace KJS; 64 63 65 namespace WebCore { 64 66 65 67 typedef int ExpectionCode; 66 68 67 KJS::JSValue* JSNode::insertBefore(KJS::ExecState* exec, const KJS::List& args)69 JSValue* JSNode::insertBefore(ExecState* exec, const List& args) 68 70 { 69 71 ExceptionCode ec = 0; 70 72 bool ok = impl()->insertBefore(toNode(args[0]), toNode(args[1]), ec); 71 KJS::setDOMException(exec, ec);73 setDOMException(exec, ec); 72 74 if (ok) 73 75 return args[0]; 74 return KJS::jsNull();75 } 76 77 KJS::JSValue* JSNode::replaceChild(KJS::ExecState* exec, const KJS::List& args)76 return jsNull(); 77 } 78 79 JSValue* JSNode::replaceChild(ExecState* exec, const List& args) 78 80 { 79 81 ExceptionCode ec = 0; 80 82 bool ok = impl()->replaceChild(toNode(args[0]), toNode(args[1]), ec); 81 KJS::setDOMException(exec, ec);83 setDOMException(exec, ec); 82 84 if (ok) 83 85 return args[1]; 84 return KJS::jsNull();85 } 86 87 KJS::JSValue* JSNode::removeChild(KJS::ExecState* exec, const KJS::List& args)86 return jsNull(); 87 } 88 89 JSValue* JSNode::removeChild(ExecState* exec, const List& args) 88 90 { 89 91 ExceptionCode ec = 0; 90 92 bool ok = impl()->removeChild(toNode(args[0]), ec); 91 KJS::setDOMException(exec, ec);93 setDOMException(exec, ec); 92 94 if (ok) 93 95 return args[0]; 94 return KJS::jsNull();95 } 96 97 KJS::JSValue* JSNode::appendChild(KJS::ExecState* exec, const KJS::List& args)96 return jsNull(); 97 } 98 99 JSValue* JSNode::appendChild(ExecState* exec, const List& args) 98 100 { 99 101 ExceptionCode ec = 0; 100 102 bool ok = impl()->appendChild(toNode(args[0]), ec); 101 KJS::setDOMException(exec, ec);103 setDOMException(exec, ec); 102 104 if (ok) 103 105 return args[0]; 104 return KJS::jsNull();106 return jsNull(); 105 107 } 106 108 … … 134 136 root->m_inSubtreeMark = true; 135 137 for (Node* nodeToMark = root; nodeToMark; nodeToMark = nodeToMark->traverseNextNode()) { 136 JSNode* wrapper = KJS::ScriptInterpreter::getDOMNodeForDocument(m_impl->document(), nodeToMark);138 JSNode* wrapper = ScriptInterpreter::getDOMNodeForDocument(m_impl->document(), nodeToMark); 137 139 if (wrapper) { 138 140 if (!wrapper->marked()) … … 154 156 } 155 157 156 KJS::JSValue* toJS(KJS::ExecState* exec, PassRefPtr<Node> n)158 JSValue* toJS(ExecState* exec, PassRefPtr<Node> n) 157 159 { 158 160 Node* node = n.get(); 159 161 if (!node) 160 return KJS::jsNull(); 161 162 KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter()); 162 return jsNull(); 163 163 164 Document* doc = node->document(); 164 JSNode* ret = interp->getDOMNodeForDocument(doc, node);165 JSNode* ret = ScriptInterpreter::getDOMNodeForDocument(doc, node); 165 166 if (ret) 166 167 return ret; … … 214 215 } 215 216 216 interp->putDOMNodeForDocument(doc, node, ret);217 ScriptInterpreter::putDOMNodeForDocument(doc, node, ret); 217 218 218 219 return ret; -
trunk/WebCore/bindings/js/JSSQLResultSetRowListCustom.cpp
r26787 r28468 51 51 } 52 52 53 JSObject* object = new JSObject(exec->lexical Interpreter()->builtinObjectPrototype());53 JSObject* object = new JSObject(exec->lexicalGlobalObject()->objectPrototype()); 54 54 55 55 unsigned numColumns = m_impl->columnNames().size(); -
trunk/WebCore/bindings/js/JSStyleSheetCustom.cpp
r21911 r28468 31 31 #include "StyleSheet.h" 32 32 33 using namespace KJS; 34 33 35 namespace WebCore { 34 36 35 KJS::JSValue* toJS(KJS::ExecState* exec, StyleSheet* styleSheet)37 JSValue* toJS(ExecState* exec, StyleSheet* styleSheet) 36 38 { 37 39 if (!styleSheet) 38 return KJS::jsNull();40 return jsNull(); 39 41 40 KJS::ScriptInterpreter* interp = static_cast<KJS::ScriptInterpreter*>(exec->dynamicInterpreter()); 41 KJS::DOMObject* ret = interp->getDOMObject(styleSheet); 42 DOMObject* ret = ScriptInterpreter::getDOMObject(styleSheet); 42 43 if (ret) 43 44 return ret; … … 48 49 ret = new JSStyleSheet(exec, styleSheet); 49 50 50 interp->putDOMObject(styleSheet, ret);51 ScriptInterpreter::putDOMObject(styleSheet, ret); 51 52 return ret; 52 53 } -
trunk/WebCore/bindings/js/JSXMLHttpRequest.cpp
r28110 r28468 62 62 : doc(d) 63 63 { 64 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());64 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 65 65 putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None); 66 66 } -
trunk/WebCore/bindings/js/JSXSLTProcessor.cpp
r27608 r28468 187 187 XSLTProcessorConstructorImp::XSLTProcessorConstructorImp(ExecState *exec) 188 188 { 189 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());189 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 190 190 putDirect(exec->propertyNames().prototype, XSLTProcessorPrototype::self(exec), None); 191 191 } -
trunk/WebCore/bindings/js/kjs_binding.cpp
r28328 r28468 138 138 } 139 139 140 ScriptInterpreter::ScriptInterpreter(JSGlobalObject* global, Frame* frame)141 : m_frame(frame)142 , m_currentEvent(0)143 , m_inlineCode(false)144 , m_timerCallback(false)145 {146 setGlobalObject(global);147 // Time in milliseconds before the script timeout handler kicks in.148 setTimeoutTime(10000);149 }150 151 140 DOMObject* ScriptInterpreter::getDOMObject(void* objectHandle) 152 141 { … … 243 232 addWrapper(wrapper); 244 233 } 245 }246 247 bool ScriptInterpreter::wasRunByUserGesture() const248 {249 if (m_currentEvent) {250 const AtomicString& type = m_currentEvent->type();251 bool eventOk = ( // mouse events252 type == clickEvent || type == mousedownEvent ||253 type == mouseupEvent || type == dblclickEvent ||254 // keyboard events255 type == keydownEvent || type == keypressEvent ||256 type == keyupEvent ||257 // other accepted events258 type == selectEvent || type == changeEvent ||259 type == focusEvent || type == blurEvent ||260 type == submitEvent);261 if (eventOk)262 return true;263 } else { // no event264 if (m_inlineCode && !m_timerCallback)265 // This is the <a href="javascript:window.open('...')> case -> we let it through266 return true;267 // This is the <script>window.open(...)</script> case or a timer callback -> block it268 }269 return false;270 234 } 271 235 -
trunk/WebCore/bindings/js/kjs_binding.h
r28328 r28468 25 25 26 26 #include <kjs/function.h> 27 #include <kjs/interpreter.h> 27 28 #include <kjs/lookup.h> 28 29 #include <wtf/Noncopyable.h> … … 66 67 }; 67 68 68 /**69 * We inherit from Interpreter, to save a pointer to the HTML part70 * that the interpreter runs for.71 * The interpreter also stores the DOM object -> KJS::DOMObject cache.72 */73 69 class ScriptInterpreter : public Interpreter { 74 70 public: 75 ScriptInterpreter(JSGlobalObject*, WebCore::Frame*);76 77 71 static DOMObject* getDOMObject(void* objectHandle); 78 72 static void putDOMObject(void* objectHandle, DOMObject*); … … 85 79 static void updateDOMNodeDocument(WebCore::Node*, WebCore::Document* oldDoc, WebCore::Document* newDoc); 86 80 static void markDOMNodesForDocument(WebCore::Document*); 87 88 WebCore::Frame* frame() const { return m_frame; }89 90 /**91 * Set the event that is triggering the execution of a script, if any92 */93 void setCurrentEvent(WebCore::Event* event) { m_currentEvent = event; }94 void setInlineCode(bool inlineCode) { m_inlineCode = inlineCode; }95 void setProcessingTimerCallback(bool timerCallback) { m_timerCallback = timerCallback; }96 97 /**98 * "Smart" window.open policy99 */100 bool wasRunByUserGesture() const;101 102 WebCore::Event* getCurrentEvent() const { return m_currentEvent; }103 104 private:105 106 WebCore::Frame* m_frame;107 WebCore::Event* m_currentEvent;108 bool m_inlineCode;109 bool m_timerCallback;110 81 }; 111 82 … … 117 88 if (!domObj) 118 89 return jsNull(); 119 ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter()); 120 if (DOMObject* ret = interp->getDOMObject(domObj)) 90 if (DOMObject* ret = ScriptInterpreter::getDOMObject(domObj)) 121 91 return ret; 122 92 DOMObject* ret = new KJSDOMObj(exec, domObj); 123 interp->putDOMObject(domObj, ret);93 ScriptInterpreter::putDOMObject(domObj, ret); 124 94 return ret; 125 95 } … … 133 103 if (!domObj) 134 104 return jsNull(); 135 ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter()); 136 if (DOMObject* ret = interp->getDOMObject(domObj)) 105 if (DOMObject* ret = ScriptInterpreter::getDOMObject(domObj)) 137 106 return ret; 138 107 DOMObject* ret = new KJSDOMObj(exec, domObj, context); 139 interp->putDOMObject(domObj, ret);108 ScriptInterpreter::putDOMObject(domObj, ret); 140 109 return ret; 141 110 } -
trunk/WebCore/bindings/js/kjs_css.cpp
r27413 r28468 48 48 : m_color(color) 49 49 { 50 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());50 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 51 51 } 52 52 -
trunk/WebCore/bindings/js/kjs_dom.cpp
r26816 r28468 63 63 64 64 // Check to see if the currently executing interpreter is allowed to access the specified node 65 KJS::Window* win = KJS::Window::retrieveWindow(n->document()->frame());65 Window* win = Window::retrieveWindow(n->document()->frame()); 66 66 return win && win->isSafeScript(exec); 67 67 } … … 83 83 return toJS(exec, node); 84 84 85 XMLHttpRequest* xhr = target->toXMLHttpRequest(); 86 if (xhr) { 85 if (XMLHttpRequest* xhr = target->toXMLHttpRequest()) 87 86 // XMLHttpRequest is always created via JS, so we don't need to use cacheDOMObject() here. 88 ScriptInterpreter* interp = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter()); 89 return interp->getDOMObject(xhr); 90 } 87 return ScriptInterpreter::getDOMObject(xhr); 91 88 92 89 // There are two kinds of EventTargets: EventTargetNode and XMLHttpRequest. -
trunk/WebCore/bindings/js/kjs_events.cpp
r28328 r28468 39 39 #include "kjs_proxy.h" 40 40 #include "kjs_window.h" 41 #include <kjs/array_object.h> 42 #include <kjs/function_object.h> 41 43 42 44 #include "kjs_events.lut.h" … … 80 82 JSLock lock; 81 83 82 ScriptInterpreter* interpreter = proxy->interpreter();83 ExecState* exec = proxy->globalObject()->globalExec();84 JSGlobalObject* globalObject = proxy->globalObject(); 85 ExecState* exec = globalObject->globalExec(); 84 86 85 87 JSValue* handleEventFuncValue = listener->get(exec, "handleEvent"); … … 97 99 args.append(toJS(exec, event)); 98 100 99 // Set the event we're handling in the KJS::Window object100 101 window->setCurrentEvent(event); 101 // ... and in the interpreter102 interpreter->setCurrentEvent(event);103 102 104 103 JSValue* retval; 105 104 if (handleEventFunc) { 106 interpreter->startTimeoutCheck();105 globalObject->startTimeoutCheck(); 107 106 retval = handleEventFunc->call(exec, listener, args); 108 107 } else { … … 112 111 else 113 112 thisObj = static_cast<JSObject*>(toJS(exec, event->currentTarget())); 114 interpreter->startTimeoutCheck();113 globalObject->startTimeoutCheck(); 115 114 retval = listener->call(exec, thisObj, args); 116 115 } 117 interpreter->stopTimeoutCheck();116 globalObject->stopTimeoutCheck(); 118 117 119 118 window->setCurrentEvent(0); 120 interpreter->setCurrentEvent(0);121 119 122 120 if (exec->hadException()) { … … 297 295 298 296 if (proxy) { 299 ScriptInterpreter* interpreter = proxy->interpreter();300 297 ExecState* exec = proxy->globalObject()->globalExec(); 301 298 302 299 JSLock lock; 303 JSObject* constr = interpreter->builtinFunction();300 JSObject* constr = proxy->globalObject()->functionConstructor(); 304 301 List args; 305 302 … … 406 403 for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it) 407 404 list.append(jsString(UString(*it))); 408 return exec->lexical Interpreter()->builtinArray()->construct(exec, list);405 return exec->lexicalGlobalObject()->arrayConstructor()->construct(exec, list); 409 406 } 410 407 } -
trunk/WebCore/bindings/js/kjs_events.h
r28110 r28468 26 26 #include "kjs_dom.h" 27 27 #include "kjs_html.h" 28 28 #include <kjs/protect.h> 29 29 30 30 namespace KJS { -
trunk/WebCore/bindings/js/kjs_html.cpp
r28328 r28468 37 37 : m_doc(doc) 38 38 { 39 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());39 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 40 40 } 41 41 -
trunk/WebCore/bindings/js/kjs_navigator.cpp
r27608 r28468 26 26 #include "AtomicString.h" 27 27 #include "CookieJar.h" 28 #include "DOMWindow.h" 28 29 #include "Document.h" 29 30 #include "Frame.h" … … 33 34 #include "PlugInInfoStore.h" 34 35 #include "Settings.h" 36 #include "kjs_window.h" 37 #include <kjs/object_object.h> 35 38 36 39 #ifndef WEBCORE_NAVIGATOR_PLATFORM … … 176 179 : m_frame(f) 177 180 { 178 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());181 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 179 182 } 180 183 … … 249 252 PluginBase::PluginBase(ExecState *exec) 250 253 { 251 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());254 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 252 255 253 256 cachePluginDataIfNecessary(); … … 513 516 return jsString(m_info->desc); 514 517 case EnabledPlugin: { 515 ScriptInterpreter *interpreter = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter()); 516 Frame *frame = interpreter->frame(); 518 Frame* frame = Window::retrieveActive(exec)->impl()->frame(); 517 519 ASSERT(frame); 518 520 Settings* settings = frame->settings(); -
trunk/WebCore/bindings/js/kjs_proxy.cpp
r28328 r28468 24 24 #include "Chrome.h" 25 25 #include "Document.h" 26 #include "Event.h" 27 #include "EventNames.h" 26 28 #include "Frame.h" 27 29 #include "FrameLoader.h" … … 39 41 40 42 using namespace KJS; 43 using namespace WebCore::EventNames; 41 44 42 45 namespace WebCore { … … 45 48 : m_frame(frame) 46 49 , m_handlerLineno(0) 50 , m_processingTimerCallback(0) 51 , m_processingInlineCode(0) 47 52 { 48 53 } … … 50 55 KJSProxy::~KJSProxy() 51 56 { 52 // Check for <rdar://problem/4876466>. In theory, no JS should be executing 53 // in our interpreter. 54 ASSERT(!m_globalObject || !m_globalObject->interpreter()->currentExec()); 57 // Check for <rdar://problem/4876466>. In theory, no JS should be executing now. 58 ASSERT(!m_globalObject || !m_globalObject->currentExec()); 55 59 56 60 if (m_globalObject) { 57 61 m_globalObject = 0; 58 62 59 // It's likely that destroying the interpreterhas created a lot of garbage.63 // It's likely that releasing the global object has created a lot of garbage. 60 64 gcController().garbageCollectSoon(); 61 65 } … … 72 76 // expected value in all cases. 73 77 // See smart window.open policy for where this is used. 74 bool inlineCode = filename.isNull();75 76 ScriptInterpreter* interpreter = static_cast<ScriptInterpreter*>(m_globalObject->interpreter());77 78 ExecState* exec = m_globalObject->globalExec(); 78 79 interpreter->setInlineCode(inlineCode); 79 m_processingInlineCode = filename.isNull(); 80 80 81 81 JSLock lock; … … 87 87 JSValue* thisNode = Window::retrieve(m_frame); 88 88 89 interpreter->startTimeoutCheck();90 Completion comp = interpreter->evaluate(filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode);91 interpreter->stopTimeoutCheck();89 m_globalObject->startTimeoutCheck(); 90 Completion comp = Interpreter::evaluate(exec, filename, baseLine, reinterpret_cast<const KJS::UChar*>(str.characters()), str.length(), thisNode); 91 m_globalObject->stopTimeoutCheck(); 92 92 93 if (comp.complType() == Normal || comp.complType() == ReturnValue) 93 if (comp.complType() == Normal || comp.complType() == ReturnValue) { 94 m_processingInlineCode = false; 94 95 return comp.value(); 96 } 95 97 96 98 if (comp.complType() == Throw) { … … 102 104 } 103 105 106 m_processingInlineCode = false; 104 107 return 0; 105 108 } 106 109 107 void KJSProxy::clear() { 108 // clear resources allocated by the interpreter, and make it ready to be used by another page 109 // We have to keep it, so that the Window object for the frame remains the same. 110 // (we used to delete and re-create it, previously) 111 if (m_globalObject) 112 m_globalObject->clear(); 110 void KJSProxy::clear() 111 { 112 // clear resources allocated by the global object, and make it ready to be used by another page 113 // We have to keep it, so that the Window object for the frame remains the same. 114 // (we used to delete and re-create it, previously) 115 if (m_globalObject) 116 m_globalObject->clear(); 113 117 } 114 118 … … 135 139 // e.g. an image load or mouse move. Once the event has been dispatched, it is forgotten 136 140 // by the DOM implementation and so does not need to be cached still by the interpreter 137 if (!m_globalObject) 138 return; 139 static_cast<ScriptInterpreter*>(m_globalObject->interpreter())->forgetDOMObject(event); 140 } 141 142 ScriptInterpreter* KJSProxy::interpreter() 143 { 144 initScriptIfNeeded(); 145 return static_cast<ScriptInterpreter*>(m_globalObject->interpreter()); 141 ScriptInterpreter::forgetDOMObject(event); 146 142 } 147 143 148 144 void KJSProxy::initScript() 149 145 { 150 if (m_globalObject)151 return;152 153 // Build the global object - which is a Window instance154 JSLock lock; 155 156 m_globalObject = new JSDOMWindow(m_frame->domWindow()); 157 ScriptInterpreter* interpreter = new ScriptInterpreter(m_globalObject, m_frame); // m_globalObject now owns interpreter158 159 String userAgent = m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->URL() : KURL());160 if (userAgent.find("Microsoft") >= 0 || userAgent.find("MSIE") >= 0)161 interpreter->setCompatMode(Interpreter::IECompat);162 else163 // If we find "Mozilla" but not "(compatible, ...)" we are a real Netscape164 if (userAgent.find("Mozilla") >= 0 && userAgent.find("compatible") == -1)165 interpreter->setCompatMode(Interpreter::NetscapeCompat);166 167 m_frame->loader()->dispatchWindowObjectAvailable();146 if (m_globalObject) 147 return; 148 149 JSLock lock; 150 151 m_globalObject = new JSDOMWindow(m_frame->domWindow()); 152 153 // FIXME: We can get rid of this (and eliminate compatMode entirely). 154 String userAgent = m_frame->loader()->userAgent(m_frame->document() ? m_frame->document()->URL() : KURL()); 155 if (userAgent.find("Microsoft") >= 0 || userAgent.find("MSIE") >= 0) 156 m_globalObject->setCompatMode(IECompat); 157 else { 158 // If we find "Mozilla" but not "(compatible, ...)" we are a real Netscape 159 if (userAgent.find("Mozilla") >= 0 && userAgent.find("compatible") == -1) 160 m_globalObject->setCompatMode(NetscapeCompat); 161 } 162 163 m_frame->loader()->dispatchWindowObjectAvailable(); 168 164 } 169 165 … … 177 173 } 178 174 175 bool KJSProxy::processingUserGesture() const 176 { 177 if (!m_globalObject) 178 return false; 179 180 if (Event* event = m_globalObject->currentEvent()) { 181 const AtomicString& type = event->type(); 182 if ( // mouse events 183 type == clickEvent || type == mousedownEvent || 184 type == mouseupEvent || type == dblclickEvent || 185 // keyboard events 186 type == keydownEvent || type == keypressEvent || 187 type == keyupEvent || 188 // other accepted events 189 type == selectEvent || type == changeEvent || 190 type == focusEvent || type == blurEvent || 191 type == submitEvent) 192 return true; 193 } else { // no event 194 if (m_processingInlineCode && !m_processingTimerCallback) { 195 // This is the <a href="javascript:window.open('...')> case -> we let it through 196 return true; 197 } 198 // This is the <script>window.open(...)</script> case or a timer callback -> block it 199 } 200 return false; 201 } 202 179 203 } // namespace WebCore -
trunk/WebCore/bindings/js/kjs_proxy.h
r28328 r28468 29 29 class JSGlobalObject; 30 30 class JSValue; 31 class ScriptInterpreter;32 31 } 33 32 … … 40 39 class String; 41 40 42 // FIXME: Rename this class to JSController and merge functions from 43 // ScriptInterpreter into it. 41 // FIXME: Rename this class to JSController and the Frame function to javaScript(). 44 42 45 43 class KJSProxy { … … 48 46 ~KJSProxy(); 49 47 50 bool haveInterpreter() const { return m_globalObject; } 51 KJS::ScriptInterpreter* interpreter(); 52 KJS::JSGlobalObject* globalObject() 48 bool haveGlobalObject() const { return m_globalObject; } 49 JSDOMWindow* globalObject() 53 50 { 54 51 initScriptIfNeeded(); … … 67 64 void clearDocumentWrapper(); 68 65 66 void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; } 67 bool processingUserGesture() const; 68 69 69 private: 70 70 void initScriptIfNeeded() … … 78 78 Frame* m_frame; 79 79 int m_handlerLineno; 80 81 bool m_processingTimerCallback; 82 bool m_processingInlineCode; 80 83 }; 81 84 -
trunk/WebCore/bindings/js/kjs_window.cpp
r28415 r28468 223 223 // the non-thread-safe WebCore structures it references. 224 224 Collector::collectOnMainThreadOnly(this); 225 226 // Time in milliseconds before the script timeout handler kicks in. 227 setTimeoutTime(10000); 225 228 } 226 229 … … 260 263 Window *Window::retrieveActive(ExecState *exec) 261 264 { 262 JSValue *imp = exec->dynamic Interpreter()->globalObject();265 JSValue *imp = exec->dynamicGlobalObject(); 263 266 ASSERT(imp); 264 267 return static_cast<Window*>(imp); … … 294 297 if (!frame) 295 298 return false; 296 if ( static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->wasRunByUserGesture())299 if (window->impl()->frame()->scriptProxy()->processingUserGesture()); 297 300 return true; 298 301 Settings* settings = frame->settings(); … … 390 393 if (!url.startsWith("javascript:", false) || newWindow->isSafeScript(exec)) { 391 394 String completedURL = url.isEmpty() ? url : activeFrame->document()->completeURL(url); 392 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();395 bool userGesture = activeFrame->scriptProxy()->processingUserGesture(); 393 396 394 397 if (created) { … … 727 730 DeprecatedString dstUrl = p->loader()->completeURL(DeprecatedString(value->toString(exec))).url(); 728 731 if (!dstUrl.startsWith("javascript:", false) || isSafeScript(exec)) { 729 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();732 bool userGesture = p->scriptProxy()->processingUserGesture(); 730 733 // We want a new history item if this JS was called via a user gesture 731 734 impl()->frame()->loader()->scheduleLocationChange(dstUrl, p->loader()->outgoingReferrer(), false, userGesture); … … 935 938 if (!frame) 936 939 return false; 937 Frame* activeFrame = static_cast<ScriptInterpreter*>(exec->dynamicInterpreter())->frame();940 Frame* activeFrame = Window::retrieveActive(exec)->impl()->frame(); 938 941 if (!activeFrame) 939 942 return false; … … 1066 1069 clearProperties(); 1067 1070 clearHelperObjectProperties(); 1068 setPrototype(JSDOMWindowPrototype::self()); // clear the prototype1069 1071 1070 1072 // Now recreate a working global object for the next URL that will use us; but only if we haven't been 1071 1073 // disconnected yet 1072 1074 if (Frame* frame = impl()->frame()) 1073 frame->scriptProxy()-> interpreter()->resetGlobalObjectProperties();1075 frame->scriptProxy()->globalObject()->reset(JSDOMWindowPrototype::self()); 1074 1076 1075 1077 // there's likely to be lots of garbage now … … 1080 1082 { 1081 1083 d->m_evt = evt; 1084 } 1085 1086 Event* Window::currentEvent() 1087 { 1088 return d->m_evt; 1082 1089 } 1083 1090 … … 1357 1364 const Window* window = Window::retrieveWindow(frame); 1358 1365 if (!completedURL.isEmpty() && (!completedURL.startsWith("javascript:", false) || (window && window->isSafeScript(exec)))) { 1359 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();1366 bool userGesture = activeFrame->scriptProxy()->processingUserGesture(); 1360 1367 frame->loader()->scheduleLocationChange(completedURL, activeFrame->loader()->outgoingReferrer(), false, userGesture); 1361 1368 } … … 1682 1689 return; 1683 1690 1684 ScriptInterpreter* interpreter = scriptProxy->interpreter();1685 1686 interpreter->setProcessingTimerCallback(true);1691 Window* globalObject = scriptProxy->globalObject(); 1692 1693 scriptProxy->setProcessingTimerCallback(true); 1687 1694 1688 1695 if (JSValue* func = m_func.get()) { … … 1690 1697 if (func->isObject() && static_cast<JSObject*>(func)->implementsCall()) { 1691 1698 ExecState* exec = window->globalExec(); 1692 ASSERT(window == interpreter->globalObject());1699 ASSERT(window == globalObject); 1693 1700 1694 1701 List args; … … 1698 1705 } 1699 1706 1700 interpreter->startTimeoutCheck();1707 globalObject->startTimeoutCheck(); 1701 1708 static_cast<JSObject*>(func)->call(exec, window, args); 1702 interpreter->stopTimeoutCheck();1709 globalObject->stopTimeoutCheck(); 1703 1710 if (exec->hadException()) { 1704 1711 JSObject* exception = exec->exception()->toObject(exec); … … 1723 1730 doc->updateRendering(); 1724 1731 1725 interpreter->setProcessingTimerCallback(false);1732 scriptProxy->setProcessingTimerCallback(false); 1726 1733 } 1727 1734 … … 2032 2039 Frame* activeFrame = Window::retrieveActive(exec)->impl()->frame(); 2033 2040 if (!url.url().startsWith("javascript:", false) || sameDomainAccess) { 2034 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();2041 bool userGesture = activeFrame->scriptProxy()->processingUserGesture(); 2035 2042 m_frame->loader()->scheduleLocationChange(url.url(), activeFrame->loader()->outgoingReferrer(), false, userGesture); 2036 2043 } … … 2053 2060 const Window* window = Window::retrieveWindow(frame); 2054 2061 if (!str.startsWith("javascript:", false) || (window && window->isSafeScript(exec))) { 2055 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();2062 bool userGesture = p->scriptProxy()->processingUserGesture(); 2056 2063 frame->loader()->scheduleLocationChange(p->loader()->completeURL(str).url(), p->loader()->outgoingReferrer(), true, userGesture); 2057 2064 } … … 2075 2082 2076 2083 if (!frame->loader()->url().url().startsWith("javascript:", false) || (window && window->isSafeScript(exec))) { 2077 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();2084 bool userGesture = Window::retrieveActive(exec)->impl()->frame()->scriptProxy()->processingUserGesture(); 2078 2085 frame->loader()->scheduleRefresh(userGesture); 2079 2086 } … … 2097 2104 DeprecatedString dstUrl = p->loader()->completeURL(DeprecatedString(args[0]->toString(exec))).url(); 2098 2105 if (!dstUrl.startsWith("javascript:", false) || (window && window->isSafeScript(exec))) { 2099 bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();2106 bool userGesture = p->scriptProxy()->processingUserGesture(); 2100 2107 // We want a new history item if this JS was called via a user gesture 2101 2108 frame->loader()->scheduleLocationChange(dstUrl, p->loader()->outgoingReferrer(), false, userGesture); -
trunk/WebCore/bindings/js/kjs_window.h
r28415 r28468 23 23 #include "PlatformString.h" 24 24 #include "kjs_binding.h" 25 #include <kjs/protect.h> 25 26 #include <wtf/HashMap.h> 26 27 #include <wtf/OwnPtr.h> … … 106 107 static bool isSafeScript(const JSGlobalObject *origin, const JSGlobalObject *target); 107 108 virtual bool isSafeScript(const JSGlobalObject* other) const { return Window::isSafeScript(this, other); } 109 bool isSafeScript(ExecState*) const; 108 110 109 111 Location* location() const; … … 123 125 void clear(); 124 126 125 // Set the current "event" object126 127 void setCurrentEvent(WebCore::Event*); 128 WebCore::Event* currentEvent(); 127 129 128 130 // Set a place to put a dialog return value when the window is cleared. … … 142 144 virtual ExecState* globalExec(); 143 145 virtual bool shouldInterruptScript() const; 144 bool isSafeScript(ExecState*) const;145 146 146 147 enum { -
trunk/WebCore/bindings/objc/WebScriptObject.mm
r28328 r28468 37 37 #import <JavaScriptCore/APICast.h> 38 38 #import <JavaScriptCore/JSGlobalObject.h> 39 #import <JavaScriptCore/interpreter.h> 39 40 40 41 using namespace KJS; … … 250 251 JSLock lock; 251 252 252 Interpreter *first, *interp = Interpreter::firstInterpreter();253 JSGlobalObject* head = JSGlobalObject::head(); 253 254 254 255 // This code assumes that we only ever have one running interpreter. A … … 256 257 // in the future we may have the ability to run multiple interpreters, 257 258 // in which case this will have to change. 258 first = interp;259 JSGlobalObject* o = head; 259 260 do { 260 if (! interp)261 if (!o) 261 262 return NO; 262 263 263 264 // If the interpreter has a current exec state, we set the exception. 264 if (ExecState* exec = interp->currentExec()) {265 if (ExecState* exec = o->currentExec()) { 265 266 throwError(exec, GeneralError, exceptionMessage); 266 267 return YES; 267 268 } 268 interp = interp->nextInterpreter();269 } while ( interp != first);269 o = o->next(); 270 } while (o != head); 270 271 271 272 return NO; … … 310 311 return nil; 311 312 312 [self _rootObject]-> interpreter()->startTimeoutCheck();313 [self _rootObject]->globalObject()->startTimeoutCheck(); 313 314 JSValue *result = funcImp->call(exec, [self _imp], argList); 314 [self _rootObject]-> interpreter()->stopTimeoutCheck();315 [self _rootObject]->globalObject()->stopTimeoutCheck(); 315 316 316 317 if (exec->hadException()) { … … 339 340 JSLock lock; 340 341 341 [self _rootObject]-> interpreter()->startTimeoutCheck();342 Completion completion = [self _rootObject]->interpreter()->evaluate(UString(), 0, String(script));343 [self _rootObject]-> interpreter()->stopTimeoutCheck();342 [self _rootObject]->globalObject()->startTimeoutCheck(); 343 Completion completion = Interpreter::evaluate([self _rootObject]->globalObject()->globalExec(), UString(), 0, String(script)); 344 [self _rootObject]->globalObject()->stopTimeoutCheck(); 344 345 ComplType type = completion.complType(); 345 346 … … 496 497 JSLock lock; 497 498 498 if (ExecState* exec = [self _rootObject]-> interpreter()->currentExec()) {499 if (ExecState* exec = [self _rootObject]->globalObject()->currentExec()) { 499 500 throwError(exec, GeneralError, description); 500 501 } else -
trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm
r28327 r28468 297 297 } else { 298 298 push(@headerContent, "#include \"kjs_binding.h\"\n"); 299 push(@headerContent, "#include <kjs/JSGlobalObject.h>\n"); 300 push(@headerContent, "#include <kjs/object_object.h>\n"); 299 301 } 300 302 } … … 541 543 push(@headerContent, " : KJS::JSObject(${parentClassName}Prototype::self(exec)) { }\n"); 542 544 } else { 543 push(@headerContent, " : KJS::JSObject(exec->lexical Interpreter()->builtinObjectPrototype()) { }\n");545 push(@headerContent, " : KJS::JSObject(exec->lexicalGlobalObject()->objectPrototype()) { }\n"); 544 546 } 545 547 } … … 1747 1749 ${className}Constructor(ExecState* exec) 1748 1750 { 1749 setPrototype(exec->lexical Interpreter()->builtinObjectPrototype());1751 setPrototype(exec->lexicalGlobalObject()->objectPrototype()); 1750 1752 putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec), None); 1751 1753 } … … 1800 1802 1801 1803 ${name}(KJS::ExecState* exec, int len, const KJS::Identifier& name) 1802 : KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexical Interpreter()->builtinFunctionPrototype()), name)1804 : KJS::InternalFunctionImp(static_cast<KJS::FunctionPrototype*>(exec->lexicalGlobalObject()->functionPrototype()), name) 1803 1805 { 1804 1806 put(exec, exec->propertyNames().length, KJS::jsNumber(len), KJS::DontDelete | KJS::ReadOnly | KJS::DontEnum); -
trunk/WebCore/bridge/JavaScriptStatistics.cpp
r20332 r28468 55 55 { 56 56 JSLock lock; 57 return Collector::num Interpreters();57 return Collector::numGlobalObjects(); 58 58 } 59 59 -
trunk/WebCore/bridge/mac/WebCoreScriptDebugger.mm
r28328 r28468 35 35 #import "WebCoreObjCExtras.h" 36 36 #import "WebScriptObjectPrivate.h" 37 #import <JavaScriptCore/ExecState.h> 38 #import <JavaScriptCore/JSGlobalObject.h> 37 39 #import <JavaScriptCore/debugger.h> 38 #import <JavaScriptCore/ExecState.h>39 40 #import <JavaScriptCore/function.h> 40 #import <JavaScriptCore/ JSGlobalObject.h>41 #import <JavaScriptCore/interpreter.h> 41 42 42 43 using namespace KJS; … … 83 84 public: 84 85 // constructor 85 WebCoreScriptDebuggerImp(WebCoreScriptDebugger *objc, Interpreter *interp) : _objc(objc) {86 WebCoreScriptDebuggerImp(WebCoreScriptDebugger *objc, JSGlobalObject* globalObject) : _objc(objc) { 86 87 _nested = true; 87 _current = [_objc _enterFrame: interp->globalObject()->globalExec()];88 attach( interp);88 _current = [_objc _enterFrame:globalObject->globalExec()]; 89 attach(globalObject); 89 90 [[_objc delegate] enteredFrame:_current sourceId:-1 line:-1]; 90 91 _nested = false; … … 144 145 // 145 146 // The WebCoreScriptDebugger has two faces, one for Objective-C (this class), and another (WebCoreScriptDebuggerImp) 146 // for C++. The ObjC side creates the C++ side, which does the real work of attaching to the interpreterand147 // for C++. The ObjC side creates the C++ side, which does the real work of attaching to the global object and 147 148 // forwarding the KJS debugger callbacks to the delegate. 148 149 … … 161 162 _delegate = delegate; 162 163 _globalObj = [_delegate globalObject]; 163 _debugger = new WebCoreScriptDebuggerImp(self, [_globalObj _rootObject]-> interpreter());164 _debugger = new WebCoreScriptDebuggerImp(self, [_globalObj _rootObject]->globalObject()); 164 165 } 165 166 return self; … … 333 334 // method of the same name, due to the treatment of exceptions. 334 335 336 // FIXME: If "script" contains var declarations, the machinery to handle local variables 337 // efficiently in JavaScriptCore will not work properly. This could lead to crashes or 338 // incorrect variable values. So this is not appropriate for evaluating arbitrary script. 335 339 - (id)evaluateWebScript:(NSString *)script 336 340 { … … 339 343 UString code = String(script); 340 344 341 ExecState *state = _state; 342 Interpreter *interp = state->dynamicInterpreter(); 343 JSObject *globObj = interp->globalObject(); 345 ExecState* state = _state; 346 JSGlobalObject* globalObject = state->dynamicGlobalObject(); 344 347 345 348 // find "eval" 346 349 JSObject *eval = NULL; 347 350 if (state->currentBody()) { // "eval" won't work without context (i.e. at global scope) 348 JSValue *v = glob Obj->get(state, "eval");351 JSValue *v = globalObject->get(state, "eval"); 349 352 if (v->isObject() && static_cast<JSObject *>(v)->implementsCall()) 350 353 eval = static_cast<JSObject *>(v); 351 354 else 352 355 // no "eval" - fallback operates on global exec state 353 state = interp->globalObject()->globalExec();356 state = globalObject->globalExec(); 354 357 } 355 358 … … 365 368 } else 366 369 // no "eval", or no context (i.e. global scope) - use global fallback 367 result = interp->evaluate(UString(), 0, code.data(), code.size(), globObj).value();370 result = Interpreter::evaluate(state, UString(), 0, code.data(), code.size(), globalObject).value(); 368 371 369 372 if (state->hadException()) -
trunk/WebCore/history/CachedPage.cpp
r27277 r28468 82 82 , m_windowProperties(new SavedProperties) 83 83 , m_locationProperties(new SavedProperties) 84 , m_ interpreterBuiltins(new SavedBuiltins)84 , m_windowBuiltins(new SavedBuiltins) 85 85 { 86 86 #ifndef NDEBUG … … 99 99 100 100 if (proxy && window) { 101 proxy-> interpreter()->saveBuiltins(*m_interpreterBuiltins.get());101 proxy->globalObject()->saveBuiltins(*m_windowBuiltins.get()); 102 102 window->saveProperties(*m_windowProperties.get()); 103 103 window->location()->saveProperties(*m_locationProperties.get()); … … 133 133 134 134 if (proxy && window) { 135 proxy-> interpreter()->restoreBuiltins(*m_interpreterBuiltins.get());135 proxy->globalObject()->restoreBuiltins(*m_windowBuiltins.get()); 136 136 window->restoreProperties(*m_windowProperties.get()); 137 137 window->location()->restoreProperties(*m_locationProperties.get()); … … 187 187 m_windowProperties.clear(); 188 188 m_locationProperties.clear(); 189 m_ interpreterBuiltins.clear();189 m_windowBuiltins.clear(); 190 190 m_pausedTimeouts.clear(); 191 191 -
trunk/WebCore/history/CachedPage.h
r27776 r28468 87 87 OwnPtr<KJS::SavedProperties> m_windowProperties; 88 88 OwnPtr<KJS::SavedProperties> m_locationProperties; 89 OwnPtr<KJS::SavedBuiltins> m_ interpreterBuiltins;89 OwnPtr<KJS::SavedBuiltins> m_windowBuiltins; 90 90 OwnPtr<KJS::PausedTimeouts> m_pausedTimeouts; 91 91 -
trunk/WebCore/loader/FrameLoader.cpp
r28464 r28468 1723 1723 1724 1724 if (rootFrame->scriptProxy()) 1725 return rootFrame->scriptProxy()-> interpreter()->wasRunByUserGesture();1725 return rootFrame->scriptProxy()->processingUserGesture(); 1726 1726 1727 1727 return true; // If JavaScript is disabled, a user gesture must have initiated the navigation … … 4536 4536 { 4537 4537 Settings* settings = m_frame->settings(); 4538 if (!settings || !settings->isJavaScriptEnabled() || !m_frame->scriptProxy()->have Interpreter())4538 if (!settings || !settings->isJavaScriptEnabled() || !m_frame->scriptProxy()->haveGlobalObject()) 4539 4539 return; 4540 4540 -
trunk/WebCore/page/Frame.cpp
r28411 r28468 195 195 #endif 196 196 197 if (d->m_jscript && d->m_jscript->have Interpreter())197 if (d->m_jscript && d->m_jscript->haveGlobalObject()) 198 198 static_cast<KJS::Window*>(d->m_jscript->globalObject())->disconnectFrame(); 199 199 … … 1818 1818 1819 1819 // This will stop any JS timers 1820 if (d->m_jscript && d->m_jscript->have Interpreter())1820 if (d->m_jscript && d->m_jscript->haveGlobalObject()) 1821 1821 if (KJS::Window* w = KJS::Window::retrieveWindow(this)) 1822 1822 w->disconnectFrame(); -
trunk/WebKit/mac/ChangeLog
r28446 r28468 1 2007-12-04 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Third step in refactoring JSGlobalObject: Moved data members and data 6 member access from Interpreter to JSGlobalObject. 7 8 * WebView/WebFrame.mm: 9 (-[WebFrame _attachScriptDebugger]): 10 1 11 2007-12-04 Kevin McCullough <kmccullough@apple.com> 2 12 -
trunk/WebKit/mac/WebView/WebFrame.mm
r28328 r28468 367 367 - (void)_attachScriptDebugger 368 368 { 369 if (!_private->scriptDebugger && core(self)->scriptProxy()->have Interpreter())369 if (!_private->scriptDebugger && core(self)->scriptProxy()->haveGlobalObject()) 370 370 _private->scriptDebugger = [[WebScriptDebugger alloc] initWithWebFrame:self]; 371 371 } -
trunk/WebKit/win/ChangeLog
r28466 r28468 1 2007-12-04 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Third step in refactoring JSGlobalObject: Moved data members and data 6 member access from Interpreter to JSGlobalObject. 7 8 * WebFrame.cpp: 9 (WebFrame::globalContext): 10 (WebFrame::attachScriptDebugger): 11 (WebFrame::windowObjectCleared): 12 * WebScriptDebugger.cpp: 13 (WebScriptDebugger::WebScriptDebugger): 14 1 15 2007-12-05 Steve Falkenburg <sfalken@apple.com> 2 16 -
trunk/WebKit/win/WebFrame.cpp
r28405 r28468 768 768 void WebFrame::attachScriptDebugger() 769 769 { 770 if (!m_scriptDebugger && core(this)->scriptProxy()->have Interpreter())770 if (!m_scriptDebugger && core(this)->scriptProxy()->haveGlobalObject()) 771 771 m_scriptDebugger.set(new WebScriptDebugger(this)); 772 772 } -
trunk/WebKit/win/WebScriptDebugger.cpp
r28413 r28468 57 57 return; 58 58 59 Interpreter* interp(proxy->interpreter());60 attach( interp);59 JSGlobalObject* globalObject = proxy->globalObject(); 60 attach(globalObject); 61 61 62 62 m_frame->webView(&m_webView); 63 63 ASSERT(m_webView); 64 64 65 callEvent( proxy->globalObject()->globalExec(), -1, -1, 0, List());65 callEvent(globalObject->globalExec(), -1, -1, 0, List()); 66 66 m_callingServer = false; 67 67 }
Note: See TracChangeset
for help on using the changeset viewer.