Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/sharedRuntime.cpp @ 18041:52b4284cb496
Merge with jdk8u20-b26
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 15 Oct 2014 16:02:50 +0200 |
parents | 4703a9442f3f 0bf37f737702 |
children | 810222d74f7c |
comparison
equal
deleted
inserted
replaced
17606:45d7b2c7029d | 18041:52b4284cb496 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2014, 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. |
80 #endif | 80 #endif |
81 #ifdef COMPILER1 | 81 #ifdef COMPILER1 |
82 #include "c1/c1_Runtime1.hpp" | 82 #include "c1/c1_Runtime1.hpp" |
83 #endif | 83 #endif |
84 | 84 |
85 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC | |
86 | |
85 // Shared stub locations | 87 // Shared stub locations |
86 RuntimeStub* SharedRuntime::_wrong_method_blob; | 88 RuntimeStub* SharedRuntime::_wrong_method_blob; |
87 RuntimeStub* SharedRuntime::_wrong_method_abstract_blob; | 89 RuntimeStub* SharedRuntime::_wrong_method_abstract_blob; |
88 RuntimeStub* SharedRuntime::_ic_miss_blob; | 90 RuntimeStub* SharedRuntime::_ic_miss_blob; |
89 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; | 91 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; |
406 return (f <= (double)0.0) ? (double)0.0 - f : f; | 408 return (f <= (double)0.0) ? (double)0.0 - f : f; |
407 } | 409 } |
408 | 410 |
409 #endif | 411 #endif |
410 | 412 |
411 #if defined(__SOFTFP__) || defined(PPC) | 413 #if defined(__SOFTFP__) || defined(PPC32) |
412 double SharedRuntime::dsqrt(double f) { | 414 double SharedRuntime::dsqrt(double f) { |
413 return sqrt(f); | 415 return sqrt(f); |
414 } | 416 } |
415 #endif | 417 #endif |
416 | 418 |
498 thread->set_is_method_handle_return(nm->is_method_handle_return(return_address)); | 500 thread->set_is_method_handle_return(nm->is_method_handle_return(return_address)); |
499 // native nmethods don't have exception handlers | 501 // native nmethods don't have exception handlers |
500 assert(!nm->is_native_method(), "no exception handler"); | 502 assert(!nm->is_native_method(), "no exception handler"); |
501 assert(nm->header_begin() != nm->exception_begin(), "no exception handler"); | 503 assert(nm->header_begin() != nm->exception_begin(), "no exception handler"); |
502 if (nm->is_deopt_pc(return_address)) { | 504 if (nm->is_deopt_pc(return_address)) { |
505 // If we come here because of a stack overflow, the stack may be | |
506 // unguarded. Reguard the stack otherwise if we return to the | |
507 // deopt blob and the stack bang causes a stack overflow we | |
508 // crash. | |
509 bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); | |
510 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); | |
511 assert(guard_pages_enabled, "stack banging in deopt blob may cause crash"); | |
503 return SharedRuntime::deopt_blob()->unpack_with_exception(); | 512 return SharedRuntime::deopt_blob()->unpack_with_exception(); |
504 } else { | 513 } else { |
505 return nm->exception_begin(); | 514 return nm->exception_begin(); |
506 } | 515 } |
507 } | 516 } |
810 case STACK_OVERFLOW: { | 819 case STACK_OVERFLOW: { |
811 // Stack overflow only occurs upon frame setup; the callee is | 820 // Stack overflow only occurs upon frame setup; the callee is |
812 // going to be unwound. Dispatch to a shared runtime stub | 821 // going to be unwound. Dispatch to a shared runtime stub |
813 // which will cause the StackOverflowError to be fabricated | 822 // which will cause the StackOverflowError to be fabricated |
814 // and processed. | 823 // and processed. |
815 // For stack overflow in deoptimization blob, cleanup thread. | 824 // Stack overflow should never occur during deoptimization: |
816 if (thread->deopt_mark() != NULL) { | 825 // the compiled method bangs the stack by as much as the |
817 Deoptimization::cleanup_deopt_info(thread, NULL); | 826 // interpreter would need in case of a deoptimization. The |
818 } | 827 // deoptimization blob and uncommon trap blob bang the stack |
828 // in a debug VM to verify the correctness of the compiled | |
829 // method stack banging. | |
830 assert(thread->deopt_mark() == NULL, "no stack overflow from deopt blob/uncommon trap"); | |
819 Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, pc); | 831 Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, pc); |
820 return StubRoutines::throw_StackOverflowError_entry(); | 832 return StubRoutines::throw_StackOverflowError_entry(); |
821 } | 833 } |
822 | 834 |
823 case IMPLICIT_NULL: { | 835 case IMPLICIT_NULL: { |
1017 /** | 1029 /** |
1018 * This function ought to be a void function, but cannot be because | 1030 * This function ought to be a void function, but cannot be because |
1019 * it gets turned into a tail-call on sparc, which runs into dtrace bug | 1031 * it gets turned into a tail-call on sparc, which runs into dtrace bug |
1020 * 6254741. Once that is fixed we can remove the dummy return value. | 1032 * 6254741. Once that is fixed we can remove the dummy return value. |
1021 */ | 1033 */ |
1022 int SharedRuntime::dtrace_object_alloc(oopDesc* o) { | 1034 int SharedRuntime::dtrace_object_alloc(oopDesc* o, int size) { |
1023 return dtrace_object_alloc_base(Thread::current(), o); | 1035 return dtrace_object_alloc_base(Thread::current(), o, size); |
1024 } | 1036 } |
1025 | 1037 |
1026 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { | 1038 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o, int size) { |
1027 assert(DTraceAllocProbes, "wrong call"); | 1039 assert(DTraceAllocProbes, "wrong call"); |
1028 Klass* klass = o->klass(); | 1040 Klass* klass = o->klass(); |
1029 int size = o->size(); | |
1030 Symbol* name = klass->name(); | 1041 Symbol* name = klass->name(); |
1031 #ifndef USDT2 | 1042 #ifndef USDT2 |
1032 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), | 1043 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), |
1033 name->bytes(), name->utf8_length(), size * HeapWordSize); | 1044 name->bytes(), name->utf8_length(), size * HeapWordSize); |
1034 #else /* USDT2 */ | 1045 #else /* USDT2 */ |
2463 assert(ic_miss != NULL, "must have handler"); | 2474 assert(ic_miss != NULL, "must have handler"); |
2464 | 2475 |
2465 ResourceMark rm; | 2476 ResourceMark rm; |
2466 | 2477 |
2467 NOT_PRODUCT(int insts_size); | 2478 NOT_PRODUCT(int insts_size); |
2468 AdapterBlob* B = NULL; | 2479 AdapterBlob* new_adapter = NULL; |
2469 AdapterHandlerEntry* entry = NULL; | 2480 AdapterHandlerEntry* entry = NULL; |
2470 AdapterFingerPrint* fingerprint = NULL; | 2481 AdapterFingerPrint* fingerprint = NULL; |
2471 { | 2482 { |
2472 MutexLocker mu(AdapterHandlerLibrary_lock); | 2483 MutexLocker mu(AdapterHandlerLibrary_lock); |
2473 // make sure data structure is initialized | 2484 // make sure data structure is initialized |
2495 // Lookup method signature's fingerprint | 2506 // Lookup method signature's fingerprint |
2496 entry = _adapters->lookup(total_args_passed, sig_bt); | 2507 entry = _adapters->lookup(total_args_passed, sig_bt); |
2497 | 2508 |
2498 #ifdef ASSERT | 2509 #ifdef ASSERT |
2499 AdapterHandlerEntry* shared_entry = NULL; | 2510 AdapterHandlerEntry* shared_entry = NULL; |
2500 if (VerifyAdapterSharing && entry != NULL) { | 2511 // Start adapter sharing verification only after the VM is booted. |
2512 if (VerifyAdapterSharing && (entry != NULL)) { | |
2501 shared_entry = entry; | 2513 shared_entry = entry; |
2502 entry = NULL; | 2514 entry = NULL; |
2503 } | 2515 } |
2504 #endif | 2516 #endif |
2505 | 2517 |
2511 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); | 2523 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); |
2512 | 2524 |
2513 // Make a C heap allocated version of the fingerprint to store in the adapter | 2525 // Make a C heap allocated version of the fingerprint to store in the adapter |
2514 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt); | 2526 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt); |
2515 | 2527 |
2528 // StubRoutines::code2() is initialized after this function can be called. As a result, | |
2529 // VerifyAdapterCalls and VerifyAdapterSharing can fail if we re-use code that generated | |
2530 // prior to StubRoutines::code2() being set. Checks refer to checks generated in an I2C | |
2531 // stub that ensure that an I2C stub is called from an interpreter frame. | |
2532 bool contains_all_checks = StubRoutines::code2() != NULL; | |
2533 | |
2516 // Create I2C & C2I handlers | 2534 // Create I2C & C2I handlers |
2517 | |
2518 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2535 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2519 if (buf != NULL) { | 2536 if (buf != NULL) { |
2520 CodeBuffer buffer(buf); | 2537 CodeBuffer buffer(buf); |
2521 short buffer_locs[20]; | 2538 short buffer_locs[20]; |
2522 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, | 2539 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, |
2523 sizeof(buffer_locs)/sizeof(relocInfo)); | 2540 sizeof(buffer_locs)/sizeof(relocInfo)); |
2541 | |
2524 MacroAssembler _masm(&buffer); | 2542 MacroAssembler _masm(&buffer); |
2525 | |
2526 entry = SharedRuntime::generate_i2c2i_adapters(&_masm, | 2543 entry = SharedRuntime::generate_i2c2i_adapters(&_masm, |
2527 total_args_passed, | 2544 total_args_passed, |
2528 comp_args_on_stack, | 2545 comp_args_on_stack, |
2529 sig_bt, | 2546 sig_bt, |
2530 regs, | 2547 regs, |
2531 fingerprint); | 2548 fingerprint); |
2532 | |
2533 #ifdef ASSERT | 2549 #ifdef ASSERT |
2534 if (VerifyAdapterSharing) { | 2550 if (VerifyAdapterSharing) { |
2535 if (shared_entry != NULL) { | 2551 if (shared_entry != NULL) { |
2536 assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt), | 2552 assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size()), "code must match"); |
2537 "code must match"); | |
2538 // Release the one just created and return the original | 2553 // Release the one just created and return the original |
2539 _adapters->free_entry(entry); | 2554 _adapters->free_entry(entry); |
2540 return shared_entry; | 2555 return shared_entry; |
2541 } else { | 2556 } else { |
2542 entry->save_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt); | 2557 entry->save_code(buf->code_begin(), buffer.insts_size()); |
2543 } | 2558 } |
2544 } | 2559 } |
2545 #endif | 2560 #endif |
2546 | 2561 |
2547 B = AdapterBlob::create(&buffer); | 2562 new_adapter = AdapterBlob::create(&buffer); |
2548 NOT_PRODUCT(insts_size = buffer.insts_size()); | 2563 NOT_PRODUCT(insts_size = buffer.insts_size()); |
2549 } | 2564 } |
2550 if (B == NULL) { | 2565 if (new_adapter == NULL) { |
2551 // CodeCache is full, disable compilation | 2566 // CodeCache is full, disable compilation |
2552 // Ought to log this but compile log is only per compile thread | 2567 // Ought to log this but compile log is only per compile thread |
2553 // and we're some non descript Java thread. | 2568 // and we're some non descript Java thread. |
2554 MutexUnlocker mu(AdapterHandlerLibrary_lock); | 2569 MutexUnlocker mu(AdapterHandlerLibrary_lock); |
2555 CompileBroker::handle_full_code_cache(); | 2570 CompileBroker::handle_full_code_cache(); |
2556 return NULL; // Out of CodeCache space | 2571 return NULL; // Out of CodeCache space |
2557 } | 2572 } |
2558 entry->relocate(B->content_begin()); | 2573 entry->relocate(new_adapter->content_begin()); |
2559 #ifndef PRODUCT | 2574 #ifndef PRODUCT |
2560 // debugging suppport | 2575 // debugging suppport |
2561 if (PrintAdapterHandlers || PrintStubCode) { | 2576 if (PrintAdapterHandlers || PrintStubCode) { |
2562 ttyLocker ttyl; | 2577 ttyLocker ttyl; |
2563 entry->print_adapter_on(tty); | 2578 entry->print_adapter_on(tty); |
2572 tty->cr(); | 2587 tty->cr(); |
2573 } | 2588 } |
2574 } | 2589 } |
2575 } | 2590 } |
2576 #endif | 2591 #endif |
2577 | 2592 // Add the entry only if the entry contains all required checks (see sharedRuntime_xxx.cpp) |
2578 _adapters->add(entry); | 2593 // The checks are inserted only if -XX:+VerifyAdapterCalls is specified. |
2594 if (contains_all_checks || !VerifyAdapterCalls) { | |
2595 _adapters->add(entry); | |
2596 } | |
2579 } | 2597 } |
2580 // Outside of the lock | 2598 // Outside of the lock |
2581 if (B != NULL) { | 2599 if (new_adapter != NULL) { |
2582 char blob_id[256]; | 2600 char blob_id[256]; |
2583 jio_snprintf(blob_id, | 2601 jio_snprintf(blob_id, |
2584 sizeof(blob_id), | 2602 sizeof(blob_id), |
2585 "%s(%s)@" PTR_FORMAT, | 2603 "%s(%s)@" PTR_FORMAT, |
2586 B->name(), | 2604 new_adapter->name(), |
2587 fingerprint->as_string(), | 2605 fingerprint->as_string(), |
2588 B->content_begin()); | 2606 new_adapter->content_begin()); |
2589 Forte::register_stub(blob_id, B->content_begin(), B->content_end()); | 2607 Forte::register_stub(blob_id, new_adapter->content_begin(),new_adapter->content_end()); |
2590 | 2608 |
2591 if (JvmtiExport::should_post_dynamic_code_generated()) { | 2609 if (JvmtiExport::should_post_dynamic_code_generated()) { |
2592 JvmtiExport::post_dynamic_code_generated(blob_id, B->content_begin(), B->content_end()); | 2610 JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end()); |
2593 } | 2611 } |
2594 } | 2612 } |
2595 return entry; | 2613 return entry; |
2596 } | 2614 } |
2597 | 2615 |
2619 | 2637 |
2620 void AdapterHandlerEntry::deallocate() { | 2638 void AdapterHandlerEntry::deallocate() { |
2621 delete _fingerprint; | 2639 delete _fingerprint; |
2622 #ifdef ASSERT | 2640 #ifdef ASSERT |
2623 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); | 2641 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); |
2624 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig, mtCode); | |
2625 #endif | 2642 #endif |
2626 } | 2643 } |
2627 | 2644 |
2628 | 2645 |
2629 #ifdef ASSERT | 2646 #ifdef ASSERT |
2630 // Capture the code before relocation so that it can be compared | 2647 // Capture the code before relocation so that it can be compared |
2631 // against other versions. If the code is captured after relocation | 2648 // against other versions. If the code is captured after relocation |
2632 // then relative instructions won't be equivalent. | 2649 // then relative instructions won't be equivalent. |
2633 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | 2650 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length) { |
2634 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); | 2651 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); |
2635 _code_length = length; | 2652 _saved_code_length = length; |
2636 memcpy(_saved_code, buffer, length); | 2653 memcpy(_saved_code, buffer, length); |
2637 _total_args_passed = total_args_passed; | 2654 } |
2638 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed, mtCode); | 2655 |
2639 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); | 2656 |
2640 } | 2657 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length) { |
2641 | 2658 if (length != _saved_code_length) { |
2642 | |
2643 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | |
2644 if (length != _code_length) { | |
2645 return false; | 2659 return false; |
2646 } | 2660 } |
2647 for (int i = 0; i < length; i++) { | 2661 |
2648 if (buffer[i] != _saved_code[i]) { | 2662 return (memcmp(buffer, _saved_code, length) == 0) ? true : false; |
2649 return false; | 2663 } |
2650 } | 2664 #endif |
2651 } | 2665 |
2652 return true; | 2666 |
2653 } | 2667 /** |
2654 #endif | 2668 * Create a native wrapper for this native method. The wrapper converts the |
2655 | 2669 * Java-compiled calling convention to the native convention, handles |
2656 | 2670 * arguments, and transitions to native. On return from the native we transition |
2657 // Create a native wrapper for this native method. The wrapper converts the | 2671 * back to java blocking if a safepoint is in progress. |
2658 // java compiled calling convention to the native convention, handlizes | 2672 */ |
2659 // arguments, and transitions to native. On return from the native we transition | 2673 void AdapterHandlerLibrary::create_native_wrapper(methodHandle method) { |
2660 // back to java blocking if a safepoint is in progress. | |
2661 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method, int compile_id) { | |
2662 ResourceMark rm; | 2674 ResourceMark rm; |
2663 nmethod* nm = NULL; | 2675 nmethod* nm = NULL; |
2664 | 2676 |
2665 assert(method->is_native(), "must be native"); | 2677 assert(method->is_native(), "must be native"); |
2666 assert(method->is_method_handle_intrinsic() || | 2678 assert(method->is_method_handle_intrinsic() || |
2667 method->has_native_function(), "must have something valid to call!"); | 2679 method->has_native_function(), "must have something valid to call!"); |
2668 | 2680 |
2669 { | 2681 { |
2670 // perform the work while holding the lock, but perform any printing outside the lock | 2682 // Perform the work while holding the lock, but perform any printing outside the lock |
2671 MutexLocker mu(AdapterHandlerLibrary_lock); | 2683 MutexLocker mu(AdapterHandlerLibrary_lock); |
2672 // See if somebody beat us to it | 2684 // See if somebody beat us to it |
2673 nm = method->code(); | 2685 nm = method->code(); |
2674 if (nm) { | 2686 if (nm != NULL) { |
2675 return nm; | 2687 return; |
2676 } | 2688 } |
2689 | |
2690 const int compile_id = CompileBroker::assign_compile_id(method, CompileBroker::standard_entry_bci); | |
2691 assert(compile_id > 0, "Must generate native wrapper"); | |
2692 | |
2677 | 2693 |
2678 ResourceMark rm; | 2694 ResourceMark rm; |
2679 | |
2680 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2695 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2681 if (buf != NULL) { | 2696 if (buf != NULL) { |
2682 CodeBuffer buffer(buf); | 2697 CodeBuffer buffer(buf); |
2683 double locs_buf[20]; | 2698 double locs_buf[20]; |
2684 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); | 2699 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); |
2706 // are just trampolines so the argument registers must be outgoing ones. | 2721 // are just trampolines so the argument registers must be outgoing ones. |
2707 const bool is_outgoing = method->is_method_handle_intrinsic(); | 2722 const bool is_outgoing = method->is_method_handle_intrinsic(); |
2708 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); | 2723 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); |
2709 | 2724 |
2710 // Generate the compiled-to-native wrapper code | 2725 // Generate the compiled-to-native wrapper code |
2711 nm = SharedRuntime::generate_native_wrapper(&_masm, | 2726 nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type); |
2712 method, | 2727 |
2713 compile_id, | 2728 if (nm != NULL) { |
2714 sig_bt, | 2729 method->set_code(method, nm); |
2715 regs, | 2730 } |
2716 ret_type); | 2731 } |
2717 } | 2732 } // Unlock AdapterHandlerLibrary_lock |
2718 } | 2733 |
2719 | |
2720 // Must unlock before calling set_code | |
2721 | 2734 |
2722 // Install the generated code. | 2735 // Install the generated code. |
2723 if (nm != NULL) { | 2736 if (nm != NULL) { |
2724 if (PrintCompilation) { | 2737 if (PrintCompilation) { |
2725 ttyLocker ttyl; | 2738 ttyLocker ttyl; |
2726 CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : ""); | 2739 CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : ""); |
2727 } | 2740 } |
2728 method->set_code(method, nm); | |
2729 nm->post_compiled_method_load_event(); | 2741 nm->post_compiled_method_load_event(); |
2730 } else { | 2742 } else { |
2731 // CodeCache is full, disable compilation | 2743 // CodeCache is full, disable compilation |
2732 CompileBroker::handle_full_code_cache(); | 2744 CompileBroker::handle_full_code_cache(); |
2733 } | 2745 } |
2734 return nm; | |
2735 } | 2746 } |
2736 | 2747 |
2737 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread)) | 2748 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread)) |
2738 assert(thread == JavaThread::current(), "must be"); | 2749 assert(thread == JavaThread::current(), "must be"); |
2739 // The code is about to enter a JNI lazy critical native method and | 2750 // The code is about to enter a JNI lazy critical native method and |
2747 GC_locker::lock_critical(thread); | 2758 GC_locker::lock_critical(thread); |
2748 GC_locker::unlock_critical(thread); | 2759 GC_locker::unlock_critical(thread); |
2749 JRT_END | 2760 JRT_END |
2750 | 2761 |
2751 #ifdef HAVE_DTRACE_H | 2762 #ifdef HAVE_DTRACE_H |
2752 // Create a dtrace nmethod for this method. The wrapper converts the | 2763 /** |
2753 // java compiled calling convention to the native convention, makes a dummy call | 2764 * Create a dtrace nmethod for this method. The wrapper converts the |
2754 // (actually nops for the size of the call instruction, which become a trap if | 2765 * Java-compiled calling convention to the native convention, makes a dummy call |
2755 // probe is enabled). The returns to the caller. Since this all looks like a | 2766 * (actually nops for the size of the call instruction, which become a trap if |
2756 // leaf no thread transition is needed. | 2767 * probe is enabled), and finally returns to the caller. Since this all looks like a |
2757 | 2768 * leaf, no thread transition is needed. |
2769 */ | |
2758 nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) { | 2770 nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) { |
2759 ResourceMark rm; | 2771 ResourceMark rm; |
2760 nmethod* nm = NULL; | 2772 nmethod* nm = NULL; |
2761 | 2773 |
2762 if (PrintCompilation) { | 2774 if (PrintCompilation) { |
2763 ttyLocker ttyl; | 2775 ttyLocker ttyl; |
2764 tty->print("--- n%s "); | 2776 tty->print("--- n "); |
2765 method->print_short_name(tty); | 2777 method->print_short_name(tty); |
2766 if (method->is_static()) { | 2778 if (method->is_static()) { |
2767 tty->print(" (static)"); | 2779 tty->print(" (static)"); |
2768 } | 2780 } |
2769 tty->cr(); | 2781 tty->cr(); |
2806 jlsValue->char_at_addr(jlsOffset); | 2818 jlsValue->char_at_addr(jlsOffset); |
2807 assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string"); | 2819 assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string"); |
2808 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size); | 2820 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size); |
2809 } | 2821 } |
2810 #endif // ndef HAVE_DTRACE_H | 2822 #endif // ndef HAVE_DTRACE_H |
2823 | |
2824 int SharedRuntime::convert_ints_to_longints_argcnt(int in_args_count, BasicType* in_sig_bt) { | |
2825 int argcnt = in_args_count; | |
2826 if (CCallingConventionRequiresIntsAsLongs) { | |
2827 for (int in = 0; in < in_args_count; in++) { | |
2828 BasicType bt = in_sig_bt[in]; | |
2829 switch (bt) { | |
2830 case T_BOOLEAN: | |
2831 case T_CHAR: | |
2832 case T_BYTE: | |
2833 case T_SHORT: | |
2834 case T_INT: | |
2835 argcnt++; | |
2836 break; | |
2837 default: | |
2838 break; | |
2839 } | |
2840 } | |
2841 } else { | |
2842 assert(0, "This should not be needed on this platform"); | |
2843 } | |
2844 | |
2845 return argcnt; | |
2846 } | |
2847 | |
2848 void SharedRuntime::convert_ints_to_longints(int i2l_argcnt, int& in_args_count, | |
2849 BasicType*& in_sig_bt, VMRegPair*& in_regs) { | |
2850 if (CCallingConventionRequiresIntsAsLongs) { | |
2851 VMRegPair *new_in_regs = NEW_RESOURCE_ARRAY(VMRegPair, i2l_argcnt); | |
2852 BasicType *new_in_sig_bt = NEW_RESOURCE_ARRAY(BasicType, i2l_argcnt); | |
2853 | |
2854 int argcnt = 0; | |
2855 for (int in = 0; in < in_args_count; in++, argcnt++) { | |
2856 BasicType bt = in_sig_bt[in]; | |
2857 VMRegPair reg = in_regs[in]; | |
2858 switch (bt) { | |
2859 case T_BOOLEAN: | |
2860 case T_CHAR: | |
2861 case T_BYTE: | |
2862 case T_SHORT: | |
2863 case T_INT: | |
2864 // Convert (bt) to (T_LONG,bt). | |
2865 new_in_sig_bt[argcnt ] = T_LONG; | |
2866 new_in_sig_bt[argcnt+1] = bt; | |
2867 assert(reg.first()->is_valid() && !reg.second()->is_valid(), ""); | |
2868 new_in_regs[argcnt ].set2(reg.first()); | |
2869 new_in_regs[argcnt+1].set_bad(); | |
2870 argcnt++; | |
2871 break; | |
2872 default: | |
2873 // No conversion needed. | |
2874 new_in_sig_bt[argcnt] = bt; | |
2875 new_in_regs[argcnt] = reg; | |
2876 break; | |
2877 } | |
2878 } | |
2879 assert(argcnt == i2l_argcnt, "must match"); | |
2880 | |
2881 in_regs = new_in_regs; | |
2882 in_sig_bt = new_in_sig_bt; | |
2883 in_args_count = i2l_argcnt; | |
2884 } else { | |
2885 assert(0, "This should not be needed on this platform"); | |
2886 } | |
2887 } | |
2811 | 2888 |
2812 // ------------------------------------------------------------------------- | 2889 // ------------------------------------------------------------------------- |
2813 // Java-Java calling convention | 2890 // Java-Java calling convention |
2814 // (what you use when Java calls Java) | 2891 // (what you use when Java calls Java) |
2815 | 2892 |