Tue, 11 Nov 2014 11:05:41 +0100
8056071: compiler/whitebox/IsMethodCompilableTest.java fails with 'method() is not compilable after 3 iterations'
Summary: Always use MDO if valid and always compile trivial methods with C1 if available.
Reviewed-by: kvn, iveresov
coleenp@4037 | 1 | /* |
drchase@6680 | 2 | * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
coleenp@4037 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
coleenp@4037 | 4 | * |
coleenp@4037 | 5 | * This code is free software; you can redistribute it and/or modify it |
coleenp@4037 | 6 | * under the terms of the GNU General Public License version 2 only, as |
coleenp@4037 | 7 | * published by the Free Software Foundation. |
coleenp@4037 | 8 | * |
coleenp@4037 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
coleenp@4037 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
coleenp@4037 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
coleenp@4037 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
coleenp@4037 | 13 | * accompanied this code). |
coleenp@4037 | 14 | * |
coleenp@4037 | 15 | * You should have received a copy of the GNU General Public License version |
coleenp@4037 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
coleenp@4037 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
coleenp@4037 | 18 | * |
coleenp@4037 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
coleenp@4037 | 20 | * or visit www.oracle.com if you need additional information or have any |
coleenp@4037 | 21 | * questions. |
coleenp@4037 | 22 | * |
coleenp@4037 | 23 | */ |
coleenp@4037 | 24 | |
coleenp@4037 | 25 | #include "precompiled.hpp" |
coleenp@4037 | 26 | #include "classfile/classLoaderData.hpp" |
acorn@4497 | 27 | #include "memory/heapInspection.hpp" |
coleenp@4037 | 28 | #include "memory/metadataFactory.hpp" |
coleenp@4037 | 29 | #include "memory/oopFactory.hpp" |
coleenp@4037 | 30 | #include "oops/annotations.hpp" |
coleenp@4037 | 31 | #include "oops/instanceKlass.hpp" |
coleenp@4037 | 32 | #include "utilities/ostream.hpp" |
coleenp@4037 | 33 | |
coleenp@4037 | 34 | // Allocate annotations in metadata area |
coleenp@4037 | 35 | Annotations* Annotations::allocate(ClassLoaderData* loader_data, TRAPS) { |
iklam@5208 | 36 | return new (loader_data, size(), true, MetaspaceObj::AnnotationType, THREAD) Annotations(); |
coleenp@4037 | 37 | } |
coleenp@4037 | 38 | |
coleenp@4037 | 39 | // helper |
coleenp@4572 | 40 | void Annotations::free_contents(ClassLoaderData* loader_data, Array<AnnotationArray*>* p) { |
coleenp@4037 | 41 | if (p != NULL) { |
coleenp@4037 | 42 | for (int i = 0; i < p->length(); i++) { |
coleenp@4037 | 43 | MetadataFactory::free_array<u1>(loader_data, p->at(i)); |
coleenp@4037 | 44 | } |
coleenp@4037 | 45 | MetadataFactory::free_array<AnnotationArray*>(loader_data, p); |
coleenp@4037 | 46 | } |
coleenp@4037 | 47 | } |
coleenp@4037 | 48 | |
coleenp@4037 | 49 | void Annotations::deallocate_contents(ClassLoaderData* loader_data) { |
coleenp@4037 | 50 | if (class_annotations() != NULL) { |
coleenp@4037 | 51 | MetadataFactory::free_array<u1>(loader_data, class_annotations()); |
coleenp@4037 | 52 | } |
coleenp@4037 | 53 | free_contents(loader_data, fields_annotations()); |
stefank@4393 | 54 | |
coleenp@4572 | 55 | if (class_type_annotations() != NULL) { |
coleenp@4572 | 56 | MetadataFactory::free_array<u1>(loader_data, class_type_annotations()); |
coleenp@4572 | 57 | } |
coleenp@4572 | 58 | free_contents(loader_data, fields_type_annotations()); |
coleenp@4037 | 59 | } |
coleenp@4037 | 60 | |
coleenp@4037 | 61 | // Copy annotations to JVM call or reflection to the java heap. |
coleenp@4572 | 62 | // The alternative to creating this array and adding to Java heap pressure |
coleenp@4572 | 63 | // is to have a hashtable of the already created typeArrayOops |
coleenp@4037 | 64 | typeArrayOop Annotations::make_java_array(AnnotationArray* annotations, TRAPS) { |
coleenp@4037 | 65 | if (annotations != NULL) { |
coleenp@4037 | 66 | int length = annotations->length(); |
coleenp@4037 | 67 | typeArrayOop copy = oopFactory::new_byteArray(length, CHECK_NULL); |
coleenp@4037 | 68 | for (int i = 0; i< length; i++) { |
coleenp@4037 | 69 | copy->byte_at_put(i, annotations->at(i)); |
coleenp@4037 | 70 | } |
coleenp@4037 | 71 | return copy; |
coleenp@4037 | 72 | } else { |
coleenp@4037 | 73 | return NULL; |
coleenp@4037 | 74 | } |
coleenp@4037 | 75 | } |
coleenp@4037 | 76 | |
coleenp@4037 | 77 | |
coleenp@4037 | 78 | void Annotations::print_value_on(outputStream* st) const { |
drchase@6680 | 79 | st->print("Anotations(" INTPTR_FORMAT ")", p2i(this)); |
coleenp@4037 | 80 | } |
coleenp@4037 | 81 | |
acorn@4497 | 82 | #if INCLUDE_SERVICES |
acorn@4497 | 83 | // Size Statistics |
acorn@4497 | 84 | |
acorn@4497 | 85 | julong Annotations::count_bytes(Array<AnnotationArray*>* p) { |
acorn@4497 | 86 | julong bytes = 0; |
acorn@4497 | 87 | if (p != NULL) { |
acorn@4497 | 88 | for (int i = 0; i < p->length(); i++) { |
acorn@4497 | 89 | bytes += KlassSizeStats::count_array(p->at(i)); |
acorn@4497 | 90 | } |
acorn@4497 | 91 | bytes += KlassSizeStats::count_array(p); |
acorn@4497 | 92 | } |
acorn@4497 | 93 | return bytes; |
acorn@4497 | 94 | } |
acorn@4497 | 95 | |
acorn@4497 | 96 | void Annotations::collect_statistics(KlassSizeStats *sz) const { |
acorn@4497 | 97 | sz->_annotations_bytes = sz->count(this); |
acorn@4497 | 98 | sz->_class_annotations_bytes = sz->count(class_annotations()); |
coleenp@4572 | 99 | sz->_class_type_annotations_bytes = sz->count(class_type_annotations()); |
acorn@4497 | 100 | sz->_fields_annotations_bytes = count_bytes(fields_annotations()); |
coleenp@4572 | 101 | sz->_fields_type_annotations_bytes = count_bytes(fields_type_annotations()); |
acorn@4497 | 102 | |
acorn@4497 | 103 | sz->_annotations_bytes += |
acorn@4497 | 104 | sz->_class_annotations_bytes + |
coleenp@4572 | 105 | sz->_class_type_annotations_bytes + |
acorn@4497 | 106 | sz->_fields_annotations_bytes + |
coleenp@4572 | 107 | sz->_fields_type_annotations_bytes; |
acorn@4497 | 108 | |
acorn@4497 | 109 | sz->_ro_bytes += sz->_annotations_bytes; |
acorn@4497 | 110 | } |
acorn@4497 | 111 | #endif // INCLUDE_SERVICES |
acorn@4497 | 112 | |
coleenp@4037 | 113 | #define BULLET " - " |
coleenp@4037 | 114 | |
coleenp@4037 | 115 | #ifndef PRODUCT |
coleenp@4037 | 116 | void Annotations::print_on(outputStream* st) const { |
coleenp@4037 | 117 | st->print(BULLET"class_annotations "); class_annotations()->print_value_on(st); |
coleenp@4037 | 118 | st->print(BULLET"fields_annotations "); fields_annotations()->print_value_on(st); |
coleenp@4572 | 119 | st->print(BULLET"class_type_annotations "); class_type_annotations()->print_value_on(st); |
coleenp@4572 | 120 | st->print(BULLET"fields_type_annotations "); fields_type_annotations()->print_value_on(st); |
coleenp@4037 | 121 | } |
coleenp@4037 | 122 | #endif // PRODUCT |