Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: src/heap/spaces.h

Issue 1460063006: [heap] report allocated object to the inline-allocation-observers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #ifndef V8_HEAP_SPACES_H_ 5 #ifndef V8_HEAP_SPACES_H_
6 #define V8_HEAP_SPACES_H_ 6 #define V8_HEAP_SPACES_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/atomic-utils.h" 9 #include "src/atomic-utils.h"
10 #include "src/base/atomicops.h" 10 #include "src/base/atomicops.h"
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 : step_size_(step_size), bytes_to_next_step_(step_size) { 2516 : step_size_(step_size), bytes_to_next_step_(step_size) {
2517 DCHECK(step_size >= kPointerSize); 2517 DCHECK(step_size >= kPointerSize);
2518 } 2518 }
2519 virtual ~InlineAllocationObserver() {} 2519 virtual ~InlineAllocationObserver() {}
2520 2520
2521 private: 2521 private:
2522 intptr_t step_size() const { return step_size_; } 2522 intptr_t step_size() const { return step_size_; }
2523 intptr_t bytes_to_next_step() const { return bytes_to_next_step_; } 2523 intptr_t bytes_to_next_step() const { return bytes_to_next_step_; }
2524 2524
2525 // Pure virtual method provided by the subclasses that gets called when at 2525 // Pure virtual method provided by the subclasses that gets called when at
2526 // least step_size bytes have been allocated. 2526 // least step_size bytes have been allocated. soon_object is the address just
2527 virtual void Step(int bytes_allocated) = 0; 2527 // allocated (but not yet initialized.) size is the size of the object as
2528 // requested (i.e. w/o the alignment fillers). Some complexities to be aware
2529 // of:
2530 // 1) soon_object will be nullptr in cases where we end up observing an
2531 // allocation that happens to be a filler space (e.g. page boundaries.)
2532 // 2) size is the requested size at the time of allocation. Right-trimming
2533 // may change the object size dynamically.
2534 // 3) soon_object may actually be the first object in an allocation-folding
2535 // group. In such a case size is the size of the group rather than the
2536 // first object.
2537 virtual void Step(int bytes_allocated, Address soon_object, size_t size) = 0;
2528 2538
2529 // Called each time the new space does an inline allocation step. This may be 2539 // Called each time the new space does an inline allocation step. This may be
2530 // more frequently than the step_size we are monitoring (e.g. when there are 2540 // more frequently than the step_size we are monitoring (e.g. when there are
2531 // multiple observers, or when page or space boundary is encountered.) 2541 // multiple observers, or when page or space boundary is encountered.)
2532 void InlineAllocationStep(int bytes_allocated) { 2542 void InlineAllocationStep(int bytes_allocated, Address soon_object,
2543 size_t size) {
2533 bytes_to_next_step_ -= bytes_allocated; 2544 bytes_to_next_step_ -= bytes_allocated;
2534 if (bytes_to_next_step_ <= 0) { 2545 if (bytes_to_next_step_ <= 0) {
2535 Step(static_cast<int>(step_size_ - bytes_to_next_step_)); 2546 Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object,
2547 size);
2536 bytes_to_next_step_ = step_size_; 2548 bytes_to_next_step_ = step_size_;
2537 } 2549 }
2538 } 2550 }
2539 2551
2540 intptr_t step_size_; 2552 intptr_t step_size_;
2541 intptr_t bytes_to_next_step_; 2553 intptr_t bytes_to_next_step_;
2542 2554
2543 friend class NewSpace; 2555 friend class NewSpace;
2544 2556
2545 DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver); 2557 DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 HistogramInfo* promoted_histogram_; 2868 HistogramInfo* promoted_histogram_;
2857 2869
2858 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); 2870 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment);
2859 2871
2860 // If we are doing inline allocation in steps, this method performs the 'step' 2872 // If we are doing inline allocation in steps, this method performs the 'step'
2861 // operation. top is the memory address of the bump pointer at the last 2873 // operation. top is the memory address of the bump pointer at the last
2862 // inline allocation (i.e. it determines the numbers of bytes actually 2874 // inline allocation (i.e. it determines the numbers of bytes actually
2863 // allocated since the last step.) new_top is the address of the bump pointer 2875 // allocated since the last step.) new_top is the address of the bump pointer
2864 // where the next byte is going to be allocated from. top and new_top may be 2876 // where the next byte is going to be allocated from. top and new_top may be
2865 // different when we cross a page boundary or reset the space. 2877 // different when we cross a page boundary or reset the space.
2866 void InlineAllocationStep(Address top, Address new_top); 2878 void InlineAllocationStep(Address top, Address new_top, Address soon_object,
2879 size_t size);
2867 intptr_t GetNextInlineAllocationStepSize(); 2880 intptr_t GetNextInlineAllocationStepSize();
2868 void StartNextInlineAllocationStep(); 2881 void StartNextInlineAllocationStep();
2869 2882
2870 friend class SemiSpaceIterator; 2883 friend class SemiSpaceIterator;
2871 }; 2884 };
2872 2885
2873 // ----------------------------------------------------------------------------- 2886 // -----------------------------------------------------------------------------
2874 // Compaction space that is used temporarily during compaction. 2887 // Compaction space that is used temporarily during compaction.
2875 2888
2876 class CompactionSpace : public PagedSpace { 2889 class CompactionSpace : public PagedSpace {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3127 count = 0; 3140 count = 0;
3128 } 3141 }
3129 // Must be small, since an iteration is used for lookup. 3142 // Must be small, since an iteration is used for lookup.
3130 static const int kMaxComments = 64; 3143 static const int kMaxComments = 64;
3131 }; 3144 };
3132 #endif 3145 #endif
3133 } // namespace internal 3146 } // namespace internal
3134 } // namespace v8 3147 } // namespace v8
3135 3148
3136 #endif // V8_HEAP_SPACES_H_ 3149 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698