36 #include "utilities/vmError.hpp" |
36 #include "utilities/vmError.hpp" |
37 #ifdef COMPILER2 |
37 #ifdef COMPILER2 |
38 #include "opto/runtime.hpp" |
38 #include "opto/runtime.hpp" |
39 #endif |
39 #endif |
40 |
40 |
|
41 UnsafeCopyMemory* UnsafeCopyMemory::_table = NULL; |
|
42 int UnsafeCopyMemory::_table_length = 0; |
|
43 int UnsafeCopyMemory::_table_max_length = 0; |
|
44 address UnsafeCopyMemory::_common_exit_stub_pc = NULL; |
41 |
45 |
42 // Implementation of StubRoutines - for a description |
46 // Implementation of StubRoutines - for a description |
43 // of how to extend it, see the header file. |
47 // of how to extend it, see the header file. |
44 |
48 |
45 // Class Variables |
49 // Class Variables |
111 address StubRoutines::_checkcast_arraycopy = NULL; |
115 address StubRoutines::_checkcast_arraycopy = NULL; |
112 address StubRoutines::_checkcast_arraycopy_uninit = NULL; |
116 address StubRoutines::_checkcast_arraycopy_uninit = NULL; |
113 address StubRoutines::_unsafe_arraycopy = NULL; |
117 address StubRoutines::_unsafe_arraycopy = NULL; |
114 address StubRoutines::_generic_arraycopy = NULL; |
118 address StubRoutines::_generic_arraycopy = NULL; |
115 |
119 |
116 |
|
117 address StubRoutines::_jbyte_fill; |
120 address StubRoutines::_jbyte_fill; |
118 address StubRoutines::_jshort_fill; |
121 address StubRoutines::_jshort_fill; |
119 address StubRoutines::_jint_fill; |
122 address StubRoutines::_jint_fill; |
120 address StubRoutines::_arrayof_jbyte_fill; |
123 address StubRoutines::_arrayof_jbyte_fill; |
121 address StubRoutines::_arrayof_jshort_fill; |
124 address StubRoutines::_arrayof_jshort_fill; |
174 // Note: to break cycle with universe initialization, stubs are generated in two phases. |
177 // Note: to break cycle with universe initialization, stubs are generated in two phases. |
175 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry). |
178 // The first one generates stubs needed during universe init (e.g., _handle_must_compile_first_entry). |
176 // The second phase includes all other stubs (which may depend on universe being initialized.) |
179 // The second phase includes all other stubs (which may depend on universe being initialized.) |
177 |
180 |
178 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators |
181 extern void StubGenerator_generate(CodeBuffer* code, bool all); // only interface to generators |
|
182 |
|
183 void UnsafeCopyMemory::create_table(int max_size) { |
|
184 UnsafeCopyMemory::_table = new UnsafeCopyMemory[max_size]; |
|
185 UnsafeCopyMemory::_table_max_length = max_size; |
|
186 } |
|
187 |
|
188 bool UnsafeCopyMemory::contains_pc(address pc) { |
|
189 for (int i = 0; i < UnsafeCopyMemory::_table_length; i++) { |
|
190 UnsafeCopyMemory* entry = &UnsafeCopyMemory::_table[i]; |
|
191 if (pc >= entry->start_pc() && pc < entry->end_pc()) { |
|
192 return true; |
|
193 } |
|
194 } |
|
195 return false; |
|
196 } |
|
197 |
|
198 address UnsafeCopyMemory::page_error_continue_pc(address pc) { |
|
199 for (int i = 0; i < UnsafeCopyMemory::_table_length; i++) { |
|
200 UnsafeCopyMemory* entry = &UnsafeCopyMemory::_table[i]; |
|
201 if (pc >= entry->start_pc() && pc < entry->end_pc()) { |
|
202 return entry->error_exit_pc(); |
|
203 } |
|
204 } |
|
205 return NULL; |
|
206 } |
179 |
207 |
180 void StubRoutines::initialize1() { |
208 void StubRoutines::initialize1() { |
181 if (_code1 == NULL) { |
209 if (_code1 == NULL) { |
182 ResourceMark rm; |
210 ResourceMark rm; |
183 TraceTime timer("StubRoutines generation 1", TRACETIME_LOG(Info, startuptime)); |
211 TraceTime timer("StubRoutines generation 1", TRACETIME_LOG(Info, startuptime)); |
567 } |
595 } |
568 |
596 |
569 #undef RETURN_STUB |
597 #undef RETURN_STUB |
570 #undef RETURN_STUB_PARM |
598 #undef RETURN_STUB_PARM |
571 } |
599 } |
|
600 |
|
601 UnsafeCopyMemoryMark::UnsafeCopyMemoryMark(StubCodeGenerator* cgen, bool add_entry, bool continue_at_scope_end, address error_exit_pc) { |
|
602 _cgen = cgen; |
|
603 _ucm_entry = NULL; |
|
604 if (add_entry) { |
|
605 address err_exit_pc = NULL; |
|
606 if (!continue_at_scope_end) { |
|
607 err_exit_pc = error_exit_pc != NULL ? error_exit_pc : UnsafeCopyMemory::common_exit_stub_pc(); |
|
608 } |
|
609 assert(err_exit_pc != NULL || continue_at_scope_end, "error exit not set"); |
|
610 _ucm_entry = UnsafeCopyMemory::add_to_table(_cgen->assembler()->pc(), NULL, err_exit_pc); |
|
611 } |
|
612 } |
|
613 |
|
614 UnsafeCopyMemoryMark::~UnsafeCopyMemoryMark() { |
|
615 if (_ucm_entry != NULL) { |
|
616 _ucm_entry->set_end_pc(_cgen->assembler()->pc()); |
|
617 if (_ucm_entry->error_exit_pc() == NULL) { |
|
618 _ucm_entry->set_error_exit_pc(_cgen->assembler()->pc()); |
|
619 } |
|
620 } |
|
621 } |