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

Side by Side Diff: src/deoptimizer.cc

Issue 7310027: Add inspection of arguments for optimized frames (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor fixes Created 9 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/runtime.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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Create the GC safe output frame information and register it for GC 154 // Create the GC safe output frame information and register it for GC
155 // handling. 155 // handling.
156 ASSERT_LT(frame_index, deoptimizer->output_count()); 156 ASSERT_LT(frame_index, deoptimizer->output_count());
157 DeoptimizedFrameInfo* info = 157 DeoptimizedFrameInfo* info =
158 new DeoptimizedFrameInfo(deoptimizer, frame_index); 158 new DeoptimizedFrameInfo(deoptimizer, frame_index);
159 isolate->deoptimizer_data()->deoptimized_frame_info_ = info; 159 isolate->deoptimizer_data()->deoptimized_frame_info_ = info;
160 160
161 // Get the "simulated" top and size for the requested frame. 161 // Get the "simulated" top and size for the requested frame.
162 Address top = 162 Address top =
163 reinterpret_cast<Address>(deoptimizer->output_[frame_index]->GetTop()); 163 reinterpret_cast<Address>(deoptimizer->output_[frame_index]->GetTop());
164 unsigned size = 164 unsigned size = deoptimizer->output_[frame_index]->GetFrameSize();
165 deoptimizer->output_[frame_index]->GetFrameSize() / kPointerSize;
166 165
167 // Done with the GC-unsafe frame descriptions. This re-enables allocation. 166 // Done with the GC-unsafe frame descriptions. This re-enables allocation.
168 deoptimizer->DeleteFrameDescriptions(); 167 deoptimizer->DeleteFrameDescriptions();
169 168
170 // Allocate a heap number for the doubles belonging to this frame. 169 // Allocate a heap number for the doubles belonging to this frame.
171 deoptimizer->MaterializeHeapNumbersForDebuggerInspectableFrame( 170 deoptimizer->MaterializeHeapNumbersForDebuggerInspectableFrame(
172 top, size, info); 171 top, size, info);
173 172
174 // Finished using the deoptimizer instance. 173 // Finished using the deoptimizer instance.
175 delete deoptimizer; 174 delete deoptimizer;
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 Address top, intptr_t size, DeoptimizedFrameInfo* info) { 549 Address top, intptr_t size, DeoptimizedFrameInfo* info) {
551 ASSERT_EQ(DEBUGGER, bailout_type_); 550 ASSERT_EQ(DEBUGGER, bailout_type_);
552 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { 551 for (int i = 0; i < deferred_heap_numbers_.length(); i++) {
553 HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i]; 552 HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i];
554 553
555 // Check of the heap number to materialize actually belong to the frame 554 // Check of the heap number to materialize actually belong to the frame
556 // being extracted. 555 // being extracted.
557 Address slot = d.slot_address(); 556 Address slot = d.slot_address();
558 if (top <= slot && slot < top + size) { 557 if (top <= slot && slot < top + size) {
559 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); 558 Handle<Object> num = isolate_->factory()->NewNumber(d.value());
560 int expression_index = static_cast<int>( 559 // Calculate the index with the botton of the expression stack
560 // at index 0, and the fixed part (including incoming arguments)
561 // at negative indexes.
562 int index = static_cast<int>(
561 info->expression_count_ - (slot - top) / kPointerSize - 1); 563 info->expression_count_ - (slot - top) / kPointerSize - 1);
562 if (FLAG_trace_deopt) { 564 if (FLAG_trace_deopt) {
563 PrintF("Materializing a new heap number %p [%e] in slot %p" 565 PrintF("Materializing a new heap number %p [%e] in slot %p"
564 "for expression stack index %d\n", 566 "for stack index %d\n",
565 reinterpret_cast<void*>(*num), 567 reinterpret_cast<void*>(*num),
566 d.value(), 568 d.value(),
567 d.slot_address(), 569 d.slot_address(),
568 expression_index); 570 index);
569 } 571 }
570 info->SetExpression(expression_index, *num); 572 if (index >=0) {
573 info->SetExpression(index, *num);
574 } else {
575 // Calculate parameter index subtracting one for the receiver.
576 int parameter_index =
577 index + size / kPointerSize - info->expression_count_ - 1;
578 info->SetParameter(parameter_index, *num);
579 }
571 } 580 }
572 } 581 }
573 } 582 }
574 #endif 583 #endif
575 584
576 585
577 void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator, 586 void Deoptimizer::DoTranslateCommand(TranslationIterator* iterator,
578 int frame_index, 587 int frame_index,
579 unsigned output_offset) { 588 unsigned output_offset) {
580 disasm::NameConverter converter; 589 disasm::NameConverter converter;
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 return base - ((slot_index + 1) * kPointerSize); 1128 return base - ((slot_index + 1) * kPointerSize);
1120 } else { 1129 } else {
1121 // Incoming parameter. 1130 // Incoming parameter.
1122 unsigned base = GetFrameSize() - 1131 unsigned base = GetFrameSize() -
1123 deoptimizer->ComputeIncomingArgumentSize(GetFunction()); 1132 deoptimizer->ComputeIncomingArgumentSize(GetFunction());
1124 return base - ((slot_index + 1) * kPointerSize); 1133 return base - ((slot_index + 1) * kPointerSize);
1125 } 1134 }
1126 } 1135 }
1127 1136
1128 1137
1138 int FrameDescription::ComputeParametersCount() {
1139 return function_->shared()->formal_parameter_count();
1140 }
1141
1142
1143 Object* FrameDescription::GetParameter(Deoptimizer* deoptimizer, int index) {
1144 ASSERT_EQ(Code::FUNCTION, kind_);
1145 ASSERT(index >= 0);
1146 ASSERT(index < ComputeParametersCount());
1147 // The slot indexes for incoming arguments are negative.
1148 unsigned offset = GetOffsetFromSlotIndex(deoptimizer,
1149 index - ComputeParametersCount());
1150 return reinterpret_cast<Object*>(*GetFrameSlotPointer(offset));
1151 }
1152
1153
1129 unsigned FrameDescription::GetExpressionCount(Deoptimizer* deoptimizer) { 1154 unsigned FrameDescription::GetExpressionCount(Deoptimizer* deoptimizer) {
1130 ASSERT_EQ(Code::FUNCTION, kind_); 1155 ASSERT_EQ(Code::FUNCTION, kind_);
1131 unsigned size = GetFrameSize() - deoptimizer->ComputeFixedSize(GetFunction()); 1156 unsigned size = GetFrameSize() - deoptimizer->ComputeFixedSize(GetFunction());
1132 return size / kPointerSize; 1157 return size / kPointerSize;
1133 } 1158 }
1134 1159
1135 1160
1136 Object* FrameDescription::GetExpression(Deoptimizer* deoptimizer, int index) { 1161 Object* FrameDescription::GetExpression(Deoptimizer* deoptimizer, int index) {
1137 ASSERT_EQ(Code::FUNCTION, kind_); 1162 ASSERT_EQ(Code::FUNCTION, kind_);
1138 unsigned offset = GetOffsetFromSlotIndex(deoptimizer, index); 1163 unsigned offset = GetOffsetFromSlotIndex(deoptimizer, index);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 1435
1411 UNREACHABLE(); 1436 UNREACHABLE();
1412 } 1437 }
1413 1438
1414 1439
1415 DeoptimizedFrameInfo::DeoptimizedFrameInfo( 1440 DeoptimizedFrameInfo::DeoptimizedFrameInfo(
1416 Deoptimizer* deoptimizer, int frame_index) { 1441 Deoptimizer* deoptimizer, int frame_index) {
1417 FrameDescription* output_frame = deoptimizer->output_[frame_index]; 1442 FrameDescription* output_frame = deoptimizer->output_[frame_index];
1418 SetFunction(output_frame->GetFunction()); 1443 SetFunction(output_frame->GetFunction());
1419 expression_count_ = output_frame->GetExpressionCount(deoptimizer); 1444 expression_count_ = output_frame->GetExpressionCount(deoptimizer);
1445 parameters_count_ = output_frame->ComputeParametersCount();
1446 parameters_ = new Object*[expression_count_];
1447 for (int i = 0; i < parameters_count_; i++) {
1448 SetParameter(i, output_frame->GetParameter(deoptimizer, i));
1449 }
1420 expression_stack_ = new Object*[expression_count_]; 1450 expression_stack_ = new Object*[expression_count_];
1421 for (int i = 0; i < expression_count_; i++) { 1451 for (int i = 0; i < expression_count_; i++) {
1422 SetExpression(i, output_frame->GetExpression(deoptimizer, i)); 1452 SetExpression(i, output_frame->GetExpression(deoptimizer, i));
1423 } 1453 }
1424 } 1454 }
1425 1455
1426 1456
1427 DeoptimizedFrameInfo::~DeoptimizedFrameInfo() { 1457 DeoptimizedFrameInfo::~DeoptimizedFrameInfo() {
1428 delete expression_stack_; 1458 delete expression_stack_;
1429 } 1459 }
1430 1460
1431 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 1461 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
1432 v->VisitPointer(reinterpret_cast<Object**>(&function_)); 1462 v->VisitPointer(reinterpret_cast<Object**>(&function_));
1463 v->VisitPointers(parameters_, parameters_ + parameters_count_);
1433 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 1464 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
1434 } 1465 }
1435 1466
1436 1467
1437 } } // namespace v8::internal 1468 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698