Title: [253144] trunk
- Revision
- 253144
- Author
- [email protected]
- Date
- 2019-12-04 22:26:06 -0800 (Wed, 04 Dec 2019)
Log Message
[JSC] AI should convert IsCellWithType to constant when Structure set is finite
https://bugs.webkit.org/show_bug.cgi?id=204141
Reviewed by Mark Lam.
JSTests:
* stress/generator-cell-with-type.js: Added.
(shouldBe):
(shouldThrow):
(test):
(i.shouldThrow):
* stress/is-cell-with-type-should-check-non-cell-cases.js: Added.
(getter):
(foo):
Source/_javascript_Core:
We should fold IsCellWithType if Structure set is finite since we have a chance to know what JSType is.
The difference from the last patch is that we have `if (!(child.m_type & ~SpecCell))` check. Even if
structures meet the requirement, this structures do not guarantee that non cell types never come. We
should ensure it by using proven type.
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (253143 => 253144)
--- trunk/JSTests/ChangeLog 2019-12-05 06:19:20 UTC (rev 253143)
+++ trunk/JSTests/ChangeLog 2019-12-05 06:26:06 UTC (rev 253144)
@@ -1,3 +1,19 @@
+2019-12-04 Yusuke Suzuki <[email protected]>
+
+ [JSC] AI should convert IsCellWithType to constant when Structure set is finite
+ https://bugs.webkit.org/show_bug.cgi?id=204141
+
+ Reviewed by Mark Lam.
+
+ * stress/generator-cell-with-type.js: Added.
+ (shouldBe):
+ (shouldThrow):
+ (test):
+ (i.shouldThrow):
+ * stress/is-cell-with-type-should-check-non-cell-cases.js: Added.
+ (getter):
+ (foo):
+
2019-12-04 Mark Lam <[email protected]>
Fix missing exception check in ArrayPrototype's fastJoin().
Added: trunk/JSTests/stress/generator-cell-with-type.js (0 => 253144)
--- trunk/JSTests/stress/generator-cell-with-type.js (rev 0)
+++ trunk/JSTests/stress/generator-cell-with-type.js 2019-12-05 06:26:06 UTC (rev 253144)
@@ -0,0 +1,45 @@
+// This test takes too long on arm and mips devices.
+//@ skip if ["arm", "mips"].include?($architecture)
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+function shouldThrow(func, errorMessage) {
+ var errorThrown = false;
+ var error = null;
+ try {
+ func();
+ } catch (e) {
+ errorThrown = true;
+ error = e;
+ }
+ if (!errorThrown)
+ throw new Error('not thrown');
+ if (String(error) !== errorMessage)
+ throw new Error(`bad error: ${String(error)}`);
+}
+
+function *generator()
+{
+}
+
+function test(gen)
+{
+ var func = gen.next;
+ shouldBe(gen.next().done, true);
+ return func;
+}
+noInline(test);
+var gen = generator();
+for (var i = 0; i < 1e6; ++i)
+ test(gen);
+
+for (var i = 0; i < 1e6; ++i) {
+ test(gen);
+ shouldThrow(() => {
+ test({
+ __proto__: gen.__proto__
+ });
+ }, `TypeError: |this| should be a generator`);
+}
Added: trunk/JSTests/stress/is-cell-with-type-should-check-non-cell-cases.js (0 => 253144)
--- trunk/JSTests/stress/is-cell-with-type-should-check-non-cell-cases.js (rev 0)
+++ trunk/JSTests/stress/is-cell-with-type-should-check-non-cell-cases.js 2019-12-05 06:26:06 UTC (rev 253144)
@@ -0,0 +1,13 @@
+function getter() {
+ if (+undefined) {
+ return '';
+ }
+}
+
+function foo() {}
+
+Object.defineProperty(foo, 'name', {get: getter});
+
+for (let i=0; i<10000; i++) {
+ foo.bind(null, foo, null);
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (253143 => 253144)
--- trunk/Source/_javascript_Core/ChangeLog 2019-12-05 06:19:20 UTC (rev 253143)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-12-05 06:26:06 UTC (rev 253144)
@@ -1,5 +1,20 @@
2019-12-04 Yusuke Suzuki <[email protected]>
+ [JSC] AI should convert IsCellWithType to constant when Structure set is finite
+ https://bugs.webkit.org/show_bug.cgi?id=204141
+
+ Reviewed by Mark Lam.
+
+ We should fold IsCellWithType if Structure set is finite since we have a chance to know what JSType is.
+ The difference from the last patch is that we have `if (!(child.m_type & ~SpecCell))` check. Even if
+ structures meet the requirement, this structures do not guarantee that non cell types never come. We
+ should ensure it by using proven type.
+
+ * dfg/DFGAbstractInterpreterInlines.h:
+ (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
+
+2019-12-04 Yusuke Suzuki <[email protected]>
+
[JSC] Put TypedArrays in IsoSubspace
https://bugs.webkit.org/show_bug.cgi?id=204867
Modified: trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h (253143 => 253144)
--- trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h 2019-12-05 06:19:20 UTC (rev 253143)
+++ trunk/Source/_javascript_Core/dfg/DFGAbstractInterpreterInlines.h 2019-12-05 06:26:06 UTC (rev 253144)
@@ -1444,6 +1444,37 @@
if (constantWasSet)
break;
}
+
+ if (!(child.m_type & ~SpecCell)) {
+ if (child.m_structure.isFinite()) {
+ bool constantWasSet = false;
+ switch (node->op()) {
+ case IsCellWithType: {
+ bool ok = true;
+ Optional<bool> result;
+ child.m_structure.forEach(
+ [&](RegisteredStructure structure) {
+ bool matched = structure->typeInfo().type() == node->queriedType();
+ if (!result)
+ result = matched;
+ else {
+ if (result.value() != matched)
+ ok = false;
+ }
+ });
+ if (ok && result) {
+ setConstant(node, jsBoolean(result.value()));
+ constantWasSet = true;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if (constantWasSet)
+ break;
+ }
+ }
// FIXME: This code should really use AbstractValue::isType() and
// AbstractValue::couldBeType().
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes