1 /* |
1 /* |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2019, 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. |
39 #include "runtime/handles.inline.hpp" |
39 #include "runtime/handles.inline.hpp" |
40 #include "runtime/java.hpp" |
40 #include "runtime/java.hpp" |
41 #include "runtime/os.hpp" |
41 #include "runtime/os.hpp" |
42 #include "runtime/safepointVerifiers.hpp" |
42 #include "runtime/safepointVerifiers.hpp" |
43 #include "runtime/sharedRuntime.hpp" |
43 #include "runtime/sharedRuntime.hpp" |
|
44 #include "utilities/sizes.hpp" |
44 #include "utilities/xmlstream.hpp" |
45 #include "utilities/xmlstream.hpp" |
45 |
46 |
46 #include <stdio.h> |
47 #include <stdio.h> |
47 |
48 |
48 #if 0 |
49 #if 0 |
86 Klass* k = (Klass*)(meta & ~1); |
87 Klass* k = (Klass*)(meta & ~1); |
87 return k->java_mirror(); |
88 return k->java_mirror(); |
88 } |
89 } |
89 // The entry is string which we need to resolve. |
90 // The entry is string which we need to resolve. |
90 const char* meta_name = _heap->get_name_at((int)meta); |
91 const char* meta_name = _heap->get_name_at((int)meta); |
91 int klass_len = build_u2_from((address)meta_name); |
92 int klass_len = Bytes::get_Java_u2((address)meta_name); |
92 const char* klass_name = meta_name + 2; |
93 const char* klass_name = meta_name + 2; |
93 // Quick check the current method's holder. |
94 // Quick check the current method's holder. |
94 Klass* k = _method->method_holder(); |
95 Klass* k = _method->method_holder(); |
95 |
96 |
96 ResourceMark rm; // for signature_name() |
97 ResourceMark rm; // for signature_name() |
97 if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match? |
98 if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match? |
98 // Search klass in got cells in DSO which have this compiled method. |
99 // Search klass in got cells in DSO which have this compiled method. |
99 k = _heap->get_klass_from_got(klass_name, klass_len, _method); |
100 k = _heap->get_klass_from_got(klass_name, klass_len, _method); |
100 } |
101 } |
101 int method_name_len = build_u2_from((address)klass_name + klass_len); |
102 int method_name_len = Bytes::get_Java_u2((address)klass_name + klass_len); |
102 guarantee(method_name_len == 0, "only klass is expected here"); |
103 guarantee(method_name_len == 0, "only klass is expected here"); |
103 meta = ((intptr_t)k) | 1; |
104 meta = ((intptr_t)k) | 1; |
104 *entry = (Metadata*)meta; // Should be atomic on x64 |
105 *entry = (Metadata*)meta; // Should be atomic on x64 |
105 return k->java_mirror(); |
106 return k->java_mirror(); |
106 } |
107 } |
118 Metadata *m = (Metadata*)(meta & ~1); |
119 Metadata *m = (Metadata*)(meta & ~1); |
119 return m; |
120 return m; |
120 } |
121 } |
121 // The entry is string which we need to resolve. |
122 // The entry is string which we need to resolve. |
122 const char* meta_name = _heap->get_name_at((int)meta); |
123 const char* meta_name = _heap->get_name_at((int)meta); |
123 int klass_len = build_u2_from((address)meta_name); |
124 int klass_len = Bytes::get_Java_u2((address)meta_name); |
124 const char* klass_name = meta_name + 2; |
125 const char* klass_name = meta_name + 2; |
125 // Quick check the current method's holder. |
126 // Quick check the current method's holder. |
126 Klass* k = _method->method_holder(); |
127 Klass* k = _method->method_holder(); |
127 bool klass_matched = true; |
128 bool klass_matched = true; |
128 |
129 |
130 if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match? |
131 if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match? |
131 // Search klass in got cells in DSO which have this compiled method. |
132 // Search klass in got cells in DSO which have this compiled method. |
132 k = _heap->get_klass_from_got(klass_name, klass_len, _method); |
133 k = _heap->get_klass_from_got(klass_name, klass_len, _method); |
133 klass_matched = false; |
134 klass_matched = false; |
134 } |
135 } |
135 int method_name_len = build_u2_from((address)klass_name + klass_len); |
136 int method_name_len = Bytes::get_Java_u2((address)klass_name + klass_len); |
136 if (method_name_len == 0) { // Array or Klass name only? |
137 if (method_name_len == 0) { // Array or Klass name only? |
137 meta = ((intptr_t)k) | 1; |
138 meta = ((intptr_t)k) | 1; |
138 *entry = (Metadata*)meta; // Should be atomic on x64 |
139 *entry = (Metadata*)meta; // Should be atomic on x64 |
139 return (Metadata*)k; |
140 return (Metadata*)k; |
140 } else { // Method |
141 } else { // Method |
141 // Quick check the current method's name. |
142 // Quick check the current method's name. |
142 Method* m = _method; |
143 Method* m = _method; |
143 int signature_len = build_u2_from((address)klass_name + klass_len + 2 + method_name_len); |
144 int signature_len = Bytes::get_Java_u2((address)klass_name + klass_len + 2 + method_name_len); |
144 int full_len = 2 + klass_len + 2 + method_name_len + 2 + signature_len; |
145 int full_len = 2 + klass_len + 2 + method_name_len + 2 + signature_len; |
145 if (!klass_matched || memcmp(_name, meta_name, full_len) != 0) { // Does not match? |
146 if (!klass_matched || memcmp(_name, meta_name, full_len) != 0) { // Does not match? |
146 Thread* thread = Thread::current(); |
147 Thread* thread = Thread::current(); |
147 const char* method_name = klass_name + klass_len; |
148 const char* method_name = klass_name + klass_len; |
148 m = AOTCodeHeap::find_method(k, thread, method_name); |
149 m = AOTCodeHeap::find_method(k, thread, method_name); |