src/share/vm/classfile/classFileParser.cpp

changeset 2264
d2e35ffae982
parent 2202
a932f331ef90
child 2268
3b2dea75431e
     1.1 --- a/src/share/vm/classfile/classFileParser.cpp	Fri Oct 22 03:34:25 2010 -0700
     1.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Thu Oct 28 00:48:18 2010 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -2516,18 +2516,6 @@
    1.11    // field.  If it is not present, artifically create a field for it.
    1.12    // This allows this VM to run on early JDK where the field is not
    1.13    // present.
    1.14 -
    1.15 -  //
    1.16 -  // Increment fac.nonstatic_oop_count so that the start of the
    1.17 -  // next type of non-static oops leaves room for the fake oop.
    1.18 -  // Do not increment next_nonstatic_oop_offset so that the
    1.19 -  // fake oop is place after the java.lang.ref.Reference oop
    1.20 -  // fields.
    1.21 -  //
    1.22 -  // Check the fields in java.lang.ref.Reference for the "discovered"
    1.23 -  // field.  If it is not present, artifically create a field for it.
    1.24 -  // This allows this VM to run on early JDK where the field is not
    1.25 -  // present.
    1.26    int reference_sig_index = 0;
    1.27    int reference_name_index = 0;
    1.28    int reference_index = 0;
    1.29 @@ -2663,7 +2651,7 @@
    1.30  // Force MethodHandle.vmentry to be an unmanaged pointer.
    1.31  // There is no way for a classfile to express this, so we must help it.
    1.32  void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
    1.33 -                                                    typeArrayHandle* fields_ptr,
    1.34 +                                                    typeArrayHandle fields,
    1.35                                                      FieldAllocationCount *fac_ptr,
    1.36                                                      TRAPS) {
    1.37    // Add fake fields for java.dyn.MethodHandle instances
    1.38 @@ -2687,41 +2675,45 @@
    1.39      THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
    1.40                "missing I or J signature (for vmentry) in java.dyn.MethodHandle");
    1.41  
    1.42 +  // Find vmentry field and change the signature.
    1.43    bool found_vmentry = false;
    1.44 -
    1.45 -  const int n = (*fields_ptr)()->length();
    1.46 -  for (int i = 0; i < n; i += instanceKlass::next_offset) {
    1.47 -    int name_index = (*fields_ptr)->ushort_at(i + instanceKlass::name_index_offset);
    1.48 -    int sig_index  = (*fields_ptr)->ushort_at(i + instanceKlass::signature_index_offset);
    1.49 -    int acc_flags  = (*fields_ptr)->ushort_at(i + instanceKlass::access_flags_offset);
    1.50 +  for (int i = 0; i < fields->length(); i += instanceKlass::next_offset) {
    1.51 +    int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
    1.52 +    int sig_index  = fields->ushort_at(i + instanceKlass::signature_index_offset);
    1.53 +    int acc_flags  = fields->ushort_at(i + instanceKlass::access_flags_offset);
    1.54      symbolOop f_name = cp->symbol_at(name_index);
    1.55      symbolOop f_sig  = cp->symbol_at(sig_index);
    1.56 -    if (f_sig == vmSymbols::byte_signature() &&
    1.57 -        f_name == vmSymbols::vmentry_name() &&
    1.58 -        (acc_flags & JVM_ACC_STATIC) == 0) {
    1.59 -      // Adjust the field type from byte to an unmanaged pointer.
    1.60 -      assert(fac_ptr->nonstatic_byte_count > 0, "");
    1.61 -      fac_ptr->nonstatic_byte_count -= 1;
    1.62 -
    1.63 -      (*fields_ptr)->ushort_at_put(i + instanceKlass::signature_index_offset, word_sig_index);
    1.64 -      assert(wordSize == longSize || wordSize == jintSize, "ILP32 or LP64");
    1.65 -      if (wordSize == longSize)  fac_ptr->nonstatic_double_count += 1;
    1.66 -      else                       fac_ptr->nonstatic_word_count   += 1;
    1.67 -
    1.68 -      FieldAllocationType atype = (FieldAllocationType) (*fields_ptr)->ushort_at(i + instanceKlass::low_offset);
    1.69 -      assert(atype == NONSTATIC_BYTE, "");
    1.70 -      FieldAllocationType new_atype = (wordSize == longSize) ? NONSTATIC_DOUBLE : NONSTATIC_WORD;
    1.71 -      (*fields_ptr)->ushort_at_put(i + instanceKlass::low_offset, new_atype);
    1.72 -
    1.73 -      found_vmentry = true;
    1.74 -      break;
    1.75 +
    1.76 +    if (f_name == vmSymbols::vmentry_name() && (acc_flags & JVM_ACC_STATIC) == 0) {
    1.77 +      if (f_sig == vmSymbols::machine_word_signature()) {
    1.78 +        // If the signature of vmentry is already changed, we're done.
    1.79 +        found_vmentry = true;
    1.80 +        break;
    1.81 +      }
    1.82 +      else if (f_sig == vmSymbols::byte_signature()) {
    1.83 +        // Adjust the field type from byte to an unmanaged pointer.
    1.84 +        assert(fac_ptr->nonstatic_byte_count > 0, "");
    1.85 +        fac_ptr->nonstatic_byte_count -= 1;
    1.86 +
    1.87 +        fields->ushort_at_put(i + instanceKlass::signature_index_offset, word_sig_index);
    1.88 +        assert(wordSize == longSize || wordSize == jintSize, "ILP32 or LP64");
    1.89 +        if (wordSize == longSize)  fac_ptr->nonstatic_double_count += 1;
    1.90 +        else                       fac_ptr->nonstatic_word_count   += 1;
    1.91 +
    1.92 +        FieldAllocationType atype = (FieldAllocationType) fields->ushort_at(i + instanceKlass::low_offset);
    1.93 +        assert(atype == NONSTATIC_BYTE, "");
    1.94 +        FieldAllocationType new_atype = (wordSize == longSize) ? NONSTATIC_DOUBLE : NONSTATIC_WORD;
    1.95 +        fields->ushort_at_put(i + instanceKlass::low_offset, new_atype);
    1.96 +
    1.97 +        found_vmentry = true;
    1.98 +        break;
    1.99 +      }
   1.100      }
   1.101    }
   1.102  
   1.103    if (!found_vmentry)
   1.104      THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
   1.105                "missing vmentry byte field in java.dyn.MethodHandle");
   1.106 -
   1.107  }
   1.108  
   1.109  
   1.110 @@ -3082,7 +3074,7 @@
   1.111  
   1.112      // adjust the vmentry field declaration in java.dyn.MethodHandle
   1.113      if (EnableMethodHandles && class_name() == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
   1.114 -      java_dyn_MethodHandle_fix_pre(cp, &fields, &fac, CHECK_(nullHandle));
   1.115 +      java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
   1.116      }
   1.117  
   1.118      // Add a fake "discovered" field if it is not present

mercurial