Changeset 37257 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 3, 2008, 2:39:16 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ArrayConstructor.cpp
r36726 r37257 34 34 35 35 ArrayConstructor::ArrayConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ArrayPrototype* arrayPrototype) 36 : InternalFunction( exec, structure, Identifier(exec, arrayPrototype->classInfo()->className))36 : InternalFunction(&exec->globalData(), structure, Identifier(exec, arrayPrototype->classInfo()->className)) 37 37 { 38 38 // ECMA 15.4.3.1 Array.prototype -
trunk/JavaScriptCore/kjs/BooleanConstructor.cpp
r36726 r37257 30 30 31 31 BooleanConstructor::BooleanConstructor(ExecState* exec, PassRefPtr<StructureID> structure, BooleanPrototype* booleanPrototype) 32 : InternalFunction( exec, structure, Identifier(exec, booleanPrototype->classInfo()->className))32 : InternalFunction(&exec->globalData(), structure, Identifier(exec, booleanPrototype->classInfo()->className)) 33 33 { 34 34 putDirect(exec->propertyNames().prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly); -
trunk/JavaScriptCore/kjs/DateConstructor.cpp
r36784 r37257 53 53 54 54 DateConstructor::DateConstructor(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure, DatePrototype* datePrototype) 55 : InternalFunction( exec, structure, Identifier(exec, datePrototype->classInfo()->className))55 : InternalFunction(&exec->globalData(), structure, Identifier(exec, datePrototype->classInfo()->className)) 56 56 { 57 57 putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly); -
trunk/JavaScriptCore/kjs/DebuggerCallFrame.cpp
r37184 r37257 69 69 return 0; 70 70 71 ExecState newExec(m_ scopeChain->globalObject(), m_registers);71 ExecState newExec(m_registers); 72 72 73 73 int errLine; -
trunk/JavaScriptCore/kjs/ErrorConstructor.cpp
r36784 r37257 31 31 32 32 ErrorConstructor::ErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ErrorPrototype* errorPrototype) 33 : InternalFunction( exec, structure, Identifier(exec, errorPrototype->classInfo()->className))33 : InternalFunction(&exec->globalData(), structure, Identifier(exec, errorPrototype->classInfo()->className)) 34 34 { 35 35 // ECMA 15.11.3.1 Error.prototype -
trunk/JavaScriptCore/kjs/ExecState.cpp
r37125 r37257 1 /* 2 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #include "config.h" 24 #include "ExecState.h" 25 26 #include "JSGlobalObject.h" 27 #include "JSString.h" 28 #include "ScopeChainMark.h" 29 30 namespace JSC { 31 32 ExecState::ExecState(JSGlobalObject* globalObject, Register* callFrame) 33 : m_globalObject(globalObject) 34 , m_exception(0) 35 , m_globalData(globalObject->globalData()) 36 , m_callFrame(callFrame) 37 { 38 } 39 40 ExecState::ExecState(ExecState* exec, Register* callFrame) 41 : m_globalObject(exec->m_globalObject) 42 , m_exception(0) 43 , m_globalData(exec->m_globalData) 44 , m_callFrame(callFrame) 45 { 46 ASSERT(!exec->m_exception); 47 } 48 49 } // namespace JSC 1 /* delete me */ -
trunk/JavaScriptCore/kjs/ExecState.h
r37215 r37257 42 42 friend class DebuggerCallFrame; 43 43 public: 44 ExecState(JSGlobalObject*, Register* callFrame); 44 explicit ExecState(Register* callFrame) 45 : m_exception(0) 46 , m_callFrame(callFrame) 47 { 48 } 45 49 46 50 // Global object in which execution began. 47 JSGlobalObject* dynamicGlobalObject() const { return m_globalObject; } 48 51 JSGlobalObject* dynamicGlobalObject() const 52 { 53 return Machine::scopeChain(Machine::firstCallFrame(m_callFrame))->globalObject(); 54 } 55 49 56 // Global object in which the current script was defined. (Can differ 50 57 // from dynamicGlobalObject() during function calls across frames.) … … 53 60 return Machine::scopeChain(m_callFrame)->globalObject(); 54 61 } 55 56 JSObject* globalThisValue() const { return Machine::scopeChain(m_callFrame)->globalThisObject(); } 57 62 63 JSObject* globalThisValue() const 64 { 65 return Machine::scopeChain(m_callFrame)->globalThisObject(); 66 } 67 58 68 // Exception propogation. 59 69 void setException(JSValue* exception) { m_exception = exception; } … … 67 77 #endif 68 78 69 JSGlobalData& globalData() { return *m_globalData; } 79 JSGlobalData& globalData() const 80 { 81 return *Machine::scopeChain(m_callFrame)->globalData; 82 } 70 83 71 IdentifierTable* identifierTable() { return m_globalData->identifierTable; }72 const CommonIdentifiers& propertyNames() const { return * m_globalData->propertyNames; }73 const ArgList& emptyList() const { return * m_globalData->emptyList; }74 Lexer* lexer() { return m_globalData->lexer; }75 Parser* parser() { return m_globalData->parser; }76 Machine* machine() const { return m_globalData->machine; }77 static const HashTable* arrayTable(ExecState* exec) { return exec-> m_globalData->arrayTable; }78 static const HashTable* dateTable(ExecState* exec) { return exec-> m_globalData->dateTable; }79 static const HashTable* mathTable(ExecState* exec) { return exec-> m_globalData->mathTable; }80 static const HashTable* numberTable(ExecState* exec) { return exec-> m_globalData->numberTable; }81 static const HashTable* regExpTable(ExecState* exec) { return exec-> m_globalData->regExpTable; }82 static const HashTable* regExpConstructorTable(ExecState* exec) { return exec-> m_globalData->regExpConstructorTable; }83 static const HashTable* stringTable(ExecState* exec) { return exec-> m_globalData->stringTable; }84 IdentifierTable* identifierTable() { return globalData().identifierTable; } 85 const CommonIdentifiers& propertyNames() const { return *globalData().propertyNames; } 86 const ArgList& emptyList() const { return *globalData().emptyList; } 87 Lexer* lexer() { return globalData().lexer; } 88 Parser* parser() { return globalData().parser; } 89 Machine* machine() const { return globalData().machine; } 90 static const HashTable* arrayTable(ExecState* exec) { return exec->globalData().arrayTable; } 91 static const HashTable* dateTable(ExecState* exec) { return exec->globalData().dateTable; } 92 static const HashTable* mathTable(ExecState* exec) { return exec->globalData().mathTable; } 93 static const HashTable* numberTable(ExecState* exec) { return exec->globalData().numberTable; } 94 static const HashTable* regExpTable(ExecState* exec) { return exec->globalData().regExpTable; } 95 static const HashTable* regExpConstructorTable(ExecState* exec) { return exec->globalData().regExpConstructorTable; } 96 static const HashTable* stringTable(ExecState* exec) { return exec->globalData().stringTable; } 84 97 85 Heap* heap() const { return & m_globalData->heap; }98 Heap* heap() const { return &globalData().heap; } 86 99 87 100 private: … … 89 102 ExecState() { } 90 103 91 ExecState(ExecState*, Register* callFrame);92 93 104 bool isGlobalObject(JSObject*) const; 94 95 JSGlobalObject* m_globalObject;96 105 97 106 JSValue* m_exception; … … 99 108 void* m_ctiReturnAddress; 100 109 #endif 101 JSGlobalData* m_globalData;102 103 110 Register* m_callFrame; // The most recent call frame. 104 111 }; 105 106 enum CodeType { GlobalCode, EvalCode, FunctionCode };107 112 108 113 } // namespace JSC -
trunk/JavaScriptCore/kjs/FunctionConstructor.cpp
r37184 r37257 36 36 37 37 FunctionConstructor::FunctionConstructor(ExecState* exec, PassRefPtr<StructureID> structure, FunctionPrototype* functionPrototype) 38 : InternalFunction( exec, structure, Identifier(exec, functionPrototype->classInfo()->className))38 : InternalFunction(&exec->globalData(), structure, Identifier(exec, functionPrototype->classInfo()->className)) 39 39 { 40 40 putDirect(exec->propertyNames().prototype, functionPrototype, DontEnum | DontDelete | ReadOnly); … … 128 128 functionBody->finishParsing(source, parameters.releaseBuffer(), count); 129 129 130 ScopeChain scopeChain(exec->lexicalGlobalObject(), exec->globalThisValue()); 130 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 131 ScopeChain scopeChain(globalObject, globalObject->globalData(), exec->globalThisValue()); 131 132 JSFunction* function = new (exec) JSFunction(exec, functionName, functionBody.get(), scopeChain.node()); 132 133 -
trunk/JavaScriptCore/kjs/FunctionPrototype.cpp
r36875 r37257 38 38 39 39 FunctionPrototype::FunctionPrototype(ExecState* exec) 40 : InternalFunction( exec)40 : InternalFunction(&exec->globalData()) 41 41 { 42 42 putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum); -
trunk/JavaScriptCore/kjs/InternalFunction.cpp
r37103 r37257 38 38 } 39 39 40 InternalFunction::InternalFunction( ExecState* exec)41 : JSObject( exec->globalData().nullProtoStructureID)40 InternalFunction::InternalFunction(JSGlobalData* globalData) 41 : JSObject(globalData->nullProtoStructureID) 42 42 { 43 putDirect( exec->propertyNames().name, jsString(exec, exec->propertyNames().nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum);43 putDirect(globalData->propertyNames->name, jsString(globalData, globalData->propertyNames->nullIdentifier.ustring()), DontDelete | ReadOnly | DontEnum); 44 44 } 45 45 46 InternalFunction::InternalFunction( ExecState* exec, PassRefPtr<StructureID> structure, const Identifier& name)46 InternalFunction::InternalFunction(JSGlobalData* globalData, PassRefPtr<StructureID> structure, const Identifier& name) 47 47 : JSObject(structure) 48 48 { 49 putDirect( exec->propertyNames().name, jsString(exec, name.ustring()), DontDelete | ReadOnly | DontEnum);49 putDirect(globalData->propertyNames->name, jsString(globalData, name.ustring()), DontDelete | ReadOnly | DontEnum); 50 50 } 51 51 -
trunk/JavaScriptCore/kjs/InternalFunction.h
r37103 r37257 46 46 protected: 47 47 InternalFunction(PassRefPtr<StructureID> structure) : JSObject(structure) { } 48 InternalFunction( ExecState*);49 InternalFunction( ExecState*, PassRefPtr<StructureID>, const Identifier&);48 InternalFunction(JSGlobalData*); 49 InternalFunction(JSGlobalData*, PassRefPtr<StructureID>, const Identifier&); 50 50 51 51 private: -
trunk/JavaScriptCore/kjs/JSCell.h
r36764 r37257 80 80 // Garbage collection. 81 81 void* operator new(size_t, ExecState*); 82 void* operator new(size_t, JSGlobalData*); 82 83 void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; } 83 84 virtual void mark(); … … 156 157 } 157 158 159 inline void* JSCell::operator new(size_t size, JSGlobalData* globalData) 160 { 161 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 162 return globalData->heap.inlineAllocate(size); 163 #else 164 return globalData->heap.allocate(size); 165 #endif 166 } 158 167 159 168 // --- JSValue inlines ---------------------------- -
trunk/JavaScriptCore/kjs/JSFunction.cpp
r37184 r37257 46 46 47 47 JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode) 48 : Base( exec, exec->lexicalGlobalObject()->functionStructure(), name)48 : Base(&exec->globalData(), exec->lexicalGlobalObject()->functionStructure(), name) 49 49 , m_body(body) 50 50 , m_scopeChain(scopeChainNode) -
trunk/JavaScriptCore/kjs/JSGlobalObject.cpp
r37215 r37257 123 123 } 124 124 125 void JSGlobalObject::init( )125 void JSGlobalObject::init(JSObject* thisValue) 126 126 { 127 127 ASSERT(JSLock::currentThreadIsHoldingLock()); 128 128 129 129 d()->globalData = Heap::heap(this)->globalData(); 130 d()->globalScopeChain = ScopeChain(this, d()->globalData.get(), thisValue); 131 132 Machine::initializeCallFrame(d()->globalCallFrame + RegisterFile::CallFrameHeaderSize, 0, 0, d()->globalScopeChain.node(), makeHostCallFramePointer(0), 0, 0, 0); 130 133 131 134 if (JSGlobalObject*& headObject = head()) { … … 140 143 d()->debugger = 0; 141 144 142 d()->globalExec.set(new ExecState( this,d()->globalCallFrame + RegisterFile::CallFrameHeaderSize));145 d()->globalExec.set(new ExecState(d()->globalCallFrame + RegisterFile::CallFrameHeaderSize)); 143 146 144 147 d()->profileGroup = 0; -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r37191 r37257 55 55 56 56 struct JSGlobalObjectData : public JSVariableObjectData { 57 JSGlobalObjectData( JSGlobalObject* globalObject, JSObject* thisValue)57 JSGlobalObjectData() 58 58 : JSVariableObjectData(&symbolTable, 0) 59 59 , registerArraySize(0) 60 , globalScopeChain( globalObject, thisValue)60 , globalScopeChain(NoScopeChain()) 61 61 , regExpConstructor(0) 62 62 , errorConstructor(0) … … 77 77 , regExpPrototype(0) 78 78 { 79 Machine::initializeCallFrame(globalCallFrame + RegisterFile::CallFrameHeaderSize, 0, 0, globalScopeChain.node(), makeHostCallFramePointer(0), 0, 0, 0);80 79 } 81 80 … … 144 143 void* operator new(size_t, JSGlobalData*); 145 144 146 JSGlobalObject(JSGlobalData* globalData)147 : JSVariableObject(globalData->nullProtoStructureID, new JSGlobalObjectData (this, this))145 explicit JSGlobalObject(JSGlobalData* globalData) 146 : JSVariableObject(globalData->nullProtoStructureID, new JSGlobalObjectData) 148 147 { 149 init( );148 init(this); 150 149 } 151 150 152 151 protected: 153 JSGlobalObject(PassRefPtr<StructureID> structure, JSGlobalObjectData* data )152 JSGlobalObject(PassRefPtr<StructureID> structure, JSGlobalObjectData* data, JSObject* thisValue) 154 153 : JSVariableObject(structure, data) 155 154 { 156 init( );155 init(thisValue); 157 156 } 158 157 … … 268 267 private: 269 268 // FIXME: Fold reset into init. 270 void init( );269 void init(JSObject* thisValue); 271 270 void reset(JSValue* prototype); 272 271 … … 333 332 } 334 333 335 336 334 } // namespace JSC 337 335 -
trunk/JavaScriptCore/kjs/JSNumberCell.cpp
r36726 r37257 112 112 } 113 113 114 NEVER_INLINE JSValue* jsNumberCell(JSGlobalData* globalData, double d) 115 { 116 return new (globalData) JSNumberCell(globalData, d); 117 } 118 119 NEVER_INLINE JSValue* jsNaN(JSGlobalData* globalData) 120 { 121 return new (globalData) JSNumberCell(globalData, NaN); 122 } 123 114 124 } // namespace JSC -
trunk/JavaScriptCore/kjs/JSNumberCell.h
r36976 r37257 44 44 class JSNumberCell : public JSCell { 45 45 friend class CTI; 46 friend JSValue* jsNumberCell(JSGlobalData*, double); 47 friend JSValue* jsNaN(JSGlobalData*); 46 48 friend JSValue* jsNumberCell(ExecState*, double); 47 49 friend JSValue* jsNaN(ExecState*); … … 72 74 } 73 75 76 void* operator new(size_t size, JSGlobalData* globalData) 77 { 78 #ifdef JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 79 return globalData->heap.inlineAllocateNumber(size); 80 #else 81 return globalData->heap.allocateNumber(size); 82 #endif 83 } 84 74 85 static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(NumberType)); } 75 86 76 87 private: 88 JSNumberCell(JSGlobalData* globalData, double value) 89 : JSCell(globalData->numberStructureID.get()) 90 , m_value(value) 91 { 92 } 93 77 94 JSNumberCell(ExecState* exec, double value) 78 95 : JSCell(exec->globalData().numberStructureID.get()) … … 100 117 } 101 118 119 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, short i) 120 { 121 JSValue* v = JSImmediate::from(i); 122 return v ? v : jsNumberCell(exec, i); 123 } 124 125 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, unsigned short i) 126 { 127 JSValue* v = JSImmediate::from(i); 128 return v ? v : jsNumberCell(exec, i); 129 } 130 102 131 ALWAYS_INLINE JSValue* jsNumber(ExecState* exec, int i) 103 132 { … … 134 163 JSValue* v = JSImmediate::from(i); 135 164 return v ? v : jsNumberCell(exec, static_cast<double>(i)); 165 } 166 167 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, double d) 168 { 169 JSValue* v = JSImmediate::from(d); 170 return v ? v : jsNumberCell(globalData, d); 171 } 172 173 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, short i) 174 { 175 JSValue* v = JSImmediate::from(i); 176 return v ? v : jsNumberCell(globalData, i); 177 } 178 179 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned short i) 180 { 181 JSValue* v = JSImmediate::from(i); 182 return v ? v : jsNumberCell(globalData, i); 183 } 184 185 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, int i) 186 { 187 JSValue* v = JSImmediate::from(i); 188 return v ? v : jsNumberCell(globalData, i); 189 } 190 191 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned i) 192 { 193 JSValue* v = JSImmediate::from(i); 194 return v ? v : jsNumberCell(globalData, i); 195 } 196 197 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, long i) 198 { 199 JSValue* v = JSImmediate::from(i); 200 return v ? v : jsNumberCell(globalData, i); 201 } 202 203 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned long i) 204 { 205 JSValue* v = JSImmediate::from(i); 206 return v ? v : jsNumberCell(globalData, i); 207 } 208 209 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, long long i) 210 { 211 JSValue* v = JSImmediate::from(i); 212 return v ? v : jsNumberCell(globalData, static_cast<double>(i)); 213 } 214 215 ALWAYS_INLINE JSValue* jsNumber(JSGlobalData* globalData, unsigned long long i) 216 { 217 JSValue* v = JSImmediate::from(i); 218 return v ? v : jsNumberCell(globalData, static_cast<double>(i)); 136 219 } 137 220 -
trunk/JavaScriptCore/kjs/JSString.cpp
r36726 r37257 110 110 } 111 111 112 JSString* jsString( ExecState* exec, const UString& s)112 JSString* jsString(JSGlobalData* globalData, const UString& s) 113 113 { 114 114 int size = s.size(); 115 115 if (!size) 116 return exec->globalData().smallStrings.emptyString(exec);116 return globalData->smallStrings.emptyString(globalData); 117 117 if (size == 1) { 118 118 UChar c = s.data()[0]; 119 119 if (c <= 0xFF) 120 return exec->globalData().smallStrings.singleCharacterString(exec, c);120 return globalData->smallStrings.singleCharacterString(globalData, c); 121 121 } 122 return new ( exec) JSString(exec, s);122 return new (globalData) JSString(globalData, s); 123 123 } 124 124 125 JSString* jsSubstring( ExecState* exec, const UString& s, unsigned offset, unsigned length)125 JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length) 126 126 { 127 127 ASSERT(offset <= static_cast<unsigned>(s.size())); … … 129 129 ASSERT(offset + length <= static_cast<unsigned>(s.size())); 130 130 if (!length) 131 return exec->globalData().smallStrings.emptyString(exec);131 return globalData->smallStrings.emptyString(globalData); 132 132 if (length == 1) { 133 133 UChar c = s.data()[offset]; 134 134 if (c <= 0xFF) 135 return exec->globalData().smallStrings.singleCharacterString(exec, c);135 return globalData->smallStrings.singleCharacterString(globalData, c); 136 136 } 137 return new ( exec) JSString(exec, UString::Rep::create(s.rep(), offset, length));137 return new (globalData) JSString(globalData, UString::Rep::create(s.rep(), offset, length)); 138 138 } 139 139 140 JSString* jsOwnedString( ExecState* exec, const UString& s)140 JSString* jsOwnedString(JSGlobalData* globalData, const UString& s) 141 141 { 142 142 int size = s.size(); 143 143 if (!size) 144 return exec->globalData().smallStrings.emptyString(exec);144 return globalData->smallStrings.emptyString(globalData); 145 145 if (size == 1) { 146 146 UChar c = s.data()[0]; 147 147 if (c <= 0xFF) 148 return exec->globalData().smallStrings.singleCharacterString(exec, c);148 return globalData->smallStrings.singleCharacterString(globalData, c); 149 149 } 150 return new ( exec) JSString(exec, s, JSString::HasOtherOwner);150 return new (globalData) JSString(globalData, s, JSString::HasOtherOwner); 151 151 } 152 152 -
trunk/JavaScriptCore/kjs/JSString.h
r36755 r37257 34 34 class JSString; 35 35 36 JSString* jsEmptyString(JSGlobalData*); 36 37 JSString* jsEmptyString(ExecState*); 38 JSString* jsString(JSGlobalData*, const UString&); // returns empty string if passed null string 37 39 JSString* jsString(ExecState*, const UString&); // returns empty string if passed null string 38 40 41 JSString* jsSingleCharacterString(JSGlobalData*, UChar); 39 42 JSString* jsSingleCharacterString(ExecState*, UChar); 43 JSString* jsSingleCharacterSubstring(JSGlobalData*, const UString&, unsigned offset); 40 44 JSString* jsSingleCharacterSubstring(ExecState*, const UString&, unsigned offset); 45 JSString* jsSubstring(JSGlobalData*, const UString&, unsigned offset, unsigned length); 41 46 JSString* jsSubstring(ExecState*, const UString&, unsigned offset, unsigned length); 42 47 43 48 // Non-trivial strings are two or more characters long. 44 49 // These functions are faster than just calling jsString. 50 JSString* jsNontrivialString(JSGlobalData*, const UString&); 45 51 JSString* jsNontrivialString(ExecState*, const UString&); 52 JSString* jsNontrivialString(JSGlobalData*, const char*); 46 53 JSString* jsNontrivialString(ExecState*, const char*); 47 54 … … 49 56 // likely outlive the JSValue this makes, such as the parse tree or a 50 57 // DOM object that contains a UString 58 JSString* jsOwnedString(JSGlobalData*, const UString&); 51 59 JSString* jsOwnedString(ExecState*, const UString&); 52 60 … … 56 64 57 65 public: 58 JSString( ExecState* exec, const UString& value)59 : JSCell( exec->globalData().stringStructureID.get())66 JSString(JSGlobalData* globalData, const UString& value) 67 : JSCell(globalData->stringStructureID.get()) 60 68 , m_value(value) 61 69 { … … 64 72 65 73 enum HasOtherOwnerType { HasOtherOwner }; 66 JSString( ExecState* exec, const UString& value, HasOtherOwnerType)67 : JSCell( exec->globalData().stringStructureID.get())74 JSString(JSGlobalData* globalData, const UString& value, HasOtherOwnerType) 75 : JSCell(globalData->stringStructureID.get()) 68 76 , m_value(value) 69 77 { 70 78 } 71 JSString( ExecState* exec, PassRefPtr<UString::Rep> value, HasOtherOwnerType)72 : JSCell( exec->globalData().stringStructureID.get())79 JSString(JSGlobalData* globalData, PassRefPtr<UString::Rep> value, HasOtherOwnerType) 80 : JSCell(globalData->stringStructureID.get()) 73 81 , m_value(value) 74 82 { … … 81 89 82 90 bool canGetIndex(unsigned i) { return i < static_cast<unsigned>(m_value.size()); } 83 JSString* getIndex( ExecState*, unsigned);91 JSString* getIndex(JSGlobalData*, unsigned); 84 92 85 93 static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(StringType)); } … … 110 118 }; 111 119 112 inline JSString* jsEmptyString( ExecState* exec)113 { 114 return exec->globalData().smallStrings.emptyString(exec);115 } 116 117 inline JSString* jsSingleCharacterString( ExecState* exec, UChar c)120 inline JSString* jsEmptyString(JSGlobalData* globalData) 121 { 122 return globalData->smallStrings.emptyString(globalData); 123 } 124 125 inline JSString* jsSingleCharacterString(JSGlobalData* globalData, UChar c) 118 126 { 119 127 if (c <= 0xFF) 120 return exec->globalData().smallStrings.singleCharacterString(exec, c);121 return new ( exec) JSString(exec, UString(&c, 1));122 } 123 124 inline JSString* jsSingleCharacterSubstring( ExecState* exec, const UString& s, unsigned offset)128 return globalData->smallStrings.singleCharacterString(globalData, c); 129 return new (globalData) JSString(globalData, UString(&c, 1)); 130 } 131 132 inline JSString* jsSingleCharacterSubstring(JSGlobalData* globalData, const UString& s, unsigned offset) 125 133 { 126 134 ASSERT(offset < static_cast<unsigned>(s.size())); 127 135 UChar c = s.data()[offset]; 128 136 if (c <= 0xFF) 129 return exec->globalData().smallStrings.singleCharacterString(exec, c);130 return new ( exec) JSString(exec, UString::Rep::create(s.rep(), offset, 1));131 } 132 133 inline JSString* jsNontrivialString( ExecState* exec, const char* s)137 return globalData->smallStrings.singleCharacterString(globalData, c); 138 return new (globalData) JSString(globalData, UString::Rep::create(s.rep(), offset, 1)); 139 } 140 141 inline JSString* jsNontrivialString(JSGlobalData* globalData, const char* s) 134 142 { 135 143 ASSERT(s); 136 144 ASSERT(s[0]); 137 145 ASSERT(s[1]); 138 return new ( exec) JSString(exec, s);139 } 140 141 inline JSString* jsNontrivialString( ExecState* exec, const UString& s)146 return new (globalData) JSString(globalData, s); 147 } 148 149 inline JSString* jsNontrivialString(JSGlobalData* globalData, const UString& s) 142 150 { 143 151 ASSERT(s.size() > 1); 144 return new ( exec) JSString(exec, s);145 } 146 147 inline JSString* JSString::getIndex( ExecState* exec, unsigned i)152 return new (globalData) JSString(globalData, s); 153 } 154 155 inline JSString* JSString::getIndex(JSGlobalData* globalData, unsigned i) 148 156 { 149 157 ASSERT(canGetIndex(i)); 150 return jsSingleCharacterSubstring(exec, m_value, i); 151 } 158 return jsSingleCharacterSubstring(globalData, m_value, i); 159 } 160 161 inline JSString* jsEmptyString(ExecState* exec) { return jsEmptyString(&exec->globalData()); } 162 inline JSString* jsString(ExecState* exec, const UString& s) { return jsString(&exec->globalData(), s); } 163 inline JSString* jsSingleCharacterString(ExecState* exec, UChar c) { return jsSingleCharacterString(&exec->globalData(), c); } 164 inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset) { return jsSingleCharacterSubstring(&exec->globalData(), s, offset); } 165 inline JSString* jsSubstring(ExecState* exec, const UString& s, unsigned offset, unsigned length) { return jsSubstring(&exec->globalData(), s, offset, length); } 166 inline JSString* jsNontrivialString(ExecState* exec, const UString& s) { return jsNontrivialString(&exec->globalData(), s); } 167 inline JSString* jsNontrivialString(ExecState* exec, const char* s) { return jsNontrivialString(&exec->globalData(), s); } 168 inline JSString* jsOwnedString(ExecState* exec, const UString& s) { return jsOwnedString(&exec->globalData(), s); } 152 169 153 170 ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) -
trunk/JavaScriptCore/kjs/NativeErrorConstructor.cpp
r36755 r37257 33 33 34 34 NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NativeErrorPrototype* nativeErrorPrototype) 35 : InternalFunction( exec, structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))35 : InternalFunction(&exec->globalData(), structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString())) 36 36 , m_errorStructure(ErrorInstance::createStructureID(nativeErrorPrototype)) 37 37 { -
trunk/JavaScriptCore/kjs/NumberConstructor.cpp
r36977 r37257 55 55 56 56 NumberConstructor::NumberConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NumberPrototype* numberPrototype) 57 : InternalFunction( exec, structure, Identifier(exec, numberPrototype->info.className))57 : InternalFunction(&exec->globalData(), structure, Identifier(exec, numberPrototype->info.className)) 58 58 { 59 59 // Number.Prototype -
trunk/JavaScriptCore/kjs/ObjectConstructor.cpp
r36726 r37257 30 30 31 31 ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<StructureID> structure, ObjectPrototype* objectPrototype) 32 : InternalFunction( exec, structure, Identifier(exec, "Object"))32 : InternalFunction(&exec->globalData(), structure, Identifier(exec, "Object")) 33 33 { 34 34 // ECMA 15.2.3.1 -
trunk/JavaScriptCore/kjs/PrototypeFunction.cpp
r36726 r37257 34 34 35 35 PrototypeFunction::PrototypeFunction(ExecState* exec, int length, const Identifier& name, NativeFunction function) 36 : InternalFunction( exec, exec->lexicalGlobalObject()->prototypeFunctionStructure(), name)36 : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->prototypeFunctionStructure(), name) 37 37 , m_function(function) 38 38 { … … 42 42 43 43 PrototypeFunction::PrototypeFunction(ExecState* exec, PassRefPtr<StructureID> prototypeFunctionStructure, int length, const Identifier& name, NativeFunction function) 44 : InternalFunction( exec, prototypeFunctionStructure, name)44 : InternalFunction(&exec->globalData(), prototypeFunctionStructure, name) 45 45 , m_function(function) 46 46 { -
trunk/JavaScriptCore/kjs/RegExpConstructor.cpp
r36977 r37257 105 105 106 106 RegExpConstructor::RegExpConstructor(ExecState* exec, PassRefPtr<StructureID> structure, RegExpPrototype* regExpPrototype) 107 : InternalFunction( exec, structure, Identifier(exec, "RegExp"))107 : InternalFunction(&exec->globalData(), structure, Identifier(exec, "RegExp")) 108 108 , d(new RegExpConstructorPrivate) 109 109 { -
trunk/JavaScriptCore/kjs/ScopeChain.h
r36263 r37257 32 32 class ScopeChainNode { 33 33 public: 34 ScopeChainNode(ScopeChainNode* n, JSObject* o, JSObject* gt) 35 : next(n) 36 , object(o) 37 , globalThis(gt) 34 ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSObject* globalThis) 35 : next(next) 36 , object(object) 37 , globalData(globalData) 38 , globalThis(globalThis) 38 39 , refCount(1) 39 40 { 41 ASSERT(globalData); 40 42 } 41 43 42 44 ScopeChainNode* next; 43 45 JSObject* object; 46 JSGlobalData* globalData; 44 47 JSObject* globalThis; 45 48 int refCount; … … 79 82 { 80 83 ASSERT(o); 81 return new ScopeChainNode(this, o, global This);84 return new ScopeChainNode(this, o, globalData, globalThis); 82 85 } 83 86 … … 156 159 } 157 160 158 ScopeChain(JSObject* o, JS Object* globalThis)159 : m_node(new ScopeChainNode(0, o, global This))161 ScopeChain(JSObject* o, JSGlobalData* globalData, JSObject* globalThis) 162 : m_node(new ScopeChainNode(0, o, globalData, globalThis)) 160 163 { 161 164 } -
trunk/JavaScriptCore/kjs/SmallStrings.cpp
r36316 r37257 27 27 #include "SmallStrings.h" 28 28 29 #include "JSGlobalObject.h" 29 30 #include "JSString.h" 30 31 … … 88 89 } 89 90 90 void SmallStrings::createEmptyString( ExecState* exec)91 void SmallStrings::createEmptyString(JSGlobalData* globalData) 91 92 { 92 93 ASSERT(!m_emptyString); 93 m_emptyString = new ( exec) JSString(exec, "", JSString::HasOtherOwner);94 m_emptyString = new (globalData) JSString(globalData, "", JSString::HasOtherOwner); 94 95 } 95 96 96 void SmallStrings::createSingleCharacterString( ExecState* exec, unsigned char character)97 void SmallStrings::createSingleCharacterString(JSGlobalData* globalData, unsigned char character) 97 98 { 98 99 if (!m_storage) 99 100 m_storage.set(new SmallStringsStorage); 100 101 ASSERT(!m_singleCharacterStrings[character]); 101 m_singleCharacterStrings[character] = new ( exec) JSString(exec, m_storage->rep(character), JSString::HasOtherOwner);102 m_singleCharacterStrings[character] = new (globalData) JSString(globalData, m_storage->rep(character), JSString::HasOtherOwner); 102 103 } 103 104 -
trunk/JavaScriptCore/kjs/SmallStrings.h
r36263 r37257 32 32 namespace JSC { 33 33 34 class ExecState;34 class JSGlobalData; 35 35 class JSString; 36 36 … … 42 42 ~SmallStrings(); 43 43 44 JSString* emptyString( ExecState* exec)44 JSString* emptyString(JSGlobalData* globalData) 45 45 { 46 46 if (!m_emptyString) 47 createEmptyString( exec);47 createEmptyString(globalData); 48 48 return m_emptyString; 49 49 } 50 JSString* singleCharacterString( ExecState* exec, unsigned char character)50 JSString* singleCharacterString(JSGlobalData* globalData, unsigned char character) 51 51 { 52 52 if (!m_singleCharacterStrings[character]) 53 createSingleCharacterString( exec, character);53 createSingleCharacterString(globalData, character); 54 54 return m_singleCharacterStrings[character]; 55 55 } … … 60 60 61 61 private: 62 void createEmptyString( ExecState*);63 void createSingleCharacterString( ExecState*, unsigned char);62 void createEmptyString(JSGlobalData*); 63 void createSingleCharacterString(JSGlobalData*, unsigned char); 64 64 65 65 JSString* m_emptyString; -
trunk/JavaScriptCore/kjs/StringConstructor.cpp
r36726 r37257 48 48 49 49 StringConstructor::StringConstructor(ExecState* exec, PassRefPtr<StructureID> structure, StructureID* prototypeFunctionStructure, StringPrototype* stringPrototype) 50 : InternalFunction( exec, structure, Identifier(exec, stringPrototype->classInfo()->className))50 : InternalFunction(&exec->globalData(), structure, Identifier(exec, stringPrototype->classInfo()->className)) 51 51 { 52 52 // ECMA 15.5.3.1 String.prototype
Note:
See TracChangeset
for help on using the changeset viewer.