12013-12-11 Filip Pizlo <fpizlo@apple.com>
2
3 Get rid of forward exit on UInt32ToNumber by adding an op_unsigned bytecode instruction
4 https://bugs.webkit.org/show_bug.cgi?id=125553
5
6 Reviewed by NOBODY (OOPS!).
7
8 UInt32ToNumber was a super complicated node because it had to do a speculation, but it
9 would do it after we already had computed the urshift. It couldn't just back to the
10 beginning of the urshift because the inputs to the urshift weren't necessarily live
11 anymore. We couldn't jump forward to the beginning of the next instruction because the
12 result of the urshift was not yet unsigned-converted.
13
14 For a while we solved this by forward-exiting in UInt32ToNumber. But that's really
15 gross and I want to get rid of all forward exits. They cause a lot of bugs.
16
17 We could also have turned UInt32ToNumber to a backwards exit by forcing the inputs to
18 the urshift to be live. I figure that this might be a bit too extreme.
19
20 So, I just created a new place that we can exit to: I split op_urshift into op_urshift
21 followed by op_unsigned. op_unsigned is an "unsigned cast" along the lines of what
22 UInt32ToNumber does. This allows me to get rid of all of the nastyness in the DFG for
23 forward exiting in UInt32ToNumber.
24
25 This patch enables massive code carnage in the DFG and FTL, and brings us closer to
26 eliminating one of the DFG's most confusing concepts. On the flipside, it does make the
27 bytecode slightly more complex (one new instruction). This is a profitable trade. We
28 want the DFG and FTL to trend towards simplicity, since they are both currently too
29 complicated.
30
31 * bytecode/BytecodeUseDef.h:
32 (JSC::computeUsesForBytecodeOffset):
33 (JSC::computeDefsForBytecodeOffset):
34 * bytecode/CodeBlock.cpp:
35 (JSC::CodeBlock::dumpBytecode):
36 * bytecode/Opcode.h:
37 (JSC::padOpcodeName):
38 * bytecode/ValueRecovery.cpp:
39 (JSC::ValueRecovery::dumpInContext):
40 * bytecode/ValueRecovery.h:
41 (JSC::ValueRecovery::gpr):
42 * bytecompiler/NodesCodegen.cpp:
43 (JSC::BinaryOpNode::emitBytecode):
44 (JSC::emitReadModifyAssignment):
45 * dfg/DFGByteCodeParser.cpp:
46 (JSC::DFG::ByteCodeParser::toInt32):
47 (JSC::DFG::ByteCodeParser::parseBlock):
48 * dfg/DFGClobberize.h:
49 (JSC::DFG::clobberize):
50 * dfg/DFGNodeType.h:
51 * dfg/DFGOSRExitCompiler32_64.cpp:
52 (JSC::DFG::OSRExitCompiler::compileExit):
53 * dfg/DFGOSRExitCompiler64.cpp:
54 (JSC::DFG::OSRExitCompiler::compileExit):
55 * dfg/DFGSpeculativeJIT.cpp:
56 (JSC::DFG::SpeculativeJIT::compileMovHint):
57 (JSC::DFG::SpeculativeJIT::compileUInt32ToNumber):
58 * dfg/DFGSpeculativeJIT.h:
59 * dfg/DFGSpeculativeJIT32_64.cpp:
60 * dfg/DFGSpeculativeJIT64.cpp:
61 * dfg/DFGStrengthReductionPhase.cpp:
62 (JSC::DFG::StrengthReductionPhase::handleNode):
63 (JSC::DFG::StrengthReductionPhase::convertToIdentityOverChild):
64 (JSC::DFG::StrengthReductionPhase::convertToIdentityOverChild1):
65 (JSC::DFG::StrengthReductionPhase::convertToIdentityOverChild2):
66 * ftl/FTLFormattedValue.h:
67 (JSC::FTL::int32Value):
68 * ftl/FTLLowerDFGToLLVM.cpp:
69 (JSC::FTL::LowerDFGToLLVM::compileUInt32ToNumber):
70 * ftl/FTLValueFormat.cpp:
71 (JSC::FTL::reboxAccordingToFormat):
72 (WTF::printInternal):
73 * ftl/FTLValueFormat.h:
74 * jit/JIT.cpp:
75 (JSC::JIT::privateCompileMainPass):
76 (JSC::JIT::privateCompileSlowCases):
77 * jit/JIT.h:
78 * jit/JITArithmetic.cpp:
79 (JSC::JIT::emit_op_urshift):
80 (JSC::JIT::emitSlow_op_urshift):
81 (JSC::JIT::emit_op_unsigned):
82 (JSC::JIT::emitSlow_op_unsigned):
83 * jit/JITArithmetic32_64.cpp:
84 (JSC::JIT::emitRightShift):
85 (JSC::JIT::emitRightShiftSlowCase):
86 (JSC::JIT::emit_op_unsigned):
87 (JSC::JIT::emitSlow_op_unsigned):
88 * llint/LowLevelInterpreter32_64.asm:
89 * llint/LowLevelInterpreter64.asm:
90 * runtime/CommonSlowPaths.cpp:
91 (JSC::SLOW_PATH_DECL):
92 * runtime/CommonSlowPaths.h:
93