| 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 ASSERT(!Serializer::enabled()); // Nbr of d-regs not known at snapshot time. |
| 912 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); | 913 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); |
| 913 DwVfpRegister last = | 914 DwVfpRegister last = DwVfpRegister::FromAllocationIndex( |
| 914 DwVfpRegister::FromAllocationIndex( | 915 DwVfpRegister::NumAllocatableRegisters() - 1); |
| 915 DwVfpRegister::kNumAllocatableRegisters - 1); | |
| 916 ASSERT(last.code() > first.code()); | 916 ASSERT(last.code() > first.code()); |
| 917 ASSERT((last.code() - first.code()) == | |
| 918 (DwVfpRegister::kNumAllocatableRegisters - 1)); | |
| 919 #ifdef DEBUG | 917 #ifdef DEBUG |
| 920 for (int i = 0; i <= (DwVfpRegister::kNumAllocatableRegisters - 1); i++) { | 918 for (int i = 0; i <= (DwVfpRegister::NumAllocatableRegisters() - 1); i++) { |
| 921 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | 919 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && |
| 922 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | 920 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); |
| 923 } | 921 } |
| 924 #endif | 922 #endif |
| 925 __ vstm(db_w, sp, first, last); | 923 if (last.code() > kScratchDoubleReg.code()) { |
| 924 // This happens when we also have d16-d31 available. |
| 925 // Store the registers < ZeroReg and > ScratchReg separately. |
| 926 ASSERT(kScratchDoubleReg.code() == kDoubleRegZero.code() + 1); |
| 927 __ vstm(db_w, sp, DwVfpRegister::from_code( |
| 928 kScratchDoubleReg.code() + 1), last); |
| 929 __ vstm(db_w, sp, first, DwVfpRegister::from_code( |
| 930 kDoubleRegZero.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 23 matching lines...) Expand all Loading... |
| 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). |
| 1030 | 1040 |
| 1041 // TODO(hans): Change the code below to not clobber r0, so that it can be |
| 1042 // used in the "restore the d registers" code further down, making this mov |
| 1043 // redundant. |
| 1044 __ mov(r4, r0); |
| 1045 |
| 1031 // Replace the current (input) frame with the output frames. | 1046 // Replace the current (input) frame with the output frames. |
| 1032 Label outer_push_loop, inner_push_loop; | 1047 Label outer_push_loop, inner_push_loop; |
| 1033 // Outer loop state: r0 = current "FrameDescription** output_", | 1048 // Outer loop state: r0 = current "FrameDescription** output_", |
| 1034 // r1 = one past the last FrameDescription**. | 1049 // r1 = one past the last FrameDescription**. |
| 1035 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 1050 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
| 1036 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. | 1051 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. |
| 1037 __ add(r1, r0, Operand(r1, LSL, 2)); | 1052 __ add(r1, r0, Operand(r1, LSL, 2)); |
| 1038 __ bind(&outer_push_loop); | 1053 __ bind(&outer_push_loop); |
| 1039 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 1054 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
| 1040 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] | 1055 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] |
| 1041 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 1056 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
| 1042 __ bind(&inner_push_loop); | 1057 __ bind(&inner_push_loop); |
| 1043 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 1058 __ sub(r3, r3, Operand(sizeof(uint32_t))); |
| 1044 __ add(r6, r2, Operand(r3)); | 1059 __ add(r6, r2, Operand(r3)); |
| 1045 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); | 1060 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); |
| 1046 __ push(r7); | 1061 __ push(r7); |
| 1047 __ cmp(r3, Operand(0)); | 1062 __ cmp(r3, Operand(0)); |
| 1048 __ b(ne, &inner_push_loop); // test for gt? | 1063 __ b(ne, &inner_push_loop); // test for gt? |
| 1049 __ add(r0, r0, Operand(kPointerSize)); | 1064 __ add(r0, r0, Operand(kPointerSize)); |
| 1050 __ cmp(r0, r1); | 1065 __ cmp(r0, r1); |
| 1051 __ b(lt, &outer_push_loop); | 1066 __ b(lt, &outer_push_loop); |
| 1052 | 1067 |
| 1068 // In case of OSR, we have to restore the d registers. |
| 1069 if (type() == OSR) { |
| 1070 __ ldr(r1, MemOperand(r4, Deoptimizer::input_offset())); |
| 1071 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { |
| 1072 DwVfpRegister reg = DwVfpRegister::FromAllocationIndex(i); |
| 1073 int src_offset = double_regs_offset + i * kDoubleSize; |
| 1074 __ vldr(reg, r1, src_offset); |
| 1075 } |
| 1076 } |
| 1077 |
| 1053 // Push state, pc, and continuation from the last output frame. | 1078 // Push state, pc, and continuation from the last output frame. |
| 1054 if (type() != OSR) { | 1079 if (type() != OSR) { |
| 1055 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 1080 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
| 1056 __ push(r6); | 1081 __ push(r6); |
| 1057 } | 1082 } |
| 1058 | 1083 |
| 1059 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 1084 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
| 1060 __ push(r6); | 1085 __ push(r6); |
| 1061 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); | 1086 __ ldr(r6, MemOperand(r2, FrameDescription::continuation_offset())); |
| 1062 __ push(r6); | 1087 __ push(r6); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 __ push(ip); | 1125 __ push(ip); |
| 1101 __ b(&done); | 1126 __ b(&done); |
| 1102 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1127 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 1103 } | 1128 } |
| 1104 __ bind(&done); | 1129 __ bind(&done); |
| 1105 } | 1130 } |
| 1106 | 1131 |
| 1107 #undef __ | 1132 #undef __ |
| 1108 | 1133 |
| 1109 } } // namespace v8::internal | 1134 } } // namespace v8::internal |
| OLD | NEW |