Merge

Fri, 13 Sep 2013 16:56:58 -0700

author
sspitsyn
date
Fri, 13 Sep 2013 16:56:58 -0700
changeset 5678
b135b600a66c
parent 5674
b89a1a870965
parent 5677
0d3ff4d36a31
child 5679
2e6938dd68f2

Merge

     1.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Sep 13 19:20:59 2013 +0200
     1.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Sep 13 16:56:58 2013 -0700
     1.3 @@ -1072,8 +1072,17 @@
     1.4      }
     1.5  
     1.6      res = merge_cp_and_rewrite(the_class, scratch_class, THREAD);
     1.7 -    if (res != JVMTI_ERROR_NONE) {
     1.8 -      return res;
     1.9 +    if (HAS_PENDING_EXCEPTION) {
    1.10 +      Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
    1.11 +      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
    1.12 +      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
    1.13 +        ("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string()));
    1.14 +      CLEAR_PENDING_EXCEPTION;
    1.15 +      if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
    1.16 +        return JVMTI_ERROR_OUT_OF_MEMORY;
    1.17 +      } else {
    1.18 +        return JVMTI_ERROR_INTERNAL;
    1.19 +      }
    1.20      }
    1.21  
    1.22      if (VerifyMergedCPBytecodes) {
    1.23 @@ -1105,6 +1114,9 @@
    1.24      }
    1.25      if (HAS_PENDING_EXCEPTION) {
    1.26        Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
    1.27 +      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
    1.28 +      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
    1.29 +        ("Rewriter::rewrite or link_methods exception: '%s'", ex_name->as_C_string()));
    1.30        CLEAR_PENDING_EXCEPTION;
    1.31        if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
    1.32          return JVMTI_ERROR_OUT_OF_MEMORY;
    1.33 @@ -1395,8 +1407,8 @@
    1.34    ClassLoaderData* loader_data = the_class->class_loader_data();
    1.35    ConstantPool* merge_cp_oop =
    1.36      ConstantPool::allocate(loader_data,
    1.37 -                                  merge_cp_length,
    1.38 -                                  THREAD);
    1.39 +                           merge_cp_length,
    1.40 +                           CHECK_(JVMTI_ERROR_OUT_OF_MEMORY));
    1.41    MergeCPCleaner cp_cleaner(loader_data, merge_cp_oop);
    1.42  
    1.43    HandleMark hm(THREAD);  // make sure handles are cleared before
    1.44 @@ -1472,7 +1484,8 @@
    1.45  
    1.46        // Replace the new constant pool with a shrunken copy of the
    1.47        // merged constant pool
    1.48 -      set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, THREAD);
    1.49 +      set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length,
    1.50 +                            CHECK_(JVMTI_ERROR_OUT_OF_MEMORY));
    1.51        // The new constant pool replaces scratch_cp so have cleaner clean it up.
    1.52        // It can't be cleaned up while there are handles to it.
    1.53        cp_cleaner.add_scratch_cp(scratch_cp());
    1.54 @@ -1502,7 +1515,8 @@
    1.55      // merged constant pool so now the rewritten bytecodes have
    1.56      // valid references; the previous new constant pool will get
    1.57      // GCed.
    1.58 -    set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, THREAD);
    1.59 +    set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length,
    1.60 +                          CHECK_(JVMTI_ERROR_OUT_OF_MEMORY));
    1.61      // The new constant pool replaces scratch_cp so have cleaner clean it up.
    1.62      // It can't be cleaned up while there are handles to it.
    1.63      cp_cleaner.add_scratch_cp(scratch_cp());
    1.64 @@ -1590,11 +1604,23 @@
    1.65    for (int i = methods->length() - 1; i >= 0; i--) {
    1.66      methodHandle method(THREAD, methods->at(i));
    1.67      methodHandle new_method;
    1.68 -    rewrite_cp_refs_in_method(method, &new_method, CHECK_false);
    1.69 +    rewrite_cp_refs_in_method(method, &new_method, THREAD);
    1.70      if (!new_method.is_null()) {
    1.71        // the method has been replaced so save the new method version
    1.72 +      // even in the case of an exception.  original method is on the
    1.73 +      // deallocation list.
    1.74        methods->at_put(i, new_method());
    1.75      }
    1.76 +    if (HAS_PENDING_EXCEPTION) {
    1.77 +      Symbol* ex_name = PENDING_EXCEPTION->klass()->name();
    1.78 +      // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
    1.79 +      RC_TRACE_WITH_THREAD(0x00000002, THREAD,
    1.80 +        ("rewrite_cp_refs_in_method exception: '%s'", ex_name->as_C_string()));
    1.81 +      // Need to clear pending exception here as the super caller sets
    1.82 +      // the JVMTI_ERROR_INTERNAL if the returned value is false.
    1.83 +      CLEAR_PENDING_EXCEPTION;
    1.84 +      return false;
    1.85 +    }
    1.86    }
    1.87  
    1.88    return true;
    1.89 @@ -1674,10 +1700,7 @@
    1.90                Pause_No_Safepoint_Verifier pnsv(&nsv);
    1.91  
    1.92                // ldc is 2 bytes and ldc_w is 3 bytes
    1.93 -              m = rc.insert_space_at(bci, 3, inst_buffer, THREAD);
    1.94 -              if (m.is_null() || HAS_PENDING_EXCEPTION) {
    1.95 -                guarantee(false, "insert_space_at() failed");
    1.96 -              }
    1.97 +              m = rc.insert_space_at(bci, 3, inst_buffer, CHECK);
    1.98              }
    1.99  
   1.100              // return the new method so that the caller can update
   1.101 @@ -2487,8 +2510,8 @@
   1.102    // scratch_cp is a merged constant pool and has enough space for a
   1.103    // worst case merge situation. We want to associate the minimum
   1.104    // sized constant pool with the klass to save space.
   1.105 -  constantPoolHandle smaller_cp(THREAD,
   1.106 -          ConstantPool::allocate(loader_data, scratch_cp_length, THREAD));
   1.107 +  ConstantPool* cp = ConstantPool::allocate(loader_data, scratch_cp_length, CHECK);
   1.108 +  constantPoolHandle smaller_cp(THREAD, cp);
   1.109  
   1.110    // preserve version() value in the smaller copy
   1.111    int version = scratch_cp->version();
   1.112 @@ -2500,6 +2523,11 @@
   1.113    smaller_cp->set_pool_holder(scratch_class());
   1.114  
   1.115    scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD);
   1.116 +  if (HAS_PENDING_EXCEPTION) {
   1.117 +    // Exception is handled in the caller
   1.118 +    loader_data->add_to_deallocate_list(smaller_cp());
   1.119 +    return;
   1.120 +  }
   1.121    scratch_cp = smaller_cp;
   1.122  
   1.123    // attach new constant pool to klass

mercurial