1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/code/icBuffer.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,128 @@ 1.4 +/* 1.5 + * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// 1.29 +// For CompiledIC's: 1.30 +// 1.31 +// In cases where we do not have MT-safe state transformation, 1.32 +// we go to a transition state, using ICStubs. At a safepoint, 1.33 +// the inline caches are transferred from the transitional code: 1.34 +// 1.35 +// instruction_address --> 01 set xxx_oop, Ginline_cache_klass 1.36 +// 23 jump_to Gtemp, yyyy 1.37 +// 4 nop 1.38 + 1.39 +class ICStub: public Stub { 1.40 + private: 1.41 + int _size; // total size of the stub incl. code 1.42 + address _ic_site; // points at call instruction of owning ic-buffer 1.43 + /* stub code follows here */ 1.44 + protected: 1.45 + friend class ICStubInterface; 1.46 + // This will be called only by ICStubInterface 1.47 + void initialize(int size) { _size = size; _ic_site = NULL; } 1.48 + void finalize(); // called when a method is removed 1.49 + 1.50 + // General info 1.51 + int size() const { return _size; } 1.52 + static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; } 1.53 + 1.54 + public: 1.55 + // Creation 1.56 + void set_stub(CompiledIC *ic, oop cached_value, address dest_addr); 1.57 + 1.58 + // Code info 1.59 + address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); } 1.60 + address code_end() const { return (address)this + size(); } 1.61 + 1.62 + // Call site info 1.63 + address ic_site() const { return _ic_site; } 1.64 + void clear(); 1.65 + bool is_empty() const { return _ic_site == NULL; } 1.66 + 1.67 + // stub info 1.68 + address destination() const; // destination of jump instruction 1.69 + oop cached_oop() const; // cached_oop for stub 1.70 + 1.71 + // Debugging 1.72 + void verify() PRODUCT_RETURN; 1.73 + void print() PRODUCT_RETURN; 1.74 + 1.75 + // Creation 1.76 + friend ICStub* ICStub_from_destination_address(address destination_address); 1.77 +}; 1.78 + 1.79 +// ICStub Creation 1.80 +inline ICStub* ICStub_from_destination_address(address destination_address) { 1.81 + ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment)); 1.82 + #ifdef ASSERT 1.83 + stub->verify(); 1.84 + #endif 1.85 + return stub; 1.86 +} 1.87 + 1.88 +class InlineCacheBuffer: public AllStatic { 1.89 + private: 1.90 + // friends 1.91 + friend class ICStub; 1.92 + 1.93 + static int ic_stub_code_size(); 1.94 + 1.95 + static StubQueue* _buffer; 1.96 + static ICStub* _next_stub; 1.97 + 1.98 + static StubQueue* buffer() { return _buffer; } 1.99 + static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; } 1.100 + static ICStub* get_next_stub() { return _next_stub; } 1.101 + 1.102 + static void init_next_stub(); 1.103 + 1.104 + static ICStub* new_ic_stub(); 1.105 + 1.106 + 1.107 + // Machine-dependent implementation of ICBuffer 1.108 + static void assemble_ic_buffer_code(address code_begin, oop cached_oop, address entry_point); 1.109 + static address ic_buffer_entry_point (address code_begin); 1.110 + static oop ic_buffer_cached_oop (address code_begin); 1.111 + 1.112 + public: 1.113 + 1.114 + // Initialization; must be called before first usage 1.115 + static void initialize(); 1.116 + 1.117 + // Access 1.118 + static bool contains(address instruction_address); 1.119 + 1.120 + // removes the ICStubs after backpatching 1.121 + static void update_inline_caches(); 1.122 + 1.123 + // for debugging 1.124 + static bool is_empty(); 1.125 + 1.126 + 1.127 + // New interface 1.128 + static void create_transition_stub(CompiledIC *ic, oop cached_oop, address entry); 1.129 + static address ic_destination_for(CompiledIC *ic); 1.130 + static oop cached_oop_for(CompiledIC *ic); 1.131 +};