set executable bit on promote-build.sh (r=cpeyer)
[tamarin-stm.git] / MMgc / GCPolicyManager-inlines.h
blob8eef9dc9b997c6bcbc5581d488f118c7198cf201
1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2006
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Adobe AS3 Team
25 * leon.sha@sun.com
27 * Alternatively, the contents of this file may be used under the terms of
28 * either the GNU General Public License Version 2 or later (the "GPL"), or
29 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef __MMgc_GCPolicyManager_inlines__
42 #define __MMgc_GCPolicyManager_inlines__
44 namespace MMgc
46 // GCPolicyManager
47 // A number of the inline functions for this class are currently in GC.cpp
49 #ifdef MMGC_POLICY_PROFILING
50 REALLY_INLINE void GCPolicyManager::signalWriteBarrierWork(int stage)
52 GCAssert(ARRAY_SIZE(barrierStageLastCollection) > size_t(stage));
53 barrierStageLastCollection[stage]++;
55 #endif
57 #ifdef MMGC_REFCOUNT_PROFILING
58 REALLY_INLINE void GCPolicyManager::signalIncrementRef()
60 incrementRefLastCollection++;
63 REALLY_INLINE void GCPolicyManager::signalDecrementRef()
65 decrementRefLastCollection++;
68 REALLY_INLINE void GCPolicyManager::signalZCTAdd(bool initial, uint32_t population)
70 addZCTLastCollection++;
71 if (initial)
72 addZCTInitialTotal++;
73 if (population > zctPeakSize)
74 zctPeakSize = population;
77 REALLY_INLINE void GCPolicyManager::signalZCTRemove(bool final)
79 removeZCTLastCollection++;
80 if (final)
81 removeZCTFinalTotal++;
83 #endif
85 #ifdef MMGC_POINTINESS_PROFILING
86 REALLY_INLINE void GCPolicyManager::signalDemographics(size_t candidate_words, size_t could_be_pointer, size_t actually_is_pointer)
88 candidateWords += candidate_words;
89 couldBePointer += could_be_pointer;
90 actuallyIsPointer += actually_is_pointer;
92 #endif
94 REALLY_INLINE bool GCPolicyManager::signalAllocWork(size_t nbytes)
96 #ifdef MMGC_POLICY_PROFILING
97 objectsAllocated++;
98 bytesAllocated += nbytes;
99 #endif
100 remainingMinorAllocationBudget -= int32_t(nbytes);
102 // Important to use < 0 not <= 0: in greedy mode we set the budget to
103 // exactly the object size we're about to allocate. Using <= 0 would
104 // cause the allocation never to succeed.
105 return remainingMinorAllocationBudget < 0;
108 REALLY_INLINE void GCPolicyManager::signalMarkWork(size_t nbytes)
110 objectsScannedLastCollection++;
111 bytesScannedLastCollection += uint32_t(nbytes);
114 REALLY_INLINE void GCPolicyManager::signalFreeWork(size_t nbytes)
116 remainingMinorAllocationBudget += int32_t(nbytes);
119 REALLY_INLINE uint32_t GCPolicyManager::lowerLimitCollectionThreshold() {
120 return collectionThreshold;
123 REALLY_INLINE uint64_t GCPolicyManager::now() {
124 return VMPI_getPerformanceCounter();
128 #endif // __MMgc_GCPolicyManager_inlines__