Diff
Modified: trunk/LayoutTests/ChangeLog (153240 => 153241)
--- trunk/LayoutTests/ChangeLog 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/LayoutTests/ChangeLog 2013-07-25 04:03:33 UTC (rev 153241)
@@ -1,5 +1,19 @@
2013-06-21 Filip Pizlo <[email protected]>
+ fourthTier: DFG should't exit just because it GetByVal'd a big character
+ https://bugs.webkit.org/show_bug.cgi?id=117899
+
+ Reviewed by Mark Hahnenberg.
+
+ This benchmark speeds up by 3x.
+
+ * fast/js/regress/script-tests/string-get-by-val-big-char.js: Added.
+ (foo):
+ * fast/js/regress/string-get-by-val-big-char-expected.txt: Added.
+ * fast/js/regress/string-get-by-val-big-char.html: Added.
+
+2013-06-21 Filip Pizlo <[email protected]>
+
fourthTier: Small strings shouldn't get GC'd
https://bugs.webkit.org/show_bug.cgi?id=117897
Added: trunk/LayoutTests/fast/js/regress/script-tests/string-get-by-val-big-char.js (0 => 153241)
--- trunk/LayoutTests/fast/js/regress/script-tests/string-get-by-val-big-char.js (rev 0)
+++ trunk/LayoutTests/fast/js/regress/script-tests/string-get-by-val-big-char.js 2013-07-25 04:03:33 UTC (rev 153241)
@@ -0,0 +1,22 @@
+function foo(string) {
+ var result1, result2;
+ var m_z = 1;
+ var m_w = 2;
+ for (var i = 0; i < 100000; ++i) {
+ result1 = string[0]; // This will be slow, but we're testing if we stay in the DFG.
+ for (var j = 0; j < 10; ++j) {
+ m_z = (36969 * (m_z & 65535) + (m_z >> 16)) | 0;
+ m_w = (18000 * (m_w & 65535) + (m_w >> 16)) | 0;
+ result2 = ((m_z << 16) + m_w) | 0;
+ }
+ }
+ return [result1, result2];
+}
+
+var lBar = String.fromCharCode(322);
+
+var result = foo(lBar);
+if (result[0] != lBar)
+ throw "Bad result1: " + result[0];
+if (result[1] != 561434430)
+ throw "Bad result2: " + result[1];
Added: trunk/LayoutTests/fast/js/regress/string-get-by-val-big-char-expected.txt (0 => 153241)
--- trunk/LayoutTests/fast/js/regress/string-get-by-val-big-char-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/js/regress/string-get-by-val-big-char-expected.txt 2013-07-25 04:03:33 UTC (rev 153241)
@@ -0,0 +1,10 @@
+JSRegress/string-get-by-val-big-char
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/js/regress/string-get-by-val-big-char.html (0 => 153241)
--- trunk/LayoutTests/fast/js/regress/string-get-by-val-big-char.html (rev 0)
+++ trunk/LayoutTests/fast/js/regress/string-get-by-val-big-char.html 2013-07-25 04:03:33 UTC (rev 153241)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+</body>
+</html>
Modified: trunk/Source/_javascript_Core/ChangeLog (153240 => 153241)
--- trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-07-25 04:03:33 UTC (rev 153241)
@@ -1,5 +1,27 @@
2013-06-21 Filip Pizlo <[email protected]>
+ fourthTier: DFG should't exit just because it GetByVal'd a big character
+ https://bugs.webkit.org/show_bug.cgi?id=117899
+
+ Reviewed by Mark Hahnenberg.
+
+ Add a slow path. Also clarify handling of GetByVal in PutStructure elimination.
+ Previously it would fail due to canExit() but now we can also fail because
+ GetByVal(String) can allocate. Just make it so GetByVal is totally poisoned, in
+ a very explicit way.
+
+ * dfg/DFGCSEPhase.cpp:
+ (JSC::DFG::CSEPhase::putStructureStoreElimination):
+ * dfg/DFGOperations.cpp:
+ * dfg/DFGOperations.h:
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileGetByValOnString):
+ * dfg/DFGSpeculativeJIT.h:
+ (JSC::DFG::SpeculativeJIT::callOperation):
+ (SpeculativeJIT):
+
+2013-06-21 Filip Pizlo <[email protected]>
+
fourthTier: Small strings shouldn't get GC'd
https://bugs.webkit.org/show_bug.cgi?id=117897
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (153240 => 153241)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2013-07-25 04:03:33 UTC (rev 153241)
@@ -2976,8 +2976,6 @@
86EC9DB31328DF44002B2AD7 /* dfg */ = {
isa = PBXGroup;
children = (
- A73A53581799CD5D00170C19 /* DFGLazyJSValue.cpp */,
- A73A53591799CD5D00170C19 /* DFGLazyJSValue.h */,
0F62016D143FCD2F0068B77C /* DFGAbstractState.cpp */,
0F62016E143FCD2F0068B77C /* DFGAbstractState.h */,
0F55C19317276E4600CEABFD /* DFGAbstractValue.cpp */,
@@ -3053,6 +3051,8 @@
86EC9DBC1328DF82002B2AD7 /* DFGJITCompiler.h */,
A78A9770179738B8009DF744 /* DFGJITFinalizer.cpp */,
A78A9771179738B8009DF744 /* DFGJITFinalizer.h */,
+ A73A53581799CD5D00170C19 /* DFGLazyJSValue.cpp */,
+ A73A53591799CD5D00170C19 /* DFGLazyJSValue.h */,
0FB4B51C16B62772003F696B /* DFGLongLivedState.cpp */,
0FB4B51D16B62772003F696B /* DFGLongLivedState.h */,
0F2BDC3D1522801700CD8910 /* DFGMinifiedGraph.h */,
@@ -3322,6 +3322,7 @@
0FFB921F16D033050055A5DB /* (null) in Headers */,
860161E30F3A83C100F84710 /* AbstractMacroAssembler.h in Headers */,
0F55F0F514D1063C00AC7649 /* AbstractPC.h in Headers */,
+ 2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */,
BC18C3E50E16F5CD00B34460 /* APICast.h in Headers */,
865F408810E7D56300947361 /* APIShims.h in Headers */,
BCF605140E203EF800B9A64D /* ArgList.h in Headers */,
@@ -3442,6 +3443,7 @@
0FEA0A34170D40BF00BB722C /* DFGJITCode.h in Headers */,
86EC9DCC1328DF82002B2AD7 /* DFGJITCompiler.h in Headers */,
A78A9779179738B8009DF744 /* DFGJITFinalizer.h in Headers */,
+ A73A535B1799CD5D00170C19 /* DFGLazyJSValue.h in Headers */,
0FF0F19B16B729FA005DF95B /* DFGLongLivedState.h in Headers */,
0F2BDC451522801B00CD8910 /* DFGMinifiedGraph.h in Headers */,
0F2E892D16D02BAF009E4FD2 /* DFGMinifiedID.h in Headers */,
@@ -3720,7 +3722,6 @@
14CA958D16AB50FA00938A06 /* ObjectAllocationProfile.h in Headers */,
BC18C4450E16F5CD00B34460 /* ObjectConstructor.h in Headers */,
BC18C4460E16F5CD00B34460 /* ObjectPrototype.h in Headers */,
- A73A535B1799CD5D00170C19 /* DFGLazyJSValue.h in Headers */,
E124A8F70E555775003091F1 /* OpaqueJSString.h in Headers */,
969A079B0ED1D3AE00F1F681 /* Opcode.h in Headers */,
0F2BDC2C151FDE9100CD8910 /* Operands.h in Headers */,
@@ -3811,7 +3812,6 @@
0FD2C92416D01EE900C7803F /* StructureInlines.h in Headers */,
C2FE18A416BAEC4000AF3061 /* StructureRareData.h in Headers */,
C20BA92D16BB1C1500B3AEA2 /* StructureRareDataInlines.h in Headers */,
- 2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */,
0F9332A514CA7DDD0085F3C6 /* StructureSet.h in Headers */,
0F766D3915AE4A1F008F363E /* StructureStubClearingWatchpoint.h in Headers */,
BCCF0D080EF0AAB900413C8F /* StructureStubInfo.h in Headers */,
@@ -4278,6 +4278,7 @@
0FEA0A33170D40BF00BB722C /* DFGJITCode.cpp in Sources */,
86EC9DCB1328DF82002B2AD7 /* DFGJITCompiler.cpp in Sources */,
A78A9778179738B8009DF744 /* DFGJITFinalizer.cpp in Sources */,
+ A73A535A1799CD5D00170C19 /* DFGLazyJSValue.cpp in Sources */,
0FF0F19916B729F6005DF95B /* DFGLongLivedState.cpp in Sources */,
0F2BDC4D1522818600CD8910 /* DFGMinifiedNode.cpp in Sources */,
0FF0F19C16B72A03005DF95B /* DFGNode.cpp in Sources */,
@@ -4290,7 +4291,6 @@
0FC09776146943B000CF2442 /* DFGOSRExitCompiler32_64.cpp in Sources */,
0FC0977214693AF900CF2442 /* DFGOSRExitCompiler64.cpp in Sources */,
0F7025A91714B0FA00382C0E /* DFGOSRExitCompilerCommon.cpp in Sources */,
- A73A535A1799CD5D00170C19 /* DFGLazyJSValue.cpp in Sources */,
0FEFC9AA1681A3B300567F53 /* DFGOSRExitJumpPlaceholder.cpp in Sources */,
0F235BED17178E7300690C7F /* DFGOSRExitPreparation.cpp in Sources */,
0FFFC95B14EF90AD00C72532 /* DFGPhase.cpp in Sources */,
Modified: trunk/Source/_javascript_Core/dfg/DFGCSEPhase.cpp (153240 => 153241)
--- trunk/Source/_javascript_Core/dfg/DFGCSEPhase.cpp 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/dfg/DFGCSEPhase.cpp 2013-07-25 04:03:33 UTC (rev 153241)
@@ -593,6 +593,12 @@
case MakeRope:
return 0;
+ // This either exits, causes a GC (lazy string allocation), or clobbers
+ // the world. The chances of it not doing any of those things are so
+ // slim that we might as well not even try to reason about it.
+ case GetByVal:
+ return 0;
+
case GetIndexedPropertyStorage:
if (node->arrayMode().getIndexedPropertyStorageMayTriggerGC())
return 0;
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.cpp (153240 => 153241)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.cpp 2013-07-25 04:03:33 UTC (rev 153241)
@@ -1572,6 +1572,14 @@
return string->value(exec).impl();
}
+JSString* DFG_OPERATION operationSingleCharacterString(ExecState* exec, int32_t character)
+{
+ VM& vm = exec->vm();
+ NativeCallFrameTracer tracer(&vm, exec);
+
+ return jsSingleCharacterString(exec, static_cast<UChar>(character));
+}
+
JSCell* DFG_OPERATION operationNewStringObject(ExecState* exec, JSString* string, Structure* structure)
{
VM& vm = exec->vm();
Modified: trunk/Source/_javascript_Core/dfg/DFGOperations.h (153240 => 153241)
--- trunk/Source/_javascript_Core/dfg/DFGOperations.h 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/dfg/DFGOperations.h 2013-07-25 04:03:33 UTC (rev 153241)
@@ -124,6 +124,7 @@
typedef char* DFG_OPERATION (*P_DFGOperation_EStSS)(ExecState*, Structure*, size_t, size_t);
typedef char* DFG_OPERATION (*P_DFGOperation_EStZ)(ExecState*, Structure*, int32_t);
typedef StringImpl* DFG_OPERATION (*I_DFGOperation_EJss)(ExecState*, JSString*);
+typedef JSString* DFG_OPERATION (*Jss_DFGOperation_EZ)(ExecState*, int32_t);
JSCell* DFG_OPERATION operationStringFromCharCode(ExecState*, int32_t) WTF_INTERNAL;
// These routines are provide callbacks out to C++ implementations of operations too complex to JIT.
@@ -219,6 +220,8 @@
char* DFG_OPERATION operationRageEnsureContiguous(ExecState*, JSCell*);
char* DFG_OPERATION operationEnsureArrayStorage(ExecState*, JSCell*);
StringImpl* DFG_OPERATION operationResolveRope(ExecState*, JSString*);
+JSString* DFG_OPERATION operationSingleCharacterString(ExecState*, int32_t);
+
JSCell* DFG_OPERATION operationNewStringObject(ExecState*, JSString*, Structure*);
JSCell* DFG_OPERATION operationToStringOnCell(ExecState*, JSCell*);
JSCell* DFG_OPERATION operationToString(ExecState*, EncodedJSValue);
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (153240 => 153241)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2013-07-25 04:03:33 UTC (rev 153241)
@@ -2095,8 +2095,8 @@
m_jit.load16(MacroAssembler::BaseIndex(storageReg, propertyReg, MacroAssembler::TimesTwo, 0), scratchReg);
- // We only support ascii characters
- speculationCheck(Uncountable, JSValueRegs(), 0, m_jit.branch32(MacroAssembler::AboveOrEqual, scratchReg, TrustedImm32(0x100)));
+ JITCompiler::Jump bigCharacter =
+ m_jit.branch32(MacroAssembler::AboveOrEqual, scratchReg, TrustedImm32(0x100));
// 8 bit string values don't need the isASCII check.
cont8Bit.link(&m_jit);
@@ -2105,6 +2105,11 @@
GPRReg smallStringsReg = smallStrings.gpr();
m_jit.move(MacroAssembler::TrustedImmPtr(m_jit.vm()->smallStrings.singleCharacterStrings()), smallStringsReg);
m_jit.loadPtr(MacroAssembler::BaseIndex(smallStringsReg, scratchReg, MacroAssembler::ScalePtr, 0), scratchReg);
+
+ addSlowPathGenerator(
+ slowPathCall(
+ bigCharacter, this, operationSingleCharacterString, scratchReg, scratchReg));
+
cellResult(scratchReg, m_currentNode);
}
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (153240 => 153241)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2013-07-25 04:03:30 UTC (rev 153240)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2013-07-25 04:03:33 UTC (rev 153241)
@@ -1033,6 +1033,12 @@
return appendCallWithExceptionCheckSetResult(operation, result);
}
+ JITCompiler::Call callOperation(Jss_DFGOperation_EZ operation, GPRReg result, GPRReg arg1)
+ {
+ m_jit.setupArgumentsWithExecState(arg1);
+ return appendCallWithExceptionCheckSetResult(operation, result);
+ }
+
JITCompiler::Call callOperation(V_DFGOperation_EC operation, GPRReg arg1)
{
m_jit.setupArgumentsWithExecState(arg1);