| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (value == 1) return i; | 199 if (value == 1) return i; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 UNREACHABLE(); | 202 UNREACHABLE(); |
| 203 return -1; | 203 return -1; |
| 204 } | 204 } |
| 205 | 205 |
| 206 | 206 |
| 207 void Deoptimizer::DoComputeOsrOutputFrame() { | 207 void Deoptimizer::DoComputeOsrOutputFrame() { |
| 208 DeoptimizationInputData* data = DeoptimizationInputData::cast( | 208 DeoptimizationInputData* data = DeoptimizationInputData::cast( |
| 209 optimized_code_->deoptimization_data()); | 209 compiled_code_->deoptimization_data()); |
| 210 unsigned ast_id = data->OsrAstId()->value(); | 210 unsigned ast_id = data->OsrAstId()->value(); |
| 211 | 211 |
| 212 int bailout_id = LookupBailoutId(data, BailoutId(ast_id)); | 212 int bailout_id = LookupBailoutId(data, BailoutId(ast_id)); |
| 213 unsigned translation_index = data->TranslationIndex(bailout_id)->value(); | 213 unsigned translation_index = data->TranslationIndex(bailout_id)->value(); |
| 214 ByteArray* translations = data->TranslationByteArray(); | 214 ByteArray* translations = data->TranslationByteArray(); |
| 215 | 215 |
| 216 TranslationIterator iterator(translations, translation_index); | 216 TranslationIterator iterator(translations, translation_index); |
| 217 Translation::Opcode opcode = | 217 Translation::Opcode opcode = |
| 218 static_cast<Translation::Opcode>(iterator.Next()); | 218 static_cast<Translation::Opcode>(iterator.Next()); |
| 219 ASSERT(Translation::BEGIN == opcode); | 219 ASSERT(Translation::BEGIN == opcode); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 233 USE(closure_id); | 233 USE(closure_id); |
| 234 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 234 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
| 235 unsigned height = iterator.Next(); | 235 unsigned height = iterator.Next(); |
| 236 unsigned height_in_bytes = height * kPointerSize; | 236 unsigned height_in_bytes = height * kPointerSize; |
| 237 USE(height_in_bytes); | 237 USE(height_in_bytes); |
| 238 | 238 |
| 239 unsigned fixed_size = ComputeFixedSize(function_); | 239 unsigned fixed_size = ComputeFixedSize(function_); |
| 240 unsigned input_frame_size = input_->GetFrameSize(); | 240 unsigned input_frame_size = input_->GetFrameSize(); |
| 241 ASSERT(fixed_size + height_in_bytes == input_frame_size); | 241 ASSERT(fixed_size + height_in_bytes == input_frame_size); |
| 242 | 242 |
| 243 unsigned stack_slot_size = optimized_code_->stack_slots() * kPointerSize; | 243 unsigned stack_slot_size = compiled_code_->stack_slots() * kPointerSize; |
| 244 unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); | 244 unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); |
| 245 unsigned outgoing_size = outgoing_height * kPointerSize; | 245 unsigned outgoing_size = outgoing_height * kPointerSize; |
| 246 unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; | 246 unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; |
| 247 ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. | 247 ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. |
| 248 | 248 |
| 249 if (FLAG_trace_osr) { | 249 if (FLAG_trace_osr) { |
| 250 PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", | 250 PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", |
| 251 reinterpret_cast<intptr_t>(function_)); | 251 reinterpret_cast<intptr_t>(function_)); |
| 252 function_->PrintName(); | 252 function_->PrintName(); |
| 253 PrintF(" => node=%u, frame=%d->%d]\n", | 253 PrintF(" => node=%u, frame=%d->%d]\n", |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 delete output_[0]; | 325 delete output_[0]; |
| 326 output_[0] = input_; | 326 output_[0] = input_; |
| 327 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); | 327 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); |
| 328 } else { | 328 } else { |
| 329 // Set up the frame pointer and the context pointer. | 329 // Set up the frame pointer and the context pointer. |
| 330 output_[0]->SetRegister(fp.code(), input_->GetRegister(fp.code())); | 330 output_[0]->SetRegister(fp.code(), input_->GetRegister(fp.code())); |
| 331 output_[0]->SetRegister(cp.code(), input_->GetRegister(cp.code())); | 331 output_[0]->SetRegister(cp.code(), input_->GetRegister(cp.code())); |
| 332 | 332 |
| 333 unsigned pc_offset = data->OsrPcOffset()->value(); | 333 unsigned pc_offset = data->OsrPcOffset()->value(); |
| 334 uint32_t pc = reinterpret_cast<uint32_t>( | 334 uint32_t pc = reinterpret_cast<uint32_t>( |
| 335 optimized_code_->entry() + pc_offset); | 335 compiled_code_->entry() + pc_offset); |
| 336 output_[0]->SetPc(pc); | 336 output_[0]->SetPc(pc); |
| 337 } | 337 } |
| 338 Code* continuation = isolate_->builtins()->builtin(Builtins::kNotifyOSR); | 338 Code* continuation = isolate_->builtins()->builtin(Builtins::kNotifyOSR); |
| 339 output_[0]->SetContinuation( | 339 output_[0]->SetContinuation( |
| 340 reinterpret_cast<uint32_t>(continuation->entry())); | 340 reinterpret_cast<uint32_t>(continuation->entry())); |
| 341 | 341 |
| 342 if (FLAG_trace_osr) { | 342 if (FLAG_trace_osr) { |
| 343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", | 343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", |
| 344 ok ? "finished" : "aborted", | 344 ok ? "finished" : "aborted", |
| 345 reinterpret_cast<intptr_t>(function_)); | 345 reinterpret_cast<intptr_t>(function_)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 Builtins* builtins = isolate_->builtins(); | 438 Builtins* builtins = isolate_->builtins(); |
| 439 Code* adaptor_trampoline = | 439 Code* adaptor_trampoline = |
| 440 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); | 440 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); |
| 441 uint32_t pc = reinterpret_cast<uint32_t>( | 441 uint32_t pc = reinterpret_cast<uint32_t>( |
| 442 adaptor_trampoline->instruction_start() + | 442 adaptor_trampoline->instruction_start() + |
| 443 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); | 443 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); |
| 444 output_frame->SetPc(pc); | 444 output_frame->SetPc(pc); |
| 445 } | 445 } |
| 446 | 446 |
| 447 | 447 |
| 448 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, |
| 449 int frame_index) { |
| 450 // |
| 451 // FROM TO <-fp |
| 452 // | .... | | .... | |
| 453 // +-------------------------+ +-------------------------+ |
| 454 // | JSFunction continuation | | JSFunction continuation | |
| 455 // +-------------------------+ +-------------------------+<-sp |
| 456 // | | saved frame (fp) | |
| 457 // | +=========================+<-fp |
| 458 // | | JSFunction context | |
| 459 // v +-------------------------+ |
| 460 // | COMPILED_STUB marker | fp = saved frame |
| 461 // +-------------------------+ f8 = JSFunction context |
| 462 // | | |
| 463 // | ... | |
| 464 // | | |
| 465 // +-------------------------+<-sp |
| 466 // |
| 467 // |
| 468 int output_frame_size = 1 * kPointerSize; |
| 469 FrameDescription* output_frame = |
| 470 new(output_frame_size) FrameDescription(output_frame_size, 0); |
| 471 Code* notify_miss = |
| 472 isolate_->builtins()->builtin(Builtins::kNotifyICMiss); |
| 473 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); |
| 474 output_frame->SetContinuation( |
| 475 reinterpret_cast<intptr_t>(notify_miss->entry())); |
| 476 |
| 477 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); |
| 478 int major_key = compiled_code_->major_key(); |
| 479 CodeStubInterfaceDescriptor* descriptor = |
| 480 isolate_->code_stub_interface_descriptor(major_key); |
| 481 Handle<Code> miss_ic(descriptor->deoptimization_handler_); |
| 482 output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start())); |
| 483 unsigned input_frame_size = input_->GetFrameSize(); |
| 484 intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); |
| 485 output_frame->SetFrameSlot(0, value); |
| 486 value = input_->GetFrameSlot(input_frame_size - 2 * kPointerSize); |
| 487 output_frame->SetRegister(fp.code(), value); |
| 488 output_frame->SetFp(value); |
| 489 value = input_->GetFrameSlot(input_frame_size - 3 * kPointerSize); |
| 490 output_frame->SetRegister(cp.code(), value); |
| 491 |
| 492 Translation::Opcode opcode = |
| 493 static_cast<Translation::Opcode>(iterator->Next()); |
| 494 ASSERT(opcode == Translation::REGISTER); |
| 495 USE(opcode); |
| 496 int input_reg = iterator->Next(); |
| 497 intptr_t input_value = input_->GetRegister(input_reg); |
| 498 output_frame->SetRegister(a1.code(), input_value); |
| 499 |
| 500 int32_t next = iterator->Next(); |
| 501 opcode = static_cast<Translation::Opcode>(next); |
| 502 ASSERT(opcode == Translation::REGISTER); |
| 503 input_reg = iterator->Next(); |
| 504 input_value = input_->GetRegister(input_reg); |
| 505 output_frame->SetRegister(a0.code(), input_value); |
| 506 |
| 507 ASSERT(frame_index == 0); |
| 508 output_[frame_index] = output_frame; |
| 509 } |
| 510 |
| 511 |
| 448 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 512 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
| 449 int frame_index) { | 513 int frame_index) { |
| 450 Builtins* builtins = isolate_->builtins(); | 514 Builtins* builtins = isolate_->builtins(); |
| 451 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 515 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); |
| 452 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 516 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 453 unsigned height = iterator->Next(); | 517 unsigned height = iterator->Next(); |
| 454 unsigned height_in_bytes = height * kPointerSize; | 518 unsigned height_in_bytes = height * kPointerSize; |
| 455 if (FLAG_trace_deopt) { | 519 if (FLAG_trace_deopt) { |
| 456 PrintF(" translating construct stub => height=%d\n", height_in_bytes); | 520 PrintF(" translating construct stub => height=%d\n", height_in_bytes); |
| 457 } | 521 } |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 925 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
| 862 // Set the register values. The values are not important as there are no | 926 // Set the register values. The values are not important as there are no |
| 863 // callee saved registers in JavaScript frames, so all registers are | 927 // callee saved registers in JavaScript frames, so all registers are |
| 864 // spilled. Registers fp and sp are set to the correct values though. | 928 // spilled. Registers fp and sp are set to the correct values though. |
| 865 | 929 |
| 866 for (int i = 0; i < Register::kNumRegisters; i++) { | 930 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 867 input_->SetRegister(i, i * 4); | 931 input_->SetRegister(i, i * 4); |
| 868 } | 932 } |
| 869 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 933 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
| 870 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 934 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 871 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; i++) { | 935 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { |
| 872 input_->SetDoubleRegister(i, 0.0); | 936 input_->SetDoubleRegister(i, 0.0); |
| 873 } | 937 } |
| 874 | 938 |
| 875 // Fill the frame content from the actual data on the frame. | 939 // Fill the frame content from the actual data on the frame. |
| 876 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 940 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
| 877 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); | 941 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
| 878 } | 942 } |
| 879 } | 943 } |
| 880 | 944 |
| 881 | 945 |
| 882 #define __ masm()-> | 946 #define __ masm()-> |
| 883 | 947 |
| 884 | 948 |
| 885 // This code tries to be close to ia32 code so that any changes can be | 949 // This code tries to be close to ia32 code so that any changes can be |
| 886 // easily ported. | 950 // easily ported. |
| 887 void Deoptimizer::EntryGenerator::Generate() { | 951 void Deoptimizer::EntryGenerator::Generate() { |
| 888 GeneratePrologue(); | 952 GeneratePrologue(); |
| 889 | 953 |
| 890 Isolate* isolate = masm()->isolate(); | 954 Isolate* isolate = masm()->isolate(); |
| 891 | 955 |
| 892 CpuFeatures::Scope scope(FPU); | |
| 893 // Unlike on ARM we don't save all the registers, just the useful ones. | 956 // Unlike on ARM we don't save all the registers, just the useful ones. |
| 894 // For the rest, there are gaps on the stack, so the offsets remain the same. | 957 // For the rest, there are gaps on the stack, so the offsets remain the same. |
| 895 const int kNumberOfRegisters = Register::kNumRegisters; | 958 const int kNumberOfRegisters = Register::kNumRegisters; |
| 896 | 959 |
| 897 RegList restored_regs = kJSCallerSaved | kCalleeSaved; | 960 RegList restored_regs = kJSCallerSaved | kCalleeSaved; |
| 898 RegList saved_regs = restored_regs | sp.bit() | ra.bit(); | 961 RegList saved_regs = restored_regs | sp.bit() | ra.bit(); |
| 899 | 962 |
| 900 const int kDoubleRegsSize = | 963 const int kDoubleRegsSize = |
| 901 kDoubleSize * FPURegister::kNumAllocatableRegisters; | 964 kDoubleSize * FPURegister::kMaxNumAllocatableRegisters; |
| 902 | 965 |
| 903 // Save all FPU registers before messing with them. | 966 if (CpuFeatures::IsSupported(FPU)) { |
| 904 __ Subu(sp, sp, Operand(kDoubleRegsSize)); | 967 CpuFeatures::Scope scope(FPU); |
| 905 for (int i = 0; i < FPURegister::kNumAllocatableRegisters; ++i) { | 968 // Save all FPU registers before messing with them. |
| 906 FPURegister fpu_reg = FPURegister::FromAllocationIndex(i); | 969 __ Subu(sp, sp, Operand(kDoubleRegsSize)); |
| 907 int offset = i * kDoubleSize; | 970 for (int i = 0; i < FPURegister::kMaxNumAllocatableRegisters; ++i) { |
| 908 __ sdc1(fpu_reg, MemOperand(sp, offset)); | 971 FPURegister fpu_reg = FPURegister::FromAllocationIndex(i); |
| 972 int offset = i * kDoubleSize; |
| 973 __ sdc1(fpu_reg, MemOperand(sp, offset)); |
| 974 } |
| 975 } else { |
| 976 __ Subu(sp, sp, Operand(kDoubleRegsSize)); |
| 909 } | 977 } |
| 910 | 978 |
| 911 // Push saved_regs (needed to populate FrameDescription::registers_). | 979 // Push saved_regs (needed to populate FrameDescription::registers_). |
| 912 // Leave gaps for other registers. | 980 // Leave gaps for other registers. |
| 913 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize); | 981 __ Subu(sp, sp, kNumberOfRegisters * kPointerSize); |
| 914 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { | 982 for (int16_t i = kNumberOfRegisters - 1; i >= 0; i--) { |
| 915 if ((saved_regs & (1 << i)) != 0) { | 983 if ((saved_regs & (1 << i)) != 0) { |
| 916 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i)); | 984 __ sw(ToRegister(i), MemOperand(sp, kPointerSize * i)); |
| 917 } | 985 } |
| 918 } | 986 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 1038 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
| 971 if ((saved_regs & (1 << i)) != 0) { | 1039 if ((saved_regs & (1 << i)) != 0) { |
| 972 __ lw(a2, MemOperand(sp, i * kPointerSize)); | 1040 __ lw(a2, MemOperand(sp, i * kPointerSize)); |
| 973 __ sw(a2, MemOperand(a1, offset)); | 1041 __ sw(a2, MemOperand(a1, offset)); |
| 974 } else if (FLAG_debug_code) { | 1042 } else if (FLAG_debug_code) { |
| 975 __ li(a2, kDebugZapValue); | 1043 __ li(a2, kDebugZapValue); |
| 976 __ sw(a2, MemOperand(a1, offset)); | 1044 __ sw(a2, MemOperand(a1, offset)); |
| 977 } | 1045 } |
| 978 } | 1046 } |
| 979 | 1047 |
| 980 // Copy FPU registers to | 1048 if (CpuFeatures::IsSupported(FPU)) { |
| 981 // double_registers_[DoubleRegister::kNumAllocatableRegisters] | 1049 CpuFeatures::Scope scope(FPU); |
| 982 int double_regs_offset = FrameDescription::double_registers_offset(); | 1050 // Copy FPU registers to |
| 983 for (int i = 0; i < FPURegister::kNumAllocatableRegisters; ++i) { | 1051 // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
| 984 int dst_offset = i * kDoubleSize + double_regs_offset; | 1052 int double_regs_offset = FrameDescription::double_registers_offset(); |
| 985 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 1053 for (int i = 0; i < FPURegister::NumAllocatableRegisters(); ++i) { |
| 986 __ ldc1(f0, MemOperand(sp, src_offset)); | 1054 int dst_offset = i * kDoubleSize + double_regs_offset; |
| 987 __ sdc1(f0, MemOperand(a1, dst_offset)); | 1055 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
| 1056 __ ldc1(f0, MemOperand(sp, src_offset)); |
| 1057 __ sdc1(f0, MemOperand(a1, dst_offset)); |
| 1058 } |
| 988 } | 1059 } |
| 989 | 1060 |
| 990 // Remove the bailout id, eventually return address, and the saved registers | 1061 // Remove the bailout id, eventually return address, and the saved registers |
| 991 // from the stack. | 1062 // from the stack. |
| 992 if (type() == EAGER || type() == OSR) { | 1063 if (type() == EAGER || type() == OSR) { |
| 993 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 1064 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
| 994 } else { | 1065 } else { |
| 995 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize))); | 1066 __ Addu(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize))); |
| 996 } | 1067 } |
| 997 | 1068 |
| 998 // Compute a pointer to the unwinding limit in register a2; that is | 1069 // Compute a pointer to the unwinding limit in register a2; that is |
| 999 // the first stack slot not part of the input frame. | 1070 // the first stack slot not part of the input frame. |
| 1000 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset())); | 1071 __ lw(a2, MemOperand(a1, FrameDescription::frame_size_offset())); |
| 1001 __ Addu(a2, a2, sp); | 1072 __ Addu(a2, a2, sp); |
| 1002 | 1073 |
| 1003 // Unwind the stack down to - but not including - the unwinding | 1074 // Unwind the stack down to - but not including - the unwinding |
| 1004 // limit and copy the contents of the activation frame to the input | 1075 // limit and copy the contents of the activation frame to the input |
| 1005 // frame description. | 1076 // frame description. |
| 1006 __ Addu(a3, a1, Operand(FrameDescription::frame_content_offset())); | 1077 __ Addu(a3, a1, Operand(FrameDescription::frame_content_offset())); |
| 1007 Label pop_loop; | 1078 Label pop_loop; |
| 1079 Label pop_loop_header; |
| 1080 __ Branch(&pop_loop_header); |
| 1008 __ bind(&pop_loop); | 1081 __ bind(&pop_loop); |
| 1009 __ pop(t0); | 1082 __ pop(t0); |
| 1010 __ sw(t0, MemOperand(a3, 0)); | 1083 __ sw(t0, MemOperand(a3, 0)); |
| 1011 __ Branch(USE_DELAY_SLOT, &pop_loop, ne, a2, Operand(sp)); | 1084 __ addiu(a3, a3, sizeof(uint32_t)); |
| 1012 __ addiu(a3, a3, sizeof(uint32_t)); // In delay slot. | 1085 __ bind(&pop_loop_header); |
| 1086 __ Branch(&pop_loop, ne, a2, Operand(sp)); |
| 1013 | 1087 |
| 1014 // Compute the output frame in the deoptimizer. | 1088 // Compute the output frame in the deoptimizer. |
| 1015 __ push(a0); // Preserve deoptimizer object across call. | 1089 __ push(a0); // Preserve deoptimizer object across call. |
| 1016 // a0: deoptimizer object; a1: scratch. | 1090 // a0: deoptimizer object; a1: scratch. |
| 1017 __ PrepareCallCFunction(1, a1); | 1091 __ PrepareCallCFunction(1, a1); |
| 1018 // Call Deoptimizer::ComputeOutputFrames(). | 1092 // Call Deoptimizer::ComputeOutputFrames(). |
| 1019 { | 1093 { |
| 1020 AllowExternalCallThatCantCauseGC scope(masm()); | 1094 AllowExternalCallThatCantCauseGC scope(masm()); |
| 1021 __ CallCFunction( | 1095 __ CallCFunction( |
| 1022 ExternalReference::compute_output_frames_function(isolate), 1); | 1096 ExternalReference::compute_output_frames_function(isolate), 1); |
| 1023 } | 1097 } |
| 1024 __ pop(a0); // Restore deoptimizer object (class Deoptimizer). | 1098 __ pop(a0); // Restore deoptimizer object (class Deoptimizer). |
| 1025 | 1099 |
| 1026 // Replace the current (input) frame with the output frames. | 1100 // Replace the current (input) frame with the output frames. |
| 1027 Label outer_push_loop, inner_push_loop; | 1101 Label outer_push_loop, inner_push_loop, |
| 1102 outer_loop_header, inner_loop_header; |
| 1028 // Outer loop state: a0 = current "FrameDescription** output_", | 1103 // Outer loop state: a0 = current "FrameDescription** output_", |
| 1029 // a1 = one past the last FrameDescription**. | 1104 // a1 = one past the last FrameDescription**. |
| 1030 __ lw(a1, MemOperand(a0, Deoptimizer::output_count_offset())); | 1105 __ lw(a1, MemOperand(a0, Deoptimizer::output_count_offset())); |
| 1031 __ lw(a0, MemOperand(a0, Deoptimizer::output_offset())); // a0 is output_. | 1106 __ lw(a0, MemOperand(a0, Deoptimizer::output_offset())); // a0 is output_. |
| 1032 __ sll(a1, a1, kPointerSizeLog2); // Count to offset. | 1107 __ sll(a1, a1, kPointerSizeLog2); // Count to offset. |
| 1033 __ addu(a1, a0, a1); // a1 = one past the last FrameDescription**. | 1108 __ addu(a1, a0, a1); // a1 = one past the last FrameDescription**. |
| 1109 __ jmp(&outer_loop_header); |
| 1034 __ bind(&outer_push_loop); | 1110 __ bind(&outer_push_loop); |
| 1035 // Inner loop state: a2 = current FrameDescription*, a3 = loop index. | 1111 // Inner loop state: a2 = current FrameDescription*, a3 = loop index. |
| 1036 __ lw(a2, MemOperand(a0, 0)); // output_[ix] | 1112 __ lw(a2, MemOperand(a0, 0)); // output_[ix] |
| 1037 __ lw(a3, MemOperand(a2, FrameDescription::frame_size_offset())); | 1113 __ lw(a3, MemOperand(a2, FrameDescription::frame_size_offset())); |
| 1114 __ jmp(&inner_loop_header); |
| 1038 __ bind(&inner_push_loop); | 1115 __ bind(&inner_push_loop); |
| 1039 __ Subu(a3, a3, Operand(sizeof(uint32_t))); | 1116 __ Subu(a3, a3, Operand(sizeof(uint32_t))); |
| 1040 __ Addu(t2, a2, Operand(a3)); | 1117 __ Addu(t2, a2, Operand(a3)); |
| 1041 __ lw(t3, MemOperand(t2, FrameDescription::frame_content_offset())); | 1118 __ lw(t3, MemOperand(t2, FrameDescription::frame_content_offset())); |
| 1042 __ push(t3); | 1119 __ push(t3); |
| 1120 __ bind(&inner_loop_header); |
| 1043 __ Branch(&inner_push_loop, ne, a3, Operand(zero_reg)); | 1121 __ Branch(&inner_push_loop, ne, a3, Operand(zero_reg)); |
| 1044 | 1122 |
| 1045 __ Addu(a0, a0, Operand(kPointerSize)); | 1123 __ Addu(a0, a0, Operand(kPointerSize)); |
| 1124 __ bind(&outer_loop_header); |
| 1046 __ Branch(&outer_push_loop, lt, a0, Operand(a1)); | 1125 __ Branch(&outer_push_loop, lt, a0, Operand(a1)); |
| 1047 | 1126 |
| 1048 | 1127 |
| 1049 // Push state, pc, and continuation from the last output frame. | 1128 // Push state, pc, and continuation from the last output frame. |
| 1050 if (type() != OSR) { | 1129 if (type() != OSR) { |
| 1051 __ lw(t2, MemOperand(a2, FrameDescription::state_offset())); | 1130 __ lw(t2, MemOperand(a2, FrameDescription::state_offset())); |
| 1052 __ push(t2); | 1131 __ push(t2); |
| 1053 } | 1132 } |
| 1054 | 1133 |
| 1055 __ lw(t2, MemOperand(a2, FrameDescription::pc_offset())); | 1134 __ lw(t2, MemOperand(a2, FrameDescription::pc_offset())); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 } | 1197 } |
| 1119 | 1198 |
| 1120 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), | 1199 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), |
| 1121 count() * table_entry_size_); | 1200 count() * table_entry_size_); |
| 1122 } | 1201 } |
| 1123 | 1202 |
| 1124 #undef __ | 1203 #undef __ |
| 1125 | 1204 |
| 1126 | 1205 |
| 1127 } } // namespace v8::internal | 1206 } } // namespace v8::internal |
| OLD | NEW |