Chromium Code Reviews| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 Builtins* builtins = isolate_->builtins(); | 454 Builtins* builtins = isolate_->builtins(); |
| 455 Code* adaptor_trampoline = | 455 Code* adaptor_trampoline = |
| 456 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); | 456 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); |
| 457 uint32_t pc = reinterpret_cast<uint32_t>( | 457 uint32_t pc = reinterpret_cast<uint32_t>( |
| 458 adaptor_trampoline->instruction_start() + | 458 adaptor_trampoline->instruction_start() + |
| 459 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); | 459 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); |
| 460 output_frame->SetPc(pc); | 460 output_frame->SetPc(pc); |
| 461 } | 461 } |
| 462 | 462 |
| 463 | 463 |
| 464 void Deoptimizer::DoCompiledStubPseudoFrame(TranslationIterator* iterator, | |
|
Jakob Kummerow
2012/11/19 12:36:00
s/Pseudo//
danno
2012/11/26 17:16:18
Done.
| |
| 465 int frame_index) { | |
| 466 // Builtins* builtins = isolate_->builtins(); | |
| 467 // Code::Kind stub_kind = static_cast<Code::Kind>(iterator->Next()); | |
|
Jakob Kummerow
2012/11/19 12:36:00
remove
danno
2012/11/26 17:16:18
Done.
| |
| 468 FrameDescription* output_frame = new(0) FrameDescription(0, 0); | |
|
Jakob Kummerow
2012/11/19 12:36:00
just "NULL"?
danno
2012/11/26 17:16:18
Done.
| |
| 469 Code* continuation = | |
| 470 isolate_->builtins()->builtin(Builtins::kNotifyICMiss); | |
| 471 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | |
| 472 output_frame->SetContinuation( | |
| 473 reinterpret_cast<uintptr_t>(continuation->entry())); | |
| 474 Handle<Code> miss_ic = isolate_->builtins()->KeyedLoadIC_Miss(); | |
|
Jakob Kummerow
2012/11/19 12:36:00
use stub_kind (see line 478) to figure this out
danno
2012/11/26 17:16:18
Done.
| |
| 475 output_frame->SetPc( | |
| 476 reinterpret_cast<intptr_t>(miss_ic->instruction_start())); | |
| 477 | |
| 478 Code::Kind stub_kind = static_cast<Code::Kind>(iterator->Next()); | |
| 479 ASSERT(stub_kind == Code::KEYED_LOAD_IC); | |
| 480 USE(stub_kind); | |
| 481 | |
| 482 Translation::Opcode opcode = | |
| 483 static_cast<Translation::Opcode>(iterator->Next()); | |
| 484 ASSERT(opcode == Translation::REGISTER); | |
| 485 USE(opcode); | |
| 486 int input_reg = iterator->Next(); | |
| 487 intptr_t input_value = input_->GetRegister(input_reg); | |
| 488 output_frame->SetRegister(r1.code(), input_value); | |
| 489 | |
| 490 int32_t next = iterator->Next(); | |
| 491 opcode = static_cast<Translation::Opcode>(next); | |
| 492 ASSERT(opcode == Translation::REGISTER); | |
| 493 input_reg = iterator->Next(); | |
| 494 input_value = input_->GetRegister(input_reg); | |
| 495 output_frame->SetRegister(r0.code(), input_value); | |
| 496 | |
| 497 ASSERT(frame_index == 0); | |
| 498 output_[frame_index] = output_frame; | |
| 499 } | |
| 500 | |
| 501 | |
| 464 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 502 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
| 465 int frame_index) { | 503 int frame_index) { |
| 466 Builtins* builtins = isolate_->builtins(); | 504 Builtins* builtins = isolate_->builtins(); |
| 467 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 505 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); |
| 468 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 506 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 469 unsigned height = iterator->Next(); | 507 unsigned height = iterator->Next(); |
| 470 unsigned height_in_bytes = height * kPointerSize; | 508 unsigned height_in_bytes = height * kPointerSize; |
| 471 if (FLAG_trace_deopt) { | 509 if (FLAG_trace_deopt) { |
| 472 PrintF(" translating construct stub => height=%d\n", height_in_bytes); | 510 PrintF(" translating construct stub => height=%d\n", height_in_bytes); |
| 473 } | 511 } |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 881 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 919 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
| 882 // Set the register values. The values are not important as there are no | 920 // Set the register values. The values are not important as there are no |
| 883 // callee saved registers in JavaScript frames, so all registers are | 921 // callee saved registers in JavaScript frames, so all registers are |
| 884 // spilled. Registers fp and sp are set to the correct values though. | 922 // spilled. Registers fp and sp are set to the correct values though. |
| 885 | 923 |
| 886 for (int i = 0; i < Register::kNumRegisters; i++) { | 924 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 887 input_->SetRegister(i, i * 4); | 925 input_->SetRegister(i, i * 4); |
| 888 } | 926 } |
| 889 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 927 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
| 890 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 928 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 891 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; i++) { | 929 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { |
| 892 input_->SetDoubleRegister(i, 0.0); | 930 input_->SetDoubleRegister(i, 0.0); |
| 893 } | 931 } |
| 894 | 932 |
| 895 // Fill the frame content from the actual data on the frame. | 933 // Fill the frame content from the actual data on the frame. |
| 896 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 934 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
| 897 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); | 935 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
| 898 } | 936 } |
| 899 } | 937 } |
| 900 | 938 |
| 901 | 939 |
| 902 #define __ masm()-> | 940 #define __ masm()-> |
| 903 | 941 |
| 904 // This code tries to be close to ia32 code so that any changes can be | 942 // This code tries to be close to ia32 code so that any changes can be |
| 905 // easily ported. | 943 // easily ported. |
| 906 void Deoptimizer::EntryGenerator::Generate() { | 944 void Deoptimizer::EntryGenerator::Generate() { |
| 907 GeneratePrologue(); | 945 GeneratePrologue(); |
| 908 | 946 |
| 909 Isolate* isolate = masm()->isolate(); | 947 Isolate* isolate = masm()->isolate(); |
| 910 | 948 |
| 911 CpuFeatures::Scope scope(VFP3); | |
| 912 // Save all general purpose registers before messing with them. | 949 // Save all general purpose registers before messing with them. |
| 913 const int kNumberOfRegisters = Register::kNumRegisters; | 950 const int kNumberOfRegisters = Register::kNumRegisters; |
| 914 | 951 |
| 915 // Everything but pc, lr and ip which will be saved but not restored. | 952 // Everything but pc, lr and ip which will be saved but not restored. |
| 916 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); | 953 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); |
| 917 | 954 |
| 918 const int kDoubleRegsSize = | 955 const int kDoubleRegsSize = |
| 919 kDoubleSize * DwVfpRegister::kNumAllocatableRegisters; | 956 kDoubleSize * DwVfpRegister::NumAllocatableRegisters(); |
| 920 | 957 |
| 921 // Save all VFP registers before messing with them. | 958 if (CpuFeatures::IsSupported(VFP2)) { |
| 922 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); | 959 // Save all VFP registers before messing with them. |
| 923 DwVfpRegister last = | 960 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); |
| 924 DwVfpRegister::FromAllocationIndex( | 961 DwVfpRegister last = |
| 925 DwVfpRegister::kNumAllocatableRegisters - 1); | 962 DwVfpRegister::FromAllocationIndex( |
| 926 ASSERT(last.code() > first.code()); | 963 DwVfpRegister::NumAllocatableRegisters() - 1); |
| 927 ASSERT((last.code() - first.code()) == | 964 ASSERT(last.code() > first.code()); |
| 928 (DwVfpRegister::kNumAllocatableRegisters - 1)); | 965 ASSERT((last.code() - first.code()) == |
| 966 (DwVfpRegister::NumAllocatableRegisters() - 1)); | |
| 929 #ifdef DEBUG | 967 #ifdef DEBUG |
| 930 for (int i = 0; i <= (DwVfpRegister::kNumAllocatableRegisters - 1); i++) { | 968 for (int i = 0; i <= (DwVfpRegister::NumAllocatableRegisters() - 1); i++) { |
| 931 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | 969 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && |
| 932 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | 970 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); |
| 971 } | |
| 972 #endif | |
| 973 __ vstm(db_w, sp, first, last); | |
| 974 } else { | |
| 975 __ sub(sp, sp, Operand(kDoubleRegsSize)); | |
| 933 } | 976 } |
| 934 #endif | |
| 935 __ vstm(db_w, sp, first, last); | |
| 936 | 977 |
| 937 // Push all 16 registers (needed to populate FrameDescription::registers_). | 978 // Push all 16 registers (needed to populate FrameDescription::registers_). |
| 938 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps | 979 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
| 939 // handle this a bit differently. | 980 // handle this a bit differently. |
| 940 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | 981 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
| 941 | 982 |
| 942 const int kSavedRegistersAreaSize = | 983 const int kSavedRegistersAreaSize = |
| 943 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 984 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; |
| 944 | 985 |
| 945 // Get the bailout id from the stack. | 986 // Get the bailout id from the stack. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 984 __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); | 1025 __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); |
| 985 | 1026 |
| 986 // Copy core registers into FrameDescription::registers_[kNumRegisters]. | 1027 // Copy core registers into FrameDescription::registers_[kNumRegisters]. |
| 987 ASSERT(Register::kNumRegisters == kNumberOfRegisters); | 1028 ASSERT(Register::kNumRegisters == kNumberOfRegisters); |
| 988 for (int i = 0; i < kNumberOfRegisters; i++) { | 1029 for (int i = 0; i < kNumberOfRegisters; i++) { |
| 989 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 1030 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
| 990 __ ldr(r2, MemOperand(sp, i * kPointerSize)); | 1031 __ ldr(r2, MemOperand(sp, i * kPointerSize)); |
| 991 __ str(r2, MemOperand(r1, offset)); | 1032 __ str(r2, MemOperand(r1, offset)); |
| 992 } | 1033 } |
| 993 | 1034 |
| 994 // Copy VFP registers to | 1035 if (CpuFeatures::IsSupported(VFP2)) { |
| 995 // double_registers_[DoubleRegister::kNumAllocatableRegisters] | 1036 // Copy VFP registers to |
| 996 int double_regs_offset = FrameDescription::double_registers_offset(); | 1037 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] |
| 997 for (int i = 0; i < DwVfpRegister::kNumAllocatableRegisters; ++i) { | 1038 int double_regs_offset = FrameDescription::double_registers_offset(); |
| 998 int dst_offset = i * kDoubleSize + double_regs_offset; | 1039 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { |
| 999 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 1040 int dst_offset = i * kDoubleSize + double_regs_offset; |
| 1000 __ vldr(d0, sp, src_offset); | 1041 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
| 1001 __ vstr(d0, r1, dst_offset); | 1042 __ vldr(d0, sp, src_offset); |
| 1043 __ vstr(d0, r1, dst_offset); | |
| 1044 } | |
| 1002 } | 1045 } |
| 1003 | 1046 |
| 1004 // Remove the bailout id, eventually return address, and the saved registers | 1047 // Remove the bailout id, eventually return address, and the saved registers |
| 1005 // from the stack. | 1048 // from the stack. |
| 1006 if (type() == EAGER || type() == OSR) { | 1049 if (type() == EAGER || type() == OSR) { |
| 1007 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 1050 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
| 1008 } else { | 1051 } else { |
| 1009 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize))); | 1052 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize))); |
| 1010 } | 1053 } |
| 1011 | 1054 |
| 1012 // Compute a pointer to the unwinding limit in register r2; that is | 1055 // Compute a pointer to the unwinding limit in register r2; that is |
| 1013 // the first stack slot not part of the input frame. | 1056 // the first stack slot not part of the input frame. |
| 1014 __ ldr(r2, MemOperand(r1, FrameDescription::frame_size_offset())); | 1057 __ ldr(r2, MemOperand(r1, FrameDescription::frame_size_offset())); |
| 1015 __ add(r2, r2, sp); | 1058 __ add(r2, r2, sp); |
| 1016 | 1059 |
| 1017 // Unwind the stack down to - but not including - the unwinding | 1060 // Unwind the stack down to - but not including - the unwinding |
| 1018 // limit and copy the contents of the activation frame to the input | 1061 // limit and copy the contents of the activation frame to the input |
| 1019 // frame description. | 1062 // frame description. |
| 1020 __ add(r3, r1, Operand(FrameDescription::frame_content_offset())); | 1063 __ add(r3, r1, Operand(FrameDescription::frame_content_offset())); |
| 1021 Label pop_loop; | 1064 Label pop_loop; |
| 1065 Label pop_loop_header; | |
| 1066 __ b(&pop_loop_header); | |
| 1022 __ bind(&pop_loop); | 1067 __ bind(&pop_loop); |
| 1023 __ pop(r4); | 1068 __ pop(r4); |
| 1024 __ str(r4, MemOperand(r3, 0)); | 1069 __ str(r4, MemOperand(r3, 0)); |
| 1025 __ add(r3, r3, Operand(sizeof(uint32_t))); | 1070 __ add(r3, r3, Operand(sizeof(uint32_t))); |
| 1071 __ bind(&pop_loop_header); | |
| 1026 __ cmp(r2, sp); | 1072 __ cmp(r2, sp); |
| 1027 __ b(ne, &pop_loop); | 1073 __ b(ne, &pop_loop); |
| 1028 | 1074 |
| 1029 // Compute the output frame in the deoptimizer. | 1075 // Compute the output frame in the deoptimizer. |
| 1030 __ push(r0); // Preserve deoptimizer object across call. | 1076 __ push(r0); // Preserve deoptimizer object across call. |
| 1031 // r0: deoptimizer object; r1: scratch. | 1077 // r0: deoptimizer object; r1: scratch. |
| 1032 __ PrepareCallCFunction(1, r1); | 1078 __ PrepareCallCFunction(1, r1); |
| 1033 // Call Deoptimizer::ComputeOutputFrames(). | 1079 // Call Deoptimizer::ComputeOutputFrames(). |
| 1034 { | 1080 { |
| 1035 AllowExternalCallThatCantCauseGC scope(masm()); | 1081 AllowExternalCallThatCantCauseGC scope(masm()); |
| 1036 __ CallCFunction( | 1082 __ CallCFunction( |
| 1037 ExternalReference::compute_output_frames_function(isolate), 1); | 1083 ExternalReference::compute_output_frames_function(isolate), 1); |
| 1038 } | 1084 } |
| 1039 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). | 1085 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). |
| 1040 | 1086 |
| 1041 // Replace the current (input) frame with the output frames. | 1087 // Replace the current (input) frame with the output frames. |
| 1042 Label outer_push_loop, inner_push_loop; | 1088 Label outer_push_loop, inner_push_loop, |
| 1089 outer_loop_header, inner_loop_header; | |
| 1043 // Outer loop state: r0 = current "FrameDescription** output_", | 1090 // Outer loop state: r0 = current "FrameDescription** output_", |
| 1044 // r1 = one past the last FrameDescription**. | 1091 // r1 = one past the last FrameDescription**. |
| 1045 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 1092 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
| 1046 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. | 1093 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. |
| 1047 __ add(r1, r0, Operand(r1, LSL, 2)); | 1094 __ add(r1, r0, Operand(r1, LSL, 2)); |
| 1095 __ jmp(&outer_loop_header); | |
| 1048 __ bind(&outer_push_loop); | 1096 __ bind(&outer_push_loop); |
| 1049 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 1097 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
| 1050 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] | 1098 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] |
| 1051 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 1099 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
| 1100 __ jmp(&inner_loop_header); | |
| 1052 __ bind(&inner_push_loop); | 1101 __ bind(&inner_push_loop); |
| 1053 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 1102 __ sub(r3, r3, Operand(sizeof(uint32_t))); |
| 1054 __ add(r6, r2, Operand(r3)); | 1103 __ add(r6, r2, Operand(r3)); |
| 1055 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); | 1104 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); |
| 1056 __ push(r7); | 1105 __ push(r7); |
| 1106 __ bind(&inner_loop_header); | |
| 1057 __ cmp(r3, Operand(0)); | 1107 __ cmp(r3, Operand(0)); |
| 1058 __ b(ne, &inner_push_loop); // test for gt? | 1108 __ b(ne, &inner_push_loop); // test for gt? |
| 1059 __ add(r0, r0, Operand(kPointerSize)); | 1109 __ add(r0, r0, Operand(kPointerSize)); |
| 1110 __ bind(&outer_loop_header); | |
| 1060 __ cmp(r0, r1); | 1111 __ cmp(r0, r1); |
| 1061 __ b(lt, &outer_push_loop); | 1112 __ b(lt, &outer_push_loop); |
| 1062 | 1113 |
| 1063 // Push state, pc, and continuation from the last output frame. | 1114 // Push state, pc, and continuation from the last output frame. |
| 1064 if (type() != OSR) { | 1115 if (type() != OSR) { |
| 1065 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 1116 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
| 1066 __ push(r6); | 1117 __ push(r6); |
| 1067 } | 1118 } |
| 1068 | 1119 |
| 1069 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 1120 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1110 __ push(ip); | 1161 __ push(ip); |
| 1111 __ b(&done); | 1162 __ b(&done); |
| 1112 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1163 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 1113 } | 1164 } |
| 1114 __ bind(&done); | 1165 __ bind(&done); |
| 1115 } | 1166 } |
| 1116 | 1167 |
| 1117 #undef __ | 1168 #undef __ |
| 1118 | 1169 |
| 1119 } } // namespace v8::internal | 1170 } } // namespace v8::internal |
| OLD | NEW |