OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 8440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8451 if (number_of_deopt_points == 0) { | 8451 if (number_of_deopt_points == 0) { |
8452 result = isolate->factory()->empty_fixed_array(); | 8452 result = isolate->factory()->empty_fixed_array(); |
8453 } else { | 8453 } else { |
8454 result = isolate->factory()->NewFixedArray( | 8454 result = isolate->factory()->NewFixedArray( |
8455 LengthOfFixedArray(number_of_deopt_points), pretenure); | 8455 LengthOfFixedArray(number_of_deopt_points), pretenure); |
8456 } | 8456 } |
8457 return Handle<DeoptimizationOutputData>::cast(result); | 8457 return Handle<DeoptimizationOutputData>::cast(result); |
8458 } | 8458 } |
8459 | 8459 |
8460 | 8460 |
| 8461 int HandlerTable::LookupRange(int pc_offset, int* stack_depth_out) { |
| 8462 int innermost_handler = -1, innermost_start = -1; |
| 8463 for (int i = 0; i < length(); i += kRangeEntrySize) { |
| 8464 int start_offset = Smi::cast(get(i + kRangeStartIndex))->value(); |
| 8465 int end_offset = Smi::cast(get(i + kRangeEndIndex))->value(); |
| 8466 int handler_offset = Smi::cast(get(i + kRangeHandlerIndex))->value(); |
| 8467 int stack_depth = Smi::cast(get(i + kRangeDepthIndex))->value(); |
| 8468 if (pc_offset > start_offset && pc_offset <= end_offset) { |
| 8469 DCHECK_NE(start_offset, innermost_start); |
| 8470 if (start_offset < innermost_start) continue; |
| 8471 innermost_handler = handler_offset; |
| 8472 innermost_start = start_offset; |
| 8473 *stack_depth_out = stack_depth; |
| 8474 } |
| 8475 } |
| 8476 return innermost_handler; |
| 8477 } |
| 8478 |
| 8479 |
| 8480 // TODO(turbofan): Make sure table is sorted and use binary search. |
| 8481 int HandlerTable::LookupReturn(int pc_offset) { |
| 8482 for (int i = 0; i < length(); i += kReturnEntrySize) { |
| 8483 int return_offset = Smi::cast(get(i + kReturnOffsetIndex))->value(); |
| 8484 int handler_offset = Smi::cast(get(i + kReturnHandlerIndex))->value(); |
| 8485 if (pc_offset == return_offset) return handler_offset; |
| 8486 } |
| 8487 return -1; |
| 8488 } |
| 8489 |
| 8490 |
8461 #ifdef DEBUG | 8491 #ifdef DEBUG |
8462 bool DescriptorArray::IsEqualTo(DescriptorArray* other) { | 8492 bool DescriptorArray::IsEqualTo(DescriptorArray* other) { |
8463 if (IsEmpty()) return other->IsEmpty(); | 8493 if (IsEmpty()) return other->IsEmpty(); |
8464 if (other->IsEmpty()) return false; | 8494 if (other->IsEmpty()) return false; |
8465 if (length() != other->length()) return false; | 8495 if (length() != other->length()) return false; |
8466 for (int i = 0; i < length(); ++i) { | 8496 for (int i = 0; i < length(); ++i) { |
8467 if (get(i) != other->get(i)) return false; | 8497 if (get(i) != other->get(i)) return false; |
8468 } | 8498 } |
8469 return true; | 8499 return true; |
8470 } | 8500 } |
(...skipping 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11477 for (int i = 0; i < this->DeoptPoints(); i++) { | 11507 for (int i = 0; i < this->DeoptPoints(); i++) { |
11478 int pc_and_state = this->PcAndState(i)->value(); | 11508 int pc_and_state = this->PcAndState(i)->value(); |
11479 os << std::setw(6) << this->AstId(i).ToInt() << " " << std::setw(8) | 11509 os << std::setw(6) << this->AstId(i).ToInt() << " " << std::setw(8) |
11480 << FullCodeGenerator::PcField::decode(pc_and_state) << " " | 11510 << FullCodeGenerator::PcField::decode(pc_and_state) << " " |
11481 << FullCodeGenerator::State2String( | 11511 << FullCodeGenerator::State2String( |
11482 FullCodeGenerator::StateField::decode(pc_and_state)) << "\n"; | 11512 FullCodeGenerator::StateField::decode(pc_and_state)) << "\n"; |
11483 } | 11513 } |
11484 } | 11514 } |
11485 | 11515 |
11486 | 11516 |
| 11517 void HandlerTable::HandlerTableRangePrint(std::ostream& os) { |
| 11518 os << " from to hdlr\n"; |
| 11519 for (int i = 0; i < length(); i += kRangeEntrySize) { |
| 11520 int pc_start = Smi::cast(get(i + kRangeStartIndex))->value(); |
| 11521 int pc_end = Smi::cast(get(i + kRangeEndIndex))->value(); |
| 11522 int handler = Smi::cast(get(i + kRangeHandlerIndex))->value(); |
| 11523 int depth = Smi::cast(get(i + kRangeDepthIndex))->value(); |
| 11524 os << " (" << std::setw(4) << pc_start << "," << std::setw(4) << pc_end |
| 11525 << ") -> " << std::setw(4) << handler << " (depth=" << depth << ")\n"; |
| 11526 } |
| 11527 } |
| 11528 |
| 11529 |
| 11530 void HandlerTable::HandlerTableReturnPrint(std::ostream& os) { |
| 11531 os << " off hdlr\n"; |
| 11532 for (int i = 0; i < length(); i += kReturnEntrySize) { |
| 11533 int pc_offset = Smi::cast(get(i + kReturnOffsetIndex))->value(); |
| 11534 int handler = Smi::cast(get(i + kReturnHandlerIndex))->value(); |
| 11535 os << " " << std::setw(4) << pc_offset << " -> " << std::setw(4) |
| 11536 << handler << "\n"; |
| 11537 } |
| 11538 } |
| 11539 |
| 11540 |
11487 const char* Code::ICState2String(InlineCacheState state) { | 11541 const char* Code::ICState2String(InlineCacheState state) { |
11488 switch (state) { | 11542 switch (state) { |
11489 case UNINITIALIZED: return "UNINITIALIZED"; | 11543 case UNINITIALIZED: return "UNINITIALIZED"; |
11490 case PREMONOMORPHIC: return "PREMONOMORPHIC"; | 11544 case PREMONOMORPHIC: return "PREMONOMORPHIC"; |
11491 case MONOMORPHIC: return "MONOMORPHIC"; | 11545 case MONOMORPHIC: return "MONOMORPHIC"; |
11492 case PROTOTYPE_FAILURE: | 11546 case PROTOTYPE_FAILURE: |
11493 return "PROTOTYPE_FAILURE"; | 11547 return "PROTOTYPE_FAILURE"; |
11494 case POLYMORPHIC: return "POLYMORPHIC"; | 11548 case POLYMORPHIC: return "POLYMORPHIC"; |
11495 case MEGAMORPHIC: return "MEGAMORPHIC"; | 11549 case MEGAMORPHIC: return "MEGAMORPHIC"; |
11496 case GENERIC: return "GENERIC"; | 11550 case GENERIC: return "GENERIC"; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11623 } | 11677 } |
11624 #ifdef OBJECT_PRINT | 11678 #ifdef OBJECT_PRINT |
11625 if (!type_feedback_info()->IsUndefined()) { | 11679 if (!type_feedback_info()->IsUndefined()) { |
11626 OFStream os(stdout); | 11680 OFStream os(stdout); |
11627 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os); | 11681 TypeFeedbackInfo::cast(type_feedback_info())->TypeFeedbackInfoPrint(os); |
11628 os << "\n"; | 11682 os << "\n"; |
11629 } | 11683 } |
11630 #endif | 11684 #endif |
11631 } | 11685 } |
11632 | 11686 |
11633 if (handler_table()->length() > 0 && is_turbofanned()) { | 11687 if (handler_table()->length() > 0) { |
11634 os << "Handler Table (size = " << handler_table()->Size() << ")\n"; | 11688 os << "Handler Table (size = " << handler_table()->Size() << ")\n"; |
11635 for (int i = 0; i < handler_table()->length(); i += 2) { | 11689 if (kind() == FUNCTION) { |
11636 int pc_offset = Smi::cast(handler_table()->get(i))->value(); | 11690 HandlerTable::cast(handler_table())->HandlerTableRangePrint(os); |
11637 int handler = Smi::cast(handler_table()->get(i + 1))->value(); | 11691 } else if (kind() == OPTIMIZED_FUNCTION) { |
11638 os << static_cast<const void*>(instruction_start() + pc_offset) << " " | 11692 HandlerTable::cast(handler_table())->HandlerTableReturnPrint(os); |
11639 << std::setw(4) << pc_offset << " " << std::setw(4) << handler << "\n"; | |
11640 } | 11693 } |
11641 os << "\n"; | 11694 os << "\n"; |
11642 } | 11695 } |
11643 | 11696 |
11644 os << "RelocInfo (size = " << relocation_size() << ")\n"; | 11697 os << "RelocInfo (size = " << relocation_size() << ")\n"; |
11645 for (RelocIterator it(this); !it.done(); it.next()) { | 11698 for (RelocIterator it(this); !it.done(); it.next()) { |
11646 it.rinfo()->Print(GetIsolate(), os); | 11699 it.rinfo()->Print(GetIsolate(), os); |
11647 } | 11700 } |
11648 os << "\n"; | 11701 os << "\n"; |
11649 | 11702 |
(...skipping 5456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17106 CompilationInfo* info) { | 17159 CompilationInfo* info) { |
17107 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17160 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17108 handle(cell->dependent_code(), info->isolate()), | 17161 handle(cell->dependent_code(), info->isolate()), |
17109 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17162 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17110 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17163 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17111 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17164 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17112 cell, info->zone()); | 17165 cell, info->zone()); |
17113 } | 17166 } |
17114 | 17167 |
17115 } } // namespace v8::internal | 17168 } } // namespace v8::internal |
OLD | NEW |