Merge

Fri, 27 Sep 2013 11:18:26 +0200

author
tschatzl
date
Fri, 27 Sep 2013 11:18:26 +0200
changeset 5809
4fa18058548e
parent 5807
c319b188c7b2
parent 5780
24250c363d7f
child 5810
ccef6e165e8b

Merge

     1.1 --- a/.hgtags	Thu Sep 26 12:49:45 2013 +0200
     1.2 +++ b/.hgtags	Fri Sep 27 11:18:26 2013 +0200
     1.3 @@ -379,3 +379,5 @@
     1.4  a09fe9d1e016c285307507a5793bc4fa6215e9c9 hs25-b50
     1.5  85072013aad46050a362d10ab78e963121c8014c jdk8-b108
     1.6  566db1b0e6efca31f181456e54c8911d0192410d hs25-b51
     1.7 +c81dd5393a5e333df7cb1f6621f5897ada6522b5 jdk8-b109
     1.8 +58043478c26d4e8bf48700acea5f97aba8b417d4 hs25-b52
     2.1 --- a/agent/src/os/linux/ps_core.c	Thu Sep 26 12:49:45 2013 +0200
     2.2 +++ b/agent/src/os/linux/ps_core.c	Fri Sep 27 11:18:26 2013 +0200
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -698,29 +698,58 @@
    2.11  
    2.12  // read segments of a shared object
    2.13  static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* lib_ehdr, uintptr_t lib_base) {
    2.14 -   int i = 0;
    2.15 -   ELF_PHDR* phbuf;
    2.16 -   ELF_PHDR* lib_php = NULL;
    2.17 +  int i = 0;
    2.18 +  ELF_PHDR* phbuf;
    2.19 +  ELF_PHDR* lib_php = NULL;
    2.20  
    2.21 -   if ((phbuf = read_program_header_table(lib_fd, lib_ehdr)) == NULL)
    2.22 -      return false;
    2.23 +  int page_size=sysconf(_SC_PAGE_SIZE);
    2.24  
    2.25 -   // we want to process only PT_LOAD segments that are not writable.
    2.26 -   // i.e., text segments. The read/write/exec (data) segments would
    2.27 -   // have been already added from core file segments.
    2.28 -   for (lib_php = phbuf, i = 0; i < lib_ehdr->e_phnum; i++) {
    2.29 -      if ((lib_php->p_type == PT_LOAD) && !(lib_php->p_flags & PF_W) && (lib_php->p_filesz != 0)) {
    2.30 -         if (add_map_info(ph, lib_fd, lib_php->p_offset, lib_php->p_vaddr + lib_base, lib_php->p_filesz) == NULL)
    2.31 -            goto err;
    2.32 +  if ((phbuf = read_program_header_table(lib_fd, lib_ehdr)) == NULL) {
    2.33 +    return false;
    2.34 +  }
    2.35 +
    2.36 +  // we want to process only PT_LOAD segments that are not writable.
    2.37 +  // i.e., text segments. The read/write/exec (data) segments would
    2.38 +  // have been already added from core file segments.
    2.39 +  for (lib_php = phbuf, i = 0; i < lib_ehdr->e_phnum; i++) {
    2.40 +    if ((lib_php->p_type == PT_LOAD) && !(lib_php->p_flags & PF_W) && (lib_php->p_filesz != 0)) {
    2.41 +
    2.42 +      uintptr_t target_vaddr = lib_php->p_vaddr + lib_base;
    2.43 +      map_info *existing_map = core_lookup(ph, target_vaddr);
    2.44 +
    2.45 +      if (existing_map == NULL){
    2.46 +        if (add_map_info(ph, lib_fd, lib_php->p_offset,
    2.47 +                          target_vaddr, lib_php->p_filesz) == NULL) {
    2.48 +          goto err;
    2.49 +        }
    2.50 +      } else {
    2.51 +        if ((existing_map->memsz != page_size) &&
    2.52 +            (existing_map->fd != lib_fd) &&
    2.53 +            (existing_map->memsz != lib_php->p_filesz)){
    2.54 +
    2.55 +          print_debug("address conflict @ 0x%lx (size = %ld, flags = %d\n)",
    2.56 +                        target_vaddr, lib_php->p_filesz, lib_php->p_flags);
    2.57 +          goto err;
    2.58 +        }
    2.59 +
    2.60 +        /* replace PT_LOAD segment with library segment */
    2.61 +        print_debug("overwrote with new address mapping (memsz %ld -> %ld)\n",
    2.62 +                     existing_map->memsz, lib_php->p_filesz);
    2.63 +
    2.64 +        existing_map->fd = lib_fd;
    2.65 +        existing_map->offset = lib_php->p_offset;
    2.66 +        existing_map->memsz = lib_php->p_filesz;
    2.67        }
    2.68 -      lib_php++;
    2.69 -   }
    2.70 +    }
    2.71  
    2.72 -   free(phbuf);
    2.73 -   return true;
    2.74 +    lib_php++;
    2.75 +  }
    2.76 +
    2.77 +  free(phbuf);
    2.78 +  return true;
    2.79  err:
    2.80 -   free(phbuf);
    2.81 -   return false;
    2.82 +  free(phbuf);
    2.83 +  return false;
    2.84  }
    2.85  
    2.86  // process segments from interpreter (ld.so or ld-linux.so)
     3.1 --- a/make/hotspot_version	Thu Sep 26 12:49:45 2013 +0200
     3.2 +++ b/make/hotspot_version	Fri Sep 27 11:18:26 2013 +0200
     3.3 @@ -35,7 +35,7 @@
     3.4  
     3.5  HS_MAJOR_VER=25
     3.6  HS_MINOR_VER=0
     3.7 -HS_BUILD_NUMBER=52
     3.8 +HS_BUILD_NUMBER=53
     3.9  
    3.10  JDK_MAJOR_VER=1
    3.11  JDK_MINOR_VER=8
     4.1 --- a/make/jprt.properties	Thu Sep 26 12:49:45 2013 +0200
     4.2 +++ b/make/jprt.properties	Fri Sep 27 11:18:26 2013 +0200
     4.3 @@ -120,13 +120,13 @@
     4.4  jprt.my.macosx.x64.jdk7u8=${jprt.my.macosx.x64.jdk7}
     4.5  jprt.my.macosx.x64=${jprt.my.macosx.x64.${jprt.tools.default.release}}
     4.6  
     4.7 -jprt.my.windows.i586.jdk8=windows_i586_5.1
     4.8 -jprt.my.windows.i586.jdk7=windows_i586_5.1
     4.9 +jprt.my.windows.i586.jdk8=windows_i586_6.1
    4.10 +jprt.my.windows.i586.jdk7=windows_i586_6.1
    4.11  jprt.my.windows.i586.jdk7u8=${jprt.my.windows.i586.jdk7}
    4.12  jprt.my.windows.i586=${jprt.my.windows.i586.${jprt.tools.default.release}}
    4.13  
    4.14 -jprt.my.windows.x64.jdk8=windows_x64_5.2
    4.15 -jprt.my.windows.x64.jdk7=windows_x64_5.2
    4.16 +jprt.my.windows.x64.jdk8=windows_x64_6.1
    4.17 +jprt.my.windows.x64.jdk7=windows_x64_6.1
    4.18  jprt.my.windows.x64.jdk7u8=${jprt.my.windows.x64.jdk7}
    4.19  jprt.my.windows.x64=${jprt.my.windows.x64.${jprt.tools.default.release}}
    4.20  
     5.1 --- a/src/cpu/sparc/vm/vtableStubs_sparc.cpp	Thu Sep 26 12:49:45 2013 +0200
     5.2 +++ b/src/cpu/sparc/vm/vtableStubs_sparc.cpp	Fri Sep 27 11:18:26 2013 +0200
     5.3 @@ -52,6 +52,11 @@
     5.4  VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
     5.5    const int sparc_code_length = VtableStub::pd_code_size_limit(true);
     5.6    VtableStub* s = new(sparc_code_length) VtableStub(true, vtable_index);
     5.7 +  // Can be NULL if there is no free space in the code cache.
     5.8 +  if (s == NULL) {
     5.9 +    return NULL;
    5.10 +  }
    5.11 +
    5.12    ResourceMark rm;
    5.13    CodeBuffer cb(s->entry_point(), sparc_code_length);
    5.14    MacroAssembler* masm = new MacroAssembler(&cb);
    5.15 @@ -125,6 +130,11 @@
    5.16  VtableStub* VtableStubs::create_itable_stub(int itable_index) {
    5.17    const int sparc_code_length = VtableStub::pd_code_size_limit(false);
    5.18    VtableStub* s = new(sparc_code_length) VtableStub(false, itable_index);
    5.19 +  // Can be NULL if there is no free space in the code cache.
    5.20 +  if (s == NULL) {
    5.21 +    return NULL;
    5.22 +  }
    5.23 +
    5.24    ResourceMark rm;
    5.25    CodeBuffer cb(s->entry_point(), sparc_code_length);
    5.26    MacroAssembler* masm = new MacroAssembler(&cb);
     6.1 --- a/src/cpu/x86/vm/vtableStubs_x86_32.cpp	Thu Sep 26 12:49:45 2013 +0200
     6.2 +++ b/src/cpu/x86/vm/vtableStubs_x86_32.cpp	Fri Sep 27 11:18:26 2013 +0200
     6.3 @@ -58,6 +58,11 @@
     6.4  VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
     6.5    const int i486_code_length = VtableStub::pd_code_size_limit(true);
     6.6    VtableStub* s = new(i486_code_length) VtableStub(true, vtable_index);
     6.7 +  // Can be NULL if there is no free space in the code cache.
     6.8 +  if (s == NULL) {
     6.9 +    return NULL;
    6.10 +  }
    6.11 +
    6.12    ResourceMark rm;
    6.13    CodeBuffer cb(s->entry_point(), i486_code_length);
    6.14    MacroAssembler* masm = new MacroAssembler(&cb);
    6.15 @@ -132,6 +137,11 @@
    6.16    //            add code here, bump the code stub size returned by pd_code_size_limit!
    6.17    const int i486_code_length = VtableStub::pd_code_size_limit(false);
    6.18    VtableStub* s = new(i486_code_length) VtableStub(false, itable_index);
    6.19 +  // Can be NULL if there is no free space in the code cache.
    6.20 +  if (s == NULL) {
    6.21 +    return NULL;
    6.22 +  }
    6.23 +
    6.24    ResourceMark rm;
    6.25    CodeBuffer cb(s->entry_point(), i486_code_length);
    6.26    MacroAssembler* masm = new MacroAssembler(&cb);
     7.1 --- a/src/cpu/x86/vm/vtableStubs_x86_64.cpp	Thu Sep 26 12:49:45 2013 +0200
     7.2 +++ b/src/cpu/x86/vm/vtableStubs_x86_64.cpp	Fri Sep 27 11:18:26 2013 +0200
     7.3 @@ -49,6 +49,11 @@
     7.4  VtableStub* VtableStubs::create_vtable_stub(int vtable_index) {
     7.5    const int amd64_code_length = VtableStub::pd_code_size_limit(true);
     7.6    VtableStub* s = new(amd64_code_length) VtableStub(true, vtable_index);
     7.7 +  // Can be NULL if there is no free space in the code cache.
     7.8 +  if (s == NULL) {
     7.9 +    return NULL;
    7.10 +  }
    7.11 +
    7.12    ResourceMark rm;
    7.13    CodeBuffer cb(s->entry_point(), amd64_code_length);
    7.14    MacroAssembler* masm = new MacroAssembler(&cb);
    7.15 @@ -126,6 +131,11 @@
    7.16    // returned by pd_code_size_limit!
    7.17    const int amd64_code_length = VtableStub::pd_code_size_limit(false);
    7.18    VtableStub* s = new(amd64_code_length) VtableStub(false, itable_index);
    7.19 +  // Can be NULL if there is no free space in the code cache.
    7.20 +  if (s == NULL) {
    7.21 +    return NULL;
    7.22 +  }
    7.23 +
    7.24    ResourceMark rm;
    7.25    CodeBuffer cb(s->entry_point(), amd64_code_length);
    7.26    MacroAssembler* masm = new MacroAssembler(&cb);
     8.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Thu Sep 26 12:49:45 2013 +0200
     8.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Fri Sep 27 11:18:26 2013 +0200
     8.3 @@ -4219,7 +4219,9 @@
     8.4      }
     8.5    }
     8.6  
     8.7 -  if (!PrintInlining)  return;
     8.8 +  if (!PrintInlining && !compilation()->method()->has_option("PrintInlining")) {
     8.9 +    return;
    8.10 +  }
    8.11    CompileTask::print_inlining(callee, scope()->level(), bci(), msg);
    8.12    if (success && CIPrintMethodCodes) {
    8.13      callee->print_codes();
     9.1 --- a/src/share/vm/classfile/javaClasses.cpp	Thu Sep 26 12:49:45 2013 +0200
     9.2 +++ b/src/share/vm/classfile/javaClasses.cpp	Fri Sep 27 11:18:26 2013 +0200
     9.3 @@ -438,6 +438,29 @@
     9.4    return true;
     9.5  }
     9.6  
     9.7 +bool java_lang_String::equals(oop str1, oop str2) {
     9.8 +  assert(str1->klass() == SystemDictionary::String_klass(),
     9.9 +         "must be java String");
    9.10 +  assert(str2->klass() == SystemDictionary::String_klass(),
    9.11 +         "must be java String");
    9.12 +  typeArrayOop value1  = java_lang_String::value(str1);
    9.13 +  int          offset1 = java_lang_String::offset(str1);
    9.14 +  int          length1 = java_lang_String::length(str1);
    9.15 +  typeArrayOop value2  = java_lang_String::value(str2);
    9.16 +  int          offset2 = java_lang_String::offset(str2);
    9.17 +  int          length2 = java_lang_String::length(str2);
    9.18 +
    9.19 +  if (length1 != length2) {
    9.20 +    return false;
    9.21 +  }
    9.22 +  for (int i = 0; i < length1; i++) {
    9.23 +    if (value1->char_at(i + offset1) != value2->char_at(i + offset2)) {
    9.24 +      return false;
    9.25 +    }
    9.26 +  }
    9.27 +  return true;
    9.28 +}
    9.29 +
    9.30  void java_lang_String::print(Handle java_string, outputStream* st) {
    9.31    oop          obj    = java_string();
    9.32    assert(obj->klass() == SystemDictionary::String_klass(), "must be java_string");
    10.1 --- a/src/share/vm/classfile/javaClasses.hpp	Thu Sep 26 12:49:45 2013 +0200
    10.2 +++ b/src/share/vm/classfile/javaClasses.hpp	Fri Sep 27 11:18:26 2013 +0200
    10.3 @@ -182,6 +182,7 @@
    10.4    static unsigned int hash_string(oop java_string);
    10.5  
    10.6    static bool equals(oop java_string, jchar* chars, int len);
    10.7 +  static bool equals(oop str1, oop str2);
    10.8  
    10.9    // Conversion between '.' and '/' formats
   10.10    static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); }
    11.1 --- a/src/share/vm/classfile/symbolTable.cpp	Thu Sep 26 12:49:45 2013 +0200
    11.2 +++ b/src/share/vm/classfile/symbolTable.cpp	Fri Sep 27 11:18:26 2013 +0200
    11.3 @@ -807,6 +807,8 @@
    11.4    }
    11.5  }
    11.6  
    11.7 +// This verification is part of Universe::verify() and needs to be quick.
    11.8 +// See StringTable::verify_and_compare() below for exhaustive verification.
    11.9  void StringTable::verify() {
   11.10    for (int i = 0; i < the_table()->table_size(); ++i) {
   11.11      HashtableEntry<oop, mtSymbol>* p = the_table()->bucket(i);
   11.12 @@ -825,6 +827,162 @@
   11.13    the_table()->dump_table(st, "StringTable");
   11.14  }
   11.15  
   11.16 +StringTable::VerifyRetTypes StringTable::compare_entries(
   11.17 +                                      int bkt1, int e_cnt1,
   11.18 +                                      HashtableEntry<oop, mtSymbol>* e_ptr1,
   11.19 +                                      int bkt2, int e_cnt2,
   11.20 +                                      HashtableEntry<oop, mtSymbol>* e_ptr2) {
   11.21 +  // These entries are sanity checked by verify_and_compare_entries()
   11.22 +  // before this function is called.
   11.23 +  oop str1 = e_ptr1->literal();
   11.24 +  oop str2 = e_ptr2->literal();
   11.25 +
   11.26 +  if (str1 == str2) {
   11.27 +    tty->print_cr("ERROR: identical oop values (0x" PTR_FORMAT ") "
   11.28 +                  "in entry @ bucket[%d][%d] and entry @ bucket[%d][%d]",
   11.29 +                  str1, bkt1, e_cnt1, bkt2, e_cnt2);
   11.30 +    return _verify_fail_continue;
   11.31 +  }
   11.32 +
   11.33 +  if (java_lang_String::equals(str1, str2)) {
   11.34 +    tty->print_cr("ERROR: identical String values in entry @ "
   11.35 +                  "bucket[%d][%d] and entry @ bucket[%d][%d]",
   11.36 +                  bkt1, e_cnt1, bkt2, e_cnt2);
   11.37 +    return _verify_fail_continue;
   11.38 +  }
   11.39 +
   11.40 +  return _verify_pass;
   11.41 +}
   11.42 +
   11.43 +StringTable::VerifyRetTypes StringTable::verify_entry(int bkt, int e_cnt,
   11.44 +                                      HashtableEntry<oop, mtSymbol>* e_ptr,
   11.45 +                                      StringTable::VerifyMesgModes mesg_mode) {
   11.46 +
   11.47 +  VerifyRetTypes ret = _verify_pass;  // be optimistic
   11.48 +
   11.49 +  oop str = e_ptr->literal();
   11.50 +  if (str == NULL) {
   11.51 +    if (mesg_mode == _verify_with_mesgs) {
   11.52 +      tty->print_cr("ERROR: NULL oop value in entry @ bucket[%d][%d]", bkt,
   11.53 +                    e_cnt);
   11.54 +    }
   11.55 +    // NULL oop means no more verifications are possible
   11.56 +    return _verify_fail_done;
   11.57 +  }
   11.58 +
   11.59 +  if (str->klass() != SystemDictionary::String_klass()) {
   11.60 +    if (mesg_mode == _verify_with_mesgs) {
   11.61 +      tty->print_cr("ERROR: oop is not a String in entry @ bucket[%d][%d]",
   11.62 +                    bkt, e_cnt);
   11.63 +    }
   11.64 +    // not a String means no more verifications are possible
   11.65 +    return _verify_fail_done;
   11.66 +  }
   11.67 +
   11.68 +  unsigned int h = java_lang_String::hash_string(str);
   11.69 +  if (e_ptr->hash() != h) {
   11.70 +    if (mesg_mode == _verify_with_mesgs) {
   11.71 +      tty->print_cr("ERROR: broken hash value in entry @ bucket[%d][%d], "
   11.72 +                    "bkt_hash=%d, str_hash=%d", bkt, e_cnt, e_ptr->hash(), h);
   11.73 +    }
   11.74 +    ret = _verify_fail_continue;
   11.75 +  }
   11.76 +
   11.77 +  if (the_table()->hash_to_index(h) != bkt) {
   11.78 +    if (mesg_mode == _verify_with_mesgs) {
   11.79 +      tty->print_cr("ERROR: wrong index value for entry @ bucket[%d][%d], "
   11.80 +                    "str_hash=%d, hash_to_index=%d", bkt, e_cnt, h,
   11.81 +                    the_table()->hash_to_index(h));
   11.82 +    }
   11.83 +    ret = _verify_fail_continue;
   11.84 +  }
   11.85 +
   11.86 +  return ret;
   11.87 +}
   11.88 +
   11.89 +// See StringTable::verify() above for the quick verification that is
   11.90 +// part of Universe::verify(). This verification is exhaustive and
   11.91 +// reports on every issue that is found. StringTable::verify() only
   11.92 +// reports on the first issue that is found.
   11.93 +//
   11.94 +// StringTable::verify_entry() checks:
   11.95 +// - oop value != NULL (same as verify())
   11.96 +// - oop value is a String
   11.97 +// - hash(String) == hash in entry (same as verify())
   11.98 +// - index for hash == index of entry (same as verify())
   11.99 +//
  11.100 +// StringTable::compare_entries() checks:
  11.101 +// - oops are unique across all entries
  11.102 +// - String values are unique across all entries
  11.103 +//
  11.104 +int StringTable::verify_and_compare_entries() {
  11.105 +  assert(StringTable_lock->is_locked(), "sanity check");
  11.106 +
  11.107 +  int  fail_cnt = 0;
  11.108 +
  11.109 +  // first, verify all the entries individually:
  11.110 +  for (int bkt = 0; bkt < the_table()->table_size(); bkt++) {
  11.111 +    HashtableEntry<oop, mtSymbol>* e_ptr = the_table()->bucket(bkt);
  11.112 +    for (int e_cnt = 0; e_ptr != NULL; e_ptr = e_ptr->next(), e_cnt++) {
  11.113 +      VerifyRetTypes ret = verify_entry(bkt, e_cnt, e_ptr, _verify_with_mesgs);
  11.114 +      if (ret != _verify_pass) {
  11.115 +        fail_cnt++;
  11.116 +      }
  11.117 +    }
  11.118 +  }
  11.119 +
  11.120 +  // Optimization: if the above check did not find any failures, then
  11.121 +  // the comparison loop below does not need to call verify_entry()
  11.122 +  // before calling compare_entries(). If there were failures, then we
  11.123 +  // have to call verify_entry() to see if the entry can be passed to
  11.124 +  // compare_entries() safely. When we call verify_entry() in the loop
  11.125 +  // below, we do so quietly to void duplicate messages and we don't
  11.126 +  // increment fail_cnt because the failures have already been counted.
  11.127 +  bool need_entry_verify = (fail_cnt != 0);
  11.128 +
  11.129 +  // second, verify all entries relative to each other:
  11.130 +  for (int bkt1 = 0; bkt1 < the_table()->table_size(); bkt1++) {
  11.131 +    HashtableEntry<oop, mtSymbol>* e_ptr1 = the_table()->bucket(bkt1);
  11.132 +    for (int e_cnt1 = 0; e_ptr1 != NULL; e_ptr1 = e_ptr1->next(), e_cnt1++) {
  11.133 +      if (need_entry_verify) {
  11.134 +        VerifyRetTypes ret = verify_entry(bkt1, e_cnt1, e_ptr1,
  11.135 +                                          _verify_quietly);
  11.136 +        if (ret == _verify_fail_done) {
  11.137 +          // cannot use the current entry to compare against other entries
  11.138 +          continue;
  11.139 +        }
  11.140 +      }
  11.141 +
  11.142 +      for (int bkt2 = bkt1; bkt2 < the_table()->table_size(); bkt2++) {
  11.143 +        HashtableEntry<oop, mtSymbol>* e_ptr2 = the_table()->bucket(bkt2);
  11.144 +        int e_cnt2;
  11.145 +        for (e_cnt2 = 0; e_ptr2 != NULL; e_ptr2 = e_ptr2->next(), e_cnt2++) {
  11.146 +          if (bkt1 == bkt2 && e_cnt2 <= e_cnt1) {
  11.147 +            // skip the entries up to and including the one that
  11.148 +            // we're comparing against
  11.149 +            continue;
  11.150 +          }
  11.151 +
  11.152 +          if (need_entry_verify) {
  11.153 +            VerifyRetTypes ret = verify_entry(bkt2, e_cnt2, e_ptr2,
  11.154 +                                              _verify_quietly);
  11.155 +            if (ret == _verify_fail_done) {
  11.156 +              // cannot compare against this entry
  11.157 +              continue;
  11.158 +            }
  11.159 +          }
  11.160 +
  11.161 +          // compare two entries, report and count any failures:
  11.162 +          if (compare_entries(bkt1, e_cnt1, e_ptr1, bkt2, e_cnt2, e_ptr2)
  11.163 +              != _verify_pass) {
  11.164 +            fail_cnt++;
  11.165 +          }
  11.166 +        }
  11.167 +      }
  11.168 +    }
  11.169 +  }
  11.170 +  return fail_cnt;
  11.171 +}
  11.172  
  11.173  // Create a new table and using alternate hash code, populate the new table
  11.174  // with the existing strings.   Set flag to use the alternate hash code afterwards.
    12.1 --- a/src/share/vm/classfile/symbolTable.hpp	Thu Sep 26 12:49:45 2013 +0200
    12.2 +++ b/src/share/vm/classfile/symbolTable.hpp	Fri Sep 27 11:18:26 2013 +0200
    12.3 @@ -311,6 +311,26 @@
    12.4    static void verify();
    12.5    static void dump(outputStream* st);
    12.6  
    12.7 +  enum VerifyMesgModes {
    12.8 +    _verify_quietly    = 0,
    12.9 +    _verify_with_mesgs = 1
   12.10 +  };
   12.11 +
   12.12 +  enum VerifyRetTypes {
   12.13 +    _verify_pass          = 0,
   12.14 +    _verify_fail_continue = 1,
   12.15 +    _verify_fail_done     = 2
   12.16 +  };
   12.17 +
   12.18 +  static VerifyRetTypes compare_entries(int bkt1, int e_cnt1,
   12.19 +                                        HashtableEntry<oop, mtSymbol>* e_ptr1,
   12.20 +                                        int bkt2, int e_cnt2,
   12.21 +                                        HashtableEntry<oop, mtSymbol>* e_ptr2);
   12.22 +  static VerifyRetTypes verify_entry(int bkt, int e_cnt,
   12.23 +                                     HashtableEntry<oop, mtSymbol>* e_ptr,
   12.24 +                                     VerifyMesgModes mesg_mode);
   12.25 +  static int verify_and_compare_entries();
   12.26 +
   12.27    // Sharing
   12.28    static void copy_buckets(char** top, char*end) {
   12.29      the_table()->Hashtable<oop, mtSymbol>::copy_buckets(top, end);
    13.1 --- a/src/share/vm/code/compiledIC.cpp	Thu Sep 26 12:49:45 2013 +0200
    13.2 +++ b/src/share/vm/code/compiledIC.cpp	Fri Sep 27 11:18:26 2013 +0200
    13.3 @@ -160,7 +160,7 @@
    13.4  // High-level access to an inline cache. Guaranteed to be MT-safe.
    13.5  
    13.6  
    13.7 -void CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) {
    13.8 +bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) {
    13.9    assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "");
   13.10    assert(!is_optimized(), "cannot set an optimized virtual call to megamorphic");
   13.11    assert(is_call_to_compiled() || is_call_to_interpreted(), "going directly to megamorphic?");
   13.12 @@ -170,8 +170,10 @@
   13.13      assert(bytecode == Bytecodes::_invokeinterface, "");
   13.14      int itable_index = call_info->itable_index();
   13.15      entry = VtableStubs::find_itable_stub(itable_index);
   13.16 +    if (entry == false) {
   13.17 +      return false;
   13.18 +    }
   13.19  #ifdef ASSERT
   13.20 -    assert(entry != NULL, "entry not computed");
   13.21      int index = call_info->resolved_method()->itable_index();
   13.22      assert(index == itable_index, "CallInfo pre-computes this");
   13.23  #endif //ASSERT
   13.24 @@ -184,6 +186,9 @@
   13.25      int vtable_index = call_info->vtable_index();
   13.26      assert(call_info->resolved_klass()->verify_vtable_index(vtable_index), "sanity check");
   13.27      entry = VtableStubs::find_vtable_stub(vtable_index);
   13.28 +    if (entry == NULL) {
   13.29 +      return false;
   13.30 +    }
   13.31      InlineCacheBuffer::create_transition_stub(this, NULL, entry);
   13.32    }
   13.33  
   13.34 @@ -200,6 +205,7 @@
   13.35    // race because the IC entry was complete when we safepointed so
   13.36    // cleaning it immediately is harmless.
   13.37    // assert(is_megamorphic(), "sanity check");
   13.38 +  return true;
   13.39  }
   13.40  
   13.41  
    14.1 --- a/src/share/vm/code/compiledIC.hpp	Thu Sep 26 12:49:45 2013 +0200
    14.2 +++ b/src/share/vm/code/compiledIC.hpp	Fri Sep 27 11:18:26 2013 +0200
    14.3 @@ -226,7 +226,10 @@
    14.4    //
    14.5    void set_to_clean();  // Can only be called during a safepoint operation
    14.6    void set_to_monomorphic(CompiledICInfo& info);
    14.7 -  void set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS);
    14.8 +
    14.9 +  // Returns true if successful and false otherwise. The call can fail if memory
   14.10 +  // allocation in the code cache fails.
   14.11 +  bool set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS);
   14.12  
   14.13    static void compute_monomorphic_entry(methodHandle method, KlassHandle receiver_klass,
   14.14                                          bool is_optimized, bool static_bound, CompiledICInfo& info, TRAPS);
    15.1 --- a/src/share/vm/code/vtableStubs.cpp	Thu Sep 26 12:49:45 2013 +0200
    15.2 +++ b/src/share/vm/code/vtableStubs.cpp	Fri Sep 27 11:18:26 2013 +0200
    15.3 @@ -46,12 +46,9 @@
    15.4  address VtableStub::_chunk_end         = NULL;
    15.5  VMReg   VtableStub::_receiver_location = VMRegImpl::Bad();
    15.6  
    15.7 -static int num_vtable_chunks = 0;
    15.8 -
    15.9  
   15.10  void* VtableStub::operator new(size_t size, int code_size) throw() {
   15.11    assert(size == sizeof(VtableStub), "mismatched size");
   15.12 -  num_vtable_chunks++;
   15.13    // compute real VtableStub size (rounded to nearest word)
   15.14    const int real_size = round_to(code_size + sizeof(VtableStub), wordSize);
   15.15    // malloc them in chunks to minimize header overhead
   15.16 @@ -60,7 +57,7 @@
   15.17      const int bytes = chunk_factor * real_size + pd_code_alignment();
   15.18      BufferBlob* blob = BufferBlob::create("vtable chunks", bytes);
   15.19      if (blob == NULL) {
   15.20 -      vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "CodeCache: no room for vtable chunks");
   15.21 +      return NULL;
   15.22      }
   15.23      _chunk = blob->content_begin();
   15.24      _chunk_end = _chunk + bytes;
   15.25 @@ -121,6 +118,12 @@
   15.26      } else {
   15.27        s = create_itable_stub(vtable_index);
   15.28      }
   15.29 +
   15.30 +    // Creation of vtable or itable can fail if there is not enough free space in the code cache.
   15.31 +    if (s == NULL) {
   15.32 +      return NULL;
   15.33 +    }
   15.34 +
   15.35      enter(is_vtable_stub, vtable_index, s);
   15.36      if (PrintAdapterHandlers) {
   15.37        tty->print_cr("Decoding VtableStub %s[%d]@%d",
    16.1 --- a/src/share/vm/memory/metaspaceShared.cpp	Thu Sep 26 12:49:45 2013 +0200
    16.2 +++ b/src/share/vm/memory/metaspaceShared.cpp	Fri Sep 27 11:18:26 2013 +0200
    16.3 @@ -103,9 +103,10 @@
    16.4      if (k->oop_is_instance()) {
    16.5        InstanceKlass* ik = InstanceKlass::cast(k);
    16.6        for (int i = 0; i < ik->methods()->length(); i++) {
    16.7 -        ResourceMark rm;
    16.8          Method* m = ik->methods()->at(i);
    16.9 -        (new Fingerprinter(m))->fingerprint();
   16.10 +        Fingerprinter fp(m);
   16.11 +        // The side effect of this call sets method's fingerprint field.
   16.12 +        fp.fingerprint();
   16.13        }
   16.14      }
   16.15    }
    17.1 --- a/src/share/vm/oops/constantPool.cpp	Thu Sep 26 12:49:45 2013 +0200
    17.2 +++ b/src/share/vm/oops/constantPool.cpp	Fri Sep 27 11:18:26 2013 +0200
    17.3 @@ -108,16 +108,16 @@
    17.4  void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
    17.5                                                    intStack reference_map,
    17.6                                                    int constant_pool_map_length,
    17.7 -                                                   TRAPS) {
    17.8 +                                                  TRAPS) {
    17.9    // Initialized the resolved object cache.
   17.10    int map_length = reference_map.length();
   17.11    if (map_length > 0) {
   17.12      // Only need mapping back to constant pool entries.  The map isn't used for
   17.13 -    // invokedynamic resolved_reference entries.  The constant pool cache index
   17.14 -    // has the mapping back to both the constant pool and to the resolved
   17.15 -    // reference index.
   17.16 +    // invokedynamic resolved_reference entries.  For invokedynamic entries,
   17.17 +    // the constant pool cache index has the mapping back to both the constant
   17.18 +    // pool and to the resolved reference index.
   17.19      if (constant_pool_map_length > 0) {
   17.20 -      Array<u2>* om = MetadataFactory::new_array<u2>(loader_data, map_length, CHECK);
   17.21 +      Array<u2>* om = MetadataFactory::new_array<u2>(loader_data, constant_pool_map_length, CHECK);
   17.22  
   17.23        for (int i = 0; i < constant_pool_map_length; i++) {
   17.24          int x = reference_map.at(i);
   17.25 @@ -182,16 +182,9 @@
   17.26  
   17.27  int ConstantPool::cp_to_object_index(int cp_index) {
   17.28    // this is harder don't do this so much.
   17.29 -  for (int i = 0; i< reference_map()->length(); i++) {
   17.30 -    if (reference_map()->at(i) == cp_index) return i;
   17.31 -    // Zero entry is divider between constant pool indices for strings,
   17.32 -    // method handles and method types. After that the index is a constant
   17.33 -    // pool cache index for invokedynamic.  Stop when zero (which can never
   17.34 -    // be a constant pool index)
   17.35 -    if (reference_map()->at(i) == 0) break;
   17.36 -  }
   17.37 -  // We might not find the index.
   17.38 -  return _no_index_sentinel;
   17.39 +  int i = reference_map()->find(cp_index);
   17.40 +  // We might not find the index for jsr292 call.
   17.41 +  return (i < 0) ? _no_index_sentinel : i;
   17.42  }
   17.43  
   17.44  Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
   17.45 @@ -840,8 +833,7 @@
   17.46    // If the string has already been interned, this entry will be non-null
   17.47    oop str = this_oop->resolved_references()->obj_at(obj_index);
   17.48    if (str != NULL) return str;
   17.49 -
   17.50 -      Symbol* sym = this_oop->unresolved_string_at(which);
   17.51 +  Symbol* sym = this_oop->unresolved_string_at(which);
   17.52    str = StringTable::intern(sym, CHECK_(NULL));
   17.53    this_oop->string_at_put(which, obj_index, str);
   17.54    assert(java_lang_String::is_instance(str), "must be string");
   17.55 @@ -1619,9 +1611,11 @@
   17.56      case JVM_CONSTANT_UnresolvedClassInError:
   17.57      case JVM_CONSTANT_StringIndex:
   17.58      case JVM_CONSTANT_MethodType:
   17.59 +    case JVM_CONSTANT_MethodTypeInError:
   17.60        return 3;
   17.61  
   17.62      case JVM_CONSTANT_MethodHandle:
   17.63 +    case JVM_CONSTANT_MethodHandleInError:
   17.64        return 4; //tag, ref_kind, ref_index
   17.65  
   17.66      case JVM_CONSTANT_Integer:
   17.67 @@ -1802,8 +1796,8 @@
   17.68        case JVM_CONSTANT_MethodHandle:
   17.69        case JVM_CONSTANT_MethodHandleInError: {
   17.70          *bytes = JVM_CONSTANT_MethodHandle;
   17.71 -        int kind = method_handle_ref_kind_at(idx);
   17.72 -        idx1 = method_handle_index_at(idx);
   17.73 +        int kind = method_handle_ref_kind_at_error_ok(idx);
   17.74 +        idx1 = method_handle_index_at_error_ok(idx);
   17.75          *(bytes+1) = (unsigned char) kind;
   17.76          Bytes::put_Java_u2((address) (bytes+2), idx1);
   17.77          DBG(printf("JVM_CONSTANT_MethodHandle: %d %hd", kind, idx1));
   17.78 @@ -1812,7 +1806,7 @@
   17.79        case JVM_CONSTANT_MethodType:
   17.80        case JVM_CONSTANT_MethodTypeInError: {
   17.81          *bytes = JVM_CONSTANT_MethodType;
   17.82 -        idx1 = method_type_index_at(idx);
   17.83 +        idx1 = method_type_index_at_error_ok(idx);
   17.84          Bytes::put_Java_u2((address) (bytes+1), idx1);
   17.85          DBG(printf("JVM_CONSTANT_MethodType: %hd", idx1));
   17.86          break;
   17.87 @@ -2000,12 +1994,12 @@
   17.88        break;
   17.89      case JVM_CONSTANT_MethodHandle :
   17.90      case JVM_CONSTANT_MethodHandleInError :
   17.91 -      st->print("ref_kind=%d", method_handle_ref_kind_at(index));
   17.92 -      st->print(" ref_index=%d", method_handle_index_at(index));
   17.93 +      st->print("ref_kind=%d", method_handle_ref_kind_at_error_ok(index));
   17.94 +      st->print(" ref_index=%d", method_handle_index_at_error_ok(index));
   17.95        break;
   17.96      case JVM_CONSTANT_MethodType :
   17.97      case JVM_CONSTANT_MethodTypeInError :
   17.98 -      st->print("signature_index=%d", method_type_index_at(index));
   17.99 +      st->print("signature_index=%d", method_type_index_at_error_ok(index));
  17.100        break;
  17.101      case JVM_CONSTANT_InvokeDynamic :
  17.102        {
    18.1 --- a/src/share/vm/oops/constantPool.hpp	Thu Sep 26 12:49:45 2013 +0200
    18.2 +++ b/src/share/vm/oops/constantPool.hpp	Fri Sep 27 11:18:26 2013 +0200
    18.3 @@ -231,7 +231,6 @@
    18.4    static int cache_offset_in_bytes()        { return offset_of(ConstantPool, _cache); }
    18.5    static int pool_holder_offset_in_bytes()  { return offset_of(ConstantPool, _pool_holder); }
    18.6    static int resolved_references_offset_in_bytes() { return offset_of(ConstantPool, _resolved_references); }
    18.7 -  static int reference_map_offset_in_bytes() { return offset_of(ConstantPool, _reference_map); }
    18.8  
    18.9    // Storing constants
   18.10  
   18.11 @@ -475,18 +474,42 @@
   18.12      return *int_at_addr(which);
   18.13    }
   18.14  
   18.15 -  int method_handle_ref_kind_at(int which) {
   18.16 -    assert(tag_at(which).is_method_handle(), "Corrupted constant pool");
   18.17 + private:
   18.18 +  int method_handle_ref_kind_at(int which, bool error_ok) {
   18.19 +    assert(tag_at(which).is_method_handle() ||
   18.20 +           (error_ok && tag_at(which).is_method_handle_in_error()), "Corrupted constant pool");
   18.21      return extract_low_short_from_int(*int_at_addr(which));  // mask out unwanted ref_index bits
   18.22    }
   18.23 -  int method_handle_index_at(int which) {
   18.24 -    assert(tag_at(which).is_method_handle(), "Corrupted constant pool");
   18.25 +  int method_handle_index_at(int which, bool error_ok) {
   18.26 +    assert(tag_at(which).is_method_handle() ||
   18.27 +           (error_ok && tag_at(which).is_method_handle_in_error()), "Corrupted constant pool");
   18.28      return extract_high_short_from_int(*int_at_addr(which));  // shift out unwanted ref_kind bits
   18.29    }
   18.30 -  int method_type_index_at(int which) {
   18.31 -    assert(tag_at(which).is_method_type(), "Corrupted constant pool");
   18.32 +  int method_type_index_at(int which, bool error_ok) {
   18.33 +    assert(tag_at(which).is_method_type() ||
   18.34 +           (error_ok && tag_at(which).is_method_type_in_error()), "Corrupted constant pool");
   18.35      return *int_at_addr(which);
   18.36    }
   18.37 + public:
   18.38 +  int method_handle_ref_kind_at(int which) {
   18.39 +    return method_handle_ref_kind_at(which, false);
   18.40 +  }
   18.41 +  int method_handle_ref_kind_at_error_ok(int which) {
   18.42 +    return method_handle_ref_kind_at(which, true);
   18.43 +  }
   18.44 +  int method_handle_index_at(int which) {
   18.45 +    return method_handle_index_at(which, false);
   18.46 +  }
   18.47 +  int method_handle_index_at_error_ok(int which) {
   18.48 +    return method_handle_index_at(which, true);
   18.49 +  }
   18.50 +  int method_type_index_at(int which) {
   18.51 +    return method_type_index_at(which, false);
   18.52 +  }
   18.53 +  int method_type_index_at_error_ok(int which) {
   18.54 +    return method_type_index_at(which, true);
   18.55 +  }
   18.56 +
   18.57    // Derived queries:
   18.58    Symbol* method_handle_name_ref_at(int which) {
   18.59      int member = method_handle_index_at(which);
    19.1 --- a/src/share/vm/oops/instanceKlass.cpp	Thu Sep 26 12:49:45 2013 +0200
    19.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Fri Sep 27 11:18:26 2013 +0200
    19.3 @@ -2769,24 +2769,17 @@
    19.4    st->print(BULLET"field annotations:       "); fields_annotations()->print_value_on(st); st->cr();
    19.5    st->print(BULLET"field type annotations:  "); fields_type_annotations()->print_value_on(st); st->cr();
    19.6    {
    19.7 -    ResourceMark rm;
    19.8 -    // PreviousVersionInfo objects returned via PreviousVersionWalker
    19.9 -    // contain a GrowableArray of handles. We have to clean up the
   19.10 -    // GrowableArray _after_ the PreviousVersionWalker destructor
   19.11 -    // has destroyed the handles.
   19.12 -    {
   19.13 -      bool have_pv = false;
   19.14 -      PreviousVersionWalker pvw((InstanceKlass*)this);
   19.15 -      for (PreviousVersionInfo * pv_info = pvw.next_previous_version();
   19.16 -           pv_info != NULL; pv_info = pvw.next_previous_version()) {
   19.17 -        if (!have_pv)
   19.18 -          st->print(BULLET"previous version:  ");
   19.19 -        have_pv = true;
   19.20 -        pv_info->prev_constant_pool_handle()()->print_value_on(st);
   19.21 -      }
   19.22 -      if (have_pv)  st->cr();
   19.23 -    } // pvw is cleaned up
   19.24 -  } // rm is cleaned up
   19.25 +    bool have_pv = false;
   19.26 +    PreviousVersionWalker pvw(Thread::current(), (InstanceKlass*)this);
   19.27 +    for (PreviousVersionNode * pv_node = pvw.next_previous_version();
   19.28 +         pv_node != NULL; pv_node = pvw.next_previous_version()) {
   19.29 +      if (!have_pv)
   19.30 +        st->print(BULLET"previous version:  ");
   19.31 +      have_pv = true;
   19.32 +      pv_node->prev_constant_pool()->print_value_on(st);
   19.33 +    }
   19.34 +    if (have_pv) st->cr();
   19.35 +  } // pvw is cleaned up
   19.36  
   19.37    if (generic_signature() != NULL) {
   19.38      st->print(BULLET"generic signature: ");
   19.39 @@ -3317,34 +3310,34 @@
   19.40    Array<Method*>* old_methods = ikh->methods();
   19.41  
   19.42    if (cp_ref->on_stack()) {
   19.43 -  PreviousVersionNode * pv_node = NULL;
   19.44 -  if (emcp_method_count == 0) {
   19.45 +    PreviousVersionNode * pv_node = NULL;
   19.46 +    if (emcp_method_count == 0) {
   19.47        // non-shared ConstantPool gets a reference
   19.48 -      pv_node = new PreviousVersionNode(cp_ref, !cp_ref->is_shared(), NULL);
   19.49 -    RC_TRACE(0x00000400,
   19.50 -        ("add: all methods are obsolete; flushing any EMCP refs"));
   19.51 -  } else {
   19.52 -    int local_count = 0;
   19.53 +      pv_node = new PreviousVersionNode(cp_ref, NULL);
   19.54 +      RC_TRACE(0x00000400,
   19.55 +          ("add: all methods are obsolete; flushing any EMCP refs"));
   19.56 +    } else {
   19.57 +      int local_count = 0;
   19.58        GrowableArray<Method*>* method_refs = new (ResourceObj::C_HEAP, mtClass)
   19.59 -        GrowableArray<Method*>(emcp_method_count, true);
   19.60 -    for (int i = 0; i < old_methods->length(); i++) {
   19.61 -      if (emcp_methods->at(i)) {
   19.62 -          // this old method is EMCP. Save it only if it's on the stack
   19.63 -          Method* old_method = old_methods->at(i);
   19.64 -          if (old_method->on_stack()) {
   19.65 -            method_refs->append(old_method);
   19.66 +          GrowableArray<Method*>(emcp_method_count, true);
   19.67 +      for (int i = 0; i < old_methods->length(); i++) {
   19.68 +        if (emcp_methods->at(i)) {
   19.69 +            // this old method is EMCP. Save it only if it's on the stack
   19.70 +            Method* old_method = old_methods->at(i);
   19.71 +            if (old_method->on_stack()) {
   19.72 +              method_refs->append(old_method);
   19.73 +            }
   19.74 +          if (++local_count >= emcp_method_count) {
   19.75 +            // no more EMCP methods so bail out now
   19.76 +            break;
   19.77            }
   19.78 -        if (++local_count >= emcp_method_count) {
   19.79 -          // no more EMCP methods so bail out now
   19.80 -          break;
   19.81          }
   19.82        }
   19.83 -    }
   19.84        // non-shared ConstantPool gets a reference
   19.85 -      pv_node = new PreviousVersionNode(cp_ref, !cp_ref->is_shared(), method_refs);
   19.86 +      pv_node = new PreviousVersionNode(cp_ref, method_refs);
   19.87      }
   19.88      // append new previous version.
   19.89 -  _previous_versions->append(pv_node);
   19.90 +    _previous_versions->append(pv_node);
   19.91    }
   19.92  
   19.93    // Since the caller is the VMThread and we are at a safepoint, this
   19.94 @@ -3445,6 +3438,8 @@
   19.95          return m;
   19.96        }
   19.97      }
   19.98 +    // None found, return null for the caller to handle.
   19.99 +    return NULL;
  19.100    }
  19.101    return m;
  19.102  }
  19.103 @@ -3461,10 +3456,9 @@
  19.104  // Construct a PreviousVersionNode entry for the array hung off
  19.105  // the InstanceKlass.
  19.106  PreviousVersionNode::PreviousVersionNode(ConstantPool* prev_constant_pool,
  19.107 -  bool prev_cp_is_weak, GrowableArray<Method*>* prev_EMCP_methods) {
  19.108 +  GrowableArray<Method*>* prev_EMCP_methods) {
  19.109  
  19.110    _prev_constant_pool = prev_constant_pool;
  19.111 -  _prev_cp_is_weak = prev_cp_is_weak;
  19.112    _prev_EMCP_methods = prev_EMCP_methods;
  19.113  }
  19.114  
  19.115 @@ -3480,99 +3474,38 @@
  19.116    }
  19.117  }
  19.118  
  19.119 -
  19.120 -// Construct a PreviousVersionInfo entry
  19.121 -PreviousVersionInfo::PreviousVersionInfo(PreviousVersionNode *pv_node) {
  19.122 -  _prev_constant_pool_handle = constantPoolHandle();  // NULL handle
  19.123 -  _prev_EMCP_method_handles = NULL;
  19.124 -
  19.125 -  ConstantPool* cp = pv_node->prev_constant_pool();
  19.126 -  assert(cp != NULL, "constant pool ref was unexpectedly cleared");
  19.127 -  if (cp == NULL) {
  19.128 -    return;  // robustness
  19.129 -  }
  19.130 -
  19.131 -  // make the ConstantPool* safe to return
  19.132 -  _prev_constant_pool_handle = constantPoolHandle(cp);
  19.133 -
  19.134 -  GrowableArray<Method*>* method_refs = pv_node->prev_EMCP_methods();
  19.135 -  if (method_refs == NULL) {
  19.136 -    // the InstanceKlass did not have any EMCP methods
  19.137 -    return;
  19.138 -  }
  19.139 -
  19.140 -  _prev_EMCP_method_handles = new GrowableArray<methodHandle>(10);
  19.141 -
  19.142 -  int n_methods = method_refs->length();
  19.143 -  for (int i = 0; i < n_methods; i++) {
  19.144 -    Method* method = method_refs->at(i);
  19.145 -    assert (method != NULL, "method has been cleared");
  19.146 -    if (method == NULL) {
  19.147 -      continue;  // robustness
  19.148 -    }
  19.149 -    // make the Method* safe to return
  19.150 -    _prev_EMCP_method_handles->append(methodHandle(method));
  19.151 -  }
  19.152 -}
  19.153 -
  19.154 -
  19.155 -// Destroy a PreviousVersionInfo
  19.156 -PreviousVersionInfo::~PreviousVersionInfo() {
  19.157 -  // Since _prev_EMCP_method_handles is not C-heap allocated, we
  19.158 -  // don't have to delete it.
  19.159 -}
  19.160 -
  19.161 -
  19.162  // Construct a helper for walking the previous versions array
  19.163 -PreviousVersionWalker::PreviousVersionWalker(InstanceKlass *ik) {
  19.164 +PreviousVersionWalker::PreviousVersionWalker(Thread* thread, InstanceKlass *ik) {
  19.165 +  _thread = thread;
  19.166    _previous_versions = ik->previous_versions();
  19.167    _current_index = 0;
  19.168 -  // _hm needs no initialization
  19.169    _current_p = NULL;
  19.170 -}
  19.171 -
  19.172 -
  19.173 -// Destroy a PreviousVersionWalker
  19.174 -PreviousVersionWalker::~PreviousVersionWalker() {
  19.175 -  // Delete the current info just in case the caller didn't walk to
  19.176 -  // the end of the previous versions list. No harm if _current_p is
  19.177 -  // already NULL.
  19.178 -  delete _current_p;
  19.179 -
  19.180 -  // When _hm is destroyed, all the Handles returned in
  19.181 -  // PreviousVersionInfo objects will be destroyed.
  19.182 -  // Also, after this destructor is finished it will be
  19.183 -  // safe to delete the GrowableArray allocated in the
  19.184 -  // PreviousVersionInfo objects.
  19.185 +  _current_constant_pool_handle = constantPoolHandle(thread, ik->constants());
  19.186  }
  19.187  
  19.188  
  19.189  // Return the interesting information for the next previous version
  19.190  // of the klass. Returns NULL if there are no more previous versions.
  19.191 -PreviousVersionInfo* PreviousVersionWalker::next_previous_version() {
  19.192 +PreviousVersionNode* PreviousVersionWalker::next_previous_version() {
  19.193    if (_previous_versions == NULL) {
  19.194      // no previous versions so nothing to return
  19.195      return NULL;
  19.196    }
  19.197  
  19.198 -  delete _current_p;  // cleanup the previous info for the caller
  19.199 -  _current_p = NULL;  // reset to NULL so we don't delete same object twice
  19.200 +  _current_p = NULL;  // reset to NULL
  19.201 +  _current_constant_pool_handle = NULL;
  19.202  
  19.203    int length = _previous_versions->length();
  19.204  
  19.205    while (_current_index < length) {
  19.206      PreviousVersionNode * pv_node = _previous_versions->at(_current_index++);
  19.207 -    PreviousVersionInfo * pv_info = new (ResourceObj::C_HEAP, mtClass)
  19.208 -                                          PreviousVersionInfo(pv_node);
  19.209 -
  19.210 -    constantPoolHandle cp_h = pv_info->prev_constant_pool_handle();
  19.211 -    assert (!cp_h.is_null(), "null cp found in previous version");
  19.212 -
  19.213 -    // The caller will need to delete pv_info when they are done with it.
  19.214 -    _current_p = pv_info;
  19.215 -    return pv_info;
  19.216 +
  19.217 +    // Save a handle to the constant pool for this previous version,
  19.218 +    // which keeps all the methods from being deallocated.
  19.219 +    _current_constant_pool_handle = constantPoolHandle(_thread, pv_node->prev_constant_pool());
  19.220 +    _current_p = pv_node;
  19.221 +    return pv_node;
  19.222    }
  19.223  
  19.224 -  // all of the underlying nodes' info has been deleted
  19.225    return NULL;
  19.226  } // end next_previous_version()
    20.1 --- a/src/share/vm/oops/instanceKlass.hpp	Thu Sep 26 12:49:45 2013 +0200
    20.2 +++ b/src/share/vm/oops/instanceKlass.hpp	Fri Sep 27 11:18:26 2013 +0200
    20.3 @@ -1126,21 +1126,11 @@
    20.4  
    20.5  
    20.6  // A collection point for interesting information about the previous
    20.7 -// version(s) of an InstanceKlass. This class uses weak references to
    20.8 -// the information so that the information may be collected as needed
    20.9 -// by the system. If the information is shared, then a regular
   20.10 -// reference must be used because a weak reference would be seen as
   20.11 -// collectible. A GrowableArray of PreviousVersionNodes is attached
   20.12 -// to the InstanceKlass as needed. See PreviousVersionWalker below.
   20.13 +// version(s) of an InstanceKlass.  A GrowableArray of PreviousVersionNodes
   20.14 +// is attached to the InstanceKlass as needed. See PreviousVersionWalker below.
   20.15  class PreviousVersionNode : public CHeapObj<mtClass> {
   20.16   private:
   20.17 -  // A shared ConstantPool is never collected so we'll always have
   20.18 -  // a reference to it so we can update items in the cache. We'll
   20.19 -  // have a weak reference to a non-shared ConstantPool until all
   20.20 -  // of the methods (EMCP or obsolete) have been collected; the
   20.21 -  // non-shared ConstantPool becomes collectible at that point.
   20.22 -  ConstantPool*    _prev_constant_pool;  // regular or weak reference
   20.23 -  bool    _prev_cp_is_weak;     // true if not a shared ConstantPool
   20.24 +  ConstantPool*    _prev_constant_pool;
   20.25  
   20.26    // If the previous version of the InstanceKlass doesn't have any
   20.27    // EMCP methods, then _prev_EMCP_methods will be NULL. If all the
   20.28 @@ -1149,8 +1139,8 @@
   20.29    GrowableArray<Method*>* _prev_EMCP_methods;
   20.30  
   20.31  public:
   20.32 -  PreviousVersionNode(ConstantPool* prev_constant_pool, bool prev_cp_is_weak,
   20.33 -    GrowableArray<Method*>* prev_EMCP_methods);
   20.34 +  PreviousVersionNode(ConstantPool* prev_constant_pool,
   20.35 +                      GrowableArray<Method*>* prev_EMCP_methods);
   20.36    ~PreviousVersionNode();
   20.37    ConstantPool* prev_constant_pool() const {
   20.38      return _prev_constant_pool;
   20.39 @@ -1161,59 +1151,26 @@
   20.40  };
   20.41  
   20.42  
   20.43 -// A Handle-ized version of PreviousVersionNode.
   20.44 -class PreviousVersionInfo : public ResourceObj {
   20.45 - private:
   20.46 -  constantPoolHandle   _prev_constant_pool_handle;
   20.47 -  // If the previous version of the InstanceKlass doesn't have any
   20.48 -  // EMCP methods, then _prev_EMCP_methods will be NULL. Since the
   20.49 -  // methods cannot be collected while we hold a handle,
   20.50 -  // _prev_EMCP_methods should never have a length of zero.
   20.51 -  GrowableArray<methodHandle>* _prev_EMCP_method_handles;
   20.52 -
   20.53 -public:
   20.54 -  PreviousVersionInfo(PreviousVersionNode *pv_node);
   20.55 -  ~PreviousVersionInfo();
   20.56 -  constantPoolHandle prev_constant_pool_handle() const {
   20.57 -    return _prev_constant_pool_handle;
   20.58 -  }
   20.59 -  GrowableArray<methodHandle>* prev_EMCP_method_handles() const {
   20.60 -    return _prev_EMCP_method_handles;
   20.61 -  }
   20.62 -};
   20.63 -
   20.64 -
   20.65 -// Helper object for walking previous versions. This helper cleans up
   20.66 -// the Handles that it allocates when the helper object is destroyed.
   20.67 -// The PreviousVersionInfo object returned by next_previous_version()
   20.68 -// is only valid until a subsequent call to next_previous_version() or
   20.69 -// the helper object is destroyed.
   20.70 +// Helper object for walking previous versions.
   20.71  class PreviousVersionWalker : public StackObj {
   20.72   private:
   20.73 +  Thread*                               _thread;
   20.74    GrowableArray<PreviousVersionNode *>* _previous_versions;
   20.75    int                                   _current_index;
   20.76 -  // Fields for cleaning up when we are done walking the previous versions:
   20.77 -  // A HandleMark for the PreviousVersionInfo handles:
   20.78 -  HandleMark                            _hm;
   20.79  
   20.80 -  // It would be nice to have a ResourceMark field in this helper also,
   20.81 -  // but the ResourceMark code says to be careful to delete handles held
   20.82 -  // in GrowableArrays _before_ deleting the GrowableArray. Since we
   20.83 -  // can't guarantee the order in which the fields are destroyed, we
   20.84 -  // have to let the creator of the PreviousVersionWalker object do
   20.85 -  // the right thing. Also, adding a ResourceMark here causes an
   20.86 -  // include loop.
   20.87 +  // A pointer to the current node object so we can handle the deletes.
   20.88 +  PreviousVersionNode*                  _current_p;
   20.89  
   20.90 -  // A pointer to the current info object so we can handle the deletes.
   20.91 -  PreviousVersionInfo *                 _current_p;
   20.92 +  // The constant pool handle keeps all the methods in this class from being
   20.93 +  // deallocated from the metaspace during class unloading.
   20.94 +  constantPoolHandle                    _current_constant_pool_handle;
   20.95  
   20.96   public:
   20.97 -  PreviousVersionWalker(InstanceKlass *ik);
   20.98 -  ~PreviousVersionWalker();
   20.99 +  PreviousVersionWalker(Thread* thread, InstanceKlass *ik);
  20.100  
  20.101    // Return the interesting information for the next previous version
  20.102    // of the klass. Returns NULL if there are no more previous versions.
  20.103 -  PreviousVersionInfo* next_previous_version();
  20.104 +  PreviousVersionNode* next_previous_version();
  20.105  };
  20.106  
  20.107  
    21.1 --- a/src/share/vm/opto/bytecodeInfo.cpp	Thu Sep 26 12:49:45 2013 +0200
    21.2 +++ b/src/share/vm/opto/bytecodeInfo.cpp	Fri Sep 27 11:18:26 2013 +0200
    21.3 @@ -123,7 +123,7 @@
    21.4    // Allows targeted inlining
    21.5    if(callee_method->should_inline()) {
    21.6      *wci_result = *(WarmCallInfo::always_hot());
    21.7 -    if (PrintInlining && Verbose) {
    21.8 +    if (C->print_inlining() && Verbose) {
    21.9        CompileTask::print_inline_indent(inline_level());
   21.10        tty->print_cr("Inlined method is hot: ");
   21.11      }
   21.12 @@ -137,7 +137,7 @@
   21.13    if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
   21.14       size < InlineThrowMaxSize ) {
   21.15      wci_result->set_profit(wci_result->profit() * 100);
   21.16 -    if (PrintInlining && Verbose) {
   21.17 +    if (C->print_inlining() && Verbose) {
   21.18        CompileTask::print_inline_indent(inline_level());
   21.19        tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
   21.20      }
   21.21 @@ -491,7 +491,7 @@
   21.22        C->log()->inline_fail(inline_msg);
   21.23      }
   21.24    }
   21.25 -  if (PrintInlining) {
   21.26 +  if (C->print_inlining()) {
   21.27      C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
   21.28      if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
   21.29      if (Verbose && callee_method) {
   21.30 @@ -540,7 +540,7 @@
   21.31  
   21.32  #ifndef PRODUCT
   21.33    if (UseOldInlining && InlineWarmCalls
   21.34 -      && (PrintOpto || PrintOptoInlining || PrintInlining)) {
   21.35 +      && (PrintOpto || C->print_inlining())) {
   21.36      bool cold = wci.is_cold();
   21.37      bool hot  = !cold && wci.is_hot();
   21.38      bool old_cold = !success;
   21.39 @@ -617,7 +617,7 @@
   21.40               callee_method->is_compiled_lambda_form()) {
   21.41        max_inline_level_adjust += 1;  // don't count method handle calls from java.lang.invoke implem
   21.42      }
   21.43 -    if (max_inline_level_adjust != 0 && PrintInlining && (Verbose || WizardMode)) {
   21.44 +    if (max_inline_level_adjust != 0 && C->print_inlining() && (Verbose || WizardMode)) {
   21.45        CompileTask::print_inline_indent(inline_level());
   21.46        tty->print_cr(" \\-> discounting inline depth");
   21.47      }
    22.1 --- a/src/share/vm/opto/callGenerator.hpp	Thu Sep 26 12:49:45 2013 +0200
    22.2 +++ b/src/share/vm/opto/callGenerator.hpp	Fri Sep 27 11:18:26 2013 +0200
    22.3 @@ -159,8 +159,9 @@
    22.4    virtual void print_inlining_late(const char* msg) { ShouldNotReachHere(); }
    22.5  
    22.6    static void print_inlining(Compile* C, ciMethod* callee, int inline_level, int bci, const char* msg) {
    22.7 -    if (PrintInlining)
    22.8 +    if (C->print_inlining()) {
    22.9        C->print_inlining(callee, inline_level, bci, msg);
   22.10 +    }
   22.11    }
   22.12  };
   22.13  
    23.1 --- a/src/share/vm/opto/compile.cpp	Thu Sep 26 12:49:45 2013 +0200
    23.2 +++ b/src/share/vm/opto/compile.cpp	Fri Sep 27 11:18:26 2013 +0200
    23.3 @@ -654,7 +654,7 @@
    23.4                    _inlining_progress(false),
    23.5                    _inlining_incrementally(false),
    23.6                    _print_inlining_list(NULL),
    23.7 -                  _print_inlining(0) {
    23.8 +                  _print_inlining_idx(0) {
    23.9    C = this;
   23.10  
   23.11    CompileWrapper cw(this);
   23.12 @@ -679,6 +679,8 @@
   23.13    set_print_assembly(print_opto_assembly);
   23.14    set_parsed_irreducible_loop(false);
   23.15  #endif
   23.16 +  set_print_inlining(PrintInlining || method()->has_option("PrintInlining") NOT_PRODUCT( || PrintOptoInlining));
   23.17 +  set_print_intrinsics(PrintIntrinsics || method()->has_option("PrintIntrinsics"));
   23.18  
   23.19    if (ProfileTraps) {
   23.20      // Make sure the method being compiled gets its own MDO,
   23.21 @@ -710,7 +712,7 @@
   23.22    PhaseGVN gvn(node_arena(), estimated_size);
   23.23    set_initial_gvn(&gvn);
   23.24  
   23.25 -  if (PrintInlining  || PrintIntrinsics NOT_PRODUCT( || PrintOptoInlining)) {
   23.26 +  if (print_inlining() || print_intrinsics()) {
   23.27      _print_inlining_list = new (comp_arena())GrowableArray<PrintInliningBuffer>(comp_arena(), 1, 1, PrintInliningBuffer());
   23.28    }
   23.29    { // Scope for timing the parser
   23.30 @@ -937,7 +939,7 @@
   23.31      _inlining_progress(false),
   23.32      _inlining_incrementally(false),
   23.33      _print_inlining_list(NULL),
   23.34 -    _print_inlining(0) {
   23.35 +    _print_inlining_idx(0) {
   23.36    C = this;
   23.37  
   23.38  #ifndef PRODUCT
   23.39 @@ -3611,7 +3613,7 @@
   23.40  }
   23.41  
   23.42  void Compile::dump_inlining() {
   23.43 -  if (PrintInlining || PrintIntrinsics NOT_PRODUCT( || PrintOptoInlining)) {
   23.44 +  if (print_inlining() || print_intrinsics()) {
   23.45      // Print inlining message for candidates that we couldn't inline
   23.46      // for lack of space or non constant receiver
   23.47      for (int i = 0; i < _late_inlines.length(); i++) {
   23.48 @@ -3635,7 +3637,7 @@
   23.49        }
   23.50      }
   23.51      for (int i = 0; i < _print_inlining_list->length(); i++) {
   23.52 -      tty->print(_print_inlining_list->at(i).ss()->as_string());
   23.53 +      tty->print(_print_inlining_list->adr_at(i)->ss()->as_string());
   23.54      }
   23.55    }
   23.56  }
    24.1 --- a/src/share/vm/opto/compile.hpp	Thu Sep 26 12:49:45 2013 +0200
    24.2 +++ b/src/share/vm/opto/compile.hpp	Fri Sep 27 11:18:26 2013 +0200
    24.3 @@ -312,6 +312,8 @@
    24.4    bool                  _do_method_data_update; // True if we generate code to update MethodData*s
    24.5    int                   _AliasLevel;            // Locally-adjusted version of AliasLevel flag.
    24.6    bool                  _print_assembly;        // True if we should dump assembly code for this compilation
    24.7 +  bool                  _print_inlining;        // True if we should print inlining for this compilation
    24.8 +  bool                  _print_intrinsics;      // True if we should print intrinsics for this compilation
    24.9  #ifndef PRODUCT
   24.10    bool                  _trace_opto_output;
   24.11    bool                  _parsed_irreducible_loop; // True if ciTypeFlow detected irreducible loops during parsing
   24.12 @@ -414,7 +416,7 @@
   24.13    };
   24.14  
   24.15    GrowableArray<PrintInliningBuffer>* _print_inlining_list;
   24.16 -  int _print_inlining;
   24.17 +  int _print_inlining_idx;
   24.18  
   24.19    // Only keep nodes in the expensive node list that need to be optimized
   24.20    void cleanup_expensive_nodes(PhaseIterGVN &igvn);
   24.21 @@ -426,24 +428,24 @@
   24.22   public:
   24.23  
   24.24    outputStream* print_inlining_stream() const {
   24.25 -    return _print_inlining_list->at(_print_inlining).ss();
   24.26 +    return _print_inlining_list->adr_at(_print_inlining_idx)->ss();
   24.27    }
   24.28  
   24.29    void print_inlining_skip(CallGenerator* cg) {
   24.30 -    if (PrintInlining) {
   24.31 -      _print_inlining_list->at(_print_inlining).set_cg(cg);
   24.32 -      _print_inlining++;
   24.33 -      _print_inlining_list->insert_before(_print_inlining, PrintInliningBuffer());
   24.34 +    if (_print_inlining) {
   24.35 +      _print_inlining_list->adr_at(_print_inlining_idx)->set_cg(cg);
   24.36 +      _print_inlining_idx++;
   24.37 +      _print_inlining_list->insert_before(_print_inlining_idx, PrintInliningBuffer());
   24.38      }
   24.39    }
   24.40  
   24.41    void print_inlining_insert(CallGenerator* cg) {
   24.42 -    if (PrintInlining) {
   24.43 +    if (_print_inlining) {
   24.44        for (int i = 0; i < _print_inlining_list->length(); i++) {
   24.45 -        if (_print_inlining_list->at(i).cg() == cg) {
   24.46 +        if (_print_inlining_list->adr_at(i)->cg() == cg) {
   24.47            _print_inlining_list->insert_before(i+1, PrintInliningBuffer());
   24.48 -          _print_inlining = i+1;
   24.49 -          _print_inlining_list->at(i).set_cg(NULL);
   24.50 +          _print_inlining_idx = i+1;
   24.51 +          _print_inlining_list->adr_at(i)->set_cg(NULL);
   24.52            return;
   24.53          }
   24.54        }
   24.55 @@ -572,6 +574,10 @@
   24.56    int               AliasLevel() const          { return _AliasLevel; }
   24.57    bool              print_assembly() const       { return _print_assembly; }
   24.58    void          set_print_assembly(bool z)       { _print_assembly = z; }
   24.59 +  bool              print_inlining() const       { return _print_inlining; }
   24.60 +  void          set_print_inlining(bool z)       { _print_inlining = z; }
   24.61 +  bool              print_intrinsics() const     { return _print_intrinsics; }
   24.62 +  void          set_print_intrinsics(bool z)     { _print_intrinsics = z; }
   24.63    // check the CompilerOracle for special behaviours for this compile
   24.64    bool          method_has_option(const char * option) {
   24.65      return method() != NULL && method()->has_option(option);
    25.1 --- a/src/share/vm/opto/doCall.cpp	Thu Sep 26 12:49:45 2013 +0200
    25.2 +++ b/src/share/vm/opto/doCall.cpp	Fri Sep 27 11:18:26 2013 +0200
    25.3 @@ -41,9 +41,9 @@
    25.4  #include "runtime/sharedRuntime.hpp"
    25.5  
    25.6  void trace_type_profile(Compile* C, ciMethod *method, int depth, int bci, ciMethod *prof_method, ciKlass *prof_klass, int site_count, int receiver_count) {
    25.7 -  if (TraceTypeProfile || PrintInlining NOT_PRODUCT(|| PrintOptoInlining)) {
    25.8 +  if (TraceTypeProfile || C->print_inlining()) {
    25.9      outputStream* out = tty;
   25.10 -    if (!PrintInlining) {
   25.11 +    if (!C->print_inlining()) {
   25.12        if (NOT_PRODUCT(!PrintOpto &&) !PrintCompilation) {
   25.13          method->print_short_name();
   25.14          tty->cr();
    26.1 --- a/src/share/vm/opto/library_call.cpp	Thu Sep 26 12:49:45 2013 +0200
    26.2 +++ b/src/share/vm/opto/library_call.cpp	Fri Sep 27 11:18:26 2013 +0200
    26.3 @@ -543,7 +543,7 @@
    26.4    Compile* C = kit.C;
    26.5    int nodes = C->unique();
    26.6  #ifndef PRODUCT
    26.7 -  if ((PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) && Verbose) {
    26.8 +  if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
    26.9      char buf[1000];
   26.10      const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
   26.11      tty->print_cr("Intrinsic %s", str);
   26.12 @@ -554,7 +554,7 @@
   26.13  
   26.14    // Try to inline the intrinsic.
   26.15    if (kit.try_to_inline()) {
   26.16 -    if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
   26.17 +    if (C->print_intrinsics() || C->print_inlining()) {
   26.18        C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
   26.19      }
   26.20      C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
   26.21 @@ -570,7 +570,7 @@
   26.22    }
   26.23  
   26.24    // The intrinsic bailed out
   26.25 -  if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
   26.26 +  if (C->print_intrinsics() || C->print_inlining()) {
   26.27      if (jvms->has_method()) {
   26.28        // Not a root compile.
   26.29        const char* msg = is_virtual() ? "failed to inline (intrinsic, virtual)" : "failed to inline (intrinsic)";
   26.30 @@ -592,7 +592,7 @@
   26.31    int nodes = C->unique();
   26.32  #ifndef PRODUCT
   26.33    assert(is_predicted(), "sanity");
   26.34 -  if ((PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) && Verbose) {
   26.35 +  if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
   26.36      char buf[1000];
   26.37      const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf));
   26.38      tty->print_cr("Predicate for intrinsic %s", str);
   26.39 @@ -603,7 +603,7 @@
   26.40  
   26.41    Node* slow_ctl = kit.try_to_predicate();
   26.42    if (!kit.failing()) {
   26.43 -    if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
   26.44 +    if (C->print_intrinsics() || C->print_inlining()) {
   26.45        C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)");
   26.46      }
   26.47      C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked);
   26.48 @@ -617,7 +617,7 @@
   26.49    }
   26.50  
   26.51    // The intrinsic bailed out
   26.52 -  if (PrintIntrinsics || PrintInlining NOT_PRODUCT( || PrintOptoInlining) ) {
   26.53 +  if (C->print_intrinsics() || C->print_inlining()) {
   26.54      if (jvms->has_method()) {
   26.55        // Not a root compile.
   26.56        const char* msg = "failed to generate predicate for intrinsic";
   26.57 @@ -2299,7 +2299,7 @@
   26.58      const TypeOopPtr* tjp = TypeOopPtr::make_from_klass(sharpened_klass);
   26.59  
   26.60  #ifndef PRODUCT
   26.61 -    if (PrintIntrinsics || PrintInlining || PrintOptoInlining) {
   26.62 +    if (C->print_intrinsics() || C->print_inlining()) {
   26.63        tty->print("  from base type: ");  adr_type->dump();
   26.64        tty->print("  sharpened value: ");  tjp->dump();
   26.65      }
   26.66 @@ -3260,7 +3260,7 @@
   26.67    if (mirror_con == NULL)  return false;  // cannot happen?
   26.68  
   26.69  #ifndef PRODUCT
   26.70 -  if (PrintIntrinsics || PrintInlining || PrintOptoInlining) {
   26.71 +  if (C->print_intrinsics() || C->print_inlining()) {
   26.72      ciType* k = mirror_con->java_mirror_type();
   26.73      if (k) {
   26.74        tty->print("Inlining %s on constant Class ", vmIntrinsics::name_at(intrinsic_id()));
   26.75 @@ -3952,14 +3952,14 @@
   26.76  // caller sensitive methods.
   26.77  bool LibraryCallKit::inline_native_Reflection_getCallerClass() {
   26.78  #ifndef PRODUCT
   26.79 -  if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
   26.80 +  if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
   26.81      tty->print_cr("Attempting to inline sun.reflect.Reflection.getCallerClass");
   26.82    }
   26.83  #endif
   26.84  
   26.85    if (!jvms()->has_method()) {
   26.86  #ifndef PRODUCT
   26.87 -    if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
   26.88 +    if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
   26.89        tty->print_cr("  Bailing out because intrinsic was inlined at top level");
   26.90      }
   26.91  #endif
   26.92 @@ -3983,7 +3983,7 @@
   26.93        // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass).
   26.94        if (!m->caller_sensitive()) {
   26.95  #ifndef PRODUCT
   26.96 -        if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
   26.97 +        if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
   26.98            tty->print_cr("  Bailing out: CallerSensitive annotation expected at frame %d", n);
   26.99          }
  26.100  #endif
  26.101 @@ -3999,7 +3999,7 @@
  26.102          set_result(makecon(TypeInstPtr::make(caller_mirror)));
  26.103  
  26.104  #ifndef PRODUCT
  26.105 -        if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
  26.106 +        if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
  26.107            tty->print_cr("  Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth());
  26.108            tty->print_cr("  JVM state at this point:");
  26.109            for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
  26.110 @@ -4015,7 +4015,7 @@
  26.111    }
  26.112  
  26.113  #ifndef PRODUCT
  26.114 -  if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) {
  26.115 +  if ((C->print_intrinsics() || C->print_inlining()) && Verbose) {
  26.116      tty->print_cr("  Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth());
  26.117      tty->print_cr("  JVM state at this point:");
  26.118      for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) {
    27.1 --- a/src/share/vm/prims/jvm.cpp	Thu Sep 26 12:49:45 2013 +0200
    27.2 +++ b/src/share/vm/prims/jvm.cpp	Fri Sep 27 11:18:26 2013 +0200
    27.3 @@ -1835,16 +1835,27 @@
    27.4  }
    27.5  JVM_END
    27.6  
    27.7 -JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly))
    27.8 -{
    27.9 -  JVMWrapper("JVM_GetClassDeclaredMethods");
   27.10 +static bool select_method(methodHandle method, bool want_constructor) {
   27.11 +  if (want_constructor) {
   27.12 +    return (method->is_initializer() && !method->is_static());
   27.13 +  } else {
   27.14 +    return  (!method->is_initializer() && !method->is_overpass());
   27.15 +  }
   27.16 +}
   27.17 +
   27.18 +static jobjectArray get_class_declared_methods_helper(
   27.19 +                                  JNIEnv *env,
   27.20 +                                  jclass ofClass, jboolean publicOnly,
   27.21 +                                  bool want_constructor,
   27.22 +                                  Klass* klass, TRAPS) {
   27.23 +
   27.24    JvmtiVMObjectAllocEventCollector oam;
   27.25  
   27.26    // Exclude primitive types and array types
   27.27    if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass))
   27.28        || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) {
   27.29      // Return empty array
   27.30 -    oop res = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), 0, CHECK_NULL);
   27.31 +    oop res = oopFactory::new_objArray(klass, 0, CHECK_NULL);
   27.32      return (jobjectArray) JNIHandles::make_local(env, res);
   27.33    }
   27.34  
   27.35 @@ -1855,87 +1866,67 @@
   27.36  
   27.37    Array<Method*>* methods = k->methods();
   27.38    int methods_length = methods->length();
   27.39 +
   27.40 +  // Save original method_idnum in case of redefinition, which can change
   27.41 +  // the idnum of obsolete methods.  The new method will have the same idnum
   27.42 +  // but if we refresh the methods array, the counts will be wrong.
   27.43 +  ResourceMark rm(THREAD);
   27.44 +  GrowableArray<int>* idnums = new GrowableArray<int>(methods_length);
   27.45    int num_methods = 0;
   27.46  
   27.47 -  int i;
   27.48 -  for (i = 0; i < methods_length; i++) {
   27.49 +  for (int i = 0; i < methods_length; i++) {
   27.50      methodHandle method(THREAD, methods->at(i));
   27.51 -    if (!method->is_initializer() && !method->is_overpass()) {
   27.52 +    if (select_method(method, want_constructor)) {
   27.53        if (!publicOnly || method->is_public()) {
   27.54 +        idnums->push(method->method_idnum());
   27.55          ++num_methods;
   27.56        }
   27.57      }
   27.58    }
   27.59  
   27.60    // Allocate result
   27.61 -  objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Method_klass(), num_methods, CHECK_NULL);
   27.62 +  objArrayOop r = oopFactory::new_objArray(klass, num_methods, CHECK_NULL);
   27.63    objArrayHandle result (THREAD, r);
   27.64  
   27.65 -  int out_idx = 0;
   27.66 -  for (i = 0; i < methods_length; i++) {
   27.67 -    methodHandle method(THREAD, methods->at(i));
   27.68 -    if (!method->is_initializer() && !method->is_overpass()) {
   27.69 -      if (!publicOnly || method->is_public()) {
   27.70 -        oop m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL);
   27.71 -        result->obj_at_put(out_idx, m);
   27.72 -        ++out_idx;
   27.73 +  // Now just put the methods that we selected above, but go by their idnum
   27.74 +  // in case of redefinition.  The methods can be redefined at any safepoint,
   27.75 +  // so above when allocating the oop array and below when creating reflect
   27.76 +  // objects.
   27.77 +  for (int i = 0; i < num_methods; i++) {
   27.78 +    methodHandle method(THREAD, k->method_with_idnum(idnums->at(i)));
   27.79 +    if (method.is_null()) {
   27.80 +      // Method may have been deleted and seems this API can handle null
   27.81 +      // Otherwise should probably put a method that throws NSME
   27.82 +      result->obj_at_put(i, NULL);
   27.83 +    } else {
   27.84 +      oop m;
   27.85 +      if (want_constructor) {
   27.86 +        m = Reflection::new_constructor(method, CHECK_NULL);
   27.87 +      } else {
   27.88 +        m = Reflection::new_method(method, UseNewReflection, false, CHECK_NULL);
   27.89        }
   27.90 +      result->obj_at_put(i, m);
   27.91      }
   27.92    }
   27.93 -  assert(out_idx == num_methods, "just checking");
   27.94 +
   27.95    return (jobjectArray) JNIHandles::make_local(env, result());
   27.96  }
   27.97 +
   27.98 +JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly))
   27.99 +{
  27.100 +  JVMWrapper("JVM_GetClassDeclaredMethods");
  27.101 +  return get_class_declared_methods_helper(env, ofClass, publicOnly,
  27.102 +                                           /*want_constructor*/ false,
  27.103 +                                           SystemDictionary::reflect_Method_klass(), THREAD);
  27.104 +}
  27.105  JVM_END
  27.106  
  27.107  JVM_ENTRY(jobjectArray, JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly))
  27.108  {
  27.109    JVMWrapper("JVM_GetClassDeclaredConstructors");
  27.110 -  JvmtiVMObjectAllocEventCollector oam;
  27.111 -
  27.112 -  // Exclude primitive types and array types
  27.113 -  if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass))
  27.114 -      || java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass))->oop_is_array()) {
  27.115 -    // Return empty array
  27.116 -    oop res = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), 0 , CHECK_NULL);
  27.117 -    return (jobjectArray) JNIHandles::make_local(env, res);
  27.118 -  }
  27.119 -
  27.120 -  instanceKlassHandle k(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(ofClass)));
  27.121 -
  27.122 -  // Ensure class is linked
  27.123 -  k->link_class(CHECK_NULL);
  27.124 -
  27.125 -  Array<Method*>* methods = k->methods();
  27.126 -  int methods_length = methods->length();
  27.127 -  int num_constructors = 0;
  27.128 -
  27.129 -  int i;
  27.130 -  for (i = 0; i < methods_length; i++) {
  27.131 -    methodHandle method(THREAD, methods->at(i));
  27.132 -    if (method->is_initializer() && !method->is_static()) {
  27.133 -      if (!publicOnly || method->is_public()) {
  27.134 -        ++num_constructors;
  27.135 -      }
  27.136 -    }
  27.137 -  }
  27.138 -
  27.139 -  // Allocate result
  27.140 -  objArrayOop r = oopFactory::new_objArray(SystemDictionary::reflect_Constructor_klass(), num_constructors, CHECK_NULL);
  27.141 -  objArrayHandle result(THREAD, r);
  27.142 -
  27.143 -  int out_idx = 0;
  27.144 -  for (i = 0; i < methods_length; i++) {
  27.145 -    methodHandle method(THREAD, methods->at(i));
  27.146 -    if (method->is_initializer() && !method->is_static()) {
  27.147 -      if (!publicOnly || method->is_public()) {
  27.148 -        oop m = Reflection::new_constructor(method, CHECK_NULL);
  27.149 -        result->obj_at_put(out_idx, m);
  27.150 -        ++out_idx;
  27.151 -      }
  27.152 -    }
  27.153 -  }
  27.154 -  assert(out_idx == num_constructors, "just checking");
  27.155 -  return (jobjectArray) JNIHandles::make_local(env, result());
  27.156 +  return get_class_declared_methods_helper(env, ofClass, publicOnly,
  27.157 +                                           /*want_constructor*/ true,
  27.158 +                                           SystemDictionary::reflect_Constructor_klass(), THREAD);
  27.159  }
  27.160  JVM_END
  27.161  
    28.1 --- a/src/share/vm/prims/jvmtiEnvBase.hpp	Thu Sep 26 12:49:45 2013 +0200
    28.2 +++ b/src/share/vm/prims/jvmtiEnvBase.hpp	Fri Sep 27 11:18:26 2013 +0200
    28.3 @@ -406,7 +406,11 @@
    28.4    VMOp_Type type() const { return VMOp_GetCurrentContendedMonitor; }
    28.5    jvmtiError result() { return _result; }
    28.6    void doit() {
    28.7 -    _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,_java_thread,_owned_monitor_ptr);
    28.8 +    _result = JVMTI_ERROR_THREAD_NOT_ALIVE;
    28.9 +    if (Threads::includes(_java_thread) && !_java_thread->is_exiting() &&
   28.10 +        _java_thread->threadObj() != NULL) {
   28.11 +      _result = ((JvmtiEnvBase *)_env)->get_current_contended_monitor(_calling_thread,_java_thread,_owned_monitor_ptr);
   28.12 +    }
   28.13    }
   28.14  };
   28.15  
    29.1 --- a/src/share/vm/prims/jvmtiImpl.cpp	Thu Sep 26 12:49:45 2013 +0200
    29.2 +++ b/src/share/vm/prims/jvmtiImpl.cpp	Fri Sep 27 11:18:26 2013 +0200
    29.3 @@ -273,59 +273,49 @@
    29.4  
    29.5    // add/remove breakpoint to/from versions of the method that
    29.6    // are EMCP. Directly or transitively obsolete methods are
    29.7 -  // not saved in the PreviousVersionInfo.
    29.8 +  // not saved in the PreviousVersionNodes.
    29.9    Thread *thread = Thread::current();
   29.10    instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder());
   29.11    Symbol* m_name = _method->name();
   29.12    Symbol* m_signature = _method->signature();
   29.13  
   29.14 -  {
   29.15 -    ResourceMark rm(thread);
   29.16 -    // PreviousVersionInfo objects returned via PreviousVersionWalker
   29.17 -    // contain a GrowableArray of handles. We have to clean up the
   29.18 -    // GrowableArray _after_ the PreviousVersionWalker destructor
   29.19 -    // has destroyed the handles.
   29.20 -    {
   29.21 -      // search previous versions if they exist
   29.22 -      PreviousVersionWalker pvw((InstanceKlass *)ikh());
   29.23 -      for (PreviousVersionInfo * pv_info = pvw.next_previous_version();
   29.24 -           pv_info != NULL; pv_info = pvw.next_previous_version()) {
   29.25 -        GrowableArray<methodHandle>* methods =
   29.26 -          pv_info->prev_EMCP_method_handles();
   29.27 +  // search previous versions if they exist
   29.28 +  PreviousVersionWalker pvw(thread, (InstanceKlass *)ikh());
   29.29 +  for (PreviousVersionNode * pv_node = pvw.next_previous_version();
   29.30 +       pv_node != NULL; pv_node = pvw.next_previous_version()) {
   29.31 +    GrowableArray<Method*>* methods = pv_node->prev_EMCP_methods();
   29.32  
   29.33 -        if (methods == NULL) {
   29.34 -          // We have run into a PreviousVersion generation where
   29.35 -          // all methods were made obsolete during that generation's
   29.36 -          // RedefineClasses() operation. At the time of that
   29.37 -          // operation, all EMCP methods were flushed so we don't
   29.38 -          // have to go back any further.
   29.39 -          //
   29.40 -          // A NULL methods array is different than an empty methods
   29.41 -          // array. We cannot infer any optimizations about older
   29.42 -          // generations from an empty methods array for the current
   29.43 -          // generation.
   29.44 -          break;
   29.45 -        }
   29.46 +    if (methods == NULL) {
   29.47 +      // We have run into a PreviousVersion generation where
   29.48 +      // all methods were made obsolete during that generation's
   29.49 +      // RedefineClasses() operation. At the time of that
   29.50 +      // operation, all EMCP methods were flushed so we don't
   29.51 +      // have to go back any further.
   29.52 +      //
   29.53 +      // A NULL methods array is different than an empty methods
   29.54 +      // array. We cannot infer any optimizations about older
   29.55 +      // generations from an empty methods array for the current
   29.56 +      // generation.
   29.57 +      break;
   29.58 +    }
   29.59  
   29.60 -        for (int i = methods->length() - 1; i >= 0; i--) {
   29.61 -          methodHandle method = methods->at(i);
   29.62 -          // obsolete methods that are running are not deleted from
   29.63 -          // previous version array, but they are skipped here.
   29.64 -          if (!method->is_obsolete() &&
   29.65 -              method->name() == m_name &&
   29.66 -              method->signature() == m_signature) {
   29.67 -            RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)",
   29.68 -              meth_act == &Method::set_breakpoint ? "sett" : "clear",
   29.69 -              method->name()->as_C_string(),
   29.70 -              method->signature()->as_C_string()));
   29.71 +    for (int i = methods->length() - 1; i >= 0; i--) {
   29.72 +      Method* method = methods->at(i);
   29.73 +      // obsolete methods that are running are not deleted from
   29.74 +      // previous version array, but they are skipped here.
   29.75 +      if (!method->is_obsolete() &&
   29.76 +          method->name() == m_name &&
   29.77 +          method->signature() == m_signature) {
   29.78 +        RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)",
   29.79 +          meth_act == &Method::set_breakpoint ? "sett" : "clear",
   29.80 +          method->name()->as_C_string(),
   29.81 +          method->signature()->as_C_string()));
   29.82  
   29.83 -            ((Method*)method()->*meth_act)(_bci);
   29.84 -            break;
   29.85 -          }
   29.86 -        }
   29.87 +        (method->*meth_act)(_bci);
   29.88 +        break;
   29.89        }
   29.90 -    } // pvw is cleaned up
   29.91 -  } // rm is cleaned up
   29.92 +    }
   29.93 +  }
   29.94  }
   29.95  
   29.96  void JvmtiBreakpoint::set() {
    30.1 --- a/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Sep 26 12:49:45 2013 +0200
    30.2 +++ b/src/share/vm/prims/jvmtiRedefineClasses.cpp	Fri Sep 27 11:18:26 2013 +0200
    30.3 @@ -2807,28 +2807,20 @@
    30.4                                          &trace_name_printed);
    30.5        }
    30.6      }
    30.7 -    {
    30.8 -      ResourceMark rm(_thread);
    30.9 -      // PreviousVersionInfo objects returned via PreviousVersionWalker
   30.10 -      // contain a GrowableArray of handles. We have to clean up the
   30.11 -      // GrowableArray _after_ the PreviousVersionWalker destructor
   30.12 -      // has destroyed the handles.
   30.13 -      {
   30.14 -        // the previous versions' constant pool caches may need adjustment
   30.15 -        PreviousVersionWalker pvw(ik);
   30.16 -        for (PreviousVersionInfo * pv_info = pvw.next_previous_version();
   30.17 -             pv_info != NULL; pv_info = pvw.next_previous_version()) {
   30.18 -          other_cp = pv_info->prev_constant_pool_handle();
   30.19 -          cp_cache = other_cp->cache();
   30.20 -          if (cp_cache != NULL) {
   30.21 -            cp_cache->adjust_method_entries(_matching_old_methods,
   30.22 -                                            _matching_new_methods,
   30.23 -                                            _matching_methods_length,
   30.24 -                                            &trace_name_printed);
   30.25 -          }
   30.26 -        }
   30.27 -      } // pvw is cleaned up
   30.28 -    } // rm is cleaned up
   30.29 +
   30.30 +    // the previous versions' constant pool caches may need adjustment
   30.31 +    PreviousVersionWalker pvw(_thread, ik);
   30.32 +    for (PreviousVersionNode * pv_node = pvw.next_previous_version();
   30.33 +         pv_node != NULL; pv_node = pvw.next_previous_version()) {
   30.34 +      other_cp = pv_node->prev_constant_pool();
   30.35 +      cp_cache = other_cp->cache();
   30.36 +      if (cp_cache != NULL) {
   30.37 +        cp_cache->adjust_method_entries(_matching_old_methods,
   30.38 +                                        _matching_new_methods,
   30.39 +                                        _matching_methods_length,
   30.40 +                                        &trace_name_printed);
   30.41 +      }
   30.42 +    }
   30.43    }
   30.44  }
   30.45  
   30.46 @@ -2942,10 +2934,9 @@
   30.47        // obsolete methods need a unique idnum
   30.48        u2 num = InstanceKlass::cast(_the_class_oop)->next_method_idnum();
   30.49        if (num != ConstMethod::UNSET_IDNUM) {
   30.50 -//      u2 old_num = old_method->method_idnum();
   30.51          old_method->set_method_idnum(num);
   30.52 -// TO DO: attach obsolete annotations to obsolete method's new idnum
   30.53        }
   30.54 +
   30.55        // With tracing we try not to "yack" too much. The position of
   30.56        // this trace assumes there are fewer obsolete methods than
   30.57        // EMCP methods.
    31.1 --- a/src/share/vm/runtime/arguments.cpp	Thu Sep 26 12:49:45 2013 +0200
    31.2 +++ b/src/share/vm/runtime/arguments.cpp	Fri Sep 27 11:18:26 2013 +0200
    31.3 @@ -1100,6 +1100,7 @@
    31.4    }
    31.5  }
    31.6  
    31.7 +#if defined(COMPILER2) || defined(_LP64) || !INCLUDE_CDS
    31.8  // Conflict: required to use shared spaces (-Xshare:on), but
    31.9  // incompatible command line options were chosen.
   31.10  
   31.11 @@ -1112,6 +1113,7 @@
   31.12      FLAG_SET_DEFAULT(UseSharedSpaces, false);
   31.13    }
   31.14  }
   31.15 +#endif
   31.16  
   31.17  void Arguments::set_tiered_flags() {
   31.18    // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
   31.19 @@ -1520,16 +1522,18 @@
   31.20          FLAG_SET_ERGO(bool, UseParallelGC, true);
   31.21        }
   31.22      }
   31.23 -    // Shared spaces work fine with other GCs but causes bytecode rewriting
   31.24 -    // to be disabled, which hurts interpreter performance and decreases
   31.25 -    // server performance.   On server class machines, keep the default
   31.26 -    // off unless it is asked for.  Future work: either add bytecode rewriting
   31.27 -    // at link time, or rewrite bytecodes in non-shared methods.
   31.28 -    if (!DumpSharedSpaces && !RequireSharedSpaces &&
   31.29 -        (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
   31.30 -      no_shared_spaces();
   31.31 -    }
   31.32    }
   31.33 +#ifdef COMPILER2
   31.34 +  // Shared spaces work fine with other GCs but causes bytecode rewriting
   31.35 +  // to be disabled, which hurts interpreter performance and decreases
   31.36 +  // server performance.  When -server is specified, keep the default off
   31.37 +  // unless it is asked for.  Future work: either add bytecode rewriting
   31.38 +  // at link time, or rewrite bytecodes in non-shared methods.
   31.39 +  if (!DumpSharedSpaces && !RequireSharedSpaces &&
   31.40 +      (FLAG_IS_DEFAULT(UseSharedSpaces) || !UseSharedSpaces)) {
   31.41 +    no_shared_spaces();
   31.42 +  }
   31.43 +#endif
   31.44  
   31.45    set_conservative_max_heap_alignment();
   31.46  
   31.47 @@ -2439,21 +2443,6 @@
   31.48      return result;
   31.49    }
   31.50  
   31.51 -  if (AggressiveOpts) {
   31.52 -    // Insert alt-rt.jar between user-specified bootclasspath
   31.53 -    // prefix and the default bootclasspath.  os::set_boot_path()
   31.54 -    // uses meta_index_dir as the default bootclasspath directory.
   31.55 -    const char* altclasses_jar = "alt-rt.jar";
   31.56 -    size_t altclasses_path_len = strlen(get_meta_index_dir()) + 1 +
   31.57 -                                 strlen(altclasses_jar);
   31.58 -    char* altclasses_path = NEW_C_HEAP_ARRAY(char, altclasses_path_len, mtInternal);
   31.59 -    strcpy(altclasses_path, get_meta_index_dir());
   31.60 -    strcat(altclasses_path, altclasses_jar);
   31.61 -    scp.add_suffix_to_prefix(altclasses_path);
   31.62 -    scp_assembly_required = true;
   31.63 -    FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal);
   31.64 -  }
   31.65 -
   31.66    // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
   31.67    result = parse_java_options_environment_variable(&scp, &scp_assembly_required);
   31.68    if (result != JNI_OK) {
    32.1 --- a/src/share/vm/runtime/globals.hpp	Thu Sep 26 12:49:45 2013 +0200
    32.2 +++ b/src/share/vm/runtime/globals.hpp	Fri Sep 27 11:18:26 2013 +0200
    32.3 @@ -2526,6 +2526,9 @@
    32.4    product(bool, PrintStringTableStatistics, false,                          \
    32.5            "print statistics about the StringTable and SymbolTable")         \
    32.6                                                                              \
    32.7 +  diagnostic(bool, VerifyStringTableAtExit, false,                          \
    32.8 +          "verify StringTable contents at exit")                            \
    32.9 +                                                                            \
   32.10    notproduct(bool, PrintSymbolTableSizeHistogram, false,                    \
   32.11            "print histogram of the symbol table")                            \
   32.12                                                                              \
    33.1 --- a/src/share/vm/runtime/handles.hpp	Thu Sep 26 12:49:45 2013 +0200
    33.2 +++ b/src/share/vm/runtime/handles.hpp	Fri Sep 27 11:18:26 2013 +0200
    33.3 @@ -136,7 +136,7 @@
    33.4  // Specific Handles for different oop types
    33.5  #define DEF_METADATA_HANDLE(name, type)          \
    33.6    class name##Handle;                            \
    33.7 -  class name##Handle {                           \
    33.8 +  class name##Handle : public StackObj {         \
    33.9      type*     _value;                            \
   33.10      Thread*   _thread;                           \
   33.11     protected:                                    \
   33.12 @@ -175,7 +175,7 @@
   33.13  // Writing this class explicitly, since DEF_METADATA_HANDLE(klass) doesn't
   33.14  // provide the necessary Klass* <-> Klass* conversions. This Klass
   33.15  // could be removed when we don't have the Klass* typedef anymore.
   33.16 -class KlassHandle {
   33.17 +class KlassHandle : public StackObj {
   33.18    Klass* _value;
   33.19   protected:
   33.20     Klass* obj() const          { return _value; }
    34.1 --- a/src/share/vm/runtime/handles.inline.hpp	Thu Sep 26 12:49:45 2013 +0200
    34.2 +++ b/src/share/vm/runtime/handles.inline.hpp	Fri Sep 27 11:18:26 2013 +0200
    34.3 @@ -79,6 +79,7 @@
    34.4      } else {                                                           \
    34.5        _thread = Thread::current();                                     \
    34.6      }                                                                  \
    34.7 +    assert (_thread->is_in_stack((address)this), "not on stack?");     \
    34.8      _thread->metadata_handles()->push((Metadata*)_value);              \
    34.9    } else {                                                             \
   34.10      _thread = NULL;                                                    \
   34.11 @@ -95,6 +96,7 @@
   34.12      } else {                                                           \
   34.13        _thread = Thread::current();                                     \
   34.14      }                                                                  \
   34.15 +    assert (_thread->is_in_stack((address)this), "not on stack?");     \
   34.16      _thread->metadata_handles()->push((Metadata*)_value);              \
   34.17    } else {                                                             \
   34.18      _thread = NULL;                                                    \
    35.1 --- a/src/share/vm/runtime/java.cpp	Thu Sep 26 12:49:45 2013 +0200
    35.2 +++ b/src/share/vm/runtime/java.cpp	Fri Sep 27 11:18:26 2013 +0200
    35.3 @@ -544,6 +544,19 @@
    35.4    // it will run into trouble when system destroys static variables.
    35.5    MemTracker::shutdown(MemTracker::NMT_normal);
    35.6  
    35.7 +  if (VerifyStringTableAtExit) {
    35.8 +    int fail_cnt = 0;
    35.9 +    {
   35.10 +      MutexLocker ml(StringTable_lock);
   35.11 +      fail_cnt = StringTable::verify_and_compare_entries();
   35.12 +    }
   35.13 +
   35.14 +    if (fail_cnt != 0) {
   35.15 +      tty->print_cr("ERROR: fail_cnt=%d", fail_cnt);
   35.16 +      guarantee(fail_cnt == 0, "unexpected StringTable verification failures");
   35.17 +    }
   35.18 +  }
   35.19 +
   35.20    #undef BEFORE_EXIT_NOT_RUN
   35.21    #undef BEFORE_EXIT_RUNNING
   35.22    #undef BEFORE_EXIT_DONE
    36.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Thu Sep 26 12:49:45 2013 +0200
    36.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Fri Sep 27 11:18:26 2013 +0200
    36.3 @@ -1506,8 +1506,11 @@
    36.4                                                  info, CHECK_(methodHandle()));
    36.5          inline_cache->set_to_monomorphic(info);
    36.6        } else if (!inline_cache->is_megamorphic() && !inline_cache->is_clean()) {
    36.7 -        // Change to megamorphic
    36.8 -        inline_cache->set_to_megamorphic(&call_info, bc, CHECK_(methodHandle()));
    36.9 +        // Potential change to megamorphic
   36.10 +        bool successful = inline_cache->set_to_megamorphic(&call_info, bc, CHECK_(methodHandle()));
   36.11 +        if (!successful) {
   36.12 +          inline_cache->set_to_clean();
   36.13 +        }
   36.14        } else {
   36.15          // Either clean or megamorphic
   36.16        }
    37.1 --- a/src/share/vm/runtime/vm_version.hpp	Thu Sep 26 12:49:45 2013 +0200
    37.2 +++ b/src/share/vm/runtime/vm_version.hpp	Fri Sep 27 11:18:26 2013 +0200
    37.3 @@ -78,7 +78,13 @@
    37.4    static const char* jre_release_version();
    37.5  
    37.6    // does HW support an 8-byte compare-exchange operation?
    37.7 -  static bool supports_cx8()  {return _supports_cx8;}
    37.8 +  static bool supports_cx8()  {
    37.9 +#ifdef SUPPORTS_NATIVE_CX8
   37.10 +    return true;
   37.11 +#else
   37.12 +    return _supports_cx8;
   37.13 +#endif
   37.14 +  }
   37.15    // does HW support atomic get-and-set or atomic get-and-add?  Used
   37.16    // to guide intrinsification decisions for Unsafe atomic ops
   37.17    static bool supports_atomic_getset4()  {return _supports_atomic_getset4;}
    38.1 --- a/src/share/vm/services/attachListener.cpp	Thu Sep 26 12:49:45 2013 +0200
    38.2 +++ b/src/share/vm/services/attachListener.cpp	Fri Sep 27 11:18:26 2013 +0200
    38.3 @@ -470,7 +470,17 @@
    38.4                         vmSymbols::threadgroup_string_void_signature(),
    38.5                         thread_group,
    38.6                         string,
    38.7 -                       CHECK);
    38.8 +                       THREAD);
    38.9 +
   38.10 +  if (HAS_PENDING_EXCEPTION) {
   38.11 +    tty->print_cr("Exception in VM (AttachListener::init) : ");
   38.12 +    java_lang_Throwable::print(PENDING_EXCEPTION, tty);
   38.13 +    tty->cr();
   38.14 +
   38.15 +    CLEAR_PENDING_EXCEPTION;
   38.16 +
   38.17 +    return;
   38.18 +  }
   38.19  
   38.20    KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass());
   38.21    JavaCalls::call_special(&result,
   38.22 @@ -479,7 +489,17 @@
   38.23                          vmSymbols::add_method_name(),
   38.24                          vmSymbols::thread_void_signature(),
   38.25                          thread_oop,             // ARG 1
   38.26 -                        CHECK);
   38.27 +                        THREAD);
   38.28 +
   38.29 +  if (HAS_PENDING_EXCEPTION) {
   38.30 +    tty->print_cr("Exception in VM (AttachListener::init) : ");
   38.31 +    java_lang_Throwable::print(PENDING_EXCEPTION, tty);
   38.32 +    tty->cr();
   38.33 +
   38.34 +    CLEAR_PENDING_EXCEPTION;
   38.35 +
   38.36 +    return;
   38.37 +  }
   38.38  
   38.39    { MutexLocker mu(Threads_lock);
   38.40      JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry);
    39.1 --- a/src/share/vm/services/diagnosticArgument.cpp	Thu Sep 26 12:49:45 2013 +0200
    39.2 +++ b/src/share/vm/services/diagnosticArgument.cpp	Fri Sep 27 11:18:26 2013 +0200
    39.3 @@ -61,7 +61,7 @@
    39.4  }
    39.5  
    39.6  void GenDCmdArgument::to_string(char* c, char* buf, size_t len) {
    39.7 -  jio_snprintf(buf, len, "%s", c);
    39.8 +  jio_snprintf(buf, len, "%s", (c != NULL) ? c : "");
    39.9  }
   39.10  
   39.11  void GenDCmdArgument::to_string(StringArrayArgument* f, char* buf, size_t len) {
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/compiler/print/PrintInlining.java	Fri Sep 27 11:18:26 2013 +0200
    40.3 @@ -0,0 +1,36 @@
    40.4 +/*
    40.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 + *
    40.8 + * This code is free software; you can redistribute it and/or modify it
    40.9 + * under the terms of the GNU General Public License version 2 only, as
   40.10 + * published by the Free Software Foundation.
   40.11 + *
   40.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   40.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.15 + * version 2 for more details (a copy is included in the LICENSE file that
   40.16 + * accompanied this code).
   40.17 + *
   40.18 + * You should have received a copy of the GNU General Public License version
   40.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   40.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.21 + *
   40.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   40.23 + * or visit www.oracle.com if you need additional information or have any
   40.24 + * questions.
   40.25 + */
   40.26 +
   40.27 +/*
   40.28 + * @test
   40.29 + * @bug 8022585
   40.30 + * @summary VM crashes when ran with -XX:+PrintInlining
   40.31 + * @run main/othervm -Xcomp -XX:+PrintInlining PrintInlining
   40.32 + *
   40.33 + */
   40.34 +
   40.35 +public class PrintInlining {
   40.36 +  public static void main(String[] args) {
   40.37 +    System.out.println("Passed");
   40.38 +  }
   40.39 +}
    41.1 --- a/test/runtime/CDSCompressedKPtrs/XShareAuto.java	Thu Sep 26 12:49:45 2013 +0200
    41.2 +++ b/test/runtime/CDSCompressedKPtrs/XShareAuto.java	Fri Sep 27 11:18:26 2013 +0200
    41.3 @@ -33,16 +33,9 @@
    41.4  
    41.5  public class XShareAuto {
    41.6      public static void main(String[] args) throws Exception {
    41.7 -        if (!Platform.is64bit()) {
    41.8 -            System.out.println("ObjectAlignmentInBytes for CDS is only " +
    41.9 -                "supported on 64bit platforms; this plaform is " +
   41.10 -                System.getProperty("sun.arch.data.model"));
   41.11 -            System.out.println("Skipping the test");
   41.12 -            return;
   41.13 -        }
   41.14          ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   41.15 -            "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
   41.16 -            "-Xshare:dump");
   41.17 +            "-server", "-XX:+UnlockDiagnosticVMOptions",
   41.18 +            "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
   41.19          OutputAnalyzer output = new OutputAnalyzer(pb.start());
   41.20          output.shouldContain("Loading classes to share");
   41.21          output.shouldHaveExitValue(0);

mercurial