Changeset 93378 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Aug 18, 2011, 5:58:34 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r93375 r93378 1 2011-08-18 Mark Hahnenberg <[email protected]> 2 3 Move allocation in constructors into separate constructorBody() methods 4 https://bugs.webkit.org/show_bug.cgi?id=66265 5 6 Reviewed by Oliver Hunt. 7 8 Refactoring to put all allocations that need to be done after the object's 9 initialization list has executed but before the object is ready for use 10 into a separate constructorBody() method. This method is still called by the constructor, 11 so the patch doesn't resolve any potential issues, it's just to set up the code for further refactoring. 12 13 * JavaScriptCore.exp: 14 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 15 * jsc.cpp: 16 (GlobalObject::constructorBody): 17 (GlobalObject::GlobalObject): 18 * runtime/ErrorInstance.cpp: 19 (JSC::ErrorInstance::ErrorInstance): 20 * runtime/ErrorInstance.h: 21 (JSC::ErrorInstance::constructorBody): 22 * runtime/ErrorPrototype.cpp: 23 (JSC::ErrorPrototype::ErrorPrototype): 24 (JSC::ErrorPrototype::constructorBody): 25 * runtime/ErrorPrototype.h: 26 * runtime/Executable.cpp: 27 (JSC::FunctionExecutable::FunctionExecutable): 28 * runtime/Executable.h: 29 (JSC::FunctionExecutable::constructorBody): 30 * runtime/InternalFunction.cpp: 31 (JSC::InternalFunction::InternalFunction): 32 * runtime/InternalFunction.h: 33 (JSC::InternalFunction::constructorBody): 34 * runtime/JSByteArray.cpp: 35 (JSC::JSByteArray::JSByteArray): 36 * runtime/JSByteArray.h: 37 (JSC::JSByteArray::constructorBody): 38 * runtime/JSFunction.cpp: 39 (JSC::JSFunction::JSFunction): 40 (JSC::JSFunction::constructorBody): 41 * runtime/JSFunction.h: 42 * runtime/JSGlobalObject.h: 43 (JSC::JSGlobalObject::JSGlobalObject): 44 (JSC::JSGlobalObject::constructorBody): 45 * runtime/JSPropertyNameIterator.cpp: 46 (JSC::JSPropertyNameIterator::JSPropertyNameIterator): 47 * runtime/JSPropertyNameIterator.h: 48 (JSC::JSPropertyNameIterator::constructorBody): 49 * runtime/JSString.h: 50 (JSC::RopeBuilder::JSString): 51 (JSC::RopeBuilder::constructorBody): 52 * runtime/NativeErrorConstructor.cpp: 53 (JSC::NativeErrorConstructor::NativeErrorConstructor): 54 * runtime/NativeErrorConstructor.h: 55 (JSC::NativeErrorConstructor::constructorBody): 56 * runtime/NativeErrorPrototype.cpp: 57 (JSC::NativeErrorPrototype::NativeErrorPrototype): 58 (JSC::NativeErrorPrototype::constructorBody): 59 * runtime/NativeErrorPrototype.h: 60 * runtime/StringObject.cpp: 61 * runtime/StringObject.h: 62 (JSC::StringObject::create): 63 * runtime/StringObjectThatMasqueradesAsUndefined.h: 64 (JSC::StringObjectThatMasqueradesAsUndefined::create): 65 (JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined): 66 * runtime/StringPrototype.cpp: 67 (JSC::StringPrototype::StringPrototype): 68 * runtime/StringPrototype.h: 69 (JSC::StringPrototype::create): 70 1 71 2011-08-10 Filip Pizlo <[email protected]> 2 72 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r92224 r93378 152 152 __ZN3JSC12StringObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE 153 153 __ZN3JSC12StringObject6s_infoE 154 __ZN3JSC12StringObjectC2E PNS_9ExecStateEPNS_9StructureERKNS_7UStringE154 __ZN3JSC12StringObjectC2ERNS_12JSGlobalDataEPNS_9StructureEPNS_8JSStringE 155 155 __ZN3JSC13SamplingFlags4stopEv 156 156 __ZN3JSC13SamplingFlags5startEv -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r92230 r93378 20 20 ??0RegExpObject@JSC@@IAE@PAVJSGlobalObject@1@PAVStructure@1@PAVRegExp@1@@Z 21 21 ??0SHA1@WTF@@QAE@XZ 22 ??0StringObject@JSC@@IAE@ PAVExecState@1@PAVStructure@1@ABVUString@1@@Z22 ??0StringObject@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@PAVJSString@1@@Z 23 23 ??0Structure@JSC@@AAE@AAVJSGlobalData@1@VJSValue@1@ABVTypeInfo@1@IPBUClassInfo@1@@Z 24 24 ??0ThreadCondition@WTF@@QAE@XZ -
trunk/Source/JavaScriptCore/jsc.cpp
r92706 r93378 156 156 } 157 157 virtual UString className() const { return "global"; } 158 159 protected: 160 void constructorBody(const Vector<UString>& arguments) 161 { 162 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug)); 163 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint)); 164 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit)); 165 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC)); 166 #ifndef NDEBUG 167 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory)); 168 #endif 169 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion)); 170 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun)); 171 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad)); 172 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax)); 173 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline)); 174 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "preciseTime"), functionPreciseTime)); 175 176 #if ENABLE(SAMPLING_FLAGS) 177 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags)); 178 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags)); 179 #endif 180 181 JSObject* array = constructEmptyArray(globalExec()); 182 for (size_t i = 0; i < arguments.size(); ++i) 183 array->put(globalExec(), i, jsString(globalExec(), arguments[i])); 184 putDirect(globalExec()->globalData(), Identifier(globalExec(), "arguments"), array); 185 } 158 186 }; 159 187 COMPILE_ASSERT(!IsInteger<GlobalObject>::value, WTF_IsInteger_GlobalObject_false); … … 163 191 : JSGlobalObject(globalData, structure) 164 192 { 165 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug)); 166 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint)); 167 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit)); 168 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC)); 169 #ifndef NDEBUG 170 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory)); 171 #endif 172 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion)); 173 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun)); 174 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad)); 175 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax)); 176 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline)); 177 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "preciseTime"), functionPreciseTime)); 178 179 #if ENABLE(SAMPLING_FLAGS) 180 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags)); 181 putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags)); 182 #endif 183 184 JSObject* array = constructEmptyArray(globalExec()); 185 for (size_t i = 0; i < arguments.size(); ++i) 186 array->put(globalExec(), i, jsString(globalExec(), arguments[i])); 187 putDirect(globalExec()->globalData(), Identifier(globalExec(), "arguments"), array); 193 constructorBody(arguments); 188 194 } 189 195 -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp
r91194 r93378 30 30 , m_appendSourceToMessage(false) 31 31 { 32 ASSERT(inherits(&s_info)); 33 putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, ""), DontEnum); 32 constructorBody(globalData); 34 33 } 35 34 -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.h
r92706 r93378 51 51 explicit ErrorInstance(JSGlobalData&, Structure*, const UString&); 52 52 53 void constructorBody(JSGlobalData& globalData) 54 { 55 ASSERT(inherits(&s_info)); 56 putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, ""), DontEnum); 57 } 58 53 59 bool m_appendSourceToMessage; 54 60 }; -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
r91194 r93378 54 54 : ErrorInstance(exec->globalData(), structure) 55 55 { 56 constructorBody(exec, globalObject); 57 } 58 59 void ErrorPrototype::constructorBody(ExecState* exec, JSGlobalObject* globalObject) 60 { 61 ASSERT(inherits(&s_info)); 56 62 putDirect(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum); 57 58 ASSERT(inherits(&s_info));59 63 putAnonymousValue(globalObject->globalData(), 0, globalObject); 60 64 } -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.h
r92706 r93378 46 46 protected: 47 47 ErrorPrototype(ExecState*, JSGlobalObject*, Structure*); 48 void constructorBody(ExecState*, JSGlobalObject*); 49 48 50 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ErrorInstance::StructureFlags; 49 51 static const unsigned AnonymousSlotCount = ErrorInstance::AnonymousSlotCount + 1; -
trunk/Source/JavaScriptCore/runtime/Executable.cpp
r92250 r93378 143 143 , m_symbolTable(0) 144 144 { 145 m_firstLine = firstLine; 146 m_lastLine = lastLine; 147 m_nameValue.set(globalData, this, jsString(&globalData, name.ustring())); 145 constructorBody(globalData, name, firstLine, lastLine); 148 146 } 149 147 … … 158 156 m_firstLine = firstLine; 159 157 m_lastLine = lastLine; 160 m_nameValue.set(exec->globalData(), this, jsString(&exec->globalData(), name.ustring()));158 constructorBody(exec->globalData(), name, firstLine, lastLine); 161 159 } 162 160 -
trunk/Source/JavaScriptCore/runtime/Executable.h
r92706 r93378 505 505 static const ClassInfo s_info; 506 506 507 protected: 508 void constructorBody(JSGlobalData& globalData, const Identifier& name, int firstLine, int lastLine) 509 { 510 m_firstLine = firstLine; 511 m_lastLine = lastLine; 512 m_nameValue.set(globalData, this, jsString(&globalData, name.ustring())); 513 } 514 507 515 private: 508 516 FunctionExecutable(JSGlobalData&, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine); -
trunk/Source/JavaScriptCore/runtime/InternalFunction.cpp
r84052 r93378 45 45 : JSObjectWithGlobalObject(globalObject, structure) 46 46 { 47 ASSERT(inherits(&s_info)); 48 putDirect(*globalData, globalData->propertyNames->name, jsString(globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); 47 constructorBody(*globalData, name); 49 48 } 50 49 -
trunk/Source/JavaScriptCore/runtime/InternalFunction.h
r92706 r93378 55 55 InternalFunction(JSGlobalData*, JSGlobalObject*, Structure*, const Identifier&); 56 56 57 void constructorBody(JSGlobalData& globalData, const Identifier& name) 58 { 59 ASSERT(inherits(&s_info)); 60 putDirect(globalData, globalData.propertyNames->name, jsString(&globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); 61 } 62 57 63 private: 58 64 virtual CallType getCallData(CallData&) = 0; -
trunk/Source/JavaScriptCore/runtime/JSByteArray.cpp
r91790 r93378 40 40 , m_storage(storage) 41 41 { 42 putDirect(exec->globalData(), exec->globalData().propertyNames->length, jsNumber(m_storage->length()), ReadOnly | DontDelete);42 constructorBody(exec); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/runtime/JSByteArray.h
r91790 r93378 105 105 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags; 106 106 107 void constructorBody(ExecState* exec) 108 { 109 putDirect(exec->globalData(), exec->globalData().propertyNames->length, jsNumber(m_storage->length()), ReadOnly | DontDelete); 110 } 111 107 112 private: 108 113 JSByteArray(VPtrStealingHackType) -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r92250 r93378 64 64 JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, int length, const Identifier& name, NativeExecutable* thunk) 65 65 : Base(globalObject, structure) 66 , m_executable( exec->globalData(), this, thunk)66 , m_executable() 67 67 , m_scopeChain(exec->globalData(), this, globalObject->globalScopeChain()) 68 68 { 69 ASSERT(inherits(&s_info)); 70 putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); 71 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum); 69 constructorBody(exec, length, name, thunk); 72 70 } 73 71 74 72 JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, int length, const Identifier& name, NativeFunction func) 75 73 : Base(globalObject, structure) 74 , m_executable() 76 75 , m_scopeChain(exec->globalData(), this, globalObject->globalScopeChain()) 77 76 { 78 ASSERT(inherits(&s_info));79 80 77 // Can't do this during initialization because getHostFunction might do a GC allocation. 81 m_executable.set(exec->globalData(), this, exec->globalData().getHostFunction(func)); 82 83 putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); 84 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum); 78 constructorBody(exec, length, name, exec->globalData().getHostFunction(func)); 85 79 } 86 80 … … 93 87 setStructure(exec->globalData(), scopeChainNode->globalObject->namedFunctionStructure()); 94 88 putDirectOffset(exec->globalData(), scopeChainNode->globalObject->functionNameOffset(), executable->nameValue()); 89 } 90 91 inline void JSFunction::constructorBody(ExecState* exec, int length, const Identifier& name, ExecutableBase* executable) 92 { 93 ASSERT(inherits(&s_info)); 94 m_executable.set(exec->globalData(), this, executable); 95 putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum); 96 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum); 95 97 } 96 98 -
trunk/Source/JavaScriptCore/runtime/JSFunction.h
r92706 r93378 124 124 const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesVisitChildren | OverridesGetPropertyNames | JSObject::StructureFlags; 125 125 126 void constructorBody(ExecState*, int length, const Identifier& name, ExecutableBase*); 127 126 128 private: 127 129 explicit JSFunction(VPtrStealingHackType); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r92706 r93378 160 160 , m_evalEnabled(true) 161 161 { 162 COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot); 163 putThisToAnonymousValue(0); 164 init(this); 162 constructorBody(this); 165 163 } 166 164 … … 171 169 , m_weakRandom(static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0))) 172 170 , m_evalEnabled(true) 171 { 172 constructorBody(thisValue); 173 } 174 175 void constructorBody(JSObject* thisValue) 173 176 { 174 177 COMPILE_ASSERT(JSGlobalObject::AnonymousSlotCount == 1, JSGlobalObject_has_only_a_single_slot); -
trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.cpp
r91194 r93378 44 44 , m_jsStrings(adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize])) 45 45 { 46 PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArrayData->propertyNameVector(); 47 for (size_t i = 0; i < m_jsStringsSize; ++i) 48 m_jsStrings[i].set(exec->globalData(), this, jsOwnedString(exec, propertyNameVector[i].ustring())); 46 constructorBody(exec, propertyNameArrayData); 49 47 } 50 48 -
trunk/Source/JavaScriptCore/runtime/JSPropertyNameIterator.h
r92706 r93378 85 85 static const ClassInfo s_info; 86 86 87 protected: 88 void constructorBody(ExecState* exec, PropertyNameArrayData* propertyNameArrayData) 89 { 90 PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArrayData->propertyNameVector(); 91 for (size_t i = 0; i < m_jsStringsSize; ++i) 92 m_jsStrings[i].set(exec->globalData(), this, jsOwnedString(exec, propertyNameVector[i].ustring())); 93 } 94 87 95 private: 88 96 JSPropertyNameIterator(ExecState*, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot); -
trunk/Source/JavaScriptCore/runtime/JSString.h
r92706 r93378 268 268 , m_fiberCount(s_maxInternalRopeLength) 269 269 { 270 constructorBody(exec, v1, v2, v3); 271 } 272 273 // This constructor constructs a new string by concatenating u1 & u2. 274 JSString(JSGlobalData& globalData, const UString& u1, const UString& u2) 275 : JSCell(globalData, globalData.stringStructure.get()) 276 , m_length(u1.length() + u2.length()) 277 , m_fiberCount(2) 278 { 279 unsigned index = 0; 280 appendStringInConstruct(index, u1); 281 appendStringInConstruct(index, u2); 282 ASSERT(index <= s_maxInternalRopeLength); 283 } 284 285 // This constructor constructs a new string by concatenating u1, u2 & u3. 286 JSString(JSGlobalData& globalData, const UString& u1, const UString& u2, const UString& u3) 287 : JSCell(globalData, globalData.stringStructure.get()) 288 , m_length(u1.length() + u2.length() + u3.length()) 289 , m_fiberCount(s_maxInternalRopeLength) 290 { 291 unsigned index = 0; 292 appendStringInConstruct(index, u1); 293 appendStringInConstruct(index, u2); 294 appendStringInConstruct(index, u3); 295 ASSERT(index <= s_maxInternalRopeLength); 296 } 297 298 protected: 299 void constructorBody(ExecState* exec, JSValue v1, JSValue v2, JSValue v3) 300 { 270 301 unsigned index = 0; 271 302 appendValueInConstructAndIncrementLength(exec, index, v1); … … 273 304 appendValueInConstructAndIncrementLength(exec, index, v3); 274 305 ASSERT(index == s_maxInternalRopeLength); 275 }276 277 // This constructor constructs a new string by concatenating u1 & u2.278 JSString(JSGlobalData& globalData, const UString& u1, const UString& u2)279 : JSCell(globalData, globalData.stringStructure.get())280 , m_length(u1.length() + u2.length())281 , m_fiberCount(2)282 {283 unsigned index = 0;284 appendStringInConstruct(index, u1);285 appendStringInConstruct(index, u2);286 ASSERT(index <= s_maxInternalRopeLength);287 }288 289 // This constructor constructs a new string by concatenating u1, u2 & u3.290 JSString(JSGlobalData& globalData, const UString& u1, const UString& u2, const UString& u3)291 : JSCell(globalData, globalData.stringStructure.get())292 , m_length(u1.length() + u2.length() + u3.length())293 , m_fiberCount(s_maxInternalRopeLength)294 {295 unsigned index = 0;296 appendStringInConstruct(index, u1);297 appendStringInConstruct(index, u2);298 appendStringInConstruct(index, u3);299 ASSERT(index <= s_maxInternalRopeLength);300 306 } 301 307 -
trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r91194 r93378 36 36 : InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, nameAndMessage)) 37 37 { 38 ASSERT(inherits(&s_info)); 39 40 NativeErrorPrototype* prototype = NativeErrorPrototype::create(exec, globalObject, prototypeStructure, nameAndMessage, this); 41 42 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5 43 putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | ReadOnly | DontEnum); 44 m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), prototype)); 45 ASSERT(m_errorStructure); 46 ASSERT(m_errorStructure->typeInfo().type() == ObjectType); 38 constructorBody(exec, globalObject, prototypeStructure, nameAndMessage); 47 39 } 48 40 -
trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.h
r92706 r93378 23 23 24 24 #include "InternalFunction.h" 25 #include "NativeErrorPrototype.h" 25 26 26 27 namespace JSC { … … 48 49 Structure* errorStructure() { return m_errorStructure.get(); } 49 50 51 protected: 52 void constructorBody(ExecState* exec, JSGlobalObject* globalObject, Structure* prototypeStructure, const UString& nameAndMessage) 53 { 54 ASSERT(inherits(&s_info)); 55 56 NativeErrorPrototype* prototype = NativeErrorPrototype::create(exec, globalObject, prototypeStructure, nameAndMessage, this); 57 58 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5 59 putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | ReadOnly | DontEnum); 60 m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), prototype)); 61 ASSERT(m_errorStructure); 62 ASSERT(m_errorStructure->typeInfo().type() == ObjectType); 63 } 64 50 65 private: 51 66 NativeErrorConstructor(ExecState*, JSGlobalObject*, Structure*, Structure* prototypeStructure, const UString&); -
trunk/Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp
r91116 r93378 34 34 : ErrorPrototype(exec, globalObject, structure) 35 35 { 36 constructorBody(exec, nameAndMessage, constructor); 37 } 38 39 inline void NativeErrorPrototype::constructorBody(ExecState* exec, const UString& nameAndMessage, NativeErrorConstructor* constructor) 40 { 36 41 putDirect(exec->globalData(), exec->propertyNames().name, jsString(exec, nameAndMessage), DontEnum); 37 42 putDirect(exec->globalData(), exec->propertyNames().message, jsString(exec, nameAndMessage), DontEnum); -
trunk/Source/JavaScriptCore/runtime/NativeErrorPrototype.h
r92706 r93378 38 38 return new (allocateCell<NativeErrorPrototype>(*exec->heap())) NativeErrorPrototype(exec, globalObject, structure, nameAndMessage, constructor); 39 39 } 40 41 protected: 42 void constructorBody(ExecState*, const UString& nameAndMessage, NativeErrorConstructor*); 40 43 }; 41 44 -
trunk/Source/JavaScriptCore/runtime/StringObject.cpp
r84052 r93378 30 30 const ClassInfo StringObject::s_info = { "String", &JSWrapperObject::s_info, 0, 0 }; 31 31 32 StringObject::StringObject(ExecState* exec, Structure* structure)33 : JSWrapperObject(exec->globalData(), structure)34 {35 ASSERT(inherits(&s_info));36 setInternalValue(exec->globalData(), jsEmptyString(exec));37 }38 39 32 StringObject::StringObject(JSGlobalData& globalData, Structure* structure, JSString* string) 40 33 : JSWrapperObject(globalData, structure) … … 42 35 ASSERT(inherits(&s_info)); 43 36 setInternalValue(globalData, string); 44 }45 46 StringObject::StringObject(ExecState* exec, Structure* structure, const UString& string)47 : JSWrapperObject(exec->globalData(), structure)48 {49 ASSERT(inherits(&s_info));50 setInternalValue(exec->globalData(), jsString(exec, string));51 37 } 52 38 -
trunk/Source/JavaScriptCore/runtime/StringObject.h
r92706 r93378 33 33 static StringObject* create(ExecState* exec, Structure* structure) 34 34 { 35 return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec, structure); 35 JSString* string = jsEmptyString(exec); 36 return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec->globalData(), structure, string); 36 37 } 37 38 static StringObject* create(ExecState* exec, Structure* structure, const UString& str) 38 39 { 39 return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec, structure, str); 40 JSString* string = jsString(exec, str); 41 return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec->globalData(), structure, string); 40 42 } 41 43 static StringObject* create(ExecState*, JSGlobalObject*, JSString*); 42 43 44 44 45 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); … … 60 61 61 62 protected: 62 StringObject(ExecState*, Structure*);63 StringObject(ExecState*, Structure*, const UString&);64 63 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSWrapperObject::StructureFlags; 65 64 StringObject(JSGlobalData&, Structure*, JSString*); -
trunk/Source/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h
r92706 r93378 35 35 static StringObjectThatMasqueradesAsUndefined* create(ExecState* exec, const UString& string) 36 36 { 37 JSString* newString = jsString(exec, string); 37 38 return new (allocateCell<StringObjectThatMasqueradesAsUndefined>(*exec->heap())) StringObjectThatMasqueradesAsUndefined(exec, 38 createStructure(exec->globalData(), exec->lexicalGlobalObject()->stringPrototype()), string);39 createStructure(exec->globalData(), exec->lexicalGlobalObject()->stringPrototype()), newString); 39 40 } 40 41 41 42 private: 42 StringObjectThatMasqueradesAsUndefined(ExecState* exec, Structure* structure, const UString&string)43 : StringObject(exec , structure, string)43 StringObjectThatMasqueradesAsUndefined(ExecState* exec, Structure* structure, JSString* string) 44 : StringObject(exec->globalData(), structure, string) 44 45 { 45 46 } -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r92540 r93378 132 132 133 133 // ECMA 15.5.4 134 StringPrototype::StringPrototype(ExecState* exec, JSGlobalObject* globalObject, Structure* structure )135 : StringObject(exec , structure)134 StringPrototype::StringPrototype(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSString* nameAndMessage) 135 : StringObject(exec->globalData(), structure, nameAndMessage) 136 136 { 137 137 ASSERT(inherits(&s_info)); -
trunk/Source/JavaScriptCore/runtime/StringPrototype.h
r92706 r93378 30 30 class StringPrototype : public StringObject { 31 31 private: 32 StringPrototype(ExecState*, JSGlobalObject*, Structure* );32 StringPrototype(ExecState*, JSGlobalObject*, Structure*, JSString*); 33 33 34 34 public: … … 37 37 static StringPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure) 38 38 { 39 return new (allocateCell<StringPrototype>(*exec->heap())) StringPrototype(exec, globalObject, structure); 39 JSString* nameAndMessage = jsEmptyString(exec); 40 return new (allocateCell<StringPrototype>(*exec->heap())) StringPrototype(exec, globalObject, structure, nameAndMessage); 40 41 } 41 42
Note:
See TracChangeset
for help on using the changeset viewer.