comparison src/share/vm/prims/methodComparator.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 3582bf76420e
children
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 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.
30 #include "runtime/handles.inline.hpp" 30 #include "runtime/handles.inline.hpp"
31 #include "utilities/globalDefinitions.hpp" 31 #include "utilities/globalDefinitions.hpp"
32 32
33 BytecodeStream *MethodComparator::_s_old; 33 BytecodeStream *MethodComparator::_s_old;
34 BytecodeStream *MethodComparator::_s_new; 34 BytecodeStream *MethodComparator::_s_new;
35 constantPoolOop MethodComparator::_old_cp; 35 ConstantPool* MethodComparator::_old_cp;
36 constantPoolOop MethodComparator::_new_cp; 36 ConstantPool* MethodComparator::_new_cp;
37 BciMap *MethodComparator::_bci_map; 37 BciMap *MethodComparator::_bci_map;
38 bool MethodComparator::_switchable_test; 38 bool MethodComparator::_switchable_test;
39 GrowableArray<int> *MethodComparator::_fwd_jmps; 39 GrowableArray<int> *MethodComparator::_fwd_jmps;
40 40
41 bool MethodComparator::methods_EMCP(methodOop old_method, methodOop new_method) { 41 bool MethodComparator::methods_EMCP(Method* old_method, Method* new_method) {
42 if (old_method->code_size() != new_method->code_size()) 42 if (old_method->code_size() != new_method->code_size())
43 return false; 43 return false;
44 if (check_stack_and_locals_size(old_method, new_method) != 0) { 44 if (check_stack_and_locals_size(old_method, new_method) != 0) {
45 // RC_TRACE macro has an embedded ResourceMark 45 // RC_TRACE macro has an embedded ResourceMark
46 RC_TRACE(0x00800000, ("Methods %s non-comparable with diagnosis %d", 46 RC_TRACE(0x00800000, ("Methods %s non-comparable with diagnosis %d",
67 } 67 }
68 return true; 68 return true;
69 } 69 }
70 70
71 71
72 bool MethodComparator::methods_switchable(methodOop old_method, methodOop new_method, 72 bool MethodComparator::methods_switchable(Method* old_method, Method* new_method,
73 BciMap &bci_map) { 73 BciMap &bci_map) {
74 if (old_method->code_size() > new_method->code_size()) 74 if (old_method->code_size() > new_method->code_size())
75 // Something has definitely been deleted in the new method, compared to the old one. 75 // Something has definitely been deleted in the new method, compared to the old one.
76 return false; 76 return false;
77 77
165 break; 165 break;
166 } 166 }
167 case Bytecodes::_invokedynamic: { 167 case Bytecodes::_invokedynamic: {
168 int cpci_old = _s_old->get_index_u4(); 168 int cpci_old = _s_old->get_index_u4();
169 int cpci_new = _s_new->get_index_u4(); 169 int cpci_new = _s_new->get_index_u4();
170
170 // Check if the names of classes, field/method names and signatures at these indexes 171 // Check if the names of classes, field/method names and signatures at these indexes
171 // are the same. Indices which are really into constantpool cache (rather than constant 172 // are the same. Indices which are really into constantpool cache (rather than constant
172 // pool itself) are accepted by the constantpool query routines below. 173 // pool itself) are accepted by the constantpool query routines below.
173 if ((_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) || 174 if ((_old_cp->name_ref_at(cpci_old) != _new_cp->name_ref_at(cpci_new)) ||
174 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new))) 175 (_old_cp->signature_ref_at(cpci_old) != _new_cp->signature_ref_at(cpci_new)))
175 return false; 176 return false;
176 int cpi_old = _old_cp->cache()->main_entry_at(cpci_old)->constant_pool_index(); 177
177 int cpi_new = _new_cp->cache()->main_entry_at(cpci_new)->constant_pool_index(); 178 // Translate object indexes to constant pool cache indexes.
179 cpci_old = _old_cp->invokedynamic_cp_cache_index(cpci_old);
180 cpci_new = _new_cp->invokedynamic_cp_cache_index(cpci_new);
181
182 int cpi_old = _old_cp->cache()->entry_at(cpci_old)->constant_pool_index();
183 int cpi_new = _new_cp->cache()->entry_at(cpci_new)->constant_pool_index();
178 int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old); 184 int bsm_old = _old_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_old);
179 int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new); 185 int bsm_new = _new_cp->invoke_dynamic_bootstrap_method_ref_index_at(cpi_new);
180 if (!pool_constants_same(bsm_old, bsm_new)) 186 if (!pool_constants_same(bsm_old, bsm_new))
181 return false; 187 return false;
182 int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old); 188 int cnt_old = _old_cp->invoke_dynamic_argument_count_at(cpi_old);
393 // Use jint_cast to compare the bits rather than numerical values. 399 // Use jint_cast to compare the bits rather than numerical values.
394 // This makes a difference for NaN constants. 400 // This makes a difference for NaN constants.
395 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new))) 401 if (jint_cast(_old_cp->float_at(cpi_old)) != jint_cast(_new_cp->float_at(cpi_new)))
396 return false; 402 return false;
397 } 403 }
398 } else if (tag_old.is_string() || tag_old.is_unresolved_string()) { 404 } else if (tag_old.is_string() && tag_new.is_string()) {
399 if (! (tag_new.is_unresolved_string() || tag_new.is_string()))
400 return false;
401 if (strcmp(_old_cp->string_at_noresolve(cpi_old), 405 if (strcmp(_old_cp->string_at_noresolve(cpi_old),
402 _new_cp->string_at_noresolve(cpi_new)) != 0) 406 _new_cp->string_at_noresolve(cpi_new)) != 0)
403 return false; 407 return false;
404 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) { 408 } else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) {
405 // tag_old should be klass - 4881222 409 // tag_old should be klass - 4881222
428 } 432 }
429 return true; 433 return true;
430 } 434 }
431 435
432 436
433 int MethodComparator::check_stack_and_locals_size(methodOop old_method, methodOop new_method) { 437 int MethodComparator::check_stack_and_locals_size(Method* old_method, Method* new_method) {
434 if (old_method->max_stack() != new_method->max_stack()) { 438 if (old_method->max_stack() != new_method->max_stack()) {
435 return 1; 439 return 1;
436 } else if (old_method->max_locals() != new_method->max_locals()) { 440 } else if (old_method->max_locals() != new_method->max_locals()) {
437 return 2; 441 return 2;
438 } else if (old_method->size_of_parameters() != new_method->size_of_parameters()) { 442 } else if (old_method->size_of_parameters() != new_method->size_of_parameters()) {