| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | 1020 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| 1021 next_gc_likely_to_collect_more = | 1021 next_gc_likely_to_collect_more = |
| 1022 isolate_->global_handles()->PostGarbageCollectionProcessing( | 1022 isolate_->global_handles()->PostGarbageCollectionProcessing( |
| 1023 collector, tracer); | 1023 collector, tracer); |
| 1024 } | 1024 } |
| 1025 gc_post_processing_depth_--; | 1025 gc_post_processing_depth_--; |
| 1026 | 1026 |
| 1027 isolate_->eternal_handles()->PostGarbageCollectionProcessing(this); | 1027 isolate_->eternal_handles()->PostGarbageCollectionProcessing(this); |
| 1028 | 1028 |
| 1029 // Update relocatables. | 1029 // Update relocatables. |
| 1030 Relocatable::PostGarbageCollectionProcessing(); | 1030 Relocatable::PostGarbageCollectionProcessing(isolate_); |
| 1031 | 1031 |
| 1032 if (collector == MARK_COMPACTOR) { | 1032 if (collector == MARK_COMPACTOR) { |
| 1033 // Register the amount of external allocated memory. | 1033 // Register the amount of external allocated memory. |
| 1034 amount_of_external_allocated_memory_at_last_global_gc_ = | 1034 amount_of_external_allocated_memory_at_last_global_gc_ = |
| 1035 amount_of_external_allocated_memory_; | 1035 amount_of_external_allocated_memory_; |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 { | 1038 { |
| 1039 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); | 1039 GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); |
| 1040 VMState<EXTERNAL> state(isolate_); | 1040 VMState<EXTERNAL> state(isolate_); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 static void VisitLiveObject(Heap*, JSFunction*, | 1609 static void VisitLiveObject(Heap*, JSFunction*, |
| 1610 WeakObjectRetainer*, bool) { | 1610 WeakObjectRetainer*, bool) { |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 static void VisitPhantomObject(Heap*, JSFunction*) { | 1613 static void VisitPhantomObject(Heap*, JSFunction*) { |
| 1614 } | 1614 } |
| 1615 }; | 1615 }; |
| 1616 | 1616 |
| 1617 | 1617 |
| 1618 template<> | 1618 template<> |
| 1619 struct WeakListVisitor<Code> { |
| 1620 static void SetWeakNext(Code* code, Object* next) { |
| 1621 code->set_next_code_link(next); |
| 1622 } |
| 1623 |
| 1624 static Object* WeakNext(Code* code) { |
| 1625 return code->next_code_link(); |
| 1626 } |
| 1627 |
| 1628 static int WeakNextOffset() { |
| 1629 return Code::kNextCodeLinkOffset; |
| 1630 } |
| 1631 |
| 1632 static void VisitLiveObject(Heap*, Code*, |
| 1633 WeakObjectRetainer*, bool) { |
| 1634 } |
| 1635 |
| 1636 static void VisitPhantomObject(Heap*, Code*) { |
| 1637 } |
| 1638 }; |
| 1639 |
| 1640 |
| 1641 template<> |
| 1619 struct WeakListVisitor<Context> { | 1642 struct WeakListVisitor<Context> { |
| 1620 static void SetWeakNext(Context* context, Object* next) { | 1643 static void SetWeakNext(Context* context, Object* next) { |
| 1621 context->set(Context::NEXT_CONTEXT_LINK, | 1644 context->set(Context::NEXT_CONTEXT_LINK, |
| 1622 next, | 1645 next, |
| 1623 UPDATE_WRITE_BARRIER); | 1646 UPDATE_WRITE_BARRIER); |
| 1624 } | 1647 } |
| 1625 | 1648 |
| 1626 static Object* WeakNext(Context* context) { | 1649 static Object* WeakNext(Context* context) { |
| 1627 return context->get(Context::NEXT_CONTEXT_LINK); | 1650 return context->get(Context::NEXT_CONTEXT_LINK); |
| 1628 } | 1651 } |
| 1629 | 1652 |
| 1630 static void VisitLiveObject(Heap* heap, | 1653 static void VisitLiveObject(Heap* heap, |
| 1631 Context* context, | 1654 Context* context, |
| 1632 WeakObjectRetainer* retainer, | 1655 WeakObjectRetainer* retainer, |
| 1633 bool record_slots) { | 1656 bool record_slots) { |
| 1634 // Process the weak list of optimized functions for the context. | 1657 // Process the three weak lists linked off the context. |
| 1635 Object* function_list_head = | 1658 DoWeakList<JSFunction>(heap, context, retainer, record_slots, |
| 1636 VisitWeakList<JSFunction>( | 1659 Context::OPTIMIZED_FUNCTIONS_LIST); |
| 1637 heap, | 1660 DoWeakList<Code>(heap, context, retainer, record_slots, |
| 1638 context->get(Context::OPTIMIZED_FUNCTIONS_LIST), | 1661 Context::OPTIMIZED_CODE_LIST); |
| 1639 retainer, | 1662 DoWeakList<Code>(heap, context, retainer, record_slots, |
| 1640 record_slots); | 1663 Context::DEOPTIMIZED_CODE_LIST); |
| 1641 context->set(Context::OPTIMIZED_FUNCTIONS_LIST, | 1664 } |
| 1642 function_list_head, | 1665 |
| 1643 UPDATE_WRITE_BARRIER); | 1666 template<class T> |
| 1667 static void DoWeakList(Heap* heap, |
| 1668 Context* context, |
| 1669 WeakObjectRetainer* retainer, |
| 1670 bool record_slots, |
| 1671 int index) { |
| 1672 // Visit the weak list, removing dead intermediate elements. |
| 1673 Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer, |
| 1674 record_slots); |
| 1675 |
| 1676 // Update the list head. |
| 1677 context->set(index, list_head, UPDATE_WRITE_BARRIER); |
| 1678 |
| 1644 if (record_slots) { | 1679 if (record_slots) { |
| 1645 Object** optimized_functions = | 1680 // Record the updated slot if necessary. |
| 1646 HeapObject::RawField( | 1681 Object** head_slot = HeapObject::RawField( |
| 1647 context, FixedArray::SizeFor(Context::OPTIMIZED_FUNCTIONS_LIST)); | 1682 context, FixedArray::SizeFor(index)); |
| 1648 heap->mark_compact_collector()->RecordSlot( | 1683 heap->mark_compact_collector()->RecordSlot( |
| 1649 optimized_functions, optimized_functions, function_list_head); | 1684 head_slot, head_slot, list_head); |
| 1650 } | 1685 } |
| 1651 } | 1686 } |
| 1652 | 1687 |
| 1653 static void VisitPhantomObject(Heap*, Context*) { | 1688 static void VisitPhantomObject(Heap*, Context*) { |
| 1654 } | 1689 } |
| 1655 | 1690 |
| 1656 static int WeakNextOffset() { | 1691 static int WeakNextOffset() { |
| 1657 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); | 1692 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); |
| 1658 } | 1693 } |
| 1659 }; | 1694 }; |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2931 } | 2966 } |
| 2932 | 2967 |
| 2933 | 2968 |
| 2934 MaybeObject* Heap::CreateOddball(const char* to_string, | 2969 MaybeObject* Heap::CreateOddball(const char* to_string, |
| 2935 Object* to_number, | 2970 Object* to_number, |
| 2936 byte kind) { | 2971 byte kind) { |
| 2937 Object* result; | 2972 Object* result; |
| 2938 { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE); | 2973 { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE); |
| 2939 if (!maybe_result->ToObject(&result)) return maybe_result; | 2974 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2940 } | 2975 } |
| 2941 return Oddball::cast(result)->Initialize(to_string, to_number, kind); | 2976 return Oddball::cast(result)->Initialize(this, to_string, to_number, kind); |
| 2942 } | 2977 } |
| 2943 | 2978 |
| 2944 | 2979 |
| 2945 bool Heap::CreateApiObjects() { | 2980 bool Heap::CreateApiObjects() { |
| 2946 Object* obj; | 2981 Object* obj; |
| 2947 | 2982 |
| 2948 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 2983 { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 2949 if (!maybe_obj->ToObject(&obj)) return false; | 2984 if (!maybe_obj->ToObject(&obj)) return false; |
| 2950 } | 2985 } |
| 2951 // Don't use Smi-only elements optimizations for objects with the neander | 2986 // Don't use Smi-only elements optimizations for objects with the neander |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3040 // Allocate initial string table. | 3075 // Allocate initial string table. |
| 3041 { MaybeObject* maybe_obj = | 3076 { MaybeObject* maybe_obj = |
| 3042 StringTable::Allocate(this, kInitialStringTableSize); | 3077 StringTable::Allocate(this, kInitialStringTableSize); |
| 3043 if (!maybe_obj->ToObject(&obj)) return false; | 3078 if (!maybe_obj->ToObject(&obj)) return false; |
| 3044 } | 3079 } |
| 3045 // Don't use set_string_table() due to asserts. | 3080 // Don't use set_string_table() due to asserts. |
| 3046 roots_[kStringTableRootIndex] = obj; | 3081 roots_[kStringTableRootIndex] = obj; |
| 3047 | 3082 |
| 3048 // Finish initializing oddballs after creating the string table. | 3083 // Finish initializing oddballs after creating the string table. |
| 3049 { MaybeObject* maybe_obj = | 3084 { MaybeObject* maybe_obj = |
| 3050 undefined_value()->Initialize("undefined", | 3085 undefined_value()->Initialize(this, |
| 3086 "undefined", |
| 3051 nan_value(), | 3087 nan_value(), |
| 3052 Oddball::kUndefined); | 3088 Oddball::kUndefined); |
| 3053 if (!maybe_obj->ToObject(&obj)) return false; | 3089 if (!maybe_obj->ToObject(&obj)) return false; |
| 3054 } | 3090 } |
| 3055 | 3091 |
| 3056 // Initialize the null_value. | 3092 // Initialize the null_value. |
| 3057 { MaybeObject* maybe_obj = | 3093 { MaybeObject* maybe_obj = null_value()->Initialize( |
| 3058 null_value()->Initialize("null", Smi::FromInt(0), Oddball::kNull); | 3094 this, "null", Smi::FromInt(0), Oddball::kNull); |
| 3059 if (!maybe_obj->ToObject(&obj)) return false; | 3095 if (!maybe_obj->ToObject(&obj)) return false; |
| 3060 } | 3096 } |
| 3061 | 3097 |
| 3062 { MaybeObject* maybe_obj = CreateOddball("true", | 3098 { MaybeObject* maybe_obj = CreateOddball("true", |
| 3063 Smi::FromInt(1), | 3099 Smi::FromInt(1), |
| 3064 Oddball::kTrue); | 3100 Oddball::kTrue); |
| 3065 if (!maybe_obj->ToObject(&obj)) return false; | 3101 if (!maybe_obj->ToObject(&obj)) return false; |
| 3066 } | 3102 } |
| 3067 set_true_value(Oddball::cast(obj)); | 3103 set_true_value(Oddball::cast(obj)); |
| 3068 | 3104 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3643 // Set integer fields (smi or int, depending on the architecture). | 3679 // Set integer fields (smi or int, depending on the architecture). |
| 3644 share->set_length(0); | 3680 share->set_length(0); |
| 3645 share->set_formal_parameter_count(0); | 3681 share->set_formal_parameter_count(0); |
| 3646 share->set_expected_nof_properties(0); | 3682 share->set_expected_nof_properties(0); |
| 3647 share->set_num_literals(0); | 3683 share->set_num_literals(0); |
| 3648 share->set_start_position_and_type(0); | 3684 share->set_start_position_and_type(0); |
| 3649 share->set_end_position(0); | 3685 share->set_end_position(0); |
| 3650 share->set_function_token_position(0); | 3686 share->set_function_token_position(0); |
| 3651 // All compiler hints default to false or 0. | 3687 // All compiler hints default to false or 0. |
| 3652 share->set_compiler_hints(0); | 3688 share->set_compiler_hints(0); |
| 3653 share->set_opt_count(0); | 3689 share->set_opt_count_and_bailout_reason(0); |
| 3654 | 3690 |
| 3655 return share; | 3691 return share; |
| 3656 } | 3692 } |
| 3657 | 3693 |
| 3658 | 3694 |
| 3659 MaybeObject* Heap::AllocateJSMessageObject(String* type, | 3695 MaybeObject* Heap::AllocateJSMessageObject(String* type, |
| 3660 JSArray* arguments, | 3696 JSArray* arguments, |
| 3661 int start_position, | 3697 int start_position, |
| 3662 int end_position, | 3698 int end_position, |
| 3663 Object* script, | 3699 Object* script, |
| (...skipping 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6113 isolate()->PrintStack(stdout); | 6149 isolate()->PrintStack(stdout); |
| 6114 AllSpaces spaces(this); | 6150 AllSpaces spaces(this); |
| 6115 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { | 6151 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { |
| 6116 space->Print(); | 6152 space->Print(); |
| 6117 } | 6153 } |
| 6118 } | 6154 } |
| 6119 | 6155 |
| 6120 | 6156 |
| 6121 void Heap::ReportCodeStatistics(const char* title) { | 6157 void Heap::ReportCodeStatistics(const char* title) { |
| 6122 PrintF(">>>>>> Code Stats (%s) >>>>>>\n", title); | 6158 PrintF(">>>>>> Code Stats (%s) >>>>>>\n", title); |
| 6123 PagedSpace::ResetCodeStatistics(); | 6159 PagedSpace::ResetCodeStatistics(isolate()); |
| 6124 // We do not look for code in new space, map space, or old space. If code | 6160 // We do not look for code in new space, map space, or old space. If code |
| 6125 // somehow ends up in those spaces, we would miss it here. | 6161 // somehow ends up in those spaces, we would miss it here. |
| 6126 code_space_->CollectCodeStatistics(); | 6162 code_space_->CollectCodeStatistics(); |
| 6127 lo_space_->CollectCodeStatistics(); | 6163 lo_space_->CollectCodeStatistics(); |
| 6128 PagedSpace::ReportCodeStatistics(); | 6164 PagedSpace::ReportCodeStatistics(isolate()); |
| 6129 } | 6165 } |
| 6130 | 6166 |
| 6131 | 6167 |
| 6132 // This function expects that NewSpace's allocated objects histogram is | 6168 // This function expects that NewSpace's allocated objects histogram is |
| 6133 // populated (via a call to CollectStatistics or else as a side effect of a | 6169 // populated (via a call to CollectStatistics or else as a side effect of a |
| 6134 // just-completed scavenge collection). | 6170 // just-completed scavenge collection). |
| 6135 void Heap::ReportHeapStatistics(const char* title) { | 6171 void Heap::ReportHeapStatistics(const char* title) { |
| 6136 USE(title); | 6172 USE(title); |
| 6137 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", | 6173 PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", |
| 6138 title, gc_count_); | 6174 title, gc_count_); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6166 } | 6202 } |
| 6167 | 6203 |
| 6168 #endif // DEBUG | 6204 #endif // DEBUG |
| 6169 | 6205 |
| 6170 bool Heap::Contains(HeapObject* value) { | 6206 bool Heap::Contains(HeapObject* value) { |
| 6171 return Contains(value->address()); | 6207 return Contains(value->address()); |
| 6172 } | 6208 } |
| 6173 | 6209 |
| 6174 | 6210 |
| 6175 bool Heap::Contains(Address addr) { | 6211 bool Heap::Contains(Address addr) { |
| 6176 if (OS::IsOutsideAllocatedSpace(addr)) return false; | 6212 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
| 6177 return HasBeenSetUp() && | 6213 return HasBeenSetUp() && |
| 6178 (new_space_.ToSpaceContains(addr) || | 6214 (new_space_.ToSpaceContains(addr) || |
| 6179 old_pointer_space_->Contains(addr) || | 6215 old_pointer_space_->Contains(addr) || |
| 6180 old_data_space_->Contains(addr) || | 6216 old_data_space_->Contains(addr) || |
| 6181 code_space_->Contains(addr) || | 6217 code_space_->Contains(addr) || |
| 6182 map_space_->Contains(addr) || | 6218 map_space_->Contains(addr) || |
| 6183 cell_space_->Contains(addr) || | 6219 cell_space_->Contains(addr) || |
| 6184 property_cell_space_->Contains(addr) || | 6220 property_cell_space_->Contains(addr) || |
| 6185 lo_space_->SlowContains(addr)); | 6221 lo_space_->SlowContains(addr)); |
| 6186 } | 6222 } |
| 6187 | 6223 |
| 6188 | 6224 |
| 6189 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { | 6225 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { |
| 6190 return InSpace(value->address(), space); | 6226 return InSpace(value->address(), space); |
| 6191 } | 6227 } |
| 6192 | 6228 |
| 6193 | 6229 |
| 6194 bool Heap::InSpace(Address addr, AllocationSpace space) { | 6230 bool Heap::InSpace(Address addr, AllocationSpace space) { |
| 6195 if (OS::IsOutsideAllocatedSpace(addr)) return false; | 6231 if (isolate_->memory_allocator()->IsOutsideAllocatedSpace(addr)) return false; |
| 6196 if (!HasBeenSetUp()) return false; | 6232 if (!HasBeenSetUp()) return false; |
| 6197 | 6233 |
| 6198 switch (space) { | 6234 switch (space) { |
| 6199 case NEW_SPACE: | 6235 case NEW_SPACE: |
| 6200 return new_space_.ToSpaceContains(addr); | 6236 return new_space_.ToSpaceContains(addr); |
| 6201 case OLD_POINTER_SPACE: | 6237 case OLD_POINTER_SPACE: |
| 6202 return old_pointer_space_->Contains(addr); | 6238 return old_pointer_space_->Contains(addr); |
| 6203 case OLD_DATA_SPACE: | 6239 case OLD_DATA_SPACE: |
| 6204 return old_data_space_->Contains(addr); | 6240 return old_data_space_->Contains(addr); |
| 6205 case CODE_SPACE: | 6241 case CODE_SPACE: |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6572 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); | 6608 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); |
| 6573 v->Synchronize(VisitorSynchronization::kStrongRootList); | 6609 v->Synchronize(VisitorSynchronization::kStrongRootList); |
| 6574 | 6610 |
| 6575 v->VisitPointer(BitCast<Object**>(&hidden_string_)); | 6611 v->VisitPointer(BitCast<Object**>(&hidden_string_)); |
| 6576 v->Synchronize(VisitorSynchronization::kInternalizedString); | 6612 v->Synchronize(VisitorSynchronization::kInternalizedString); |
| 6577 | 6613 |
| 6578 isolate_->bootstrapper()->Iterate(v); | 6614 isolate_->bootstrapper()->Iterate(v); |
| 6579 v->Synchronize(VisitorSynchronization::kBootstrapper); | 6615 v->Synchronize(VisitorSynchronization::kBootstrapper); |
| 6580 isolate_->Iterate(v); | 6616 isolate_->Iterate(v); |
| 6581 v->Synchronize(VisitorSynchronization::kTop); | 6617 v->Synchronize(VisitorSynchronization::kTop); |
| 6582 Relocatable::Iterate(v); | 6618 Relocatable::Iterate(isolate_, v); |
| 6583 v->Synchronize(VisitorSynchronization::kRelocatable); | 6619 v->Synchronize(VisitorSynchronization::kRelocatable); |
| 6584 | 6620 |
| 6585 #ifdef ENABLE_DEBUGGER_SUPPORT | 6621 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 6586 isolate_->debug()->Iterate(v); | 6622 isolate_->debug()->Iterate(v); |
| 6587 if (isolate_->deoptimizer_data() != NULL) { | 6623 if (isolate_->deoptimizer_data() != NULL) { |
| 6588 isolate_->deoptimizer_data()->Iterate(v); | 6624 isolate_->deoptimizer_data()->Iterate(v); |
| 6589 } | 6625 } |
| 6590 #endif | 6626 #endif |
| 6591 v->Synchronize(VisitorSynchronization::kDebug); | 6627 v->Synchronize(VisitorSynchronization::kDebug); |
| 6592 isolate_->compilation_cache()->Iterate(v); | 6628 isolate_->compilation_cache()->Iterate(v); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6633 v->Synchronize(VisitorSynchronization::kThreadManager); | 6669 v->Synchronize(VisitorSynchronization::kThreadManager); |
| 6634 | 6670 |
| 6635 // Iterate over the pointers the Serialization/Deserialization code is | 6671 // Iterate over the pointers the Serialization/Deserialization code is |
| 6636 // holding. | 6672 // holding. |
| 6637 // During garbage collection this keeps the partial snapshot cache alive. | 6673 // During garbage collection this keeps the partial snapshot cache alive. |
| 6638 // During deserialization of the startup snapshot this creates the partial | 6674 // During deserialization of the startup snapshot this creates the partial |
| 6639 // snapshot cache and deserializes the objects it refers to. During | 6675 // snapshot cache and deserializes the objects it refers to. During |
| 6640 // serialization this does nothing, since the partial snapshot cache is | 6676 // serialization this does nothing, since the partial snapshot cache is |
| 6641 // empty. However the next thing we do is create the partial snapshot, | 6677 // empty. However the next thing we do is create the partial snapshot, |
| 6642 // filling up the partial snapshot cache with objects it needs as we go. | 6678 // filling up the partial snapshot cache with objects it needs as we go. |
| 6643 SerializerDeserializer::Iterate(v); | 6679 SerializerDeserializer::Iterate(isolate_, v); |
| 6644 // We don't do a v->Synchronize call here, because in debug mode that will | 6680 // We don't do a v->Synchronize call here, because in debug mode that will |
| 6645 // output a flag to the snapshot. However at this point the serializer and | 6681 // output a flag to the snapshot. However at this point the serializer and |
| 6646 // deserializer are deliberately a little unsynchronized (see above) so the | 6682 // deserializer are deliberately a little unsynchronized (see above) so the |
| 6647 // checking of the sync flag in the snapshot would fail. | 6683 // checking of the sync flag in the snapshot would fail. |
| 6648 } | 6684 } |
| 6649 | 6685 |
| 6650 | 6686 |
| 6651 // TODO(1236194): Since the heap size is configurable on the command line | 6687 // TODO(1236194): Since the heap size is configurable on the command line |
| 6652 // and through the API, we should gracefully handle the case that the heap | 6688 // and through the API, we should gracefully handle the case that the heap |
| 6653 // size is not big enough to fit all the initial objects. | 6689 // size is not big enough to fit all the initial objects. |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7237 | 7273 |
| 7238 class HeapObjectsFilter { | 7274 class HeapObjectsFilter { |
| 7239 public: | 7275 public: |
| 7240 virtual ~HeapObjectsFilter() {} | 7276 virtual ~HeapObjectsFilter() {} |
| 7241 virtual bool SkipObject(HeapObject* object) = 0; | 7277 virtual bool SkipObject(HeapObject* object) = 0; |
| 7242 }; | 7278 }; |
| 7243 | 7279 |
| 7244 | 7280 |
| 7245 class UnreachableObjectsFilter : public HeapObjectsFilter { | 7281 class UnreachableObjectsFilter : public HeapObjectsFilter { |
| 7246 public: | 7282 public: |
| 7247 UnreachableObjectsFilter() { | 7283 explicit UnreachableObjectsFilter(Heap* heap) : heap_(heap) { |
| 7248 MarkReachableObjects(); | 7284 MarkReachableObjects(); |
| 7249 } | 7285 } |
| 7250 | 7286 |
| 7251 ~UnreachableObjectsFilter() { | 7287 ~UnreachableObjectsFilter() { |
| 7252 Isolate::Current()->heap()->mark_compact_collector()->ClearMarkbits(); | 7288 heap_->mark_compact_collector()->ClearMarkbits(); |
| 7253 } | 7289 } |
| 7254 | 7290 |
| 7255 bool SkipObject(HeapObject* object) { | 7291 bool SkipObject(HeapObject* object) { |
| 7256 MarkBit mark_bit = Marking::MarkBitFrom(object); | 7292 MarkBit mark_bit = Marking::MarkBitFrom(object); |
| 7257 return !mark_bit.Get(); | 7293 return !mark_bit.Get(); |
| 7258 } | 7294 } |
| 7259 | 7295 |
| 7260 private: | 7296 private: |
| 7261 class MarkingVisitor : public ObjectVisitor { | 7297 class MarkingVisitor : public ObjectVisitor { |
| 7262 public: | 7298 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7279 HeapObject* obj = marking_stack_.RemoveLast(); | 7315 HeapObject* obj = marking_stack_.RemoveLast(); |
| 7280 obj->Iterate(this); | 7316 obj->Iterate(this); |
| 7281 } | 7317 } |
| 7282 } | 7318 } |
| 7283 | 7319 |
| 7284 private: | 7320 private: |
| 7285 List<HeapObject*> marking_stack_; | 7321 List<HeapObject*> marking_stack_; |
| 7286 }; | 7322 }; |
| 7287 | 7323 |
| 7288 void MarkReachableObjects() { | 7324 void MarkReachableObjects() { |
| 7289 Heap* heap = Isolate::Current()->heap(); | |
| 7290 MarkingVisitor visitor; | 7325 MarkingVisitor visitor; |
| 7291 heap->IterateRoots(&visitor, VISIT_ALL); | 7326 heap_->IterateRoots(&visitor, VISIT_ALL); |
| 7292 visitor.TransitiveClosure(); | 7327 visitor.TransitiveClosure(); |
| 7293 } | 7328 } |
| 7294 | 7329 |
| 7330 Heap* heap_; |
| 7295 DisallowHeapAllocation no_allocation_; | 7331 DisallowHeapAllocation no_allocation_; |
| 7296 }; | 7332 }; |
| 7297 | 7333 |
| 7298 | 7334 |
| 7299 HeapIterator::HeapIterator(Heap* heap) | 7335 HeapIterator::HeapIterator(Heap* heap) |
| 7300 : heap_(heap), | 7336 : heap_(heap), |
| 7301 filtering_(HeapIterator::kNoFiltering), | 7337 filtering_(HeapIterator::kNoFiltering), |
| 7302 filter_(NULL) { | 7338 filter_(NULL) { |
| 7303 Init(); | 7339 Init(); |
| 7304 } | 7340 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7316 HeapIterator::~HeapIterator() { | 7352 HeapIterator::~HeapIterator() { |
| 7317 Shutdown(); | 7353 Shutdown(); |
| 7318 } | 7354 } |
| 7319 | 7355 |
| 7320 | 7356 |
| 7321 void HeapIterator::Init() { | 7357 void HeapIterator::Init() { |
| 7322 // Start the iteration. | 7358 // Start the iteration. |
| 7323 space_iterator_ = new SpaceIterator(heap_); | 7359 space_iterator_ = new SpaceIterator(heap_); |
| 7324 switch (filtering_) { | 7360 switch (filtering_) { |
| 7325 case kFilterUnreachable: | 7361 case kFilterUnreachable: |
| 7326 filter_ = new UnreachableObjectsFilter; | 7362 filter_ = new UnreachableObjectsFilter(heap_); |
| 7327 break; | 7363 break; |
| 7328 default: | 7364 default: |
| 7329 break; | 7365 break; |
| 7330 } | 7366 } |
| 7331 object_iterator_ = space_iterator_->next(); | 7367 object_iterator_ = space_iterator_->next(); |
| 7332 } | 7368 } |
| 7333 | 7369 |
| 7334 | 7370 |
| 7335 void HeapIterator::Shutdown() { | 7371 void HeapIterator::Shutdown() { |
| 7336 #ifdef DEBUG | 7372 #ifdef DEBUG |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7861 #ifdef DEBUG | 7897 #ifdef DEBUG |
| 7862 void Heap::GarbageCollectionGreedyCheck() { | 7898 void Heap::GarbageCollectionGreedyCheck() { |
| 7863 ASSERT(FLAG_gc_greedy); | 7899 ASSERT(FLAG_gc_greedy); |
| 7864 if (isolate_->bootstrapper()->IsActive()) return; | 7900 if (isolate_->bootstrapper()->IsActive()) return; |
| 7865 if (disallow_allocation_failure()) return; | 7901 if (disallow_allocation_failure()) return; |
| 7866 CollectGarbage(NEW_SPACE); | 7902 CollectGarbage(NEW_SPACE); |
| 7867 } | 7903 } |
| 7868 #endif | 7904 #endif |
| 7869 | 7905 |
| 7870 | 7906 |
| 7871 TranscendentalCache::SubCache::SubCache(Type t) | 7907 TranscendentalCache::SubCache::SubCache(Isolate* isolate, Type t) |
| 7872 : type_(t), | 7908 : type_(t), |
| 7873 isolate_(Isolate::Current()) { | 7909 isolate_(isolate) { |
| 7874 uint32_t in0 = 0xffffffffu; // Bit-pattern for a NaN that isn't | 7910 uint32_t in0 = 0xffffffffu; // Bit-pattern for a NaN that isn't |
| 7875 uint32_t in1 = 0xffffffffu; // generated by the FPU. | 7911 uint32_t in1 = 0xffffffffu; // generated by the FPU. |
| 7876 for (int i = 0; i < kCacheSize; i++) { | 7912 for (int i = 0; i < kCacheSize; i++) { |
| 7877 elements_[i].in[0] = in0; | 7913 elements_[i].in[0] = in0; |
| 7878 elements_[i].in[1] = in1; | 7914 elements_[i].in[1] = in1; |
| 7879 elements_[i].output = NULL; | 7915 elements_[i].output = NULL; |
| 7880 } | 7916 } |
| 7881 } | 7917 } |
| 7882 | 7918 |
| 7883 | 7919 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8064 if (FLAG_concurrent_recompilation) { | 8100 if (FLAG_concurrent_recompilation) { |
| 8065 heap_->relocation_mutex_->Lock(); | 8101 heap_->relocation_mutex_->Lock(); |
| 8066 #ifdef DEBUG | 8102 #ifdef DEBUG |
| 8067 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8103 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
| 8068 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8104 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
| 8069 #endif // DEBUG | 8105 #endif // DEBUG |
| 8070 } | 8106 } |
| 8071 } | 8107 } |
| 8072 | 8108 |
| 8073 } } // namespace v8::internal | 8109 } } // namespace v8::internal |
| OLD | NEW |