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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
871 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 871 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
872 // Set the register values. The values are not important as there are no | 872 // Set the register values. The values are not important as there are no |
873 // callee saved registers in JavaScript frames, so all registers are | 873 // callee saved registers in JavaScript frames, so all registers are |
874 // spilled. Registers fp and sp are set to the correct values though. | 874 // spilled. Registers fp and sp are set to the correct values though. |
875 | 875 |
876 for (int i = 0; i < Register::kNumRegisters; i++) { | 876 for (int i = 0; i < Register::kNumRegisters; i++) { |
877 input_->SetRegister(i, i * 4); | 877 input_->SetRegister(i, i * 4); |
878 } | 878 } |
879 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 879 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
880 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 880 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
881 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; i++) { | 881 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { |
882 input_->SetDoubleRegister(i, 0.0); | 882 input_->SetDoubleRegister(i, 0.0); |
883 } | 883 } |
884 | 884 |
885 // Fill the frame content from the actual data on the frame. | 885 // Fill the frame content from the actual data on the frame. |
886 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 886 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
887 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); | 887 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
888 } | 888 } |
889 } | 889 } |
890 | 890 |
891 | 891 |
892 #define __ masm()-> | 892 #define __ masm()-> |
893 | 893 |
894 // This code tries to be close to ia32 code so that any changes can be | 894 // This code tries to be close to ia32 code so that any changes can be |
895 // easily ported. | 895 // easily ported. |
896 void Deoptimizer::EntryGenerator::Generate() { | 896 void Deoptimizer::EntryGenerator::Generate() { |
897 GeneratePrologue(); | 897 GeneratePrologue(); |
898 | 898 |
899 Isolate* isolate = masm()->isolate(); | 899 Isolate* isolate = masm()->isolate(); |
900 | 900 |
901 CpuFeatures::Scope scope(VFP3); | 901 CpuFeatures::Scope scope(VFP3); |
902 // Save all general purpose registers before messing with them. | 902 // Save all general purpose registers before messing with them. |
903 const int kNumberOfRegisters = Register::kNumRegisters; | 903 const int kNumberOfRegisters = Register::kNumRegisters; |
904 | 904 |
905 // Everything but pc, lr and ip which will be saved but not restored. | 905 // Everything but pc, lr and ip which will be saved but not restored. |
906 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); | 906 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); |
907 | 907 |
908 const int kDoubleRegsSize = | 908 const int kDoubleRegsSize = |
909 kDoubleSize * DwVfpRegister::kNumAllocatableRegisters; | 909 kDoubleSize * DwVfpRegister::NumAllocatableRegisters(); |
910 | 910 |
911 // Save all VFP registers before messing with them. | 911 // Save all VFP registers before messing with them. |
912 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); | 912 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); |
913 DwVfpRegister last = | 913 DwVfpRegister last = DwVfpRegister::FromAllocationIndex( |
914 DwVfpRegister::FromAllocationIndex( | 914 DwVfpRegister::NumAllocatableRegisters() - 1); |
915 DwVfpRegister::kNumAllocatableRegisters - 1); | |
916 ASSERT(last.code() > first.code()); | 915 ASSERT(last.code() > first.code()); |
917 ASSERT((last.code() - first.code()) == | |
918 (DwVfpRegister::kNumAllocatableRegisters - 1)); | |
919 #ifdef DEBUG | 916 #ifdef DEBUG |
920 for (int i = 0; i <= (DwVfpRegister::kNumAllocatableRegisters - 1); i++) { | 917 for (int i = 0; i <= (DwVfpRegister::NumAllocatableRegisters() - 1); i++) { |
921 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | 918 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && |
922 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | 919 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); |
923 } | 920 } |
924 #endif | 921 #endif |
925 __ vstm(db_w, sp, first, last); | 922 if (last.code() > DwVfpRegister::ScratchReg().code()) { |
923 // This happens when we also have d16-d31 available. | |
924 // Store the registers < ZeroReg and > ScratchReg separately. | |
925 ASSERT(DwVfpRegister::ScratchReg().code() == | |
926 DwVfpRegister::ZeroReg().code() + 1); | |
927 __ vstm(db_w, sp, DwVfpRegister::from_code( | |
928 DwVfpRegister::ScratchReg().code() + 1), last); | |
929 __ vstm(db_w, sp, first, DwVfpRegister::from_code( | |
930 DwVfpRegister::ZeroReg().code() - 1)); | |
931 } else { | |
932 ASSERT(last.code() - first.code() == | |
933 DwVfpRegister::NumAllocatableRegisters() - 1); | |
934 __ vstm(db_w, sp, first, last); | |
935 } | |
926 | 936 |
927 // Push all 16 registers (needed to populate FrameDescription::registers_). | 937 // Push all 16 registers (needed to populate FrameDescription::registers_). |
928 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps | 938 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
929 // handle this a bit differently. | 939 // handle this a bit differently. |
930 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | 940 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
931 | 941 |
932 const int kSavedRegistersAreaSize = | 942 const int kSavedRegistersAreaSize = |
933 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 943 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; |
934 | 944 |
935 // Get the bailout id from the stack. | 945 // Get the bailout id from the stack. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 ASSERT(Register::kNumRegisters == kNumberOfRegisters); | 987 ASSERT(Register::kNumRegisters == kNumberOfRegisters); |
978 for (int i = 0; i < kNumberOfRegisters; i++) { | 988 for (int i = 0; i < kNumberOfRegisters; i++) { |
979 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 989 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
980 __ ldr(r2, MemOperand(sp, i * kPointerSize)); | 990 __ ldr(r2, MemOperand(sp, i * kPointerSize)); |
981 __ str(r2, MemOperand(r1, offset)); | 991 __ str(r2, MemOperand(r1, offset)); |
982 } | 992 } |
983 | 993 |
984 // Copy VFP registers to | 994 // Copy VFP registers to |
985 // double_registers_[DoubleRegister::kNumAllocatableRegisters] | 995 // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
986 int double_regs_offset = FrameDescription::double_registers_offset(); | 996 int double_regs_offset = FrameDescription::double_registers_offset(); |
987 for (int i = 0; i < DwVfpRegister::kNumAllocatableRegisters; ++i) { | 997 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { |
988 int dst_offset = i * kDoubleSize + double_regs_offset; | 998 int dst_offset = i * kDoubleSize + double_regs_offset; |
989 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 999 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
990 __ vldr(d0, sp, src_offset); | 1000 __ vldr(d0, sp, src_offset); |
991 __ vstr(d0, r1, dst_offset); | 1001 __ vstr(d0, r1, dst_offset); |
992 } | 1002 } |
993 | 1003 |
994 // Remove the bailout id, eventually return address, and the saved registers | 1004 // Remove the bailout id, eventually return address, and the saved registers |
995 // from the stack. | 1005 // from the stack. |
996 if (type() == EAGER || type() == OSR) { | 1006 if (type() == EAGER || type() == OSR) { |
997 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 1007 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
(...skipping 22 matching lines...) Expand all Loading... | |
1020 __ push(r0); // Preserve deoptimizer object across call. | 1030 __ push(r0); // Preserve deoptimizer object across call. |
1021 // r0: deoptimizer object; r1: scratch. | 1031 // r0: deoptimizer object; r1: scratch. |
1022 __ PrepareCallCFunction(1, r1); | 1032 __ PrepareCallCFunction(1, r1); |
1023 // Call Deoptimizer::ComputeOutputFrames(). | 1033 // Call Deoptimizer::ComputeOutputFrames(). |
1024 { | 1034 { |
1025 AllowExternalCallThatCantCauseGC scope(masm()); | 1035 AllowExternalCallThatCantCauseGC scope(masm()); |
1026 __ CallCFunction( | 1036 __ CallCFunction( |
1027 ExternalReference::compute_output_frames_function(isolate), 1); | 1037 ExternalReference::compute_output_frames_function(isolate), 1); |
1028 } | 1038 } |
1029 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). | 1039 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). |
1040 __ mov(r4, r0); | |
Rodolph Perfetta
2012/12/12 14:29:15
minor tweak: the code below could be rewritten not
hans
2012/12/12 17:58:47
Is it OK if I note this in a TODO instead, so as t
| |
1030 | 1041 |
1031 // Replace the current (input) frame with the output frames. | 1042 // Replace the current (input) frame with the output frames. |
1032 Label outer_push_loop, inner_push_loop; | 1043 Label outer_push_loop, inner_push_loop; |
1033 // Outer loop state: r0 = current "FrameDescription** output_", | 1044 // Outer loop state: r0 = current "FrameDescription** output_", |
1034 // r1 = one past the last FrameDescription**. | 1045 // r1 = one past the last FrameDescription**. |
1035 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 1046 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
1036 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. | 1047 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. |
1037 __ add(r1, r0, Operand(r1, LSL, 2)); | 1048 __ add(r1, r0, Operand(r1, LSL, 2)); |
1038 __ bind(&outer_push_loop); | 1049 __ bind(&outer_push_loop); |
1039 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 1050 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
1040 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] | 1051 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] |
1041 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 1052 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
1042 __ bind(&inner_push_loop); | 1053 __ bind(&inner_push_loop); |
1043 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 1054 __ sub(r3, r3, Operand(sizeof(uint32_t))); |
1044 __ add(r6, r2, Operand(r3)); | 1055 __ add(r6, r2, Operand(r3)); |
1045 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); | 1056 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); |
1046 __ push(r7); | 1057 __ push(r7); |
1047 __ cmp(r3, Operand(0)); | 1058 __ cmp(r3, Operand(0)); |
1048 __ b(ne, &inner_push_loop); // test for gt? | 1059 __ b(ne, &inner_push_loop); // test for gt? |
1049 __ add(r0, r0, Operand(kPointerSize)); | 1060 __ add(r0, r0, Operand(kPointerSize)); |
1050 __ cmp(r0, r1); | 1061 __ cmp(r0, r1); |
1051 __ b(lt, &outer_push_loop); | 1062 __ b(lt, &outer_push_loop); |
1052 | 1063 |
1064 // In case of OSR, we have to restore the d registers. | |
1065 if (type() == OSR) { | |
1066 __ ldr(r1, MemOperand(r4, Deoptimizer::input_offset())); | |
1067 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { | |
1068 DwVfpRegister reg = DwVfpRegister::FromAllocationIndex(i); | |
1069 int src_offset = double_regs_offset + i * kDoubleSize; | |
1070 __ vldr(reg, r1, src_offset); | |
1071 } | |
1072 } | |
1073 | |
1053 // Push state, pc, and continuation from the last output frame. | 1074 // Push state, pc, and continuation from the last output frame. |
1054 if (type() != OSR) { | 1075 if (type() != OSR) { |
1055 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 1076 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
1056 __ push(r6); | 1077 __ push(r6); |
1057 } | 1078 } |
1058 | 1079 |
1059 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 1080 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
1060 __ push(r6); | 1081 __ push(r6); |
1061 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); | 1082 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); |
1062 __ push(r6); | 1083 __ push(r6); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1100 __ push(ip); | 1121 __ push(ip); |
1101 __ b(&done); | 1122 __ b(&done); |
1102 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1123 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
1103 } | 1124 } |
1104 __ bind(&done); | 1125 __ bind(&done); |
1105 } | 1126 } |
1106 | 1127 |
1107 #undef __ | 1128 #undef __ |
1108 | 1129 |
1109 } } // namespace v8::internal | 1130 } } // namespace v8::internal |
OLD | NEW |