src/share/vm/code/icBuffer.hpp

Mon, 28 Feb 2011 06:07:12 -0800

author
twisti
date
Mon, 28 Feb 2011 06:07:12 -0800
changeset 2603
1b4e6a5d98e0
parent 2314
f95d63e2154a
child 4037
da91efe96a93
permissions
-rw-r--r--

7012914: JSR 292 MethodHandlesTest C1: frame::verify_return_pc(return_address) failed: must be a return pc
Reviewed-by: never, bdelsart

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1997, 2010, 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
duke@435 60 void set_stub(CompiledIC *ic, oop 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
duke@435 73 oop cached_oop() const; // cached_oop 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
duke@435 102 static StubQueue* buffer() { return _buffer; }
duke@435 103 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
duke@435 104 static ICStub* get_next_stub() { return _next_stub; }
duke@435 105
duke@435 106 static void init_next_stub();
duke@435 107
duke@435 108 static ICStub* new_ic_stub();
duke@435 109
duke@435 110
duke@435 111 // Machine-dependent implementation of ICBuffer
duke@435 112 static void assemble_ic_buffer_code(address code_begin, oop cached_oop, address entry_point);
duke@435 113 static address ic_buffer_entry_point (address code_begin);
duke@435 114 static oop ic_buffer_cached_oop (address code_begin);
duke@435 115
duke@435 116 public:
duke@435 117
duke@435 118 // Initialization; must be called before first usage
duke@435 119 static void initialize();
duke@435 120
duke@435 121 // Access
duke@435 122 static bool contains(address instruction_address);
duke@435 123
duke@435 124 // removes the ICStubs after backpatching
duke@435 125 static void update_inline_caches();
duke@435 126
duke@435 127 // for debugging
duke@435 128 static bool is_empty();
duke@435 129
duke@435 130
duke@435 131 // New interface
duke@435 132 static void create_transition_stub(CompiledIC *ic, oop cached_oop, address entry);
duke@435 133 static address ic_destination_for(CompiledIC *ic);
duke@435 134 static oop cached_oop_for(CompiledIC *ic);
duke@435 135 };
stefank@2314 136
stefank@2314 137 #endif // SHARE_VM_CODE_ICBUFFER_HPP

mercurial