Title: [242626] trunk
- Revision
- 242626
- Author
- [email protected]
- Date
- 2019-03-07 17:53:35 -0800 (Thu, 07 Mar 2019)
Log Message
[JSC] StringFromCharCode fast path should accept 0xff in DFG and FTL
https://bugs.webkit.org/show_bug.cgi?id=195429
Reviewed by Saam Barati.
JSTests:
* stress/must-handled-values-should-not-be-used-as-proven-constants-in-cfa.js: Added.
(foo):
* stress/string-from-char-code-255.js: Added.
Source/_javascript_Core:
We can create single characters without allocation up to 0xff character code. But currently, DFGSpeculativeJIT and FTLLowerDFGToB3 go to the slow path
for 0xff case. On the other hand, DFG DoesGC phase says GC won't happen if the child is int32 constant and it is <= 0xff. So, if you have `String.fromCharCode(0xff)`,
this breaks the assumption in DFG DoesGC. The correct fix is changing the check in DFGSpeculativeJIT and FTLLowerDFGToB3 from AboveOrEqual to Above.
Note that ThunkGenerators's StringFromCharCode thunk was correct.
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileFromCharCode):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileStringFromCharCode):
Modified Paths
Added Paths
Diff
Modified: trunk/JSTests/ChangeLog (242625 => 242626)
--- trunk/JSTests/ChangeLog 2019-03-08 01:35:23 UTC (rev 242625)
+++ trunk/JSTests/ChangeLog 2019-03-08 01:53:35 UTC (rev 242626)
@@ -1,3 +1,14 @@
+2019-03-07 Yusuke Suzuki <[email protected]>
+
+ [JSC] StringFromCharCode fast path should accept 0xff in DFG and FTL
+ https://bugs.webkit.org/show_bug.cgi?id=195429
+
+ Reviewed by Saam Barati.
+
+ * stress/must-handled-values-should-not-be-used-as-proven-constants-in-cfa.js: Added.
+ (foo):
+ * stress/string-from-char-code-255.js: Added.
+
2019-03-06 Mark Lam <[email protected]>
Fix incorrect handling of try-finally completion values.
Added: trunk/JSTests/stress/must-handled-values-should-not-be-used-as-proven-constants-in-cfa.js (0 => 242626)
--- trunk/JSTests/stress/must-handled-values-should-not-be-used-as-proven-constants-in-cfa.js (rev 0)
+++ trunk/JSTests/stress/must-handled-values-should-not-be-used-as-proven-constants-in-cfa.js 2019-03-08 01:53:35 UTC (rev 242626)
@@ -0,0 +1,17 @@
+//@ runDefault("--forceEagerCompilation=1")
+
+function foo() {
+ let array = [];
+ for (let a = 0; a < 4; a++) {
+ array[a + 1] = 0;
+ }
+ gc();
+ array.length=0;
+ gc();
+ var bar = 0;
+ for (var i = 0; i < 1000; i++) {
+ bar[0] = String.fromCharCode(i)[0];
+ }
+}
+
+foo();
Added: trunk/JSTests/stress/string-from-char-code-255.js (0 => 242626)
--- trunk/JSTests/stress/string-from-char-code-255.js (rev 0)
+++ trunk/JSTests/stress/string-from-char-code-255.js 2019-03-08 01:53:35 UTC (rev 242626)
@@ -0,0 +1,4 @@
+for (var i = 0; i <= 1e6; ++i) {
+ if (String.fromCharCode(0xff) != '\u00ff')
+ throw new Error("out");
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (242625 => 242626)
--- trunk/Source/_javascript_Core/ChangeLog 2019-03-08 01:35:23 UTC (rev 242625)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-03-08 01:53:35 UTC (rev 242626)
@@ -1,3 +1,20 @@
+2019-03-07 Yusuke Suzuki <[email protected]>
+
+ [JSC] StringFromCharCode fast path should accept 0xff in DFG and FTL
+ https://bugs.webkit.org/show_bug.cgi?id=195429
+
+ Reviewed by Saam Barati.
+
+ We can create single characters without allocation up to 0xff character code. But currently, DFGSpeculativeJIT and FTLLowerDFGToB3 go to the slow path
+ for 0xff case. On the other hand, DFG DoesGC phase says GC won't happen if the child is int32 constant and it is <= 0xff. So, if you have `String.fromCharCode(0xff)`,
+ this breaks the assumption in DFG DoesGC. The correct fix is changing the check in DFGSpeculativeJIT and FTLLowerDFGToB3 from AboveOrEqual to Above.
+ Note that ThunkGenerators's StringFromCharCode thunk was correct.
+
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileFromCharCode):
+ * ftl/FTLLowerDFGToB3.cpp:
+ (JSC::FTL::DFG::LowerDFGToB3::compileStringFromCharCode):
+
2019-03-07 Mark Lam <[email protected]>
Follow up refactoring in try-finally code after r242591.
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (242625 => 242626)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2019-03-08 01:35:23 UTC (rev 242625)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2019-03-08 01:53:35 UTC (rev 242626)
@@ -2296,7 +2296,7 @@
GPRReg smallStringsReg = smallStrings.gpr();
JITCompiler::JumpList slowCases;
- slowCases.append(m_jit.branch32(MacroAssembler::AboveOrEqual, propertyReg, TrustedImm32(maxSingleCharacterString)));
+ slowCases.append(m_jit.branch32(MacroAssembler::Above, propertyReg, TrustedImm32(maxSingleCharacterString)));
m_jit.move(TrustedImmPtr(m_jit.vm()->smallStrings.singleCharacterStrings()), smallStringsReg);
m_jit.loadPtr(MacroAssembler::BaseIndex(smallStringsReg, propertyReg, MacroAssembler::ScalePtr, 0), scratchReg);
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp (242625 => 242626)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2019-03-08 01:35:23 UTC (rev 242625)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToB3.cpp 2019-03-08 01:53:35 UTC (rev 242626)
@@ -6811,7 +6811,7 @@
LBasicBlock continuation = m_out.newBlock();
m_out.branch(
- m_out.aboveOrEqual(value, m_out.constInt32(maxSingleCharacterString)),
+ m_out.above(value, m_out.constInt32(maxSingleCharacterString)),
rarely(slowCase), usually(smallIntCase));
LBasicBlock lastNext = m_out.appendTo(smallIntCase, slowCase);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes