aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "asm/macroAssembler.hpp" aoqi@0: #include "runtime/icache.hpp" aoqi@0: aoqi@0: #define __ _masm-> aoqi@0: aoqi@0: void ICacheStubGenerator::generate_icache_flush(ICache::flush_icache_stub_t* flush_icache_stub) { aoqi@0: StubCodeMark mark(this, "ICache", "flush_icache_stub"); aoqi@0: aoqi@0: address start = __ pc(); aoqi@0: #ifdef AMD64 aoqi@0: aoqi@0: const Register addr = c_rarg0; aoqi@0: const Register lines = c_rarg1; aoqi@0: const Register magic = c_rarg2; aoqi@0: aoqi@0: Label flush_line, done; aoqi@0: aoqi@0: __ testl(lines, lines); aoqi@0: __ jcc(Assembler::zero, done); aoqi@0: aoqi@0: // Force ordering wrt cflush. aoqi@0: // Other fence and sync instructions won't do the job. aoqi@0: __ mfence(); aoqi@0: aoqi@0: __ bind(flush_line); aoqi@0: __ clflush(Address(addr, 0)); aoqi@0: __ addptr(addr, ICache::line_size); aoqi@0: __ decrementl(lines); aoqi@0: __ jcc(Assembler::notZero, flush_line); aoqi@0: aoqi@0: __ mfence(); aoqi@0: aoqi@0: __ bind(done); aoqi@0: aoqi@0: #else aoqi@0: const Address magic(rsp, 3*wordSize); aoqi@0: __ lock(); __ addl(Address(rsp, 0), 0); aoqi@0: #endif // AMD64 aoqi@0: __ movptr(rax, magic); // Handshake with caller to make sure it happened! aoqi@0: __ ret(0); aoqi@0: aoqi@0: // Must be set here so StubCodeMark destructor can call the flush stub. aoqi@0: *flush_icache_stub = (ICache::flush_icache_stub_t)start; aoqi@0: } aoqi@0: aoqi@0: #undef __