1 /*
2 * Copyright (c) 1997, 2010, 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 *
679
680 // UseBiasedLocking support
681 ByteSize native_receiver_sp_offset() {
682 return _native_receiver_sp_offset;
683 }
684 ByteSize native_basic_lock_sp_offset() {
685 return _native_basic_lock_sp_offset;
686 }
687
688 // support for code generation
689 static int verified_entry_point_offset() { return offset_of(nmethod, _verified_entry_point); }
690 static int osr_entry_point_offset() { return offset_of(nmethod, _osr_entry_point); }
691 static int entry_bci_offset() { return offset_of(nmethod, _entry_bci); }
692
693 };
694
695 // Locks an nmethod so its code will not get removed, even if it is a zombie/not_entrant method
696 class nmethodLocker : public StackObj {
697 nmethod* _nm;
698
699 static void lock_nmethod(nmethod* nm); // note: nm can be NULL
700 static void unlock_nmethod(nmethod* nm); // (ditto)
701
702 public:
703 nmethodLocker(address pc); // derive nm from pc
704 nmethodLocker(nmethod *nm) { _nm = nm; lock_nmethod(_nm); }
705 nmethodLocker() { _nm = NULL; }
706 ~nmethodLocker() { unlock_nmethod(_nm); }
707
708 nmethod* code() { return _nm; }
709 void set_code(nmethod* new_nm) {
710 unlock_nmethod(_nm); // note: This works even if _nm==new_nm.
711 _nm = new_nm;
712 lock_nmethod(_nm);
713 }
714 };
715
716 #endif // SHARE_VM_CODE_NMETHOD_HPP
|
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 *
679
680 // UseBiasedLocking support
681 ByteSize native_receiver_sp_offset() {
682 return _native_receiver_sp_offset;
683 }
684 ByteSize native_basic_lock_sp_offset() {
685 return _native_basic_lock_sp_offset;
686 }
687
688 // support for code generation
689 static int verified_entry_point_offset() { return offset_of(nmethod, _verified_entry_point); }
690 static int osr_entry_point_offset() { return offset_of(nmethod, _osr_entry_point); }
691 static int entry_bci_offset() { return offset_of(nmethod, _entry_bci); }
692
693 };
694
695 // Locks an nmethod so its code will not get removed, even if it is a zombie/not_entrant method
696 class nmethodLocker : public StackObj {
697 nmethod* _nm;
698
699 public:
700
701 static void lock_nmethod(nmethod* nm); // note: nm can be NULL
702 static void unlock_nmethod(nmethod* nm); // (ditto)
703
704 nmethodLocker(address pc); // derive nm from pc
705 nmethodLocker(nmethod *nm) { _nm = nm; lock_nmethod(_nm); }
706 nmethodLocker() { _nm = NULL; }
707 ~nmethodLocker() { unlock_nmethod(_nm); }
708
709 nmethod* code() { return _nm; }
710 void set_code(nmethod* new_nm) {
711 unlock_nmethod(_nm); // note: This works even if _nm==new_nm.
712 _nm = new_nm;
713 lock_nmethod(_nm);
714 }
715 };
716
717 #endif // SHARE_VM_CODE_NMETHOD_HPP
|