1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/code/icBuffer.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,145 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_CODE_ICBUFFER_HPP 1.29 +#define SHARE_VM_CODE_ICBUFFER_HPP 1.30 + 1.31 +#include "asm/codeBuffer.hpp" 1.32 +#include "code/stubs.hpp" 1.33 +#include "interpreter/bytecodes.hpp" 1.34 +#include "memory/allocation.hpp" 1.35 + 1.36 +// 1.37 +// For CompiledIC's: 1.38 +// 1.39 +// In cases where we do not have MT-safe state transformation, 1.40 +// we go to a transition state, using ICStubs. At a safepoint, 1.41 +// the inline caches are transferred from the transitional code: 1.42 +// 1.43 +// instruction_address --> 01 set xxx_oop, Ginline_cache_klass 1.44 +// 23 jump_to Gtemp, yyyy 1.45 +// 4 nop 1.46 + 1.47 +class ICStub: public Stub { 1.48 + private: 1.49 + int _size; // total size of the stub incl. code 1.50 + address _ic_site; // points at call instruction of owning ic-buffer 1.51 + /* stub code follows here */ 1.52 + protected: 1.53 + friend class ICStubInterface; 1.54 + // This will be called only by ICStubInterface 1.55 + void initialize(int size, 1.56 + CodeStrings strings) { _size = size; _ic_site = NULL; } 1.57 + void finalize(); // called when a method is removed 1.58 + 1.59 + // General info 1.60 + int size() const { return _size; } 1.61 + static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; } 1.62 + 1.63 + public: 1.64 + // Creation 1.65 + void set_stub(CompiledIC *ic, void* cached_value, address dest_addr); 1.66 + 1.67 + // Code info 1.68 + address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); } 1.69 + address code_end() const { return (address)this + size(); } 1.70 + 1.71 + // Call site info 1.72 + address ic_site() const { return _ic_site; } 1.73 + void clear(); 1.74 + bool is_empty() const { return _ic_site == NULL; } 1.75 + 1.76 + // stub info 1.77 + address destination() const; // destination of jump instruction 1.78 + void* cached_value() const; // cached_value for stub 1.79 + 1.80 + // Debugging 1.81 + void verify() PRODUCT_RETURN; 1.82 + void print() PRODUCT_RETURN; 1.83 + 1.84 + // Creation 1.85 + friend ICStub* ICStub_from_destination_address(address destination_address); 1.86 +}; 1.87 + 1.88 +// ICStub Creation 1.89 +inline ICStub* ICStub_from_destination_address(address destination_address) { 1.90 + ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment)); 1.91 + #ifdef ASSERT 1.92 + stub->verify(); 1.93 + #endif 1.94 + return stub; 1.95 +} 1.96 + 1.97 +class InlineCacheBuffer: public AllStatic { 1.98 + private: 1.99 + // friends 1.100 + friend class ICStub; 1.101 + 1.102 + static int ic_stub_code_size(); 1.103 + 1.104 + static StubQueue* _buffer; 1.105 + static ICStub* _next_stub; 1.106 + 1.107 + static CompiledICHolder* _pending_released; 1.108 + static int _pending_count; 1.109 + 1.110 + static StubQueue* buffer() { return _buffer; } 1.111 + static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; } 1.112 + static ICStub* get_next_stub() { return _next_stub; } 1.113 + 1.114 + static void init_next_stub(); 1.115 + 1.116 + static ICStub* new_ic_stub(); 1.117 + 1.118 + 1.119 + // Machine-dependent implementation of ICBuffer 1.120 + static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point); 1.121 + static address ic_buffer_entry_point (address code_begin); 1.122 + static void* ic_buffer_cached_value (address code_begin); 1.123 + 1.124 + public: 1.125 + 1.126 + // Initialization; must be called before first usage 1.127 + static void initialize(); 1.128 + 1.129 + // Access 1.130 + static bool contains(address instruction_address); 1.131 + 1.132 + // removes the ICStubs after backpatching 1.133 + static void update_inline_caches(); 1.134 + 1.135 + // for debugging 1.136 + static bool is_empty(); 1.137 + 1.138 + static void release_pending_icholders(); 1.139 + static void queue_for_release(CompiledICHolder* icholder); 1.140 + static int pending_icholder_count() { return _pending_count; } 1.141 + 1.142 + // New interface 1.143 + static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry); 1.144 + static address ic_destination_for(CompiledIC *ic); 1.145 + static void* cached_value_for(CompiledIC *ic); 1.146 +}; 1.147 + 1.148 +#endif // SHARE_VM_CODE_ICBUFFER_HPP