src/share/vm/code/icBuffer.hpp

Tue, 15 Sep 2009 21:53:47 -0700

author
jrose
date
Tue, 15 Sep 2009 21:53:47 -0700
changeset 1424
148e5441d916
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6863023: need non-perm oops in code cache for JSR 292
Summary: Make a special root-list for those few nmethods which might contain non-perm oops.
Reviewed-by: twisti, kvn, never, jmasa, ysr

duke@435 1 /*
duke@435 2 * Copyright 1997-2003 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 //
duke@435 26 // For CompiledIC's:
duke@435 27 //
duke@435 28 // In cases where we do not have MT-safe state transformation,
duke@435 29 // we go to a transition state, using ICStubs. At a safepoint,
duke@435 30 // the inline caches are transferred from the transitional code:
duke@435 31 //
duke@435 32 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
duke@435 33 // 23 jump_to Gtemp, yyyy
duke@435 34 // 4 nop
duke@435 35
duke@435 36 class ICStub: public Stub {
duke@435 37 private:
duke@435 38 int _size; // total size of the stub incl. code
duke@435 39 address _ic_site; // points at call instruction of owning ic-buffer
duke@435 40 /* stub code follows here */
duke@435 41 protected:
duke@435 42 friend class ICStubInterface;
duke@435 43 // This will be called only by ICStubInterface
duke@435 44 void initialize(int size) { _size = size; _ic_site = NULL; }
duke@435 45 void finalize(); // called when a method is removed
duke@435 46
duke@435 47 // General info
duke@435 48 int size() const { return _size; }
duke@435 49 static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }
duke@435 50
duke@435 51 public:
duke@435 52 // Creation
duke@435 53 void set_stub(CompiledIC *ic, oop cached_value, address dest_addr);
duke@435 54
duke@435 55 // Code info
duke@435 56 address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }
duke@435 57 address code_end() const { return (address)this + size(); }
duke@435 58
duke@435 59 // Call site info
duke@435 60 address ic_site() const { return _ic_site; }
duke@435 61 void clear();
duke@435 62 bool is_empty() const { return _ic_site == NULL; }
duke@435 63
duke@435 64 // stub info
duke@435 65 address destination() const; // destination of jump instruction
duke@435 66 oop cached_oop() const; // cached_oop for stub
duke@435 67
duke@435 68 // Debugging
duke@435 69 void verify() PRODUCT_RETURN;
duke@435 70 void print() PRODUCT_RETURN;
duke@435 71
duke@435 72 // Creation
duke@435 73 friend ICStub* ICStub_from_destination_address(address destination_address);
duke@435 74 };
duke@435 75
duke@435 76 // ICStub Creation
duke@435 77 inline ICStub* ICStub_from_destination_address(address destination_address) {
duke@435 78 ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));
duke@435 79 #ifdef ASSERT
duke@435 80 stub->verify();
duke@435 81 #endif
duke@435 82 return stub;
duke@435 83 }
duke@435 84
duke@435 85 class InlineCacheBuffer: public AllStatic {
duke@435 86 private:
duke@435 87 // friends
duke@435 88 friend class ICStub;
duke@435 89
duke@435 90 static int ic_stub_code_size();
duke@435 91
duke@435 92 static StubQueue* _buffer;
duke@435 93 static ICStub* _next_stub;
duke@435 94
duke@435 95 static StubQueue* buffer() { return _buffer; }
duke@435 96 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
duke@435 97 static ICStub* get_next_stub() { return _next_stub; }
duke@435 98
duke@435 99 static void init_next_stub();
duke@435 100
duke@435 101 static ICStub* new_ic_stub();
duke@435 102
duke@435 103
duke@435 104 // Machine-dependent implementation of ICBuffer
duke@435 105 static void assemble_ic_buffer_code(address code_begin, oop cached_oop, address entry_point);
duke@435 106 static address ic_buffer_entry_point (address code_begin);
duke@435 107 static oop ic_buffer_cached_oop (address code_begin);
duke@435 108
duke@435 109 public:
duke@435 110
duke@435 111 // Initialization; must be called before first usage
duke@435 112 static void initialize();
duke@435 113
duke@435 114 // Access
duke@435 115 static bool contains(address instruction_address);
duke@435 116
duke@435 117 // removes the ICStubs after backpatching
duke@435 118 static void update_inline_caches();
duke@435 119
duke@435 120 // for debugging
duke@435 121 static bool is_empty();
duke@435 122
duke@435 123
duke@435 124 // New interface
duke@435 125 static void create_transition_stub(CompiledIC *ic, oop cached_oop, address entry);
duke@435 126 static address ic_destination_for(CompiledIC *ic);
duke@435 127 static oop cached_oop_for(CompiledIC *ic);
duke@435 128 };

mercurial