Diff
Modified: trunk/LayoutTests/ChangeLog (253809 => 253810)
--- trunk/LayoutTests/ChangeLog 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/LayoutTests/ChangeLog 2019-12-20 03:32:37 UTC (rev 253810)
@@ -1,3 +1,14 @@
+2019-12-19 Saam Barati <[email protected]>
+
+ Don't cache self customs on dictionaries
+ https://bugs.webkit.org/show_bug.cgi?id=205466
+ <rdar://problem/58075545>
+
+ Reviewed by Mark Lam.
+
+ * js/dom/custom-function-should-not-cache-as-dictionary-expected.txt: Added.
+ * js/dom/custom-function-should-not-cache-as-dictionary.html: Added.
+
2019-12-19 Jack Lee <[email protected]>
Nullptr crash in WebCore::RenderTreeBuilder::attach
Added: trunk/LayoutTests/js/dom/custom-function-should-not-cache-as-dictionary-expected.txt (0 => 253810)
--- trunk/LayoutTests/js/dom/custom-function-should-not-cache-as-dictionary-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/custom-function-should-not-cache-as-dictionary-expected.txt 2019-12-20 03:32:37 UTC (rev 253810)
@@ -0,0 +1,5 @@
+PASS Overrode XMLHttpRequest
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/dom/custom-function-should-not-cache-as-dictionary.html (0 => 253810)
--- trunk/LayoutTests/js/dom/custom-function-should-not-cache-as-dictionary.html (rev 0)
+++ trunk/LayoutTests/js/dom/custom-function-should-not-cache-as-dictionary.html 2019-12-20 03:32:37 UTC (rev 253810)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+(function() {
+ "use strict";
+
+ let fakeXHRCreated = false;
+
+ function createXHR() {
+ let xhr = new window.XMLHttpRequest();
+ }
+
+ for (let i = 0; i < 1000; i++) {
+ createXHR();
+ }
+
+ // Overwrite XMLHttpRequest
+ window.XMLHttpRequest = function() {
+ fakeXHRCreated = true;
+ }
+
+ createXHR();
+
+ if (fakeXHRCreated)
+ testPassed("Overrode XMLHttpRequest");
+ else
+ testFailed("Did not override XMLHttpRequest");
+})();
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/_javascript_Core/ChangeLog (253809 => 253810)
--- trunk/Source/_javascript_Core/ChangeLog 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-12-20 03:32:37 UTC (rev 253810)
@@ -1,3 +1,35 @@
+2019-12-19 Saam Barati <[email protected]>
+
+ Don't cache self customs on dictionaries
+ https://bugs.webkit.org/show_bug.cgi?id=205466
+ <rdar://problem/58075545>
+
+ Reviewed by Mark Lam.
+
+ We had a bug where we would cache a custom value/accessor on a self property
+ of a cacheable dictionary object. This turns out to be wrong because the
+ inline cache won't fail (because we won't transition structures) if that
+ property is replaced with something else. We would do the right thing when
+ the custom was on the prototype chain, but when it was a self property, we
+ didn't. The reason customs are different from values/normal accessors is that
+ we dynamically load values/getters/setters from the object itself. For
+ customs, we cache the actual pointer value of the C function. This patch makes
+ it so we don't cache customs on dictionaries.
+
+ * bytecode/ObjectPropertyConditionSet.cpp:
+ (JSC::prepareChainForCaching):
+ (JSC::preparePrototypeChainForCaching): Deleted.
+ * bytecode/ObjectPropertyConditionSet.h:
+ * jit/Repatch.cpp:
+ (JSC::tryCacheGetBy):
+ (JSC::tryCachePutByID):
+ (JSC::tryCacheInByID):
+ (JSC::tryCacheInstanceOf):
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::setupGetByIdPrototypeCache):
+ * runtime/StructureRareData.cpp:
+ (JSC::StructureRareData::setObjectToStringValue):
+
2019-12-19 Devin Rousso <[email protected]>
Web Inspector: TypeError: InjectedScriptHost.isPromiseRejectedWithNativeGetterTypeError first argument must be a Promise
Modified: trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp (253809 => 253810)
--- trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.cpp 2019-12-20 03:32:37 UTC (rev 253810)
@@ -509,7 +509,7 @@
}
// Current might be null. Structure can't be null.
-static Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject* globalObject, JSCell* current, Structure* structure, JSObject* target)
+static Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject* globalObject, JSCell* current, Structure* structure, JSObject* target)
{
ASSERT(structure);
VM& vm = globalObject->vm();
@@ -571,20 +571,20 @@
return result;
}
-Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject* globalObject, JSCell* base, JSObject* target)
+Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject* globalObject, JSCell* base, JSObject* target)
{
- return preparePrototypeChainForCaching(globalObject, base, base->structure(globalObject->vm()), target);
+ return prepareChainForCaching(globalObject, base, base->structure(globalObject->vm()), target);
}
-Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject* globalObject, JSCell* base, const PropertySlot& slot)
+Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject* globalObject, JSCell* base, const PropertySlot& slot)
{
JSObject* target = slot.isUnset() ? nullptr : slot.slotBase();
- return preparePrototypeChainForCaching(globalObject, base, target);
+ return prepareChainForCaching(globalObject, base, target);
}
-Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject* globalObject, Structure* baseStructure, JSObject* target)
+Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject* globalObject, Structure* baseStructure, JSObject* target)
{
- return preparePrototypeChainForCaching(globalObject, nullptr, baseStructure, target);
+ return prepareChainForCaching(globalObject, nullptr, baseStructure, target);
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.h (253809 => 253810)
--- trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.h 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/Source/_javascript_Core/bytecode/ObjectPropertyConditionSet.h 2019-12-20 03:32:37 UTC (rev 253810)
@@ -194,8 +194,8 @@
bool flattenedDictionary;
};
-Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject*, JSCell* base, const PropertySlot&);
-Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject*, JSCell* base, JSObject* target);
-Optional<PrototypeChainCachingStatus> preparePrototypeChainForCaching(JSGlobalObject*, Structure* base, JSObject* target);
+Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject*, JSCell* base, const PropertySlot&);
+Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject*, JSCell* base, JSObject* target);
+Optional<PrototypeChainCachingStatus> prepareChainForCaching(JSGlobalObject*, Structure* base, JSObject* target);
} // namespace JSC
Modified: trunk/Source/_javascript_Core/jit/Repatch.cpp (253809 => 253810)
--- trunk/Source/_javascript_Core/jit/Repatch.cpp 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/Source/_javascript_Core/jit/Repatch.cpp 2019-12-20 03:32:37 UTC (rev 253810)
@@ -280,6 +280,15 @@
PropertyOffset offset = slot.isUnset() ? invalidOffset : slot.cachedOffset();
+ if (slot.isCustom() && slot.slotBase() == baseValue) {
+ // To cache self customs, we must disallow dictionaries because we
+ // need to be informed if the custom goes away since we cache the
+ // constant function pointer.
+
+ if (!prepareChainForCaching(globalObject, slot.slotBase(), slot.slotBase()))
+ return GiveUpOnCache;
+ }
+
if (slot.isUnset() || slot.slotBase() != baseValue) {
if (structure->typeInfo().prohibitsPropertyCaching())
return GiveUpOnCache;
@@ -297,7 +306,7 @@
// If a kind is GetByKind::Direct, we do not need to investigate prototype chains further.
// Cacheability just depends on the head structure.
if (kind != GetByKind::Direct) {
- auto cacheStatus = preparePrototypeChainForCaching(globalObject, baseCell, slot);
+ auto cacheStatus = prepareChainForCaching(globalObject, baseCell, slot);
if (!cacheStatus)
return GiveUpOnCache;
@@ -608,7 +617,7 @@
std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
ObjectPropertyConditionSet conditionSet;
if (putKind == NotDirect) {
- auto cacheStatus = preparePrototypeChainForCaching(globalObject, baseCell, nullptr);
+ auto cacheStatus = prepareChainForCaching(globalObject, baseCell, nullptr);
if (!cacheStatus)
return GiveUpOnCache;
@@ -632,11 +641,14 @@
ObjectPropertyConditionSet conditionSet;
std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
+ // We need to do this even if we're a self custom, since we must disallow dictionaries
+ // because we need to be informed if the custom goes away since we cache the constant
+ // function pointer.
+ auto cacheStatus = prepareChainForCaching(globalObject, baseCell, slot.base());
+ if (!cacheStatus)
+ return GiveUpOnCache;
+
if (slot.base() != baseValue) {
- auto cacheStatus = preparePrototypeChainForCaching(globalObject, baseCell, slot.base());
- if (!cacheStatus)
- return GiveUpOnCache;
-
if (cacheStatus->usesPolyProto) {
prototypeAccessChain = PolyProtoAccessChain::create(globalObject, baseCell, slot.base());
if (!prototypeAccessChain)
@@ -659,7 +671,7 @@
PropertyOffset offset = slot.cachedOffset();
if (slot.base() != baseValue) {
- auto cacheStatus = preparePrototypeChainForCaching(globalObject, baseCell, slot.base());
+ auto cacheStatus = prepareChainForCaching(globalObject, baseCell, slot.base());
if (!cacheStatus)
return GiveUpOnCache;
if (cacheStatus->flattenedDictionary)
@@ -761,7 +773,7 @@
}
if (slot.slotBase() != base) {
- auto cacheStatus = preparePrototypeChainForCaching(globalObject, base, slot);
+ auto cacheStatus = prepareChainForCaching(globalObject, base, slot);
if (!cacheStatus)
return GiveUpOnCache;
if (cacheStatus->flattenedDictionary)
@@ -782,7 +794,7 @@
}
}
} else {
- auto cacheStatus = preparePrototypeChainForCaching(globalObject, base, nullptr);
+ auto cacheStatus = prepareChainForCaching(globalObject, base, nullptr);
if (!cacheStatus)
return GiveUpOnCache;
@@ -854,7 +866,7 @@
} else if (structure->prototypeQueriesAreCacheable()) {
// FIXME: Teach this to do poly proto.
// https://bugs.webkit.org/show_bug.cgi?id=185663
- preparePrototypeChainForCaching(globalObject, value, wasFound ? prototype : nullptr);
+ prepareChainForCaching(globalObject, value, wasFound ? prototype : nullptr);
ObjectPropertyConditionSet conditionSet = generateConditionsForInstanceOf(
vm, codeBlock, globalObject, structure, prototype, wasFound);
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (253809 => 253810)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2019-12-20 03:32:37 UTC (rev 253810)
@@ -716,7 +716,7 @@
structure->flattenDictionaryStructure(vm, jsCast<JSObject*>(baseCell));
}
- preparePrototypeChainForCaching(globalObject, baseCell, slot);
+ prepareChainForCaching(globalObject, baseCell, slot);
ObjectPropertyConditionSet conditions;
if (slot.isUnset())
Modified: trunk/Source/_javascript_Core/runtime/StructureRareData.cpp (253809 => 253810)
--- trunk/Source/_javascript_Core/runtime/StructureRareData.cpp 2019-12-20 02:24:59 UTC (rev 253809)
+++ trunk/Source/_javascript_Core/runtime/StructureRareData.cpp 2019-12-20 03:32:37 UTC (rev 253810)
@@ -107,11 +107,11 @@
// This will not create a condition for the current structure but that is good because we know the Symbol.toStringTag
// is not on the ownStructure so we will transisition if one is added and this cache will no longer be used.
- preparePrototypeChainForCaching(globalObject, ownStructure, toStringTagSymbolSlot.slotBase());
+ prepareChainForCaching(globalObject, ownStructure, toStringTagSymbolSlot.slotBase());
conditionSet = generateConditionsForPrototypePropertyHit(vm, this, globalObject, ownStructure, toStringTagSymbolSlot.slotBase(), vm.propertyNames->toStringTagSymbol.impl());
ASSERT(!conditionSet.isValid() || conditionSet.hasOneSlotBaseCondition());
} else if (toStringTagSymbolSlot.isUnset()) {
- preparePrototypeChainForCaching(globalObject, ownStructure, nullptr);
+ prepareChainForCaching(globalObject, ownStructure, nullptr);
conditionSet = generateConditionsForPropertyMiss(vm, this, globalObject, ownStructure, vm.propertyNames->toStringTagSymbol.impl());
} else
return;