| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 #define __ masm()-> | 141 #define __ masm()-> |
| 142 | 142 |
| 143 void Deoptimizer::EntryGenerator::Generate() { | 143 void Deoptimizer::EntryGenerator::Generate() { |
| 144 GeneratePrologue(); | 144 GeneratePrologue(); |
| 145 | 145 |
| 146 // TODO(all): This code needs to be revisited. We probably only need to save | 146 // TODO(all): This code needs to be revisited. We probably only need to save |
| 147 // caller-saved registers here. Callee-saved registers can be stored directly | 147 // caller-saved registers here. Callee-saved registers can be stored directly |
| 148 // in the input frame. | 148 // in the input frame. |
| 149 | 149 |
| 150 // Save all allocatable floating point registers. | 150 // Save all allocatable floating point registers. |
| 151 CPURegList saved_fp_registers(CPURegister::kFPRegister, kDRegSize, | 151 CPURegList saved_fp_registers(CPURegister::kFPRegister, kDRegSizeInBits, |
| 152 0, FPRegister::NumAllocatableRegisters() - 1); | 152 FPRegister::kAllocatableFPRegisters); |
| 153 __ PushCPURegList(saved_fp_registers); | 153 __ PushCPURegList(saved_fp_registers); |
| 154 | 154 |
| 155 // We save all the registers expcept jssp, sp and lr. | 155 // We save all the registers expcept jssp, sp and lr. |
| 156 CPURegList saved_registers(CPURegister::kRegister, kXRegSize, 0, 27); | 156 CPURegList saved_registers(CPURegister::kRegister, kXRegSizeInBits, 0, 27); |
| 157 saved_registers.Combine(fp); | 157 saved_registers.Combine(fp); |
| 158 __ PushCPURegList(saved_registers); | 158 __ PushCPURegList(saved_registers); |
| 159 | 159 |
| 160 const int kSavedRegistersAreaSize = | 160 const int kSavedRegistersAreaSize = |
| 161 (saved_registers.Count() * kXRegSizeInBytes) + | 161 (saved_registers.Count() * kXRegSize) + |
| 162 (saved_fp_registers.Count() * kDRegSizeInBytes); | 162 (saved_fp_registers.Count() * kDRegSize); |
| 163 | 163 |
| 164 // Floating point registers are saved on the stack above core registers. | 164 // Floating point registers are saved on the stack above core registers. |
| 165 const int kFPRegistersOffset = saved_registers.Count() * kXRegSizeInBytes; | 165 const int kFPRegistersOffset = saved_registers.Count() * kXRegSize; |
| 166 | 166 |
| 167 // Get the bailout id from the stack. | 167 // Get the bailout id from the stack. |
| 168 Register bailout_id = x2; | 168 Register bailout_id = x2; |
| 169 __ Peek(bailout_id, kSavedRegistersAreaSize); | 169 __ Peek(bailout_id, kSavedRegistersAreaSize); |
| 170 | 170 |
| 171 Register code_object = x3; | 171 Register code_object = x3; |
| 172 Register fp_to_sp = x4; | 172 Register fp_to_sp = x4; |
| 173 // Get the address of the location in the code object. This is the return | 173 // Get the address of the location in the code object. This is the return |
| 174 // address for lazy deoptimization. | 174 // address for lazy deoptimization. |
| 175 __ Mov(code_object, lr); | 175 __ Mov(code_object, lr); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 for (int i = 0; i < saved_fp_registers.Count(); i++) { | 214 for (int i = 0; i < saved_fp_registers.Count(); i++) { |
| 215 // TODO(all): Look for opportunities to optimize this by using ldp/stp. | 215 // TODO(all): Look for opportunities to optimize this by using ldp/stp. |
| 216 int dst_offset = FrameDescription::double_registers_offset() + | 216 int dst_offset = FrameDescription::double_registers_offset() + |
| 217 (i * kDoubleSize); | 217 (i * kDoubleSize); |
| 218 int src_offset = kFPRegistersOffset + (i * kDoubleSize); | 218 int src_offset = kFPRegistersOffset + (i * kDoubleSize); |
| 219 __ Peek(x2, src_offset); | 219 __ Peek(x2, src_offset); |
| 220 __ Str(x2, MemOperand(x1, dst_offset)); | 220 __ Str(x2, MemOperand(x1, dst_offset)); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // Remove the bailout id and the saved registers from the stack. | 223 // Remove the bailout id and the saved registers from the stack. |
| 224 __ Drop(1 + (kSavedRegistersAreaSize / kXRegSizeInBytes)); | 224 __ Drop(1 + (kSavedRegistersAreaSize / kXRegSize)); |
| 225 | 225 |
| 226 // Compute a pointer to the unwinding limit in register x2; that is | 226 // Compute a pointer to the unwinding limit in register x2; that is |
| 227 // the first stack slot not part of the input frame. | 227 // the first stack slot not part of the input frame. |
| 228 Register unwind_limit = x2; | 228 Register unwind_limit = x2; |
| 229 __ Ldr(unwind_limit, MemOperand(x1, FrameDescription::frame_size_offset())); | 229 __ Ldr(unwind_limit, MemOperand(x1, FrameDescription::frame_size_offset())); |
| 230 __ Add(unwind_limit, unwind_limit, __ StackPointer()); | 230 __ Add(unwind_limit, unwind_limit, __ StackPointer()); |
| 231 | 231 |
| 232 // Unwind the stack down to - but not including - the unwinding | 232 // Unwind the stack down to - but not including - the unwinding |
| 233 // limit and copy the contents of the activation frame to the input | 233 // limit and copy the contents of the activation frame to the input |
| 234 // frame description. | 234 // frame description. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 __ Br(continuation); | 333 __ Br(continuation); |
| 334 } | 334 } |
| 335 | 335 |
| 336 | 336 |
| 337 // Size of an entry of the second level deopt table. | 337 // Size of an entry of the second level deopt table. |
| 338 // This is the code size generated by GeneratePrologue for one entry. | 338 // This is the code size generated by GeneratePrologue for one entry. |
| 339 const int Deoptimizer::table_entry_size_ = 2 * kInstructionSize; | 339 const int Deoptimizer::table_entry_size_ = 2 * kInstructionSize; |
| 340 | 340 |
| 341 | 341 |
| 342 void Deoptimizer::TableEntryGenerator::GeneratePrologue() { | 342 void Deoptimizer::TableEntryGenerator::GeneratePrologue() { |
| 343 UseScratchRegisterScope temps(masm()); |
| 344 Register entry_id = temps.AcquireX(); |
| 345 |
| 343 // Create a sequence of deoptimization entries. | 346 // Create a sequence of deoptimization entries. |
| 344 // Note that registers are still live when jumping to an entry. | 347 // Note that registers are still live when jumping to an entry. |
| 345 Label done; | 348 Label done; |
| 346 { | 349 { |
| 347 InstructionAccurateScope scope(masm()); | 350 InstructionAccurateScope scope(masm()); |
| 348 | 351 |
| 349 // The number of entry will never exceed kMaxNumberOfEntries. | 352 // The number of entry will never exceed kMaxNumberOfEntries. |
| 350 // As long as kMaxNumberOfEntries is a valid 16 bits immediate you can use | 353 // As long as kMaxNumberOfEntries is a valid 16 bits immediate you can use |
| 351 // a movz instruction to load the entry id. | 354 // a movz instruction to load the entry id. |
| 352 ASSERT(is_uint16(Deoptimizer::kMaxNumberOfEntries)); | 355 ASSERT(is_uint16(Deoptimizer::kMaxNumberOfEntries)); |
| 353 | 356 |
| 354 for (int i = 0; i < count(); i++) { | 357 for (int i = 0; i < count(); i++) { |
| 355 int start = masm()->pc_offset(); | 358 int start = masm()->pc_offset(); |
| 356 USE(start); | 359 USE(start); |
| 357 __ movz(masm()->Tmp0(), i); | 360 __ movz(entry_id, i); |
| 358 __ b(&done); | 361 __ b(&done); |
| 359 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 362 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 360 } | 363 } |
| 361 } | 364 } |
| 362 __ Bind(&done); | 365 __ Bind(&done); |
| 363 // TODO(all): We need to add some kind of assertion to verify that Tmp0() | 366 __ Push(entry_id); |
| 364 // is not clobbered by Push. | |
| 365 __ Push(masm()->Tmp0()); | |
| 366 } | 367 } |
| 367 | 368 |
| 368 | 369 |
| 369 void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { | 370 void FrameDescription::SetCallerPc(unsigned offset, intptr_t value) { |
| 370 SetFrameSlot(offset, value); | 371 SetFrameSlot(offset, value); |
| 371 } | 372 } |
| 372 | 373 |
| 373 | 374 |
| 374 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { | 375 void FrameDescription::SetCallerFp(unsigned offset, intptr_t value) { |
| 375 SetFrameSlot(offset, value); | 376 SetFrameSlot(offset, value); |
| 376 } | 377 } |
| 377 | 378 |
| 378 | 379 |
| 380 void FrameDescription::SetCallerConstantPool(unsigned offset, intptr_t value) { |
| 381 // No out-of-line constant pool support. |
| 382 UNREACHABLE(); |
| 383 } |
| 384 |
| 385 |
| 379 #undef __ | 386 #undef __ |
| 380 | 387 |
| 381 } } // namespace v8::internal | 388 } } // namespace v8::internal |
| OLD | NEW |