src/cpu/x86/vm/icache_x86.cpp

Mon, 13 Feb 2012 02:29:22 -0800

author
twisti
date
Mon, 13 Feb 2012 02:29:22 -0800
changeset 3566
45a1bf98f1bb
parent 2314
f95d63e2154a
child 4318
cd3d6a6b95d9
permissions
-rw-r--r--

7141329: Strange values of stack_size in -XX:+TraceMethodHandles output
Reviewed-by: kvn, never

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "assembler_x86.inline.hpp"
stefank@2314 27 #include "runtime/icache.hpp"
duke@435 28
duke@435 29 #define __ _masm->
duke@435 30
duke@435 31 void ICacheStubGenerator::generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub) {
duke@435 32 StubCodeMark mark(this, "ICache", "flush_icache_stub");
duke@435 33
duke@435 34 address start = __ pc();
duke@435 35 #ifdef AMD64
duke@435 36
duke@435 37 const Register addr = c_rarg0;
duke@435 38 const Register lines = c_rarg1;
duke@435 39 const Register magic = c_rarg2;
duke@435 40
duke@435 41 Label flush_line, done;
duke@435 42
duke@435 43 __ testl(lines, lines);
duke@435 44 __ jcc(Assembler::zero, done);
duke@435 45
duke@435 46 // Force ordering wrt cflush.
duke@435 47 // Other fence and sync instructions won't do the job.
duke@435 48 __ mfence();
duke@435 49
duke@435 50 __ bind(flush_line);
duke@435 51 __ clflush(Address(addr, 0));
never@739 52 __ addptr(addr, ICache::line_size);
duke@435 53 __ decrementl(lines);
duke@435 54 __ jcc(Assembler::notZero, flush_line);
duke@435 55
duke@435 56 __ mfence();
duke@435 57
duke@435 58 __ bind(done);
duke@435 59
duke@435 60 #else
duke@435 61 const Address magic(rsp, 3*wordSize);
duke@435 62 __ lock(); __ addl(Address(rsp, 0), 0);
duke@435 63 #endif // AMD64
never@739 64 __ movptr(rax, magic); // Handshake with caller to make sure it happened!
duke@435 65 __ ret(0);
duke@435 66
duke@435 67 // Must be set here so StubCodeMark destructor can call the flush stub.
duke@435 68 *flush_icache_stub = (ICache::flush_icache_stub_t)start;
duke@435 69 }
duke@435 70
duke@435 71 #undef __

mercurial