Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: src/arm/deoptimizer-arm.cc

Issue 12374044: Unify deoptimizer for accessor and arguments frames. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/deoptimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (FLAG_trace_osr) { 349 if (FLAG_trace_osr) {
350 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", 350 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ",
351 ok ? "finished" : "aborted", 351 ok ? "finished" : "aborted",
352 reinterpret_cast<intptr_t>(function_)); 352 reinterpret_cast<intptr_t>(function_));
353 function_->PrintName(); 353 function_->PrintName();
354 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); 354 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc());
355 } 355 }
356 } 356 }
357 357
358 358
359 void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
360 int frame_index) {
361 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
362 unsigned height = iterator->Next();
363 unsigned height_in_bytes = height * kPointerSize;
364 if (FLAG_trace_deopt) {
365 PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes);
366 }
367
368 unsigned fixed_frame_size = ArgumentsAdaptorFrameConstants::kFrameSize;
369 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
370
371 // Allocate and store the output frame description.
372 FrameDescription* output_frame =
373 new(output_frame_size) FrameDescription(output_frame_size, function);
374 output_frame->SetFrameType(StackFrame::ARGUMENTS_ADAPTOR);
375
376 // Arguments adaptor can not be topmost or bottommost.
377 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
378 ASSERT(output_[frame_index] == NULL);
379 output_[frame_index] = output_frame;
380
381 // The top address of the frame is computed from the previous
382 // frame's top and this frame's size.
383 uint32_t top_address;
384 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
385 output_frame->SetTop(top_address);
386
387 // Compute the incoming parameter translation.
388 int parameter_count = height;
389 unsigned output_offset = output_frame_size;
390 for (int i = 0; i < parameter_count; ++i) {
391 output_offset -= kPointerSize;
392 DoTranslateCommand(iterator, frame_index, output_offset);
393 }
394
395 // Read caller's PC from the previous frame.
396 output_offset -= kPointerSize;
397 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
398 output_frame->SetFrameSlot(output_offset, callers_pc);
399 if (FLAG_trace_deopt) {
400 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
401 top_address + output_offset, output_offset, callers_pc);
402 }
403
404 // Read caller's FP from the previous frame, and set this frame's FP.
405 output_offset -= kPointerSize;
406 intptr_t value = output_[frame_index - 1]->GetFp();
407 output_frame->SetFrameSlot(output_offset, value);
408 intptr_t fp_value = top_address + output_offset;
409 output_frame->SetFp(fp_value);
410 if (FLAG_trace_deopt) {
411 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
412 fp_value, output_offset, value);
413 }
414
415 // A marker value is used in place of the context.
416 output_offset -= kPointerSize;
417 intptr_t context = reinterpret_cast<intptr_t>(
418 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
419 output_frame->SetFrameSlot(output_offset, context);
420 if (FLAG_trace_deopt) {
421 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context (adaptor sentinel)\n",
422 top_address + output_offset, output_offset, context);
423 }
424
425 // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME.
426 output_offset -= kPointerSize;
427 value = reinterpret_cast<intptr_t>(function);
428 output_frame->SetFrameSlot(output_offset, value);
429 if (FLAG_trace_deopt) {
430 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n",
431 top_address + output_offset, output_offset, value);
432 }
433
434 // Number of incoming arguments.
435 output_offset -= kPointerSize;
436 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
437 output_frame->SetFrameSlot(output_offset, value);
438 if (FLAG_trace_deopt) {
439 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
440 top_address + output_offset, output_offset, value, height - 1);
441 }
442
443 ASSERT(0 == output_offset);
444
445 Builtins* builtins = isolate_->builtins();
446 Code* adaptor_trampoline =
447 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
448 uint32_t pc = reinterpret_cast<uint32_t>(
449 adaptor_trampoline->instruction_start() +
450 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
451 output_frame->SetPc(pc);
452 }
453
454
455 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator, 359 void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
456 int frame_index) { 360 int frame_index) {
457 // 361 //
458 // FROM TO 362 // FROM TO
459 // | .... | | .... | 363 // | .... | | .... |
460 // +-------------------------+ +-------------------------+ 364 // +-------------------------+ +-------------------------+
461 // | JSFunction continuation | | JSFunction continuation | 365 // | JSFunction continuation | | JSFunction continuation |
462 // +-------------------------+ +-------------------------+ 366 // +-------------------------+ +-------------------------+
463 // | | saved frame (fp) | | saved frame (fp) | 367 // | | saved frame (fp) | | saved frame (fp) |
464 // | +=========================+<-fp +=========================+<-fp 368 // | +=========================+<-fp +=========================+<-fp
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 652
749 ASSERT(0 == output_offset); 653 ASSERT(0 == output_offset);
750 654
751 uint32_t pc = reinterpret_cast<uint32_t>( 655 uint32_t pc = reinterpret_cast<uint32_t>(
752 construct_stub->instruction_start() + 656 construct_stub->instruction_start() +
753 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); 657 isolate_->heap()->construct_stub_deopt_pc_offset()->value());
754 output_frame->SetPc(pc); 658 output_frame->SetPc(pc);
755 } 659 }
756 660
757 661
758 void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator,
759 int frame_index,
760 bool is_setter_stub_frame) {
761 JSFunction* accessor = JSFunction::cast(ComputeLiteral(iterator->Next()));
762 // The receiver (and the implicit return value, if any) are expected in
763 // registers by the LoadIC/StoreIC, so they don't belong to the output stack
764 // frame. This means that we have to use a height of 0.
765 unsigned height = 0;
766 unsigned height_in_bytes = height * kPointerSize;
767 const char* kind = is_setter_stub_frame ? "setter" : "getter";
768 if (trace_) {
769 PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes);
770 }
771
772 // We need 5 stack entries from StackFrame::INTERNAL (lr, fp, cp, frame type,
773 // code object, see MacroAssembler::EnterFrame). For a setter stub frames we
774 // need one additional entry for the implicit return value, see
775 // StoreStubCompiler::CompileStoreViaSetter.
776 unsigned fixed_frame_entries = 5 + (is_setter_stub_frame ? 1 : 0);
777 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize;
778 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
779
780 // Allocate and store the output frame description.
781 FrameDescription* output_frame =
782 new(output_frame_size) FrameDescription(output_frame_size, accessor);
783 output_frame->SetFrameType(StackFrame::INTERNAL);
784
785 // A frame for an accessor stub can not be the topmost or bottommost one.
786 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
787 ASSERT(output_[frame_index] == NULL);
788 output_[frame_index] = output_frame;
789
790 // The top address of the frame is computed from the previous frame's top and
791 // this frame's size.
792 uint32_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
793 output_frame->SetTop(top_address);
794
795 unsigned output_offset = output_frame_size;
796
797 // Read caller's PC from the previous frame.
798 output_offset -= kPointerSize;
799 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
800 output_frame->SetFrameSlot(output_offset, callers_pc);
801 if (trace_) {
802 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
803 " ; caller's pc\n",
804 top_address + output_offset, output_offset, callers_pc);
805 }
806
807 // Read caller's FP from the previous frame, and set this frame's FP.
808 output_offset -= kPointerSize;
809 intptr_t value = output_[frame_index - 1]->GetFp();
810 output_frame->SetFrameSlot(output_offset, value);
811 intptr_t fp_value = top_address + output_offset;
812 output_frame->SetFp(fp_value);
813 if (trace_) {
814 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
815 " ; caller's fp\n",
816 fp_value, output_offset, value);
817 }
818
819 // The context can be gotten from the previous frame.
820 output_offset -= kPointerSize;
821 value = output_[frame_index - 1]->GetContext();
822 output_frame->SetFrameSlot(output_offset, value);
823 if (trace_) {
824 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
825 " ; context\n",
826 top_address + output_offset, output_offset, value);
827 }
828
829 // A marker value is used in place of the function.
830 output_offset -= kPointerSize;
831 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL));
832 output_frame->SetFrameSlot(output_offset, value);
833 if (trace_) {
834 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
835 " ; function (%s sentinel)\n",
836 top_address + output_offset, output_offset, value, kind);
837 }
838
839 // Get Code object from accessor stub.
840 output_offset -= kPointerSize;
841 Builtins::Name name = is_setter_stub_frame ?
842 Builtins::kStoreIC_Setter_ForDeopt :
843 Builtins::kLoadIC_Getter_ForDeopt;
844 Code* accessor_stub = isolate_->builtins()->builtin(name);
845 value = reinterpret_cast<intptr_t>(accessor_stub);
846 output_frame->SetFrameSlot(output_offset, value);
847 if (trace_) {
848 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
849 " ; code object\n",
850 top_address + output_offset, output_offset, value);
851 }
852
853 // Skip receiver.
854 Translation::Opcode opcode =
855 static_cast<Translation::Opcode>(iterator->Next());
856 iterator->Skip(Translation::NumberOfOperandsFor(opcode));
857
858 if (is_setter_stub_frame) {
859 // The implicit return value was part of the artificial setter stub
860 // environment.
861 output_offset -= kPointerSize;
862 DoTranslateCommand(iterator, frame_index, output_offset);
863 }
864
865 ASSERT(0 == output_offset);
866
867 Smi* offset = is_setter_stub_frame ?
868 isolate_->heap()->setter_stub_deopt_pc_offset() :
869 isolate_->heap()->getter_stub_deopt_pc_offset();
870 intptr_t pc = reinterpret_cast<intptr_t>(
871 accessor_stub->instruction_start() + offset->value());
872 output_frame->SetPc(pc);
873 }
874
875
876 // This code is very similar to ia32 code, but relies on register names (fp, sp) 662 // This code is very similar to ia32 code, but relies on register names (fp, sp)
877 // and how the frame is laid out. 663 // and how the frame is laid out.
878 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, 664 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
879 int frame_index) { 665 int frame_index) {
880 // Read the ast node id, function, and frame height for this output frame. 666 // Read the ast node id, function, and frame height for this output frame.
881 BailoutId node_id = BailoutId(iterator->Next()); 667 BailoutId node_id = BailoutId(iterator->Next());
882 JSFunction* function; 668 JSFunction* function;
883 if (frame_index != 0) { 669 if (frame_index != 0) {
884 function = JSFunction::cast(ComputeLiteral(iterator->Next())); 670 function = JSFunction::cast(ComputeLiteral(iterator->Next()));
885 } else { 671 } else {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 __ push(ip); 1097 __ push(ip);
1312 __ b(&done); 1098 __ b(&done);
1313 ASSERT(masm()->pc_offset() - start == table_entry_size_); 1099 ASSERT(masm()->pc_offset() - start == table_entry_size_);
1314 } 1100 }
1315 __ bind(&done); 1101 __ bind(&done);
1316 } 1102 }
1317 1103
1318 #undef __ 1104 #undef __
1319 1105
1320 } } // namespace v8::internal 1106 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/deoptimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698