< prev index next >

src/hotspot/share/code/icBuffer.hpp


12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  *                                                                                                                                   
22  */                                                                                                                                  
23 
24 #ifndef SHARE_VM_CODE_ICBUFFER_HPP                                                                                                   
25 #define SHARE_VM_CODE_ICBUFFER_HPP                                                                                                   
26 
27 #include "asm/codeBuffer.hpp"                                                                                                        
28 #include "code/stubs.hpp"                                                                                                            
29 #include "interpreter/bytecodes.hpp"                                                                                                 
30 #include "memory/allocation.hpp"                                                                                                     
31 #include "utilities/align.hpp"                                                                                                       
                                                                                                                                     
32 
33 //                                                                                                                                   
34 // For CompiledIC's:                                                                                                                 
35 //                                                                                                                                   
36 // In cases where we do not have MT-safe state transformation,                                                                       
37 // we go to a transition state, using ICStubs. At a safepoint,                                                                       
38 // the inline caches are transferred from the transitional code:                                                                     
39 //                                                                                                                                   
40 //    instruction_address --> 01 set xxx_oop, Ginline_cache_klass                                                                    
41 //                            23 jump_to Gtemp, yyyy                                                                                 
42 //                            4  nop                                                                                                 
43 
44 class ICStub: public Stub {                                                                                                          
45  private:                                                                                                                            
46   int                 _size;       // total size of the stub incl. code                                                              
47   address             _ic_site;    // points at call instruction of owning ic-buffer                                                 
48   /* stub code follows here */                                                                                                       
49  protected:                                                                                                                          
50   friend class ICStubInterface;                                                                                                      

12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  *
22  */
23 
24 #ifndef SHARE_VM_CODE_ICBUFFER_HPP
25 #define SHARE_VM_CODE_ICBUFFER_HPP
26 
27 #include "asm/codeBuffer.hpp"
28 #include "code/stubs.hpp"
29 #include "interpreter/bytecodes.hpp"
30 #include "memory/allocation.hpp"
31 #include "utilities/align.hpp"
32 #include "utilities/macros.hpp"
33 
34 //
35 // For CompiledIC's:
36 //
37 // In cases where we do not have MT-safe state transformation,
38 // we go to a transition state, using ICStubs. At a safepoint,
39 // the inline caches are transferred from the transitional code:
40 //
41 //    instruction_address --> 01 set xxx_oop, Ginline_cache_klass
42 //                            23 jump_to Gtemp, yyyy
43 //                            4  nop
44 
45 class ICStub: public Stub {
46  private:
47   int                 _size;       // total size of the stub incl. code
48   address             _ic_site;    // points at call instruction of owning ic-buffer
49   /* stub code follows here */
50  protected:
51   friend class ICStubInterface;

82   friend ICStub* ICStub_from_destination_address(address destination_address);                                                       
83 };                                                                                                                                   
84 
85 // ICStub Creation                                                                                                                   
86 inline ICStub* ICStub_from_destination_address(address destination_address) {                                                        
87   ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment));                                     
88   #ifdef ASSERT                                                                                                                      
89   stub->verify();                                                                                                                    
90   #endif                                                                                                                             
91   return stub;                                                                                                                       
92 }                                                                                                                                    
93 
94 class InlineCacheBuffer: public AllStatic {                                                                                          
95  private:                                                                                                                            
96   // friends                                                                                                                         
97   friend class ICStub;                                                                                                               
98 
99   static int ic_stub_code_size();                                                                                                    
100 
101   static StubQueue* _buffer;                                                                                                         
102   static ICStub*    _next_stub;                                                                                                      
103 
104   static CompiledICHolder* _pending_released;                                                                                        
105   static int _pending_count;                                                                                                         
106 
107   static StubQueue* buffer()                         { return _buffer;         }                                                     
108   static void       set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }                                                     
109   static ICStub*    get_next_stub()                  { return _next_stub;      }                                                     
110 
111   static void       init_next_stub();                                                                                                
112 
113   static ICStub* new_ic_stub();                                                                                                      
114 
115                                                                                                                                      
116   // Machine-dependent implementation of ICBuffer                                                                                    
117   static void    assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);                               
118   static address ic_buffer_entry_point  (address code_begin);                                                                        
119   static void*   ic_buffer_cached_value (address code_begin);                                                                        
120 
121  public:                                                                                                                             
122 
123     // Initialization; must be called before first usage                                                                             
124   static void initialize();                                                                                                          
125 
126   // Access                                                                                                                          
127   static bool contains(address instruction_address);                                                                                 
128 
129     // removes the ICStubs after backpatching                                                                                        
130   static void update_inline_caches();                                                                                                
                                                                                                                                     
131 
132   // for debugging                                                                                                                   
133   static bool is_empty();                                                                                                            
134 
135   static void release_pending_icholders();                                                                                           
136   static void queue_for_release(CompiledICHolder* icholder);                                                                         
137   static int pending_icholder_count() { return _pending_count; }                                                                     
138 
139   // New interface                                                                                                                   
140   static void    create_transition_stub(CompiledIC *ic, void* cached_value, address entry);                                          
141   static address ic_destination_for(CompiledIC *ic);                                                                                 
142   static void*   cached_value_for(CompiledIC *ic);                                                                                   
143 };                                                                                                                                   
144 
145 #endif // SHARE_VM_CODE_ICBUFFER_HPP                                                                                                 

83   friend ICStub* ICStub_from_destination_address(address destination_address);
84 };
85 
86 // ICStub Creation
87 inline ICStub* ICStub_from_destination_address(address destination_address) {
88   ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment));
89   #ifdef ASSERT
90   stub->verify();
91   #endif
92   return stub;
93 }
94 
95 class InlineCacheBuffer: public AllStatic {
96  private:
97   // friends
98   friend class ICStub;
99 
100   static int ic_stub_code_size();
101 
102   static StubQueue* _buffer;

103 
104   static CompiledICHolder* _pending_released;
105   static int _pending_count;
106 
107   DEBUG_ONLY(static volatile int _needs_refill;)


108 
109   static StubQueue* buffer()                         { return _buffer;         }
110 
111   static ICStub* new_ic_stub();
112 

113   // Machine-dependent implementation of ICBuffer
114   static void    assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
115   static address ic_buffer_entry_point  (address code_begin);
116   static void*   ic_buffer_cached_value (address code_begin);
117 
118  public:
119 
120     // Initialization; must be called before first usage
121   static void initialize();
122 
123   // Access
124   static bool contains(address instruction_address);
125 
126     // removes the ICStubs after backpatching
127   static void update_inline_caches();
128   static void refill_ic_stubs();
129 
130   // for debugging
131   static bool is_empty();
132 
133   static void release_pending_icholders();
134   static void queue_for_release(CompiledICHolder* icholder);
135   static int pending_icholder_count() { return _pending_count; }
136 
137   // New interface
138   static bool    create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
139   static address ic_destination_for(CompiledIC *ic);
140   static void*   cached_value_for(CompiledIC *ic);
141 };
142 
143 #endif // SHARE_VM_CODE_ICBUFFER_HPP
< prev index next >