Thu, 24 May 2018 20:03:11 +0800
Increase MaxHeapSize for better performance on MIPS
1 /*
2 * Copyright (c) 1997, 2011, 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 */
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */
31 #ifndef SHARE_VM_RUNTIME_ICACHE_HPP
32 #define SHARE_VM_RUNTIME_ICACHE_HPP
34 #include "memory/allocation.hpp"
35 #include "runtime/stubCodeGenerator.hpp"
37 // Interface for updating the instruction cache. Whenever the VM modifies
38 // code, part of the processor instruction cache potentially has to be flushed.
40 // Default implementation is in icache.cpp, and can be hidden per-platform.
41 // Most platforms must provide only ICacheStubGenerator::generate_icache_flush().
42 // Platforms that don't require icache flushing can just nullify the public
43 // members of AbstractICache in their ICache class. AbstractICache should never
44 // be referenced other than by deriving the ICache class from it.
45 //
46 // The code for the ICache class and for generate_icache_flush() must be in
47 // architecture-specific files, i.e., icache_<arch>.hpp/.cpp
49 class AbstractICache : AllStatic {
50 public:
51 // The flush stub signature
52 typedef int (*flush_icache_stub_t)(address addr, int lines, int magic);
54 protected:
55 // The flush stub function address
56 static flush_icache_stub_t _flush_icache_stub;
58 // Call the flush stub
59 static void call_flush_stub(address start, int lines);
61 public:
62 enum {
63 stub_size = 0, // Size of the icache flush stub in bytes
64 line_size = 0, // Icache line size in bytes
65 log2_line_size = 0 // log2(line_size)
66 };
68 static void initialize();
69 static void invalidate_word(address addr);
70 static void invalidate_range(address start, int nbytes);
71 };
74 // Must be included before the definition of ICacheStubGenerator
75 // because ICacheStubGenerator uses ICache definitions.
77 #ifdef TARGET_ARCH_x86
78 # include "icache_x86.hpp"
79 #endif
80 #ifdef TARGET_ARCH_sparc
81 # include "icache_sparc.hpp"
82 #endif
83 #ifdef TARGET_ARCH_zero
84 # include "icache_zero.hpp"
85 #endif
86 #ifdef TARGET_ARCH_arm
87 # include "icache_arm.hpp"
88 #endif
89 #ifdef TARGET_ARCH_ppc
90 # include "icache_ppc.hpp"
91 #endif
92 #ifdef TARGET_ARCH_mips
93 # include "icache_mips.hpp"
94 #endif
97 class ICacheStubGenerator : public StubCodeGenerator {
98 public:
99 ICacheStubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
101 // Generate the icache flush stub.
102 //
103 // Since we cannot flush the cache when this stub is generated,
104 // it must be generated first, and just to be sure, we do extra
105 // work to allow a check that these instructions got executed.
106 //
107 // The flush stub has three parameters (see flush_icache_stub_t).
108 //
109 // addr - Start address, must be aligned at log2_line_size
110 // lines - Number of line_size icache lines to flush
111 // magic - Magic number copied to result register to make sure
112 // the stub executed properly
113 //
114 // A template for generate_icache_flush is
115 //
116 // #define __ _masm->
117 //
118 // void ICacheStubGenerator::generate_icache_flush(
119 // ICache::flush_icache_stub_t* flush_icache_stub
120 // ) {
121 // StubCodeMark mark(this, "ICache", "flush_icache_stub");
122 //
123 // address start = __ pc();
124 //
125 // // emit flush stub asm code
126 //
127 // // Must be set here so StubCodeMark destructor can call the flush stub.
128 // *flush_icache_stub = (ICache::flush_icache_stub_t)start;
129 // };
130 //
131 // #undef __
132 //
133 // The first use of flush_icache_stub must apply it to itself. The
134 // StubCodeMark destructor in generate_icache_flush will call Assembler::flush,
135 // which in turn will call invalidate_range (see asm/assembler.cpp), which
136 // in turn will call the flush stub *before* generate_icache_flush returns.
137 // The usual method of having generate_icache_flush return the address of the
138 // stub to its caller, which would then, e.g., store that address in
139 // flush_icache_stub, won't work. generate_icache_flush must itself set
140 // flush_icache_stub to the address of the stub it generates before
141 // the StubCodeMark destructor is invoked.
143 void generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub);
144 };
146 #endif // SHARE_VM_RUNTIME_ICACHE_HPP