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

Side by Side Diff: src/deoptimizer.cc

Issue 25583004: Refactor deferred_objects_double_values_ a little in the deoptimization (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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') | no next file » | 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 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 values.Add(Handle<Object>(deferred_objects_tagged_values_[i], isolate_)); 1687 values.Add(Handle<Object>(deferred_objects_tagged_values_[i], isolate_));
1688 } 1688 }
1689 1689
1690 // Play it safe and clear all unhandlified values before we continue. 1690 // Play it safe and clear all unhandlified values before we continue.
1691 deferred_objects_tagged_values_.Clear(); 1691 deferred_objects_tagged_values_.Clear();
1692 1692
1693 // Materialize all heap numbers before looking at arguments because when the 1693 // Materialize all heap numbers before looking at arguments because when the
1694 // output frames are used to materialize arguments objects later on they need 1694 // output frames are used to materialize arguments objects later on they need
1695 // to already contain valid heap numbers. 1695 // to already contain valid heap numbers.
1696 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { 1696 for (int i = 0; i < deferred_heap_numbers_.length(); i++) {
1697 HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i]; 1697 HeapNumberMaterializationDescriptor<Address> d = deferred_heap_numbers_[i];
1698 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); 1698 Handle<Object> num = isolate_->factory()->NewNumber(d.value());
1699 if (trace_) { 1699 if (trace_) {
1700 PrintF("Materialized a new heap number %p [%e] in slot %p\n", 1700 PrintF("Materialized a new heap number %p [%e] in slot %p\n",
1701 reinterpret_cast<void*>(*num), 1701 reinterpret_cast<void*>(*num),
1702 d.value(), 1702 d.value(),
1703 d.slot_address()); 1703 d.destination());
1704 } 1704 }
1705 Memory::Object_at(d.slot_address()) = *num; 1705 Memory::Object_at(d.destination()) = *num;
1706 } 1706 }
1707 1707
1708 // Materialize all heap numbers required for arguments/captured objects. 1708 // Materialize all heap numbers required for arguments/captured objects.
1709 for (int i = 0; i < values.length(); i++) { 1709 for (int i = 0; i < deferred_objects_double_values_.length(); i++) {
1710 if (!values.at(i)->IsTheHole()) continue; 1710 HeapNumberMaterializationDescriptor<int> d =
1711 double double_value = deferred_objects_double_values_[i]; 1711 deferred_objects_double_values_[i];
1712 Handle<Object> num = isolate_->factory()->NewNumber(double_value); 1712 Handle<Object> num = isolate_->factory()->NewNumber(d.value());
1713 if (trace_) { 1713 if (trace_) {
1714 PrintF("Materialized a new heap number %p [%e] for object\n", 1714 PrintF("Materialized a new heap number %p [%e] for object at %d\n",
1715 reinterpret_cast<void*>(*num), double_value); 1715 reinterpret_cast<void*>(*num),
1716 d.value(),
1717 d.destination());
1716 } 1718 }
1717 values.Set(i, num); 1719 ASSERT(values.at(d.destination())->IsTheHole());
1720 values.Set(d.destination(), num);
1718 } 1721 }
1719 1722
1723 // Play it safe and clear all object double values before we continue.
1724 deferred_objects_double_values_.Clear();
1725
1720 // Materialize arguments/captured objects. 1726 // Materialize arguments/captured objects.
1721 if (!deferred_objects_.is_empty()) { 1727 if (!deferred_objects_.is_empty()) {
1722 List<Handle<Object> > materialized_objects(deferred_objects_.length()); 1728 List<Handle<Object> > materialized_objects(deferred_objects_.length());
1723 materialized_objects_ = &materialized_objects; 1729 materialized_objects_ = &materialized_objects;
1724 materialized_values_ = &values; 1730 materialized_values_ = &values;
1725 1731
1726 while (materialization_object_index_ < deferred_objects_.length()) { 1732 while (materialization_object_index_ < deferred_objects_.length()) {
1727 int object_index = materialization_object_index_; 1733 int object_index = materialization_object_index_;
1728 ObjectMaterializationDescriptor descriptor = 1734 ObjectMaterializationDescriptor descriptor =
1729 deferred_objects_.at(object_index); 1735 deferred_objects_.at(object_index);
(...skipping 29 matching lines...) Expand all
1759 void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( 1765 void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame(
1760 Address parameters_top, 1766 Address parameters_top,
1761 uint32_t parameters_size, 1767 uint32_t parameters_size,
1762 Address expressions_top, 1768 Address expressions_top,
1763 uint32_t expressions_size, 1769 uint32_t expressions_size,
1764 DeoptimizedFrameInfo* info) { 1770 DeoptimizedFrameInfo* info) {
1765 ASSERT_EQ(DEBUGGER, bailout_type_); 1771 ASSERT_EQ(DEBUGGER, bailout_type_);
1766 Address parameters_bottom = parameters_top + parameters_size; 1772 Address parameters_bottom = parameters_top + parameters_size;
1767 Address expressions_bottom = expressions_top + expressions_size; 1773 Address expressions_bottom = expressions_top + expressions_size;
1768 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { 1774 for (int i = 0; i < deferred_heap_numbers_.length(); i++) {
1769 HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i]; 1775 HeapNumberMaterializationDescriptor<Address> d = deferred_heap_numbers_[i];
1770 1776
1771 // Check of the heap number to materialize actually belong to the frame 1777 // Check of the heap number to materialize actually belong to the frame
1772 // being extracted. 1778 // being extracted.
1773 Address slot = d.slot_address(); 1779 Address slot = d.destination();
1774 if (parameters_top <= slot && slot < parameters_bottom) { 1780 if (parameters_top <= slot && slot < parameters_bottom) {
1775 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); 1781 Handle<Object> num = isolate_->factory()->NewNumber(d.value());
1776 1782
1777 int index = (info->parameters_count() - 1) - 1783 int index = (info->parameters_count() - 1) -
1778 static_cast<int>(slot - parameters_top) / kPointerSize; 1784 static_cast<int>(slot - parameters_top) / kPointerSize;
1779 1785
1780 if (trace_) { 1786 if (trace_) {
1781 PrintF("Materializing a new heap number %p [%e] in slot %p" 1787 PrintF("Materializing a new heap number %p [%e] in slot %p"
1782 "for parameter slot #%d\n", 1788 "for parameter slot #%d\n",
1783 reinterpret_cast<void*>(*num), 1789 reinterpret_cast<void*>(*num),
1784 d.value(), 1790 d.value(),
1785 d.slot_address(), 1791 d.destination(),
1786 index); 1792 index);
1787 } 1793 }
1788 1794
1789 info->SetParameter(index, *num); 1795 info->SetParameter(index, *num);
1790 } else if (expressions_top <= slot && slot < expressions_bottom) { 1796 } else if (expressions_top <= slot && slot < expressions_bottom) {
1791 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); 1797 Handle<Object> num = isolate_->factory()->NewNumber(d.value());
1792 1798
1793 int index = info->expression_count() - 1 - 1799 int index = info->expression_count() - 1 -
1794 static_cast<int>(slot - expressions_top) / kPointerSize; 1800 static_cast<int>(slot - expressions_top) / kPointerSize;
1795 1801
1796 if (trace_) { 1802 if (trace_) {
1797 PrintF("Materializing a new heap number %p [%e] in slot %p" 1803 PrintF("Materializing a new heap number %p [%e] in slot %p"
1798 "for expression slot #%d\n", 1804 "for expression slot #%d\n",
1799 reinterpret_cast<void*>(*num), 1805 reinterpret_cast<void*>(*num),
1800 d.value(), 1806 d.value(),
1801 d.slot_address(), 1807 d.destination(),
1802 index); 1808 index);
1803 } 1809 }
1804 1810
1805 info->SetExpression(index, *num); 1811 info->SetExpression(index, *num);
1806 } 1812 }
1807 } 1813 }
1808 } 1814 }
1809 #endif 1815 #endif
1810 1816
1811 1817
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 2405
2400 void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) { 2406 void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) {
2401 ObjectMaterializationDescriptor object_desc( 2407 ObjectMaterializationDescriptor object_desc(
2402 reinterpret_cast<Address>(slot), jsframe_count_, -1, object_index, false); 2408 reinterpret_cast<Address>(slot), jsframe_count_, -1, object_index, false);
2403 deferred_objects_.Add(object_desc); 2409 deferred_objects_.Add(object_desc);
2404 } 2410 }
2405 2411
2406 2412
2407 void Deoptimizer::AddObjectTaggedValue(intptr_t value) { 2413 void Deoptimizer::AddObjectTaggedValue(intptr_t value) {
2408 deferred_objects_tagged_values_.Add(reinterpret_cast<Object*>(value)); 2414 deferred_objects_tagged_values_.Add(reinterpret_cast<Object*>(value));
2409 deferred_objects_double_values_.Add(isolate()->heap()->nan_value()->value());
2410 } 2415 }
2411 2416
2412 2417
2413 void Deoptimizer::AddObjectDoubleValue(double value) { 2418 void Deoptimizer::AddObjectDoubleValue(double value) {
2414 deferred_objects_tagged_values_.Add(isolate()->heap()->the_hole_value()); 2419 deferred_objects_tagged_values_.Add(isolate()->heap()->the_hole_value());
2415 deferred_objects_double_values_.Add(value); 2420 HeapNumberMaterializationDescriptor<int> value_desc(
2421 deferred_objects_tagged_values_.length() - 1, value);
2422 deferred_objects_double_values_.Add(value_desc);
2416 } 2423 }
2417 2424
2418 2425
2419 void Deoptimizer::AddDoubleValue(intptr_t slot_address, double value) { 2426 void Deoptimizer::AddDoubleValue(intptr_t slot_address, double value) {
2420 HeapNumberMaterializationDescriptor value_desc( 2427 HeapNumberMaterializationDescriptor<Address> value_desc(
2421 reinterpret_cast<Address>(slot_address), value); 2428 reinterpret_cast<Address>(slot_address), value);
2422 deferred_heap_numbers_.Add(value_desc); 2429 deferred_heap_numbers_.Add(value_desc);
2423 } 2430 }
2424 2431
2425 2432
2426 void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, 2433 void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
2427 BailoutType type, 2434 BailoutType type,
2428 int max_entry_id) { 2435 int max_entry_id) {
2429 // We cannot run this if the serializer is enabled because this will 2436 // We cannot run this if the serializer is enabled because this will
2430 // cause us to emit relocation information for the external 2437 // cause us to emit relocation information for the external
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2938 2945
2939 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { 2946 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) {
2940 v->VisitPointer(BitCast<Object**>(&function_)); 2947 v->VisitPointer(BitCast<Object**>(&function_));
2941 v->VisitPointers(parameters_, parameters_ + parameters_count_); 2948 v->VisitPointers(parameters_, parameters_ + parameters_count_);
2942 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); 2949 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_);
2943 } 2950 }
2944 2951
2945 #endif // ENABLE_DEBUGGER_SUPPORT 2952 #endif // ENABLE_DEBUGGER_SUPPORT
2946 2953
2947 } } // namespace v8::internal 2954 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/deoptimizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698