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

Side by Side Diff: src/deoptimizer.cc

Issue 19748003: Introduce kRegisterSize, kPCOnStackSize and kFPOnStackSize constants (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 5 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/deoptimizer.h ('k') | src/frames.h » ('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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 input_offset -= (parameter_count * kPointerSize); 887 input_offset -= (parameter_count * kPointerSize);
888 888
889 // There are no translation commands for the caller's pc and fp, the 889 // There are no translation commands for the caller's pc and fp, the
890 // context, and the function. Synthesize their values and set them up 890 // context, and the function. Synthesize their values and set them up
891 // explicitly. 891 // explicitly.
892 // 892 //
893 // The caller's pc for the bottommost output frame is the same as in the 893 // The caller's pc for the bottommost output frame is the same as in the
894 // input frame. For all subsequent output frames, it can be read from the 894 // input frame. For all subsequent output frames, it can be read from the
895 // previous one. This frame's pc can be computed from the non-optimized 895 // previous one. This frame's pc can be computed from the non-optimized
896 // function code and AST id of the bailout. 896 // function code and AST id of the bailout.
897 output_offset -= kPointerSize; 897 output_offset -= kPCOnStackSize;
898 input_offset -= kPointerSize; 898 input_offset -= kPCOnStackSize;
899 intptr_t value; 899 intptr_t value;
900 if (is_bottommost) { 900 if (is_bottommost) {
901 value = input_->GetFrameSlot(input_offset); 901 value = input_->GetFrameSlot(input_offset);
902 } else { 902 } else {
903 value = output_[frame_index - 1]->GetPc(); 903 value = output_[frame_index - 1]->GetPc();
904 } 904 }
905 output_frame->SetFrameSlot(output_offset, value); 905 output_frame->SetCallerPc(output_offset, value);
906 if (trace_) { 906 if (trace_) {
907 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 907 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
908 V8PRIxPTR " ; caller's pc\n", 908 V8PRIxPTR " ; caller's pc\n",
909 top_address + output_offset, output_offset, value); 909 top_address + output_offset, output_offset, value);
910 } 910 }
911 911
912 // The caller's frame pointer for the bottommost output frame is the same 912 // The caller's frame pointer for the bottommost output frame is the same
913 // as in the input frame. For all subsequent output frames, it can be 913 // as in the input frame. For all subsequent output frames, it can be
914 // read from the previous one. Also compute and set this frame's frame 914 // read from the previous one. Also compute and set this frame's frame
915 // pointer. 915 // pointer.
916 output_offset -= kPointerSize; 916 output_offset -= kFPOnStackSize;
917 input_offset -= kPointerSize; 917 input_offset -= kFPOnStackSize;
918 if (is_bottommost) { 918 if (is_bottommost) {
919 value = input_->GetFrameSlot(input_offset); 919 value = input_->GetFrameSlot(input_offset);
920 } else { 920 } else {
921 value = output_[frame_index - 1]->GetFp(); 921 value = output_[frame_index - 1]->GetFp();
922 } 922 }
923 output_frame->SetFrameSlot(output_offset, value); 923 output_frame->SetCallerFp(output_offset, value);
924 intptr_t fp_value = top_address + output_offset; 924 intptr_t fp_value = top_address + output_offset;
925 ASSERT(!is_bottommost || (input_->GetRegister(fp_reg.code()) + 925 ASSERT(!is_bottommost || (input_->GetRegister(fp_reg.code()) +
926 has_alignment_padding_ * kPointerSize) == fp_value); 926 has_alignment_padding_ * kPointerSize) == fp_value);
927 output_frame->SetFp(fp_value); 927 output_frame->SetFp(fp_value);
928 if (is_topmost) output_frame->SetRegister(fp_reg.code(), fp_value); 928 if (is_topmost) output_frame->SetRegister(fp_reg.code(), fp_value);
929 if (trace_) { 929 if (trace_) {
930 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 930 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
931 V8PRIxPTR " ; caller's fp\n", 931 V8PRIxPTR " ; caller's fp\n",
932 fp_value, output_offset, value); 932 fp_value, output_offset, value);
933 } 933 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1036
1037 // Compute the incoming parameter translation. 1037 // Compute the incoming parameter translation.
1038 int parameter_count = height; 1038 int parameter_count = height;
1039 unsigned output_offset = output_frame_size; 1039 unsigned output_offset = output_frame_size;
1040 for (int i = 0; i < parameter_count; ++i) { 1040 for (int i = 0; i < parameter_count; ++i) {
1041 output_offset -= kPointerSize; 1041 output_offset -= kPointerSize;
1042 DoTranslateCommand(iterator, frame_index, output_offset); 1042 DoTranslateCommand(iterator, frame_index, output_offset);
1043 } 1043 }
1044 1044
1045 // Read caller's PC from the previous frame. 1045 // Read caller's PC from the previous frame.
1046 output_offset -= kPointerSize; 1046 output_offset -= kPCOnStackSize;
1047 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); 1047 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
1048 output_frame->SetFrameSlot(output_offset, callers_pc); 1048 output_frame->SetCallerPc(output_offset, callers_pc);
1049 if (trace_) { 1049 if (trace_) {
1050 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 1050 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1051 V8PRIxPTR " ; caller's pc\n", 1051 V8PRIxPTR " ; caller's pc\n",
1052 top_address + output_offset, output_offset, callers_pc); 1052 top_address + output_offset, output_offset, callers_pc);
1053 } 1053 }
1054 1054
1055 // Read caller's FP from the previous frame, and set this frame's FP. 1055 // Read caller's FP from the previous frame, and set this frame's FP.
1056 output_offset -= kPointerSize; 1056 output_offset -= kFPOnStackSize;
1057 intptr_t value = output_[frame_index - 1]->GetFp(); 1057 intptr_t value = output_[frame_index - 1]->GetFp();
1058 output_frame->SetFrameSlot(output_offset, value); 1058 output_frame->SetCallerFp(output_offset, value);
1059 intptr_t fp_value = top_address + output_offset; 1059 intptr_t fp_value = top_address + output_offset;
1060 output_frame->SetFp(fp_value); 1060 output_frame->SetFp(fp_value);
1061 if (trace_) { 1061 if (trace_) {
1062 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 1062 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1063 V8PRIxPTR " ; caller's fp\n", 1063 V8PRIxPTR " ; caller's fp\n",
1064 fp_value, output_offset, value); 1064 fp_value, output_offset, value);
1065 } 1065 }
1066 1066
1067 // A marker value is used in place of the context. 1067 // A marker value is used in place of the context.
1068 output_offset -= kPointerSize; 1068 output_offset -= kPointerSize;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 1139
1140 // Compute the incoming parameter translation. 1140 // Compute the incoming parameter translation.
1141 int parameter_count = height; 1141 int parameter_count = height;
1142 unsigned output_offset = output_frame_size; 1142 unsigned output_offset = output_frame_size;
1143 for (int i = 0; i < parameter_count; ++i) { 1143 for (int i = 0; i < parameter_count; ++i) {
1144 output_offset -= kPointerSize; 1144 output_offset -= kPointerSize;
1145 DoTranslateCommand(iterator, frame_index, output_offset); 1145 DoTranslateCommand(iterator, frame_index, output_offset);
1146 } 1146 }
1147 1147
1148 // Read caller's PC from the previous frame. 1148 // Read caller's PC from the previous frame.
1149 output_offset -= kPointerSize; 1149 output_offset -= kPCOnStackSize;
1150 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); 1150 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
1151 output_frame->SetFrameSlot(output_offset, callers_pc); 1151 output_frame->SetCallerPc(output_offset, callers_pc);
1152 if (trace_) { 1152 if (trace_) {
1153 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 1153 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1154 V8PRIxPTR " ; caller's pc\n", 1154 V8PRIxPTR " ; caller's pc\n",
1155 top_address + output_offset, output_offset, callers_pc); 1155 top_address + output_offset, output_offset, callers_pc);
1156 } 1156 }
1157 1157
1158 // Read caller's FP from the previous frame, and set this frame's FP. 1158 // Read caller's FP from the previous frame, and set this frame's FP.
1159 output_offset -= kPointerSize; 1159 output_offset -= kFPOnStackSize;
1160 intptr_t value = output_[frame_index - 1]->GetFp(); 1160 intptr_t value = output_[frame_index - 1]->GetFp();
1161 output_frame->SetFrameSlot(output_offset, value); 1161 output_frame->SetCallerFp(output_offset, value);
1162 intptr_t fp_value = top_address + output_offset; 1162 intptr_t fp_value = top_address + output_offset;
1163 output_frame->SetFp(fp_value); 1163 output_frame->SetFp(fp_value);
1164 if (trace_) { 1164 if (trace_) {
1165 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 1165 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1166 V8PRIxPTR " ; caller's fp\n", 1166 V8PRIxPTR " ; caller's fp\n",
1167 fp_value, output_offset, value); 1167 fp_value, output_offset, value);
1168 } 1168 }
1169 1169
1170 // The context can be gotten from the previous frame. 1170 // The context can be gotten from the previous frame.
1171 output_offset -= kPointerSize; 1171 output_offset -= kPointerSize;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 const char* kind = is_setter_stub_frame ? "setter" : "getter"; 1252 const char* kind = is_setter_stub_frame ? "setter" : "getter";
1253 if (trace_) { 1253 if (trace_) {
1254 PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes); 1254 PrintF(" translating %s stub => height=%u\n", kind, height_in_bytes);
1255 } 1255 }
1256 1256
1257 // We need 1 stack entry for the return address + 4 stack entries from 1257 // We need 1 stack entry for the return address + 4 stack entries from
1258 // StackFrame::INTERNAL (FP, context, frame type, code object, see 1258 // StackFrame::INTERNAL (FP, context, frame type, code object, see
1259 // MacroAssembler::EnterFrame). For a setter stub frame we need one additional 1259 // MacroAssembler::EnterFrame). For a setter stub frame we need one additional
1260 // entry for the implicit return value, see 1260 // entry for the implicit return value, see
1261 // StoreStubCompiler::CompileStoreViaSetter. 1261 // StoreStubCompiler::CompileStoreViaSetter.
1262 unsigned fixed_frame_entries = 1 + 4 + (is_setter_stub_frame ? 1 : 0); 1262 unsigned fixed_frame_entries = (kPCOnStackSize/kPointerSize) +
1263 (kFPOnStackSize/kPointerSize) + 3 +
1264 (is_setter_stub_frame ? 1 : 0);
1263 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize; 1265 unsigned fixed_frame_size = fixed_frame_entries * kPointerSize;
1264 unsigned output_frame_size = height_in_bytes + fixed_frame_size; 1266 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
1265 1267
1266 // Allocate and store the output frame description. 1268 // Allocate and store the output frame description.
1267 FrameDescription* output_frame = 1269 FrameDescription* output_frame =
1268 new(output_frame_size) FrameDescription(output_frame_size, accessor); 1270 new(output_frame_size) FrameDescription(output_frame_size, accessor);
1269 output_frame->SetFrameType(StackFrame::INTERNAL); 1271 output_frame->SetFrameType(StackFrame::INTERNAL);
1270 1272
1271 // A frame for an accessor stub can not be the topmost or bottommost one. 1273 // A frame for an accessor stub can not be the topmost or bottommost one.
1272 ASSERT(frame_index > 0 && frame_index < output_count_ - 1); 1274 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
1273 ASSERT(output_[frame_index] == NULL); 1275 ASSERT(output_[frame_index] == NULL);
1274 output_[frame_index] = output_frame; 1276 output_[frame_index] = output_frame;
1275 1277
1276 // The top address of the frame is computed from the previous frame's top and 1278 // The top address of the frame is computed from the previous frame's top and
1277 // this frame's size. 1279 // this frame's size.
1278 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size; 1280 intptr_t top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
1279 output_frame->SetTop(top_address); 1281 output_frame->SetTop(top_address);
1280 1282
1281 unsigned output_offset = output_frame_size; 1283 unsigned output_offset = output_frame_size;
1282 1284
1283 // Read caller's PC from the previous frame. 1285 // Read caller's PC from the previous frame.
1284 output_offset -= kPointerSize; 1286 output_offset -= kPCOnStackSize;
1285 intptr_t callers_pc = output_[frame_index - 1]->GetPc(); 1287 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
1286 output_frame->SetFrameSlot(output_offset, callers_pc); 1288 output_frame->SetCallerPc(output_offset, callers_pc);
1287 if (trace_) { 1289 if (trace_) {
1288 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR 1290 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
1289 " ; caller's pc\n", 1291 " ; caller's pc\n",
1290 top_address + output_offset, output_offset, callers_pc); 1292 top_address + output_offset, output_offset, callers_pc);
1291 } 1293 }
1292 1294
1293 // Read caller's FP from the previous frame, and set this frame's FP. 1295 // Read caller's FP from the previous frame, and set this frame's FP.
1294 output_offset -= kPointerSize; 1296 output_offset -= kFPOnStackSize;
1295 intptr_t value = output_[frame_index - 1]->GetFp(); 1297 intptr_t value = output_[frame_index - 1]->GetFp();
1296 output_frame->SetFrameSlot(output_offset, value); 1298 output_frame->SetCallerFp(output_offset, value);
1297 intptr_t fp_value = top_address + output_offset; 1299 intptr_t fp_value = top_address + output_offset;
1298 output_frame->SetFp(fp_value); 1300 output_frame->SetFp(fp_value);
1299 if (trace_) { 1301 if (trace_) {
1300 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR 1302 PrintF(" 0x%08" V8PRIxPTR ": [top + %u] <- 0x%08" V8PRIxPTR
1301 " ; caller's fp\n", 1303 " ; caller's fp\n",
1302 fp_value, output_offset, value); 1304 fp_value, output_offset, value);
1303 } 1305 }
1304 1306
1305 // The context can be gotten from the previous frame. 1307 // The context can be gotten from the previous frame.
1306 output_offset -= kPointerSize; 1308 output_offset -= kPointerSize;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 1424
1423 // The top address for the output frame can be computed from the input 1425 // The top address for the output frame can be computed from the input
1424 // frame pointer and the output frame's height. Subtract space for the 1426 // frame pointer and the output frame's height. Subtract space for the
1425 // context and function slots. 1427 // context and function slots.
1426 Register fp_reg = StubFailureTrampolineFrame::fp_register(); 1428 Register fp_reg = StubFailureTrampolineFrame::fp_register();
1427 intptr_t top_address = input_->GetRegister(fp_reg.code()) - 1429 intptr_t top_address = input_->GetRegister(fp_reg.code()) -
1428 (2 * kPointerSize) - height_in_bytes; 1430 (2 * kPointerSize) - height_in_bytes;
1429 output_frame->SetTop(top_address); 1431 output_frame->SetTop(top_address);
1430 1432
1431 // Read caller's PC (JSFunction continuation) from the input frame. 1433 // Read caller's PC (JSFunction continuation) from the input frame.
1432 unsigned input_frame_offset = input_frame_size - kPointerSize; 1434 unsigned input_frame_offset = input_frame_size - kPCOnStackSize;
1433 unsigned output_frame_offset = output_frame_size - kPointerSize; 1435 unsigned output_frame_offset = output_frame_size - kFPOnStackSize;
1434 intptr_t value = input_->GetFrameSlot(input_frame_offset); 1436 intptr_t value = input_->GetFrameSlot(input_frame_offset);
1435 output_frame->SetFrameSlot(output_frame_offset, value); 1437 output_frame->SetCallerPc(output_frame_offset, value);
1436 if (trace_) { 1438 if (trace_) {
1437 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 1439 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1438 V8PRIxPTR " ; caller's pc\n", 1440 V8PRIxPTR " ; caller's pc\n",
1439 top_address + output_frame_offset, output_frame_offset, value); 1441 top_address + output_frame_offset, output_frame_offset, value);
1440 } 1442 }
1441 1443
1442 // Read caller's FP from the input frame, and set this frame's FP. 1444 // Read caller's FP from the input frame, and set this frame's FP.
1443 input_frame_offset -= kPointerSize; 1445 input_frame_offset -= kFPOnStackSize;
1444 value = input_->GetFrameSlot(input_frame_offset); 1446 value = input_->GetFrameSlot(input_frame_offset);
1445 output_frame_offset -= kPointerSize; 1447 output_frame_offset -= kFPOnStackSize;
1446 output_frame->SetFrameSlot(output_frame_offset, value); 1448 output_frame->SetCallerFp(output_frame_offset, value);
1447 intptr_t frame_ptr = input_->GetRegister(fp_reg.code()); 1449 intptr_t frame_ptr = input_->GetRegister(fp_reg.code());
1448 output_frame->SetRegister(fp_reg.code(), frame_ptr); 1450 output_frame->SetRegister(fp_reg.code(), frame_ptr);
1449 output_frame->SetFp(frame_ptr); 1451 output_frame->SetFp(frame_ptr);
1450 if (trace_) { 1452 if (trace_) {
1451 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" 1453 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08"
1452 V8PRIxPTR " ; caller's fp\n", 1454 V8PRIxPTR " ; caller's fp\n",
1453 top_address + output_frame_offset, output_frame_offset, value); 1455 top_address + output_frame_offset, output_frame_offset, value);
1454 } 1456 }
1455 1457
1456 // The context can be gotten from the input frame. 1458 // The context can be gotten from the input frame.
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 3094
3093 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 3095 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
3094 v->VisitPointer(BitCast<Object**>(&function_)); 3096 v->VisitPointer(BitCast<Object**>(&function_));
3095 v->VisitPointers(parameters_, parameters_ + parameters_count_); 3097 v->VisitPointers(parameters_, parameters_ + parameters_count_);
3096 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 3098 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
3097 } 3099 }
3098 3100
3099 #endif // ENABLE_DEBUGGER_SUPPORT 3101 #endif // ENABLE_DEBUGGER_SUPPORT
3100 3102
3101 } } // namespace v8::internal 3103 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.h ('k') | src/frames.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698