-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 265870.440@safari-7616-branch (965be68). https://bugs.web…
…kit.org/show_bug.cgi?id=260678 [JSC] DFG AI GetById adhoc folding should insert watchpoints for structures https://bugs.webkit.org/show_bug.cgi?id=260678 rdar://114072069 Reviewed by Keith Miller. For DFG AI GetById's variants, they are tuples of StructureSet and offset. So, we should not obtain constant property just with offset since we first need to ensure that the base object is having a structure in StructureSet. Let's say [S0, 0] [S1, 1] variants are produced. In that case, we should not load a value from offset 1 when object is S0. But previously we were doing that since only thing we checked is that base is S0 or S1. This patch just extends DFG AI GetById handling to use existing tryGetConstantProperty mechanism with StructureSet. This properly inserts replacement watchpoints too, so that we can guarantee that the loaded value is inferred constant (if it gets different, then watchpoint fires). And we correctly check that the current object's structure is meeting the requirement against *variant*'s structure set. * JSTests/stress/same-offset-different-property-name-multiple-get-by-variants.js: Added. (main.const.object1): (main.const.object2): (main.const.object3): (main.get opt): (main): * Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * Source/JavaScriptCore/dfg/DFGGraph.cpp: (JSC::DFG::Graph::inferredValueForProperty): * Source/JavaScriptCore/dfg/DFGGraph.h: Canonical link: https://commits.webkit.org/265870.440@safari-7616-branch
- Loading branch information
1 parent
9ef1b0b
commit bf680fe
Showing
4 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
JSTests/stress/same-offset-different-property-name-multiple-get-by-variants.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
function opt(wrapper, object, call, get) { | ||
// CheckStructure | ||
object.prototype.p1; | ||
object.prototype.p2; | ||
|
||
if (call) { | ||
// CheckIsConstant | ||
wrapper instanceof object; | ||
|
||
if (get) { | ||
// GetById | ||
return object.prototype.p1.value; | ||
} | ||
} | ||
} | ||
|
||
function main() { | ||
const object1 = function () {}; | ||
const object2 = function () {}; | ||
const object3 = function () {}; | ||
const object4 = {value: 1}; | ||
|
||
const wrapper1 = new object1(); | ||
const wrapper2 = new object2(); | ||
|
||
// S1 | ||
object1.prototype.p1 = object4; | ||
object1.prototype.p2 = object4; | ||
|
||
// S1 -> S2 | ||
object2.prototype.p1 = 1; | ||
object2.prototype.p2 = 1; | ||
|
||
delete object2.prototype.p2; | ||
delete object2.prototype.p1; | ||
|
||
object2.prototype.p2 = 2; | ||
object2.prototype.p1 = 2; | ||
|
||
Reflect.defineProperty(object3.prototype, 'p1', { | ||
get() { | ||
return object4; | ||
} | ||
}); | ||
|
||
// Just to force the compiler to emit the GetById node. Otherwise, it'll optimize it into a GetByOffset node. | ||
opt(wrapper1, object3, /* call */ true, /* get */ true); | ||
|
||
for (let i = 0; i < 1000000; i++) { | ||
opt(wrapper1, object1, /* call */ true, /* get */ false); | ||
opt(wrapper1, object2, /* call */ false, /* get */ false); | ||
} | ||
|
||
// S1 -> S2 | ||
delete object1.prototype.p2; | ||
delete object1.prototype.p1; | ||
|
||
object1.prototype.p2 = 1; | ||
object1.prototype.p1 = 0x1234; | ||
|
||
String(opt(wrapper1, object1, /* call */ true, /* get */ true)); | ||
} | ||
|
||
main(); | ||
|
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