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

Side by Side Diff: src/deoptimizer.cc

Issue 12379042: Unify deoptimizer for construct stub 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/arm/frames-arm.h ('k') | src/ia32/deoptimizer-ia32.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 Builtins* builtins = isolate_->builtins(); 915 Builtins* builtins = isolate_->builtins();
916 Code* adaptor_trampoline = 916 Code* adaptor_trampoline =
917 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline); 917 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
918 intptr_t pc_value = reinterpret_cast<intptr_t>( 918 intptr_t pc_value = reinterpret_cast<intptr_t>(
919 adaptor_trampoline->instruction_start() + 919 adaptor_trampoline->instruction_start() +
920 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value()); 920 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
921 output_frame->SetPc(pc_value); 921 output_frame->SetPc(pc_value);
922 } 922 }
923 923
924 924
925 void Deoptimizer::DoComputeConstructStubFrame(TranslationIterator* iterator,
926 int frame_index) {
927 Builtins* builtins = isolate_->builtins();
928 Code* construct_stub = builtins->builtin(Builtins::kJSConstructStubGeneric);
929 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
930 unsigned height = iterator->Next();
931 unsigned height_in_bytes = height * kPointerSize;
932 if (trace_) {
933 PrintF(" translating construct stub => height=%d\n", height_in_bytes);
934 }
935
936 unsigned fixed_frame_size = ConstructFrameConstants::kFrameSize;
937 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
938
939 // Allocate and store the output frame description.
940 FrameDescription* output_frame =
941 new(output_frame_size) FrameDescription(output_frame_size, function);
942 output_frame->SetFrameType(StackFrame::CONSTRUCT);
943
944 // Construct stub can not be topmost or bottommost.
945 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
946 ASSERT(output_[frame_index] == NULL);
947 output_[frame_index] = output_frame;
948
949 // The top address of the frame is computed from the previous
950 // frame's top and this frame's size.
951 intptr_t top_address;
952 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
953 output_frame->SetTop(top_address);
954
955 // Compute the incoming parameter translation.
956 int parameter_count = height;
957 unsigned output_offset = output_frame_size;
958 for (int i = 0; i < parameter_count; ++i) {
959 output_offset -= kPointerSize;
960 DoTranslateCommand(iterator, frame_index, output_offset);
961 }
962
963 // Read caller's PC from the previous frame.
964 output_offset -= kPointerSize;
965 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
966 output_frame->SetFrameSlot(output_offset, callers_pc);
967 if (trace_) {
968 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
969 V8PRIxPTR " ; caller's pc\n",
970 top_address + output_offset, output_offset, callers_pc);
971 }
972
973 // Read caller's FP from the previous frame, and set this frame's FP.
974 output_offset -= kPointerSize;
975 intptr_t value = output_[frame_index - 1]->GetFp();
976 output_frame->SetFrameSlot(output_offset, value);
977 intptr_t fp_value = top_address + output_offset;
978 output_frame->SetFp(fp_value);
979 if (trace_) {
980 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
981 V8PRIxPTR " ; caller's fp\n",
982 fp_value, output_offset, value);
983 }
984
985 // The context can be gotten from the previous frame.
986 output_offset -= kPointerSize;
987 value = output_[frame_index - 1]->GetContext();
988 output_frame->SetFrameSlot(output_offset, value);
989 if (trace_) {
990 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
991 V8PRIxPTR " ; context\n",
992 top_address + output_offset, output_offset, value);
993 }
994
995 // A marker value is used in place of the function.
996 output_offset -= kPointerSize;
997 value = reinterpret_cast<intptr_t>(Smi::FromInt(StackFrame::CONSTRUCT));
998 output_frame->SetFrameSlot(output_offset, value);
999 if (trace_) {
1000 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1001 V8PRIxPTR " ; function (construct sentinel)\n",
1002 top_address + output_offset, output_offset, value);
1003 }
1004
1005 // The output frame reflects a JSConstructStubGeneric frame.
1006 output_offset -= kPointerSize;
1007 value = reinterpret_cast<intptr_t>(construct_stub);
1008 output_frame->SetFrameSlot(output_offset, value);
1009 if (trace_) {
1010 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1011 V8PRIxPTR " ; code object\n",
1012 top_address + output_offset, output_offset, value);
1013 }
1014
1015 // Number of incoming arguments.
1016 output_offset -= kPointerSize;
1017 value = reinterpret_cast<intptr_t>(Smi::FromInt(height - 1));
1018 output_frame->SetFrameSlot(output_offset, value);
1019 if (trace_) {
1020 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1021 V8PRIxPTR " ; argc (%d)\n",
1022 top_address + output_offset, output_offset, value, height - 1);
1023 }
1024
1025 // Constructor function being invoked by the stub (only present on some
1026 // architectures, indicated by kConstructorOffset).
1027 if (ConstructFrameConstants::kConstructorOffset != kMinInt) {
1028 output_offset -= kPointerSize;
1029 value = reinterpret_cast<intptr_t>(function);
1030 output_frame->SetFrameSlot(output_offset, value);
1031 if (trace_) {
1032 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1033 V8PRIxPTR " ; constructor function\n",
1034 top_address + output_offset, output_offset, value);
1035 }
1036 }
1037
1038 // The newly allocated object was passed as receiver in the artificial
1039 // constructor stub environment created by HEnvironment::CopyForInlining().
1040 output_offset -= kPointerSize;
1041 value = output_frame->GetFrameSlot(output_frame_size - kPointerSize);
1042 output_frame->SetFrameSlot(output_offset, value);
1043 if (trace_) {
1044 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1045 V8PRIxPTR " ; allocated receiver\n",
1046 top_address + output_offset, output_offset, value);
1047 }
1048
1049 ASSERT(0 == output_offset);
1050
1051 intptr_t pc = reinterpret_cast<intptr_t>(
1052 construct_stub->instruction_start() +
1053 isolate_->heap()->construct_stub_deopt_pc_offset()->value());
1054 output_frame->SetPc(pc);
1055 }
1056
1057
925 void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator, 1058 void Deoptimizer::DoComputeAccessorStubFrame(TranslationIterator* iterator,
926 int frame_index, 1059 int frame_index,
927 bool is_setter_stub_frame) { 1060 bool is_setter_stub_frame) {
928 JSFunction* accessor = JSFunction::cast(ComputeLiteral(iterator->Next())); 1061 JSFunction* accessor = JSFunction::cast(ComputeLiteral(iterator->Next()));
929 // The receiver (and the implicit return value, if any) are expected in 1062 // The receiver (and the implicit return value, if any) are expected in
930 // registers by the LoadIC/StoreIC, so they don't belong to the output stack 1063 // registers by the LoadIC/StoreIC, so they don't belong to the output stack
931 // frame. This means that we have to use a height of 0. 1064 // frame. This means that we have to use a height of 0.
932 unsigned height = 0; 1065 unsigned height = 0;
933 unsigned height_in_bytes = height * kPointerSize; 1066 unsigned height_in_bytes = height * kPointerSize;
934 const char* kind = is_setter_stub_frame ? "setter" : "getter"; 1067 const char* kind = is_setter_stub_frame ? "setter" : "getter";
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 2499
2367 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 2500 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
2368 v->VisitPointer(BitCast<Object**>(&function_)); 2501 v->VisitPointer(BitCast<Object**>(&function_));
2369 v->VisitPointers(parameters_, parameters_ + parameters_count_); 2502 v->VisitPointers(parameters_, parameters_ + parameters_count_);
2370 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 2503 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
2371 } 2504 }
2372 2505
2373 #endif // ENABLE_DEBUGGER_SUPPORT 2506 #endif // ENABLE_DEBUGGER_SUPPORT
2374 2507
2375 } } // namespace v8::internal 2508 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/frames-arm.h ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698