Mercurial > hg > truffle
comparison src/share/vm/classfile/javaClasses.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | e5928e7dab26 |
children | a81f60ddab06 |
comparison
equal
deleted
inserted
replaced
3737:9dc19b7d89a3 | 4137:04b9a2566eec |
---|---|
26 #include "classfile/javaClasses.hpp" | 26 #include "classfile/javaClasses.hpp" |
27 #include "classfile/symbolTable.hpp" | 27 #include "classfile/symbolTable.hpp" |
28 #include "classfile/vmSymbols.hpp" | 28 #include "classfile/vmSymbols.hpp" |
29 #include "code/debugInfo.hpp" | 29 #include "code/debugInfo.hpp" |
30 #include "code/pcDesc.hpp" | 30 #include "code/pcDesc.hpp" |
31 #include "compiler/compilerOracle.hpp" | |
31 #include "interpreter/interpreter.hpp" | 32 #include "interpreter/interpreter.hpp" |
32 #include "memory/oopFactory.hpp" | 33 #include "memory/oopFactory.hpp" |
33 #include "memory/resourceArea.hpp" | 34 #include "memory/resourceArea.hpp" |
34 #include "memory/universe.inline.hpp" | 35 #include "memory/universe.inline.hpp" |
36 #include "oops/fieldStreams.hpp" | |
35 #include "oops/instanceKlass.hpp" | 37 #include "oops/instanceKlass.hpp" |
36 #include "oops/instanceMirrorKlass.hpp" | 38 #include "oops/instanceMirrorKlass.hpp" |
37 #include "oops/klass.hpp" | 39 #include "oops/klass.hpp" |
38 #include "oops/klassOop.hpp" | 40 #include "oops/klassOop.hpp" |
39 #include "oops/methodOop.hpp" | 41 #include "oops/methodOop.hpp" |
54 # include "thread_solaris.inline.hpp" | 56 # include "thread_solaris.inline.hpp" |
55 #endif | 57 #endif |
56 #ifdef TARGET_OS_FAMILY_windows | 58 #ifdef TARGET_OS_FAMILY_windows |
57 # include "thread_windows.inline.hpp" | 59 # include "thread_windows.inline.hpp" |
58 #endif | 60 #endif |
61 #ifdef TARGET_OS_FAMILY_bsd | |
62 # include "thread_bsd.inline.hpp" | |
63 #endif | |
64 | |
65 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java) \ | |
66 klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum); | |
67 | |
68 #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java) \ | |
69 { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java }, | |
70 | |
71 InjectedField JavaClasses::_injected_fields[] = { | |
72 ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD) | |
73 }; | |
74 | |
75 int JavaClasses::compute_injected_offset(InjectedFieldID id) { | |
76 return _injected_fields[id].compute_offset(); | |
77 } | |
78 | |
79 | |
80 InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) { | |
81 *field_count = 0; | |
82 | |
83 vmSymbols::SID sid = vmSymbols::find_sid(class_name); | |
84 if (sid == vmSymbols::NO_SID) { | |
85 // Only well known classes can inject fields | |
86 return NULL; | |
87 } | |
88 | |
89 int count = 0; | |
90 int start = -1; | |
91 | |
92 #define LOOKUP_INJECTED_FIELD(klass, name, signature, may_be_java) \ | |
93 if (sid == vmSymbols::VM_SYMBOL_ENUM_NAME(klass)) { \ | |
94 count++; \ | |
95 if (start == -1) start = klass##_##name##_enum; \ | |
96 } | |
97 ALL_INJECTED_FIELDS(LOOKUP_INJECTED_FIELD); | |
98 #undef LOOKUP_INJECTED_FIELD | |
99 | |
100 if (start != -1) { | |
101 *field_count = count; | |
102 return _injected_fields + start; | |
103 } | |
104 return NULL; | |
105 } | |
106 | |
59 | 107 |
60 static bool find_field(instanceKlass* ik, | 108 static bool find_field(instanceKlass* ik, |
61 Symbol* name_symbol, Symbol* signature_symbol, | 109 Symbol* name_symbol, Symbol* signature_symbol, |
62 fieldDescriptor* fd, | 110 fieldDescriptor* fd, |
63 bool allow_super = false) { | 111 bool allow_super = false) { |
425 } | 473 } |
426 } | 474 } |
427 } | 475 } |
428 | 476 |
429 | 477 |
430 // During bootstrap, java.lang.Class wasn't loaded so static field | |
431 // offsets were computed without the size added it. Go back and | |
432 // update all the static field offsets to included the size. | |
433 static void fixup_static_field(fieldDescriptor* fd, TRAPS) { | |
434 if (fd->is_static()) { | |
435 int real_offset = fd->offset() + instanceMirrorKlass::offset_of_static_fields(); | |
436 typeArrayOop fields = instanceKlass::cast(fd->field_holder())->fields(); | |
437 fields->short_at_put(fd->index() + instanceKlass::low_offset, extract_low_short_from_int(real_offset)); | |
438 fields->short_at_put(fd->index() + instanceKlass::high_offset, extract_high_short_from_int(real_offset)); | |
439 } | |
440 } | |
441 | |
442 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) { | 478 void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) { |
443 assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already"); | 479 assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already"); |
444 | 480 |
445 if (k->oop_is_instance()) { | 481 if (k->oop_is_instance()) { |
446 // Fixup the offsets | 482 // During bootstrap, java.lang.Class wasn't loaded so static field |
447 instanceKlass::cast(k())->do_local_static_fields(&fixup_static_field, CHECK); | 483 // offsets were computed without the size added it. Go back and |
484 // update all the static field offsets to included the size. | |
485 for (JavaFieldStream fs(instanceKlass::cast(k())); !fs.done(); fs.next()) { | |
486 if (fs.access_flags().is_static()) { | |
487 int real_offset = fs.offset() + instanceMirrorKlass::offset_of_static_fields(); | |
488 fs.set_offset(real_offset); | |
489 } | |
490 } | |
448 } | 491 } |
449 create_mirror(k, CHECK); | 492 create_mirror(k, CHECK); |
450 } | 493 } |
451 | 494 |
452 oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { | 495 oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { |
458 int computed_modifiers = k->compute_modifier_flags(CHECK_0); | 501 int computed_modifiers = k->compute_modifier_flags(CHECK_0); |
459 k->set_modifier_flags(computed_modifiers); | 502 k->set_modifier_flags(computed_modifiers); |
460 if (SystemDictionary::Class_klass_loaded() && (k->oop_is_instance() || k->oop_is_javaArray())) { | 503 if (SystemDictionary::Class_klass_loaded() && (k->oop_is_instance() || k->oop_is_javaArray())) { |
461 // Allocate mirror (java.lang.Class instance) | 504 // Allocate mirror (java.lang.Class instance) |
462 Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0); | 505 Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0); |
463 // Setup indirections | |
464 mirror->obj_field_put(klass_offset, k()); | |
465 k->set_java_mirror(mirror()); | |
466 | 506 |
467 instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass()); | 507 instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass()); |
468 java_lang_Class::set_oop_size(mirror(), mk->instance_size(k)); | |
469 java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror())); | 508 java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror())); |
470 | 509 |
471 // It might also have a component mirror. This mirror must already exist. | 510 // It might also have a component mirror. This mirror must already exist. |
472 if (k->oop_is_javaArray()) { | 511 if (k->oop_is_javaArray()) { |
473 Handle comp_mirror; | 512 Handle comp_mirror; |
501 } | 540 } |
502 | 541 |
503 | 542 |
504 | 543 |
505 int java_lang_Class::oop_size(oop java_class) { | 544 int java_lang_Class::oop_size(oop java_class) { |
506 assert(oop_size_offset != 0, "must be set"); | 545 assert(_oop_size_offset != 0, "must be set"); |
507 return java_class->int_field(oop_size_offset); | 546 return java_class->int_field(_oop_size_offset); |
508 } | 547 } |
509 void java_lang_Class::set_oop_size(oop java_class, int size) { | 548 void java_lang_Class::set_oop_size(oop java_class, int size) { |
510 assert(oop_size_offset != 0, "must be set"); | 549 assert(_oop_size_offset != 0, "must be set"); |
511 java_class->int_field_put(oop_size_offset, size); | 550 java_class->int_field_put(_oop_size_offset, size); |
512 } | 551 } |
513 int java_lang_Class::static_oop_field_count(oop java_class) { | 552 int java_lang_Class::static_oop_field_count(oop java_class) { |
514 assert(static_oop_field_count_offset != 0, "must be set"); | 553 assert(_static_oop_field_count_offset != 0, "must be set"); |
515 return java_class->int_field(static_oop_field_count_offset); | 554 return java_class->int_field(_static_oop_field_count_offset); |
516 } | 555 } |
517 void java_lang_Class::set_static_oop_field_count(oop java_class, int size) { | 556 void java_lang_Class::set_static_oop_field_count(oop java_class, int size) { |
518 assert(static_oop_field_count_offset != 0, "must be set"); | 557 assert(_static_oop_field_count_offset != 0, "must be set"); |
519 java_class->int_field_put(static_oop_field_count_offset, size); | 558 java_class->int_field_put(_static_oop_field_count_offset, size); |
520 } | 559 } |
521 | |
522 | |
523 | |
524 | 560 |
525 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { | 561 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { |
526 // This should be improved by adding a field at the Java level or by | 562 // This should be improved by adding a field at the Java level or by |
527 // introducing a new VM klass (see comment in ClassFileParser) | 563 // introducing a new VM klass (see comment in ClassFileParser) |
528 oop java_class = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance((oop)NULL, CHECK_0); | 564 oop java_class = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance((oop)NULL, CHECK_0); |
529 if (type != T_VOID) { | 565 if (type != T_VOID) { |
530 klassOop aklass = Universe::typeArrayKlassObj(type); | 566 klassOop aklass = Universe::typeArrayKlassObj(type); |
531 assert(aklass != NULL, "correct bootstrap"); | 567 assert(aklass != NULL, "correct bootstrap"); |
532 set_array_klass(java_class, aklass); | 568 set_array_klass(java_class, aklass); |
533 } | 569 } |
570 #ifdef ASSERT | |
534 instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass()); | 571 instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass()); |
535 java_lang_Class::set_oop_size(java_class, mk->instance_size(oop(NULL))); | 572 assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation"); |
536 java_lang_Class::set_static_oop_field_count(java_class, 0); | 573 #endif |
537 return java_class; | 574 return java_class; |
538 } | 575 } |
539 | 576 |
540 | 577 |
541 klassOop java_lang_Class::as_klassOop(oop java_class) { | 578 klassOop java_lang_Class::as_klassOop(oop java_class) { |
542 //%note memory_2 | 579 //%note memory_2 |
543 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); | 580 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
544 klassOop k = klassOop(java_class->obj_field(klass_offset)); | 581 klassOop k = klassOop(java_class->obj_field(_klass_offset)); |
545 assert(k == NULL || k->is_klass(), "type check"); | 582 assert(k == NULL || k->is_klass(), "type check"); |
546 return k; | 583 return k; |
584 } | |
585 | |
586 | |
587 void java_lang_Class::set_klass(oop java_class, klassOop klass) { | |
588 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); | |
589 java_class->obj_field_put(_klass_offset, klass); | |
547 } | 590 } |
548 | 591 |
549 | 592 |
550 void java_lang_Class::print_signature(oop java_class, outputStream* st) { | 593 void java_lang_Class::print_signature(oop java_class, outputStream* st) { |
551 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); | 594 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
595 return name; | 638 return name; |
596 } | 639 } |
597 | 640 |
598 | 641 |
599 klassOop java_lang_Class::array_klass(oop java_class) { | 642 klassOop java_lang_Class::array_klass(oop java_class) { |
600 klassOop k = klassOop(java_class->obj_field(array_klass_offset)); | 643 klassOop k = klassOop(java_class->obj_field(_array_klass_offset)); |
601 assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass"); | 644 assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass"); |
602 return k; | 645 return k; |
603 } | 646 } |
604 | 647 |
605 | 648 |
606 void java_lang_Class::set_array_klass(oop java_class, klassOop klass) { | 649 void java_lang_Class::set_array_klass(oop java_class, klassOop klass) { |
607 assert(klass->is_klass() && Klass::cast(klass)->oop_is_javaArray(), "should be array klass"); | 650 assert(klass->is_klass() && Klass::cast(klass)->oop_is_javaArray(), "should be array klass"); |
608 java_class->obj_field_put(array_klass_offset, klass); | 651 java_class->obj_field_put(_array_klass_offset, klass); |
609 } | 652 } |
610 | 653 |
611 | 654 |
612 methodOop java_lang_Class::resolved_constructor(oop java_class) { | 655 methodOop java_lang_Class::resolved_constructor(oop java_class) { |
613 oop constructor = java_class->obj_field(resolved_constructor_offset); | 656 oop constructor = java_class->obj_field(_resolved_constructor_offset); |
614 assert(constructor == NULL || constructor->is_method(), "should be method"); | 657 assert(constructor == NULL || constructor->is_method(), "should be method"); |
615 return methodOop(constructor); | 658 return methodOop(constructor); |
616 } | 659 } |
617 | 660 |
618 | 661 |
619 void java_lang_Class::set_resolved_constructor(oop java_class, methodOop constructor) { | 662 void java_lang_Class::set_resolved_constructor(oop java_class, methodOop constructor) { |
620 assert(constructor->is_method(), "should be method"); | 663 assert(constructor->is_method(), "should be method"); |
621 java_class->obj_field_put(resolved_constructor_offset, constructor); | 664 java_class->obj_field_put(_resolved_constructor_offset, constructor); |
622 } | 665 } |
623 | 666 |
624 | 667 |
625 bool java_lang_Class::is_primitive(oop java_class) { | 668 bool java_lang_Class::is_primitive(oop java_class) { |
626 // should assert: | 669 // should assert: |
627 //assert(java_lang_Class::is_instance(java_class), "must be a Class object"); | 670 //assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
628 klassOop k = klassOop(java_class->obj_field(klass_offset)); | 671 klassOop k = klassOop(java_class->obj_field(_klass_offset)); |
629 return k == NULL; | 672 return k == NULL; |
630 } | 673 } |
631 | 674 |
632 | 675 |
633 BasicType java_lang_Class::primitive_type(oop java_class) { | 676 BasicType java_lang_Class::primitive_type(oop java_class) { |
634 assert(java_lang_Class::is_primitive(java_class), "just checking"); | 677 assert(java_lang_Class::is_primitive(java_class), "just checking"); |
635 klassOop ak = klassOop(java_class->obj_field(array_klass_offset)); | 678 klassOop ak = klassOop(java_class->obj_field(_array_klass_offset)); |
636 BasicType type = T_VOID; | 679 BasicType type = T_VOID; |
637 if (ak != NULL) { | 680 if (ak != NULL) { |
638 // Note: create_basic_type_mirror above initializes ak to a non-null value. | 681 // Note: create_basic_type_mirror above initializes ak to a non-null value. |
639 type = arrayKlass::cast(ak)->element_type(); | 682 type = arrayKlass::cast(ak)->element_type(); |
640 } else { | 683 } else { |
665 return mirror; | 708 return mirror; |
666 } | 709 } |
667 | 710 |
668 bool java_lang_Class::offsets_computed = false; | 711 bool java_lang_Class::offsets_computed = false; |
669 int java_lang_Class::classRedefinedCount_offset = -1; | 712 int java_lang_Class::classRedefinedCount_offset = -1; |
670 int java_lang_Class::parallelCapable_offset = -1; | |
671 | 713 |
672 void java_lang_Class::compute_offsets() { | 714 void java_lang_Class::compute_offsets() { |
673 assert(!offsets_computed, "offsets should be initialized only once"); | 715 assert(!offsets_computed, "offsets should be initialized only once"); |
674 offsets_computed = true; | 716 offsets_computed = true; |
675 | 717 |
676 klassOop k = SystemDictionary::Class_klass(); | 718 klassOop klass_oop = SystemDictionary::Class_klass(); |
677 // The classRedefinedCount field is only present starting in 1.5, | 719 // The classRedefinedCount field is only present starting in 1.5, |
678 // so don't go fatal. | 720 // so don't go fatal. |
679 compute_optional_offset(classRedefinedCount_offset, | 721 compute_optional_offset(classRedefinedCount_offset, |
680 k, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); | 722 klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); |
681 | 723 |
682 // The field indicating parallelCapable (parallelLockMap) is only present starting in 7, | 724 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
683 klassOop k1 = SystemDictionary::ClassLoader_klass(); | |
684 compute_optional_offset(parallelCapable_offset, | |
685 k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature()); | |
686 } | |
687 | |
688 // For class loader classes, parallelCapable defined | |
689 // based on non-null field | |
690 // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it | |
691 bool java_lang_Class::parallelCapable(oop class_loader) { | |
692 if (!JDK_Version::is_gte_jdk17x_version() | |
693 || parallelCapable_offset == -1) { | |
694 // Default for backward compatibility is false | |
695 return false; | |
696 } | |
697 return (class_loader->obj_field(parallelCapable_offset) != NULL); | |
698 } | 725 } |
699 | 726 |
700 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { | 727 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { |
701 if (!JDK_Version::is_gte_jdk15x_version() | 728 if (!JDK_Version::is_gte_jdk15x_version() |
702 || classRedefinedCount_offset == -1) { | 729 || classRedefinedCount_offset == -1) { |
1017 compute_offset(_vmAllowSuspension_offset, k, vmSymbols::vmAllowSuspension_name(), vmSymbols::bool_signature()); | 1044 compute_offset(_vmAllowSuspension_offset, k, vmSymbols::vmAllowSuspension_name(), vmSymbols::bool_signature()); |
1018 compute_offset(_nthreads_offset, k, vmSymbols::nthreads_name(), vmSymbols::int_signature()); | 1045 compute_offset(_nthreads_offset, k, vmSymbols::nthreads_name(), vmSymbols::int_signature()); |
1019 compute_offset(_ngroups_offset, k, vmSymbols::ngroups_name(), vmSymbols::int_signature()); | 1046 compute_offset(_ngroups_offset, k, vmSymbols::ngroups_name(), vmSymbols::int_signature()); |
1020 } | 1047 } |
1021 | 1048 |
1049 oop java_lang_Throwable::unassigned_stacktrace() { | |
1050 instanceKlass* ik = instanceKlass::cast(SystemDictionary::Throwable_klass()); | |
1051 address addr = ik->static_field_addr(static_unassigned_stacktrace_offset); | |
1052 if (UseCompressedOops) { | |
1053 return oopDesc::load_decode_heap_oop((narrowOop *)addr); | |
1054 } else { | |
1055 return oopDesc::load_decode_heap_oop((oop*)addr); | |
1056 } | |
1057 } | |
1058 | |
1022 oop java_lang_Throwable::backtrace(oop throwable) { | 1059 oop java_lang_Throwable::backtrace(oop throwable) { |
1023 return throwable->obj_field_acquire(backtrace_offset); | 1060 return throwable->obj_field_acquire(backtrace_offset); |
1024 } | 1061 } |
1025 | 1062 |
1026 | 1063 |
1042 void java_lang_Throwable::set_message(oop throwable, oop value) { | 1079 void java_lang_Throwable::set_message(oop throwable, oop value) { |
1043 throwable->obj_field_put(detailMessage_offset, value); | 1080 throwable->obj_field_put(detailMessage_offset, value); |
1044 } | 1081 } |
1045 | 1082 |
1046 | 1083 |
1084 void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) { | |
1085 throwable->obj_field_put(stackTrace_offset, st_element_array); | |
1086 } | |
1087 | |
1047 void java_lang_Throwable::clear_stacktrace(oop throwable) { | 1088 void java_lang_Throwable::clear_stacktrace(oop throwable) { |
1048 assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4"); | 1089 assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4"); |
1049 throwable->obj_field_put(stackTrace_offset, NULL); | 1090 set_stacktrace(throwable, NULL); |
1050 } | 1091 } |
1051 | 1092 |
1052 | 1093 |
1053 void java_lang_Throwable::print(oop throwable, outputStream* st) { | 1094 void java_lang_Throwable::print(oop throwable, outputStream* st) { |
1054 ResourceMark rm; | 1095 ResourceMark rm; |
1108 // Neither soucename and linenumber | 1149 // Neither soucename and linenumber |
1109 sprintf(buf + (int)strlen(buf), "(Unknown Source)"); | 1150 sprintf(buf + (int)strlen(buf), "(Unknown Source)"); |
1110 } | 1151 } |
1111 nmethod* nm = method->code(); | 1152 nmethod* nm = method->code(); |
1112 if (WizardMode && nm != NULL) { | 1153 if (WizardMode && nm != NULL) { |
1113 sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm); | 1154 sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm); |
1114 } | 1155 } |
1115 } | 1156 } |
1116 | 1157 |
1117 return buf; | 1158 return buf; |
1118 } | 1159 } |
1256 Handle _backtrace; | 1297 Handle _backtrace; |
1257 objArrayOop _head; | 1298 objArrayOop _head; |
1258 objArrayOop _methods; | 1299 objArrayOop _methods; |
1259 typeArrayOop _bcis; | 1300 typeArrayOop _bcis; |
1260 int _index; | 1301 int _index; |
1261 bool _dirty; | |
1262 No_Safepoint_Verifier _nsv; | 1302 No_Safepoint_Verifier _nsv; |
1263 | 1303 |
1264 public: | 1304 public: |
1265 | 1305 |
1266 enum { | 1306 enum { |
1270 trace_size = java_lang_Throwable::trace_size, | 1310 trace_size = java_lang_Throwable::trace_size, |
1271 trace_chunk_size = java_lang_Throwable::trace_chunk_size | 1311 trace_chunk_size = java_lang_Throwable::trace_chunk_size |
1272 }; | 1312 }; |
1273 | 1313 |
1274 // constructor for new backtrace | 1314 // constructor for new backtrace |
1275 BacktraceBuilder(TRAPS): _methods(NULL), _bcis(NULL), _head(NULL), _dirty(false) { | 1315 BacktraceBuilder(TRAPS): _methods(NULL), _bcis(NULL), _head(NULL) { |
1276 expand(CHECK); | 1316 expand(CHECK); |
1277 _backtrace = _head; | 1317 _backtrace = _head; |
1278 _index = 0; | 1318 _index = 0; |
1279 } | 1319 } |
1280 | 1320 |
1281 void flush() { | |
1282 // The following appears to have been an optimization to save from | |
1283 // doing a barrier for each individual store into the _methods array, | |
1284 // but rather to do it for the entire array after the series of writes. | |
1285 // That optimization seems to have been lost when compressed oops was | |
1286 // implemented. However, the extra card-marks below was left in place, | |
1287 // but is now redundant because the individual stores into the | |
1288 // _methods array already execute the barrier code. CR 6918185 has | |
1289 // been filed so the original code may be restored by deferring the | |
1290 // barriers until after the entire sequence of stores, thus re-enabling | |
1291 // the intent of the original optimization. In the meantime the redundant | |
1292 // card mark below is now disabled. | |
1293 if (_dirty && _methods != NULL) { | |
1294 #if 0 | |
1295 BarrierSet* bs = Universe::heap()->barrier_set(); | |
1296 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt"); | |
1297 bs->write_ref_array((HeapWord*)_methods->base(), _methods->length()); | |
1298 #endif | |
1299 _dirty = false; | |
1300 } | |
1301 } | |
1302 | |
1303 void expand(TRAPS) { | 1321 void expand(TRAPS) { |
1304 flush(); | |
1305 | |
1306 objArrayHandle old_head(THREAD, _head); | 1322 objArrayHandle old_head(THREAD, _head); |
1307 Pause_No_Safepoint_Verifier pnsv(&_nsv); | 1323 Pause_No_Safepoint_Verifier pnsv(&_nsv); |
1308 | 1324 |
1309 objArrayOop head = oopFactory::new_objectArray(trace_size, CHECK); | 1325 objArrayOop head = oopFactory::new_objectArray(trace_size, CHECK); |
1310 objArrayHandle new_head(THREAD, head); | 1326 objArrayHandle new_head(THREAD, head); |
1326 _bcis = new_bcis(); | 1342 _bcis = new_bcis(); |
1327 _index = 0; | 1343 _index = 0; |
1328 } | 1344 } |
1329 | 1345 |
1330 oop backtrace() { | 1346 oop backtrace() { |
1331 flush(); | |
1332 return _backtrace(); | 1347 return _backtrace(); |
1333 } | 1348 } |
1334 | 1349 |
1335 inline void push(methodOop method, short bci, TRAPS) { | 1350 inline void push(methodOop method, short bci, TRAPS) { |
1336 if (_index >= trace_chunk_size) { | 1351 if (_index >= trace_chunk_size) { |
1340 } | 1355 } |
1341 | 1356 |
1342 _methods->obj_at_put(_index, method); | 1357 _methods->obj_at_put(_index, method); |
1343 _bcis->ushort_at_put(_index, bci); | 1358 _bcis->ushort_at_put(_index, bci); |
1344 _index++; | 1359 _index++; |
1345 _dirty = true; | |
1346 } | 1360 } |
1347 | 1361 |
1348 methodOop current_method() { | 1362 methodOop current_method() { |
1349 assert(_index >= 0 && _index < trace_chunk_size, "out of range"); | 1363 assert(_index >= 0 && _index < trace_chunk_size, "out of range"); |
1350 return methodOop(_methods->obj_at(_index)); | 1364 return methodOop(_methods->obj_at(_index)); |
1365 // runs out of memory while allocating the stack trace | 1379 // runs out of memory while allocating the stack trace |
1366 set_backtrace(throwable(), NULL); | 1380 set_backtrace(throwable(), NULL); |
1367 if (JDK_Version::is_gte_jdk14x_version()) { | 1381 if (JDK_Version::is_gte_jdk14x_version()) { |
1368 // New since 1.4, clear lazily constructed Java level stacktrace if | 1382 // New since 1.4, clear lazily constructed Java level stacktrace if |
1369 // refilling occurs | 1383 // refilling occurs |
1384 // This is unnecessary in 1.7+ but harmless | |
1370 clear_stacktrace(throwable()); | 1385 clear_stacktrace(throwable()); |
1371 } | 1386 } |
1372 | 1387 |
1373 int max_depth = MaxJavaStackTraceDepth; | 1388 int max_depth = MaxJavaStackTraceDepth; |
1374 JavaThread* thread = (JavaThread*)THREAD; | 1389 JavaThread* thread = (JavaThread*)THREAD; |
1566 chunk_count++; | 1581 chunk_count++; |
1567 | 1582 |
1568 // Bail-out for deep stacks | 1583 // Bail-out for deep stacks |
1569 if (chunk_count >= max_chunks) break; | 1584 if (chunk_count >= max_chunks) break; |
1570 } | 1585 } |
1586 | |
1587 // For Java 7+ we support the Throwable immutability protocol defined for Java 7. This support | |
1588 // was missing in 7u0 so in 7u0 there is a workaround in the Throwable class. That workaround | |
1589 // can be removed in a JDK using this JVM version | |
1590 if (JDK_Version::is_gte_jdk17x_version()) { | |
1591 java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace()); | |
1592 assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized"); | |
1593 } | |
1594 | |
1571 } | 1595 } |
1572 | 1596 |
1573 | 1597 |
1574 int java_lang_Throwable::get_stack_trace_depth(oop throwable, TRAPS) { | 1598 int java_lang_Throwable::get_stack_trace_depth(oop throwable, TRAPS) { |
1575 if (throwable == NULL) { | 1599 if (throwable == NULL) { |
2308 // Support for java_lang_invoke_MethodHandle | 2332 // Support for java_lang_invoke_MethodHandle |
2309 | 2333 |
2310 int java_lang_invoke_MethodHandle::_type_offset; | 2334 int java_lang_invoke_MethodHandle::_type_offset; |
2311 int java_lang_invoke_MethodHandle::_vmtarget_offset; | 2335 int java_lang_invoke_MethodHandle::_vmtarget_offset; |
2312 int java_lang_invoke_MethodHandle::_vmentry_offset; | 2336 int java_lang_invoke_MethodHandle::_vmentry_offset; |
2313 int java_lang_invoke_MethodHandle::_vmslots_offset; | |
2314 | 2337 |
2315 int java_lang_invoke_MemberName::_clazz_offset; | 2338 int java_lang_invoke_MemberName::_clazz_offset; |
2316 int java_lang_invoke_MemberName::_name_offset; | 2339 int java_lang_invoke_MemberName::_name_offset; |
2317 int java_lang_invoke_MemberName::_type_offset; | 2340 int java_lang_invoke_MemberName::_type_offset; |
2318 int java_lang_invoke_MemberName::_flags_offset; | 2341 int java_lang_invoke_MemberName::_flags_offset; |
2324 int java_lang_invoke_BoundMethodHandle::_argument_offset; | 2347 int java_lang_invoke_BoundMethodHandle::_argument_offset; |
2325 int java_lang_invoke_BoundMethodHandle::_vmargslot_offset; | 2348 int java_lang_invoke_BoundMethodHandle::_vmargslot_offset; |
2326 | 2349 |
2327 int java_lang_invoke_AdapterMethodHandle::_conversion_offset; | 2350 int java_lang_invoke_AdapterMethodHandle::_conversion_offset; |
2328 | 2351 |
2352 int java_lang_invoke_CountingMethodHandle::_vmcount_offset; | |
2353 | |
2329 void java_lang_invoke_MethodHandle::compute_offsets() { | 2354 void java_lang_invoke_MethodHandle::compute_offsets() { |
2330 klassOop k = SystemDictionary::MethodHandle_klass(); | 2355 klassOop klass_oop = SystemDictionary::MethodHandle_klass(); |
2331 if (k != NULL && EnableInvokeDynamic) { | 2356 if (klass_oop != NULL && EnableInvokeDynamic) { |
2332 bool allow_super = false; | 2357 bool allow_super = false; |
2333 compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::java_lang_invoke_MethodType_signature(), allow_super); | 2358 compute_offset(_type_offset, klass_oop, vmSymbols::type_name(), vmSymbols::java_lang_invoke_MethodType_signature(), allow_super); |
2334 compute_offset(_vmtarget_offset, k, vmSymbols::vmtarget_name(), vmSymbols::object_signature(), allow_super); | 2359 METHODHANDLE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
2335 compute_offset(_vmentry_offset, k, vmSymbols::vmentry_name(), vmSymbols::machine_word_signature(), allow_super); | |
2336 | |
2337 // Note: MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots. | |
2338 // It is optional pending experiments to keep or toss. | |
2339 compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), allow_super); | |
2340 } | 2360 } |
2341 } | 2361 } |
2342 | 2362 |
2343 void java_lang_invoke_MemberName::compute_offsets() { | 2363 void java_lang_invoke_MemberName::compute_offsets() { |
2344 klassOop k = SystemDictionary::MemberName_klass(); | 2364 klassOop klass_oop = SystemDictionary::MemberName_klass(); |
2345 if (k != NULL && EnableInvokeDynamic) { | 2365 if (klass_oop != NULL && EnableInvokeDynamic) { |
2346 compute_offset(_clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); | 2366 compute_offset(_clazz_offset, klass_oop, vmSymbols::clazz_name(), vmSymbols::class_signature()); |
2347 compute_offset(_name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature()); | 2367 compute_offset(_name_offset, klass_oop, vmSymbols::name_name(), vmSymbols::string_signature()); |
2348 compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::object_signature()); | 2368 compute_offset(_type_offset, klass_oop, vmSymbols::type_name(), vmSymbols::object_signature()); |
2349 compute_offset(_flags_offset, k, vmSymbols::flags_name(), vmSymbols::int_signature()); | 2369 compute_offset(_flags_offset, klass_oop, vmSymbols::flags_name(), vmSymbols::int_signature()); |
2350 compute_offset(_vmtarget_offset, k, vmSymbols::vmtarget_name(), vmSymbols::object_signature()); | 2370 compute_offset(_vmindex_offset, klass_oop, vmSymbols::vmindex_name(), vmSymbols::int_signature()); |
2351 compute_offset(_vmindex_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature()); | 2371 MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
2352 } | 2372 } |
2353 } | 2373 } |
2354 | 2374 |
2355 void java_lang_invoke_DirectMethodHandle::compute_offsets() { | 2375 void java_lang_invoke_DirectMethodHandle::compute_offsets() { |
2356 klassOop k = SystemDictionary::DirectMethodHandle_klass(); | 2376 klassOop k = SystemDictionary::DirectMethodHandle_klass(); |
2357 if (k != NULL && EnableInvokeDynamic) { | 2377 if (k != NULL && EnableInvokeDynamic) { |
2358 compute_offset(_vmindex_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature(), true); | 2378 DIRECTMETHODHANDLE_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
2359 } | 2379 } |
2360 } | 2380 } |
2361 | 2381 |
2362 void java_lang_invoke_BoundMethodHandle::compute_offsets() { | 2382 void java_lang_invoke_BoundMethodHandle::compute_offsets() { |
2363 klassOop k = SystemDictionary::BoundMethodHandle_klass(); | 2383 klassOop k = SystemDictionary::BoundMethodHandle_klass(); |
2372 if (k != NULL && EnableInvokeDynamic) { | 2392 if (k != NULL && EnableInvokeDynamic) { |
2373 compute_offset(_conversion_offset, k, vmSymbols::conversion_name(), vmSymbols::int_signature(), true); | 2393 compute_offset(_conversion_offset, k, vmSymbols::conversion_name(), vmSymbols::int_signature(), true); |
2374 } | 2394 } |
2375 } | 2395 } |
2376 | 2396 |
2397 void java_lang_invoke_CountingMethodHandle::compute_offsets() { | |
2398 klassOop k = SystemDictionary::CountingMethodHandle_klass(); | |
2399 if (k != NULL && EnableInvokeDynamic) { | |
2400 compute_offset(_vmcount_offset, k, vmSymbols::vmcount_name(), vmSymbols::int_signature(), true); | |
2401 } | |
2402 } | |
2403 | |
2404 int java_lang_invoke_CountingMethodHandle::vmcount(oop mh) { | |
2405 assert(is_instance(mh), "CMH only"); | |
2406 return mh->int_field(_vmcount_offset); | |
2407 } | |
2408 | |
2409 void java_lang_invoke_CountingMethodHandle::set_vmcount(oop mh, int count) { | |
2410 assert(is_instance(mh), "CMH only"); | |
2411 mh->int_field_put(_vmcount_offset, count); | |
2412 } | |
2413 | |
2377 oop java_lang_invoke_MethodHandle::type(oop mh) { | 2414 oop java_lang_invoke_MethodHandle::type(oop mh) { |
2378 return mh->obj_field(_type_offset); | 2415 return mh->obj_field(_type_offset); |
2379 } | 2416 } |
2380 | 2417 |
2381 void java_lang_invoke_MethodHandle::set_type(oop mh, oop mtype) { | 2418 void java_lang_invoke_MethodHandle::set_type(oop mh, oop mtype) { |
2382 mh->obj_field_put(_type_offset, mtype); | 2419 mh->obj_field_put(_type_offset, mtype); |
2383 } | 2420 } |
2384 | 2421 |
2385 int java_lang_invoke_MethodHandle::vmslots(oop mh) { | |
2386 int vmslots_offset = _vmslots_offset; | |
2387 if (vmslots_offset != 0) { | |
2388 #ifdef ASSERT | |
2389 int x = mh->int_field(vmslots_offset); | |
2390 int y = compute_vmslots(mh); | |
2391 assert(x == y, "correct hoisted value"); | |
2392 #endif | |
2393 return mh->int_field(vmslots_offset); | |
2394 } else { | |
2395 return compute_vmslots(mh); | |
2396 } | |
2397 } | |
2398 | |
2399 // if MH.vmslots exists, hoist into it the value of type.form.vmslots | |
2400 void java_lang_invoke_MethodHandle::init_vmslots(oop mh) { | |
2401 int vmslots_offset = _vmslots_offset; | |
2402 if (vmslots_offset != 0) { | |
2403 mh->int_field_put(vmslots_offset, compute_vmslots(mh)); | |
2404 } | |
2405 } | |
2406 | |
2407 // fetch type.form.vmslots, which is the number of JVM stack slots | 2422 // fetch type.form.vmslots, which is the number of JVM stack slots |
2408 // required to carry the arguments of this MH | 2423 // required to carry the arguments of this MH |
2409 int java_lang_invoke_MethodHandle::compute_vmslots(oop mh) { | 2424 int java_lang_invoke_MethodHandle::vmslots(oop mh) { |
2410 oop mtype = type(mh); | 2425 oop mtype = type(mh); |
2411 if (mtype == NULL) return 0; // Java code would get NPE | 2426 if (mtype == NULL) return 0; // Java code would get NPE |
2412 oop form = java_lang_invoke_MethodType::form(mtype); | 2427 oop form = java_lang_invoke_MethodType::form(mtype); |
2413 if (form == NULL) return 0; // Java code would get NPE | 2428 if (form == NULL) return 0; // Java code would get NPE |
2414 return java_lang_invoke_MethodTypeForm::vmslots(form); | 2429 return java_lang_invoke_MethodTypeForm::vmslots(form); |
2624 compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true); | 2639 compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true); |
2625 compute_optional_offset(_vmlayout_offset, k, vmSymbols::vmlayout_name(), vmSymbols::object_signature()); | 2640 compute_optional_offset(_vmlayout_offset, k, vmSymbols::vmlayout_name(), vmSymbols::object_signature()); |
2626 compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_lang_invoke_MethodType_signature(), true); | 2641 compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_lang_invoke_MethodType_signature(), true); |
2627 compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_lang_invoke_MethodHandle_signature(), true); | 2642 compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_lang_invoke_MethodHandle_signature(), true); |
2628 if (_genericInvoker_offset == 0) _genericInvoker_offset = -1; // set to explicit "empty" value | 2643 if (_genericInvoker_offset == 0) _genericInvoker_offset = -1; // set to explicit "empty" value |
2644 METHODTYPEFORM_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); | |
2629 } | 2645 } |
2630 } | 2646 } |
2631 | 2647 |
2632 int java_lang_invoke_MethodTypeForm::vmslots(oop mtform) { | 2648 int java_lang_invoke_MethodTypeForm::vmslots(oop mtform) { |
2633 assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only"); | 2649 assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only"); |
2675 if (!EnableInvokeDynamic) return; | 2691 if (!EnableInvokeDynamic) return; |
2676 klassOop k = SystemDictionary::CallSite_klass(); | 2692 klassOop k = SystemDictionary::CallSite_klass(); |
2677 if (k != NULL) { | 2693 if (k != NULL) { |
2678 compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature()); | 2694 compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature()); |
2679 } | 2695 } |
2680 } | 2696 |
2681 | 2697 // Disallow compilation of CallSite.setTargetNormal and CallSite.setTargetVolatile |
2682 oop java_lang_invoke_CallSite::target(oop site) { | 2698 // (For C2: keep this until we have throttling logic for uncommon traps.) |
2683 return site->obj_field(_target_offset); | 2699 if (k != NULL) { |
2684 } | 2700 instanceKlass* ik = instanceKlass::cast(k); |
2685 | 2701 methodOop m_normal = ik->lookup_method(vmSymbols::setTargetNormal_name(), vmSymbols::setTarget_signature()); |
2686 void java_lang_invoke_CallSite::set_target(oop site, oop target) { | 2702 methodOop m_volatile = ik->lookup_method(vmSymbols::setTargetVolatile_name(), vmSymbols::setTarget_signature()); |
2687 site->obj_field_put(_target_offset, target); | 2703 guarantee(m_normal != NULL && m_volatile != NULL, "must exist"); |
2704 m_normal->set_not_compilable_quietly(); | |
2705 m_volatile->set_not_compilable_quietly(); | |
2706 } | |
2688 } | 2707 } |
2689 | 2708 |
2690 | 2709 |
2691 // Support for java_security_AccessControlContext | 2710 // Support for java_security_AccessControlContext |
2692 | 2711 |
2729 return result; | 2748 return result; |
2730 } | 2749 } |
2731 | 2750 |
2732 | 2751 |
2733 // Support for java_lang_ClassLoader | 2752 // Support for java_lang_ClassLoader |
2753 bool java_lang_ClassLoader::offsets_computed = false; | |
2754 int java_lang_ClassLoader::parallelCapable_offset = -1; | |
2755 | |
2756 void java_lang_ClassLoader::compute_offsets() { | |
2757 assert(!offsets_computed, "offsets should be initialized only once"); | |
2758 offsets_computed = true; | |
2759 | |
2760 // The field indicating parallelCapable (parallelLockMap) is only present starting in 7, | |
2761 klassOop k1 = SystemDictionary::ClassLoader_klass(); | |
2762 compute_optional_offset(parallelCapable_offset, | |
2763 k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature()); | |
2764 } | |
2734 | 2765 |
2735 oop java_lang_ClassLoader::parent(oop loader) { | 2766 oop java_lang_ClassLoader::parent(oop loader) { |
2736 assert(loader->is_oop(), "loader must be oop"); | 2767 assert(loader->is_oop(), "loader must be oop"); |
2737 return loader->obj_field(parent_offset); | 2768 return loader->obj_field(parent_offset); |
2738 } | 2769 } |
2739 | 2770 |
2771 | |
2772 // For class loader classes, parallelCapable defined | |
2773 // based on non-null field | |
2774 // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it | |
2775 bool java_lang_ClassLoader::parallelCapable(oop class_loader) { | |
2776 if (!JDK_Version::is_gte_jdk17x_version() | |
2777 || parallelCapable_offset == -1) { | |
2778 // Default for backward compatibility is false | |
2779 return false; | |
2780 } | |
2781 return (class_loader->obj_field(parallelCapable_offset) != NULL); | |
2782 } | |
2740 | 2783 |
2741 bool java_lang_ClassLoader::is_trusted_loader(oop loader) { | 2784 bool java_lang_ClassLoader::is_trusted_loader(oop loader) { |
2742 // Fix for 4474172; see evaluation for more details | 2785 // Fix for 4474172; see evaluation for more details |
2743 loader = non_reflection_class_loader(loader); | 2786 loader = non_reflection_class_loader(loader); |
2744 | 2787 |
2785 | 2828 |
2786 int java_lang_String::value_offset; | 2829 int java_lang_String::value_offset; |
2787 int java_lang_String::offset_offset; | 2830 int java_lang_String::offset_offset; |
2788 int java_lang_String::count_offset; | 2831 int java_lang_String::count_offset; |
2789 int java_lang_String::hash_offset; | 2832 int java_lang_String::hash_offset; |
2790 int java_lang_Class::klass_offset; | 2833 int java_lang_Class::_klass_offset; |
2791 int java_lang_Class::array_klass_offset; | 2834 int java_lang_Class::_array_klass_offset; |
2792 int java_lang_Class::resolved_constructor_offset; | 2835 int java_lang_Class::_resolved_constructor_offset; |
2793 int java_lang_Class::number_of_fake_oop_fields; | 2836 int java_lang_Class::_oop_size_offset; |
2794 int java_lang_Class::oop_size_offset; | 2837 int java_lang_Class::_static_oop_field_count_offset; |
2795 int java_lang_Class::static_oop_field_count_offset; | |
2796 int java_lang_Throwable::backtrace_offset; | 2838 int java_lang_Throwable::backtrace_offset; |
2797 int java_lang_Throwable::detailMessage_offset; | 2839 int java_lang_Throwable::detailMessage_offset; |
2798 int java_lang_Throwable::cause_offset; | 2840 int java_lang_Throwable::cause_offset; |
2799 int java_lang_Throwable::stackTrace_offset; | 2841 int java_lang_Throwable::stackTrace_offset; |
2842 int java_lang_Throwable::static_unassigned_stacktrace_offset; | |
2800 int java_lang_reflect_AccessibleObject::override_offset; | 2843 int java_lang_reflect_AccessibleObject::override_offset; |
2801 int java_lang_reflect_Method::clazz_offset; | 2844 int java_lang_reflect_Method::clazz_offset; |
2802 int java_lang_reflect_Method::name_offset; | 2845 int java_lang_reflect_Method::name_offset; |
2803 int java_lang_reflect_Method::returnType_offset; | 2846 int java_lang_reflect_Method::returnType_offset; |
2804 int java_lang_reflect_Method::parameterTypes_offset; | 2847 int java_lang_reflect_Method::parameterTypes_offset; |
2902 return _limit_offset; | 2945 return _limit_offset; |
2903 } | 2946 } |
2904 | 2947 |
2905 | 2948 |
2906 void java_nio_Buffer::compute_offsets() { | 2949 void java_nio_Buffer::compute_offsets() { |
2907 klassOop k = SystemDictionary::java_nio_Buffer_klass(); | 2950 klassOop k = SystemDictionary::nio_Buffer_klass(); |
2908 assert(k != NULL, "must be loaded in 1.4+"); | 2951 assert(k != NULL, "must be loaded in 1.4+"); |
2909 compute_offset(_limit_offset, k, vmSymbols::limit_name(), vmSymbols::int_signature()); | 2952 compute_offset(_limit_offset, k, vmSymbols::limit_name(), vmSymbols::int_signature()); |
2910 } | 2953 } |
2911 | 2954 |
2912 // Support for intrinsification of sun.misc.AtomicLongCSImpl.attemptUpdate | 2955 // Support for intrinsification of sun.misc.AtomicLongCSImpl.attemptUpdate |
2913 int sun_misc_AtomicLongCSImpl::value_offset() { | 2956 int sun_misc_AtomicLongCSImpl::value_offset() { |
2914 assert(SystemDictionary::sun_misc_AtomicLongCSImpl_klass() != NULL, "can't call this"); | 2957 assert(SystemDictionary::AtomicLongCSImpl_klass() != NULL, "can't call this"); |
2915 return _value_offset; | 2958 return _value_offset; |
2916 } | 2959 } |
2917 | 2960 |
2918 | 2961 |
2919 void sun_misc_AtomicLongCSImpl::compute_offsets() { | 2962 void sun_misc_AtomicLongCSImpl::compute_offsets() { |
2920 klassOop k = SystemDictionary::sun_misc_AtomicLongCSImpl_klass(); | 2963 klassOop k = SystemDictionary::AtomicLongCSImpl_klass(); |
2921 // If this class is not present, its value field offset won't be referenced. | 2964 // If this class is not present, its value field offset won't be referenced. |
2922 if (k != NULL) { | 2965 if (k != NULL) { |
2923 compute_offset(_value_offset, k, vmSymbols::value_name(), vmSymbols::long_signature()); | 2966 compute_offset(_value_offset, k, vmSymbols::value_name(), vmSymbols::long_signature()); |
2924 } | 2967 } |
2925 } | 2968 } |
2950 java_lang_String::value_offset = java_lang_String::hc_value_offset * x + header; | 2993 java_lang_String::value_offset = java_lang_String::hc_value_offset * x + header; |
2951 java_lang_String::offset_offset = java_lang_String::hc_offset_offset * x + header; | 2994 java_lang_String::offset_offset = java_lang_String::hc_offset_offset * x + header; |
2952 java_lang_String::count_offset = java_lang_String::offset_offset + sizeof (jint); | 2995 java_lang_String::count_offset = java_lang_String::offset_offset + sizeof (jint); |
2953 java_lang_String::hash_offset = java_lang_String::count_offset + sizeof (jint); | 2996 java_lang_String::hash_offset = java_lang_String::count_offset + sizeof (jint); |
2954 | 2997 |
2955 { | |
2956 // Do the Class Class | |
2957 int offset = header; | |
2958 java_lang_Class::oop_size_offset = header; | |
2959 offset += BytesPerInt; | |
2960 java_lang_Class::static_oop_field_count_offset = offset; | |
2961 offset = align_size_up(offset + BytesPerInt, x); | |
2962 java_lang_Class::klass_offset = offset; | |
2963 offset += x; | |
2964 java_lang_Class::array_klass_offset = offset; | |
2965 offset += x; | |
2966 java_lang_Class::resolved_constructor_offset = offset; | |
2967 } | |
2968 | |
2969 // This is NOT an offset | |
2970 java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields; | |
2971 | |
2972 // Throwable Class | 2998 // Throwable Class |
2973 java_lang_Throwable::backtrace_offset = java_lang_Throwable::hc_backtrace_offset * x + header; | 2999 java_lang_Throwable::backtrace_offset = java_lang_Throwable::hc_backtrace_offset * x + header; |
2974 java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header; | 3000 java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header; |
2975 java_lang_Throwable::cause_offset = java_lang_Throwable::hc_cause_offset * x + header; | 3001 java_lang_Throwable::cause_offset = java_lang_Throwable::hc_cause_offset * x + header; |
2976 java_lang_Throwable::stackTrace_offset = java_lang_Throwable::hc_stackTrace_offset * x + header; | 3002 java_lang_Throwable::stackTrace_offset = java_lang_Throwable::hc_stackTrace_offset * x + header; |
3003 java_lang_Throwable::static_unassigned_stacktrace_offset = java_lang_Throwable::hc_static_unassigned_stacktrace_offset * x; | |
2977 | 3004 |
2978 // java_lang_boxing_object | 3005 // java_lang_boxing_object |
2979 java_lang_boxing_object::value_offset = java_lang_boxing_object::hc_value_offset + header; | 3006 java_lang_boxing_object::value_offset = java_lang_boxing_object::hc_value_offset + header; |
2980 java_lang_boxing_object::long_value_offset = align_size_up((java_lang_boxing_object::hc_value_offset + header), BytesPerLong); | 3007 java_lang_boxing_object::long_value_offset = align_size_up((java_lang_boxing_object::hc_value_offset + header), BytesPerLong); |
2981 | 3008 |
3017 } | 3044 } |
3018 | 3045 |
3019 | 3046 |
3020 // Compute non-hard-coded field offsets of all the classes in this file | 3047 // Compute non-hard-coded field offsets of all the classes in this file |
3021 void JavaClasses::compute_offsets() { | 3048 void JavaClasses::compute_offsets() { |
3022 | 3049 // java_lang_Class::compute_offsets was called earlier in bootstrap |
3023 java_lang_Class::compute_offsets(); | 3050 java_lang_ClassLoader::compute_offsets(); |
3024 java_lang_Thread::compute_offsets(); | 3051 java_lang_Thread::compute_offsets(); |
3025 java_lang_ThreadGroup::compute_offsets(); | 3052 java_lang_ThreadGroup::compute_offsets(); |
3026 if (EnableInvokeDynamic) { | 3053 if (EnableInvokeDynamic) { |
3027 java_lang_invoke_MethodHandle::compute_offsets(); | 3054 java_lang_invoke_MethodHandle::compute_offsets(); |
3028 java_lang_invoke_MemberName::compute_offsets(); | 3055 java_lang_invoke_MemberName::compute_offsets(); |
3030 java_lang_invoke_BoundMethodHandle::compute_offsets(); | 3057 java_lang_invoke_BoundMethodHandle::compute_offsets(); |
3031 java_lang_invoke_AdapterMethodHandle::compute_offsets(); | 3058 java_lang_invoke_AdapterMethodHandle::compute_offsets(); |
3032 java_lang_invoke_MethodType::compute_offsets(); | 3059 java_lang_invoke_MethodType::compute_offsets(); |
3033 java_lang_invoke_MethodTypeForm::compute_offsets(); | 3060 java_lang_invoke_MethodTypeForm::compute_offsets(); |
3034 java_lang_invoke_CallSite::compute_offsets(); | 3061 java_lang_invoke_CallSite::compute_offsets(); |
3062 java_lang_invoke_CountingMethodHandle::compute_offsets(); | |
3035 } | 3063 } |
3036 java_security_AccessControlContext::compute_offsets(); | 3064 java_security_AccessControlContext::compute_offsets(); |
3037 // Initialize reflection classes. The layouts of these classes | 3065 // Initialize reflection classes. The layouts of these classes |
3038 // changed with the new reflection implementation in JDK 1.4, and | 3066 // changed with the new reflection implementation in JDK 1.4, and |
3039 // since the Universe doesn't know what JDK version it is until this | 3067 // since the Universe doesn't know what JDK version it is until this |
3242 if (!valid) vm_exit_during_initialization("Hard-coded field offset verification failed"); | 3270 if (!valid) vm_exit_during_initialization("Hard-coded field offset verification failed"); |
3243 } | 3271 } |
3244 | 3272 |
3245 #endif // PRODUCT | 3273 #endif // PRODUCT |
3246 | 3274 |
3275 int InjectedField::compute_offset() { | |
3276 klassOop klass_oop = klass(); | |
3277 for (AllFieldStream fs(instanceKlass::cast(klass_oop)); !fs.done(); fs.next()) { | |
3278 if (!may_be_java && !fs.access_flags().is_internal()) { | |
3279 // Only look at injected fields | |
3280 continue; | |
3281 } | |
3282 if (fs.name() == name() && fs.signature() == signature()) { | |
3283 return fs.offset(); | |
3284 } | |
3285 } | |
3286 ResourceMark rm; | |
3287 tty->print_cr("Invalid layout of %s at %s", instanceKlass::cast(klass_oop)->external_name(), name()->as_C_string()); | |
3288 fatal("Invalid layout of preloaded class"); | |
3289 return -1; | |
3290 } | |
3291 | |
3247 void javaClasses_init() { | 3292 void javaClasses_init() { |
3248 JavaClasses::compute_offsets(); | 3293 JavaClasses::compute_offsets(); |
3249 JavaClasses::check_offsets(); | 3294 JavaClasses::check_offsets(); |
3250 FilteredFieldsMap::initialize(); // must be done after computing offsets. | 3295 FilteredFieldsMap::initialize(); // must be done after computing offsets. |
3251 } | 3296 } |