| OLD | NEW |
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 linear_allocation_scope_depth_(0), | 100 linear_allocation_scope_depth_(0), |
| 101 contexts_disposed_(0), | 101 contexts_disposed_(0), |
| 102 new_space_(this), | 102 new_space_(this), |
| 103 old_pointer_space_(NULL), | 103 old_pointer_space_(NULL), |
| 104 old_data_space_(NULL), | 104 old_data_space_(NULL), |
| 105 code_space_(NULL), | 105 code_space_(NULL), |
| 106 map_space_(NULL), | 106 map_space_(NULL), |
| 107 cell_space_(NULL), | 107 cell_space_(NULL), |
| 108 lo_space_(NULL), | 108 lo_space_(NULL), |
| 109 gc_state_(NOT_IN_GC), | 109 gc_state_(NOT_IN_GC), |
| 110 gc_post_processing_depth_(0), |
| 110 mc_count_(0), | 111 mc_count_(0), |
| 111 ms_count_(0), | 112 ms_count_(0), |
| 112 gc_count_(0), | 113 gc_count_(0), |
| 113 unflattened_strings_length_(0), | 114 unflattened_strings_length_(0), |
| 114 #ifdef DEBUG | 115 #ifdef DEBUG |
| 115 allocation_allowed_(true), | 116 allocation_allowed_(true), |
| 116 allocation_timeout_(0), | 117 allocation_timeout_(0), |
| 117 disallow_allocation_failure_(false), | 118 disallow_allocation_failure_(false), |
| 118 debug_utils_(NULL), | 119 debug_utils_(NULL), |
| 119 #endif // DEBUG | 120 #endif // DEBUG |
| (...skipping 25 matching lines...) Expand all Loading... |
| 145 last_idle_notification_gc_count_init_(false), | 146 last_idle_notification_gc_count_init_(false), |
| 146 configured_(false), | 147 configured_(false), |
| 147 is_safe_to_read_maps_(true) { | 148 is_safe_to_read_maps_(true) { |
| 148 // Allow build-time customization of the max semispace size. Building | 149 // Allow build-time customization of the max semispace size. Building |
| 149 // V8 with snapshots and a non-default max semispace size is much | 150 // V8 with snapshots and a non-default max semispace size is much |
| 150 // easier if you can define it as part of the build environment. | 151 // easier if you can define it as part of the build environment. |
| 151 #if defined(V8_MAX_SEMISPACE_SIZE) | 152 #if defined(V8_MAX_SEMISPACE_SIZE) |
| 152 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; | 153 max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; |
| 153 #endif | 154 #endif |
| 154 | 155 |
| 156 intptr_t max_virtual = OS::MaxVirtualMemory(); |
| 157 |
| 158 if (max_virtual > 0) { |
| 159 intptr_t half = max_virtual >> 1; |
| 160 intptr_t quarter = max_virtual >> 2; |
| 161 // If we have limits on the amount of virtual memory we can use then we may |
| 162 // be forced to lower the allocation limits. We reserve one quarter of the |
| 163 // memory for young space and off-heap data. The rest is distributed as |
| 164 // described below. |
| 165 if (code_range_size_ > 0) { |
| 166 // Reserve a quarter of the memory for the code range. The old space |
| 167 // heap gets the remaining half. There is some unavoidable double |
| 168 // counting going on here since the heap size is measured in committed |
| 169 // virtual memory and the code range is only reserved virtual memory. |
| 170 code_range_size_ = Min(code_range_size_, quarter); |
| 171 max_old_generation_size_ = Min(max_old_generation_size_, half); |
| 172 } else { |
| 173 // Reserve three quarters of the memory for the old space heap including |
| 174 // the executable code. |
| 175 max_old_generation_size_ = Min(max_old_generation_size_, half + quarter); |
| 176 } |
| 177 } |
| 178 |
| 155 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); | 179 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
| 156 global_contexts_list_ = NULL; | 180 global_contexts_list_ = NULL; |
| 157 mark_compact_collector_.heap_ = this; | 181 mark_compact_collector_.heap_ = this; |
| 158 external_string_table_.heap_ = this; | 182 external_string_table_.heap_ = this; |
| 159 } | 183 } |
| 160 | 184 |
| 161 | 185 |
| 162 intptr_t Heap::Capacity() { | 186 intptr_t Heap::Capacity() { |
| 163 if (!HasBeenSetup()) return 0; | 187 if (!HasBeenSetup()) return 0; |
| 164 | 188 |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 } else { | 788 } else { |
| 765 tracer_ = tracer; | 789 tracer_ = tracer; |
| 766 Scavenge(); | 790 Scavenge(); |
| 767 tracer_ = NULL; | 791 tracer_ = NULL; |
| 768 | 792 |
| 769 UpdateSurvivalRateTrend(start_new_space_size); | 793 UpdateSurvivalRateTrend(start_new_space_size); |
| 770 } | 794 } |
| 771 | 795 |
| 772 isolate_->counters()->objs_since_last_young()->Set(0); | 796 isolate_->counters()->objs_since_last_young()->Set(0); |
| 773 | 797 |
| 798 gc_post_processing_depth_++; |
| 774 { DisableAssertNoAllocation allow_allocation; | 799 { DisableAssertNoAllocation allow_allocation; |
| 775 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | 800 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| 776 next_gc_likely_to_collect_more = | 801 next_gc_likely_to_collect_more = |
| 777 isolate_->global_handles()->PostGarbageCollectionProcessing(collector); | 802 isolate_->global_handles()->PostGarbageCollectionProcessing(collector); |
| 778 } | 803 } |
| 804 gc_post_processing_depth_--; |
| 779 | 805 |
| 780 // Update relocatables. | 806 // Update relocatables. |
| 781 Relocatable::PostGarbageCollectionProcessing(); | 807 Relocatable::PostGarbageCollectionProcessing(); |
| 782 | 808 |
| 783 if (collector == MARK_COMPACTOR) { | 809 if (collector == MARK_COMPACTOR) { |
| 784 // Register the amount of external allocated memory. | 810 // Register the amount of external allocated memory. |
| 785 amount_of_external_allocated_memory_at_last_global_gc_ = | 811 amount_of_external_allocated_memory_at_last_global_gc_ = |
| 786 amount_of_external_allocated_memory_; | 812 amount_of_external_allocated_memory_; |
| 787 } | 813 } |
| 788 | 814 |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 map->set_prototype(null_value()); | 1629 map->set_prototype(null_value()); |
| 1604 map->set_constructor(null_value()); | 1630 map->set_constructor(null_value()); |
| 1605 map->set_instance_size(instance_size); | 1631 map->set_instance_size(instance_size); |
| 1606 map->set_inobject_properties(0); | 1632 map->set_inobject_properties(0); |
| 1607 map->set_pre_allocated_property_fields(0); | 1633 map->set_pre_allocated_property_fields(0); |
| 1608 map->init_instance_descriptors(); | 1634 map->init_instance_descriptors(); |
| 1609 map->set_code_cache(empty_fixed_array()); | 1635 map->set_code_cache(empty_fixed_array()); |
| 1610 map->set_prototype_transitions(empty_fixed_array()); | 1636 map->set_prototype_transitions(empty_fixed_array()); |
| 1611 map->set_unused_property_fields(0); | 1637 map->set_unused_property_fields(0); |
| 1612 map->set_bit_field(0); | 1638 map->set_bit_field(0); |
| 1613 map->set_bit_field2((1 << Map::kIsExtensible) | (1 << Map::kHasFastElements)); | 1639 map->set_bit_field2(1 << Map::kIsExtensible); |
| 1640 map->set_elements_kind(JSObject::FAST_ELEMENTS); |
| 1614 | 1641 |
| 1615 // If the map object is aligned fill the padding area with Smi 0 objects. | 1642 // If the map object is aligned fill the padding area with Smi 0 objects. |
| 1616 if (Map::kPadStart < Map::kSize) { | 1643 if (Map::kPadStart < Map::kSize) { |
| 1617 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, | 1644 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, |
| 1618 0, | 1645 0, |
| 1619 Map::kSize - Map::kPadStart); | 1646 Map::kSize - Map::kPadStart); |
| 1620 } | 1647 } |
| 1621 return map; | 1648 return map; |
| 1622 } | 1649 } |
| 1623 | 1650 |
| (...skipping 4299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5923 } | 5950 } |
| 5924 | 5951 |
| 5925 | 5952 |
| 5926 void ExternalStringTable::TearDown() { | 5953 void ExternalStringTable::TearDown() { |
| 5927 new_space_strings_.Free(); | 5954 new_space_strings_.Free(); |
| 5928 old_space_strings_.Free(); | 5955 old_space_strings_.Free(); |
| 5929 } | 5956 } |
| 5930 | 5957 |
| 5931 | 5958 |
| 5932 } } // namespace v8::internal | 5959 } } // namespace v8::internal |
| OLD | NEW |