| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if (value == 1) return i; | 205 if (value == 1) return i; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 UNREACHABLE(); | 208 UNREACHABLE(); |
| 209 return -1; | 209 return -1; |
| 210 } | 210 } |
| 211 | 211 |
| 212 | 212 |
| 213 void Deoptimizer::DoComputeOsrOutputFrame() { | 213 void Deoptimizer::DoComputeOsrOutputFrame() { |
| 214 DeoptimizationInputData* data = DeoptimizationInputData::cast( | 214 DeoptimizationInputData* data = DeoptimizationInputData::cast( |
| 215 compiled_code_->deoptimization_data()); | 215 optimized_code_->deoptimization_data()); |
| 216 unsigned ast_id = data->OsrAstId()->value(); | 216 unsigned ast_id = data->OsrAstId()->value(); |
| 217 | 217 |
| 218 int bailout_id = LookupBailoutId(data, BailoutId(ast_id)); | 218 int bailout_id = LookupBailoutId(data, BailoutId(ast_id)); |
| 219 unsigned translation_index = data->TranslationIndex(bailout_id)->value(); | 219 unsigned translation_index = data->TranslationIndex(bailout_id)->value(); |
| 220 ByteArray* translations = data->TranslationByteArray(); | 220 ByteArray* translations = data->TranslationByteArray(); |
| 221 | 221 |
| 222 TranslationIterator iterator(translations, translation_index); | 222 TranslationIterator iterator(translations, translation_index); |
| 223 Translation::Opcode opcode = | 223 Translation::Opcode opcode = |
| 224 static_cast<Translation::Opcode>(iterator.Next()); | 224 static_cast<Translation::Opcode>(iterator.Next()); |
| 225 ASSERT(Translation::BEGIN == opcode); | 225 ASSERT(Translation::BEGIN == opcode); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 239 USE(closure_id); | 239 USE(closure_id); |
| 240 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); | 240 ASSERT_EQ(Translation::kSelfLiteralId, closure_id); |
| 241 unsigned height = iterator.Next(); | 241 unsigned height = iterator.Next(); |
| 242 unsigned height_in_bytes = height * kPointerSize; | 242 unsigned height_in_bytes = height * kPointerSize; |
| 243 USE(height_in_bytes); | 243 USE(height_in_bytes); |
| 244 | 244 |
| 245 unsigned fixed_size = ComputeFixedSize(function_); | 245 unsigned fixed_size = ComputeFixedSize(function_); |
| 246 unsigned input_frame_size = input_->GetFrameSize(); | 246 unsigned input_frame_size = input_->GetFrameSize(); |
| 247 ASSERT(fixed_size + height_in_bytes == input_frame_size); | 247 ASSERT(fixed_size + height_in_bytes == input_frame_size); |
| 248 | 248 |
| 249 unsigned stack_slot_size = compiled_code_->stack_slots() * kPointerSize; | 249 unsigned stack_slot_size = optimized_code_->stack_slots() * kPointerSize; |
| 250 unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); | 250 unsigned outgoing_height = data->ArgumentsStackHeight(bailout_id)->value(); |
| 251 unsigned outgoing_size = outgoing_height * kPointerSize; | 251 unsigned outgoing_size = outgoing_height * kPointerSize; |
| 252 unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; | 252 unsigned output_frame_size = fixed_size + stack_slot_size + outgoing_size; |
| 253 ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. | 253 ASSERT(outgoing_size == 0); // OSR does not happen in the middle of a call. |
| 254 | 254 |
| 255 if (FLAG_trace_osr) { | 255 if (FLAG_trace_osr) { |
| 256 PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", | 256 PrintF("[on-stack replacement: begin 0x%08" V8PRIxPTR " ", |
| 257 reinterpret_cast<intptr_t>(function_)); | 257 reinterpret_cast<intptr_t>(function_)); |
| 258 function_->PrintName(); | 258 function_->PrintName(); |
| 259 PrintF(" => node=%u, frame=%d->%d]\n", | 259 PrintF(" => node=%u, frame=%d->%d]\n", |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 delete output_[0]; | 331 delete output_[0]; |
| 332 output_[0] = input_; | 332 output_[0] = input_; |
| 333 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); | 333 output_[0]->SetPc(reinterpret_cast<uint32_t>(from_)); |
| 334 } else { | 334 } else { |
| 335 // Set up the frame pointer and the context pointer. | 335 // Set up the frame pointer and the context pointer. |
| 336 output_[0]->SetRegister(fp.code(), input_->GetRegister(fp.code())); | 336 output_[0]->SetRegister(fp.code(), input_->GetRegister(fp.code())); |
| 337 output_[0]->SetRegister(cp.code(), input_->GetRegister(cp.code())); | 337 output_[0]->SetRegister(cp.code(), input_->GetRegister(cp.code())); |
| 338 | 338 |
| 339 unsigned pc_offset = data->OsrPcOffset()->value(); | 339 unsigned pc_offset = data->OsrPcOffset()->value(); |
| 340 uint32_t pc = reinterpret_cast<uint32_t>( | 340 uint32_t pc = reinterpret_cast<uint32_t>( |
| 341 compiled_code_->entry() + pc_offset); | 341 optimized_code_->entry() + pc_offset); |
| 342 output_[0]->SetPc(pc); | 342 output_[0]->SetPc(pc); |
| 343 } | 343 } |
| 344 Code* continuation = isolate_->builtins()->builtin(Builtins::kNotifyOSR); | 344 Code* continuation = isolate_->builtins()->builtin(Builtins::kNotifyOSR); |
| 345 output_[0]->SetContinuation( | 345 output_[0]->SetContinuation( |
| 346 reinterpret_cast<uint32_t>(continuation->entry())); | 346 reinterpret_cast<uint32_t>(continuation->entry())); |
| 347 | 347 |
| 348 if (FLAG_trace_osr) { | 348 if (FLAG_trace_osr) { |
| 349 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", | 349 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", |
| 350 ok ? "finished" : "aborted", | 350 ok ? "finished" : "aborted", |
| 351 reinterpret_cast<intptr_t>(function_)); | 351 reinterpret_cast<intptr_t>(function_)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 Builtins* builtins = isolate_->builtins(); | 444 Builtins* builtins = isolate_->builtins(); |
| 445 Code* adaptor_trampoline = | 445 Code* adaptor_trampoline = |
| 446 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); | 446 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); |
| 447 uint32_t pc = reinterpret_cast<uint32_t>( | 447 uint32_t pc = reinterpret_cast<uint32_t>( |
| 448 adaptor_trampoline->instruction_start() + | 448 adaptor_trampoline->instruction_start() + |
| 449 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); | 449 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); |
| 450 output_frame->SetPc(pc); | 450 output_frame->SetPc(pc); |
| 451 } | 451 } |
| 452 | 452 |
| 453 | 453 |
| 454 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, | |
| 455 int frame_index) { | |
| 456 // | |
| 457 // FROM TO <-fp | |
| 458 // | .... | | .... | | |
| 459 // +-------------------------+ +-------------------------+ | |
| 460 // | JSFunction continuation | | JSFunction continuation | | |
| 461 // +-------------------------+ +-------------------------+<-sp | |
| 462 // | | saved frame (fp) | | |
| 463 // | +=========================+<-fp | |
| 464 // | | JSFunction context | | |
| 465 // v +-------------------------+ | |
| 466 // | COMPILED_STUB marker | fp = saved frame | |
| 467 // +-------------------------+ f8 = JSFunction context | |
| 468 // | | | |
| 469 // | ... | | |
| 470 // | | | |
| 471 // +-------------------------+<-sp | |
| 472 // | |
| 473 // | |
| 474 int output_frame_size = 1 * kPointerSize; | |
| 475 FrameDescription* output_frame = | |
| 476 new(output_frame_size) FrameDescription(output_frame_size, 0); | |
| 477 Code* notify_miss = | |
| 478 isolate_->builtins()->builtin(Builtins::kNotifyICMiss); | |
| 479 output_frame->SetState(Smi::FromInt(FullCodeGenerator::NO_REGISTERS)); | |
| 480 output_frame->SetContinuation( | |
| 481 reinterpret_cast<intptr_t>(notify_miss->entry())); | |
| 482 | |
| 483 ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); | |
| 484 int major_key = compiled_code_->major_key(); | |
| 485 CodeStubInterfaceDescriptor* descriptor = | |
| 486 isolate_->code_stub_interface_descriptor(major_key); | |
| 487 Handle<Code> miss_ic(descriptor->deoptimization_handler_); | |
| 488 output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start())); | |
| 489 unsigned input_frame_size = input_->GetFrameSize(); | |
| 490 intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); | |
| 491 output_frame->SetFrameSlot(0, value); | |
| 492 value = input_->GetFrameSlot(input_frame_size - 2 * kPointerSize); | |
| 493 output_frame->SetRegister(fp.code(), value); | |
| 494 output_frame->SetFp(value); | |
| 495 value = input_->GetFrameSlot(input_frame_size - 3 * kPointerSize); | |
| 496 output_frame->SetRegister(cp.code(), value); | |
| 497 | |
| 498 Translation::Opcode opcode = | |
| 499 static_cast<Translation::Opcode>(iterator->Next()); | |
| 500 ASSERT(opcode == Translation::REGISTER); | |
| 501 USE(opcode); | |
| 502 int input_reg = iterator->Next(); | |
| 503 intptr_t input_value = input_->GetRegister(input_reg); | |
| 504 output_frame->SetRegister(r1.code(), input_value); | |
| 505 | |
| 506 int32_t next = iterator->Next(); | |
| 507 opcode = static_cast<Translation::Opcode>(next); | |
| 508 ASSERT(opcode == Translation::REGISTER); | |
| 509 input_reg = iterator->Next(); | |
| 510 input_value = input_->GetRegister(input_reg); | |
| 511 output_frame->SetRegister(r0.code(), input_value); | |
| 512 | |
| 513 ASSERT(frame_index == 0); | |
| 514 output_[frame_index] = output_frame; | |
| 515 } | |
| 516 | |
| 517 | |
| 518 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, | 454 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator, |
| 519 int frame_index) { | 455 int frame_index) { |
| 520 Builtins* builtins = isolate_->builtins(); | 456 Builtins* builtins = isolate_->builtins(); |
| 521 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); | 457 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric); |
| 522 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); | 458 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); |
| 523 unsigned height = iterator->Next(); | 459 unsigned height = iterator->Next(); |
| 524 unsigned height_in_bytes = height * kPointerSize; | 460 unsigned height_in_bytes = height * kPointerSize; |
| 525 if (FLAG_trace_deopt) { | 461 if (FLAG_trace_deopt) { |
| 526 PrintF(" translating construct stub => height=%d\n", height_in_bytes); | 462 PrintF(" translating construct stub => height=%d\n", height_in_bytes); |
| 527 } | 463 } |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { | 871 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { |
| 936 // 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 |
| 937 // callee saved registers in JavaScript frames, so all registers are | 873 // callee saved registers in JavaScript frames, so all registers are |
| 938 // 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. |
| 939 | 875 |
| 940 for (int i = 0; i < Register::kNumRegisters; i++) { | 876 for (int i = 0; i < Register::kNumRegisters; i++) { |
| 941 input_->SetRegister(i, i * 4); | 877 input_->SetRegister(i, i * 4); |
| 942 } | 878 } |
| 943 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); | 879 input_->SetRegister(sp.code(), reinterpret_cast<intptr_t>(frame->sp())); |
| 944 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); | 880 input_->SetRegister(fp.code(), reinterpret_cast<intptr_t>(frame->fp())); |
| 945 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { | 881 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; i++) { |
| 946 input_->SetDoubleRegister(i, 0.0); | 882 input_->SetDoubleRegister(i, 0.0); |
| 947 } | 883 } |
| 948 | 884 |
| 949 // Fill the frame content from the actual data on the frame. | 885 // Fill the frame content from the actual data on the frame. |
| 950 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { | 886 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { |
| 951 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); | 887 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); |
| 952 } | 888 } |
| 953 } | 889 } |
| 954 | 890 |
| 955 | 891 |
| 956 #define __ masm()-> | 892 #define __ masm()-> |
| 957 | 893 |
| 958 // 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 |
| 959 // easily ported. | 895 // easily ported. |
| 960 void Deoptimizer::EntryGenerator::Generate() { | 896 void Deoptimizer::EntryGenerator::Generate() { |
| 961 GeneratePrologue(); | 897 GeneratePrologue(); |
| 962 | 898 |
| 963 Isolate* isolate = masm()->isolate(); | 899 Isolate* isolate = masm()->isolate(); |
| 964 | 900 |
| 901 CpuFeatures::Scope scope(VFP3); |
| 965 // Save all general purpose registers before messing with them. | 902 // Save all general purpose registers before messing with them. |
| 966 const int kNumberOfRegisters = Register::kNumRegisters; | 903 const int kNumberOfRegisters = Register::kNumRegisters; |
| 967 | 904 |
| 968 // 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. |
| 969 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); | 906 RegList restored_regs = kJSCallerSaved | kCalleeSaved | ip.bit(); |
| 970 | 907 |
| 971 const int kDoubleRegsSize = | 908 const int kDoubleRegsSize = |
| 972 kDoubleSize * DwVfpRegister::kMaxNumAllocatableRegisters; | 909 kDoubleSize * DwVfpRegister::kNumAllocatableRegisters; |
| 973 | 910 |
| 974 if (CpuFeatures::IsSupported(VFP2)) { | 911 // Save all VFP registers before messing with them. |
| 975 CpuFeatures::Scope scope(VFP2); | 912 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); |
| 976 // Save all VFP registers before messing with them. | 913 DwVfpRegister last = |
| 977 DwVfpRegister first = DwVfpRegister::FromAllocationIndex(0); | 914 DwVfpRegister::FromAllocationIndex( |
| 978 DwVfpRegister last = | 915 DwVfpRegister::kNumAllocatableRegisters - 1); |
| 979 DwVfpRegister::FromAllocationIndex( | 916 ASSERT(last.code() > first.code()); |
| 980 DwVfpRegister::kMaxNumAllocatableRegisters - 1); | 917 ASSERT((last.code() - first.code()) == |
| 981 ASSERT(last.code() > first.code()); | 918 (DwVfpRegister::kNumAllocatableRegisters - 1)); |
| 982 ASSERT((last.code() - first.code()) == | |
| 983 (DwVfpRegister::kMaxNumAllocatableRegisters - 1)); | |
| 984 #ifdef DEBUG | 919 #ifdef DEBUG |
| 985 int max = DwVfpRegister::kMaxNumAllocatableRegisters - 1; | 920 for (int i = 0; i <= (DwVfpRegister::kNumAllocatableRegisters - 1); i++) { |
| 986 for (int i = 0; i <= max; i++) { | 921 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && |
| 987 ASSERT((DwVfpRegister::FromAllocationIndex(i).code() <= last.code()) && | 922 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); |
| 988 (DwVfpRegister::FromAllocationIndex(i).code() >= first.code())); | 923 } |
| 989 } | |
| 990 #endif | 924 #endif |
| 991 __ vstm(db_w, sp, first, last); | 925 __ vstm(db_w, sp, first, last); |
| 992 } else { | |
| 993 __ sub(sp, sp, Operand(kDoubleRegsSize)); | |
| 994 } | |
| 995 | 926 |
| 996 // Push all 16 registers (needed to populate FrameDescription::registers_). | 927 // Push all 16 registers (needed to populate FrameDescription::registers_). |
| 997 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps | 928 // TODO(1588) Note that using pc with stm is deprecated, so we should perhaps |
| 998 // handle this a bit differently. | 929 // handle this a bit differently. |
| 999 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); | 930 __ stm(db_w, sp, restored_regs | sp.bit() | lr.bit() | pc.bit()); |
| 1000 | 931 |
| 1001 const int kSavedRegistersAreaSize = | 932 const int kSavedRegistersAreaSize = |
| 1002 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; | 933 (kNumberOfRegisters * kPointerSize) + kDoubleRegsSize; |
| 1003 | 934 |
| 1004 // Get the bailout id from the stack. | 935 // Get the bailout id from the stack. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); | 974 __ ldr(r1, MemOperand(r0, Deoptimizer::input_offset())); |
| 1044 | 975 |
| 1045 // Copy core registers into FrameDescription::registers_[kNumRegisters]. | 976 // Copy core registers into FrameDescription::registers_[kNumRegisters]. |
| 1046 ASSERT(Register::kNumRegisters == kNumberOfRegisters); | 977 ASSERT(Register::kNumRegisters == kNumberOfRegisters); |
| 1047 for (int i = 0; i < kNumberOfRegisters; i++) { | 978 for (int i = 0; i < kNumberOfRegisters; i++) { |
| 1048 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 979 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
| 1049 __ ldr(r2, MemOperand(sp, i * kPointerSize)); | 980 __ ldr(r2, MemOperand(sp, i * kPointerSize)); |
| 1050 __ str(r2, MemOperand(r1, offset)); | 981 __ str(r2, MemOperand(r1, offset)); |
| 1051 } | 982 } |
| 1052 | 983 |
| 1053 if (CpuFeatures::IsSupported(VFP2)) { | 984 // Copy VFP registers to |
| 1054 CpuFeatures::Scope scope(VFP2); | 985 // double_registers_[DoubleRegister::kNumAllocatableRegisters] |
| 1055 // Copy VFP registers to | 986 int double_regs_offset = FrameDescription::double_registers_offset(); |
| 1056 // double_registers_[DoubleRegister::kMaxNumAllocatableRegisters] | 987 for (int i = 0; i < DwVfpRegister::kNumAllocatableRegisters; ++i) { |
| 1057 int double_regs_offset = FrameDescription::double_registers_offset(); | 988 int dst_offset = i * kDoubleSize + double_regs_offset; |
| 1058 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); ++i) { | 989 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; |
| 1059 int dst_offset = i * kDoubleSize + double_regs_offset; | 990 __ vldr(d0, sp, src_offset); |
| 1060 int src_offset = i * kDoubleSize + kNumberOfRegisters * kPointerSize; | 991 __ vstr(d0, r1, dst_offset); |
| 1061 __ vldr(d0, sp, src_offset); | |
| 1062 __ vstr(d0, r1, dst_offset); | |
| 1063 } | |
| 1064 } | 992 } |
| 1065 | 993 |
| 1066 // Remove the bailout id, eventually return address, and the saved registers | 994 // Remove the bailout id, eventually return address, and the saved registers |
| 1067 // from the stack. | 995 // from the stack. |
| 1068 if (type() == EAGER || type() == OSR) { | 996 if (type() == EAGER || type() == OSR) { |
| 1069 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); | 997 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (1 * kPointerSize))); |
| 1070 } else { | 998 } else { |
| 1071 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize))); | 999 __ add(sp, sp, Operand(kSavedRegistersAreaSize + (2 * kPointerSize))); |
| 1072 } | 1000 } |
| 1073 | 1001 |
| 1074 // Compute a pointer to the unwinding limit in register r2; that is | 1002 // Compute a pointer to the unwinding limit in register r2; that is |
| 1075 // the first stack slot not part of the input frame. | 1003 // the first stack slot not part of the input frame. |
| 1076 __ ldr(r2, MemOperand(r1, FrameDescription::frame_size_offset())); | 1004 __ ldr(r2, MemOperand(r1, FrameDescription::frame_size_offset())); |
| 1077 __ add(r2, r2, sp); | 1005 __ add(r2, r2, sp); |
| 1078 | 1006 |
| 1079 // Unwind the stack down to - but not including - the unwinding | 1007 // Unwind the stack down to - but not including - the unwinding |
| 1080 // limit and copy the contents of the activation frame to the input | 1008 // limit and copy the contents of the activation frame to the input |
| 1081 // frame description. | 1009 // frame description. |
| 1082 __ add(r3, r1, Operand(FrameDescription::frame_content_offset())); | 1010 __ add(r3, r1, Operand(FrameDescription::frame_content_offset())); |
| 1083 Label pop_loop; | 1011 Label pop_loop; |
| 1084 Label pop_loop_header; | |
| 1085 __ b(&pop_loop_header); | |
| 1086 __ bind(&pop_loop); | 1012 __ bind(&pop_loop); |
| 1087 __ pop(r4); | 1013 __ pop(r4); |
| 1088 __ str(r4, MemOperand(r3, 0)); | 1014 __ str(r4, MemOperand(r3, 0)); |
| 1089 __ add(r3, r3, Operand(sizeof(uint32_t))); | 1015 __ add(r3, r3, Operand(sizeof(uint32_t))); |
| 1090 __ bind(&pop_loop_header); | |
| 1091 __ cmp(r2, sp); | 1016 __ cmp(r2, sp); |
| 1092 __ b(ne, &pop_loop); | 1017 __ b(ne, &pop_loop); |
| 1093 | 1018 |
| 1094 // Compute the output frame in the deoptimizer. | 1019 // Compute the output frame in the deoptimizer. |
| 1095 __ push(r0); // Preserve deoptimizer object across call. | 1020 __ push(r0); // Preserve deoptimizer object across call. |
| 1096 // r0: deoptimizer object; r1: scratch. | 1021 // r0: deoptimizer object; r1: scratch. |
| 1097 __ PrepareCallCFunction(1, r1); | 1022 __ PrepareCallCFunction(1, r1); |
| 1098 // Call Deoptimizer::ComputeOutputFrames(). | 1023 // Call Deoptimizer::ComputeOutputFrames(). |
| 1099 { | 1024 { |
| 1100 AllowExternalCallThatCantCauseGC scope(masm()); | 1025 AllowExternalCallThatCantCauseGC scope(masm()); |
| 1101 __ CallCFunction( | 1026 __ CallCFunction( |
| 1102 ExternalReference::compute_output_frames_function(isolate), 1); | 1027 ExternalReference::compute_output_frames_function(isolate), 1); |
| 1103 } | 1028 } |
| 1104 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). | 1029 __ pop(r0); // Restore deoptimizer object (class Deoptimizer). |
| 1105 | 1030 |
| 1106 // Replace the current (input) frame with the output frames. | 1031 // Replace the current (input) frame with the output frames. |
| 1107 Label outer_push_loop, inner_push_loop, | 1032 Label outer_push_loop, inner_push_loop; |
| 1108 outer_loop_header, inner_loop_header; | |
| 1109 // Outer loop state: r0 = current "FrameDescription** output_", | 1033 // Outer loop state: r0 = current "FrameDescription** output_", |
| 1110 // r1 = one past the last FrameDescription**. | 1034 // r1 = one past the last FrameDescription**. |
| 1111 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); | 1035 __ ldr(r1, MemOperand(r0, Deoptimizer::output_count_offset())); |
| 1112 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. | 1036 __ ldr(r0, MemOperand(r0, Deoptimizer::output_offset())); // r0 is output_. |
| 1113 __ add(r1, r0, Operand(r1, LSL, 2)); | 1037 __ add(r1, r0, Operand(r1, LSL, 2)); |
| 1114 __ jmp(&outer_loop_header); | |
| 1115 __ bind(&outer_push_loop); | 1038 __ bind(&outer_push_loop); |
| 1116 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. | 1039 // Inner loop state: r2 = current FrameDescription*, r3 = loop index. |
| 1117 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] | 1040 __ ldr(r2, MemOperand(r0, 0)); // output_[ix] |
| 1118 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); | 1041 __ ldr(r3, MemOperand(r2, FrameDescription::frame_size_offset())); |
| 1119 __ jmp(&inner_loop_header); | |
| 1120 __ bind(&inner_push_loop); | 1042 __ bind(&inner_push_loop); |
| 1121 __ sub(r3, r3, Operand(sizeof(uint32_t))); | 1043 __ sub(r3, r3, Operand(sizeof(uint32_t))); |
| 1122 __ add(r6, r2, Operand(r3)); | 1044 __ add(r6, r2, Operand(r3)); |
| 1123 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); | 1045 __ ldr(r7, MemOperand(r6, FrameDescription::frame_content_offset())); |
| 1124 __ push(r7); | 1046 __ push(r7); |
| 1125 __ bind(&inner_loop_header); | |
| 1126 __ cmp(r3, Operand(0)); | 1047 __ cmp(r3, Operand(0)); |
| 1127 __ b(ne, &inner_push_loop); // test for gt? | 1048 __ b(ne, &inner_push_loop); // test for gt? |
| 1128 __ add(r0, r0, Operand(kPointerSize)); | 1049 __ add(r0, r0, Operand(kPointerSize)); |
| 1129 __ bind(&outer_loop_header); | |
| 1130 __ cmp(r0, r1); | 1050 __ cmp(r0, r1); |
| 1131 __ b(lt, &outer_push_loop); | 1051 __ b(lt, &outer_push_loop); |
| 1132 | 1052 |
| 1133 // Push state, pc, and continuation from the last output frame. | 1053 // Push state, pc, and continuation from the last output frame. |
| 1134 if (type() != OSR) { | 1054 if (type() != OSR) { |
| 1135 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); | 1055 __ ldr(r6, MemOperand(r2, FrameDescription::state_offset())); |
| 1136 __ push(r6); | 1056 __ push(r6); |
| 1137 } | 1057 } |
| 1138 | 1058 |
| 1139 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); | 1059 __ ldr(r6, MemOperand(r2, FrameDescription::pc_offset())); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 __ push(ip); | 1100 __ push(ip); |
| 1181 __ b(&done); | 1101 __ b(&done); |
| 1182 ASSERT(masm()->pc_offset() - start == table_entry_size_); | 1102 ASSERT(masm()->pc_offset() - start == table_entry_size_); |
| 1183 } | 1103 } |
| 1184 __ bind(&done); | 1104 __ bind(&done); |
| 1185 } | 1105 } |
| 1186 | 1106 |
| 1187 #undef __ | 1107 #undef __ |
| 1188 | 1108 |
| 1189 } } // namespace v8::internal | 1109 } } // namespace v8::internal |
| OLD | NEW |