Mercurial > hg > truffle
comparison src/share/vm/runtime/sharedRuntime.cpp @ 1930:2d26b0046e0d
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 30 Nov 2010 14:53:30 +0100 |
parents | f8ab19e5acae 3dc12ef8735e |
children | 8d88c9ac9247 |
comparison
equal
deleted
inserted
replaced
1484:6b7001391c97 | 1930:2d26b0046e0d |
---|---|
1 /* | 1 /* |
2 * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License version | 15 * You should have received a copy of the GNU General Public License version |
16 * 2 along with this work; if not, write to the Free Software Foundation, | 16 * 2 along with this work; if not, write to the Free Software Foundation, |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 * | 18 * |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | 20 * or visit www.oracle.com if you need additional information or have any |
21 * have any questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "incls/_precompiled.incl" | 25 #include "incls/_precompiled.incl" |
26 #include "incls/_sharedRuntime.cpp.incl" | 26 #include "incls/_sharedRuntime.cpp.incl" |
189 } | 189 } |
190 #endif | 190 #endif |
191 return ((jdouble)fmod((double)x,(double)y)); | 191 return ((jdouble)fmod((double)x,(double)y)); |
192 JRT_END | 192 JRT_END |
193 | 193 |
194 #ifdef __SOFTFP__ | |
195 JRT_LEAF(jfloat, SharedRuntime::fadd(jfloat x, jfloat y)) | |
196 return x + y; | |
197 JRT_END | |
198 | |
199 JRT_LEAF(jfloat, SharedRuntime::fsub(jfloat x, jfloat y)) | |
200 return x - y; | |
201 JRT_END | |
202 | |
203 JRT_LEAF(jfloat, SharedRuntime::fmul(jfloat x, jfloat y)) | |
204 return x * y; | |
205 JRT_END | |
206 | |
207 JRT_LEAF(jfloat, SharedRuntime::fdiv(jfloat x, jfloat y)) | |
208 return x / y; | |
209 JRT_END | |
210 | |
211 JRT_LEAF(jdouble, SharedRuntime::dadd(jdouble x, jdouble y)) | |
212 return x + y; | |
213 JRT_END | |
214 | |
215 JRT_LEAF(jdouble, SharedRuntime::dsub(jdouble x, jdouble y)) | |
216 return x - y; | |
217 JRT_END | |
218 | |
219 JRT_LEAF(jdouble, SharedRuntime::dmul(jdouble x, jdouble y)) | |
220 return x * y; | |
221 JRT_END | |
222 | |
223 JRT_LEAF(jdouble, SharedRuntime::ddiv(jdouble x, jdouble y)) | |
224 return x / y; | |
225 JRT_END | |
226 | |
227 JRT_LEAF(jfloat, SharedRuntime::i2f(jint x)) | |
228 return (jfloat)x; | |
229 JRT_END | |
230 | |
231 JRT_LEAF(jdouble, SharedRuntime::i2d(jint x)) | |
232 return (jdouble)x; | |
233 JRT_END | |
234 | |
235 JRT_LEAF(jdouble, SharedRuntime::f2d(jfloat x)) | |
236 return (jdouble)x; | |
237 JRT_END | |
238 | |
239 JRT_LEAF(int, SharedRuntime::fcmpl(float x, float y)) | |
240 return x>y ? 1 : (x==y ? 0 : -1); /* x<y or is_nan*/ | |
241 JRT_END | |
242 | |
243 JRT_LEAF(int, SharedRuntime::fcmpg(float x, float y)) | |
244 return x<y ? -1 : (x==y ? 0 : 1); /* x>y or is_nan */ | |
245 JRT_END | |
246 | |
247 JRT_LEAF(int, SharedRuntime::dcmpl(double x, double y)) | |
248 return x>y ? 1 : (x==y ? 0 : -1); /* x<y or is_nan */ | |
249 JRT_END | |
250 | |
251 JRT_LEAF(int, SharedRuntime::dcmpg(double x, double y)) | |
252 return x<y ? -1 : (x==y ? 0 : 1); /* x>y or is_nan */ | |
253 JRT_END | |
254 | |
255 // Functions to return the opposite of the aeabi functions for nan. | |
256 JRT_LEAF(int, SharedRuntime::unordered_fcmplt(float x, float y)) | |
257 return (x < y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
258 JRT_END | |
259 | |
260 JRT_LEAF(int, SharedRuntime::unordered_dcmplt(double x, double y)) | |
261 return (x < y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
262 JRT_END | |
263 | |
264 JRT_LEAF(int, SharedRuntime::unordered_fcmple(float x, float y)) | |
265 return (x <= y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
266 JRT_END | |
267 | |
268 JRT_LEAF(int, SharedRuntime::unordered_dcmple(double x, double y)) | |
269 return (x <= y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
270 JRT_END | |
271 | |
272 JRT_LEAF(int, SharedRuntime::unordered_fcmpge(float x, float y)) | |
273 return (x >= y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
274 JRT_END | |
275 | |
276 JRT_LEAF(int, SharedRuntime::unordered_dcmpge(double x, double y)) | |
277 return (x >= y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
278 JRT_END | |
279 | |
280 JRT_LEAF(int, SharedRuntime::unordered_fcmpgt(float x, float y)) | |
281 return (x > y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
282 JRT_END | |
283 | |
284 JRT_LEAF(int, SharedRuntime::unordered_dcmpgt(double x, double y)) | |
285 return (x > y) ? 1 : ((g_isnan(x) || g_isnan(y)) ? 1 : 0); | |
286 JRT_END | |
287 | |
288 // Intrinsics make gcc generate code for these. | |
289 float SharedRuntime::fneg(float f) { | |
290 return -f; | |
291 } | |
292 | |
293 double SharedRuntime::dneg(double f) { | |
294 return -f; | |
295 } | |
296 | |
297 #endif // __SOFTFP__ | |
298 | |
299 #if defined(__SOFTFP__) || defined(E500V2) | |
300 // Intrinsics make gcc generate code for these. | |
301 double SharedRuntime::dabs(double f) { | |
302 return (f <= (double)0.0) ? (double)0.0 - f : f; | |
303 } | |
304 | |
305 #endif | |
306 | |
307 #if defined(__SOFTFP__) || defined(PPC) | |
308 double SharedRuntime::dsqrt(double f) { | |
309 return sqrt(f); | |
310 } | |
311 #endif | |
194 | 312 |
195 JRT_LEAF(jint, SharedRuntime::f2i(jfloat x)) | 313 JRT_LEAF(jint, SharedRuntime::f2i(jfloat x)) |
196 if (g_isnan(x)) | 314 if (g_isnan(x)) |
197 return 0; | 315 return 0; |
198 if (x >= (jfloat) max_jint) | 316 if (x >= (jfloat) max_jint) |
338 | 456 |
339 bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc); | 457 bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc); |
340 if (at_poll_return) { | 458 if (at_poll_return) { |
341 assert(SharedRuntime::polling_page_return_handler_blob() != NULL, | 459 assert(SharedRuntime::polling_page_return_handler_blob() != NULL, |
342 "polling page return stub not created yet"); | 460 "polling page return stub not created yet"); |
343 stub = SharedRuntime::polling_page_return_handler_blob()->instructions_begin(); | 461 stub = SharedRuntime::polling_page_return_handler_blob()->entry_point(); |
344 } else { | 462 } else { |
345 assert(SharedRuntime::polling_page_safepoint_handler_blob() != NULL, | 463 assert(SharedRuntime::polling_page_safepoint_handler_blob() != NULL, |
346 "polling page safepoint stub not created yet"); | 464 "polling page safepoint stub not created yet"); |
347 stub = SharedRuntime::polling_page_safepoint_handler_blob()->instructions_begin(); | 465 stub = SharedRuntime::polling_page_safepoint_handler_blob()->entry_point(); |
348 } | 466 } |
349 #ifndef PRODUCT | 467 #ifndef PRODUCT |
350 if( TraceSafepoint ) { | 468 if( TraceSafepoint ) { |
351 char buf[256]; | 469 char buf[256]; |
352 jio_snprintf(buf, sizeof(buf), | 470 jio_snprintf(buf, sizeof(buf), |
457 } | 575 } |
458 } while (!top_frame_only && handler_bci < 0 && sd != NULL); | 576 } while (!top_frame_only && handler_bci < 0 && sd != NULL); |
459 } | 577 } |
460 | 578 |
461 // found handling method => lookup exception handler | 579 // found handling method => lookup exception handler |
462 int catch_pco = ret_pc - nm->instructions_begin(); | 580 int catch_pco = ret_pc - nm->code_begin(); |
463 | 581 |
464 ExceptionHandlerTable table(nm); | 582 ExceptionHandlerTable table(nm); |
465 HandlerTableEntry *t = table.entry_for(catch_pco, handler_bci, scope_depth); | 583 HandlerTableEntry *t = table.entry_for(catch_pco, handler_bci, scope_depth); |
466 if (t == NULL && (nm->is_compiled_by_c1() || handler_bci != -1)) { | 584 if (t == NULL && (nm->is_compiled_by_c1() || handler_bci != -1)) { |
467 // Allow abbreviated catch tables. The idea is to allow a method | 585 // Allow abbreviated catch tables. The idea is to allow a method |
490 nm->print_code(); | 608 nm->print_code(); |
491 guarantee(false, "missing exception handler"); | 609 guarantee(false, "missing exception handler"); |
492 return NULL; | 610 return NULL; |
493 } | 611 } |
494 | 612 |
495 return nm->instructions_begin() + t->pco(); | 613 return nm->code_begin() + t->pco(); |
496 } | 614 } |
497 | 615 |
498 JRT_ENTRY(void, SharedRuntime::throw_AbstractMethodError(JavaThread* thread)) | 616 JRT_ENTRY(void, SharedRuntime::throw_AbstractMethodError(JavaThread* thread)) |
499 // These errors occur only at call sites | 617 // These errors occur only at call sites |
500 throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_AbstractMethodError()); | 618 throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_AbstractMethodError()); |
785 methodHandle caller (THREAD, vfst.method()); | 903 methodHandle caller (THREAD, vfst.method()); |
786 int bci = vfst.bci(); | 904 int bci = vfst.bci(); |
787 | 905 |
788 // Find bytecode | 906 // Find bytecode |
789 Bytecode_invoke* bytecode = Bytecode_invoke_at(caller, bci); | 907 Bytecode_invoke* bytecode = Bytecode_invoke_at(caller, bci); |
790 bc = bytecode->adjusted_invoke_code(); | 908 bc = bytecode->java_code(); |
791 int bytecode_index = bytecode->index(); | 909 int bytecode_index = bytecode->index(); |
792 | 910 |
793 // Find receiver for non-static call | 911 // Find receiver for non-static call |
794 if (bc != Bytecodes::_invokestatic) { | 912 if (bc != Bytecodes::_invokestatic) { |
795 // This register map must be update since we need to find the receiver for | 913 // This register map must be update since we need to find the receiver for |
1441 // there. If you're lucky you'll get the assert in the bugid, if not you've | 1559 // there. If you're lucky you'll get the assert in the bugid, if not you've |
1442 // just made a call site that could be megamorphic into a monomorphic site | 1560 // just made a call site that could be megamorphic into a monomorphic site |
1443 // for the rest of its life! Just another racing bug in the life of | 1561 // for the rest of its life! Just another racing bug in the life of |
1444 // fixup_callers_callsite ... | 1562 // fixup_callers_callsite ... |
1445 // | 1563 // |
1446 RelocIterator iter(cb, call->instruction_address(), call->next_instruction_address()); | 1564 RelocIterator iter(nm, call->instruction_address(), call->next_instruction_address()); |
1447 iter.next(); | 1565 iter.next(); |
1448 assert(iter.has_current(), "must have a reloc at java call site"); | 1566 assert(iter.has_current(), "must have a reloc at java call site"); |
1449 relocInfo::relocType typ = iter.reloc()->type(); | 1567 relocInfo::relocType typ = iter.reloc()->type(); |
1450 if ( typ != relocInfo::static_call_type && | 1568 if ( typ != relocInfo::static_call_type && |
1451 typ != relocInfo::opt_virtual_call_type && | 1569 typ != relocInfo::opt_virtual_call_type && |
1524 } | 1642 } |
1525 | 1643 |
1526 char* SharedRuntime::generate_wrong_method_type_message(JavaThread* thread, | 1644 char* SharedRuntime::generate_wrong_method_type_message(JavaThread* thread, |
1527 oopDesc* required, | 1645 oopDesc* required, |
1528 oopDesc* actual) { | 1646 oopDesc* actual) { |
1647 if (TraceMethodHandles) { | |
1648 tty->print_cr("WrongMethodType thread="PTR_FORMAT" req="PTR_FORMAT" act="PTR_FORMAT"", | |
1649 thread, required, actual); | |
1650 } | |
1529 assert(EnableMethodHandles, ""); | 1651 assert(EnableMethodHandles, ""); |
1530 oop singleKlass = wrong_method_type_is_for_single_argument(thread, required); | 1652 oop singleKlass = wrong_method_type_is_for_single_argument(thread, required); |
1653 char* message = NULL; | |
1531 if (singleKlass != NULL) { | 1654 if (singleKlass != NULL) { |
1532 const char* objName = "argument or return value"; | 1655 const char* objName = "argument or return value"; |
1533 if (actual != NULL) { | 1656 if (actual != NULL) { |
1534 // be flexible about the junk passed in: | 1657 // be flexible about the junk passed in: |
1535 klassOop ak = (actual->is_klass() | 1658 klassOop ak = (actual->is_klass() |
1538 objName = Klass::cast(ak)->external_name(); | 1661 objName = Klass::cast(ak)->external_name(); |
1539 } | 1662 } |
1540 Klass* targetKlass = Klass::cast(required->is_klass() | 1663 Klass* targetKlass = Klass::cast(required->is_klass() |
1541 ? (klassOop)required | 1664 ? (klassOop)required |
1542 : java_lang_Class::as_klassOop(required)); | 1665 : java_lang_Class::as_klassOop(required)); |
1543 return generate_class_cast_message(objName, targetKlass->external_name()); | 1666 message = generate_class_cast_message(objName, targetKlass->external_name()); |
1544 } else { | 1667 } else { |
1545 // %%% need to get the MethodType string, without messing around too much | 1668 // %%% need to get the MethodType string, without messing around too much |
1546 // Get a signature from the invoke instruction | 1669 // Get a signature from the invoke instruction |
1547 const char* mhName = "method handle"; | 1670 const char* mhName = "method handle"; |
1548 const char* targetType = "the required signature"; | 1671 const char* targetType = "the required signature"; |
1563 } | 1686 } |
1564 klassOop kignore; int fignore; | 1687 klassOop kignore; int fignore; |
1565 methodOop actual_method = MethodHandles::decode_method(actual, | 1688 methodOop actual_method = MethodHandles::decode_method(actual, |
1566 kignore, fignore); | 1689 kignore, fignore); |
1567 if (actual_method != NULL) { | 1690 if (actual_method != NULL) { |
1568 if (actual_method->name() == vmSymbols::invoke_name()) | 1691 if (methodOopDesc::is_method_handle_invoke_name(actual_method->name())) |
1569 mhName = "$"; | 1692 mhName = "$"; |
1570 else | 1693 else |
1571 mhName = actual_method->signature()->as_C_string(); | 1694 mhName = actual_method->signature()->as_C_string(); |
1572 if (mhName[0] == '$') | 1695 if (mhName[0] == '$') |
1573 mhName = actual_method->signature()->as_C_string(); | 1696 mhName = actual_method->signature()->as_C_string(); |
1574 } | 1697 } |
1575 return generate_class_cast_message(mhName, targetType, | 1698 message = generate_class_cast_message(mhName, targetType, |
1576 " cannot be called as "); | 1699 " cannot be called as "); |
1577 } | 1700 } |
1701 if (TraceMethodHandles) { | |
1702 tty->print_cr("WrongMethodType => message=%s", message); | |
1703 } | |
1704 return message; | |
1578 } | 1705 } |
1579 | 1706 |
1580 oop SharedRuntime::wrong_method_type_is_for_single_argument(JavaThread* thr, | 1707 oop SharedRuntime::wrong_method_type_is_for_single_argument(JavaThread* thr, |
1581 oopDesc* required) { | 1708 oopDesc* required) { |
1582 if (required == NULL) return NULL; | 1709 if (required == NULL) return NULL; |
1848 // There are all promoted to T_INT in the calling convention | 1975 // There are all promoted to T_INT in the calling convention |
1849 return T_INT; | 1976 return T_INT; |
1850 | 1977 |
1851 case T_OBJECT: | 1978 case T_OBJECT: |
1852 case T_ARRAY: | 1979 case T_ARRAY: |
1853 if (!TaggedStackInterpreter) { | |
1854 #ifdef _LP64 | 1980 #ifdef _LP64 |
1855 return T_LONG; | 1981 return T_LONG; |
1856 #else | 1982 #else |
1857 return T_INT; | 1983 return T_INT; |
1858 #endif | 1984 #endif |
1859 } | |
1860 return T_OBJECT; | |
1861 | 1985 |
1862 case T_INT: | 1986 case T_INT: |
1863 case T_LONG: | 1987 case T_LONG: |
1864 case T_FLOAT: | 1988 case T_FLOAT: |
1865 case T_DOUBLE: | 1989 case T_DOUBLE: |
2055 int AdapterHandlerTable::_buckets; | 2179 int AdapterHandlerTable::_buckets; |
2056 int AdapterHandlerTable::_equals; | 2180 int AdapterHandlerTable::_equals; |
2057 int AdapterHandlerTable::_hits; | 2181 int AdapterHandlerTable::_hits; |
2058 int AdapterHandlerTable::_compact; | 2182 int AdapterHandlerTable::_compact; |
2059 | 2183 |
2184 #endif | |
2185 | |
2060 class AdapterHandlerTableIterator : public StackObj { | 2186 class AdapterHandlerTableIterator : public StackObj { |
2061 private: | 2187 private: |
2062 AdapterHandlerTable* _table; | 2188 AdapterHandlerTable* _table; |
2063 int _index; | 2189 int _index; |
2064 AdapterHandlerEntry* _current; | 2190 AdapterHandlerEntry* _current; |
2065 | 2191 |
2066 void scan() { | 2192 void scan() { |
2067 while (_index < _table->table_size()) { | 2193 while (_index < _table->table_size()) { |
2068 AdapterHandlerEntry* a = _table->bucket(_index); | 2194 AdapterHandlerEntry* a = _table->bucket(_index); |
2195 _index++; | |
2069 if (a != NULL) { | 2196 if (a != NULL) { |
2070 _current = a; | 2197 _current = a; |
2071 return; | 2198 return; |
2072 } | 2199 } |
2073 _index++; | |
2074 } | 2200 } |
2075 } | 2201 } |
2076 | 2202 |
2077 public: | 2203 public: |
2078 AdapterHandlerTableIterator(AdapterHandlerTable* table): _table(table), _index(0), _current(NULL) { | 2204 AdapterHandlerTableIterator(AdapterHandlerTable* table): _table(table), _index(0), _current(NULL) { |
2090 } else { | 2216 } else { |
2091 return NULL; | 2217 return NULL; |
2092 } | 2218 } |
2093 } | 2219 } |
2094 }; | 2220 }; |
2095 #endif | |
2096 | 2221 |
2097 | 2222 |
2098 // --------------------------------------------------------------------------- | 2223 // --------------------------------------------------------------------------- |
2099 // Implementation of AdapterHandlerLibrary | 2224 // Implementation of AdapterHandlerLibrary |
2100 AdapterHandlerTable* AdapterHandlerLibrary::_adapters = NULL; | 2225 AdapterHandlerTable* AdapterHandlerLibrary::_adapters = NULL; |
2145 address ic_miss = SharedRuntime::get_ic_miss_stub(); | 2270 address ic_miss = SharedRuntime::get_ic_miss_stub(); |
2146 assert(ic_miss != NULL, "must have handler"); | 2271 assert(ic_miss != NULL, "must have handler"); |
2147 | 2272 |
2148 ResourceMark rm; | 2273 ResourceMark rm; |
2149 | 2274 |
2150 NOT_PRODUCT(int code_size); | 2275 NOT_PRODUCT(int insts_size); |
2151 AdapterBlob* B = NULL; | 2276 AdapterBlob* B = NULL; |
2152 AdapterHandlerEntry* entry = NULL; | 2277 AdapterHandlerEntry* entry = NULL; |
2153 AdapterFingerPrint* fingerprint = NULL; | 2278 AdapterFingerPrint* fingerprint = NULL; |
2154 { | 2279 { |
2155 MutexLocker mu(AdapterHandlerLibrary_lock); | 2280 MutexLocker mu(AdapterHandlerLibrary_lock); |
2198 | 2323 |
2199 // Create I2C & C2I handlers | 2324 // Create I2C & C2I handlers |
2200 | 2325 |
2201 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2326 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2202 if (buf != NULL) { | 2327 if (buf != NULL) { |
2203 CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); | 2328 CodeBuffer buffer(buf); |
2204 short buffer_locs[20]; | 2329 short buffer_locs[20]; |
2205 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, | 2330 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, |
2206 sizeof(buffer_locs)/sizeof(relocInfo)); | 2331 sizeof(buffer_locs)/sizeof(relocInfo)); |
2207 MacroAssembler _masm(&buffer); | 2332 MacroAssembler _masm(&buffer); |
2208 | 2333 |
2214 fingerprint); | 2339 fingerprint); |
2215 | 2340 |
2216 #ifdef ASSERT | 2341 #ifdef ASSERT |
2217 if (VerifyAdapterSharing) { | 2342 if (VerifyAdapterSharing) { |
2218 if (shared_entry != NULL) { | 2343 if (shared_entry != NULL) { |
2219 assert(shared_entry->compare_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt), | 2344 assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt), |
2220 "code must match"); | 2345 "code must match"); |
2221 // Release the one just created and return the original | 2346 // Release the one just created and return the original |
2222 _adapters->free_entry(entry); | 2347 _adapters->free_entry(entry); |
2223 return shared_entry; | 2348 return shared_entry; |
2224 } else { | 2349 } else { |
2225 entry->save_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt); | 2350 entry->save_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt); |
2226 } | 2351 } |
2227 } | 2352 } |
2228 #endif | 2353 #endif |
2229 | 2354 |
2230 B = AdapterBlob::create(&buffer); | 2355 B = AdapterBlob::create(&buffer); |
2231 NOT_PRODUCT(code_size = buffer.code_size()); | 2356 NOT_PRODUCT(insts_size = buffer.insts_size()); |
2232 } | 2357 } |
2233 if (B == NULL) { | 2358 if (B == NULL) { |
2234 // CodeCache is full, disable compilation | 2359 // CodeCache is full, disable compilation |
2235 // Ought to log this but compile log is only per compile thread | 2360 // Ought to log this but compile log is only per compile thread |
2236 // and we're some non descript Java thread. | 2361 // and we're some non descript Java thread. |
2237 MutexUnlocker mu(AdapterHandlerLibrary_lock); | 2362 MutexUnlocker mu(AdapterHandlerLibrary_lock); |
2238 CompileBroker::handle_full_code_cache(); | 2363 CompileBroker::handle_full_code_cache(); |
2239 return NULL; // Out of CodeCache space | 2364 return NULL; // Out of CodeCache space |
2240 } | 2365 } |
2241 entry->relocate(B->instructions_begin()); | 2366 entry->relocate(B->content_begin()); |
2242 #ifndef PRODUCT | 2367 #ifndef PRODUCT |
2243 // debugging suppport | 2368 // debugging suppport |
2244 if (PrintAdapterHandlers) { | 2369 if (PrintAdapterHandlers) { |
2245 tty->cr(); | 2370 tty->cr(); |
2246 tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = %s, %d bytes generated)", | 2371 tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = %s, %d bytes generated)", |
2247 _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), | 2372 _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), |
2248 method->signature()->as_C_string(), fingerprint->as_string(), code_size ); | 2373 method->signature()->as_C_string(), fingerprint->as_string(), insts_size ); |
2249 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); | 2374 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); |
2250 Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + code_size); | 2375 Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + insts_size); |
2251 } | 2376 } |
2252 #endif | 2377 #endif |
2253 | 2378 |
2254 _adapters->add(entry); | 2379 _adapters->add(entry); |
2255 } | 2380 } |
2259 jio_snprintf(blob_id, | 2384 jio_snprintf(blob_id, |
2260 sizeof(blob_id), | 2385 sizeof(blob_id), |
2261 "%s(%s)@" PTR_FORMAT, | 2386 "%s(%s)@" PTR_FORMAT, |
2262 B->name(), | 2387 B->name(), |
2263 fingerprint->as_string(), | 2388 fingerprint->as_string(), |
2264 B->instructions_begin()); | 2389 B->content_begin()); |
2265 VTune::register_stub(blob_id, B->instructions_begin(), B->instructions_end()); | 2390 Forte::register_stub(blob_id, B->content_begin(), B->content_end()); |
2266 Forte::register_stub(blob_id, B->instructions_begin(), B->instructions_end()); | |
2267 | 2391 |
2268 if (JvmtiExport::should_post_dynamic_code_generated()) { | 2392 if (JvmtiExport::should_post_dynamic_code_generated()) { |
2269 JvmtiExport::post_dynamic_code_generated(blob_id, | 2393 JvmtiExport::post_dynamic_code_generated(blob_id, B->content_begin(), B->content_end()); |
2270 B->instructions_begin(), | |
2271 B->instructions_end()); | |
2272 } | 2394 } |
2273 } | 2395 } |
2274 return entry; | 2396 return entry; |
2275 } | 2397 } |
2276 | 2398 |
2350 | 2472 |
2351 ResourceMark rm; | 2473 ResourceMark rm; |
2352 | 2474 |
2353 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2475 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2354 if (buf != NULL) { | 2476 if (buf != NULL) { |
2355 CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); | 2477 CodeBuffer buffer(buf); |
2356 double locs_buf[20]; | 2478 double locs_buf[20]; |
2357 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); | 2479 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); |
2358 MacroAssembler _masm(&buffer); | 2480 MacroAssembler _masm(&buffer); |
2359 | 2481 |
2360 // Fill in the signature array, for the calling-convention call. | 2482 // Fill in the signature array, for the calling-convention call. |
2387 ret_type); | 2509 ret_type); |
2388 } | 2510 } |
2389 } | 2511 } |
2390 | 2512 |
2391 // Must unlock before calling set_code | 2513 // Must unlock before calling set_code |
2514 | |
2392 // Install the generated code. | 2515 // Install the generated code. |
2393 if (nm != NULL) { | 2516 if (nm != NULL) { |
2394 method->set_code(method, nm); | 2517 method->set_code(method, nm); |
2395 nm->post_compiled_method_load_event(); | 2518 nm->post_compiled_method_load_event(); |
2396 } else { | 2519 } else { |
2397 // CodeCache is full, disable compilation | 2520 // CodeCache is full, disable compilation |
2398 // Ought to log this but compile log is only per compile thread | |
2399 // and we're some non descript Java thread. | |
2400 MutexUnlocker mu(AdapterHandlerLibrary_lock); | |
2401 CompileBroker::handle_full_code_cache(); | 2521 CompileBroker::handle_full_code_cache(); |
2402 } | 2522 } |
2403 return nm; | 2523 return nm; |
2404 } | 2524 } |
2405 | 2525 |
2436 | 2556 |
2437 ResourceMark rm; | 2557 ResourceMark rm; |
2438 | 2558 |
2439 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2559 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2440 if (buf != NULL) { | 2560 if (buf != NULL) { |
2441 CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size()); | 2561 CodeBuffer buffer(buf); |
2442 // Need a few relocation entries | 2562 // Need a few relocation entries |
2443 double locs_buf[20]; | 2563 double locs_buf[20]; |
2444 buffer.insts()->initialize_shared_locs( | 2564 buffer.insts()->initialize_shared_locs( |
2445 (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); | 2565 (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); |
2446 MacroAssembler _masm(&buffer); | 2566 MacroAssembler _masm(&buffer); |
2601 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words); | 2721 intptr_t *buf = NEW_C_HEAP_ARRAY(intptr_t,buf_size_words); |
2602 | 2722 |
2603 // Copy the locals. Order is preserved so that loading of longs works. | 2723 // Copy the locals. Order is preserved so that loading of longs works. |
2604 // Since there's no GC I can copy the oops blindly. | 2724 // Since there's no GC I can copy the oops blindly. |
2605 assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); | 2725 assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); |
2606 if (TaggedStackInterpreter) { | 2726 Copy::disjoint_words((HeapWord*)fr.interpreter_frame_local_at(max_locals-1), |
2607 for (int i = 0; i < max_locals; i++) { | |
2608 // copy only each local separately to the buffer avoiding the tag | |
2609 buf[i] = *fr.interpreter_frame_local_at(max_locals-i-1); | |
2610 } | |
2611 } else { | |
2612 Copy::disjoint_words( | |
2613 (HeapWord*)fr.interpreter_frame_local_at(max_locals-1), | |
2614 (HeapWord*)&buf[0], | 2727 (HeapWord*)&buf[0], |
2615 max_locals); | 2728 max_locals); |
2616 } | |
2617 | 2729 |
2618 // Inflate locks. Copy the displaced headers. Be careful, there can be holes. | 2730 // Inflate locks. Copy the displaced headers. Be careful, there can be holes. |
2619 int i = max_locals; | 2731 int i = max_locals; |
2620 for( BasicObjectLock *kptr2 = fr.interpreter_frame_monitor_end(); | 2732 for( BasicObjectLock *kptr2 = fr.interpreter_frame_monitor_end(); |
2621 kptr2 < fr.interpreter_frame_monitor_begin(); | 2733 kptr2 < fr.interpreter_frame_monitor_begin(); |
2637 | 2749 |
2638 JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) | 2750 JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) |
2639 FREE_C_HEAP_ARRAY(intptr_t,buf); | 2751 FREE_C_HEAP_ARRAY(intptr_t,buf); |
2640 JRT_END | 2752 JRT_END |
2641 | 2753 |
2642 #ifndef PRODUCT | |
2643 bool AdapterHandlerLibrary::contains(CodeBlob* b) { | 2754 bool AdapterHandlerLibrary::contains(CodeBlob* b) { |
2644 AdapterHandlerTableIterator iter(_adapters); | 2755 AdapterHandlerTableIterator iter(_adapters); |
2645 while (iter.has_next()) { | 2756 while (iter.has_next()) { |
2646 AdapterHandlerEntry* a = iter.next(); | 2757 AdapterHandlerEntry* a = iter.next(); |
2647 if ( b == CodeCache::find_blob(a->get_i2c_entry()) ) return true; | 2758 if ( b == CodeCache::find_blob(a->get_i2c_entry()) ) return true; |
2648 } | 2759 } |
2649 return false; | 2760 return false; |
2650 } | 2761 } |
2651 | 2762 |
2652 void AdapterHandlerLibrary::print_handler(CodeBlob* b) { | 2763 void AdapterHandlerLibrary::print_handler_on(outputStream* st, CodeBlob* b) { |
2653 AdapterHandlerTableIterator iter(_adapters); | 2764 AdapterHandlerTableIterator iter(_adapters); |
2654 while (iter.has_next()) { | 2765 while (iter.has_next()) { |
2655 AdapterHandlerEntry* a = iter.next(); | 2766 AdapterHandlerEntry* a = iter.next(); |
2656 if ( b == CodeCache::find_blob(a->get_i2c_entry()) ) { | 2767 if ( b == CodeCache::find_blob(a->get_i2c_entry()) ) { |
2657 tty->print("Adapter for signature: "); | 2768 st->print("Adapter for signature: "); |
2658 tty->print_cr("%s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT, | 2769 st->print_cr("%s i2c: " INTPTR_FORMAT " c2i: " INTPTR_FORMAT " c2iUV: " INTPTR_FORMAT, |
2659 a->fingerprint()->as_string(), | 2770 a->fingerprint()->as_string(), |
2660 a->get_i2c_entry(), a->get_c2i_entry(), a->get_c2i_unverified_entry()); | 2771 a->get_i2c_entry(), a->get_c2i_entry(), a->get_c2i_unverified_entry()); |
2772 | |
2661 return; | 2773 return; |
2662 } | 2774 } |
2663 } | 2775 } |
2664 assert(false, "Should have found handler"); | 2776 assert(false, "Should have found handler"); |
2665 } | 2777 } |
2778 | |
2779 #ifndef PRODUCT | |
2666 | 2780 |
2667 void AdapterHandlerLibrary::print_statistics() { | 2781 void AdapterHandlerLibrary::print_statistics() { |
2668 _adapters->print_statistics(); | 2782 _adapters->print_statistics(); |
2669 } | 2783 } |
2670 | 2784 |