annotate src/share/vm/c1/c1_ValueSet.hpp @ 342:37f87013dfd8

6711316: Open source the Garbage-First garbage collector Summary: First mercurial integration of the code for the Garbage-First garbage collector. Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr
author ysr
date Thu, 05 Jun 2008 15:57:56 -0700
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // A ValueSet is a simple abstraction on top of a BitMap representing
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // a set of Instructions. Currently it assumes that the number of
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // instructions is fixed during its lifetime; should make it
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // automatically resizable.
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class ValueSet: public CompilationResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 BitMap _map;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 ValueSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 ValueSet* copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
38 bool contains(Value x);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 void put (Value x);
a61af66fc99e Initial load
duke
parents:
diff changeset
40 void remove (Value x);
a61af66fc99e Initial load
duke
parents:
diff changeset
41 bool set_intersect(ValueSet* other);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 void set_union(ValueSet* other);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 void clear ();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 void set_from(ValueSet* other);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 bool equals (ValueSet* other);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 };
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 inline ValueSet::ValueSet() : _map(Instruction::number_of_instructions()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _map.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 inline ValueSet* ValueSet::copy() {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 ValueSet* res = new ValueSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 res->_map.set_from(_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 inline bool ValueSet::contains(Value x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 return _map.at(x->id());
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 inline void ValueSet::put(Value x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _map.set_bit(x->id());
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 inline void ValueSet::remove(Value x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _map.clear_bit(x->id());
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 inline bool ValueSet::set_intersect(ValueSet* other) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return _map.set_intersection_with_result(other->_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 inline void ValueSet::set_union(ValueSet* other) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 _map.set_union(other->_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 inline void ValueSet::clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 _map.clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 inline void ValueSet::set_from(ValueSet* other) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 _map.set_from(other->_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 inline bool ValueSet::equals(ValueSet* other) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return _map.is_same(other->_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }