Changeset 64655 in webkit
- Timestamp:
- Aug 4, 2010 10:18:07 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r64649 r64655 1 2010-08-04 Nathan Lawrence <nlawrence@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Refactoring MarkStack::append to take a reference. This is in 6 preparation for movable objects when we will need to update pointers. 7 http://bugs.webkit.org/show_bug.cgi?id=41177 8 9 Unless otherwise noted, all changes are to either return by reference 10 or pass a reference to MarkStack::append. 11 12 * bytecode/CodeBlock.cpp: 13 (JSC::CodeBlock::markAggregate): 14 * runtime/Collector.cpp: 15 (JSC::Heap::markConservatively): 16 Added a temporary variable to prevent marking from changing an 17 unknown value on the stack 18 * runtime/JSCell.h: 19 (JSC::JSValue::asCell): 20 (JSC::MarkStack::append): 21 (JSC::MarkStack::appendInternal): 22 * runtime/JSGlobalObject.cpp: 23 (JSC::markIfNeeded): 24 * runtime/JSONObject.cpp: 25 (JSC::Stringifier::Holder::object): 26 * runtime/JSObject.h: 27 (JSC::JSObject::prototype): 28 * runtime/JSStaticScopeObject.cpp: 29 (JSC::JSStaticScopeObject::markChildren): 30 * runtime/JSValue.h: 31 (JSC::JSValue::JSValue): 32 (JSC::JSValue::asCell): 33 * runtime/MarkStack.h: 34 * runtime/NativeErrorConstructor.cpp: 35 (JSC::NativeErrorConstructor::createStructure): 36 Changed the structure flags to include a custom markChildren. 37 (JSC::NativeErrorConstructor::markChildren): 38 Update the prototype of the stored structure. 39 * runtime/NativeErrorConstructor.h: 40 Added structure flags. 41 * runtime/Structure.h: 42 (JSC::Structure::storedPrototype): 43 1 44 2010-08-03 Nathan Lawrence <nlawrence@apple.com> 2 45 -
trunk/JavaScriptCore/bytecode/CodeBlock.cpp
r63449 r64655 1514 1514 { 1515 1515 for (size_t i = 0; i < m_constantRegisters.size(); ++i) 1516 markStack.append(m_constantRegisters[i] .jsValue());1516 markStack.append(m_constantRegisters[i]); 1517 1517 for (size_t i = 0; i < m_functionExprs.size(); ++i) 1518 1518 m_functionExprs[i]->markAggregate(markStack); -
trunk/JavaScriptCore/runtime/Collector.cpp
r64624 r64655 692 692 if (m_heap.collectorBlock(block) != blockAddr) 693 693 continue; 694 markStack.append(reinterpret_cast<JSCell*>(xAsBits)); 694 // While markStack.append normally takes a reference to update, 695 // we don't actually want the heap to be updated since we don't 696 // know for sure that it's actually a pointer. In the future 697 // this will be replaced by some appendRoot function for this 698 // specific case. 699 JSCell* cell = reinterpret_cast<JSCell*>(xAsBits); 700 markStack.append(cell); 695 701 markStack.drain(); 696 702 } -
trunk/JavaScriptCore/runtime/JSCell.h
r60631 r64655 36 36 37 37 class JSCell : public NoncopyableCustomAllocated { 38 friend class CollectorHeap; 38 39 friend class GetterSetter; 39 40 friend class Heap; … … 238 239 239 240 #if !USE(JSVALUE32_64) 240 ALWAYS_INLINE JSCell* JSValue::asCell() const 241 ALWAYS_INLINE JSCell*& JSValue::asCell() 242 { 243 ASSERT(isCell()); 244 return m_ptr; 245 } 246 247 ALWAYS_INLINE JSCell* const& JSValue::asCell() const 241 248 { 242 249 ASSERT(isCell()); … … 330 337 } 331 338 332 ALWAYS_INLINE void MarkStack::append(JSCell* cell) 339 template<typename T> 340 ALWAYS_INLINE void MarkStack::append(T*& cell) 341 { 342 // References in C++ are not covariant. JSObject* being a subtype of JSCell* 343 // does not mean that JSObject*& can be used as a subtype of JSCell*& because 344 // treating a JSObject*& as a JSCell*& would allow us to change the pointer to 345 // point to something that is a JSCell but not a JSObject. 346 // 347 // In this case, we need to be able to change the pointer, and although we know 348 // it to be safe, C++ doesn't, requiring us to use templated functions that 349 // pass a casted version to an internal function. 350 // 351 // Currently we're not doing anything with the value of the pointer, so nothing 352 // unsafe will happen. In the future, when we have movable objects, we will be 353 // changing the value of the pointer to be the new location, in which case the 354 // type will be preserved. 355 JSCell*& ptr = *reinterpret_cast<JSCell**>(&cell); 356 appendInternal(ptr); 357 } 358 359 ALWAYS_INLINE void MarkStack::append(JSValue& value) 360 { 361 ASSERT(value); 362 if (value.isCell()) 363 appendInternal(value.asCell()); 364 } 365 366 ALWAYS_INLINE void MarkStack::append(Register& reg) 367 { 368 JSValue value = reg.jsValue(); 369 append(value); 370 reg = value; 371 } 372 373 inline void MarkStack::appendInternal(JSCell*& cell) 333 374 { 334 375 ASSERT(!m_isCheckingForDefaultMarkViolation); … … 341 382 } 342 383 343 ALWAYS_INLINE void MarkStack::append(JSValue value)344 {345 ASSERT(value);346 if (value.isCell())347 append(value.asCell());348 }349 350 384 inline Heap* Heap::heap(JSValue v) 351 385 { -
trunk/JavaScriptCore/runtime/JSGlobalObject.cpp
r63882 r64655 81 81 static const int preferredScriptCheckTimeInterval = 1000; 82 82 83 static inline void markIfNeeded(MarkStack& markStack, JSValuev)83 template<typename T> static inline void markIfNeeded(MarkStack& markStack, T*& v) 84 84 { 85 85 if (v) … … 87 87 } 88 88 89 static inline void markIfNeeded(MarkStack& markStack, constRefPtr<Structure>& s)89 static inline void markIfNeeded(MarkStack& markStack, RefPtr<Structure>& s) 90 90 { 91 91 if (s) 92 mark IfNeeded(markStack,s->storedPrototype());92 markStack.append(s->storedPrototype()); 93 93 } 94 94 -
trunk/JavaScriptCore/runtime/JSONObject.cpp
r60762 r64655 83 83 Holder(JSObject*); 84 84 85 JSObject* object() const { return m_object; } 85 JSObject*& object() { return m_object; } 86 JSObject* const& object() const { return m_object; } 86 87 87 88 bool appendNextProperty(Stringifier&, StringBuilder&); 88 89 89 90 private: 90 JSObject* constm_object;91 JSObject* m_object; 91 92 const bool m_isArray; 92 93 bool m_isJSArray; -
trunk/JavaScriptCore/runtime/JSObject.h
r62896 r64655 87 87 virtual ~JSObject(); 88 88 89 JSValue prototype() const; 89 JSValue& prototype(); 90 const JSValue& prototype() const; 90 91 void setPrototype(JSValue prototype); 91 92 bool setPrototypeWithCycleCheck(JSValue prototype); … … 313 314 } 314 315 315 inline JSValue JSObject::prototype() const 316 inline JSValue& JSObject::prototype() 317 { 318 return m_structure->storedPrototype(); 319 } 320 321 inline const JSValue& JSObject::prototype() const 316 322 { 317 323 return m_structure->storedPrototype(); -
trunk/JavaScriptCore/runtime/JSStaticScopeObject.cpp
r58986 r64655 35 35 { 36 36 JSVariableObject::markChildren(markStack); 37 markStack.append(d()->registerStore .jsValue());37 markStack.append(d()->registerStore); 38 38 } 39 39 -
trunk/JavaScriptCore/runtime/JSValue.h
r62896 r64655 200 200 201 201 bool isCell() const; 202 JSCell* asCell() const; 202 JSCell*& asCell(); 203 JSCell* const& asCell() const; 203 204 bool isValidCallee(); 204 205 … … 241 242 int32_t payload; 242 243 } asBits; 244 struct { 245 int32_t tag; 246 JSCell* ptr; 247 } asPtr; 243 248 #else 244 249 struct { … … 246 251 int32_t tag; 247 252 } asBits; 253 struct { 254 JSCell* ptr; 255 int32_t tag; 256 } asPtr; 248 257 #endif 249 258 } u; … … 492 501 else 493 502 u.asBits.tag = EmptyValueTag; 494 u.as Bits.payload = reinterpret_cast<int32_t>(ptr);503 u.asPtr.ptr = ptr; 495 504 #if ENABLE(JSC_ZOMBIES) 496 505 ASSERT(!isZombie()); … … 504 513 else 505 514 u.asBits.tag = EmptyValueTag; 506 u.as Bits.payload = reinterpret_cast<int32_t>(const_cast<JSCell*>(ptr));515 u.asPtr.ptr = const_cast<JSCell*>(ptr); 507 516 #if ENABLE(JSC_ZOMBIES) 508 517 ASSERT(!isZombie()); … … 599 608 } 600 609 601 ALWAYS_INLINE JSCell* JSValue::asCell() const610 ALWAYS_INLINE JSCell* const& JSValue::asCell() const 602 611 { 603 612 ASSERT(isCell()); 604 return reinterpret_cast<JSCell*>(u.asBits.payload); 613 return u.asPtr.ptr; 614 } 615 616 ALWAYS_INLINE JSCell*& JSValue::asCell() 617 { 618 ASSERT(isCell()); 619 return u.asPtr.ptr; 605 620 } 606 621 -
trunk/JavaScriptCore/runtime/MarkStack.h
r53922 r64655 47 47 } 48 48 49 ALWAYS_INLINE void append(JSValue); 50 void append(JSCell*); 49 template<typename T> ALWAYS_INLINE void append(T*& cell); 50 ALWAYS_INLINE void append(JSValue&); 51 ALWAYS_INLINE void append(Register&); 51 52 52 53 ALWAYS_INLINE void appendValues(Register* values, size_t count, MarkSetProperties properties = NoNullValues) … … 71 72 72 73 private: 74 void appendInternal(JSCell*&); 75 73 76 void markChildren(JSCell*); 74 77 -
trunk/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r60762 r64655 69 69 } 70 70 71 PassRefPtr<Structure> NativeErrorConstructor::createStructure(JSObject* prototype) 72 { 73 return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); 74 } 75 76 void NativeErrorConstructor::markChildren(MarkStack& markStack) 77 { 78 InternalFunction::markChildren(markStack); 79 80 markStack.append(m_errorStructure->storedPrototype()); 81 } 82 71 83 } // namespace JSC -
trunk/JavaScriptCore/runtime/NativeErrorConstructor.h
r60762 r64655 37 37 38 38 Structure* errorStructure() { return m_errorStructure.get(); } 39 static PassRefPtr<Structure> createStructure(JSObject* prototype); 40 41 protected: 42 static const unsigned StructureFlags = InternalFunction::StructureFlags | OverridesMarkChildren; 39 43 40 44 private: 41 45 virtual ConstructType getConstructData(ConstructData&); 42 46 virtual CallType getCallData(CallData&); 47 48 virtual void markChildren(MarkStack&); 43 49 44 50 virtual const ClassInfo* classInfo() const { return &info; } -
trunk/JavaScriptCore/runtime/Structure.h
r54798 r64655 95 95 const TypeInfo& typeInfo() const { return m_typeInfo; } 96 96 97 JSValue storedPrototype() const { return m_prototype; } 97 const JSValue& storedPrototype() const { return m_prototype; } 98 JSValue& storedPrototype() { return m_prototype; } 98 99 JSValue prototypeForLookup(ExecState*) const; 99 100 StructureChain* prototypeChain(ExecState*) const; -
trunk/JavaScriptGlue/ChangeLog
r64626 r64655 1 2010-08-04 Nathan Lawrence <nlawrence@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Removed unneeded marking. We need to remove this marking in order to have 6 MarkStack::append take references for updating movable objects. 7 8 https://bugs.webkit.org/show_bug.cgi?id=41177 9 10 * JSValueWrapper.cpp: 11 (JSValueWrapper::JSObjectMark): 12 1 13 2010-08-03 Gavin Barraclough <barraclough@apple.com> 2 14 -
trunk/JavaScriptGlue/JSValueWrapper.cpp
r52856 r64655 193 193 } 194 194 195 void JSValueWrapper::JSObjectMark(void *data) 196 { 197 JSValueWrapper* ptr = (JSValueWrapper*)data; 198 if (ptr) 199 { 200 // This results in recursive marking but will be otherwise safe and correct. 201 // We claim the array vptr is 0 because we don't have access to it here, and 202 // claiming 0 is functionally harmless -- it merely means that we can't 203 // devirtualise marking of arrays when recursing from this point. 204 MarkStack markStack(0); 205 markStack.append(ptr->fValue.get()); 206 markStack.drain(); 207 } 208 } 195 void JSValueWrapper::JSObjectMark(void*) 196 { 197 // The object doesn't need to be marked here because it is a protected 198 // object and should therefore be marked by 199 // JSC::Heap::markProtectedObjects. 200 201 // We are keeping the function around because the function is passed as a 202 // callback. 203 }
Note: See TracChangeset
for help on using the changeset viewer.