OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 function->ReplaceCode(function->shared()->code()); | 101 function->ReplaceCode(function->shared()->code()); |
102 | 102 |
103 if (FLAG_trace_deopt) { | 103 if (FLAG_trace_deopt) { |
104 PrintF("[forced deoptimization: "); | 104 PrintF("[forced deoptimization: "); |
105 function->PrintName(); | 105 function->PrintName(); |
106 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); | 106 PrintF(" / %x]\n", reinterpret_cast<uint32_t>(function)); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 static const int32_t kBranchBeforeStackCheck = 0x2a000001; | |
112 static const int32_t kBranchBeforeInterrupt = 0x5a000004; | |
Erik Corry
2012/03/23 09:55:53
There is a bunch of these in assembler-arm.h eg kM
Jakob Kummerow
2012/03/23 12:07:32
I disagree. They contain condition codes and jump
| |
113 | |
114 | |
111 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, | 115 void Deoptimizer::PatchStackCheckCodeAt(Code* unoptimized_code, |
112 Address pc_after, | 116 Address pc_after, |
113 Code* check_code, | 117 Code* check_code, |
114 Code* replacement_code) { | 118 Code* replacement_code) { |
115 const int kInstrSize = Assembler::kInstrSize; | 119 const int kInstrSize = Assembler::kInstrSize; |
116 // The call of the stack guard check has the following form: | 120 // The call of the stack guard check has the following form: |
117 // e1 5d 00 0c cmp sp, <limit> | 121 // e1 5d 00 0c cmp sp, <limit> |
118 // 2a 00 00 01 bcs ok | 122 // 2a 00 00 01 bcs ok |
119 // e5 9f c? ?? ldr ip, [pc, <stack guard address>] | 123 // e5 9f c? ?? ldr ip, [pc, <stack guard address>] |
120 // e1 2f ff 3c blx ip | 124 // e1 2f ff 3c blx ip |
121 ASSERT(Memory::int32_at(pc_after - kInstrSize) == | 125 ASSERT(Memory::int32_at(pc_after - kInstrSize) == |
122 (al | B24 | B21 | 15*B16 | 15*B12 | 15*B8 | BLX | ip.code())); | 126 (al | B24 | B21 | 15*B16 | 15*B12 | 15*B8 | BLX | ip.code())); |
123 ASSERT(Assembler::IsLdrPcImmediateOffset( | 127 ASSERT(Assembler::IsLdrPcImmediateOffset( |
124 Assembler::instr_at(pc_after - 2 * kInstrSize))); | 128 Assembler::instr_at(pc_after - 2 * kInstrSize))); |
129 if (FLAG_count_based_interrupts) { | |
130 ASSERT_EQ(kBranchBeforeInterrupt, | |
131 Memory::int32_at(pc_after - 3 * kInstrSize)); | |
132 } else { | |
133 ASSERT_EQ(kBranchBeforeStackCheck, | |
134 Memory::int32_at(pc_after - 3 * kInstrSize)); | |
135 } | |
125 | 136 |
126 // We patch the code to the following form: | 137 // We patch the code to the following form: |
127 // e1 5d 00 0c cmp sp, <limit> | 138 // e1 5d 00 0c cmp sp, <limit> |
128 // e1 a0 00 00 mov r0, r0 (NOP) | 139 // e1 a0 00 00 mov r0, r0 (NOP) |
129 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] | 140 // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] |
130 // e1 2f ff 3c blx ip | 141 // e1 2f ff 3c blx ip |
131 // and overwrite the constant containing the | 142 // and overwrite the constant containing the |
132 // address of the stack check stub. | 143 // address of the stack check stub. |
133 | 144 |
134 // Replace conditional jump with NOP. | 145 // Replace conditional jump with NOP. |
(...skipping 13 matching lines...) Expand all Loading... | |
148 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 159 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
149 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code); | 160 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code); |
150 } | 161 } |
151 | 162 |
152 | 163 |
153 void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code, | 164 void Deoptimizer::RevertStackCheckCodeAt(Code* unoptimized_code, |
154 Address pc_after, | 165 Address pc_after, |
155 Code* check_code, | 166 Code* check_code, |
156 Code* replacement_code) { | 167 Code* replacement_code) { |
157 const int kInstrSize = Assembler::kInstrSize; | 168 const int kInstrSize = Assembler::kInstrSize; |
158 ASSERT(Memory::uint32_at(pc_after - kInstrSize) == 0xe12fff3c); | 169 ASSERT(Memory::int32_at(pc_after - kInstrSize) == |
159 ASSERT(Memory::uint8_at(pc_after - kInstrSize - 1) == 0xe5); | 170 (al | B24 | B21 | 15*B16 | 15*B12 | 15*B8 | BLX | ip.code())); |
Erik Corry
2012/03/23 09:55:53
What is this instruction?
Jakob Kummerow
2012/03/23 12:07:32
"blx ip", copied from above in the interest of uni
| |
160 ASSERT(Memory::uint8_at(pc_after - kInstrSize - 2) == 0x9f); | 171 ASSERT(Assembler::IsLdrPcImmediateOffset( |
172 Assembler::instr_at(pc_after - 2 * kInstrSize))); | |
161 | 173 |
162 // Replace NOP with conditional jump. | 174 // Replace NOP with conditional jump. |
163 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); | 175 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); |
164 patcher.masm()->b(+4, cs); | 176 if (FLAG_count_based_interrupts) { |
177 patcher.masm()->b(+16, pl); | |
178 ASSERT_EQ(kBranchBeforeInterrupt, | |
179 Memory::int32_at(pc_after - 3 * kInstrSize)); | |
180 } else { | |
181 patcher.masm()->b(+4, cs); | |
182 ASSERT_EQ(kBranchBeforeStackCheck, | |
183 Memory::int32_at(pc_after - 3 * kInstrSize)); | |
184 } | |
165 | 185 |
166 // Replace the stack check address in the constant pool | 186 // Replace the stack check address in the constant pool |
167 // with the entry address of the replacement code. | 187 // with the entry address of the replacement code. |
168 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after - | 188 uint32_t stack_check_address_offset = Memory::uint16_at(pc_after - |
169 2 * kInstrSize) & 0xfff; | 189 2 * kInstrSize) & 0xfff; |
170 Address stack_check_address_pointer = pc_after + stack_check_address_offset; | 190 Address stack_check_address_pointer = pc_after + stack_check_address_offset; |
171 ASSERT(Memory::uint32_at(stack_check_address_pointer) == | 191 ASSERT(Memory::uint32_at(stack_check_address_pointer) == |
172 reinterpret_cast<uint32_t>(replacement_code->entry())); | 192 reinterpret_cast<uint32_t>(replacement_code->entry())); |
173 Memory::uint32_at(stack_check_address_pointer) = | 193 Memory::uint32_at(stack_check_address_pointer) = |
174 reinterpret_cast<uint32_t>(check_code->entry()); | 194 reinterpret_cast<uint32_t>(check_code->entry()); |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 __ push(ip); | 971 __ push(ip); |
952 __ b(&done); | 972 __ b(&done); |
953 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 973 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
954 } | 974 } |
955 __ bind(&done); | 975 __ bind(&done); |
956 } | 976 } |
957 | 977 |
958 #undef __ | 978 #undef __ |
959 | 979 |
960 } } // namespace v8::internal | 980 } } // namespace v8::internal |
OLD | NEW |