Changeset 128802 in webkit for trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
- Timestamp:
- Sep 17, 2012, 1:56:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r128400 r128802 112 112 : Base(globalData, structure, 0) 113 113 , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(InitializedWatching))) 114 , m_havingABadTimeWatchpoint(adoptRef(new WatchpointSet(InitializedWatching))) 114 115 , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0))) 115 116 , m_evalEnabled(true) … … 231 232 232 233 m_arrayPrototype.set(exec->globalData(), this, ArrayPrototype::create(exec, this, ArrayPrototype::createStructure(exec->globalData(), this, m_objectPrototype.get()))); 233 m_arrayStructure.set(exec->globalData(), this, JSArray::createStructure(exec->globalData(), this, m_arrayPrototype.get())); 234 m_arrayStructure.set(exec->globalData(), this, JSArray::createStructure(exec->globalData(), this, m_arrayPrototype.get(), ArrayWithArrayStorage)); 235 m_arrayStructureForSlowPut.set(exec->globalData(), this, JSArray::createStructure(exec->globalData(), this, m_arrayPrototype.get(), ArrayWithSlowPutArrayStorage)); 234 236 m_regExpMatchesArrayStructure.set(exec->globalData(), this, RegExpMatchesArray::createStructure(exec->globalData(), this, m_arrayPrototype.get())); 235 237 … … 328 330 329 331 resetPrototype(exec->globalData(), prototype); 332 } 333 334 // Private namespace for helpers for JSGlobalObject::haveABadTime() 335 namespace { 336 337 class ObjectsWithBrokenIndexingFinder : public MarkedBlock::VoidFunctor { 338 public: 339 ObjectsWithBrokenIndexingFinder(MarkedArgumentBuffer&, JSGlobalObject*); 340 void operator()(JSCell*); 341 342 private: 343 MarkedArgumentBuffer& m_foundObjects; 344 JSGlobalObject* m_globalObject; 345 }; 346 347 ObjectsWithBrokenIndexingFinder::ObjectsWithBrokenIndexingFinder( 348 MarkedArgumentBuffer& foundObjects, JSGlobalObject* globalObject) 349 : m_foundObjects(foundObjects) 350 , m_globalObject(globalObject) 351 { 352 } 353 354 inline bool hasBrokenIndexing(JSObject* object) 355 { 356 // This will change if we have more indexing types. 357 return !!(object->structure()->indexingType() & HasArrayStorage); 358 } 359 360 void ObjectsWithBrokenIndexingFinder::operator()(JSCell* cell) 361 { 362 if (!cell->isObject()) 363 return; 364 365 JSObject* object = asObject(cell); 366 367 // We only want to have a bad time in the affected global object, not in the entire 368 // VM. 369 if (object->unwrappedGlobalObject() != m_globalObject) 370 return; 371 372 if (!hasBrokenIndexing(object)) 373 return; 374 375 m_foundObjects.append(object); 376 } 377 378 } // end private namespace for helpers for JSGlobalObject::haveABadTime() 379 380 void JSGlobalObject::haveABadTime(JSGlobalData& globalData) 381 { 382 ASSERT(&globalData == &this->globalData()); 383 384 if (isHavingABadTime()) 385 return; 386 387 // Make sure that all allocations or indexed storage transitions that are inlining 388 // the assumption that it's safe to transition to a non-SlowPut array storage don't 389 // do so anymore. 390 m_havingABadTimeWatchpoint->notifyWrite(); 391 ASSERT(isHavingABadTime()); // The watchpoint is what tells us that we're having a bad time. 392 393 // Make sure that all JSArray allocations that load the appropriate structure from 394 // this object now load a structure that uses SlowPut. 395 m_arrayStructure.set(globalData, this, m_arrayStructureForSlowPut.get()); 396 397 // Make sure that all objects that have indexed storage switch to the slow kind of 398 // indexed storage. 399 MarkedArgumentBuffer foundObjects; // Use MarkedArgumentBuffer because switchToSlowPutArrayStorage() may GC. 400 ObjectsWithBrokenIndexingFinder finder(foundObjects, this); 401 globalData.heap.objectSpace().forEachLiveCell(finder); 402 while (!foundObjects.isEmpty()) { 403 JSObject* object = asObject(foundObjects.last()); 404 foundObjects.removeLast(); 405 ASSERT(hasBrokenIndexing(object)); 406 object->switchToSlowPutArrayStorage(globalData); 407 } 330 408 } 331 409
Note:
See TracChangeset
for help on using the changeset viewer.