12019-01-17 Mark Lam <mark.lam@apple.com>
2
3 Audit bytecode fields and ensure that LLInt instructions for accessing them are appropriate.
4 https://bugs.webkit.org/show_bug.cgi?id=193557
5 <rdar://problem/47369125>
6
7 Reviewed by NOBODY (OOPS!).
8
9 1. Rename some bytecode fields so that it's easier to discern whether the LLInt
10 is accessing them the right way:
11 - distinguish between targetVirtualRegister and targetLabel.
12 - name all StructureID fields as structureID (oldStructureID, newStructureID)
13 instead of structure (oldStructure, newStructure).
14
15 2. Use bitwise_cast in struct Fits when sizeof(T) == size.
16 This prevents potential undefined behavior issues arising from doing
17 assignments with reinterpret_cast'ed pointers.
18
19 3. Make Special::Pointer an unsigned type (previously int).
20 Make ResolveType an unsigned type (previously int).
21
22 4. In LowLevelInterpreter*.asm:
23
24 - rename the op macro argument to opcodeName or opcodeStruct respectively.
25 This makes it clearer which argument type the macro is working with.
26
27 - rename the name macro argument to opcodeName.
28
29 - fix operator types to match the field type being accessed. The following
30 may have resulted in bugs before:
31
32 1. The following should be read with getu() instead of get() because they
33 are unsigned ints:
34 OpSwitchImm::m_tableIndex
35 OpSwitchChar::m_tableIndex
36 OpGetFromArguments::m_index
37 OpPutToArguments::m_index
38 OpGetRestLength::m_numParametersToSkip
39
40 OpJneqPtr::m_specialPointer should also be read with getu() though this
41 wasn't a bug because it was previously an int by default, and is only
42 changed to an unsigned int in this patch.
43
44 2.The following should be read with loadi (not loadp) because they are of
45 unsigned type (not a pointer):
46 OpResolveScope::Metadata::m_resolveType
47 CodeBlock::m_numParameters (see prepareForTailCall)
48
49 3. OpPutToScope::Metadata::m_operand should be read with loadp (not loadis)
50 because it is a uintptr_t.
51
52 4. The following should be read with loadi (not loadis) because they are
53 unsigned ints:
54 OpNegate::Metadata::m_arithProfile + ArithProfile::m_bits
55 OpPutById::Metadata::m_oldStructureID
56 OpPutToScope::Metadata::m_getPutInfo + GetPutInfo::m_operand
57
58 These may not have manifested in bugs because the operations that follow
59 the load are 32-bit instructions which ignore the high word.
60
61 5. Give class GetPutInfo a default constructor so that we can use bitwise_cast
62 on it. Also befriend LLIntOffsetsExtractor so that we can take the offset of
63 m_operand in it.
64
65 * bytecode/ArithProfile.h:
66 * bytecode/BytecodeList.rb:
67 * bytecode/BytecodeUseDef.h:
68 (JSC::computeUsesForBytecodeOffset):
69 (JSC::computeDefsForBytecodeOffset):
70 * bytecode/CodeBlock.cpp:
71 (JSC::CodeBlock::propagateTransitions):
72 (JSC::CodeBlock::finalizeLLIntInlineCaches):
73 * bytecode/Fits.h:
74 * bytecode/GetByIdMetadata.h:
75 * bytecode/GetByIdStatus.cpp:
76 (JSC::GetByIdStatus::computeFromLLInt):
77 * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp:
78 (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::clearLLIntGetByIdCache):
79 * bytecode/PreciseJumpTargetsInlines.h:
80 (JSC::jumpTargetForInstruction):
81 (JSC::updateStoredJumpTargetsForInstruction):
82 * bytecode/PutByIdStatus.cpp:
83 (JSC::PutByIdStatus::computeFromLLInt):
84 * bytecode/SpecialPointer.h:
85 * bytecompiler/BytecodeGenerator.cpp:
86 (JSC::Label::setLocation):
87 * dfg/DFGByteCodeParser.cpp:
88 (JSC::DFG::ByteCodeParser::parseBlock):
89 * jit/JITArithmetic.cpp:
90 (JSC::JIT::emit_compareAndJump):
91 (JSC::JIT::emit_compareUnsignedAndJump):
92 (JSC::JIT::emit_compareAndJumpSlow):
93 * jit/JITArithmetic32_64.cpp:
94 (JSC::JIT::emit_compareAndJump):
95 (JSC::JIT::emit_compareUnsignedAndJump):
96 (JSC::JIT::emit_compareAndJumpSlow):
97 (JSC::JIT::emitBinaryDoubleOp):
98 * jit/JITOpcodes.cpp:
99 (JSC::JIT::emit_op_jmp):
100 (JSC::JIT::emit_op_jfalse):
101 (JSC::JIT::emit_op_jeq_null):
102 (JSC::JIT::emit_op_jneq_null):
103 (JSC::JIT::emit_op_jneq_ptr):
104 (JSC::JIT::emit_op_jeq):
105 (JSC::JIT::emit_op_jtrue):
106 (JSC::JIT::emit_op_jneq):
107 (JSC::JIT::compileOpStrictEqJump):
108 (JSC::JIT::emitSlow_op_jstricteq):
109 (JSC::JIT::emitSlow_op_jnstricteq):
110 (JSC::JIT::emit_op_check_tdz):
111 (JSC::JIT::emitSlow_op_jeq):
112 (JSC::JIT::emitSlow_op_jneq):
113 (JSC::JIT::emit_op_profile_type):
114 * jit/JITOpcodes32_64.cpp:
115 (JSC::JIT::emit_op_jmp):
116 (JSC::JIT::emit_op_jfalse):
117 (JSC::JIT::emit_op_jtrue):
118 (JSC::JIT::emit_op_jeq_null):
119 (JSC::JIT::emit_op_jneq_null):
120 (JSC::JIT::emit_op_jneq_ptr):
121 (JSC::JIT::emit_op_jeq):
122 (JSC::JIT::emitSlow_op_jeq):
123 (JSC::JIT::emit_op_jneq):
124 (JSC::JIT::emitSlow_op_jneq):
125 (JSC::JIT::compileOpStrictEqJump):
126 (JSC::JIT::emitSlow_op_jstricteq):
127 (JSC::JIT::emitSlow_op_jnstricteq):
128 (JSC::JIT::emit_op_check_tdz):
129 (JSC::JIT::emit_op_profile_type):
130 * llint/LLIntSlowPaths.cpp:
131 (JSC::LLInt::LLINT_SLOW_PATH_DECL):
132 (JSC::LLInt::setupGetByIdPrototypeCache):
133 * llint/LowLevelInterpreter.asm:
134 * llint/LowLevelInterpreter32_64.asm:
135 * llint/LowLevelInterpreter64.asm:
136 * runtime/CommonSlowPaths.cpp:
137 * runtime/GetPutInfo.h:
138