comparison src/share/vm/ci/ciInstanceKlass.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 33df1aeaebbf 49036505ab5f
children e522a00b91aa
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, 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.
57 _init_state = ik->init_state(); 57 _init_state = ik->init_state();
58 _nonstatic_field_size = ik->nonstatic_field_size(); 58 _nonstatic_field_size = ik->nonstatic_field_size();
59 _has_nonstatic_fields = ik->has_nonstatic_fields(); 59 _has_nonstatic_fields = ik->has_nonstatic_fields();
60 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: 60 _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
61 61
62 _nof_implementors = ik->nof_implementors(); 62 _implementor = NULL; // we will fill these lazily
63 for (int i = 0; i < implementors_limit; i++) {
64 _implementors[i] = NULL; // we will fill these lazily
65 }
66 63
67 Thread *thread = Thread::current(); 64 Thread *thread = Thread::current();
68 if (ciObjectFactory::is_initialized()) { 65 if (ciObjectFactory::is_initialized()) {
69 _loader = JNIHandles::make_local(thread, ik->class_loader()); 66 _loader = JNIHandles::make_local(thread, ik->class_loader());
70 _protection_domain = JNIHandles::make_local(thread, 67 _protection_domain = JNIHandles::make_local(thread,
100 assert(name->byte_at(0) != '[', "not an instance klass"); 97 assert(name->byte_at(0) != '[', "not an instance klass");
101 _init_state = (instanceKlass::ClassState)0; 98 _init_state = (instanceKlass::ClassState)0;
102 _nonstatic_field_size = -1; 99 _nonstatic_field_size = -1;
103 _has_nonstatic_fields = false; 100 _has_nonstatic_fields = false;
104 _nonstatic_fields = NULL; 101 _nonstatic_fields = NULL;
105 _nof_implementors = -1;
106 _loader = loader; 102 _loader = loader;
107 _protection_domain = protection_domain; 103 _protection_domain = protection_domain;
108 _is_shared = false; 104 _is_shared = false;
109 _super = NULL; 105 _super = NULL;
110 _java_mirror = NULL; 106 _java_mirror = NULL;
127 bool ciInstanceKlass::compute_shared_has_subklass() { 123 bool ciInstanceKlass::compute_shared_has_subklass() {
128 GUARDED_VM_ENTRY( 124 GUARDED_VM_ENTRY(
129 instanceKlass* ik = get_instanceKlass(); 125 instanceKlass* ik = get_instanceKlass();
130 _has_subklass = ik->subklass() != NULL; 126 _has_subklass = ik->subklass() != NULL;
131 return _has_subklass; 127 return _has_subklass;
132 )
133 }
134
135 // ------------------------------------------------------------------
136 // ciInstanceKlass::compute_shared_nof_implementors
137 int ciInstanceKlass::compute_shared_nof_implementors() {
138 // We requery this property, since it is a very old ciObject.
139 GUARDED_VM_ENTRY(
140 instanceKlass* ik = get_instanceKlass();
141 _nof_implementors = ik->nof_implementors();
142 return _nof_implementors;
143 ) 128 )
144 } 129 }
145 130
146 // ------------------------------------------------------------------ 131 // ------------------------------------------------------------------
147 // ciInstanceKlass::loader 132 // ciInstanceKlass::loader
538 bool ciInstanceKlass::is_leaf_type() { 523 bool ciInstanceKlass::is_leaf_type() {
539 assert(is_loaded(), "must be loaded"); 524 assert(is_loaded(), "must be loaded");
540 if (is_shared()) { 525 if (is_shared()) {
541 return is_final(); // approximately correct 526 return is_final(); // approximately correct
542 } else { 527 } else {
543 return !_has_subklass && (_nof_implementors == 0); 528 return !_has_subklass && (nof_implementors() == 0);
544 } 529 }
545 } 530 }
546 531
547 // ------------------------------------------------------------------ 532 // ------------------------------------------------------------------
548 // ciInstanceKlass::implementor 533 // ciInstanceKlass::implementor
549 // 534 //
550 // Report an implementor of this interface. 535 // Report an implementor of this interface.
551 // Returns NULL if exact information is not available.
552 // Note that there are various races here, since my copy 536 // Note that there are various races here, since my copy
553 // of _nof_implementors might be out of date with respect 537 // of _nof_implementors might be out of date with respect
554 // to results returned by instanceKlass::implementor. 538 // to results returned by instanceKlass::implementor.
555 // This is OK, since any dependencies we decide to assert 539 // This is OK, since any dependencies we decide to assert
556 // will be checked later under the Compile_lock. 540 // will be checked later under the Compile_lock.
557 ciInstanceKlass* ciInstanceKlass::implementor(int n) { 541 ciInstanceKlass* ciInstanceKlass::implementor() {
558 if (n >= implementors_limit) { 542 ciInstanceKlass* impl = _implementor;
559 return NULL;
560 }
561 ciInstanceKlass* impl = _implementors[n];
562 if (impl == NULL) { 543 if (impl == NULL) {
563 if (_nof_implementors > implementors_limit) {
564 return NULL;
565 }
566 // Go into the VM to fetch the implementor. 544 // Go into the VM to fetch the implementor.
567 { 545 {
568 VM_ENTRY_MARK; 546 VM_ENTRY_MARK;
569 klassOop k = get_instanceKlass()->implementor(n); 547 klassOop k = get_instanceKlass()->implementor();
570 if (k != NULL) { 548 if (k != NULL) {
571 impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass(); 549 if (k == get_instanceKlass()->as_klassOop()) {
550 // More than one implementors. Use 'this' in this case.
551 impl = this;
552 } else {
553 impl = CURRENT_THREAD_ENV->get_object(k)->as_instance_klass();
554 }
572 } 555 }
573 } 556 }
574 // Memoize this result. 557 // Memoize this result.
575 if (!is_shared()) { 558 if (!is_shared()) {
576 _implementors[n] = (impl == NULL)? this: impl; 559 _implementor = impl;
577 } 560 }
578 } else if (impl == this) {
579 impl = NULL; // memoized null result from a VM query
580 } 561 }
581 return impl; 562 return impl;
582 } 563 }