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 7221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7232 | 7232 |
7233 class HeapObjectsFilter { | 7233 class HeapObjectsFilter { |
7234 public: | 7234 public: |
7235 virtual ~HeapObjectsFilter() {} | 7235 virtual ~HeapObjectsFilter() {} |
7236 virtual bool SkipObject(HeapObject* object) = 0; | 7236 virtual bool SkipObject(HeapObject* object) = 0; |
7237 }; | 7237 }; |
7238 | 7238 |
7239 | 7239 |
7240 class UnreachableObjectsFilter : public HeapObjectsFilter { | 7240 class UnreachableObjectsFilter : public HeapObjectsFilter { |
7241 public: | 7241 public: |
7242 UnreachableObjectsFilter() { | 7242 explicit UnreachableObjectsFilter(Heap* heap) : heap_(heap) { |
7243 MarkReachableObjects(); | 7243 MarkReachableObjects(); |
7244 } | 7244 } |
7245 | 7245 |
7246 ~UnreachableObjectsFilter() { | 7246 ~UnreachableObjectsFilter() { |
7247 Isolate::Current()->heap()->mark_compact_collector()->ClearMarkbits(); | 7247 heap_->mark_compact_collector()->ClearMarkbits(); |
7248 } | 7248 } |
7249 | 7249 |
7250 bool SkipObject(HeapObject* object) { | 7250 bool SkipObject(HeapObject* object) { |
7251 MarkBit mark_bit = Marking::MarkBitFrom(object); | 7251 MarkBit mark_bit = Marking::MarkBitFrom(object); |
7252 return !mark_bit.Get(); | 7252 return !mark_bit.Get(); |
7253 } | 7253 } |
7254 | 7254 |
7255 private: | 7255 private: |
7256 class MarkingVisitor : public ObjectVisitor { | 7256 class MarkingVisitor : public ObjectVisitor { |
7257 public: | 7257 public: |
(...skipping 16 matching lines...) Expand all Loading... |
7274 HeapObject* obj = marking_stack_.RemoveLast(); | 7274 HeapObject* obj = marking_stack_.RemoveLast(); |
7275 obj->Iterate(this); | 7275 obj->Iterate(this); |
7276 } | 7276 } |
7277 } | 7277 } |
7278 | 7278 |
7279 private: | 7279 private: |
7280 List<HeapObject*> marking_stack_; | 7280 List<HeapObject*> marking_stack_; |
7281 }; | 7281 }; |
7282 | 7282 |
7283 void MarkReachableObjects() { | 7283 void MarkReachableObjects() { |
7284 Heap* heap = Isolate::Current()->heap(); | |
7285 MarkingVisitor visitor; | 7284 MarkingVisitor visitor; |
7286 heap->IterateRoots(&visitor, VISIT_ALL); | 7285 heap_->IterateRoots(&visitor, VISIT_ALL); |
7287 visitor.TransitiveClosure(); | 7286 visitor.TransitiveClosure(); |
7288 } | 7287 } |
7289 | 7288 |
| 7289 Heap* heap_; |
7290 DisallowHeapAllocation no_allocation_; | 7290 DisallowHeapAllocation no_allocation_; |
7291 }; | 7291 }; |
7292 | 7292 |
7293 | 7293 |
7294 HeapIterator::HeapIterator(Heap* heap) | 7294 HeapIterator::HeapIterator(Heap* heap) |
7295 : heap_(heap), | 7295 : heap_(heap), |
7296 filtering_(HeapIterator::kNoFiltering), | 7296 filtering_(HeapIterator::kNoFiltering), |
7297 filter_(NULL) { | 7297 filter_(NULL) { |
7298 Init(); | 7298 Init(); |
7299 } | 7299 } |
(...skipping 11 matching lines...) Expand all Loading... |
7311 HeapIterator::~HeapIterator() { | 7311 HeapIterator::~HeapIterator() { |
7312 Shutdown(); | 7312 Shutdown(); |
7313 } | 7313 } |
7314 | 7314 |
7315 | 7315 |
7316 void HeapIterator::Init() { | 7316 void HeapIterator::Init() { |
7317 // Start the iteration. | 7317 // Start the iteration. |
7318 space_iterator_ = new SpaceIterator(heap_); | 7318 space_iterator_ = new SpaceIterator(heap_); |
7319 switch (filtering_) { | 7319 switch (filtering_) { |
7320 case kFilterUnreachable: | 7320 case kFilterUnreachable: |
7321 filter_ = new UnreachableObjectsFilter; | 7321 filter_ = new UnreachableObjectsFilter(heap_); |
7322 break; | 7322 break; |
7323 default: | 7323 default: |
7324 break; | 7324 break; |
7325 } | 7325 } |
7326 object_iterator_ = space_iterator_->next(); | 7326 object_iterator_ = space_iterator_->next(); |
7327 } | 7327 } |
7328 | 7328 |
7329 | 7329 |
7330 void HeapIterator::Shutdown() { | 7330 void HeapIterator::Shutdown() { |
7331 #ifdef DEBUG | 7331 #ifdef DEBUG |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7856 #ifdef DEBUG | 7856 #ifdef DEBUG |
7857 void Heap::GarbageCollectionGreedyCheck() { | 7857 void Heap::GarbageCollectionGreedyCheck() { |
7858 ASSERT(FLAG_gc_greedy); | 7858 ASSERT(FLAG_gc_greedy); |
7859 if (isolate_->bootstrapper()->IsActive()) return; | 7859 if (isolate_->bootstrapper()->IsActive()) return; |
7860 if (disallow_allocation_failure()) return; | 7860 if (disallow_allocation_failure()) return; |
7861 CollectGarbage(NEW_SPACE); | 7861 CollectGarbage(NEW_SPACE); |
7862 } | 7862 } |
7863 #endif | 7863 #endif |
7864 | 7864 |
7865 | 7865 |
7866 TranscendentalCache::SubCache::SubCache(Type t) | 7866 TranscendentalCache::SubCache::SubCache(Isolate* isolate, Type t) |
7867 : type_(t), | 7867 : type_(t), |
7868 isolate_(Isolate::Current()) { | 7868 isolate_(isolate) { |
7869 uint32_t in0 = 0xffffffffu; // Bit-pattern for a NaN that isn't | 7869 uint32_t in0 = 0xffffffffu; // Bit-pattern for a NaN that isn't |
7870 uint32_t in1 = 0xffffffffu; // generated by the FPU. | 7870 uint32_t in1 = 0xffffffffu; // generated by the FPU. |
7871 for (int i = 0; i < kCacheSize; i++) { | 7871 for (int i = 0; i < kCacheSize; i++) { |
7872 elements_[i].in[0] = in0; | 7872 elements_[i].in[0] = in0; |
7873 elements_[i].in[1] = in1; | 7873 elements_[i].in[1] = in1; |
7874 elements_[i].output = NULL; | 7874 elements_[i].output = NULL; |
7875 } | 7875 } |
7876 } | 7876 } |
7877 | 7877 |
7878 | 7878 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8059 if (FLAG_concurrent_recompilation) { | 8059 if (FLAG_concurrent_recompilation) { |
8060 heap_->relocation_mutex_->Lock(); | 8060 heap_->relocation_mutex_->Lock(); |
8061 #ifdef DEBUG | 8061 #ifdef DEBUG |
8062 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8062 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
8063 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8063 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
8064 #endif // DEBUG | 8064 #endif // DEBUG |
8065 } | 8065 } |
8066 } | 8066 } |
8067 | 8067 |
8068 } } // namespace v8::internal | 8068 } } // namespace v8::internal |
OLD | NEW |