1043 AnnotationArray* _field_annotations;
1044 AnnotationArray* _field_type_annotations;
1045 public:
1046 FieldAnnotationCollector(ClassLoaderData* loader_data) :
1047 AnnotationCollector(_in_field),
1048 _loader_data(loader_data),
1049 _field_annotations(NULL),
1050 _field_type_annotations(NULL) {}
1051 ~FieldAnnotationCollector();
1052 void apply_to(FieldInfo* f);
1053 AnnotationArray* field_annotations() { return _field_annotations; }
1054 AnnotationArray* field_type_annotations() { return _field_type_annotations; }
1055
1056 void set_field_annotations(AnnotationArray* a) { _field_annotations = a; }
1057 void set_field_type_annotations(AnnotationArray* a) { _field_type_annotations = a; }
1058 };
1059
1060 class MethodAnnotationCollector : public AnnotationCollector{
1061 public:
1062 MethodAnnotationCollector() : AnnotationCollector(_in_method) { }
1063 void apply_to(methodHandle m);
1064 };
1065
1066 class ClassFileParser::ClassAnnotationCollector : public AnnotationCollector{
1067 public:
1068 ClassAnnotationCollector() : AnnotationCollector(_in_class) { }
1069 void apply_to(InstanceKlass* ik);
1070 };
1071
1072
1073 static int skip_annotation_value(const u1*, int, int); // fwd decl
1074
1075 // Safely increment index by val if does not pass limit
1076 #define SAFE_ADD(index, limit, val) \
1077 if (index >= limit - val) return limit; \
1078 index += val;
1079
1080 // Skip an annotation. Return >=limit if there is any problem.
1081 static int skip_annotation(const u1* buffer, int limit, int index) {
1082 assert(buffer != NULL, "invariant");
1083 // annotation := atype:u2 do(nmem:u2) {member:u2 value}
2078 default: {
2079 break;
2080 }
2081 }
2082 return AnnotationCollector::_unknown;
2083 }
2084
2085 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
2086 if (is_contended())
2087 f->set_contended_group(contended_group());
2088 if (is_stable())
2089 f->set_stable(true);
2090 }
2091
2092 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
2093 // If there's an error deallocate metadata for field annotations
2094 MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
2095 MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
2096 }
2097
2098 void MethodAnnotationCollector::apply_to(methodHandle m) {
2099 if (has_annotation(_method_CallerSensitive))
2100 m->set_caller_sensitive(true);
2101 if (has_annotation(_method_ForceInline))
2102 m->set_force_inline(true);
2103 if (has_annotation(_method_DontInline))
2104 m->set_dont_inline(true);
2105 if (has_annotation(_method_InjectedProfile))
2106 m->set_has_injected_profile(true);
2107 if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
2108 m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
2109 if (has_annotation(_method_LambdaForm_Hidden))
2110 m->set_hidden(true);
2111 if (has_annotation(_method_HotSpotIntrinsicCandidate) && !m->is_synthetic())
2112 m->set_intrinsic_candidate(true);
2113 if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
2114 m->set_has_reserved_stack_access(true);
2115 }
2116
2117 void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
2118 assert(ik != NULL, "invariant");
3615
3616 const int next_offset = last_map->offset() + last_map->count() * heapOopSize;
3617 if (next_offset == first_nonstatic_oop_offset) {
3618 // There is no gap bettwen superklass's last oop field and first
3619 // local oop field, merge maps.
3620 nonstatic_oop_map_count -= 1;
3621 }
3622 else {
3623 // Superklass didn't end with a oop field, add extra maps
3624 assert(next_offset < first_nonstatic_oop_offset, "just checking");
3625 }
3626 map_count += nonstatic_oop_map_count;
3627 }
3628 }
3629 return map_count;
3630 }
3631
3632 #ifndef PRODUCT
3633 static void print_field_layout(const Symbol* name,
3634 Array<u2>* fields,
3635 constantPoolHandle cp,
3636 int instance_size,
3637 int instance_fields_start,
3638 int instance_fields_end,
3639 int static_fields_end) {
3640
3641 assert(name != NULL, "invariant");
3642
3643 tty->print("%s: field layout\n", name->as_klass_external_name());
3644 tty->print(" @%3d %s\n", instance_fields_start, "--- instance fields start ---");
3645 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
3646 if (!fs.access_flags().is_static()) {
3647 tty->print(" @%3d \"%s\" %s\n",
3648 fs.offset(),
3649 fs.name()->as_klass_external_name(),
3650 fs.signature()->as_klass_external_name());
3651 }
3652 }
3653 tty->print(" @%3d %s\n", instance_fields_end, "--- instance fields end ---");
3654 tty->print(" @%3d %s\n", instance_size * wordSize, "--- instance ends ---");
3655 tty->print(" @%3d %s\n", InstanceMirrorKlass::offset_of_static_fields(), "--- static fields start ---");
|
1043 AnnotationArray* _field_annotations;
1044 AnnotationArray* _field_type_annotations;
1045 public:
1046 FieldAnnotationCollector(ClassLoaderData* loader_data) :
1047 AnnotationCollector(_in_field),
1048 _loader_data(loader_data),
1049 _field_annotations(NULL),
1050 _field_type_annotations(NULL) {}
1051 ~FieldAnnotationCollector();
1052 void apply_to(FieldInfo* f);
1053 AnnotationArray* field_annotations() { return _field_annotations; }
1054 AnnotationArray* field_type_annotations() { return _field_type_annotations; }
1055
1056 void set_field_annotations(AnnotationArray* a) { _field_annotations = a; }
1057 void set_field_type_annotations(AnnotationArray* a) { _field_type_annotations = a; }
1058 };
1059
1060 class MethodAnnotationCollector : public AnnotationCollector{
1061 public:
1062 MethodAnnotationCollector() : AnnotationCollector(_in_method) { }
1063 void apply_to(const methodHandle& m);
1064 };
1065
1066 class ClassFileParser::ClassAnnotationCollector : public AnnotationCollector{
1067 public:
1068 ClassAnnotationCollector() : AnnotationCollector(_in_class) { }
1069 void apply_to(InstanceKlass* ik);
1070 };
1071
1072
1073 static int skip_annotation_value(const u1*, int, int); // fwd decl
1074
1075 // Safely increment index by val if does not pass limit
1076 #define SAFE_ADD(index, limit, val) \
1077 if (index >= limit - val) return limit; \
1078 index += val;
1079
1080 // Skip an annotation. Return >=limit if there is any problem.
1081 static int skip_annotation(const u1* buffer, int limit, int index) {
1082 assert(buffer != NULL, "invariant");
1083 // annotation := atype:u2 do(nmem:u2) {member:u2 value}
2078 default: {
2079 break;
2080 }
2081 }
2082 return AnnotationCollector::_unknown;
2083 }
2084
2085 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
2086 if (is_contended())
2087 f->set_contended_group(contended_group());
2088 if (is_stable())
2089 f->set_stable(true);
2090 }
2091
2092 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
2093 // If there's an error deallocate metadata for field annotations
2094 MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
2095 MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
2096 }
2097
2098 void MethodAnnotationCollector::apply_to(const methodHandle& m) {
2099 if (has_annotation(_method_CallerSensitive))
2100 m->set_caller_sensitive(true);
2101 if (has_annotation(_method_ForceInline))
2102 m->set_force_inline(true);
2103 if (has_annotation(_method_DontInline))
2104 m->set_dont_inline(true);
2105 if (has_annotation(_method_InjectedProfile))
2106 m->set_has_injected_profile(true);
2107 if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
2108 m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
2109 if (has_annotation(_method_LambdaForm_Hidden))
2110 m->set_hidden(true);
2111 if (has_annotation(_method_HotSpotIntrinsicCandidate) && !m->is_synthetic())
2112 m->set_intrinsic_candidate(true);
2113 if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
2114 m->set_has_reserved_stack_access(true);
2115 }
2116
2117 void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
2118 assert(ik != NULL, "invariant");
3615
3616 const int next_offset = last_map->offset() + last_map->count() * heapOopSize;
3617 if (next_offset == first_nonstatic_oop_offset) {
3618 // There is no gap bettwen superklass's last oop field and first
3619 // local oop field, merge maps.
3620 nonstatic_oop_map_count -= 1;
3621 }
3622 else {
3623 // Superklass didn't end with a oop field, add extra maps
3624 assert(next_offset < first_nonstatic_oop_offset, "just checking");
3625 }
3626 map_count += nonstatic_oop_map_count;
3627 }
3628 }
3629 return map_count;
3630 }
3631
3632 #ifndef PRODUCT
3633 static void print_field_layout(const Symbol* name,
3634 Array<u2>* fields,
3635 const constantPoolHandle& cp,
3636 int instance_size,
3637 int instance_fields_start,
3638 int instance_fields_end,
3639 int static_fields_end) {
3640
3641 assert(name != NULL, "invariant");
3642
3643 tty->print("%s: field layout\n", name->as_klass_external_name());
3644 tty->print(" @%3d %s\n", instance_fields_start, "--- instance fields start ---");
3645 for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
3646 if (!fs.access_flags().is_static()) {
3647 tty->print(" @%3d \"%s\" %s\n",
3648 fs.offset(),
3649 fs.name()->as_klass_external_name(),
3650 fs.signature()->as_klass_external_name());
3651 }
3652 }
3653 tty->print(" @%3d %s\n", instance_fields_end, "--- instance fields end ---");
3654 tty->print(" @%3d %s\n", instance_size * wordSize, "--- instance ends ---");
3655 tty->print(" @%3d %s\n", InstanceMirrorKlass::offset_of_static_fields(), "--- static fields start ---");
|