< prev index next >

src/hotspot/share/code/icBuffer.cpp


24 #include "precompiled.hpp"                                                                                                           
25 #include "code/codeCache.hpp"                                                                                                        
26 #include "code/compiledIC.hpp"                                                                                                       
27 #include "code/icBuffer.hpp"                                                                                                         
28 #include "code/nmethod.hpp"                                                                                                          
29 #include "code/scopeDesc.hpp"                                                                                                        
30 #include "gc/shared/collectedHeap.inline.hpp"                                                                                        
31 #include "interpreter/interpreter.hpp"                                                                                               
32 #include "interpreter/linkResolver.hpp"                                                                                              
33 #include "memory/resourceArea.hpp"                                                                                                   
34 #include "memory/universe.hpp"                                                                                                       
35 #include "oops/method.hpp"                                                                                                           
36 #include "oops/oop.inline.hpp"                                                                                                       
37 #include "runtime/handles.inline.hpp"                                                                                                
38 #include "runtime/mutexLocker.hpp"                                                                                                   
39 #include "runtime/stubRoutines.hpp"                                                                                                  
40 
41 DEF_STUB_INTERFACE(ICStub);                                                                                                          
42 
43 StubQueue* InlineCacheBuffer::_buffer    = NULL;                                                                                     
44 ICStub*    InlineCacheBuffer::_next_stub = NULL;                                                                                     
45 
46 CompiledICHolder* InlineCacheBuffer::_pending_released = NULL;                                                                       
47 int InlineCacheBuffer::_pending_count = 0;                                                                                           
48 
49 void ICStub::finalize() {                                                                                                            
50   if (!is_empty()) {                                                                                                                 
51     ResourceMark rm;                                                                                                                 
52     CompiledIC *ic = CompiledIC_at(CodeCache::find_compiled(ic_site()), ic_site());                                                  
53     assert(CodeCache::find_compiled(ic->instruction_address()) != NULL, "inline cache in non-compiled?");                            
54 
55     assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer");                                 
56     ic->set_ic_destination_and_value(destination(), cached_value());                                                                 
57   }                                                                                                                                  
58 }                                                                                                                                    
59 
60 
61 address ICStub::destination() const {                                                                                                
62   return InlineCacheBuffer::ic_buffer_entry_point(code_begin());                                                                     
63 }                                                                                                                                    

24 #include "precompiled.hpp"
25 #include "code/codeCache.hpp"
26 #include "code/compiledIC.hpp"
27 #include "code/icBuffer.hpp"
28 #include "code/nmethod.hpp"
29 #include "code/scopeDesc.hpp"
30 #include "gc/shared/collectedHeap.inline.hpp"
31 #include "interpreter/interpreter.hpp"
32 #include "interpreter/linkResolver.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "memory/universe.hpp"
35 #include "oops/method.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/mutexLocker.hpp"
39 #include "runtime/stubRoutines.hpp"
40 
41 DEF_STUB_INTERFACE(ICStub);
42 
43 StubQueue* InlineCacheBuffer::_buffer    = NULL;

44 
45 CompiledICHolder* InlineCacheBuffer::_pending_released = NULL;
46 int InlineCacheBuffer::_pending_count = 0;
47 
48 void ICStub::finalize() {
49   if (!is_empty()) {
50     ResourceMark rm;
51     CompiledIC *ic = CompiledIC_at(CodeCache::find_compiled(ic_site()), ic_site());
52     assert(CodeCache::find_compiled(ic->instruction_address()) != NULL, "inline cache in non-compiled?");
53 
54     assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer");
55     ic->set_ic_destination_and_value(destination(), cached_value());
56   }
57 }
58 
59 
60 address ICStub::destination() const {
61   return InlineCacheBuffer::ic_buffer_entry_point(code_begin());
62 }

85     InlineCacheBuffer::queue_for_release((CompiledICHolder*)cached_value());                                                         
86   }                                                                                                                                  
87   _ic_site = NULL;                                                                                                                   
88 }                                                                                                                                    
89 
90 
91 #ifndef PRODUCT                                                                                                                      
92 // anybody calling to this stub will trap                                                                                            
93 
94 void ICStub::verify() {                                                                                                              
95 }                                                                                                                                    
96 
97 void ICStub::print() {                                                                                                               
98   tty->print_cr("ICStub: site: " INTPTR_FORMAT, p2i(_ic_site));                                                                      
99 }                                                                                                                                    
100 #endif                                                                                                                               
101 
102 //-----------------------------------------------------------------------------------------------                                    
103 // Implementation of InlineCacheBuffer                                                                                               
104 
105 void InlineCacheBuffer::init_next_stub() {                                                                                           
106   ICStub* ic_stub = (ICStub*)buffer()->request_committed (ic_stub_code_size());                                                      
107   assert (ic_stub != NULL, "no room for a single stub");                                                                             
108   set_next_stub(ic_stub);                                                                                                            
109 }                                                                                                                                    
110                                                                                                                                      
111 
112 void InlineCacheBuffer::initialize() {                                                                                               
113   if (_buffer != NULL) return; // already initialized                                                                                
114   _buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer");                                   
115   assert (_buffer != NULL, "cannot allocate InlineCacheBuffer");                                                                     
116 }                                                                                                                                    
117 
118 
119 ICStub* InlineCacheBuffer::new_ic_stub() {                                                                                           
120   return (ICStub*)buffer()->request_committed(ic_stub_code_size());                                                                  
121 }                                                                                                                                    
122 
123 
124 void InlineCacheBuffer::refill_ic_stubs() {                                                                                          
125   // we ran out of inline cache buffer space; must enter safepoint.                                                                  
126   // We do this by forcing a safepoint                                                                                               
127   EXCEPTION_MARK;                                                                                                                    
128 
129   VM_ICBufferFull ibf;                                                                                                               

84     InlineCacheBuffer::queue_for_release((CompiledICHolder*)cached_value());
85   }
86   _ic_site = NULL;
87 }
88 
89 
90 #ifndef PRODUCT
91 // anybody calling to this stub will trap
92 
93 void ICStub::verify() {
94 }
95 
96 void ICStub::print() {
97   tty->print_cr("ICStub: site: " INTPTR_FORMAT, p2i(_ic_site));
98 }
99 #endif
100 
101 //-----------------------------------------------------------------------------------------------
102 // Implementation of InlineCacheBuffer
103 






104 
105 void InlineCacheBuffer::initialize() {
106   if (_buffer != NULL) return; // already initialized
107   _buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer");
108   assert (_buffer != NULL, "cannot allocate InlineCacheBuffer");
109 }
110 
111 
112 ICStub* InlineCacheBuffer::new_ic_stub() {
113   return (ICStub*)buffer()->request_committed(ic_stub_code_size());
114 }
115 
116 
117 void InlineCacheBuffer::refill_ic_stubs() {
118   // we ran out of inline cache buffer space; must enter safepoint.
119   // We do this by forcing a safepoint
120   EXCEPTION_MARK;
121 
122   VM_ICBufferFull ibf;

138 }                                                                                                                                    
139 
140 
141 void InlineCacheBuffer::update_inline_caches() {                                                                                     
142   if (buffer()->number_of_stubs() > 0) {                                                                                             
143     if (TraceICBuffer) {                                                                                                             
144       tty->print_cr("[updating inline caches with %d stubs]", buffer()->number_of_stubs());                                          
145     }                                                                                                                                
146     buffer()->remove_all();                                                                                                          
147   }                                                                                                                                  
148   release_pending_icholders();                                                                                                       
149 }                                                                                                                                    
150 
151 
152 bool InlineCacheBuffer::contains(address instruction_address) {                                                                      
153   return buffer()->contains(instruction_address);                                                                                    
154 }                                                                                                                                    
155 
156 
157 bool InlineCacheBuffer::is_empty() {                                                                                                 
158   return buffer()->number_of_stubs() == 0;    // always has sentinel                                                                 
159 }                                                                                                                                    
160 
161 
162 void InlineCacheBuffer_init() {                                                                                                      
163   InlineCacheBuffer::initialize();                                                                                                   
164 }                                                                                                                                    
165 
166 
167 bool InlineCacheBuffer::create_transition_stub(CompiledIC *ic, void* cached_value, address entry) {                                  
168   assert(!SafepointSynchronize::is_at_safepoint(), "should not be called during a safepoint");                                       
169   assert(CompiledICLocker::is_safe(ic->instruction_address()), "mt unsafe call");                                                    
170   if (TraceICBuffer) {                                                                                                               
171     tty->print_cr("  create transition stub for " INTPTR_FORMAT " destination " INTPTR_FORMAT " cached value " INTPTR_FORMAT,        
172                   p2i(ic->instruction_address()), p2i(entry), p2i(cached_value));                                                    
173   }                                                                                                                                  
174 
175   // allocate and initialize new "out-of-line" inline-cache                                                                          
176   ICStub* ic_stub = new_ic_stub();                                                                                                   
177   if (ic_stub == NULL) {                                                                                                             

131 }
132 
133 
134 void InlineCacheBuffer::update_inline_caches() {
135   if (buffer()->number_of_stubs() > 0) {
136     if (TraceICBuffer) {
137       tty->print_cr("[updating inline caches with %d stubs]", buffer()->number_of_stubs());
138     }
139     buffer()->remove_all();
140   }
141   release_pending_icholders();
142 }
143 
144 
145 bool InlineCacheBuffer::contains(address instruction_address) {
146   return buffer()->contains(instruction_address);
147 }
148 
149 
150 bool InlineCacheBuffer::is_empty() {
151   return buffer()->number_of_stubs() == 0;
152 }
153 
154 
155 void InlineCacheBuffer_init() {
156   InlineCacheBuffer::initialize();
157 }
158 
159 
160 bool InlineCacheBuffer::create_transition_stub(CompiledIC *ic, void* cached_value, address entry) {
161   assert(!SafepointSynchronize::is_at_safepoint(), "should not be called during a safepoint");
162   assert(CompiledICLocker::is_safe(ic->instruction_address()), "mt unsafe call");
163   if (TraceICBuffer) {
164     tty->print_cr("  create transition stub for " INTPTR_FORMAT " destination " INTPTR_FORMAT " cached value " INTPTR_FORMAT,
165                   p2i(ic->instruction_address()), p2i(entry), p2i(cached_value));
166   }
167 
168   // allocate and initialize new "out-of-line" inline-cache
169   ICStub* ic_stub = new_ic_stub();
170   if (ic_stub == NULL) {
< prev index next >