Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiExport.cpp @ 11198:1e6d5dec4a4e
Merge.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 05 Aug 2013 13:20:06 +0200 |
parents | 825e6cb66923 |
children | f92b82d454fa |
comparison
equal
deleted
inserted
replaced
11197:3479ab380552 | 11198:1e6d5dec4a4e |
---|---|
39 #include "prims/jvmtiImpl.hpp" | 39 #include "prims/jvmtiImpl.hpp" |
40 #include "prims/jvmtiManageCapabilities.hpp" | 40 #include "prims/jvmtiManageCapabilities.hpp" |
41 #include "prims/jvmtiRawMonitor.hpp" | 41 #include "prims/jvmtiRawMonitor.hpp" |
42 #include "prims/jvmtiTagMap.hpp" | 42 #include "prims/jvmtiTagMap.hpp" |
43 #include "prims/jvmtiThreadState.inline.hpp" | 43 #include "prims/jvmtiThreadState.inline.hpp" |
44 #include "prims/jvmtiRedefineClasses.hpp" | |
44 #include "runtime/arguments.hpp" | 45 #include "runtime/arguments.hpp" |
45 #include "runtime/handles.hpp" | 46 #include "runtime/handles.hpp" |
46 #include "runtime/interfaceSupport.hpp" | 47 #include "runtime/interfaceSupport.hpp" |
47 #include "runtime/objectMonitor.hpp" | 48 #include "runtime/objectMonitor.hpp" |
48 #include "runtime/objectMonitor.inline.hpp" | 49 #include "runtime/objectMonitor.inline.hpp" |
514 unsigned char ** _end_ptr; | 515 unsigned char ** _end_ptr; |
515 JavaThread * _thread; | 516 JavaThread * _thread; |
516 jint _curr_len; | 517 jint _curr_len; |
517 unsigned char * _curr_data; | 518 unsigned char * _curr_data; |
518 JvmtiEnv * _curr_env; | 519 JvmtiEnv * _curr_env; |
519 jint * _cached_length_ptr; | 520 JvmtiCachedClassFileData ** _cached_class_file_ptr; |
520 unsigned char ** _cached_data_ptr; | |
521 JvmtiThreadState * _state; | 521 JvmtiThreadState * _state; |
522 KlassHandle * _h_class_being_redefined; | 522 KlassHandle * _h_class_being_redefined; |
523 JvmtiClassLoadKind _load_kind; | 523 JvmtiClassLoadKind _load_kind; |
524 | 524 |
525 public: | 525 public: |
526 inline JvmtiClassFileLoadHookPoster(Symbol* h_name, Handle class_loader, | 526 inline JvmtiClassFileLoadHookPoster(Symbol* h_name, Handle class_loader, |
527 Handle h_protection_domain, | 527 Handle h_protection_domain, |
528 unsigned char **data_ptr, unsigned char **end_ptr, | 528 unsigned char **data_ptr, unsigned char **end_ptr, |
529 unsigned char **cached_data_ptr, | 529 JvmtiCachedClassFileData **cache_ptr) { |
530 jint *cached_length_ptr) { | |
531 _h_name = h_name; | 530 _h_name = h_name; |
532 _class_loader = class_loader; | 531 _class_loader = class_loader; |
533 _h_protection_domain = h_protection_domain; | 532 _h_protection_domain = h_protection_domain; |
534 _data_ptr = data_ptr; | 533 _data_ptr = data_ptr; |
535 _end_ptr = end_ptr; | 534 _end_ptr = end_ptr; |
536 _thread = JavaThread::current(); | 535 _thread = JavaThread::current(); |
537 _curr_len = *end_ptr - *data_ptr; | 536 _curr_len = *end_ptr - *data_ptr; |
538 _curr_data = *data_ptr; | 537 _curr_data = *data_ptr; |
539 _curr_env = NULL; | 538 _curr_env = NULL; |
540 _cached_length_ptr = cached_length_ptr; | 539 _cached_class_file_ptr = cache_ptr; |
541 _cached_data_ptr = cached_data_ptr; | |
542 | 540 |
543 _state = _thread->jvmti_thread_state(); | 541 _state = _thread->jvmti_thread_state(); |
544 if (_state != NULL) { | 542 if (_state != NULL) { |
545 _h_class_being_redefined = _state->get_class_being_redefined(); | 543 _h_class_being_redefined = _state->get_class_being_redefined(); |
546 _load_kind = _state->get_class_load_kind(); | 544 _load_kind = _state->get_class_load_kind(); |
613 _curr_len, _curr_data, | 611 _curr_len, _curr_data, |
614 &new_len, &new_data); | 612 &new_len, &new_data); |
615 } | 613 } |
616 if (new_data != NULL) { | 614 if (new_data != NULL) { |
617 // this agent has modified class data. | 615 // this agent has modified class data. |
618 if (caching_needed && *_cached_data_ptr == NULL) { | 616 if (caching_needed && *_cached_class_file_ptr == NULL) { |
619 // data has been changed by the new retransformable agent | 617 // data has been changed by the new retransformable agent |
620 // and it hasn't already been cached, cache it | 618 // and it hasn't already been cached, cache it |
621 *_cached_data_ptr = (unsigned char *)os::malloc(_curr_len, mtInternal); | 619 JvmtiCachedClassFileData *p; |
622 if (*_cached_data_ptr == NULL) { | 620 p = (JvmtiCachedClassFileData *)os::malloc( |
623 vm_exit_out_of_memory(_curr_len, OOM_MALLOC_ERROR, "unable to allocate cached copy of original class bytes"); | 621 offset_of(JvmtiCachedClassFileData, data) + _curr_len, mtInternal); |
622 if (p == NULL) { | |
623 vm_exit_out_of_memory(offset_of(JvmtiCachedClassFileData, data) + _curr_len, | |
624 OOM_MALLOC_ERROR, | |
625 "unable to allocate cached copy of original class bytes"); | |
624 } | 626 } |
625 memcpy(*_cached_data_ptr, _curr_data, _curr_len); | 627 p->length = _curr_len; |
626 *_cached_length_ptr = _curr_len; | 628 memcpy(p->data, _curr_data, _curr_len); |
629 *_cached_class_file_ptr = p; | |
627 } | 630 } |
628 | 631 |
629 if (_curr_data != *_data_ptr) { | 632 if (_curr_data != *_data_ptr) { |
630 // curr_data is previous agent modified class data. | 633 // curr_data is previous agent modified class data. |
631 // And this has been changed by the new agent so | 634 // And this has been changed by the new agent so |
660 void JvmtiExport::post_class_file_load_hook(Symbol* h_name, | 663 void JvmtiExport::post_class_file_load_hook(Symbol* h_name, |
661 Handle class_loader, | 664 Handle class_loader, |
662 Handle h_protection_domain, | 665 Handle h_protection_domain, |
663 unsigned char **data_ptr, | 666 unsigned char **data_ptr, |
664 unsigned char **end_ptr, | 667 unsigned char **end_ptr, |
665 unsigned char **cached_data_ptr, | 668 JvmtiCachedClassFileData **cache_ptr) { |
666 jint *cached_length_ptr) { | |
667 JvmtiClassFileLoadHookPoster poster(h_name, class_loader, | 669 JvmtiClassFileLoadHookPoster poster(h_name, class_loader, |
668 h_protection_domain, | 670 h_protection_domain, |
669 data_ptr, end_ptr, | 671 data_ptr, end_ptr, |
670 cached_data_ptr, | 672 cache_ptr); |
671 cached_length_ptr); | |
672 poster.post(); | 673 poster.post(); |
673 } | 674 } |
674 | 675 |
675 void JvmtiExport::report_unsupported(bool on) { | 676 void JvmtiExport::report_unsupported(bool on) { |
676 // If any JVMTI service is turned on, we need to exit before native code | 677 // If any JVMTI service is turned on, we need to exit before native code |