EMMA Coverage Report (generated Sat Jun 02 16:47:50 EDT 2012)
[all classes][net.sf.madmap]

COVERAGE SUMMARY FOR SOURCE FILE [HprofHeapCollectable.java]

nameclass, %method, %block, %line, %
HprofHeapCollectable.java100% (1/1)93%  (13/14)86%  (142/166)87%  (33/38)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class HprofHeapCollectable100% (1/1)93%  (13/14)86%  (142/166)87%  (33/38)
containsRef (long): boolean 0%   (0/1)0%   (0/21)0%   (0/4)
setClaimed (boolean): void 100% (1/1)75%  (9/12)75%  (3/4)
HprofHeapCollectable (long): void 100% (1/1)100% (7/7)100% (3/3)
claim (): void 100% (1/1)100% (7/7)100% (1/1)
getRetainedSize (): long 100% (1/1)100% (7/7)100% (1/1)
getVisitedCount (): int 100% (1/1)100% (9/9)100% (1/1)
getVisitedStack (): Stack 100% (1/1)100% (3/3)100% (1/1)
isAlive (): boolean 100% (1/1)100% (11/11)100% (1/1)
isClaimed (): boolean 100% (1/1)100% (11/11)100% (1/1)
longArrayListtoLongArray (ArrayList): long [] 100% (1/1)100% (31/31)100% (8/8)
resetVisited (): void 100% (1/1)100% (4/4)100% (2/2)
setLiveness (boolean): void 100% (1/1)100% (16/16)100% (4/4)
setRetainedSize (long): void 100% (1/1)100% (13/13)100% (3/3)
visited (HprofHeapCollectable): void 100% (1/1)100% (14/14)100% (4/4)

1/*
2 * Copyright 2008 Eric Caspole
3 * 
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
5 * file except in compliance with the License. You may obtain a copy of the License at
6 * 
7 * http://www.apache.org/licenses/LICENSE-2.0
8 * 
9 * Unless required by applicable law or agreed to in writing, software distributed under
10 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14 package net.sf.madmap;
15 
16import java.util.*;
17 
18/**
19 * HprofHeapCollectable is the base class for everything that is "collectable"
20 * in the target process heap, i.e. objects, arrays and classes. This class
21 * has methods to compute the liveness and retained size during the analysis.
22 * 
23 * @author ecaspole
24 *  
25 */
26public abstract class HprofHeapCollectable extends HprofHeapElement {
27 
28  // highest bit is sign bit
29  static final long _liveBits     = 0x40000000;
30  static final long _claimedBits  = 0x20000000;
31  static final long _sizeBits     = 0x1fffffff;
32  
33  // support for iterative retained size accumulation
34  protected Stack  _visitedChildren;
35  long      _retainedSize = 0;
36 
37  public long getRetainedSize()         { return (_retainedSize << 3) >> 3; }
38  public void claim()                   { _retainedSize = (_retainedSize | (_claimedBits << 32)); }
39  public boolean isClaimed()            { return (_retainedSize & (_claimedBits << 32)) != 0; }
40  public void setClaimed( boolean x )   { 
41    if ( x ) {
42      claim(); 
43    } else {
44      _retainedSize = (_retainedSize & (~(_claimedBits<<32)));
45    }
46  }
47  
48  public boolean  isAlive()             { return (_retainedSize & (_liveBits << 32 )) != 0; }
49  public void     setLiveness( boolean lv )   { 
50    if ( lv ) {
51      _retainedSize = _retainedSize | (_liveBits << 32);
52    } else {
53      _retainedSize = _retainedSize & (~(_liveBits << 32));    
54    }
55  }
56  
57  /**
58   * @param newSize the object's retained size, computed in the analysis phase 
59   */
60  public void setRetainedSize( long newSize) { 
61    long oldBits = _retainedSize >> 61;
62          _retainedSize = newSize | (oldBits << 61); 
63  }
64 
65  /**
66   * @param addr address of the object
67   */
68  public HprofHeapCollectable( long addr ) {
69          super( addr );
70  }
71 
72  long[]  longArrayListtoLongArray( ArrayList in ) {
73    if ( in == null ) {
74      return null;
75    }      
76    if ( in.size() == 0 ) {
77      return null;
78    }
79    long[]  out = new long[ in.size() ];
80    for ( int i = 0; i < out.length; i++ ) {
81      out[ i ] = ((Long) in.get( i )).longValue();
82    }
83    return out;
84  }
85 
86 
87  public abstract String    className();
88  public abstract long      children_size();
89  public abstract long[]    children();
90  public abstract long      size();
91  
92  /**
93 * @param ref        the address to find in this object
94 * @return                true if ref is a member of this object
95 */
96public boolean containsRef( long ref ) {
97    for ( int i = 0; i < children_size(); i ++ ) {
98      if ( children()[i] == ref ) {
99        return true;
100      }
101    }
102    return false;
103  }
104  
105  void visited( HprofHeapCollectable child ) {
106    if ( _visitedChildren == null ) {
107      _visitedChildren = new Stack();
108    }
109    _visitedChildren.push( child );
110  }
111  
112  Stack getVisitedStack() { return _visitedChildren; }
113  int getVisitedCount() { 
114    return _visitedChildren == null ? 0 : _visitedChildren.size();
115  }
116  
117  void resetVisited() { 
118    _visitedChildren = null;
119  }  
120}

[all classes][net.sf.madmap]
EMMA 2.0.5312 (C) Vladimir Roubtsov