src/share/vm/code/icBuffer.hpp

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 2314
f95d63e2154a
child 4107
b31471cdc53e
permissions
-rw-r--r--

6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>

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

mercurial