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

Side by Side Diff: src/mips/deoptimizer-mips.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 | « src/ia32/deoptimizer-ia32.cc ('k') | src/x64/deoptimizer-x64.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (FLAG_trace_osr) { 342 if (FLAG_trace_osr) {
343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", 343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ",
344 ok ? "finished" : "aborted", 344 ok ? "finished" : "aborted",
345 reinterpret_cast<intptr_t>(function_)); 345 reinterpret_cast<intptr_t>(function_));
346 function_->PrintName(); 346 function_->PrintName();
347 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); 347 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc());
348 } 348 }
349 } 349 }
350 350
351 351
352 void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
353 int frame_index) {
354 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
355 unsigned height = iterator->Next();
356 unsigned height_in_bytes = height * kPointerSize;
357 if (FLAG_trace_deopt) {
358 PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes);
359 }
360
361 unsigned fixed_frame_size = ArgumentsAdaptorFrameConstants::kFrameSize;
362 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
363
364 // Allocate and store the output frame description.
365 FrameDescription* output_frame =
366 new(output_frame_size) FrameDescription(output_frame_size, function);
367 output_frame->SetFrameType(StackFrame::ARGUMENTS_ADAPTOR);
368
369 // Arguments adaptor can not be topmost or bottommost.
370 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
371 ASSERT(output_[frame_index] == NULL);
372 output_[frame_index] = output_frame;
373
374 // The top address of the frame is computed from the previous
375 // frame's top and this frame's size.
376 uint32_t top_address;
377 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
378 output_frame->SetTop(top_address);
379
380 // Compute the incoming parameter translation.
381 int parameter_count = height;
382 unsigned output_offset = output_frame_size;
383 for (int i = 0; i < parameter_count; ++i) {
384 output_offset -= kPointerSize;
385 DoTranslateCommand(iterator, frame_index, output_offset);
386 }
387
388 // Read caller's PC from the previous frame.
389 output_offset -= kPointerSize;
390 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
391 output_frame->SetFrameSlot(output_offset, callers_pc);
392 if (FLAG_trace_deopt) {
393 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
394 top_address + output_offset, output_offset, callers_pc);
395 }
396
397 // Read caller's FP from the previous frame, and set this frame's FP.
398 output_offset -= kPointerSize;
399 intptr_t value = output_[frame_index - 1]->GetFp();
400 output_frame->SetFrameSlot(output_offset, value);
401 intptr_t fp_value = top_address + output_offset;
402 output_frame->SetFp(fp_value);
403 if (FLAG_trace_deopt) {
404 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
405 fp_value, output_offset, value);
406 }
407
408 // A marker value is used in place of the context.
409 output_offset -= kPointerSize;
410 intptr_t context = reinterpret_cast<intptr_t>(
411 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
412 output_frame->SetFrameSlot(output_offset, context);
413 if (FLAG_trace_deopt) {
414 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context (adaptor sentinel)\n",
415 top_address + output_offset, output_offset, context);
416 }
417
418 // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME.
419 output_offset -= kPointerSize;
420 value = reinterpret_cast<intptr_t>(function);
421 output_frame->SetFrameSlot(output_offset, value);
422 if (FLAG_trace_deopt) {
423 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n",
424 top_address + output_offset, output_offset, value);
425 }
426
427 // Number of incoming arguments.
428 output_offset -= kPointerSize;
429 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
430 output_frame->SetFrameSlot(output_offset, value);
431 if (FLAG_trace_deopt) {
432 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
433 top_address + output_offset, output_offset, value, height - 1);
434 }
435
436 ASSERT(0 == output_offset);
437
438 Builtins* builtins = isolate_->builtins();
439 Code* adaptor_trampoline =
440 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
441 uint32_t pc = reinterpret_cast<uint32_t>(
442 adaptor_trampoline->instruction_start() +
443 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
444 output_frame->SetPc(pc);
445 }
446
447
448 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, 352 void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
449 int frame_index) { 353 int frame_index) {
450 // 354 //
451 // FROM TO 355 // FROM TO
452 // | .... | | .... | 356 // | .... | | .... |
453 // +-------------------------+ +-------------------------+ 357 // +-------------------------+ +-------------------------+
454 // | JSFunction continuation | | JSFunction continuation | 358 // | JSFunction continuation | | JSFunction continuation |
455 // +-------------------------+ +-------------------------+ 359 // +-------------------------+ +-------------------------+
456 // | | saved frame (fp) | | saved frame (fp) | 360 // | | saved frame (fp) | | saved frame (fp) |
457 // | +=========================+<-fp +=========================+<-fp 361 // | +=========================+<-fp +=========================+<-fp
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 603
700 ASSERT(0 == output_offset); 604 ASSERT(0 == output_offset);
701 605
702 uint32_t pc = reinterpret_cast<uint32_t>( 606 uint32_t pc = reinterpret_cast<uint32_t>(
703 construct_stub->instruction_start() + 607 construct_stub->instruction_start() +
704 isolate_->heap()->construct_stub_deopt_pc_offset()->value()); 608 isolate_->heap()->construct_stub_deopt_pc_offset()->value());
705 output_frame->SetPc(pc); 609 output_frame->SetPc(pc);
706 } 610 }
707 611
708 612
709 void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator,
710 int frame_index,
711 bool is_setter_stub_frame) {
712 JSFunction* accessor = JSFunction::cast(ComputeLiteral(iterator->Next()));
713 // The receiver (and the implicit return value, if any) are expected in
714 // registers by the LoadIC/StoreIC, so they don't belong to the output stack
715 // frame. This means that we have to use a height of 0.
716 unsigned height = 0;
717 unsigned height_in_bytes = height * kPointerSize;
718 const char* kind = is_setter_stub_frame ? "setter" : "getter";
719 if (trace_) {
720 PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes);
721 }
722
723 // We need 5 stack entries from StackFrame::INTERNAL (ra, fp, cp, frame type,
724 // code object, see MacroAssembler::EnterFrame). For a setter stub frame we
725 // need one additional entry for the implicit return value, see
726 // StoreStubCompiler::CompileStoreViaSetter.
727 unsigned fixed_frame_entries = 5 + (is_setter_stub_frame ? 1 : 0);
728 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize;
729 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
730
731 // Allocate and store the output frame description.
732 FrameDescription* output_frame =
733 new(output_frame_size) FrameDescription(output_frame_size, accessor);
734 output_frame->SetFrameType(StackFrame::INTERNAL);
735
736 // A frame for an accessor stub can not be the topmost or bottommost one.
737 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
738 ASSERT(output_[frame_index] == NULL);
739 output_[frame_index] = output_frame;
740
741 // The top address of the frame is computed from the previous frame's top and
742 // this frame's size.
743 uint32_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
744 output_frame->SetTop(top_address);
745
746 unsigned output_offset = output_frame_size;
747
748 // Read caller's PC from the previous frame.
749 output_offset -= kPointerSize;
750 intptr_t value = output_[frame_index - 1]->GetPc();
751 output_frame->SetFrameSlot(output_offset, value);
752 if (trace_) {
753 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
754 " ; caller's pc\n",
755 top_address + output_offset, output_offset, value);
756 }
757
758 // Read caller's FP from the previous frame, and set this frame's FP.
759 output_offset -= kPointerSize;
760 value = output_[frame_index - 1]->GetFp();
761 output_frame->SetFrameSlot(output_offset, value);
762 intptr_t fp_value = top_address + output_offset;
763 output_frame->SetFp(fp_value);
764 if (trace_) {
765 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
766 " ; caller's fp\n",
767 fp_value, output_offset, value);
768 }
769
770 // The context can be gotten from the previous frame.
771 output_offset -= kPointerSize;
772 value = output_[frame_index - 1]->GetContext();
773 output_frame->SetFrameSlot(output_offset, value);
774 if (trace_) {
775 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
776 " ; context\n",
777 top_address + output_offset, output_offset, value);
778 }
779
780 // A marker value is used in place of the function.
781 output_offset -= kPointerSize;
782 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::INTERNAL));
783 output_frame->SetFrameSlot(output_offset, value);
784 if (trace_) {
785 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
786 " ; function (%s sentinel)\n",
787 top_address + output_offset, output_offset, value, kind);
788 }
789
790 // Get Code object from accessor stub.
791 output_offset -= kPointerSize;
792 Builtins::Name name = is_setter_stub_frame ?
793 Builtins::kStoreIC_Setter_ForDeopt :
794 Builtins::kLoadIC_Getter_ForDeopt;
795 Code* accessor_stub = isolate_->builtins()->builtin(name);
796 value = reinterpret_cast<intptr_t>(accessor_stub);
797 output_frame->SetFrameSlot(output_offset, value);
798 if (trace_) {
799 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
800 " ; code object\n",
801 top_address + output_offset, output_offset, value);
802 }
803
804 // Skip receiver.
805 Translation::Opcode opcode =
806 static_cast<Translation::Opcode>(iterator->Next());
807 iterator->Skip(Translation::NumberOfOperandsFor(opcode));
808
809 if (is_setter_stub_frame) {
810 // The implicit return value was part of the artificial setter stub
811 // environment.
812 output_offset -= kPointerSize;
813 DoTranslateCommand(iterator, frame_index, output_offset);
814 }
815
816 ASSERT(0 == output_offset);
817
818 Smi* offset = is_setter_stub_frame ?
819 isolate_->heap()->setter_stub_deopt_pc_offset() :
820 isolate_->heap()->getter_stub_deopt_pc_offset();
821 intptr_t pc = reinterpret_cast<intptr_t>(
822 accessor_stub->instruction_start() + offset->value());
823 output_frame->SetPc(pc);
824 }
825
826
827 // This code is very similar to ia32/arm code, but relies on register names 613 // This code is very similar to ia32/arm code, but relies on register names
828 // (fp, sp) and how the frame is laid out. 614 // (fp, sp) and how the frame is laid out.
829 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator, 615 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
830 int frame_index) { 616 int frame_index) {
831 // Read the ast node id, function, and frame height for this output frame. 617 // Read the ast node id, function, and frame height for this output frame.
832 BailoutId node_id = BailoutId(iterator->Next()); 618 BailoutId node_id = BailoutId(iterator->Next());
833 JSFunction* function; 619 JSFunction* function;
834 if (frame_index != 0) { 620 if (frame_index != 0) {
835 function = JSFunction::cast(ComputeLiteral(iterator->Next())); 621 function = JSFunction::cast(ComputeLiteral(iterator->Next()));
836 } else { 622 } else {
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 } 1068 }
1283 1069
1284 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start), 1070 ASSERT_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
1285 count() * table_entry_size_); 1071 count() * table_entry_size_);
1286 } 1072 }
1287 1073
1288 #undef __ 1074 #undef __
1289 1075
1290 1076
1291 } } // namespace v8::internal 1077 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/deoptimizer-ia32.cc ('k') | src/x64/deoptimizer-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698