Changeset 64684 in webkit for trunk/JavaScriptCore/runtime/JSCell.h
- Timestamp:
- Aug 4, 2010, 3:21:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSCell.h
r64655 r64684 36 36 37 37 class JSCell : public NoncopyableCustomAllocated { 38 friend class CollectorHeap;39 38 friend class GetterSetter; 40 39 friend class Heap; … … 239 238 240 239 #if !USE(JSVALUE32_64) 241 ALWAYS_INLINE JSCell*& JSValue::asCell() 242 { 243 ASSERT(isCell()); 244 return m_ptr; 245 } 246 247 ALWAYS_INLINE JSCell* const& JSValue::asCell() const 240 ALWAYS_INLINE JSCell* JSValue::asCell() const 248 241 { 249 242 ASSERT(isCell()); … … 337 330 } 338 331 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) 332 ALWAYS_INLINE void MarkStack::append(JSCell* cell) 374 333 { 375 334 ASSERT(!m_isCheckingForDefaultMarkViolation); … … 382 341 } 383 342 343 ALWAYS_INLINE void MarkStack::append(JSValue value) 344 { 345 ASSERT(value); 346 if (value.isCell()) 347 append(value.asCell()); 348 } 349 384 350 inline Heap* Heap::heap(JSValue v) 385 351 {
Note:
See TracChangeset
for help on using the changeset viewer.