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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 155 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
156 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code); | 156 unoptimized_code, pc_after - 2 * kInstrSize, replacement_code); |
157 } | 157 } |
158 | 158 |
159 | 159 |
160 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code, | 160 void Deoptimizer::RevertInterruptCodeAt(Code* unoptimized_code, |
161 Address pc_after, | 161 Address pc_after, |
162 Code* interrupt_code, | 162 Code* interrupt_code, |
163 Code* replacement_code) { | 163 Code* replacement_code) { |
164 ASSERT(InterruptCodeIsPatched(unoptimized_code, | 164 ASSERT(InterruptCodeIsPatched(unoptimized_code, |
165 pc_after, | 165 pc_after, |
166 interrupt_code, | 166 interrupt_code, |
167 replacement_code)); | 167 replacement_code)); |
168 static const int kInstrSize = Assembler::kInstrSize; | 168 static const int kInstrSize = Assembler::kInstrSize; |
169 // Restore the original jump. | 169 // Restore the original jump. |
170 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); | 170 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); |
171 patcher.masm()->b(4 * kInstrSize, pl); // ok-label is 4 instructions later. | 171 patcher.masm()->b(4 * kInstrSize, pl); // ok-label is 4 instructions later. |
| 172 ASSERT_EQ(kBranchBeforeInterrupt, |
| 173 Memory::int32_at(pc_after - 3 * kInstrSize)); |
172 // Restore the original call address. | 174 // Restore the original call address. |
173 uint32_t interrupt_address_offset = Memory::uint16_at(pc_after - | 175 uint32_t interrupt_address_offset = Memory::uint16_at(pc_after - |
174 2 * kInstrSize) & 0xfff; | 176 2 * kInstrSize) & 0xfff; |
175 Address interrupt_address_pointer = pc_after + interrupt_address_offset; | 177 Address interrupt_address_pointer = pc_after + interrupt_address_offset; |
176 Memory::uint32_at(interrupt_address_pointer) = | 178 Memory::uint32_at(interrupt_address_pointer) = |
177 reinterpret_cast<uint32_t>(interrupt_code->entry()); | 179 reinterpret_cast<uint32_t>(interrupt_code->entry()); |
178 | 180 |
179 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 181 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
180 unoptimized_code, pc_after - 2 * kInstrSize, interrupt_code); | 182 unoptimized_code, pc_after - 2 * kInstrSize, interrupt_code); |
181 } | 183 } |
182 | 184 |
183 | 185 |
184 #ifdef DEBUG | 186 #ifdef DEBUG |
185 bool Deoptimizer::InterruptCodeIsPatched(Code* unoptimized_code, | 187 bool Deoptimizer::InterruptCodeIsPatched(Code* unoptimized_code, |
186 Address pc_after, | 188 Address pc_after, |
187 Code* interrupt_code, | 189 Code* interrupt_code, |
188 Code* replacement_code) { | 190 Code* replacement_code) { |
189 Address call_target_address = pc_after - kIntSize; | 191 static const int kInstrSize = Assembler::kInstrSize; |
190 ASSERT_EQ(kBlxIp, Memory::int32_at(pc_after - kInstrSize)); | 192 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp); |
191 | 193 |
192 uint32_t interrupt_address_offset = | 194 uint32_t interrupt_address_offset = |
193 Memory::uint16_at(pc_after - 2 * kInstrSize) & 0xfff; | 195 Memory::uint16_at(pc_after - 2 * kInstrSize) & 0xfff; |
194 Address interrupt_address_pointer = pc_after + interrupt_address_offset; | 196 Address interrupt_address_pointer = pc_after + interrupt_address_offset; |
195 | 197 |
196 if (Assembler::IsNop(Assembler::instr_at(pc_after - 3 * kInstrSize))) { | 198 if (Assembler::IsNop(Assembler::instr_at(pc_after - 3 * kInstrSize))) { |
197 ASSERT(Assembler::IsLdrPcImmediateOffset( | 199 ASSERT(Assembler::IsLdrPcImmediateOffset( |
198 Assembler::instr_at(pc_after - 2 * kInstrSize))); | 200 Assembler::instr_at(pc_after - 2 * kInstrSize))); |
199 ASSERT_EQ(kBranchBeforeInterrupt, | 201 ASSERT(reinterpret_cast<uint32_t>(replacement_code->entry()) == |
200 Memory::int32_at(pc_after - 3 * kInstrSize)); | 202 Memory::uint32_at(interrupt_address_pointer)); |
201 ASSERT_EQ(reinterpret_cast<uint32_t>(replacement_code->entry()), | |
202 Memory::uint32_at(interrupt_address_pointer)); | |
203 return true; | 203 return true; |
204 } else { | 204 } else { |
205 ASSERT(Assembler::IsLdrPcImmediateOffset( | 205 ASSERT(Assembler::IsLdrPcImmediateOffset( |
206 Assembler::instr_at(pc_after - 2 * kInstrSize))); | 206 Assembler::instr_at(pc_after - 2 * kInstrSize))); |
207 ASSERT_EQ(kBranchBeforeInterrupt, | 207 ASSERT_EQ(kBranchBeforeInterrupt, |
208 Memory::int32_at(pc_after - 3 * kInstrSize)); | 208 Memory::int32_at(pc_after - 3 * kInstrSize)); |
209 ASSERT_EQ(reinterpret_cast<uint32_t>(interrupt_code->entry()), | 209 ASSERT(reinterpret_cast<uint32_t>(interrupt_code->entry()) == |
210 Memory::uint32_at(interrupt_address_pointer)); | 210 Memory::uint32_at(interrupt_address_pointer)); |
211 return false; | 211 return false; |
212 } | 212 } |
213 } | 213 } |
214 #endif // DEBUG | 214 #endif // DEBUG |
215 | 215 |
216 | 216 |
217 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { | 217 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { |
218 ByteArray* translations = data->TranslationByteArray(); | 218 ByteArray* translations = data->TranslationByteArray(); |
219 int length = data->DeoptCount(); | 219 int length = data->DeoptCount(); |
220 for (int i = 0; i < length; i++) { | 220 for (int i = 0; i < length; i++) { |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 __ push(ip); | 826 __ push(ip); |
827 __ b(&done); | 827 __ b(&done); |
828 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 828 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
829 } | 829 } |
830 __ bind(&done); | 830 __ bind(&done); |
831 } | 831 } |
832 | 832 |
833 #undef __ | 833 #undef __ |
834 | 834 |
835 } } // namespace v8::internal | 835 } } // namespace v8::internal |
OLD | NEW |