Changeset 27097 in webkit
- Timestamp:
- Oct 26, 2007 1:32:40 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r27096 r27097 1 2007-10-26 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Oliver. 4 5 - moved Context class into ExecState.{h,cpp} in preparation for merging 6 ExecState and Context classes. 7 8 * kjs/ExecState.h: Moved CodeType enum and Context class here in 9 preparation for merging ExecState and Context. 10 * kjs/ExecState.cpp: Moved Context class here from Context.cpp. 11 (KJS::Context::Context): 12 (KJS::Context::~Context): 13 (KJS::Context::mark): 14 * kjs/context.h: Removed. 15 * kjs/Context.cpp: Removed. 16 * kjs/function.h: Removed CodeType enum. 17 * kjs/LabelStack.h: Added. Pulled LabelStack class out of internal.h. 18 * kjs/internal.h: Removed LabelStack. 19 * JavaScriptCore.xcodeproj/project.pbxproj: Added new file, removed ones that are gone. 20 * kjs/collector.cpp: Fixed includes. 21 * kjs/function.cpp: ditto 22 * kjs/internal.cpp: ditto 23 * kjs/interpreter.cpp: ditto 24 * kjs/lookup.h: ditto 25 * kjs/nodes.cpp: ditto 26 1 27 2007-10-26 Mark Rowe <mrowe@apple.com> 2 28 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r27093 r27097 79 79 14BD5A320A3E91F600BAF59C /* JSValueRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */; }; 80 80 14BD5A360A3E91F600BAF59C /* JavaScriptCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 81 14F137830A3A765B00F26F90 /* context.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F137820A3A765B00F26F90 /* context.h */; settings = {ATTRIBUTES = (Private, ); }; };82 81 1CAF34890A6C421700ABE06E /* WebScriptObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CAF34880A6C421700ABE06E /* WebScriptObject.h */; }; 83 82 5186111E0CC824900081412B /* Deque.h in Headers */ = {isa = PBXBuildFile; fileRef = 5186111D0CC824830081412B /* Deque.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 98 97 6592C318098B7DE10003D4F6 /* Vector.h in Headers */ = {isa = PBXBuildFile; fileRef = 6592C316098B7DE10003D4F6 /* Vector.h */; settings = {ATTRIBUTES = (Private, ); }; }; 99 98 6592C319098B7DE10003D4F6 /* VectorTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 6592C317098B7DE10003D4F6 /* VectorTraits.h */; settings = {ATTRIBUTES = (Private, ); }; }; 99 65A7A5E00CD1D50E00061F8E /* LabelStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B813A80CD1D01900DF59D6 /* LabelStack.h */; settings = {ATTRIBUTES = (Private, ); }; }; 100 100 65B1749A09D0FEB700820339 /* array_object.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B1749909D0FEB700820339 /* array_object.lut.h */; }; 101 101 65B174F509D100FA00820339 /* math_object.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B174F109D100FA00820339 /* math_object.lut.h */; }; … … 436 436 14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JavaScriptCore.h; sourceTree = "<group>"; }; 437 437 14D857740A4696C80032146C /* testapi.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = testapi.js; sourceTree = "<group>"; }; 438 14F137580A3A727E00F26F90 /* Context.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Context.cpp; sourceTree = "<group>"; };439 14F137820A3A765B00F26F90 /* context.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = context.h; sourceTree = "<group>"; };440 438 1C9051420BA9E8A70081E9D0 /* Version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; }; 441 439 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = JavaScriptCore.xcconfig; sourceTree = "<group>"; }; … … 517 515 65B174F209D100FA00820339 /* number_object.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = number_object.lut.h; sourceTree = "<group>"; }; 518 516 65B174F409D100FA00820339 /* string_object.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = string_object.lut.h; sourceTree = "<group>"; }; 517 65B813A80CD1D01900DF59D6 /* LabelStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LabelStack.h; sourceTree = "<group>"; }; 519 518 65C02FBB0637462A003E7EE6 /* protect.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = protect.h; sourceTree = "<group>"; tabWidth = 8; }; 520 519 65C647B3093EF8D60022C380 /* RefPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RefPtr.h; sourceTree = "<group>"; tabWidth = 8; }; … … 966 965 F5BB2BC5030F772101FCFE1D /* completion.h */, 967 966 F68EBB8C0255D4C601FF60F7 /* config.h */, 968 14F137580A3A727E00F26F90 /* Context.cpp */,969 14F137820A3A765B00F26F90 /* context.h */,970 967 F692A8540255597D01FF60F7 /* create_hash_table */, 971 968 F692A8550255597D01FF60F7 /* date_object.cpp */, … … 1003 1000 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */, 1004 1001 93F1981A08245AAE001E9ABC /* keywords.table */, 1002 65B813A80CD1D01900DF59D6 /* LabelStack.h */, 1005 1003 F692A8650255597D01FF60F7 /* lexer.cpp */, 1006 1004 F692A8660255597D01FF60F7 /* lexer.h */, … … 1130 1128 files = ( 1131 1129 932F5B400822A1C700736975 /* array_object.h in Headers */, 1130 65A7A5E00CD1D50E00061F8E /* LabelStack.h in Headers */, 1132 1131 932F5B420822A1C700736975 /* collector.h in Headers */, 1133 1132 932F5B430822A1C700736975 /* date_object.h in Headers */, … … 1232 1231 935AF46E09E9D9DB00ACD1D8 /* UnusedParam.h in Headers */, 1233 1232 BCF655590A2049710038A194 /* MathExtras.h in Headers */, 1234 14F137830A3A765B00F26F90 /* context.h in Headers */,1235 1233 14BD5A310A3E91F600BAF59C /* JSContextRef.h in Headers */, 1236 1234 14BD5A360A3E91F600BAF59C /* JavaScriptCore.h in Headers */, -
trunk/JavaScriptCore/bindings/runtime_method.cpp
r26715 r27097 27 27 #include "runtime_method.h" 28 28 29 #include " context.h"29 #include "ExecState.h" 30 30 #include "runtime_object.h" 31 31 #include "function_object.h" -
trunk/JavaScriptCore/kjs/AllInOneFile.cpp
r26881 r27097 37 37 #endif 38 38 #include "CommonIdentifiers.cpp" 39 #include "Context.cpp"40 39 #include "date_object.cpp" 41 40 #include "DateMath.cpp" -
trunk/JavaScriptCore/kjs/ExecState.cpp
r27027 r27097 23 23 */ 24 24 25 #include "context.h" 25 #include "config.h" 26 #include "ExecState.h" 27 26 28 #include "JSGlobalObject.h" 27 #include "ExecState.h"28 29 #include "internal.h" 29 30 30 31 namespace KJS { 32 33 34 // ECMA 10.2 35 Context::Context(JSGlobalObject* glob, Interpreter* interpreter, JSObject* thisV, 36 FunctionBodyNode* currentBody, CodeType type, Context* callingCon, 37 FunctionImp* func, const List* args) 38 : m_interpreter(interpreter) 39 , m_savedContext(interpreter->context()) 40 , m_currentBody(currentBody) 41 , m_function(func) 42 , m_arguments(args) 43 , m_iterationDepth(0) 44 , m_switchDepth(0) 45 { 46 m_codeType = type; 47 m_callingContext = callingCon; 48 49 // create and initialize activation object (ECMA 10.1.6) 50 if (type == FunctionCode) { 51 m_activation = new ActivationImp(func, *args); 52 m_variable = m_activation; 53 } else { 54 m_activation = 0; 55 m_variable = glob; 56 } 57 58 // ECMA 10.2 59 switch(type) { 60 case EvalCode: 61 if (m_callingContext) { 62 scope = m_callingContext->scopeChain(); 63 m_variable = m_callingContext->variableObject(); 64 m_thisVal = m_callingContext->thisValue(); 65 break; 66 } // else same as GlobalCode 67 case GlobalCode: 68 scope.clear(); 69 scope.push(glob); 70 m_thisVal = static_cast<JSObject*>(glob); 71 break; 72 case FunctionCode: 73 scope = func->scope(); 74 scope.push(m_activation); 75 m_variable = m_activation; // TODO: DontDelete ? (ECMA 10.2.3) 76 m_thisVal = thisV; 77 break; 78 } 79 80 m_interpreter->setContext(this); 81 } 82 83 Context::~Context() 84 { 85 m_interpreter->setContext(m_savedContext); 86 87 // The arguments list is only needed to potentially create the arguments object, 88 // which isn't accessible from nested scopes so we can discard the list as soon 89 // as the function is done running. 90 // This prevents lists of Lists from building up, waiting to be garbage collected 91 ActivationImp* activation = static_cast<ActivationImp*>(m_activation); 92 if (activation) 93 activation->releaseArguments(); 94 } 95 96 void Context::mark() 97 { 98 for (Context* context = this; context; context = context->m_callingContext) 99 context->scope.mark(); 100 } 31 101 32 102 Interpreter* ExecState::lexicalInterpreter() const -
trunk/JavaScriptCore/kjs/ExecState.h
r20759 r27097 1 // -*- mode: c++; c-basic-offset: 4 -*- 1 2 /* 2 * This file is part of the KDE libraries3 3 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 4 4 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 5 * Copyright (C) 2003 Apple Computer, Inc.5 * Copyright (C) 2003, 2007 Apple Inc. All rights reserved. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 28 28 #include "types.h" 29 29 #include "CommonIdentifiers.h" 30 31 namespace KJS { 32 class Context; 33 class Interpreter; 34 30 #include "LabelStack.h" 31 #include "scope_chain.h" 32 33 namespace KJS { 34 35 enum CodeType { 36 GlobalCode, 37 EvalCode, 38 FunctionCode, 39 }; 40 41 class ExecState; 42 class JSGlobalObject; 43 class ScopeChain; 35 44 class Interpreter; 36 45 class FunctionImp; 37 46 class GlobalFuncImp; 38 39 /** 40 * Represents the current state of script execution. This object allows you 41 * obtain a handle the interpreter that is currently executing the script, 42 * and also the current execution context. 43 */ 44 class ExecState { 45 friend class Interpreter; 46 friend class FunctionImp; 47 friend class GlobalFuncImp; 48 public: 47 class FunctionBodyNode; 48 49 49 /** 50 * Returns the interpreter associated with this execution state50 * @short Execution context. 51 51 * 52 * @return The interpreter executing the script 52 * Represents an execution context, as specified by section 10 of the ECMA 53 * spec. 54 * 55 * An execution context contains information about the current state of the 56 * script - the scope for variable lookup, the value of "this", etc. A new 57 * execution context is entered whenever global code is executed (e.g. with 58 * Interpreter::evaluate()), a function is called (see 59 * Object::call()), or the builtin "eval" function is executed. 60 * 61 * Most inheritable functions in the KJS api take a ExecState pointer as 62 * their first parameter. This can be used to obtain a handle to the current 63 * execution context. 53 64 */ 54 Interpreter* dynamicInterpreter() const { return m_interpreter; } 55 65 class Context { 66 public: 67 Context(JSGlobalObject*, Interpreter*, JSObject* thisV, 68 FunctionBodyNode* currentBody, CodeType type = GlobalCode, 69 Context* callingContext = 0, FunctionImp* function = 0, const List* args = 0); 70 ~Context(); 71 72 /** 73 * Returns the scope chain for this execution context. This is used for 74 * variable lookup, with the list being searched from start to end until a 75 * variable is found. 76 * 77 * @return The execution context's scope chain 78 */ 79 const ScopeChain& scopeChain() const { return scope; } 80 81 /** 82 * Returns the variable object for the execution context. This contains a 83 * property for each variable declared in the execution context. 84 * 85 * @return The execution context's variable object 86 */ 87 JSObject* variableObject() const { return m_variable; } 88 void setVariableObject(JSObject* v) { m_variable = v; } 89 90 /** 91 * Returns the "this" value for the execution context. This is the value 92 * returned when a script references the special variable "this". It should 93 * always be an Object, unless application-specific code has passed in a 94 * different type. 95 * 96 * The object that is used as the "this" value depends on the type of 97 * execution context - for global contexts, the global object is used. For 98 * function objewcts, the value is given by the caller (e.g. in the case of 99 * obj.func(), obj would be the "this" value). For code executed by the 100 * built-in "eval" function, the this value is the same as the calling 101 * context. 102 * 103 * @return The execution context's "this" value 104 */ 105 JSObject* thisValue() const { return m_thisVal; } 106 107 /** 108 * Returns the context from which the current context was invoked. For 109 * global code this will be a null context (i.e. one for which 110 * isNull() returns true). You should check isNull() on the returned 111 * value before calling any of it's methods. 112 * 113 * @return The calling execution context 114 */ 115 Context* callingContext() { return m_callingContext; } 116 117 JSObject* activationObject() { return m_activation; } 118 CodeType codeType() { return m_codeType; } 119 FunctionBodyNode* currentBody() { return m_currentBody; } 120 FunctionImp* function() const { return m_function; } 121 const List* arguments() const { return m_arguments; } 122 123 void pushScope(JSObject* s) { scope.push(s); } 124 void popScope() { scope.pop(); } 125 LabelStack* seenLabels() { return &ls; } 126 127 void pushIteration() { m_iterationDepth++; } 128 void popIteration() { m_iterationDepth--; } 129 bool inIteration() const { return (m_iterationDepth > 0); } 130 131 void pushSwitch() { m_switchDepth++; } 132 void popSwitch() { m_switchDepth--; } 133 bool inSwitch() const { return (m_switchDepth > 0); } 134 135 void mark(); 136 137 void setExecState(ExecState* exec) { m_execState = exec; } 138 ExecState* execState() { return m_execState; } 139 140 private: 141 // Contexts are always stack-allocated, and the garbage collector 142 // marks the stack, so we don't need to protect the objects below from GC. 143 144 Interpreter* m_interpreter; 145 Context* m_callingContext; 146 Context* m_savedContext; 147 FunctionBodyNode* m_currentBody; 148 ExecState* m_execState; 149 150 FunctionImp* m_function; 151 const List* m_arguments; 152 JSObject* m_activation; 153 154 ScopeChain scope; 155 JSObject* m_variable; 156 JSObject* m_thisVal; 157 158 LabelStack ls; 159 int m_iterationDepth; 160 int m_switchDepth; 161 CodeType m_codeType; 162 }; 163 164 56 165 /** 57 * Returns the interpreter associated with the current scope's 58 * global object 59 * 60 * @return The interpreter currently in scope 166 * Represents the current state of script execution. This object allows you 167 * obtain a handle the interpreter that is currently executing the script, 168 * and also the current execution context. 61 169 */ 62 Interpreter* lexicalInterpreter() const; 63 64 /** 65 * Returns the execution context associated with this execution state 66 * 67 * @return The current execution state context 68 */ 69 Context* context() const { return m_context; } 70 71 void setException(JSValue* e) { m_exception = e; } 72 void clearException() { m_exception = 0; } 73 JSValue* exception() const { return m_exception; } 74 JSValue** exceptionSlot() { return &m_exception; } 75 bool hadException() const { return !!m_exception; } 76 77 // This is a workaround to avoid accessing the global variables for these identifiers in 78 // important property lookup functions, to avoid taking PIC branches in Mach-O binaries 79 const CommonIdentifiers& propertyNames() const { return *m_propertyNames; } 80 81 private: 82 ExecState(Interpreter* interp, Context* con) 83 : m_interpreter(interp) 84 , m_context(con) 85 , m_exception(0) 86 , m_propertyNames(CommonIdentifiers::shared()) 87 { 88 } 89 Interpreter* m_interpreter; 90 Context* m_context; 91 JSValue* m_exception; 92 CommonIdentifiers* m_propertyNames; 93 }; 170 class ExecState { 171 friend class Interpreter; 172 friend class FunctionImp; 173 friend class GlobalFuncImp; 174 public: 175 /** 176 * Returns the interpreter associated with this execution state 177 * 178 * @return The interpreter executing the script 179 */ 180 Interpreter* dynamicInterpreter() const { return m_interpreter; } 181 182 /** 183 * Returns the interpreter associated with the current scope's 184 * global object 185 * 186 * @return The interpreter currently in scope 187 */ 188 Interpreter* lexicalInterpreter() const; 189 190 /** 191 * Returns the execution context associated with this execution state 192 * 193 * @return The current execution state context 194 */ 195 Context* context() const { return m_context; } 196 197 void setException(JSValue* e) { m_exception = e; } 198 void clearException() { m_exception = 0; } 199 JSValue* exception() const { return m_exception; } 200 JSValue** exceptionSlot() { return &m_exception; } 201 bool hadException() const { return !!m_exception; } 202 203 // This is a workaround to avoid accessing the global variables for these identifiers in 204 // important property lookup functions, to avoid taking PIC branches in Mach-O binaries 205 const CommonIdentifiers& propertyNames() const { return *m_propertyNames; } 206 207 private: 208 ExecState(Interpreter* interp, Context* con) 209 : m_interpreter(interp) 210 , m_context(con) 211 , m_exception(0) 212 , m_propertyNames(CommonIdentifiers::shared()) 213 { 214 } 215 Interpreter* m_interpreter; 216 Context* m_context; 217 JSValue* m_exception; 218 CommonIdentifiers* m_propertyNames; 219 }; 94 220 95 221 } // namespace KJS -
trunk/JavaScriptCore/kjs/collector.cpp
r27002 r27097 24 24 #include "collector.h" 25 25 26 #include " context.h"26 #include "ExecState.h" 27 27 #include "internal.h" 28 28 #include "list.h" -
trunk/JavaScriptCore/kjs/function.cpp
r27072 r27097 26 26 #include "function.h" 27 27 28 #include " context.h"28 #include "ExecState.h" 29 29 #include "debugger.h" 30 30 #include "dtoa.h" -
trunk/JavaScriptCore/kjs/function.h
r27072 r27097 34 34 class FunctionBodyNode; 35 35 class FunctionPrototype; 36 37 enum CodeType {38 GlobalCode,39 EvalCode,40 FunctionCode,41 };42 36 43 37 class InternalFunctionImp : public JSObject { -
trunk/JavaScriptCore/kjs/internal.cpp
r27095 r27097 24 24 #include "internal.h" 25 25 26 #include "ExecState.h" 26 27 #include "array_object.h" 27 28 #include "bool_object.h" 28 29 #include "collector.h" 29 #include "context.h"30 30 #include "date_object.h" 31 31 #include "debugger.h" -
trunk/JavaScriptCore/kjs/internal.h
r27095 r27097 91 91 92 92 93 /**94 * @short The "label set" in Ecma-262 spec95 */96 class LabelStack : Noncopyable {97 public:98 LabelStack()99 : tos(0)100 {101 }102 ~LabelStack();103 104 /**105 * If id is not empty and is not in the stack already, puts it on top of106 * the stack and returns true, otherwise returns false107 */108 bool push(const Identifier &id);109 /**110 * Is the id in the stack?111 */112 bool contains(const Identifier &id) const;113 /**114 * Removes from the stack the last pushed id (what else?)115 */116 void pop();117 118 private:119 struct StackElem {120 Identifier id;121 StackElem *prev;122 };123 124 StackElem *tos;125 };126 127 128 93 // --------------------------------------------------------------------------- 129 94 // Evaluation … … 150 115 #endif 151 116 152 inline LabelStack::~LabelStack()153 {154 StackElem *prev;155 for (StackElem *e = tos; e; e = prev) {156 prev = e->prev;157 delete e;158 }159 }160 161 inline void LabelStack::pop()162 {163 if (StackElem *e = tos) {164 tos = e->prev;165 delete e;166 }167 }168 169 117 } // namespace 170 118 -
trunk/JavaScriptCore/kjs/interpreter.cpp
r27027 r27097 26 26 #include "interpreter.h" 27 27 28 #include "ExecState.h" 28 29 #include "JSGlobalObject.h" 29 30 #include "SavedBuiltins.h" … … 31 32 #include "bool_object.h" 32 33 #include "collector.h" 33 #include "context.h"34 34 #include "date_object.h" 35 35 #include "debugger.h" -
trunk/JavaScriptCore/kjs/lookup.h
r27022 r27097 23 23 #define KJS_lookup_h 24 24 25 #include " context.h"25 #include "ExecState.h" 26 26 #include "identifier.h" 27 27 #include "interpreter.h" -
trunk/JavaScriptCore/kjs/nodes.cpp
r27086 r27097 25 25 #include "nodes.h" 26 26 27 #include "ExecState.h" 27 28 #include "JSGlobalObject.h" 28 29 #include "PropertyNameArray.h" 29 #include "context.h"30 30 #include "debugger.h" 31 31 #include "function_object.h" -
trunk/WebCore/ChangeLog
r27083 r27097 1 2007-10-26 Maciej Stachowiak <mjs@apple.com> 2 3 Reviewed by Oliver. 4 5 - update for JavaScriptCore header changes 6 7 * bindings/objc/WebScriptObject.mm: 8 * bridge/mac/WebCoreScriptDebugger.mm: 9 1 10 2007-10-26 Alp Toker <alp@atoker.com> 2 11 -
trunk/WebCore/bindings/objc/WebScriptObject.mm
r27022 r27097 32 32 #import "WebCoreObjCExtras.h" 33 33 #import "WebCoreFrameBridge.h" 34 #import <JavaScriptCore/ context.h>34 #import <JavaScriptCore/ExecState.h> 35 35 #import <JavaScriptCore/objc_instance.h> 36 36 #import <JavaScriptCore/runtime_object.h> -
trunk/WebCore/bridge/mac/WebCoreScriptDebugger.mm
r27022 r27097 35 35 #import "WebCoreObjCExtras.h" 36 36 #import "WebScriptObjectPrivate.h" 37 #import <JavaScriptCore/context.h>38 37 #import <JavaScriptCore/debugger.h> 38 #import <JavaScriptCore/ExecState.h> 39 #import <JavaScriptCore/function.h> 39 40 #import <JavaScriptCore/JSGlobalObject.h> 40 41
Note: See TracChangeset
for help on using the changeset viewer.