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