| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // |
| 3 // Copyright IBM Corp. 2012, 2013. All rights reserved. |
| 4 // |
| 2 // Use of this source code is governed by a BSD-style license that can be | 5 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 6 // found in the LICENSE file. |
| 4 | 7 |
| 5 #include "src/v8.h" | 8 #include "src/v8.h" |
| 6 | 9 |
| 7 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| 8 #include "src/deoptimizer.h" | 11 #include "src/deoptimizer.h" |
| 9 #include "src/full-codegen.h" | 12 #include "src/full-codegen.h" |
| 10 #include "src/safepoint-table.h" | 13 #include "src/safepoint-table.h" |
| 11 | 14 |
| 12 namespace v8 { | 15 namespace v8 { |
| 13 namespace internal { | 16 namespace internal { |
| 14 | 17 |
| 15 const int Deoptimizer::table_entry_size_ = 8; | 18 const int Deoptimizer::table_entry_size_ = 8; |
| 16 | 19 |
| 17 | 20 |
| 18 int Deoptimizer::patch_size() { | 21 int Deoptimizer::patch_size() { |
| 19 const int kCallInstructionSizeInWords = 3; | 22 #if V8_TARGET_ARCH_PPC64 |
| 23 const int kCallInstructionSizeInWords = 7; |
| 24 #else |
| 25 const int kCallInstructionSizeInWords = 4; |
| 26 #endif |
| 20 return kCallInstructionSizeInWords * Assembler::kInstrSize; | 27 return kCallInstructionSizeInWords * Assembler::kInstrSize; |
| 21 } | 28 } |
| 22 | 29 |
| 23 | 30 |
| 24 void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { | 31 void Deoptimizer::PatchCodeForDeoptimization(Isolate* isolate, Code* code) { |
| 25 Address code_start_address = code->instruction_start(); | 32 Address code_start_address = code->instruction_start(); |
| 33 |
| 26 // Invalidate the relocation information, as it will become invalid by the | 34 // Invalidate the relocation information, as it will become invalid by the |
| 27 // code patching below, and is not needed any more. | 35 // code patching below, and is not needed any more. |
| 28 code->InvalidateRelocation(); | 36 code->InvalidateRelocation(); |
| 29 | 37 |
| 30 if (FLAG_zap_code_space) { | 38 if (FLAG_zap_code_space) { |
| 31 // Fail hard and early if we enter this code object again. | 39 // Fail hard and early if we enter this code object again. |
| 32 byte* pointer = code->FindCodeAgeSequence(); | 40 byte* pointer = code->FindCodeAgeSequence(); |
| 33 if (pointer != NULL) { | 41 if (pointer != NULL) { |
| 34 pointer += kNoCodeAgeSequenceLength; | 42 pointer += kNoCodeAgeSequenceLength; |
| 35 } else { | 43 } else { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 #endif | 62 #endif |
| 55 // For each LLazyBailout instruction insert a call to the corresponding | 63 // For each LLazyBailout instruction insert a call to the corresponding |
| 56 // deoptimization entry. | 64 // deoptimization entry. |
| 57 for (int i = 0; i < deopt_data->DeoptCount(); i++) { | 65 for (int i = 0; i < deopt_data->DeoptCount(); i++) { |
| 58 if (deopt_data->Pc(i)->value() == -1) continue; | 66 if (deopt_data->Pc(i)->value() == -1) continue; |
| 59 Address call_address = code_start_address + deopt_data->Pc(i)->value(); | 67 Address call_address = code_start_address + deopt_data->Pc(i)->value(); |
| 60 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); | 68 Address deopt_entry = GetDeoptimizationEntry(isolate, i, LAZY); |
| 61 // We need calls to have a predictable size in the unoptimized code, but | 69 // We need calls to have a predictable size in the unoptimized code, but |
| 62 // this is optimized code, so we don't have to have a predictable size. | 70 // this is optimized code, so we don't have to have a predictable size. |
| 63 int call_size_in_bytes = | 71 int call_size_in_bytes = |
| 64 MacroAssembler::CallSizeNotPredictableCodeSize(isolate, | 72 MacroAssembler::CallSizeNotPredictableCodeSize(deopt_entry, |
| 65 deopt_entry, | 73 kRelocInfo_NONEPTR); |
| 66 RelocInfo::NONE32); | |
| 67 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; | 74 int call_size_in_words = call_size_in_bytes / Assembler::kInstrSize; |
| 68 DCHECK(call_size_in_bytes % Assembler::kInstrSize == 0); | 75 DCHECK(call_size_in_bytes % Assembler::kInstrSize == 0); |
| 69 DCHECK(call_size_in_bytes <= patch_size()); | 76 DCHECK(call_size_in_bytes <= patch_size()); |
| 70 CodePatcher patcher(call_address, call_size_in_words); | 77 CodePatcher patcher(call_address, call_size_in_words); |
| 71 patcher.masm()->Call(deopt_entry, RelocInfo::NONE32); | 78 patcher.masm()->Call(deopt_entry, kRelocInfo_NONEPTR); |
| 72 DCHECK(prev_call_address == NULL || | 79 DCHECK(prev_call_address == NULL || |
| 73 call_address >= prev_call_address + patch_size()); | 80 call_address >= prev_call_address + patch_size()); |
| 74 DCHECK(call_address + patch_size() <= code->instruction_end()); | 81 DCHECK(call_address + patch_size() <= code->instruction_end()); |
| 75 #ifdef DEBUG | 82 #ifdef DEBUG |
| 76 prev_call_address = call_address; | 83 prev_call_address = call_address; |
| 77 #endif | 84 #endif |
| 78 } | 85 } |
| 79 } | 86 } |
| 80 | 87 |
| 81 | 88 |
| 82 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 89 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
| 83 // Set the register values. The values are not important as there are no | 90 // Set the register values. The values are not important as there are no |
| 84 // callee saved registers in JavaScript frames, so all registers are | 91 // callee saved registers in JavaScript frames, so all registers are |
| 85 // spilled. Registers fp and sp are set to the correct values though. | 92 // spilled. Registers fp and sp are set to the correct values though. |
| 86 | 93 |
| 87 for (int i = 0; i < Register::kNumRegisters; i++) { | 94 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 88 input_->SetRegister(i, i * 4); | 95 input_->SetRegister(i, i * 4); |
| 89 } | 96 } |
| 90 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 97 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
| 91 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 98 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 92 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { | 99 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { |
| 93 input_->SetDoubleRegister(i, 0.0); | 100 input_->SetDoubleRegister(i, 0.0); |
| 94 } | 101 } |
| 95 | 102 |
| 96 // Fill the frame content from the actual data on the frame. | 103 // Fill the frame content from the actual data on the frame. |
| 97 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 104 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
| 98 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); | 105 input_->SetFrameSlot(i, reinterpret_cast<intptr_t>( |
| 106 Memory::Address_at(tos + i))); |
| 99 } | 107 } |
| 100 } | 108 } |
| 101 | 109 |
| 102 | 110 |
| 103 void Deoptimizer::SetPlatformCompiledStubRegisters( | 111 void Deoptimizer::SetPlatformCompiledStubRegisters( |
| 104 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { | 112 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { |
| 105 ApiFunction function(descriptor->deoptimization_handler()); | 113 ApiFunction function(descriptor->deoptimization_handler()); |
| 106 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); | 114 ExternalReference xref(&function, ExternalReference::BUILTIN_CALL, isolate_); |
| 107 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); | 115 intptr_t handler = reinterpret_cast<intptr_t>(xref.address()); |
| 108 int params = descriptor->GetHandlerParameterCount(); | 116 int params = descriptor->GetHandlerParameterCount(); |
| 109 output_frame->SetRegister(r0.code(), params); | 117 output_frame->SetRegister(r3.code(), params); |
| 110 output_frame->SetRegister(r1.code(), handler); | 118 output_frame->SetRegister(r4.code(), handler); |
| 111 } | 119 } |
| 112 | 120 |
| 113 | 121 |
| 114 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { | 122 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { |
| 115 for (int i = 0; i < DwVfpRegister::kMaxNumRegisters; ++i) { | 123 for (int i = 0; i < DoubleRegister::kMaxNumRegisters; ++i) { |
| 116 double double_value = input_->GetDoubleRegister(i); | 124 double double_value = input_->GetDoubleRegister(i); |
| 117 output_frame->SetDoubleRegister(i, double_value); | 125 output_frame->SetDoubleRegister(i, double_value); |
| 118 } | 126 } |
| 119 } | 127 } |
| 120 | 128 |
| 121 | 129 |
| 122 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { | 130 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { |
| 123 // There is no dynamic alignment padding on ARM in the input frame. | 131 // There is no dynamic alignment padding on PPC in the input frame. |
| 124 return false; | 132 return false; |
| 125 } | 133 } |
| 126 | 134 |
| 127 | 135 |
| 128 #define __ masm()-> | 136 #define __ masm()-> |
| 129 | 137 |
| 130 // This code tries to be close to ia32 code so that any changes can be | 138 // This code tries to be close to ia32 code so that any changes can be |
| 131 // easily ported. | 139 // easily ported. |
| 132 void Deoptimizer::EntryGenerator::Generate() { | 140 void Deoptimizer::EntryGenerator::Generate() { |
| 133 GeneratePrologue(); | 141 GeneratePrologue(); |
| 134 | 142 |
| 135 // Save all general purpose registers before messing with them. | 143 // Unlike on ARM we don't save all the registers, just the useful ones. |
| 144 // For the rest, there are gaps on the stack, so the offsets remain the same. |
| 136 const int kNumberOfRegisters = Register::kNumRegisters; | 145 const int kNumberOfRegisters = Register::kNumRegisters; |
| 137 | 146 |
| 138 // Everything but pc, lr and ip which will be saved but not restored. | 147 RegList restored_regs = kJSCallerSaved | kCalleeSaved; |
| 139 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); | 148 RegList saved_regs = restored_regs | sp.bit(); |
| 140 | 149 |
| 141 const int kDoubleRegsSize = | 150 const int kDoubleRegsSize = |
| 142 kDoubleSize * DwVfpRegister::kMaxNumAllocatableRegisters; | 151 kDoubleSize * DoubleRegister::kMaxNumAllocatableRegisters; |
| 143 | 152 |
| 144 // Save all allocatable VFP registers before messing with them. | 153 // Save all FPU registers before messing with them. |
| 145 DCHECK(kDoubleRegZero.code() == 14); | 154 __ subi(sp, sp, Operand(kDoubleRegsSize)); |
| 146 DCHECK(kScratchDoubleReg.code() == 15); | 155 for (int i = 0; i < DoubleRegister::kMaxNumAllocatableRegisters; ++i) { |
| 156 DoubleRegister fpu_reg = DoubleRegister::FromAllocationIndex(i); |
| 157 int offset = i * kDoubleSize; |
| 158 __ stfd(fpu_reg, MemOperand(sp, offset)); |
| 159 } |
| 147 | 160 |
| 148 // Check CPU flags for number of registers, setting the Z condition flag. | 161 // Push saved_regs (needed to populate FrameDescription::registers_). |
| 149 __ CheckFor32DRegs(ip); | 162 // Leave gaps for other registers. |
| 150 | 163 __ subi(sp, sp, Operand(kNumberOfRegisters * kPointerSize)); |
| 151 // Push registers d0-d13, and possibly d16-d31, on the stack. | 164 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { |
| 152 // If d16-d31 are not pushed, decrease the stack pointer instead. | 165 if ((saved_regs & (1 << i)) != 0) { |
| 153 __ vstm(db_w, sp, d16, d31, ne); | 166 __ StoreP(ToRegister(i), MemOperand(sp, kPointerSize * i)); |
| 154 __ sub(sp, sp, Operand(16 * kDoubleSize), LeaveCC, eq); | 167 } |
| 155 __ vstm(db_w, sp, d0, d13); | 168 } |
| 156 | |
| 157 // Push all 16 registers (needed to populate FrameDescription::registers_). | |
| 158 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps | |
| 159 // handle this a bit differently. | |
| 160 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | |
| 161 | 169 |
| 162 const int kSavedRegistersAreaSize = | 170 const int kSavedRegistersAreaSize = |
| 163 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 171 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; |
| 164 | 172 |
| 165 // Get the bailout id from the stack. | 173 // Get the bailout id from the stack. |
| 166 __ ldr(r2, MemOperand(sp, kSavedRegistersAreaSize)); | 174 __ LoadP(r5, MemOperand(sp, kSavedRegistersAreaSize)); |
| 167 | 175 |
| 168 // Get the address of the location in the code object (r3) (return | 176 // Get the address of the location in the code object (r6) (return |
| 169 // address for lazy deoptimization) and compute the fp-to-sp delta in | 177 // address for lazy deoptimization) and compute the fp-to-sp delta in |
| 170 // register r4. | 178 // register r7. |
| 171 __ mov(r3, lr); | 179 __ mflr(r6); |
| 172 // Correct one word for bailout id. | 180 // Correct one word for bailout id. |
| 173 __ add(r4, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 181 __ addi(r7, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
| 174 __ sub(r4, fp, r4); | 182 __ sub(r7, fp, r7); |
| 175 | 183 |
| 176 // Allocate a new deoptimizer object. | 184 // Allocate a new deoptimizer object. |
| 177 // Pass four arguments in r0 to r3 and fifth argument on stack. | 185 // Pass six arguments in r3 to r8. |
| 178 __ PrepareCallCFunction(6, r5); | 186 __ PrepareCallCFunction(6, r8); |
| 179 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 187 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 180 __ mov(r1, Operand(type())); // bailout type, | 188 __ li(r4, Operand(type())); // bailout type, |
| 181 // r2: bailout id already loaded. | 189 // r5: bailout id already loaded. |
| 182 // r3: code address or 0 already loaded. | 190 // r6: code address or 0 already loaded. |
| 183 __ str(r4, MemOperand(sp, 0 * kPointerSize)); // Fp-to-sp delta. | 191 // r7: Fp-to-sp delta. |
| 184 __ mov(r5, Operand(ExternalReference::isolate_address(isolate()))); | 192 __ mov(r8, Operand(ExternalReference::isolate_address(isolate()))); |
| 185 __ str(r5, MemOperand(sp, 1 * kPointerSize)); // Isolate. | |
| 186 // Call Deoptimizer::New(). | 193 // Call Deoptimizer::New(). |
| 187 { | 194 { |
| 188 AllowExternalCallThatCantCauseGC scope(masm()); | 195 AllowExternalCallThatCantCauseGC scope(masm()); |
| 189 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6); | 196 __ CallCFunction(ExternalReference::new_deoptimizer_function(isolate()), 6); |
| 190 } | 197 } |
| 191 | 198 |
| 192 // Preserve "deoptimizer" object in register r0 and get the input | 199 // Preserve "deoptimizer" object in register r3 and get the input |
| 193 // frame descriptor pointer to r1 (deoptimizer->input_); | 200 // frame descriptor pointer to r4 (deoptimizer->input_); |
| 194 __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); | 201 __ LoadP(r4, MemOperand(r3, Deoptimizer::input_offset())); |
| 195 | 202 |
| 196 // Copy core registers into FrameDescription::registers_[kNumRegisters]. | 203 // Copy core registers into FrameDescription::registers_[kNumRegisters]. |
| 197 DCHECK(Register::kNumRegisters == kNumberOfRegisters); | 204 DCHECK(Register::kNumRegisters == kNumberOfRegisters); |
| 198 for (int i = 0; i < kNumberOfRegisters; i++) { | 205 for (int i = 0; i < kNumberOfRegisters; i++) { |
| 199 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 206 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
| 200 __ ldr(r2, MemOperand(sp, i * kPointerSize)); | 207 __ LoadP(r5, MemOperand(sp, i * kPointerSize)); |
| 201 __ str(r2, MemOperand(r1, offset)); | 208 __ StoreP(r5, MemOperand(r4, offset)); |
| 202 } | 209 } |
| 203 | 210 |
| 211 int double_regs_offset = FrameDescription::double_registers_offset(); |
| 204 // Copy VFP registers to | 212 // Copy VFP registers to |
| 205 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] | 213 // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
| 206 int double_regs_offset = FrameDescription::double_registers_offset(); | 214 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); ++i) { |
| 207 for (int i = 0; i < DwVfpRegister::kMaxNumAllocatableRegisters; ++i) { | |
| 208 int dst_offset = i * kDoubleSize + double_regs_offset; | 215 int dst_offset = i * kDoubleSize + double_regs_offset; |
| 209 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 216 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
| 210 __ vldr(d0, sp, src_offset); | 217 __ lfd(d0, MemOperand(sp, src_offset)); |
| 211 __ vstr(d0, r1, dst_offset); | 218 __ stfd(d0, MemOperand(r4, dst_offset)); |
| 212 } | 219 } |
| 213 | 220 |
| 214 // Remove the bailout id and the saved registers from the stack. | 221 // Remove the bailout id and the saved registers from the stack. |
| 215 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 222 __ addi(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
| 216 | 223 |
| 217 // Compute a pointer to the unwinding limit in register r2; that is | 224 // Compute a pointer to the unwinding limit in register r5; that is |
| 218 // the first stack slot not part of the input frame. | 225 // the first stack slot not part of the input frame. |
| 219 __ ldr(r2, MemOperand(r1, FrameDescription::frame_size_offset())); | 226 __ LoadP(r5, MemOperand(r4, FrameDescription::frame_size_offset())); |
| 220 __ add(r2, r2, sp); | 227 __ add(r5, r5, sp); |
| 221 | 228 |
| 222 // Unwind the stack down to - but not including - the unwinding | 229 // Unwind the stack down to - but not including - the unwinding |
| 223 // limit and copy the contents of the activation frame to the input | 230 // limit and copy the contents of the activation frame to the input |
| 224 // frame description. | 231 // frame description. |
| 225 __ add(r3, r1, Operand(FrameDescription::frame_content_offset())); | 232 __ addi(r6, r4, Operand(FrameDescription::frame_content_offset())); |
| 226 Label pop_loop; | 233 Label pop_loop; |
| 227 Label pop_loop_header; | 234 Label pop_loop_header; |
| 228 __ b(&pop_loop_header); | 235 __ b(&pop_loop_header); |
| 229 __ bind(&pop_loop); | 236 __ bind(&pop_loop); |
| 230 __ pop(r4); | 237 __ pop(r7); |
| 231 __ str(r4, MemOperand(r3, 0)); | 238 __ StoreP(r7, MemOperand(r6, 0)); |
| 232 __ add(r3, r3, Operand(sizeof(uint32_t))); | 239 __ addi(r6, r6, Operand(kPointerSize)); |
| 233 __ bind(&pop_loop_header); | 240 __ bind(&pop_loop_header); |
| 234 __ cmp(r2, sp); | 241 __ cmp(r5, sp); |
| 235 __ b(ne, &pop_loop); | 242 __ bne(&pop_loop); |
| 236 | 243 |
| 237 // Compute the output frame in the deoptimizer. | 244 // Compute the output frame in the deoptimizer. |
| 238 __ push(r0); // Preserve deoptimizer object across call. | 245 __ push(r3); // Preserve deoptimizer object across call. |
| 239 // r0: deoptimizer object; r1: scratch. | 246 // r3: deoptimizer object; r4: scratch. |
| 240 __ PrepareCallCFunction(1, r1); | 247 __ PrepareCallCFunction(1, r4); |
| 241 // Call Deoptimizer::ComputeOutputFrames(). | 248 // Call Deoptimizer::ComputeOutputFrames(). |
| 242 { | 249 { |
| 243 AllowExternalCallThatCantCauseGC scope(masm()); | 250 AllowExternalCallThatCantCauseGC scope(masm()); |
| 244 __ CallCFunction( | 251 __ CallCFunction( |
| 245 ExternalReference::compute_output_frames_function(isolate()), 1); | 252 ExternalReference::compute_output_frames_function(isolate()), 1); |
| 246 } | 253 } |
| 247 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). | 254 __ pop(r3); // Restore deoptimizer object (class Deoptimizer). |
| 248 | 255 |
| 249 // Replace the current (input) frame with the output frames. | 256 // Replace the current (input) frame with the output frames. |
| 250 Label outer_push_loop, inner_push_loop, | 257 Label outer_push_loop, inner_push_loop, |
| 251 outer_loop_header, inner_loop_header; | 258 outer_loop_header, inner_loop_header; |
| 252 // Outer loop state: r4 = current "FrameDescription** output_", | 259 // Outer loop state: r7 = current "FrameDescription** output_", |
| 253 // r1 = one past the last FrameDescription**. | 260 // r4 = one past the last FrameDescription**. |
| 254 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 261 __ lwz(r4, MemOperand(r3, Deoptimizer::output_count_offset())); |
| 255 __ ldr(r4, MemOperand(r0, Deoptimizer::output_offset())); // r4 is output_. | 262 __ LoadP(r7, MemOperand(r3, Deoptimizer::output_offset())); // r7 is output_. |
| 256 __ add(r1, r4, Operand(r1, LSL, 2)); | 263 __ ShiftLeftImm(r4, r4, Operand(kPointerSizeLog2)); |
| 257 __ jmp(&outer_loop_header); | 264 __ add(r4, r7, r4); |
| 265 __ b(&outer_loop_header); |
| 266 |
| 258 __ bind(&outer_push_loop); | 267 __ bind(&outer_push_loop); |
| 259 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 268 // Inner loop state: r5 = current FrameDescription*, r6 = loop index. |
| 260 __ ldr(r2, MemOperand(r4, 0)); // output_[ix] | 269 __ LoadP(r5, MemOperand(r7, 0)); // output_[ix] |
| 261 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 270 __ LoadP(r6, MemOperand(r5, FrameDescription::frame_size_offset())); |
| 262 __ jmp(&inner_loop_header); | 271 __ b(&inner_loop_header); |
| 272 |
| 263 __ bind(&inner_push_loop); | 273 __ bind(&inner_push_loop); |
| 264 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 274 __ addi(r6, r6, Operand(-sizeof(intptr_t))); |
| 265 __ add(r6, r2, Operand(r3)); | 275 __ add(r9, r5, r6); |
| 266 __ ldr(r6, MemOperand(r6, FrameDescription::frame_content_offset())); | 276 __ LoadP(r9, MemOperand(r9, FrameDescription::frame_content_offset())); |
| 267 __ push(r6); | 277 __ push(r9); |
| 278 |
| 268 __ bind(&inner_loop_header); | 279 __ bind(&inner_loop_header); |
| 269 __ cmp(r3, Operand::Zero()); | 280 __ cmpi(r6, Operand::Zero()); |
| 270 __ b(ne, &inner_push_loop); // test for gt? | 281 __ bne(&inner_push_loop); // test for gt? |
| 271 __ add(r4, r4, Operand(kPointerSize)); | 282 |
| 283 __ addi(r7, r7, Operand(kPointerSize)); |
| 272 __ bind(&outer_loop_header); | 284 __ bind(&outer_loop_header); |
| 273 __ cmp(r4, r1); | 285 __ cmp(r7, r4); |
| 274 __ b(lt, &outer_push_loop); | 286 __ blt(&outer_push_loop); |
| 275 | 287 |
| 276 // Check CPU flags for number of registers, setting the Z condition flag. | 288 __ LoadP(r4, MemOperand(r3, Deoptimizer::input_offset())); |
| 277 __ CheckFor32DRegs(ip); | 289 for (int i = 0; i < DoubleRegister::kMaxNumAllocatableRegisters; ++i) { |
| 278 | 290 const DoubleRegister dreg = DoubleRegister::FromAllocationIndex(i); |
| 279 __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); | 291 int src_offset = i * kDoubleSize + double_regs_offset; |
| 280 int src_offset = FrameDescription::double_registers_offset(); | 292 __ lfd(dreg, MemOperand(r4, src_offset)); |
| 281 for (int i = 0; i < DwVfpRegister::kMaxNumRegisters; ++i) { | |
| 282 if (i == kDoubleRegZero.code()) continue; | |
| 283 if (i == kScratchDoubleReg.code()) continue; | |
| 284 | |
| 285 const DwVfpRegister reg = DwVfpRegister::from_code(i); | |
| 286 __ vldr(reg, r1, src_offset, i < 16 ? al : ne); | |
| 287 src_offset += kDoubleSize; | |
| 288 } | 293 } |
| 289 | 294 |
| 290 // Push state, pc, and continuation from the last output frame. | 295 // Push state, pc, and continuation from the last output frame. |
| 291 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 296 __ LoadP(r9, MemOperand(r5, FrameDescription::state_offset())); |
| 292 __ push(r6); | 297 __ push(r9); |
| 293 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 298 __ LoadP(r9, MemOperand(r5, FrameDescription::pc_offset())); |
| 294 __ push(r6); | 299 __ push(r9); |
| 295 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); | 300 __ LoadP(r9, MemOperand(r5, FrameDescription::continuation_offset())); |
| 296 __ push(r6); | 301 __ push(r9); |
| 297 | 302 |
| 298 // Push the registers from the last output frame. | 303 // Restore the registers from the last output frame. |
| 304 DCHECK(!(ip.bit() & restored_regs)); |
| 305 __ mr(ip, r5); |
| 299 for (int i = kNumberOfRegisters - 1; i >= 0; i--) { | 306 for (int i = kNumberOfRegisters - 1; i >= 0; i--) { |
| 300 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 307 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
| 301 __ ldr(r6, MemOperand(r2, offset)); | 308 if ((restored_regs & (1 << i)) != 0) { |
| 302 __ push(r6); | 309 __ LoadP(ToRegister(i), MemOperand(ip, offset)); |
| 310 } |
| 303 } | 311 } |
| 304 | 312 |
| 305 // Restore the registers from the stack. | |
| 306 __ ldm(ia_w, sp, restored_regs); // all but pc registers. | |
| 307 __ pop(ip); // remove sp | |
| 308 __ pop(ip); // remove lr | |
| 309 | |
| 310 __ InitializeRootRegister(); | 313 __ InitializeRootRegister(); |
| 311 | 314 |
| 312 __ pop(ip); // remove pc | |
| 313 __ pop(ip); // get continuation, leave pc on stack | 315 __ pop(ip); // get continuation, leave pc on stack |
| 314 __ pop(lr); | 316 __ pop(r0); |
| 317 __ mtlr(r0); |
| 315 __ Jump(ip); | 318 __ Jump(ip); |
| 316 __ stop("Unreachable."); | 319 __ stop("Unreachable."); |
| 317 } | 320 } |
| 318 | 321 |
| 319 | 322 |
| 320 void Deoptimizer::TableEntryGenerator::GeneratePrologue() { | 323 void Deoptimizer::TableEntryGenerator::GeneratePrologue() { |
| 324 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm()); |
| 325 |
| 321 // Create a sequence of deoptimization entries. | 326 // Create a sequence of deoptimization entries. |
| 322 // Note that registers are still live when jumping to an entry. | 327 // Note that registers are still live when jumping to an entry. |
| 323 Label done; | 328 Label done; |
| 324 for (int i = 0; i < count(); i++) { | 329 for (int i = 0; i < count(); i++) { |
| 325 int start = masm()->pc_offset(); | 330 int start = masm()->pc_offset(); |
| 326 USE(start); | 331 USE(start); |
| 327 __ mov(ip, Operand(i)); | 332 __ li(ip, Operand(i)); |
| 328 __ b(&done); | 333 __ b(&done); |
| 329 DCHECK(masm()->pc_offset() - start == table_entry_size_); | 334 DCHECK(masm()->pc_offset() - start == table_entry_size_); |
| 330 } | 335 } |
| 331 __ bind(&done); | 336 __ bind(&done); |
| 332 __ push(ip); | 337 __ push(ip); |
| 333 } | 338 } |
| 334 | 339 |
| 335 | 340 |
| 336 void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { | 341 void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { |
| 337 SetFrameSlot(offset, value); | 342 SetFrameSlot(offset, value); |
| 338 } | 343 } |
| 339 | 344 |
| 340 | 345 |
| 341 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { | 346 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { |
| 342 SetFrameSlot(offset, value); | 347 SetFrameSlot(offset, value); |
| 343 } | 348 } |
| 344 | 349 |
| 345 | 350 |
| 346 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { | 351 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { |
| 352 #if V8_OOL_CONSTANT_POOL |
| 347 DCHECK(FLAG_enable_ool_constant_pool); | 353 DCHECK(FLAG_enable_ool_constant_pool); |
| 348 SetFrameSlot(offset, value); | 354 SetFrameSlot(offset, value); |
| 355 #else |
| 356 // No out-of-line constant pool support. |
| 357 UNREACHABLE(); |
| 358 #endif |
| 349 } | 359 } |
| 350 | 360 |
| 351 | 361 |
| 352 #undef __ | 362 #undef __ |
| 353 | 363 |
| 354 } } // namespace v8::internal | 364 } } // namespace v8::internal |
| OLD | NEW |