|
1 /* |
|
2 * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 package vm.gc.containers; |
|
24 |
|
25 import nsk.share.gc.Memory; |
|
26 import nsk.share.gc.gp.GarbageProducer; |
|
27 import nsk.share.gc.gp.MemoryStrategy; |
|
28 import nsk.share.test.ExecutionController; |
|
29 |
|
30 public interface Container { |
|
31 public void setExecutionController(ExecutionController stresser); |
|
32 public void initialize(); |
|
33 public void update(); |
|
34 } |
|
35 |
|
36 abstract class TypicalContainer implements Container { |
|
37 |
|
38 protected ExecutionController stresser; |
|
39 protected long count; |
|
40 protected long size; |
|
41 protected GarbageProducer garbageProducer; |
|
42 protected Speed speed; |
|
43 |
|
44 public TypicalContainer(long maximumSize, GarbageProducer garbageProducer, |
|
45 MemoryStrategy memoryStrategy, Speed speed) { |
|
46 this.count = memoryStrategy.getCount(maximumSize); |
|
47 this.size = memoryStrategy.getSize(maximumSize); |
|
48 // typical container have at least reference to other element |
|
49 // and to data which is really size of "size" really for 100 bytes |
|
50 // overhead is about 50% |
|
51 final int structureOverHead = 6 * Memory.getReferenceSize(); |
|
52 if (this.size < structureOverHead * 100) { |
|
53 this.count = this.count * (this.size - structureOverHead) / this.size; |
|
54 } |
|
55 this.garbageProducer = garbageProducer; |
|
56 this.speed = speed; |
|
57 System.err.format("Creating container: size = %s count = %s\n", size, count); |
|
58 } |
|
59 |
|
60 public void setExecutionController(ExecutionController stresser) { |
|
61 this.stresser = stresser; |
|
62 } |
|
63 |
|
64 |
|
65 } |