annotate src/share/vm/runtime/icache.hpp @ 3979:4dfb2df418f2

6484982: G1: process references during evacuation pauses Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate. Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
author johnc
date Thu, 22 Sep 2011 10:57:37 -0700
parents 1d1603768966
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_RUNTIME_ICACHE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_ICACHE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/stubCodeGenerator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // Interface for updating the instruction cache. Whenever the VM modifies
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // code, part of the processor instruction cache potentially has to be flushed.
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // Default implementation is in icache.cpp, and can be hidden per-platform.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Most platforms must provide only ICacheStubGenerator::generate_icache_flush().
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Platforms that don't require icache flushing can just nullify the public
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // members of AbstractICache in their ICache class. AbstractICache should never
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // be referenced other than by deriving the ICache class from it.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // The code for the ICache class and for generate_icache_flush() must be in
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // architecture-specific files, i.e., icache_<arch>.hpp/.cpp
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class AbstractICache : AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // The flush stub signature
a61af66fc99e Initial load
duke
parents:
diff changeset
46 typedef int (*flush_icache_stub_t)(address addr, int lines, int magic);
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // The flush stub function address
a61af66fc99e Initial load
duke
parents:
diff changeset
50 static flush_icache_stub_t _flush_icache_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Call the flush stub
a61af66fc99e Initial load
duke
parents:
diff changeset
53 static void call_flush_stub(address start, int lines);
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
56 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 stub_size = 0, // Size of the icache flush stub in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
58 line_size = 0, // Icache line size in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
59 log2_line_size = 0 // log2(line_size)
a61af66fc99e Initial load
duke
parents:
diff changeset
60 };
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static void invalidate_word(address addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static void invalidate_range(address start, int nbytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 };
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Must be included before the definition of ICacheStubGenerator
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // because ICacheStubGenerator uses ICache definitions.
a61af66fc99e Initial load
duke
parents:
diff changeset
70
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
71 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
72 # include "icache_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
73 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
74 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
75 # include "icache_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
76 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
77 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
78 # include "icache_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
79 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
80 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
81 # include "icache_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
82 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
83 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
84 # include "icache_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
85 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
86
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 class ICacheStubGenerator : public StubCodeGenerator {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 ICacheStubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Generate the icache flush stub.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 //
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Since we cannot flush the cache when this stub is generated,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // it must be generated first, and just to be sure, we do extra
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // work to allow a check that these instructions got executed.
a61af66fc99e Initial load
duke
parents:
diff changeset
98 //
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // The flush stub has three parameters (see flush_icache_stub_t).
a61af66fc99e Initial load
duke
parents:
diff changeset
100 //
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // addr - Start address, must be aligned at log2_line_size
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // lines - Number of line_size icache lines to flush
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // magic - Magic number copied to result register to make sure
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // the stub executed properly
a61af66fc99e Initial load
duke
parents:
diff changeset
105 //
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // A template for generate_icache_flush is
a61af66fc99e Initial load
duke
parents:
diff changeset
107 //
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // #define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
109 //
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // void ICacheStubGenerator::generate_icache_flush(
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // ICache::flush_icache_stub_t* flush_icache_stub
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // StubCodeMark mark(this, "ICache", "flush_icache_stub");
a61af66fc99e Initial load
duke
parents:
diff changeset
114 //
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // address start = __ pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 //
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // // emit flush stub asm code
a61af66fc99e Initial load
duke
parents:
diff changeset
118 //
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // // Must be set here so StubCodeMark destructor can call the flush stub.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // *flush_icache_stub = (ICache::flush_icache_stub_t)start;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // };
a61af66fc99e Initial load
duke
parents:
diff changeset
122 //
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // #undef __
a61af66fc99e Initial load
duke
parents:
diff changeset
124 //
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // The first use of flush_icache_stub must apply it to itself. The
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // StubCodeMark destructor in generate_icache_flush will call Assembler::flush,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // which in turn will call invalidate_range (see asm/assembler.cpp), which
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // in turn will call the flush stub *before* generate_icache_flush returns.
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // The usual method of having generate_icache_flush return the address of the
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // stub to its caller, which would then, e.g., store that address in
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // flush_icache_stub, won't work. generate_icache_flush must itself set
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // flush_icache_stub to the address of the stub it generates before
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // the StubCodeMark destructor is invoked.
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
137
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
138 #endif // SHARE_VM_RUNTIME_ICACHE_HPP