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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); | 63 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); |
64 // We need calls to have a predictable size in the unoptimized code, but | 64 // We need calls to have a predictable size in the unoptimized code, but |
65 // this is optimized code, so we don't have to have a predictable size. | 65 // this is optimized code, so we don't have to have a predictable size. |
66 int call_size_in_bytes = | 66 int call_size_in_bytes = |
67 MacroAssembler::CallSizeNotPredictableCodeSize(deopt_entry, | 67 MacroAssembler::CallSizeNotPredictableCodeSize(deopt_entry, |
68 RelocInfo::NONE32); | 68 RelocInfo::NONE32); |
69 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; | 69 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; |
70 ASSERT(call_size_in_bytes % Assembler::kInstrSize == 0); | 70 ASSERT(call_size_in_bytes % Assembler::kInstrSize == 0); |
71 ASSERT(call_size_in_bytes <= patch_size()); | 71 ASSERT(call_size_in_bytes <= patch_size()); |
72 CodePatcher patcher(call_address, call_size_in_words); | 72 CodePatcher patcher(call_address, call_size_in_words); |
| 73 if (deopt_data->Mode(i)->value() == 1) { |
| 74 patcher.masm()->set_thumb_mode(); |
| 75 } |
73 patcher.masm()->Call(deopt_entry, RelocInfo::NONE32); | 76 patcher.masm()->Call(deopt_entry, RelocInfo::NONE32); |
74 ASSERT(prev_call_address == NULL || | 77 ASSERT(prev_call_address == NULL || |
75 call_address >= prev_call_address + patch_size()); | 78 call_address >= prev_call_address + patch_size()); |
76 ASSERT(call_address + patch_size() <= code->instruction_end()); | 79 ASSERT(call_address + patch_size() <= code->instruction_end()); |
77 #ifdef DEBUG | 80 #ifdef DEBUG |
78 prev_call_address = call_address; | 81 prev_call_address = call_address; |
79 #endif | 82 #endif |
80 } | 83 } |
81 } | 84 } |
82 | 85 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // Restore the original jump. | 138 // Restore the original jump. |
136 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); | 139 CodePatcher patcher(pc_after - 3 * kInstrSize, 1); |
137 patcher.masm()->b(4 * kInstrSize, pl); // ok-label is 4 instructions later. | 140 patcher.masm()->b(4 * kInstrSize, pl); // ok-label is 4 instructions later. |
138 ASSERT_EQ(kBranchBeforeInterrupt, | 141 ASSERT_EQ(kBranchBeforeInterrupt, |
139 Memory::int32_at(pc_after - 3 * kInstrSize)); | 142 Memory::int32_at(pc_after - 3 * kInstrSize)); |
140 // Restore the original call address. | 143 // Restore the original call address. |
141 uint32_t interrupt_address_offset = Memory::uint16_at(pc_after - | 144 uint32_t interrupt_address_offset = Memory::uint16_at(pc_after - |
142 2 * kInstrSize) & 0xfff; | 145 2 * kInstrSize) & 0xfff; |
143 Address interrupt_address_pointer = pc_after + interrupt_address_offset; | 146 Address interrupt_address_pointer = pc_after + interrupt_address_offset; |
144 Memory::uint32_at(interrupt_address_pointer) = | 147 Memory::uint32_at(interrupt_address_pointer) = |
145 reinterpret_cast<uint32_t>(interrupt_code->entry()); | 148 reinterpret_cast<uint32_t>(interrupt_code->instruction_start()); |
146 | 149 |
147 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( | 150 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
148 unoptimized_code, pc_after - 2 * kInstrSize, interrupt_code); | 151 unoptimized_code, pc_after - 2 * kInstrSize, interrupt_code); |
149 } | 152 } |
150 | 153 |
151 | 154 |
152 #ifdef DEBUG | 155 #ifdef DEBUG |
153 bool Deoptimizer::InterruptCodeIsPatched(Code* unoptimized_code, | 156 bool Deoptimizer::InterruptCodeIsPatched(Code* unoptimized_code, |
154 Address pc_after, | 157 Address pc_after, |
155 Code* interrupt_code, | 158 Code* interrupt_code, |
156 Code* replacement_code) { | 159 Code* replacement_code) { |
157 static const int kInstrSize = Assembler::kInstrSize; | 160 static const int kInstrSize = Assembler::kInstrSize; |
158 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp); | 161 ASSERT(Memory::int32_at(pc_after - kInstrSize) == kBlxIp); |
159 | 162 |
160 uint32_t interrupt_address_offset = | 163 uint32_t interrupt_address_offset = |
161 Memory::uint16_at(pc_after - 2 * kInstrSize) & 0xfff; | 164 Memory::uint16_at(pc_after - 2 * kInstrSize) & 0xfff; |
162 Address interrupt_address_pointer = pc_after + interrupt_address_offset; | 165 Address interrupt_address_pointer = pc_after + interrupt_address_offset; |
163 | 166 |
164 if (Assembler::IsNop(Assembler::instr_at(pc_after - 3 * kInstrSize))) { | 167 if (Assembler::IsNop(Assembler::instr_at(pc_after - 3 * kInstrSize))) { |
165 ASSERT(Assembler::IsLdrPcImmediateOffset( | 168 ASSERT(Assembler::IsLdrPcImmediateOffset( |
166 Assembler::instr_at(pc_after - 2 * kInstrSize))); | 169 Assembler::instr_at(pc_after - 2 * kInstrSize))); |
167 ASSERT(reinterpret_cast<uint32_t>(replacement_code->entry()) == | 170 ASSERT(reinterpret_cast<uint32_t>(replacement_code->instruction_start()) == |
168 Memory::uint32_at(interrupt_address_pointer)); | 171 Memory::uint32_at(interrupt_address_pointer)); |
169 return true; | 172 return true; |
170 } else { | 173 } else { |
171 ASSERT(Assembler::IsLdrPcImmediateOffset( | 174 ASSERT(Assembler::IsLdrPcImmediateOffset( |
172 Assembler::instr_at(pc_after - 2 * kInstrSize))); | 175 Assembler::instr_at(pc_after - 2 * kInstrSize))); |
173 ASSERT_EQ(kBranchBeforeInterrupt, | 176 ASSERT_EQ(kBranchBeforeInterrupt, |
174 Memory::int32_at(pc_after - 3 * kInstrSize)); | 177 Memory::int32_at(pc_after - 3 * kInstrSize)); |
175 ASSERT(reinterpret_cast<uint32_t>(interrupt_code->entry()) == | 178 ASSERT(reinterpret_cast<uint32_t>(interrupt_code->instruction_start()) == |
176 Memory::uint32_at(interrupt_address_pointer)); | 179 Memory::uint32_at(interrupt_address_pointer)); |
177 return false; | 180 return false; |
178 } | 181 } |
179 } | 182 } |
180 #endif // DEBUG | 183 #endif // DEBUG |
181 | 184 |
182 | 185 |
183 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { | 186 static int LookupBailoutId(DeoptimizationInputData* data, BailoutId ast_id) { |
184 ByteArray* translations = data->TranslationByteArray(); | 187 ByteArray* translations = data->TranslationByteArray(); |
185 int length = data->DeoptCount(); | 188 int length = data->DeoptCount(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 output_[0]->SetRegister(fp.code(), input_->GetRegister(fp.code())); | 327 output_[0]->SetRegister(fp.code(), input_->GetRegister(fp.code())); |
325 output_[0]->SetRegister(cp.code(), input_->GetRegister(cp.code())); | 328 output_[0]->SetRegister(cp.code(), input_->GetRegister(cp.code())); |
326 | 329 |
327 unsigned pc_offset = data->OsrPcOffset()->value(); | 330 unsigned pc_offset = data->OsrPcOffset()->value(); |
328 uint32_t pc = reinterpret_cast<uint32_t>( | 331 uint32_t pc = reinterpret_cast<uint32_t>( |
329 compiled_code_->entry() + pc_offset); | 332 compiled_code_->entry() + pc_offset); |
330 output_[0]->SetPc(pc); | 333 output_[0]->SetPc(pc); |
331 } | 334 } |
332 Code* continuation = isolate_->builtins()->builtin(Builtins::kNotifyOSR); | 335 Code* continuation = isolate_->builtins()->builtin(Builtins::kNotifyOSR); |
333 output_[0]->SetContinuation( | 336 output_[0]->SetContinuation( |
334 reinterpret_cast<uint32_t>(continuation->entry())); | 337 reinterpret_cast<uint32_t>(continuation->instruction_start())); |
335 | 338 |
336 if (FLAG_trace_osr) { | 339 if (FLAG_trace_osr) { |
337 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", | 340 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", |
338 ok ? "finished" : "aborted", | 341 ok ? "finished" : "aborted", |
339 reinterpret_cast<intptr_t>(function_)); | 342 reinterpret_cast<intptr_t>(function_)); |
340 PrintFunctionName(); | 343 PrintFunctionName(); |
341 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); | 344 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); |
342 } | 345 } |
343 } | 346 } |
344 | 347 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 612 |
610 | 613 |
611 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { | 614 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { |
612 SetFrameSlot(offset, value); | 615 SetFrameSlot(offset, value); |
613 } | 616 } |
614 | 617 |
615 | 618 |
616 #undef __ | 619 #undef __ |
617 | 620 |
618 } } // namespace v8::internal | 621 } } // namespace v8::internal |
OLD | NEW |