Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Clear StructureCache if it has Structure with relevant JSGlobalObjects
https://bugs.webkit.org/show_bug.cgi?id=240768 rdar://93232129 Reviewed by Saam Barati. We need to clear Structures in StructureCache when having-a-bad-time: it is possible that Structure could have this have-a-bad-time relevant JSGlobalObjects in its prototype chain. We are clearing it for InternalFunction's allocation cache. We should do the same thing for JSGlobalObject's StructureCache. This patch adds new watchpoint, structureCacheClearedWatchpoint. And use it in DFG. This watchpoint fires when the cache is cleared, and it can happen even though JSGlobalObject is not getting have-a-bad-time. * JSTests/stress/global-object-have-a-bad-time-dependency.js: Added. (shouldBe): (cons): * Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants): * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::JSGlobalObject): (JSC::JSGlobalObject::fireWatchpointAndMakeAllArrayStructuresSlowPut): (JSC::JSGlobalObject::clearStructureCache): * Source/JavaScriptCore/runtime/JSGlobalObject.h: (JSC::JSGlobalObject::structureCacheClearedWatchpoint): (JSC::JSGlobalObject::isStructureCacheCleared const): * Source/JavaScriptCore/runtime/StructureCache.h: (JSC::StructureCache::forEach): * Source/JavaScriptCore/runtime/WeakGCMap.h: Canonical link: https://commits.webkit.org/250845@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
7b0eb35
commit fd038f440a814e6f5c2ca81057ce5c6f5a9b1dd6
Showing
9 changed files
with
123 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,30 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error('bad value: ' + actual); | ||
} | ||
|
||
const alien_global_object = createGlobalObject(); | ||
|
||
const a = {}; | ||
const b = alien_global_object.Object(); | ||
|
||
a.__proto__ = b; | ||
|
||
function cons() { | ||
|
||
} | ||
|
||
cons.prototype = a; | ||
|
||
// Cache | ||
Reflect.construct(Array, [1.1, 2.2, 3.3], cons); | ||
|
||
// Clear rareData to avoid the check in ObjectsWithBrokenIndexingFinder<mode>::visit(JSObject* object). | ||
cons.prototype = null; | ||
cons.prototype = a; | ||
|
||
// Have a bad time. | ||
b.__proto__ = new Proxy({}, {}); | ||
|
||
// This will create a double array having a Proxy object in its prototype chain. | ||
shouldBe(!!describe(Reflect.construct(Array, [1.1, 2.2, 3.3], cons)).match(/ArrayWithSlowPutArrayStorage/), true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -103,6 +103,9 @@ class WeakGCMap final : public WeakGCHashTable { | ||
|
||
void pruneStaleEntries() final; | ||
|
||
template<typename Func> | ||
void forEach(Func); | ||
|
||
private: | ||
HashMapType m_map; | ||
VM& m_vm; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters