Skip to content

Commit 8b73308

Browse files
NewArray in FTLLowerDFGToB3 does not handle speculating on doubles when having a bad time
https://bugs.webkit.org/show_bug.cgi?id=174188 <rdar://problem/30581423> Reviewed by Mark Lam. JSTests: * stress/new-array-having-a-bad-time-double.js: Added. (assert): (foo): Source/JavaScriptCore: We were calling lowJSValue(edge) when we were speculating the edge as double. This isn't allowed. We should have been using lowDouble. This patch also adds a new option, called useArrayAllocationProfiling, which defaults to true. When false, it will make the array allocation profile not actually sample seen arrays. It'll force the allocation profile's predicted indexing type to be ArrayWithUndecided. Adding this option made it trivial to write a test for this bug. * bytecode/ArrayAllocationProfile.cpp: (JSC::ArrayAllocationProfile::updateIndexingType): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewArray): * runtime/Options.h: Tools: * Scripts/run-jsc-stress-tests: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@219187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 735de9a commit 8b73308

File tree

8 files changed

+86
-6
lines changed

8 files changed

+86
-6
lines changed

JSTests/ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2017-07-05 Saam Barati <[email protected]>
2+
3+
NewArray in FTLLowerDFGToB3 does not handle speculating on doubles when having a bad time
4+
https://bugs.webkit.org/show_bug.cgi?id=174188
5+
<rdar://problem/30581423>
6+
7+
Reviewed by Mark Lam.
8+
9+
* stress/new-array-having-a-bad-time-double.js: Added.
10+
(assert):
11+
(foo):
12+
113
2017-07-05 Yusuke Suzuki <[email protected]>
214

315
WTF::StringImpl::copyChars segfaults when built with GCC 7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function assert(b) {
2+
if (!b)
3+
throw new Error("Bad");
4+
}
5+
6+
function foo(a, b, c) {
7+
let x = a + b + c;
8+
return [a, b, c, x];
9+
}
10+
noInline(foo);
11+
12+
Object.defineProperty(Object.prototype, "10000", {get() { return 20; }});
13+
14+
for (let i = 0; i < 10000; ++i) {
15+
let a = 10.5;
16+
let b = 1.1;
17+
let c = 1.2;
18+
let x = a + b + c;
19+
let result = foo(a, b, c);
20+
assert(result.length === 4);
21+
assert(result[0] === a);
22+
assert(result[1] === b);
23+
assert(result[2] === c);
24+
assert(result[3] === x);
25+
}

Source/JavaScriptCore/ChangeLog

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2017-07-05 Saam Barati <[email protected]>
2+
3+
NewArray in FTLLowerDFGToB3 does not handle speculating on doubles when having a bad time
4+
https://bugs.webkit.org/show_bug.cgi?id=174188
5+
<rdar://problem/30581423>
6+
7+
Reviewed by Mark Lam.
8+
9+
We were calling lowJSValue(edge) when we were speculating the
10+
edge as double. This isn't allowed. We should have been using
11+
lowDouble.
12+
13+
This patch also adds a new option, called useArrayAllocationProfiling,
14+
which defaults to true. When false, it will make the array allocation
15+
profile not actually sample seen arrays. It'll force the allocation
16+
profile's predicted indexing type to be ArrayWithUndecided. Adding
17+
this option made it trivial to write a test for this bug.
18+
19+
* bytecode/ArrayAllocationProfile.cpp:
20+
(JSC::ArrayAllocationProfile::updateIndexingType):
21+
* ftl/FTLLowerDFGToB3.cpp:
22+
(JSC::FTL::DFG::LowerDFGToB3::compileNewArray):
23+
* runtime/Options.h:
24+
125
2017-07-05 Yusuke Suzuki <[email protected]>
226

327
WTF::Thread should have the threads stack bounds.

Source/JavaScriptCore/bytecode/ArrayAllocationProfile.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ void ArrayAllocationProfile::updateIndexingType()
4949
JSArray* lastArray = m_lastArray;
5050
if (!lastArray)
5151
return;
52-
m_currentIndexingType = leastUpperBoundOfIndexingTypes(m_currentIndexingType, lastArray->indexingType());
52+
if (LIKELY(Options::useArrayAllocationProfiling()))
53+
m_currentIndexingType = leastUpperBoundOfIndexingTypes(m_currentIndexingType, lastArray->indexingType());
5354
m_lastArray = 0;
5455
}
5556

Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -4648,9 +4648,16 @@ class LowerDFGToB3 {
46484648

46494649
for (unsigned operandIndex = 0; operandIndex < m_node->numChildren(); ++operandIndex) {
46504650
Edge edge = m_graph.varArgChild(m_node, operandIndex);
4651-
m_out.store64(
4652-
lowJSValue(edge, ManualOperandSpeculation),
4653-
m_out.absolute(buffer + operandIndex));
4651+
LValue valueToStore;
4652+
switch (m_node->indexingType()) {
4653+
case ALL_DOUBLE_INDEXING_TYPES:
4654+
valueToStore = boxDouble(lowDouble(edge));
4655+
break;
4656+
default:
4657+
valueToStore = lowJSValue(edge, ManualOperandSpeculation);
4658+
break;
4659+
}
4660+
m_out.store64(valueToStore, m_out.absolute(buffer + operandIndex));
46544661
}
46554662

46564663
m_out.storePtr(

Source/JavaScriptCore/runtime/Options.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ typedef const char* optionString;
464464
v(bool, useWebAssemblyFastTLS, true, Normal, "If true, we will try to use fast thread-local storage if available on the current platform.") \
465465
v(bool, useFastTLSForWasmContext, true, Normal, "If true (and fast TLS is enabled), we will store context in fast TLS. If false, we will pin it to a register.") \
466466
v(bool, useCallICsForWebAssemblyToJSCalls, true, Normal, "If true, we will use CallLinkInfo to inline cache Wasm to JS calls.") \
467-
v(bool, useObjectRestSpread, true, Normal, "If true, we will enable Object Rest/Spread feature.")
467+
v(bool, useObjectRestSpread, true, Normal, "If true, we will enable Object Rest/Spread feature.") \
468+
v(bool, useArrayAllocationProfiling, true, Normal, "If true, we will use our normal array allocation profiling. If false, the allocation profile will always claim to be undecided.")
468469

469470

470471
enum OptionEquivalence {

Tools/ChangeLog

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2017-07-05 Saam Barati <[email protected]>
2+
3+
NewArray in FTLLowerDFGToB3 does not handle speculating on doubles when having a bad time
4+
https://bugs.webkit.org/show_bug.cgi?id=174188
5+
<rdar://problem/30581423>
6+
7+
Reviewed by Mark Lam.
8+
9+
* Scripts/run-jsc-stress-tests:
10+
111
2017-07-05 Yusuke Suzuki <[email protected]>
212

313
[WTF] Clean up StringStatics.cpp by using LazyNeverDestroyed<> for Atoms

Tools/Scripts/run-jsc-stress-tests

+1-1
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def runFTLNoCJIT(*optionalTestSpecificOptions)
859859
end
860860

861861
def runFTLNoCJITB3O1(*optionalTestSpecificOptions)
862-
run("ftl-no-cjit-b3o1", *(FTL_OPTIONS + NO_CJIT_OPTIONS + B3O1_OPTIONS + optionalTestSpecificOptions))
862+
run("ftl-no-cjit-b3o1", "--useArrayAllocationProfiling=false", *(FTL_OPTIONS + NO_CJIT_OPTIONS + B3O1_OPTIONS + optionalTestSpecificOptions))
863863
end
864864

865865
def runFTLNoCJITValidate(*optionalTestSpecificOptions)

0 commit comments

Comments
 (0)