| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 sweeping_time_(0.0), | 128 sweeping_time_(0.0), |
| 129 last_idle_notification_time_(0.0), | 129 last_idle_notification_time_(0.0), |
| 130 mark_compact_collector_(this), | 130 mark_compact_collector_(this), |
| 131 store_buffer_(this), | 131 store_buffer_(this), |
| 132 marking_(this), | 132 marking_(this), |
| 133 incremental_marking_(this), | 133 incremental_marking_(this), |
| 134 gc_count_at_last_idle_gc_(0), | 134 gc_count_at_last_idle_gc_(0), |
| 135 full_codegen_bytes_generated_(0), | 135 full_codegen_bytes_generated_(0), |
| 136 crankshaft_codegen_bytes_generated_(0), | 136 crankshaft_codegen_bytes_generated_(0), |
| 137 gcs_since_last_deopt_(0), | 137 gcs_since_last_deopt_(0), |
| 138 #ifdef VERIFY_HEAP | |
| 139 no_weak_object_verification_scope_depth_(0), | |
| 140 #endif | |
| 141 allocation_sites_scratchpad_length_(0), | 138 allocation_sites_scratchpad_length_(0), |
| 142 promotion_queue_(this), | 139 promotion_queue_(this), |
| 143 configured_(false), | 140 configured_(false), |
| 144 external_string_table_(this), | 141 external_string_table_(this), |
| 145 chunks_queued_for_free_(NULL), | 142 chunks_queued_for_free_(NULL), |
| 146 gc_callbacks_depth_(0), | 143 gc_callbacks_depth_(0), |
| 147 deserialization_complete_(false), | 144 deserialization_complete_(false), |
| 148 promotion_failure_(false) { | 145 promotion_failure_(false) { |
| 149 // Allow build-time customization of the max semispace size. Building | 146 // Allow build-time customization of the max semispace size. Building |
| 150 // V8 with snapshots and a non-default max semispace size is much | 147 // V8 with snapshots and a non-default max semispace size is much |
| (...skipping 3011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3162 dummy_vector->Set(FeedbackVectorICSlot(0), | 3159 dummy_vector->Set(FeedbackVectorICSlot(0), |
| 3163 *TypeFeedbackVector::MegamorphicSentinel(isolate()), | 3160 *TypeFeedbackVector::MegamorphicSentinel(isolate()), |
| 3164 SKIP_WRITE_BARRIER); | 3161 SKIP_WRITE_BARRIER); |
| 3165 set_keyed_load_dummy_vector(*dummy_vector); | 3162 set_keyed_load_dummy_vector(*dummy_vector); |
| 3166 } else { | 3163 } else { |
| 3167 set_keyed_load_dummy_vector(empty_fixed_array()); | 3164 set_keyed_load_dummy_vector(empty_fixed_array()); |
| 3168 } | 3165 } |
| 3169 | 3166 |
| 3170 set_detached_contexts(empty_fixed_array()); | 3167 set_detached_contexts(empty_fixed_array()); |
| 3171 | 3168 |
| 3169 set_weak_object_to_code_table( |
| 3170 *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, |
| 3171 TENURED)); |
| 3172 |
| 3172 Handle<SeededNumberDictionary> slow_element_dictionary = | 3173 Handle<SeededNumberDictionary> slow_element_dictionary = |
| 3173 SeededNumberDictionary::New(isolate(), 0, TENURED); | 3174 SeededNumberDictionary::New(isolate(), 0, TENURED); |
| 3174 slow_element_dictionary->set_requires_slow_elements(); | 3175 slow_element_dictionary->set_requires_slow_elements(); |
| 3175 set_empty_slow_element_dictionary(*slow_element_dictionary); | 3176 set_empty_slow_element_dictionary(*slow_element_dictionary); |
| 3176 | 3177 |
| 3177 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); | 3178 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); |
| 3178 | 3179 |
| 3179 // Handling of script id generation is in Factory::NewScript. | 3180 // Handling of script id generation is in Factory::NewScript. |
| 3180 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); | 3181 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); |
| 3181 | 3182 |
| (...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5593 CreateApiObjects(); | 5594 CreateApiObjects(); |
| 5594 | 5595 |
| 5595 // Create initial objects | 5596 // Create initial objects |
| 5596 CreateInitialObjects(); | 5597 CreateInitialObjects(); |
| 5597 CHECK_EQ(0u, gc_count_); | 5598 CHECK_EQ(0u, gc_count_); |
| 5598 | 5599 |
| 5599 set_native_contexts_list(undefined_value()); | 5600 set_native_contexts_list(undefined_value()); |
| 5600 set_array_buffers_list(undefined_value()); | 5601 set_array_buffers_list(undefined_value()); |
| 5601 set_new_array_buffer_views_list(undefined_value()); | 5602 set_new_array_buffer_views_list(undefined_value()); |
| 5602 set_allocation_sites_list(undefined_value()); | 5603 set_allocation_sites_list(undefined_value()); |
| 5603 weak_object_to_code_table_ = undefined_value(); | |
| 5604 return true; | 5604 return true; |
| 5605 } | 5605 } |
| 5606 | 5606 |
| 5607 | 5607 |
| 5608 void Heap::SetStackLimits() { | 5608 void Heap::SetStackLimits() { |
| 5609 DCHECK(isolate_ != NULL); | 5609 DCHECK(isolate_ != NULL); |
| 5610 DCHECK(isolate_ == isolate()); | 5610 DCHECK(isolate_ == isolate()); |
| 5611 // On 64 bit machines, pointers are generally out of range of Smis. We write | 5611 // On 64 bit machines, pointers are generally out of range of Smis. We write |
| 5612 // something that looks like an out of range Smi to the GC. | 5612 // something that looks like an out of range Smi to the GC. |
| 5613 | 5613 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5768 if (gc_epilogue_callbacks_[i].callback == callback) { | 5768 if (gc_epilogue_callbacks_[i].callback == callback) { |
| 5769 gc_epilogue_callbacks_.Remove(i); | 5769 gc_epilogue_callbacks_.Remove(i); |
| 5770 return; | 5770 return; |
| 5771 } | 5771 } |
| 5772 } | 5772 } |
| 5773 UNREACHABLE(); | 5773 UNREACHABLE(); |
| 5774 } | 5774 } |
| 5775 | 5775 |
| 5776 | 5776 |
| 5777 // TODO(ishell): Find a better place for this. | 5777 // TODO(ishell): Find a better place for this. |
| 5778 void Heap::AddWeakObjectToCodeDependency(Handle<Object> obj, | 5778 void Heap::AddWeakObjectToCodeDependency(Handle<HeapObject> obj, |
| 5779 Handle<DependentCode> dep) { | 5779 Handle<DependentCode> dep) { |
| 5780 DCHECK(!InNewSpace(*obj)); | 5780 DCHECK(!InNewSpace(*obj)); |
| 5781 DCHECK(!InNewSpace(*dep)); | 5781 DCHECK(!InNewSpace(*dep)); |
| 5782 // This handle scope keeps the table handle local to this function, which | 5782 Handle<WeakHashTable> table(weak_object_to_code_table(), isolate()); |
| 5783 // allows us to safely skip write barriers in table update operations. | |
| 5784 HandleScope scope(isolate()); | |
| 5785 Handle<WeakHashTable> table(WeakHashTable::cast(weak_object_to_code_table_), | |
| 5786 isolate()); | |
| 5787 table = WeakHashTable::Put(table, obj, dep); | 5783 table = WeakHashTable::Put(table, obj, dep); |
| 5788 | 5784 if (*table != weak_object_to_code_table()) |
| 5789 if (ShouldZapGarbage() && weak_object_to_code_table_ != *table) { | 5785 set_weak_object_to_code_table(*table); |
| 5790 WeakHashTable::cast(weak_object_to_code_table_)->Zap(the_hole_value()); | 5786 DCHECK_EQ(*dep, LookupWeakObjectToCodeDependency(obj)); |
| 5791 } | |
| 5792 set_weak_object_to_code_table(*table); | |
| 5793 DCHECK_EQ(*dep, table->Lookup(obj)); | |
| 5794 } | 5787 } |
| 5795 | 5788 |
| 5796 | 5789 |
| 5797 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<Object> obj) { | 5790 DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) { |
| 5798 Object* dep = WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj); | 5791 Object* dep = weak_object_to_code_table()->Lookup(obj); |
| 5799 if (dep->IsDependentCode()) return DependentCode::cast(dep); | 5792 if (dep->IsDependentCode()) return DependentCode::cast(dep); |
| 5800 return DependentCode::cast(empty_fixed_array()); | 5793 return DependentCode::cast(empty_fixed_array()); |
| 5801 } | 5794 } |
| 5802 | 5795 |
| 5803 | 5796 |
| 5804 void Heap::EnsureWeakObjectToCodeTable() { | |
| 5805 if (!weak_object_to_code_table()->IsHashTable()) { | |
| 5806 set_weak_object_to_code_table( | |
| 5807 *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY, | |
| 5808 TENURED)); | |
| 5809 } | |
| 5810 } | |
| 5811 | |
| 5812 | |
| 5813 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { | 5797 void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) { |
| 5814 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); | 5798 v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot); |
| 5815 } | 5799 } |
| 5816 | 5800 |
| 5817 #ifdef DEBUG | 5801 #ifdef DEBUG |
| 5818 | 5802 |
| 5819 class PrintHandleVisitor : public ObjectVisitor { | 5803 class PrintHandleVisitor : public ObjectVisitor { |
| 5820 public: | 5804 public: |
| 5821 void VisitPointers(Object** start, Object** end) { | 5805 void VisitPointers(Object** start, Object** end) { |
| 5822 for (Object** p = start; p < end; p++) | 5806 for (Object** p = start; p < end; p++) |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6587 static_cast<int>(object_sizes_last_time_[index])); | 6571 static_cast<int>(object_sizes_last_time_[index])); |
| 6588 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6572 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6589 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6573 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6590 | 6574 |
| 6591 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6575 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6592 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6576 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6593 ClearObjectStats(); | 6577 ClearObjectStats(); |
| 6594 } | 6578 } |
| 6595 } | 6579 } |
| 6596 } // namespace v8::internal | 6580 } // namespace v8::internal |
| OLD | NEW |