src/share/vm/runtime/icache.hpp

Tue, 11 May 2010 14:35:43 -0700

author
prr
date
Tue, 11 May 2010 14:35:43 -0700
changeset 1840
fb57d4cf76c2
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6931180: Migration to recent versions of MS Platform SDK
6951582: Build problems on win64
Summary: Changes to enable building JDK7 with Microsoft Visual Studio 2010
Reviewed-by: ohair, art, ccheung, dcubed

duke@435 1 /*
duke@435 2 * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // Interface for updating the instruction cache. Whenever the VM modifies
duke@435 26 // code, part of the processor instruction cache potentially has to be flushed.
duke@435 27
duke@435 28 // Default implementation is in icache.cpp, and can be hidden per-platform.
duke@435 29 // Most platforms must provide only ICacheStubGenerator::generate_icache_flush().
duke@435 30 // Platforms that don't require icache flushing can just nullify the public
duke@435 31 // members of AbstractICache in their ICache class. AbstractICache should never
duke@435 32 // be referenced other than by deriving the ICache class from it.
duke@435 33 //
duke@435 34 // The code for the ICache class and for generate_icache_flush() must be in
duke@435 35 // architecture-specific files, i.e., icache_<arch>.hpp/.cpp
duke@435 36
duke@435 37 class AbstractICache : AllStatic {
duke@435 38 public:
duke@435 39 // The flush stub signature
duke@435 40 typedef int (*flush_icache_stub_t)(address addr, int lines, int magic);
duke@435 41
duke@435 42 protected:
duke@435 43 // The flush stub function address
duke@435 44 static flush_icache_stub_t _flush_icache_stub;
duke@435 45
duke@435 46 // Call the flush stub
duke@435 47 static void call_flush_stub(address start, int lines);
duke@435 48
duke@435 49 public:
duke@435 50 enum {
duke@435 51 stub_size = 0, // Size of the icache flush stub in bytes
duke@435 52 line_size = 0, // Icache line size in bytes
duke@435 53 log2_line_size = 0 // log2(line_size)
duke@435 54 };
duke@435 55
duke@435 56 static void initialize();
duke@435 57 static void invalidate_word(address addr);
duke@435 58 static void invalidate_range(address start, int nbytes);
duke@435 59 };
duke@435 60
duke@435 61
duke@435 62 // Must be included before the definition of ICacheStubGenerator
duke@435 63 // because ICacheStubGenerator uses ICache definitions.
duke@435 64
duke@435 65 #include "incls/_icache_pd.hpp.incl"
duke@435 66
duke@435 67
duke@435 68 class ICacheStubGenerator : public StubCodeGenerator {
duke@435 69 public:
duke@435 70 ICacheStubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
duke@435 71
duke@435 72 // Generate the icache flush stub.
duke@435 73 //
duke@435 74 // Since we cannot flush the cache when this stub is generated,
duke@435 75 // it must be generated first, and just to be sure, we do extra
duke@435 76 // work to allow a check that these instructions got executed.
duke@435 77 //
duke@435 78 // The flush stub has three parameters (see flush_icache_stub_t).
duke@435 79 //
duke@435 80 // addr - Start address, must be aligned at log2_line_size
duke@435 81 // lines - Number of line_size icache lines to flush
duke@435 82 // magic - Magic number copied to result register to make sure
duke@435 83 // the stub executed properly
duke@435 84 //
duke@435 85 // A template for generate_icache_flush is
duke@435 86 //
duke@435 87 // #define __ _masm->
duke@435 88 //
duke@435 89 // void ICacheStubGenerator::generate_icache_flush(
duke@435 90 // ICache::flush_icache_stub_t* flush_icache_stub
duke@435 91 // ) {
duke@435 92 // StubCodeMark mark(this, "ICache", "flush_icache_stub");
duke@435 93 //
duke@435 94 // address start = __ pc();
duke@435 95 //
duke@435 96 // // emit flush stub asm code
duke@435 97 //
duke@435 98 // // Must be set here so StubCodeMark destructor can call the flush stub.
duke@435 99 // *flush_icache_stub = (ICache::flush_icache_stub_t)start;
duke@435 100 // };
duke@435 101 //
duke@435 102 // #undef __
duke@435 103 //
duke@435 104 // The first use of flush_icache_stub must apply it to itself. The
duke@435 105 // StubCodeMark destructor in generate_icache_flush will call Assembler::flush,
duke@435 106 // which in turn will call invalidate_range (see asm/assembler.cpp), which
duke@435 107 // in turn will call the flush stub *before* generate_icache_flush returns.
duke@435 108 // The usual method of having generate_icache_flush return the address of the
duke@435 109 // stub to its caller, which would then, e.g., store that address in
duke@435 110 // flush_icache_stub, won't work. generate_icache_flush must itself set
duke@435 111 // flush_icache_stub to the address of the stub it generates before
duke@435 112 // the StubCodeMark destructor is invoked.
duke@435 113
duke@435 114 void generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub);
duke@435 115 };

mercurial