| OLD | NEW |
| 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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 value = reinterpret_cast<intptr_t>( | 1487 value = reinterpret_cast<intptr_t>( |
| 1488 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); | 1488 Smi::FromInt(StackFrame::STUB_FAILURE_TRAMPOLINE)); |
| 1489 output_frame->SetFrameSlot(output_frame_offset, value); | 1489 output_frame->SetFrameSlot(output_frame_offset, value); |
| 1490 if (trace_) { | 1490 if (trace_) { |
| 1491 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" | 1491 PrintF(" 0x%08" V8PRIxPTR ": [top + %d] <- 0x%08" |
| 1492 V8PRIxPTR " ; function (stub failure sentinel)\n", | 1492 V8PRIxPTR " ; function (stub failure sentinel)\n", |
| 1493 top_address + output_frame_offset, output_frame_offset, value); | 1493 top_address + output_frame_offset, output_frame_offset, value); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 intptr_t caller_arg_count = 0; | 1496 intptr_t caller_arg_count = 0; |
| 1497 bool arg_count_known = descriptor->stack_parameter_count_ == NULL; | 1497 bool arg_count_known = !descriptor->stack_parameter_count_.is_valid(); |
| 1498 | 1498 |
| 1499 // Build the Arguments object for the caller's parameters and a pointer to it. | 1499 // Build the Arguments object for the caller's parameters and a pointer to it. |
| 1500 output_frame_offset -= kPointerSize; | 1500 output_frame_offset -= kPointerSize; |
| 1501 int args_arguments_offset = output_frame_offset; | 1501 int args_arguments_offset = output_frame_offset; |
| 1502 intptr_t the_hole = reinterpret_cast<intptr_t>( | 1502 intptr_t the_hole = reinterpret_cast<intptr_t>( |
| 1503 isolate_->heap()->the_hole_value()); | 1503 isolate_->heap()->the_hole_value()); |
| 1504 if (arg_count_known) { | 1504 if (arg_count_known) { |
| 1505 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + | 1505 value = frame_ptr + StandardFrameConstants::kCallerSPOffset + |
| 1506 (caller_arg_count - 1) * kPointerSize; | 1506 (caller_arg_count - 1) * kPointerSize; |
| 1507 } else { | 1507 } else { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 Handle<FixedArray> array = isolate_->factory()->NewFixedArray(length); | 1607 Handle<FixedArray> array = isolate_->factory()->NewFixedArray(length); |
| 1608 ASSERT(array->length() == length); | 1608 ASSERT(array->length() == length); |
| 1609 arguments->set_elements(*array); | 1609 arguments->set_elements(*array); |
| 1610 materialized_objects_->Add(arguments); | 1610 materialized_objects_->Add(arguments); |
| 1611 for (int i = 0; i < length; ++i) { | 1611 for (int i = 0; i < length; ++i) { |
| 1612 Handle<Object> value = MaterializeNextValue(); | 1612 Handle<Object> value = MaterializeNextValue(); |
| 1613 array->set(i, *value); | 1613 array->set(i, *value); |
| 1614 } | 1614 } |
| 1615 } else { | 1615 } else { |
| 1616 // Dispatch on the instance type of the object to be materialized. | 1616 // Dispatch on the instance type of the object to be materialized. |
| 1617 Handle<Map> map = Handle<Map>::cast(MaterializeNextValue()); | 1617 // We also need to make sure that the representation of all fields |
| 1618 // in the given object are general enough to hold a tagged value. |
| 1619 Handle<Map> map = Map::GeneralizeAllFieldRepresentations( |
| 1620 Handle<Map>::cast(MaterializeNextValue()), Representation::Tagged()); |
| 1618 switch (map->instance_type()) { | 1621 switch (map->instance_type()) { |
| 1619 case HEAP_NUMBER_TYPE: { | 1622 case HEAP_NUMBER_TYPE: { |
| 1620 Handle<HeapNumber> object = isolate_->factory()->NewHeapNumber(0.0); | 1623 Handle<HeapNumber> object = isolate_->factory()->NewHeapNumber(0.0); |
| 1621 materialized_objects_->Add(object); | 1624 materialized_objects_->Add(object); |
| 1622 Handle<Object> number = MaterializeNextValue(); | 1625 Handle<Object> number = MaterializeNextValue(); |
| 1623 object->set_value(number->Number()); | 1626 object->set_value(number->Number()); |
| 1624 materialization_value_index_ += kDoubleSize / kPointerSize - 1; | 1627 materialization_value_index_ += kDoubleSize / kPointerSize - 1; |
| 1625 break; | 1628 break; |
| 1626 } | 1629 } |
| 1627 case JS_OBJECT_TYPE: { | 1630 case JS_OBJECT_TYPE: { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 values.Add(Handle<Object>(deferred_objects_tagged_values_[i], isolate_)); | 1690 values.Add(Handle<Object>(deferred_objects_tagged_values_[i], isolate_)); |
| 1688 } | 1691 } |
| 1689 | 1692 |
| 1690 // Play it safe and clear all unhandlified values before we continue. | 1693 // Play it safe and clear all unhandlified values before we continue. |
| 1691 deferred_objects_tagged_values_.Clear(); | 1694 deferred_objects_tagged_values_.Clear(); |
| 1692 | 1695 |
| 1693 // Materialize all heap numbers before looking at arguments because when the | 1696 // Materialize all heap numbers before looking at arguments because when the |
| 1694 // output frames are used to materialize arguments objects later on they need | 1697 // output frames are used to materialize arguments objects later on they need |
| 1695 // to already contain valid heap numbers. | 1698 // to already contain valid heap numbers. |
| 1696 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { | 1699 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { |
| 1697 HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i]; | 1700 HeapNumberMaterializationDescriptor<Address> d = deferred_heap_numbers_[i]; |
| 1698 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); | 1701 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); |
| 1699 if (trace_) { | 1702 if (trace_) { |
| 1700 PrintF("Materialized a new heap number %p [%e] in slot %p\n", | 1703 PrintF("Materialized a new heap number %p [%e] in slot %p\n", |
| 1701 reinterpret_cast<void*>(*num), | 1704 reinterpret_cast<void*>(*num), |
| 1702 d.value(), | 1705 d.value(), |
| 1703 d.slot_address()); | 1706 d.destination()); |
| 1704 } | 1707 } |
| 1705 Memory::Object_at(d.slot_address()) = *num; | 1708 Memory::Object_at(d.destination()) = *num; |
| 1706 } | 1709 } |
| 1707 | 1710 |
| 1708 // Materialize all heap numbers required for arguments/captured objects. | 1711 // Materialize all heap numbers required for arguments/captured objects. |
| 1709 for (int i = 0; i < values.length(); i++) { | 1712 for (int i = 0; i < deferred_objects_double_values_.length(); i++) { |
| 1710 if (!values.at(i)->IsTheHole()) continue; | 1713 HeapNumberMaterializationDescriptor<int> d = |
| 1711 double double_value = deferred_objects_double_values_[i]; | 1714 deferred_objects_double_values_[i]; |
| 1712 Handle<Object> num = isolate_->factory()->NewNumber(double_value); | 1715 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); |
| 1713 if (trace_) { | 1716 if (trace_) { |
| 1714 PrintF("Materialized a new heap number %p [%e] for object\n", | 1717 PrintF("Materialized a new heap number %p [%e] for object at %d\n", |
| 1715 reinterpret_cast<void*>(*num), double_value); | 1718 reinterpret_cast<void*>(*num), |
| 1719 d.value(), |
| 1720 d.destination()); |
| 1716 } | 1721 } |
| 1717 values.Set(i, num); | 1722 ASSERT(values.at(d.destination())->IsTheHole()); |
| 1723 values.Set(d.destination(), num); |
| 1718 } | 1724 } |
| 1719 | 1725 |
| 1726 // Play it safe and clear all object double values before we continue. |
| 1727 deferred_objects_double_values_.Clear(); |
| 1728 |
| 1720 // Materialize arguments/captured objects. | 1729 // Materialize arguments/captured objects. |
| 1721 if (!deferred_objects_.is_empty()) { | 1730 if (!deferred_objects_.is_empty()) { |
| 1722 List<Handle<Object> > materialized_objects(deferred_objects_.length()); | 1731 List<Handle<Object> > materialized_objects(deferred_objects_.length()); |
| 1723 materialized_objects_ = &materialized_objects; | 1732 materialized_objects_ = &materialized_objects; |
| 1724 materialized_values_ = &values; | 1733 materialized_values_ = &values; |
| 1725 | 1734 |
| 1726 while (materialization_object_index_ < deferred_objects_.length()) { | 1735 while (materialization_object_index_ < deferred_objects_.length()) { |
| 1727 int object_index = materialization_object_index_; | 1736 int object_index = materialization_object_index_; |
| 1728 ObjectMaterializationDescriptor descriptor = | 1737 ObjectMaterializationDescriptor descriptor = |
| 1729 deferred_objects_.at(object_index); | 1738 deferred_objects_.at(object_index); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1759 void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( | 1768 void Deoptimizer::MaterializeHeapNumbersForDebuggerInspectableFrame( |
| 1760 Address parameters_top, | 1769 Address parameters_top, |
| 1761 uint32_t parameters_size, | 1770 uint32_t parameters_size, |
| 1762 Address expressions_top, | 1771 Address expressions_top, |
| 1763 uint32_t expressions_size, | 1772 uint32_t expressions_size, |
| 1764 DeoptimizedFrameInfo* info) { | 1773 DeoptimizedFrameInfo* info) { |
| 1765 ASSERT_EQ(DEBUGGER, bailout_type_); | 1774 ASSERT_EQ(DEBUGGER, bailout_type_); |
| 1766 Address parameters_bottom = parameters_top + parameters_size; | 1775 Address parameters_bottom = parameters_top + parameters_size; |
| 1767 Address expressions_bottom = expressions_top + expressions_size; | 1776 Address expressions_bottom = expressions_top + expressions_size; |
| 1768 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { | 1777 for (int i = 0; i < deferred_heap_numbers_.length(); i++) { |
| 1769 HeapNumberMaterializationDescriptor d = deferred_heap_numbers_[i]; | 1778 HeapNumberMaterializationDescriptor<Address> d = deferred_heap_numbers_[i]; |
| 1770 | 1779 |
| 1771 // Check of the heap number to materialize actually belong to the frame | 1780 // Check of the heap number to materialize actually belong to the frame |
| 1772 // being extracted. | 1781 // being extracted. |
| 1773 Address slot = d.slot_address(); | 1782 Address slot = d.destination(); |
| 1774 if (parameters_top <= slot && slot < parameters_bottom) { | 1783 if (parameters_top <= slot && slot < parameters_bottom) { |
| 1775 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); | 1784 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); |
| 1776 | 1785 |
| 1777 int index = (info->parameters_count() - 1) - | 1786 int index = (info->parameters_count() - 1) - |
| 1778 static_cast<int>(slot - parameters_top) / kPointerSize; | 1787 static_cast<int>(slot - parameters_top) / kPointerSize; |
| 1779 | 1788 |
| 1780 if (trace_) { | 1789 if (trace_) { |
| 1781 PrintF("Materializing a new heap number %p [%e] in slot %p" | 1790 PrintF("Materializing a new heap number %p [%e] in slot %p" |
| 1782 "for parameter slot #%d\n", | 1791 "for parameter slot #%d\n", |
| 1783 reinterpret_cast<void*>(*num), | 1792 reinterpret_cast<void*>(*num), |
| 1784 d.value(), | 1793 d.value(), |
| 1785 d.slot_address(), | 1794 d.destination(), |
| 1786 index); | 1795 index); |
| 1787 } | 1796 } |
| 1788 | 1797 |
| 1789 info->SetParameter(index, *num); | 1798 info->SetParameter(index, *num); |
| 1790 } else if (expressions_top <= slot && slot < expressions_bottom) { | 1799 } else if (expressions_top <= slot && slot < expressions_bottom) { |
| 1791 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); | 1800 Handle<Object> num = isolate_->factory()->NewNumber(d.value()); |
| 1792 | 1801 |
| 1793 int index = info->expression_count() - 1 - | 1802 int index = info->expression_count() - 1 - |
| 1794 static_cast<int>(slot - expressions_top) / kPointerSize; | 1803 static_cast<int>(slot - expressions_top) / kPointerSize; |
| 1795 | 1804 |
| 1796 if (trace_) { | 1805 if (trace_) { |
| 1797 PrintF("Materializing a new heap number %p [%e] in slot %p" | 1806 PrintF("Materializing a new heap number %p [%e] in slot %p" |
| 1798 "for expression slot #%d\n", | 1807 "for expression slot #%d\n", |
| 1799 reinterpret_cast<void*>(*num), | 1808 reinterpret_cast<void*>(*num), |
| 1800 d.value(), | 1809 d.value(), |
| 1801 d.slot_address(), | 1810 d.destination(), |
| 1802 index); | 1811 index); |
| 1803 } | 1812 } |
| 1804 | 1813 |
| 1805 info->SetExpression(index, *num); | 1814 info->SetExpression(index, *num); |
| 1806 } | 1815 } |
| 1807 } | 1816 } |
| 1808 } | 1817 } |
| 1809 #endif | 1818 #endif |
| 1810 | 1819 |
| 1811 | 1820 |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2399 | 2408 |
| 2400 void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) { | 2409 void Deoptimizer::AddObjectDuplication(intptr_t slot, int object_index) { |
| 2401 ObjectMaterializationDescriptor object_desc( | 2410 ObjectMaterializationDescriptor object_desc( |
| 2402 reinterpret_cast<Address>(slot), jsframe_count_, -1, object_index, false); | 2411 reinterpret_cast<Address>(slot), jsframe_count_, -1, object_index, false); |
| 2403 deferred_objects_.Add(object_desc); | 2412 deferred_objects_.Add(object_desc); |
| 2404 } | 2413 } |
| 2405 | 2414 |
| 2406 | 2415 |
| 2407 void Deoptimizer::AddObjectTaggedValue(intptr_t value) { | 2416 void Deoptimizer::AddObjectTaggedValue(intptr_t value) { |
| 2408 deferred_objects_tagged_values_.Add(reinterpret_cast<Object*>(value)); | 2417 deferred_objects_tagged_values_.Add(reinterpret_cast<Object*>(value)); |
| 2409 deferred_objects_double_values_.Add(isolate()->heap()->nan_value()->value()); | |
| 2410 } | 2418 } |
| 2411 | 2419 |
| 2412 | 2420 |
| 2413 void Deoptimizer::AddObjectDoubleValue(double value) { | 2421 void Deoptimizer::AddObjectDoubleValue(double value) { |
| 2414 deferred_objects_tagged_values_.Add(isolate()->heap()->the_hole_value()); | 2422 deferred_objects_tagged_values_.Add(isolate()->heap()->the_hole_value()); |
| 2415 deferred_objects_double_values_.Add(value); | 2423 HeapNumberMaterializationDescriptor<int> value_desc( |
| 2424 deferred_objects_tagged_values_.length() - 1, value); |
| 2425 deferred_objects_double_values_.Add(value_desc); |
| 2416 } | 2426 } |
| 2417 | 2427 |
| 2418 | 2428 |
| 2419 void Deoptimizer::AddDoubleValue(intptr_t slot_address, double value) { | 2429 void Deoptimizer::AddDoubleValue(intptr_t slot_address, double value) { |
| 2420 HeapNumberMaterializationDescriptor value_desc( | 2430 HeapNumberMaterializationDescriptor<Address> value_desc( |
| 2421 reinterpret_cast<Address>(slot_address), value); | 2431 reinterpret_cast<Address>(slot_address), value); |
| 2422 deferred_heap_numbers_.Add(value_desc); | 2432 deferred_heap_numbers_.Add(value_desc); |
| 2423 } | 2433 } |
| 2424 | 2434 |
| 2425 | 2435 |
| 2426 void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, | 2436 void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, |
| 2427 BailoutType type, | 2437 BailoutType type, |
| 2428 int max_entry_id) { | 2438 int max_entry_id) { |
| 2429 // We cannot run this if the serializer is enabled because this will | 2439 // We cannot run this if the serializer is enabled because this will |
| 2430 // cause us to emit relocation information for the external | 2440 // cause us to emit relocation information for the external |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2938 | 2948 |
| 2939 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { | 2949 void DeoptimizedFrameInfo::Iterate(ObjectVisitor* v) { |
| 2940 v->VisitPointer(BitCast<Object**>(&function_)); | 2950 v->VisitPointer(BitCast<Object**>(&function_)); |
| 2941 v->VisitPointers(parameters_, parameters_ + parameters_count_); | 2951 v->VisitPointers(parameters_, parameters_ + parameters_count_); |
| 2942 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); | 2952 v->VisitPointers(expression_stack_, expression_stack_ + expression_count_); |
| 2943 } | 2953 } |
| 2944 | 2954 |
| 2945 #endif // ENABLE_DEBUGGER_SUPPORT | 2955 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2946 | 2956 |
| 2947 } } // namespace v8::internal | 2957 } } // namespace v8::internal |
| OLD | NEW |