Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/javaClasses.cpp @ 2356:72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
Summary: consolidate runtime support in java.dyn.MethodHandleNatives; include transitional compatibility logic
Reviewed-by: twisti
author | jrose |
---|---|
date | Fri, 11 Mar 2011 22:33:47 -0800 |
parents | 3582bf76420e |
children | 8033953d67ff |
comparison
equal
deleted
inserted
replaced
2355:799d8ccf63cf | 2356:72dee110246f |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2011, 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. |
63 if (allow_super) | 63 if (allow_super) |
64 return ik->find_field(name_symbol, signature_symbol, fd) != NULL; | 64 return ik->find_field(name_symbol, signature_symbol, fd) != NULL; |
65 else | 65 else |
66 return ik->find_local_field(name_symbol, signature_symbol, fd); | 66 return ik->find_local_field(name_symbol, signature_symbol, fd); |
67 } | 67 } |
68 | |
69 static bool find_hacked_field(instanceKlass* ik, | |
70 Symbol* name_symbol, Symbol* signature_symbol, | |
71 fieldDescriptor* fd, | |
72 bool allow_super = false) { | |
73 bool found = find_field(ik, name_symbol, signature_symbol, fd, allow_super); | |
74 if (!found && AllowTransitionalJSR292) { | |
75 Symbol* backup_sig = SystemDictionary::find_backup_signature(signature_symbol); | |
76 if (backup_sig != NULL) { | |
77 found = find_field(ik, name_symbol, backup_sig, fd, allow_super); | |
78 if (TraceMethodHandles) { | |
79 ResourceMark rm; | |
80 tty->print_cr("MethodHandles: %s.%s: backup for %s => %s%s", | |
81 ik->name()->as_C_string(), name_symbol->as_C_string(), | |
82 signature_symbol->as_C_string(), backup_sig->as_C_string(), | |
83 (found ? "" : " (NOT FOUND)")); | |
84 } | |
85 } | |
86 } | |
87 return found; | |
88 } | |
89 #define find_field find_hacked_field /* remove after AllowTransitionalJSR292 */ | |
68 | 90 |
69 // Helpful routine for computing field offsets at run time rather than hardcoding them | 91 // Helpful routine for computing field offsets at run time rather than hardcoding them |
70 static void | 92 static void |
71 compute_offset(int &dest_offset, | 93 compute_offset(int &dest_offset, |
72 klassOop klass_oop, Symbol* name_symbol, Symbol* signature_symbol, | 94 klassOop klass_oop, Symbol* name_symbol, Symbol* signature_symbol, |
2198 int sun_dyn_AdapterMethodHandle::_conversion_offset; | 2220 int sun_dyn_AdapterMethodHandle::_conversion_offset; |
2199 | 2221 |
2200 void java_dyn_MethodHandle::compute_offsets() { | 2222 void java_dyn_MethodHandle::compute_offsets() { |
2201 klassOop k = SystemDictionary::MethodHandle_klass(); | 2223 klassOop k = SystemDictionary::MethodHandle_klass(); |
2202 if (k != NULL && EnableMethodHandles) { | 2224 if (k != NULL && EnableMethodHandles) { |
2203 compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::java_dyn_MethodType_signature(), true); | 2225 bool allow_super = false; |
2204 compute_offset(_vmtarget_offset, k, vmSymbols::vmtarget_name(), vmSymbols::object_signature(), true); | 2226 if (AllowTransitionalJSR292) allow_super = true; // temporary, to access sun.dyn.MethodHandleImpl |
2205 compute_offset(_vmentry_offset, k, vmSymbols::vmentry_name(), vmSymbols::machine_word_signature(), true); | 2227 compute_offset(_type_offset, k, vmSymbols::type_name(), vmSymbols::java_dyn_MethodType_signature(), allow_super); |
2228 compute_offset(_vmtarget_offset, k, vmSymbols::vmtarget_name(), vmSymbols::object_signature(), allow_super); | |
2229 compute_offset(_vmentry_offset, k, vmSymbols::vmentry_name(), vmSymbols::machine_word_signature(), allow_super); | |
2206 | 2230 |
2207 // Note: MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots. | 2231 // Note: MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots. |
2208 // It is optional pending experiments to keep or toss. | 2232 // It is optional pending experiments to keep or toss. |
2209 compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true); | 2233 compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), allow_super); |
2210 } | 2234 } |
2211 } | 2235 } |
2212 | 2236 |
2213 void sun_dyn_MemberName::compute_offsets() { | 2237 void sun_dyn_MemberName::compute_offsets() { |
2214 klassOop k = SystemDictionary::MemberName_klass(); | 2238 klassOop k = SystemDictionary::MemberName_klass(); |
2502 | 2526 |
2503 | 2527 |
2504 // Support for java_dyn_CallSite | 2528 // Support for java_dyn_CallSite |
2505 | 2529 |
2506 int java_dyn_CallSite::_target_offset; | 2530 int java_dyn_CallSite::_target_offset; |
2507 int java_dyn_CallSite::_caller_method_offset; | |
2508 int java_dyn_CallSite::_caller_bci_offset; | |
2509 | 2531 |
2510 void java_dyn_CallSite::compute_offsets() { | 2532 void java_dyn_CallSite::compute_offsets() { |
2511 if (!EnableInvokeDynamic) return; | 2533 if (!EnableInvokeDynamic) return; |
2512 klassOop k = SystemDictionary::CallSite_klass(); | 2534 klassOop k = SystemDictionary::CallSite_klass(); |
2513 if (k != NULL) { | 2535 if (k != NULL) { |
2514 compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_dyn_MethodHandle_signature()); | 2536 compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_dyn_MethodHandle_signature()); |
2515 compute_offset(_caller_method_offset, k, vmSymbols::vmmethod_name(), vmSymbols::sun_dyn_MemberName_signature()); | |
2516 compute_offset(_caller_bci_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature()); | |
2517 } | 2537 } |
2518 } | 2538 } |
2519 | 2539 |
2520 oop java_dyn_CallSite::target(oop site) { | 2540 oop java_dyn_CallSite::target(oop site) { |
2521 return site->obj_field(_target_offset); | 2541 return site->obj_field(_target_offset); |
2522 } | 2542 } |
2523 | 2543 |
2524 void java_dyn_CallSite::set_target(oop site, oop target) { | 2544 void java_dyn_CallSite::set_target(oop site, oop target) { |
2525 site->obj_field_put(_target_offset, target); | 2545 site->obj_field_put(_target_offset, target); |
2526 } | |
2527 | |
2528 oop java_dyn_CallSite::caller_method(oop site) { | |
2529 return site->obj_field(_caller_method_offset); | |
2530 } | |
2531 | |
2532 void java_dyn_CallSite::set_caller_method(oop site, oop ref) { | |
2533 site->obj_field_put(_caller_method_offset, ref); | |
2534 } | |
2535 | |
2536 jint java_dyn_CallSite::caller_bci(oop site) { | |
2537 return site->int_field(_caller_bci_offset); | |
2538 } | |
2539 | |
2540 void java_dyn_CallSite::set_caller_bci(oop site, jint bci) { | |
2541 site->int_field_put(_caller_bci_offset, bci); | |
2542 } | 2546 } |
2543 | 2547 |
2544 | 2548 |
2545 // Support for java_security_AccessControlContext | 2549 // Support for java_security_AccessControlContext |
2546 | 2550 |