Merge

Mon, 24 Jul 2017 09:32:40 -0700

author
asaha
date
Mon, 24 Jul 2017 09:32:40 -0700
changeset 8998
1e225dabccc5
parent 8811
bfa3989eb8d3
parent 8990
7245ee7fa44a
child 8999
53d23b6b25cd

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Fri Jul 21 20:31:41 2017 -0700
     1.2 +++ b/.hgtags	Mon Jul 24 09:32:40 2017 -0700
     1.3 @@ -931,6 +931,8 @@
     1.4  b28d012a24cab8f4ceeee0c9d3252969757423ed jdk8u112-b15
     1.5  e134dc1879b72124e478be01680b0646a2fbf585 jdk8u112-b16
     1.6  87440ed4e1de7753a436f957d35555d8b4e26f1d jdk8u112-b31
     1.7 +ba25f5833a128b8062e597f794efda26b30f095d jdk8u112-b32
     1.8 +919ffdca10c2721ee0f6f233e704709174556510 jdk8u112-b33
     1.9  3b0e5f01891f5ebbf67797b1aae786196f1bb4f6 jdk8u121-b00
    1.10  251a2493b1857f2ff4f11eab2dfd8b2fe8ed441b jdk8u121-b01
    1.11  70c4a50f576a01ec975d0a02b3642ee33db39ed8 jdk8u121-b02
    1.12 @@ -945,6 +947,12 @@
    1.13  11f91811e4d7e5ddfaf938dcf386ec8fe5bf7b7c jdk8u121-b11
    1.14  b132b08b28bf23a26329928cf6b4ffda5857f4d3 jdk8u121-b12
    1.15  90f94521c3515e5f27af0ab9b31d036e88bb322a jdk8u121-b13
    1.16 +351bf1d4ff9a41137f91e2ec97ec59ed29a38d8b jdk8u121-b31
    1.17 +41daac438a2ac5a80755dc3de88b76e4ac66750a jdk8u121-b32
    1.18 +eb9e617d6f64d4ad689feac0707b5e4335b00ce2 jdk8u121-b33
    1.19 +c60b0994e8eee152666252c3ba4105db65c004db jdk8u121-b34
    1.20 +0612a789929b88612509668bea4b3138613e91e4 jdk8u121-b35
    1.21 +0ea269e49511a890e6fabfd468638dd1c0ed0be3 jdk8u121-b36
    1.22  c0a1ba0df20fda10ddb8599e888eb56ad98b3874 jdk8u131-b00
    1.23  0b85ccd6240991e1a501602ff5addec6b88ae0af jdk8u131-b01
    1.24  ef90c721a4e59b01ca36f25619010a1afe9ed4d5 jdk8u131-b02
    1.25 @@ -957,6 +965,10 @@
    1.26  56e71d16083904ceddfdd1d66312582a42781646 jdk8u131-b09
    1.27  1da23ae49386608550596502d90a381ee6c1dfaa jdk8u131-b10
    1.28  829ea9b92cda9545652f1b309f56c57383024ebb jdk8u131-b11
    1.29 +41e0713bcca27cef5d6a9afd44c7ca4811937713 jdk8u131-b31
    1.30 +e318654a4fa352a06935dd56eebf88ae387b31f9 jdk8u131-b32
    1.31 +32998fc932dc58c6bbac185cc17d2752fa6dba4c jdk8u131-b33
    1.32 +50b3fa6791f46bc582528bdc7f6311b3b6832c51 jdk8u131-b34
    1.33  692bc6b674dcab72453de08ee9da0856a7e41c0f jdk8u141-b00
    1.34  0cee0db0180b64655751e7058c251103f9660f85 jdk8u141-b01
    1.35  82435799636c8b50a090aebcb5af49946afa7bb5 jdk8u141-b02
    1.36 @@ -973,5 +985,7 @@
    1.37  df6af363337eff5b22ae7940b0981231fdf5dfb4 jdk8u141-b13
    1.38  3a1543e089c32592be9c201c6e021295fbf5fdc1 jdk8u141-b14
    1.39  23f1790147d838ddb1133cc79dc08e7c9ba5ab44 jdk8u141-b15
    1.40 +9ffa0d7ed932045a0b4ceb095fb52444eed39c1b jdk8u141-b31
    1.41 +ae8cae699f62b845703c891e0e7633e2089a3ec4 jdk8u141-b32
    1.42  eea89df81a8e414813d921eeeeef9b6795f56698 jdk8u144-b00
    1.43  db36f4d498b1bde975700a800b5ce732941c04b7 jdk8u144-b01
     2.1 --- a/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Fri Jul 21 20:31:41 2017 -0700
     2.2 +++ b/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Mon Jul 24 09:32:40 2017 -0700
     2.3 @@ -4261,6 +4261,7 @@
     2.4    assert(UseBlockZeroing && VM_Version::has_block_zeroing(), "only works with BIS zeroing");
     2.5    Register end = count;
     2.6    int cache_line_size = VM_Version::prefetch_data_size();
     2.7 +  assert(cache_line_size > 0, "cache line size should be known for this code");
     2.8    // Minimum count when BIS zeroing can be used since
     2.9    // it needs membar which is expensive.
    2.10    int block_zero_size  = MAX2(cache_line_size*3, (int)BlockZeroingLowLimit);
     3.1 --- a/src/cpu/sparc/vm/vm_version_sparc.cpp	Fri Jul 21 20:31:41 2017 -0700
     3.2 +++ b/src/cpu/sparc/vm/vm_version_sparc.cpp	Mon Jul 24 09:32:40 2017 -0700
     3.3 @@ -74,7 +74,7 @@
     3.4      AllocatePrefetchDistance = AllocatePrefetchStepSize;
     3.5    }
     3.6  
     3.7 -  if (AllocatePrefetchStyle == 3 && !has_blk_init()) {
     3.8 +  if (AllocatePrefetchStyle == 3 && (!has_blk_init() || cache_line_size <= 0)) {
     3.9      warning("BIS instructions are not available on this CPU");
    3.10      FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
    3.11    }
    3.12 @@ -138,7 +138,7 @@
    3.13        FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
    3.14      }
    3.15      if (is_niagara_plus()) {
    3.16 -      if (has_blk_init() && UseTLAB &&
    3.17 +      if (has_blk_init() && (cache_line_size > 0) && UseTLAB &&
    3.18            FLAG_IS_DEFAULT(AllocatePrefetchInstr)) {
    3.19          // Use BIS instruction for TLAB allocation prefetch.
    3.20          FLAG_SET_ERGO(intx, AllocatePrefetchInstr, 1);
    3.21 @@ -236,7 +236,7 @@
    3.22    assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
    3.23  
    3.24    char buf[512];
    3.25 -  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
    3.26 +  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
    3.27                 (has_v9() ? ", v9" : (has_v8() ? ", v8" : "")),
    3.28                 (has_hardware_popc() ? ", popc" : ""),
    3.29                 (has_vis1() ? ", vis1" : ""),
    3.30 @@ -249,6 +249,7 @@
    3.31                 (has_sha256() ? ", sha256" : ""),
    3.32                 (has_sha512() ? ", sha512" : ""),
    3.33                 (is_ultra3() ? ", ultra3" : ""),
    3.34 +               (has_sparc5_instr() ? ", sparc5" : ""),
    3.35                 (is_sun4v() ? ", sun4v" : ""),
    3.36                 (is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")),
    3.37                 (is_sparc64() ? ", sparc64" : ""),
    3.38 @@ -364,6 +365,7 @@
    3.39  
    3.40  #ifndef PRODUCT
    3.41    if (PrintMiscellaneous && Verbose) {
    3.42 +    tty->print_cr("L1 data cache line size: %u", L1_data_cache_line_size());
    3.43      tty->print_cr("L2 data cache line size: %u", L2_data_cache_line_size());
    3.44      tty->print("Allocation");
    3.45      if (AllocatePrefetchStyle <= 0) {
    3.46 @@ -447,9 +449,10 @@
    3.47  
    3.48  unsigned int VM_Version::calc_parallel_worker_threads() {
    3.49    unsigned int result;
    3.50 -  if (is_M_series()) {
    3.51 -    // for now, use same gc thread calculation for M-series as for niagara-plus
    3.52 -    // in future, we may want to tweak parameters for nof_parallel_worker_thread
    3.53 +  if (is_M_series() || is_S_series()) {
    3.54 +    // for now, use same gc thread calculation for M-series and S-series as for
    3.55 +    // niagara-plus. In future, we may want to tweak parameters for
    3.56 +    // nof_parallel_worker_thread
    3.57      result = nof_parallel_worker_threads(5, 16, 8);
    3.58    } else if (is_niagara_plus()) {
    3.59      result = nof_parallel_worker_threads(5, 16, 8);
    3.60 @@ -458,3 +461,37 @@
    3.61    }
    3.62    return result;
    3.63  }
    3.64 +
    3.65 +
    3.66 +int VM_Version::parse_features(const char* implementation) {
    3.67 +  int features = unknown_m;
    3.68 +  // Convert to UPPER case before compare.
    3.69 +  char* impl = os::strdup(implementation);
    3.70 +
    3.71 +  for (int i = 0; impl[i] != 0; i++)
    3.72 +    impl[i] = (char)toupper((uint)impl[i]);
    3.73 +
    3.74 +  if (strstr(impl, "SPARC64") != NULL) {
    3.75 +    features |= sparc64_family_m;
    3.76 +  } else if (strstr(impl, "SPARC-M") != NULL) {
    3.77 +    // M-series SPARC is based on T-series.
    3.78 +    features |= (M_family_m | T_family_m);
    3.79 +  } else if (strstr(impl, "SPARC-S") != NULL) {
    3.80 +    // S-series SPARC is based on T-series.
    3.81 +    features |= (S_family_m | T_family_m);
    3.82 +  } else if (strstr(impl, "SPARC-T") != NULL) {
    3.83 +    features |= T_family_m;
    3.84 +    if (strstr(impl, "SPARC-T1") != NULL) {
    3.85 +      features |= T1_model_m;
    3.86 +    }
    3.87 +  } else if (strstr(impl, "SUN4V-CPU") != NULL) {
    3.88 +    // Generic or migration class LDOM
    3.89 +    features |= T_family_m;
    3.90 +  } else {
    3.91 +#ifndef PRODUCT
    3.92 +    warning("Failed to parse CPU implementation = '%s'", impl);
    3.93 +#endif
    3.94 +  }
    3.95 +  os::free((void*)impl);
    3.96 +  return features;
    3.97 +}
     4.1 --- a/src/cpu/sparc/vm/vm_version_sparc.hpp	Fri Jul 21 20:31:41 2017 -0700
     4.2 +++ b/src/cpu/sparc/vm/vm_version_sparc.hpp	Mon Jul 24 09:32:40 2017 -0700
     4.3 @@ -47,13 +47,14 @@
     4.4      cbcond_instructions  = 13,
     4.5      sparc64_family       = 14,
     4.6      M_family             = 15,
     4.7 -    T_family             = 16,
     4.8 -    T1_model             = 17,
     4.9 -    sparc5_instructions  = 18,
    4.10 -    aes_instructions     = 19,
    4.11 -    sha1_instruction     = 20,
    4.12 -    sha256_instruction   = 21,
    4.13 -    sha512_instruction   = 22
    4.14 +    S_family             = 16,
    4.15 +    T_family             = 17,
    4.16 +    T1_model             = 18,
    4.17 +    sparc5_instructions  = 19,
    4.18 +    aes_instructions     = 20,
    4.19 +    sha1_instruction     = 21,
    4.20 +    sha256_instruction   = 22,
    4.21 +    sha512_instruction   = 23
    4.22    };
    4.23  
    4.24    enum Feature_Flag_Set {
    4.25 @@ -76,6 +77,7 @@
    4.26      cbcond_instructions_m   = 1 << cbcond_instructions,
    4.27      sparc64_family_m        = 1 << sparc64_family,
    4.28      M_family_m              = 1 << M_family,
    4.29 +    S_family_m              = 1 << S_family,
    4.30      T_family_m              = 1 << T_family,
    4.31      T1_model_m              = 1 << T1_model,
    4.32      sparc5_instructions_m   = 1 << sparc5_instructions,
    4.33 @@ -105,6 +107,7 @@
    4.34  
    4.35    // Returns true if the platform is in the niagara line (T series)
    4.36    static bool is_M_family(int features) { return (features & M_family_m) != 0; }
    4.37 +  static bool is_S_family(int features) { return (features & S_family_m) != 0; }
    4.38    static bool is_T_family(int features) { return (features & T_family_m) != 0; }
    4.39    static bool is_niagara() { return is_T_family(_features); }
    4.40  #ifdef ASSERT
    4.41 @@ -119,7 +122,7 @@
    4.42    static bool is_T1_model(int features) { return is_T_family(features) && ((features & T1_model_m) != 0); }
    4.43  
    4.44    static int maximum_niagara1_processor_count() { return 32; }
    4.45 -
    4.46 +  static int parse_features(const char* implementation);
    4.47  public:
    4.48    // Initialization
    4.49    static void initialize();
    4.50 @@ -152,6 +155,7 @@
    4.51    static bool is_niagara_plus()         { return is_T_family(_features) && !is_T1_model(_features); }
    4.52  
    4.53    static bool is_M_series()             { return is_M_family(_features); }
    4.54 +  static bool is_S_series()             { return is_S_family(_features); }
    4.55    static bool is_T4()                   { return is_T_family(_features) && has_cbcond(); }
    4.56    static bool is_T7()                   { return is_T_family(_features) && has_sparc5_instr(); }
    4.57  
     5.1 --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
     5.2 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
     5.3 @@ -98,7 +98,7 @@
     5.4    }
     5.5    pop(rax);
     5.6  #endif
     5.7 -  reset_last_Java_frame(thread, true, align_stack);
     5.8 +  reset_last_Java_frame(thread, true);
     5.9  
    5.10    // discard thread and arguments
    5.11    NOT_LP64(addptr(rsp, num_rt_args()*BytesPerWord));
    5.12 @@ -882,7 +882,7 @@
    5.13    }
    5.14    __ pop(rax);
    5.15  #endif
    5.16 -  __ reset_last_Java_frame(thread, true, false);
    5.17 +  __ reset_last_Java_frame(thread, true);
    5.18  #ifndef _LP64
    5.19    __ pop(rcx); // discard thread arg
    5.20    __ pop(rcx); // discard dummy
     6.1 --- a/src/cpu/x86/vm/frame_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
     6.2 +++ b/src/cpu/x86/vm/frame_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
     6.3 @@ -370,13 +370,16 @@
     6.4    JavaFrameAnchor* jfa = entry_frame_call_wrapper()->anchor();
     6.5    assert(!entry_frame_is_first(), "next Java fp must be non zero");
     6.6    assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
     6.7 +  // Since we are walking the stack now this nested anchor is obviously walkable
     6.8 +  // even if it wasn't when it was stacked.
     6.9 +  if (!jfa->walkable()) {
    6.10 +    // Capture _last_Java_pc (if needed) and mark anchor walkable.
    6.11 +    jfa->capture_last_Java_pc();
    6.12 +  }
    6.13    map->clear();
    6.14    assert(map->include_argument_oops(), "should be set by clear");
    6.15 -  if (jfa->last_Java_pc() != NULL ) {
    6.16 -    frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
    6.17 -    return fr;
    6.18 -  }
    6.19 -  frame fr(jfa->last_Java_sp(), jfa->last_Java_fp());
    6.20 +  assert(jfa->last_Java_pc() != NULL, "not walkable");
    6.21 +  frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());
    6.22    return fr;
    6.23  }
    6.24  
    6.25 @@ -714,3 +717,21 @@
    6.26    init((intptr_t*)sp, (intptr_t*)fp, (address)pc);
    6.27  }
    6.28  #endif
    6.29 +
    6.30 +void JavaFrameAnchor::make_walkable(JavaThread* thread) {
    6.31 +  // last frame set?
    6.32 +  if (last_Java_sp() == NULL) return;
    6.33 +  // already walkable?
    6.34 +  if (walkable()) return;
    6.35 +  assert(Thread::current() == (Thread*)thread, "not current thread");
    6.36 +  assert(last_Java_sp() != NULL, "not called from Java code?");
    6.37 +  assert(last_Java_pc() == NULL, "already walkable");
    6.38 +  capture_last_Java_pc();
    6.39 +  assert(walkable(), "something went wrong");
    6.40 +}
    6.41 +
    6.42 +void JavaFrameAnchor::capture_last_Java_pc() {
    6.43 +  assert(_last_Java_sp != NULL, "no last frame set");
    6.44 +  assert(_last_Java_pc == NULL, "already walkable");
    6.45 +  _last_Java_pc = (address)_last_Java_sp[-1];
    6.46 +}
     7.1 --- a/src/cpu/x86/vm/frame_x86.inline.hpp	Fri Jul 21 20:31:41 2017 -0700
     7.2 +++ b/src/cpu/x86/vm/frame_x86.inline.hpp	Mon Jul 24 09:32:40 2017 -0700
     7.3 @@ -96,6 +96,7 @@
     7.4    // call a specialized frame constructor instead of this one.
     7.5    // Then we could use the assert below. However this assert is of somewhat dubious
     7.6    // value.
     7.7 +  // UPDATE: this constructor is only used by trace_method_handle_stub() now.
     7.8    // assert(_pc != NULL, "no pc?");
     7.9  
    7.10    _cb = CodeCache::find_blob(_pc);
     8.1 --- a/src/cpu/x86/vm/javaFrameAnchor_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
     8.2 +++ b/src/cpu/x86/vm/javaFrameAnchor_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
     8.3 @@ -62,10 +62,9 @@
     8.4      _last_Java_sp = src->_last_Java_sp;
     8.5    }
     8.6  
     8.7 -  // Always walkable
     8.8 -  bool walkable(void) { return true; }
     8.9 -  // Never any thing to do since we are always walkable and can find address of return addresses
    8.10 -  void make_walkable(JavaThread* thread) { }
    8.11 +  bool walkable(void)                            { return _last_Java_sp != NULL && _last_Java_pc != NULL; }
    8.12 +  void make_walkable(JavaThread* thread);
    8.13 +  void capture_last_Java_pc(void);
    8.14  
    8.15    intptr_t* last_Java_sp(void) const             { return _last_Java_sp; }
    8.16  
     9.1 --- a/src/cpu/x86/vm/macroAssembler_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
     9.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
     9.3 @@ -748,8 +748,7 @@
     9.4    }
     9.5  }
     9.6  
     9.7 -void MacroAssembler::reset_last_Java_frame(bool clear_fp,
     9.8 -                                           bool clear_pc) {
     9.9 +void MacroAssembler::reset_last_Java_frame(bool clear_fp) {
    9.10    // we must set sp to zero to clear frame
    9.11    movptr(Address(r15_thread, JavaThread::last_Java_sp_offset()), NULL_WORD);
    9.12    // must clear fp, so that compiled frames are not confused; it is
    9.13 @@ -758,9 +757,8 @@
    9.14      movptr(Address(r15_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
    9.15    }
    9.16  
    9.17 -  if (clear_pc) {
    9.18 -    movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    9.19 -  }
    9.20 +  // Always clear the pc because it could have been set by make_walkable()
    9.21 +  movptr(Address(r15_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    9.22  }
    9.23  
    9.24  void MacroAssembler::set_last_Java_frame(Register last_java_sp,
    9.25 @@ -2561,7 +2559,7 @@
    9.26    }
    9.27    // reset last Java frame
    9.28    // Only interpreter should have to clear fp
    9.29 -  reset_last_Java_frame(java_thread, true, false);
    9.30 +  reset_last_Java_frame(java_thread, true);
    9.31  
    9.32  #ifndef CC_INTERP
    9.33     // C++ interp handles this in the interpreter
    9.34 @@ -3808,7 +3806,7 @@
    9.35    pusha();
    9.36  }
    9.37  
    9.38 -void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp, bool clear_pc) {
    9.39 +void MacroAssembler::reset_last_Java_frame(Register java_thread, bool clear_fp) {
    9.40    // determine java_thread register
    9.41    if (!java_thread->is_valid()) {
    9.42      java_thread = rdi;
    9.43 @@ -3820,8 +3818,8 @@
    9.44      movptr(Address(java_thread, JavaThread::last_Java_fp_offset()), NULL_WORD);
    9.45    }
    9.46  
    9.47 -  if (clear_pc)
    9.48 -    movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    9.49 +  // Always clear the pc because it could have been set by make_walkable()
    9.50 +  movptr(Address(java_thread, JavaThread::last_Java_pc_offset()), NULL_WORD);
    9.51  
    9.52  }
    9.53  
    10.1 --- a/src/cpu/x86/vm/macroAssembler_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
    10.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
    10.3 @@ -289,10 +289,10 @@
    10.4                             Register last_java_fp,
    10.5                             address last_java_pc);
    10.6  
    10.7 -  void reset_last_Java_frame(Register thread, bool clear_fp, bool clear_pc);
    10.8 +  void reset_last_Java_frame(Register thread, bool clear_fp);
    10.9  
   10.10    // thread in the default location (r15_thread on 64bit)
   10.11 -  void reset_last_Java_frame(bool clear_fp, bool clear_pc);
   10.12 +  void reset_last_Java_frame(bool clear_fp);
   10.13  
   10.14    // Stores
   10.15    void store_check(Register obj);                // store check for obj - register is destroyed afterwards
    11.1 --- a/src/cpu/x86/vm/runtime_x86_32.cpp	Fri Jul 21 20:31:41 2017 -0700
    11.2 +++ b/src/cpu/x86/vm/runtime_x86_32.cpp	Mon Jul 24 09:32:40 2017 -0700
    11.3 @@ -116,7 +116,7 @@
    11.4    // No registers to map, rbp is known implicitly
    11.5    oop_maps->add_gc_map( __ pc() - start,  new OopMap( framesize, 0 ));
    11.6    __ get_thread(rcx);
    11.7 -  __ reset_last_Java_frame(rcx, false, false);
    11.8 +  __ reset_last_Java_frame(rcx, false);
    11.9  
   11.10    // Restore callee-saved registers
   11.11    __ movptr(rbp, Address(rsp, rbp_off * wordSize));
    12.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Fri Jul 21 20:31:41 2017 -0700
    12.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Jul 24 09:32:40 2017 -0700
    12.3 @@ -1333,7 +1333,7 @@
    12.4    __ increment(rsp, wordSize);
    12.5  
    12.6    __ get_thread(thread);
    12.7 -  __ reset_last_Java_frame(thread, false, true);
    12.8 +  __ reset_last_Java_frame(thread, false);
    12.9  
   12.10    save_or_restore_arguments(masm, stack_slots, total_in_args,
   12.11                              arg_save_area, NULL, in_regs, in_sig_bt);
   12.12 @@ -2251,7 +2251,7 @@
   12.13  
   12.14    // We can finally stop using that last_Java_frame we setup ages ago
   12.15  
   12.16 -  __ reset_last_Java_frame(thread, false, true);
   12.17 +  __ reset_last_Java_frame(thread, false);
   12.18  
   12.19    // Unpack oop result
   12.20    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   12.21 @@ -2951,7 +2951,7 @@
   12.22    __ pop(rcx);
   12.23  
   12.24    __ get_thread(rcx);
   12.25 -  __ reset_last_Java_frame(rcx, false, false);
   12.26 +  __ reset_last_Java_frame(rcx, false);
   12.27  
   12.28    // Load UnrollBlock into EDI
   12.29    __ mov(rdi, rax);
   12.30 @@ -3117,7 +3117,7 @@
   12.31    __ push(rax);
   12.32  
   12.33    __ get_thread(rcx);
   12.34 -  __ reset_last_Java_frame(rcx, false, false);
   12.35 +  __ reset_last_Java_frame(rcx, false);
   12.36  
   12.37    // Collect return values
   12.38    __ movptr(rax,Address(rsp, (RegisterSaver::raxOffset() + additional_words + 1)*wordSize));
   12.39 @@ -3219,7 +3219,7 @@
   12.40  
   12.41    __ get_thread(rcx);
   12.42  
   12.43 -  __ reset_last_Java_frame(rcx, false, false);
   12.44 +  __ reset_last_Java_frame(rcx, false);
   12.45  
   12.46    // Load UnrollBlock into EDI
   12.47    __ movptr(rdi, rax);
   12.48 @@ -3331,7 +3331,7 @@
   12.49    oop_maps->add_gc_map( __ pc()-start, new OopMap( framesize, 0 ) );
   12.50  
   12.51    __ get_thread(rdi);
   12.52 -  __ reset_last_Java_frame(rdi, true, false);
   12.53 +  __ reset_last_Java_frame(rdi, true);
   12.54  
   12.55    // Pop self-frame.
   12.56    __ leave();     // Epilog!
   12.57 @@ -3426,7 +3426,7 @@
   12.58  
   12.59    // Clear last_Java_sp again
   12.60    __ get_thread(java_thread);
   12.61 -  __ reset_last_Java_frame(java_thread, false, false);
   12.62 +  __ reset_last_Java_frame(java_thread, false);
   12.63  
   12.64    __ cmpptr(Address(java_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
   12.65    __ jcc(Assembler::equal, noException);
   12.66 @@ -3501,7 +3501,7 @@
   12.67    __ addptr(rsp, wordSize);
   12.68  
   12.69    // clear last_Java_sp
   12.70 -  __ reset_last_Java_frame(thread, true, false);
   12.71 +  __ reset_last_Java_frame(thread, true);
   12.72    // check for pending exceptions
   12.73    Label pending;
   12.74    __ cmpptr(Address(thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
    13.1 --- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Fri Jul 21 20:31:41 2017 -0700
    13.2 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Jul 24 09:32:40 2017 -0700
    13.3 @@ -1388,7 +1388,7 @@
    13.4    __ mov(rsp, r12); // restore sp
    13.5    __ reinit_heapbase();
    13.6  
    13.7 -  __ reset_last_Java_frame(false, true);
    13.8 +  __ reset_last_Java_frame(false);
    13.9  
   13.10    save_or_restore_arguments(masm, stack_slots, total_in_args,
   13.11                              arg_save_area, NULL, in_regs, in_sig_bt);
   13.12 @@ -2497,7 +2497,7 @@
   13.13      restore_native_result(masm, ret_type, stack_slots);
   13.14    }
   13.15  
   13.16 -  __ reset_last_Java_frame(false, true);
   13.17 +  __ reset_last_Java_frame(false);
   13.18  
   13.19    // Unpack oop result
   13.20    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   13.21 @@ -3435,7 +3435,7 @@
   13.22    // find any register it might need.
   13.23    oop_maps->add_gc_map(__ pc() - start, map);
   13.24  
   13.25 -  __ reset_last_Java_frame(false, false);
   13.26 +  __ reset_last_Java_frame(false);
   13.27  
   13.28    // Load UnrollBlock* into rdi
   13.29    __ mov(rdi, rax);
   13.30 @@ -3592,7 +3592,7 @@
   13.31                         new OopMap( frame_size_in_words, 0 ));
   13.32  
   13.33    // Clear fp AND pc
   13.34 -  __ reset_last_Java_frame(true, true);
   13.35 +  __ reset_last_Java_frame(true);
   13.36  
   13.37    // Collect return values
   13.38    __ movdbl(xmm0, Address(rsp, RegisterSaver::xmm0_offset_in_bytes()));
   13.39 @@ -3662,7 +3662,7 @@
   13.40  
   13.41    oop_maps->add_gc_map(__ pc() - start, map);
   13.42  
   13.43 -  __ reset_last_Java_frame(false, false);
   13.44 +  __ reset_last_Java_frame(false);
   13.45  
   13.46    // Load UnrollBlock* into rdi
   13.47    __ mov(rdi, rax);
   13.48 @@ -3775,7 +3775,7 @@
   13.49    oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
   13.50  
   13.51    // Clear fp AND pc
   13.52 -  __ reset_last_Java_frame(true, true);
   13.53 +  __ reset_last_Java_frame(true);
   13.54  
   13.55    // Pop self-frame.
   13.56    __ leave();                 // Epilog
   13.57 @@ -3858,7 +3858,7 @@
   13.58  
   13.59    Label noException;
   13.60  
   13.61 -  __ reset_last_Java_frame(false, false);
   13.62 +  __ reset_last_Java_frame(false);
   13.63  
   13.64    __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
   13.65    __ jcc(Assembler::equal, noException);
   13.66 @@ -3928,7 +3928,7 @@
   13.67    // rax contains the address we are going to jump to assuming no exception got installed
   13.68  
   13.69    // clear last_Java_sp
   13.70 -  __ reset_last_Java_frame(false, false);
   13.71 +  __ reset_last_Java_frame(false);
   13.72    // check for pending exceptions
   13.73    Label pending;
   13.74    __ cmpptr(Address(r15_thread, Thread::pending_exception_offset()), (int32_t)NULL_WORD);
   13.75 @@ -4309,7 +4309,7 @@
   13.76  
   13.77    oop_maps->add_gc_map(the_pc - start, new OopMap(SimpleRuntimeFrame::framesize, 0));
   13.78  
   13.79 -  __ reset_last_Java_frame(false, true);
   13.80 +  __ reset_last_Java_frame(false);
   13.81  
   13.82    // Restore callee-saved registers
   13.83  
    14.1 --- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Fri Jul 21 20:31:41 2017 -0700
    14.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp	Mon Jul 24 09:32:40 2017 -0700
    14.3 @@ -2901,7 +2901,7 @@
    14.4      // however can use the register value directly if it is callee saved.
    14.5      __ get_thread(java_thread);
    14.6  
    14.7 -    __ reset_last_Java_frame(java_thread, true, false);
    14.8 +    __ reset_last_Java_frame(java_thread, true);
    14.9  
   14.10      __ leave(); // required for proper stackwalking of RuntimeStub frame
   14.11  
    15.1 --- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Fri Jul 21 20:31:41 2017 -0700
    15.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Mon Jul 24 09:32:40 2017 -0700
    15.3 @@ -3923,7 +3923,7 @@
    15.4  
    15.5      oop_maps->add_gc_map(the_pc - start, map);
    15.6  
    15.7 -    __ reset_last_Java_frame(true, true);
    15.8 +    __ reset_last_Java_frame(true);
    15.9  
   15.10      __ leave(); // required for proper stackwalking of RuntimeStub frame
   15.11  
    16.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Fri Jul 21 20:31:41 2017 -0700
    16.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_32.cpp	Mon Jul 24 09:32:40 2017 -0700
    16.3 @@ -1289,7 +1289,7 @@
    16.4    // change thread state
    16.5    __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
    16.6  
    16.7 -  __ reset_last_Java_frame(thread, true, true);
    16.8 +  __ reset_last_Java_frame(thread, true);
    16.9  
   16.10    // reset handle block
   16.11    __ movptr(t, Address(thread, JavaThread::active_handles_offset()));
   16.12 @@ -1819,7 +1819,7 @@
   16.13    __ set_last_Java_frame(thread, noreg, rbp, __ pc());
   16.14    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), thread, rax, rbx);
   16.15    __ get_thread(thread);
   16.16 -  __ reset_last_Java_frame(thread, true, true);
   16.17 +  __ reset_last_Java_frame(thread, true);
   16.18    // Restore the last_sp and null it out
   16.19    __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize));
   16.20    __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), NULL_WORD);
    17.1 --- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Fri Jul 21 20:31:41 2017 -0700
    17.2 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	Mon Jul 24 09:32:40 2017 -0700
    17.3 @@ -1262,7 +1262,7 @@
    17.4    __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_Java);
    17.5  
    17.6    // reset_last_Java_frame
    17.7 -  __ reset_last_Java_frame(true, true);
    17.8 +  __ reset_last_Java_frame(r15_thread, true);
    17.9  
   17.10    // reset handle block
   17.11    __ movptr(t, Address(r15_thread, JavaThread::active_handles_offset()));
   17.12 @@ -1837,7 +1837,7 @@
   17.13    // PC must point into interpreter here
   17.14    __ set_last_Java_frame(noreg, rbp, __ pc());
   17.15    __ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), r15_thread, c_rarg1, c_rarg2);
   17.16 -  __ reset_last_Java_frame(true, true);
   17.17 +  __ reset_last_Java_frame(r15_thread, true);
   17.18    // Restore the last_sp and null it out
   17.19    __ movptr(rsp, Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize));
   17.20    __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD);
    18.1 --- a/src/cpu/x86/vm/vm_version_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
    18.2 +++ b/src/cpu/x86/vm/vm_version_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
    18.3 @@ -406,6 +406,8 @@
    18.4    _stepping = 0;
    18.5    _cpuFeatures = 0;
    18.6    _logical_processors_per_package = 1;
    18.7 +  // i486 internal cache is both I&D and has a 16-byte line size
    18.8 +  _L1_data_cache_line_size = 16;
    18.9  
   18.10    if (!Use486InstrsOnly) {
   18.11      // Get raw processor info
   18.12 @@ -424,6 +426,7 @@
   18.13        // Logical processors are only available on P4s and above,
   18.14        // and only if hyperthreading is available.
   18.15        _logical_processors_per_package = logical_processor_count();
   18.16 +      _L1_data_cache_line_size = L1_line_size();
   18.17      }
   18.18    }
   18.19  
   18.20 @@ -1034,6 +1037,7 @@
   18.21    if (PrintMiscellaneous && Verbose) {
   18.22      tty->print_cr("Logical CPUs per core: %u",
   18.23                    logical_processors_per_package());
   18.24 +    tty->print_cr("L1 data cache line size: %u", L1_data_cache_line_size());
   18.25      tty->print("UseSSE=%d", (int) UseSSE);
   18.26      if (UseAVX > 0) {
   18.27        tty->print("  UseAVX=%d", (int) UseAVX);
    19.1 --- a/src/cpu/x86/vm/vm_version_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
    19.2 +++ b/src/cpu/x86/vm/vm_version_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
    19.3 @@ -1,5 +1,5 @@
    19.4  /*
    19.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    19.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.8   *
    19.9   * This code is free software; you can redistribute it and/or modify it
   19.10 @@ -595,7 +595,7 @@
   19.11      return (result == 0 ? 1 : result);
   19.12    }
   19.13  
   19.14 -  static intx prefetch_data_size()  {
   19.15 +  static intx L1_line_size()  {
   19.16      intx result = 0;
   19.17      if (is_intel()) {
   19.18        result = (_cpuid_info.dcp_cpuid4_ebx.bits.L1_line_size + 1);
   19.19 @@ -607,6 +607,10 @@
   19.20      return result;
   19.21    }
   19.22  
   19.23 +  static intx prefetch_data_size()  {
   19.24 +    return L1_line_size();
   19.25 +  }
   19.26 +
   19.27    //
   19.28    // Feature identification
   19.29    //
    20.1 --- a/src/os/linux/vm/os_linux.cpp	Fri Jul 21 20:31:41 2017 -0700
    20.2 +++ b/src/os/linux/vm/os_linux.cpp	Mon Jul 24 09:32:40 2017 -0700
    20.3 @@ -2859,7 +2859,7 @@
    20.4                                // in the library.
    20.5    const size_t BitsPerCLong = sizeof(long) * CHAR_BIT;
    20.6  
    20.7 -  size_t cpu_num = os::active_processor_count();
    20.8 +  size_t cpu_num = processor_count();
    20.9    size_t cpu_map_size = NCPUS / BitsPerCLong;
   20.10    size_t cpu_map_valid_size =
   20.11      MIN2((cpu_num + BitsPerCLong - 1) / BitsPerCLong, cpu_map_size);
    21.1 --- a/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
    21.2 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
    21.3 @@ -44,7 +44,7 @@
    21.4  
    21.5    // If we have a last_Java_frame, then we should use it even if
    21.6    // isInJava == true.  It should be more reliable than ucontext info.
    21.7 -  if (jt->has_last_Java_frame()) {
    21.8 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    21.9      *fr_addr = jt->pd_last_frame();
   21.10      return true;
   21.11    }
    22.1 --- a/src/os_cpu/bsd_x86/vm/thread_bsd_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
    22.2 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
    22.3 @@ -32,12 +32,8 @@
    22.4  
    22.5    frame pd_last_frame() {
    22.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    22.7 -    if (_anchor.last_Java_pc() != NULL) {
    22.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    22.9 -    } else {
   22.10 -      // This will pick up pc from sp
   22.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   22.12 -    }
   22.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   22.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   22.15    }
   22.16  
   22.17   public:
    23.1 --- a/src/os_cpu/linux_x86/vm/thread_linux_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
    23.2 +++ b/src/os_cpu/linux_x86/vm/thread_linux_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
    23.3 @@ -45,7 +45,7 @@
    23.4  
    23.5    // If we have a last_Java_frame, then we should use it even if
    23.6    // isInJava == true.  It should be more reliable than ucontext info.
    23.7 -  if (jt->has_last_Java_frame()) {
    23.8 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    23.9      *fr_addr = jt->pd_last_frame();
   23.10      return true;
   23.11    }
    24.1 --- a/src/os_cpu/linux_x86/vm/thread_linux_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
    24.2 +++ b/src/os_cpu/linux_x86/vm/thread_linux_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
    24.3 @@ -32,12 +32,8 @@
    24.4  
    24.5    frame pd_last_frame() {
    24.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    24.7 -    if (_anchor.last_Java_pc() != NULL) {
    24.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    24.9 -    } else {
   24.10 -      // This will pick up pc from sp
   24.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   24.12 -    }
   24.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   24.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   24.15    }
   24.16  
   24.17   public:
    25.1 --- a/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Fri Jul 21 20:31:41 2017 -0700
    25.2 +++ b/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Mon Jul 24 09:32:40 2017 -0700
    25.3 @@ -262,6 +262,7 @@
    25.4  
    25.5  // We need to keep these here as long as we have to build on Solaris
    25.6  // versions before 10.
    25.7 +
    25.8  #ifndef SI_ARCHITECTURE_32
    25.9  #define SI_ARCHITECTURE_32      516     /* basic 32-bit SI_ARCHITECTURE */
   25.10  #endif
   25.11 @@ -270,231 +271,233 @@
   25.12  #define SI_ARCHITECTURE_64      517     /* basic 64-bit SI_ARCHITECTURE */
   25.13  #endif
   25.14  
   25.15 -static void do_sysinfo(int si, const char* string, int* features, int mask) {
   25.16 -  char   tmp;
   25.17 -  size_t bufsize = sysinfo(si, &tmp, 1);
   25.18 +#ifndef SI_CPUBRAND
   25.19 +#define SI_CPUBRAND             523     /* return cpu brand string */
   25.20 +#endif
   25.21  
   25.22 -  // All SI defines used below must be supported.
   25.23 -  guarantee(bufsize != -1, "must be supported");
   25.24 +class Sysinfo {
   25.25 +  char* _string;
   25.26 +public:
   25.27 +  Sysinfo(int si) : _string(NULL) {
   25.28 +    char   tmp;
   25.29 +    size_t bufsize = sysinfo(si, &tmp, 1);
   25.30  
   25.31 -  char* buf = (char*) malloc(bufsize);
   25.32 +    if (bufsize != -1) {
   25.33 +      char* buf = (char*) os::malloc(bufsize, mtInternal);
   25.34 +      if (buf != NULL) {
   25.35 +        if (sysinfo(si, buf, bufsize) == bufsize) {
   25.36 +          _string = buf;
   25.37 +        } else {
   25.38 +          os::free(buf);
   25.39 +        }
   25.40 +      }
   25.41 +     }
   25.42 +   }
   25.43  
   25.44 -  if (buf == NULL)
   25.45 -    return;
   25.46 -
   25.47 -  if (sysinfo(si, buf, bufsize) == bufsize) {
   25.48 -    // Compare the string.
   25.49 -    if (strcmp(buf, string) == 0) {
   25.50 -      *features |= mask;
   25.51 +  ~Sysinfo() {
   25.52 +    if (_string != NULL) {
   25.53 +      os::free(_string);
   25.54      }
   25.55    }
   25.56  
   25.57 -  free(buf);
   25.58 -}
   25.59 +  const char* value() const {
   25.60 +    return _string;
   25.61 +  }
   25.62 +
   25.63 +  bool valid() const {
   25.64 +    return _string != NULL;
   25.65 +  }
   25.66 +
   25.67 +  bool match(const char* s) const {
   25.68 +    return valid() ? strcmp(_string, s) == 0 : false;
   25.69 +  }
   25.70 +
   25.71 +  bool match_substring(const char* s) const {
   25.72 +    return valid() ? strstr(_string, s) != NULL : false;
   25.73 +  }
   25.74 +};
   25.75 +
   25.76 +class Sysconf {
   25.77 +  int _value;
   25.78 +public:
   25.79 +  Sysconf(int sc) : _value(-1) {
   25.80 +    _value = sysconf(sc);
   25.81 +  }
   25.82 +  bool valid() const {
   25.83 +    return _value != -1;
   25.84 +  }
   25.85 +  int value() const {
   25.86 +    return _value;
   25.87 +  }
   25.88 +};
   25.89 +
   25.90 +
   25.91 +#ifndef _SC_DCACHE_LINESZ
   25.92 +#define _SC_DCACHE_LINESZ       508     /* Data cache line size */
   25.93 +#endif
   25.94 +
   25.95 +#ifndef _SC_L2CACHE_LINESZ
   25.96 +#define _SC_L2CACHE_LINESZ      527     /* Size of L2 cache line */
   25.97 +#endif
   25.98 +
   25.99  
  25.100  int VM_Version::platform_features(int features) {
  25.101 -  // getisax(2), SI_ARCHITECTURE_32, and SI_ARCHITECTURE_64 are
  25.102 -  // supported on Solaris 10 and later.
  25.103 -  if (os::Solaris::supports_getisax()) {
  25.104 +  assert(os::Solaris::supports_getisax(), "getisax() must be available");
  25.105  
  25.106 -    // Check 32-bit architecture.
  25.107 -    do_sysinfo(SI_ARCHITECTURE_32, "sparc", &features, v8_instructions_m);
  25.108 +  // Check 32-bit architecture.
  25.109 +  if (Sysinfo(SI_ARCHITECTURE_32).match("sparc")) {
  25.110 +    features |= v8_instructions_m;
  25.111 +  }
  25.112  
  25.113 -    // Check 64-bit architecture.
  25.114 -    do_sysinfo(SI_ARCHITECTURE_64, "sparcv9", &features, generic_v9_m);
  25.115 +  // Check 64-bit architecture.
  25.116 +  if (Sysinfo(SI_ARCHITECTURE_64).match("sparcv9")) {
  25.117 +    features |= generic_v9_m;
  25.118 +  }
  25.119  
  25.120 -    // Extract valid instruction set extensions.
  25.121 -    uint_t avs[2];
  25.122 -    uint_t avn = os::Solaris::getisax(avs, 2);
  25.123 -    assert(avn <= 2, "should return two or less av's");
  25.124 -    uint_t av = avs[0];
  25.125 +  // Extract valid instruction set extensions.
  25.126 +  uint_t avs[2];
  25.127 +  uint_t avn = os::Solaris::getisax(avs, 2);
  25.128 +  assert(avn <= 2, "should return two or less av's");
  25.129 +  uint_t av = avs[0];
  25.130  
  25.131  #ifndef PRODUCT
  25.132 -    if (PrintMiscellaneous && Verbose) {
  25.133 -      tty->print("getisax(2) returned: " PTR32_FORMAT, av);
  25.134 -      if (avn > 1) {
  25.135 -        tty->print(", " PTR32_FORMAT, avs[1]);
  25.136 -      }
  25.137 -      tty->cr();
  25.138 +  if (PrintMiscellaneous && Verbose) {
  25.139 +    tty->print("getisax(2) returned: " PTR32_FORMAT, av);
  25.140 +    if (avn > 1) {
  25.141 +      tty->print(", " PTR32_FORMAT, avs[1]);
  25.142      }
  25.143 +    tty->cr();
  25.144 +  }
  25.145  #endif
  25.146  
  25.147 -    if (av & AV_SPARC_MUL32)  features |= hardware_mul32_m;
  25.148 -    if (av & AV_SPARC_DIV32)  features |= hardware_div32_m;
  25.149 -    if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
  25.150 -    if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
  25.151 -    if (av & AV_SPARC_POPC)   features |= hardware_popc_m;
  25.152 -    if (av & AV_SPARC_VIS)    features |= vis1_instructions_m;
  25.153 -    if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
  25.154 -    if (avn > 1) {
  25.155 -      uint_t av2 = avs[1];
  25.156 +  if (av & AV_SPARC_MUL32)  features |= hardware_mul32_m;
  25.157 +  if (av & AV_SPARC_DIV32)  features |= hardware_div32_m;
  25.158 +  if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m;
  25.159 +  if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m;
  25.160 +  if (av & AV_SPARC_POPC)   features |= hardware_popc_m;
  25.161 +  if (av & AV_SPARC_VIS)    features |= vis1_instructions_m;
  25.162 +  if (av & AV_SPARC_VIS2)   features |= vis2_instructions_m;
  25.163 +  if (avn > 1) {
  25.164 +    uint_t av2 = avs[1];
  25.165  #ifndef AV2_SPARC_SPARC5
  25.166  #define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */
  25.167  #endif
  25.168 -      if (av2 & AV2_SPARC_SPARC5)       features |= sparc5_instructions_m;
  25.169 -    }
  25.170 +    if (av2 & AV2_SPARC_SPARC5)       features |= sparc5_instructions_m;
  25.171 +  }
  25.172  
  25.173 -    // Next values are not defined before Solaris 10
  25.174 -    // but Solaris 8 is used for jdk6 update builds.
  25.175 +  // We only build on Solaris 10 and up, but some of the values below
  25.176 +  // are not defined on all versions of Solaris 10, so we define them,
  25.177 +  // if necessary.
  25.178  #ifndef AV_SPARC_ASI_BLK_INIT
  25.179  #define AV_SPARC_ASI_BLK_INIT 0x0080  /* ASI_BLK_INIT_xxx ASI */
  25.180  #endif
  25.181 -    if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
  25.182 +  if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
  25.183  
  25.184  #ifndef AV_SPARC_FMAF
  25.185  #define AV_SPARC_FMAF 0x0100        /* Fused Multiply-Add */
  25.186  #endif
  25.187 -    if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
  25.188 +  if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
  25.189  
  25.190  #ifndef AV_SPARC_FMAU
  25.191 -#define    AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
  25.192 +#define AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
  25.193  #endif
  25.194 -    if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
  25.195 +  if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
  25.196  
  25.197  #ifndef AV_SPARC_VIS3
  25.198 -#define    AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
  25.199 +#define AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
  25.200  #endif
  25.201 -    if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
  25.202 +  if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
  25.203  
  25.204  #ifndef AV_SPARC_CBCOND
  25.205  #define AV_SPARC_CBCOND 0x10000000  /* compare and branch instrs supported */
  25.206  #endif
  25.207 -    if (av & AV_SPARC_CBCOND)       features |= cbcond_instructions_m;
  25.208 +  if (av & AV_SPARC_CBCOND)       features |= cbcond_instructions_m;
  25.209  
  25.210  #ifndef AV_SPARC_AES
  25.211  #define AV_SPARC_AES 0x00020000  /* aes instrs supported */
  25.212  #endif
  25.213 -    if (av & AV_SPARC_AES)       features |= aes_instructions_m;
  25.214 +  if (av & AV_SPARC_AES)       features |= aes_instructions_m;
  25.215  
  25.216  #ifndef AV_SPARC_SHA1
  25.217  #define AV_SPARC_SHA1   0x00400000  /* sha1 instruction supported */
  25.218  #endif
  25.219 -    if (av & AV_SPARC_SHA1)         features |= sha1_instruction_m;
  25.220 +  if (av & AV_SPARC_SHA1)         features |= sha1_instruction_m;
  25.221  
  25.222  #ifndef AV_SPARC_SHA256
  25.223  #define AV_SPARC_SHA256 0x00800000  /* sha256 instruction supported */
  25.224  #endif
  25.225 -    if (av & AV_SPARC_SHA256)       features |= sha256_instruction_m;
  25.226 +  if (av & AV_SPARC_SHA256)       features |= sha256_instruction_m;
  25.227  
  25.228  #ifndef AV_SPARC_SHA512
  25.229  #define AV_SPARC_SHA512 0x01000000  /* sha512 instruction supported */
  25.230  #endif
  25.231 -    if (av & AV_SPARC_SHA512)       features |= sha512_instruction_m;
  25.232 +  if (av & AV_SPARC_SHA512)       features |= sha512_instruction_m;
  25.233  
  25.234 +  // Determine the machine type.
  25.235 +  if (Sysinfo(SI_MACHINE).match("sun4v")) {
  25.236 +    features |= sun4v_m;
  25.237 +  }
  25.238 +
  25.239 +  // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes
  25.240 +  // is available to us as well
  25.241 +  Sysinfo cpu_info(SI_CPUBRAND);
  25.242 +  bool use_solaris_12_api = cpu_info.valid();
  25.243 +  const char* impl;
  25.244 +  int impl_m = 0;
  25.245 +  if (use_solaris_12_api) {
  25.246 +    impl = cpu_info.value();
  25.247 +#ifndef PRODUCT
  25.248 +  if (PrintMiscellaneous && Verbose) {
  25.249 +    tty->print_cr("Parsing CPU implementation from %s", impl);
  25.250 +  }
  25.251 +#endif
  25.252 +    impl_m = parse_features(impl);
  25.253    } else {
  25.254 -    // getisax(2) failed, use the old legacy code.
  25.255 +    // Otherwise use kstat to determine the machine type.
  25.256 +    kstat_ctl_t* kc = kstat_open();
  25.257 +    if (kc != NULL) {
  25.258 +      kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
  25.259 +      if (ksp != NULL) {
  25.260 +        if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
  25.261 +          kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
  25.262 +          for (int i = 0; i < ksp->ks_ndata; i++) {
  25.263 +            if (strcmp((const char*)&(knm[i].name), "implementation") == 0) {
  25.264 +              impl = KSTAT_NAMED_STR_PTR(&knm[i]);
  25.265  #ifndef PRODUCT
  25.266 -    if (PrintMiscellaneous && Verbose)
  25.267 -      tty->print_cr("getisax(2) is not supported.");
  25.268 +              if (PrintMiscellaneous && Verbose) {
  25.269 +                tty->print_cr("Parsing CPU implementation from %s", impl);
  25.270 +              }
  25.271  #endif
  25.272 -
  25.273 -    char   tmp;
  25.274 -    size_t bufsize = sysinfo(SI_ISALIST, &tmp, 1);
  25.275 -    char*  buf     = (char*) malloc(bufsize);
  25.276 -
  25.277 -    if (buf != NULL) {
  25.278 -      if (sysinfo(SI_ISALIST, buf, bufsize) == bufsize) {
  25.279 -        // Figure out what kind of sparc we have
  25.280 -        char *sparc_string = strstr(buf, "sparc");
  25.281 -        if (sparc_string != NULL) {              features |= v8_instructions_m;
  25.282 -          if (sparc_string[5] == 'v') {
  25.283 -            if (sparc_string[6] == '8') {
  25.284 -              if (sparc_string[7] == '-') {      features |= hardware_mul32_m;
  25.285 -                                                 features |= hardware_div32_m;
  25.286 -              } else if (sparc_string[7] == 'p') features |= generic_v9_m;
  25.287 -              else                               features |= generic_v8_m;
  25.288 -            } else if (sparc_string[6] == '9')   features |= generic_v9_m;
  25.289 +              impl_m = parse_features(impl);
  25.290 +              break;
  25.291 +            }
  25.292            }
  25.293          }
  25.294 -
  25.295 -        // Check for visualization instructions
  25.296 -        char *vis = strstr(buf, "vis");
  25.297 -        if (vis != NULL) {                       features |= vis1_instructions_m;
  25.298 -          if (vis[3] == '2')                     features |= vis2_instructions_m;
  25.299 -        }
  25.300        }
  25.301 -      free(buf);
  25.302 +      kstat_close(kc);
  25.303      }
  25.304    }
  25.305 +  assert(impl_m != 0, err_msg("Unknown CPU implementation %s", impl));
  25.306 +  features |= impl_m;
  25.307  
  25.308 -  // Determine the machine type.
  25.309 -  do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
  25.310 +  bool is_sun4v = (features & sun4v_m) != 0;
  25.311 +  if (use_solaris_12_api && is_sun4v) {
  25.312 +    // If Solaris 12 API is supported and it's sun4v use sysconf() to get the cache line sizes
  25.313 +    Sysconf l1_dcache_line_size(_SC_DCACHE_LINESZ);
  25.314 +    if (l1_dcache_line_size.valid()) {
  25.315 +      _L1_data_cache_line_size =  l1_dcache_line_size.value();
  25.316 +    }
  25.317  
  25.318 -  {
  25.319 -    // Using kstat to determine the machine type.
  25.320 -    kstat_ctl_t* kc = kstat_open();
  25.321 -    kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
  25.322 -    const char* implementation = "UNKNOWN";
  25.323 -    if (ksp != NULL) {
  25.324 -      if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
  25.325 -        kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
  25.326 -        for (int i = 0; i < ksp->ks_ndata; i++) {
  25.327 -          if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
  25.328 -#ifndef KSTAT_DATA_STRING
  25.329 -#define KSTAT_DATA_STRING   9
  25.330 -#endif
  25.331 -            if (knm[i].data_type == KSTAT_DATA_CHAR) {
  25.332 -              // VM is running on Solaris 8 which does not have value.str.
  25.333 -              implementation = &(knm[i].value.c[0]);
  25.334 -            } else if (knm[i].data_type == KSTAT_DATA_STRING) {
  25.335 -              // VM is running on Solaris 10.
  25.336 -#ifndef KSTAT_NAMED_STR_PTR
  25.337 -              // Solaris 8 was used to build VM, define the structure it misses.
  25.338 -              struct str_t {
  25.339 -                union {
  25.340 -                  char *ptr;     /* NULL-term string */
  25.341 -                  char __pad[8]; /* 64-bit padding */
  25.342 -                } addr;
  25.343 -                uint32_t len;    /* # bytes for strlen + '\0' */
  25.344 -              };
  25.345 -#define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr)
  25.346 -#endif
  25.347 -              implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
  25.348 -            }
  25.349 -#ifndef PRODUCT
  25.350 -            if (PrintMiscellaneous && Verbose) {
  25.351 -              tty->print_cr("cpu_info.implementation: %s", implementation);
  25.352 -            }
  25.353 -#endif
  25.354 -            // Convert to UPPER case before compare.
  25.355 -            char* impl = strdup(implementation);
  25.356 -
  25.357 -            for (int i = 0; impl[i] != 0; i++)
  25.358 -              impl[i] = (char)toupper((uint)impl[i]);
  25.359 -            if (strstr(impl, "SPARC64") != NULL) {
  25.360 -              features |= sparc64_family_m;
  25.361 -            } else if (strstr(impl, "SPARC-M") != NULL) {
  25.362 -              // M-series SPARC is based on T-series.
  25.363 -              features |= (M_family_m | T_family_m);
  25.364 -            } else if (strstr(impl, "SPARC-T") != NULL) {
  25.365 -              features |= T_family_m;
  25.366 -              if (strstr(impl, "SPARC-T1") != NULL) {
  25.367 -                features |= T1_model_m;
  25.368 -              }
  25.369 -            } else {
  25.370 -              if (strstr(impl, "SPARC") == NULL) {
  25.371 -#ifndef PRODUCT
  25.372 -                // kstat on Solaris 8 virtual machines (branded zones)
  25.373 -                // returns "(unsupported)" implementation.
  25.374 -                warning("kstat cpu_info implementation = '%s', should contain SPARC", impl);
  25.375 -#endif
  25.376 -                implementation = "SPARC";
  25.377 -              }
  25.378 -            }
  25.379 -            free((void*)impl);
  25.380 -            break;
  25.381 -          }
  25.382 -        } // for(
  25.383 -      }
  25.384 +    Sysconf l2_dcache_line_size(_SC_L2CACHE_LINESZ);
  25.385 +    if (l2_dcache_line_size.valid()) {
  25.386 +      _L2_data_cache_line_size = l2_dcache_line_size.value();
  25.387      }
  25.388 -    assert(strcmp(implementation, "UNKNOWN") != 0,
  25.389 -           "unknown cpu info (changed kstat interface?)");
  25.390 -    kstat_close(kc);
  25.391 +  } else {
  25.392 +    // Otherwise figure out the cache line sizes using PICL
  25.393 +    bool is_fujitsu = (features & sparc64_family_m) != 0;
  25.394 +    PICL picl(is_fujitsu, is_sun4v);
  25.395 +    _L1_data_cache_line_size = picl.L1_data_cache_line_size();
  25.396 +    _L2_data_cache_line_size = picl.L2_data_cache_line_size();
  25.397    }
  25.398 -
  25.399 -  // Figure out cache line sizes using PICL
  25.400 -  PICL picl((features & sparc64_family_m) != 0, (features & sun4v_m) != 0);
  25.401 -  _L2_data_cache_line_size = picl.L2_data_cache_line_size();
  25.402 -
  25.403    return features;
  25.404  }
    26.1 --- a/src/os_cpu/solaris_x86/vm/thread_solaris_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
    26.2 +++ b/src/os_cpu/solaris_x86/vm/thread_solaris_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
    26.3 @@ -44,9 +44,8 @@
    26.4    assert(this->is_Java_thread(), "must be JavaThread");
    26.5    JavaThread* jt = (JavaThread *)this;
    26.6  
    26.7 -  // last_Java_frame is always walkable and safe use it if we have it
    26.8 -
    26.9 -  if (jt->has_last_Java_frame()) {
   26.10 +  // There is small window where last_Java_frame is not walkable or safe
   26.11 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
   26.12      *fr_addr = jt->pd_last_frame();
   26.13      return true;
   26.14    }
    27.1 --- a/src/os_cpu/solaris_x86/vm/thread_solaris_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
    27.2 +++ b/src/os_cpu/solaris_x86/vm/thread_solaris_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
    27.3 @@ -30,12 +30,8 @@
    27.4  
    27.5    frame pd_last_frame() {
    27.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    27.7 -    if (_anchor.last_Java_pc() != NULL) {
    27.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    27.9 -    } else {
   27.10 -      // This will pick up pc from sp
   27.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   27.12 -    }
   27.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   27.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   27.15    }
   27.16  
   27.17   public:
    28.1 --- a/src/os_cpu/windows_x86/vm/thread_windows_x86.cpp	Fri Jul 21 20:31:41 2017 -0700
    28.2 +++ b/src/os_cpu/windows_x86/vm/thread_windows_x86.cpp	Mon Jul 24 09:32:40 2017 -0700
    28.3 @@ -47,7 +47,7 @@
    28.4  
    28.5    // If we have a last_Java_frame, then we should use it even if
    28.6    // isInJava == true.  It should be more reliable than CONTEXT info.
    28.7 -  if (jt->has_last_Java_frame()) {
    28.8 +  if (jt->has_last_Java_frame() && jt->frame_anchor()->walkable()) {
    28.9      *fr_addr = jt->pd_last_frame();
   28.10      return true;
   28.11    }
    29.1 --- a/src/os_cpu/windows_x86/vm/thread_windows_x86.hpp	Fri Jul 21 20:31:41 2017 -0700
    29.2 +++ b/src/os_cpu/windows_x86/vm/thread_windows_x86.hpp	Mon Jul 24 09:32:40 2017 -0700
    29.3 @@ -32,12 +32,8 @@
    29.4  
    29.5    frame pd_last_frame() {
    29.6      assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
    29.7 -    if (_anchor.last_Java_pc() != NULL) {
    29.8 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
    29.9 -    } else {
   29.10 -      // This will pick up pc from sp
   29.11 -      return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp());
   29.12 -    }
   29.13 +    assert(_anchor.last_Java_pc() != NULL, "not walkable");
   29.14 +    return frame(_anchor.last_Java_sp(), _anchor.last_Java_fp(), _anchor.last_Java_pc());
   29.15    }
   29.16  
   29.17   public:
    30.1 --- a/src/share/vm/classfile/classLoaderData.cpp	Fri Jul 21 20:31:41 2017 -0700
    30.2 +++ b/src/share/vm/classfile/classLoaderData.cpp	Mon Jul 24 09:32:40 2017 -0700
    30.3 @@ -1,5 +1,5 @@
    30.4  /*
    30.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
    30.6 + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
    30.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.8   *
    30.9   * This code is free software; you can redistribute it and/or modify it
   30.10 @@ -78,7 +78,7 @@
   30.11    // The null-class-loader should always be kept alive.
   30.12    _keep_alive(is_anonymous || h_class_loader.is_null()),
   30.13    _metaspace(NULL), _unloading(false), _klasses(NULL),
   30.14 -  _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
   30.15 +  _claimed(0), _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
   30.16    _next(NULL), _dependencies(dependencies),
   30.17    _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true)) {
   30.18      // empty
   30.19 @@ -96,6 +96,45 @@
   30.20    _list_head = oopFactory::new_objectArray(2, CHECK);
   30.21  }
   30.22  
   30.23 +ClassLoaderData::ChunkedHandleList::~ChunkedHandleList() {
   30.24 +  Chunk* c = _head;
   30.25 +  while (c != NULL) {
   30.26 +    Chunk* next = c->_next;
   30.27 +    delete c;
   30.28 +    c = next;
   30.29 +  }
   30.30 +}
   30.31 +
   30.32 +oop* ClassLoaderData::ChunkedHandleList::add(oop o) {
   30.33 +  if (_head == NULL || _head->_size == Chunk::CAPACITY) {
   30.34 +    Chunk* next = new Chunk(_head);
   30.35 +    OrderAccess::release_store_ptr(&_head, next);
   30.36 +  }
   30.37 +  oop* handle = &_head->_data[_head->_size];
   30.38 +  *handle = o;
   30.39 +  OrderAccess::release_store(&_head->_size, _head->_size + 1);
   30.40 +  return handle;
   30.41 +}
   30.42 +
   30.43 +inline void ClassLoaderData::ChunkedHandleList::oops_do_chunk(OopClosure* f, Chunk* c, const juint size) {
   30.44 +  for (juint i = 0; i < size; i++) {
   30.45 +    if (c->_data[i] != NULL) {
   30.46 +      f->do_oop(&c->_data[i]);
   30.47 +    }
   30.48 +  }
   30.49 +}
   30.50 +
   30.51 +void ClassLoaderData::ChunkedHandleList::oops_do(OopClosure* f) {
   30.52 +  Chunk* head = (Chunk*) OrderAccess::load_ptr_acquire(&_head);
   30.53 +  if (head != NULL) {
   30.54 +    // Must be careful when reading size of head
   30.55 +    oops_do_chunk(f, head, OrderAccess::load_acquire(&head->_size));
   30.56 +    for (Chunk* c = head->_next; c != NULL; c = c->_next) {
   30.57 +      oops_do_chunk(f, c, c->_size);
   30.58 +    }
   30.59 +  }
   30.60 +}
   30.61 +
   30.62  bool ClassLoaderData::claim() {
   30.63    if (_claimed == 1) {
   30.64      return false;
   30.65 @@ -111,7 +150,7 @@
   30.66  
   30.67    f->do_oop(&_class_loader);
   30.68    _dependencies.oops_do(f);
   30.69 -  _handles->oops_do(f);
   30.70 +  _handles.oops_do(f);
   30.71    if (klass_closure != NULL) {
   30.72      classes_do(klass_closure);
   30.73    }
   30.74 @@ -342,11 +381,6 @@
   30.75      _metaspace = NULL;
   30.76      // release the metaspace
   30.77      delete m;
   30.78 -    // release the handles
   30.79 -    if (_handles != NULL) {
   30.80 -      JNIHandleBlock::release_block(_handles);
   30.81 -      _handles = NULL;
   30.82 -    }
   30.83    }
   30.84  
   30.85    // Clear all the JNI handles for methods
   30.86 @@ -406,15 +440,9 @@
   30.87    return _metaspace;
   30.88  }
   30.89  
   30.90 -JNIHandleBlock* ClassLoaderData::handles() const           { return _handles; }
   30.91 -void ClassLoaderData::set_handles(JNIHandleBlock* handles) { _handles = handles; }
   30.92 -
   30.93  jobject ClassLoaderData::add_handle(Handle h) {
   30.94    MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
   30.95 -  if (handles() == NULL) {
   30.96 -    set_handles(JNIHandleBlock::allocate_block());
   30.97 -  }
   30.98 -  return handles()->allocate_handle(h());
   30.99 +  return (jobject) _handles.add(h());
  30.100  }
  30.101  
  30.102  // Add this metadata pointer to be freed when it's safe.  This is only during
  30.103 @@ -479,7 +507,6 @@
  30.104        p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
  30.105    if (claimed()) out->print(" claimed ");
  30.106    if (is_unloading()) out->print(" unloading ");
  30.107 -  out->print(" handles " INTPTR_FORMAT, p2i(handles()));
  30.108    out->cr();
  30.109    if (metaspace_or_null() != NULL) {
  30.110      out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null()));
    31.1 --- a/src/share/vm/classfile/classLoaderData.hpp	Fri Jul 21 20:31:41 2017 -0700
    31.2 +++ b/src/share/vm/classfile/classLoaderData.hpp	Mon Jul 24 09:32:40 2017 -0700
    31.3 @@ -1,5 +1,5 @@
    31.4  /*
    31.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
    31.6 + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
    31.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.8   *
    31.9   * This code is free software; you can redistribute it and/or modify it
   31.10 @@ -51,7 +51,6 @@
   31.11  
   31.12  class ClassLoaderData;
   31.13  class JNIMethodBlock;
   31.14 -class JNIHandleBlock;
   31.15  class Metadebug;
   31.16  
   31.17  // GC root for walking class loader data created
   31.18 @@ -145,6 +144,31 @@
   31.19      void oops_do(OopClosure* f);
   31.20    };
   31.21  
   31.22 +  class ChunkedHandleList VALUE_OBJ_CLASS_SPEC {
   31.23 +    struct Chunk : public CHeapObj<mtClass> {
   31.24 +      static const size_t CAPACITY = 32;
   31.25 +
   31.26 +      oop _data[CAPACITY];
   31.27 +      volatile juint _size;
   31.28 +      Chunk* _next;
   31.29 +
   31.30 +      Chunk(Chunk* c) : _next(c), _size(0) { }
   31.31 +    };
   31.32 +
   31.33 +    Chunk* _head;
   31.34 +
   31.35 +    void oops_do_chunk(OopClosure* f, Chunk* c, const juint size);
   31.36 +
   31.37 +   public:
   31.38 +    ChunkedHandleList() : _head(NULL) {}
   31.39 +    ~ChunkedHandleList();
   31.40 +
   31.41 +    // Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock().
   31.42 +    // However, multiple threads can execute oops_do concurrently with add.
   31.43 +    oop* add(oop o);
   31.44 +    void oops_do(OopClosure* f);
   31.45 +  };
   31.46 +
   31.47    friend class ClassLoaderDataGraph;
   31.48    friend class ClassLoaderDataGraphKlassIteratorAtomic;
   31.49    friend class ClassLoaderDataGraphMetaspaceIterator;
   31.50 @@ -169,7 +193,8 @@
   31.51                             // Has to be an int because we cas it.
   31.52    Klass* _klasses;         // The classes defined by the class loader.
   31.53  
   31.54 -  JNIHandleBlock* _handles; // Handles to constant pool arrays
   31.55 +  ChunkedHandleList _handles; // Handles to constant pool arrays, etc, which
   31.56 +                              // have the same life cycle of the corresponding ClassLoader.
   31.57  
   31.58    // These method IDs are created for the class loader and set to NULL when the
   31.59    // class loader is unloaded.  They are rarely freed, only for redefine classes
   31.60 @@ -196,9 +221,6 @@
   31.61  
   31.62    void set_metaspace(Metaspace* m) { _metaspace = m; }
   31.63  
   31.64 -  JNIHandleBlock* handles() const;
   31.65 -  void set_handles(JNIHandleBlock* handles);
   31.66 -
   31.67    Mutex* metaspace_lock() const { return _metaspace_lock; }
   31.68  
   31.69    // GC interface.
    32.1 --- a/src/share/vm/classfile/javaClasses.cpp	Fri Jul 21 20:31:41 2017 -0700
    32.2 +++ b/src/share/vm/classfile/javaClasses.cpp	Mon Jul 24 09:32:40 2017 -0700
    32.3 @@ -1,5 +1,5 @@
    32.4  /*
    32.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    32.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    32.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.8   *
    32.9   * This code is free software; you can redistribute it and/or modify it
   32.10 @@ -2852,6 +2852,15 @@
   32.11    mname->address_field_put(_vmindex_offset, (address) index);
   32.12  }
   32.13  
   32.14 +bool java_lang_invoke_MemberName::equals(oop mn1, oop mn2) {
   32.15 +  if (mn1 == mn2) {
   32.16 +     return true;
   32.17 +  }
   32.18 +  return (vmtarget(mn1) == vmtarget(mn2) && flags(mn1) == flags(mn2) &&
   32.19 +          vmindex(mn1) == vmindex(mn2) &&
   32.20 +          clazz(mn1) == clazz(mn2));
   32.21 +}
   32.22 +
   32.23  oop java_lang_invoke_LambdaForm::vmentry(oop lform) {
   32.24    assert(is_instance(lform), "wrong type");
   32.25    return lform->obj_field(_vmentry_offset);
    33.1 --- a/src/share/vm/classfile/javaClasses.hpp	Fri Jul 21 20:31:41 2017 -0700
    33.2 +++ b/src/share/vm/classfile/javaClasses.hpp	Mon Jul 24 09:32:40 2017 -0700
    33.3 @@ -1,5 +1,5 @@
    33.4  /*
    33.5 - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
    33.6 + * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
    33.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.8   *
    33.9   * This code is free software; you can redistribute it and/or modify it
   33.10 @@ -1132,6 +1132,8 @@
   33.11    static int flags_offset_in_bytes()            { return _flags_offset; }
   33.12    static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
   33.13    static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
   33.14 +
   33.15 +  static bool equals(oop mt1, oop mt2);
   33.16  };
   33.17  
   33.18  
    34.1 --- a/src/share/vm/classfile/systemDictionary.cpp	Fri Jul 21 20:31:41 2017 -0700
    34.2 +++ b/src/share/vm/classfile/systemDictionary.cpp	Mon Jul 24 09:32:40 2017 -0700
    34.3 @@ -1084,15 +1084,18 @@
    34.4                                                               THREAD);
    34.5  
    34.6    const char* pkg = "java/";
    34.7 +  size_t pkglen = strlen(pkg);
    34.8    if (!HAS_PENDING_EXCEPTION &&
    34.9        !class_loader.is_null() &&
   34.10        parsed_name != NULL &&
   34.11 -      !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) {
   34.12 +      parsed_name->utf8_length() >= (int)pkglen &&
   34.13 +      !strncmp((const char*)parsed_name->bytes(), pkg, pkglen)) {
   34.14      // It is illegal to define classes in the "java." package from
   34.15      // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader
   34.16      ResourceMark rm(THREAD);
   34.17      char* name = parsed_name->as_C_string();
   34.18      char* index = strrchr(name, '/');
   34.19 +    assert(index != NULL, "must be");
   34.20      *index = '\0'; // chop to just the package name
   34.21      while ((index = strchr(name, '/')) != NULL) {
   34.22        *index = '.'; // replace '/' with '.' in package name
    35.1 --- a/src/share/vm/code/nmethod.cpp	Fri Jul 21 20:31:41 2017 -0700
    35.2 +++ b/src/share/vm/code/nmethod.cpp	Mon Jul 24 09:32:40 2017 -0700
    35.3 @@ -1151,6 +1151,7 @@
    35.4  // Clear ICStubs of all compiled ICs
    35.5  void nmethod::clear_ic_stubs() {
    35.6    assert_locked_or_safepoint(CompiledIC_lock);
    35.7 +  ResourceMark rm;
    35.8    RelocIterator iter(this);
    35.9    while(iter.next()) {
   35.10      if (iter.type() == relocInfo::virtual_call_type) {
    36.1 --- a/src/share/vm/oops/instanceKlass.cpp	Fri Jul 21 20:31:41 2017 -0700
    36.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Mon Jul 24 09:32:40 2017 -0700
    36.3 @@ -3018,7 +3018,7 @@
    36.4    return NULL;
    36.5  }
    36.6  
    36.7 -bool InstanceKlass::add_member_name(Handle mem_name) {
    36.8 +oop InstanceKlass::add_member_name(Handle mem_name, bool intern) {
    36.9    jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
   36.10    MutexLocker ml(MemberNameTable_lock);
   36.11    DEBUG_ONLY(No_Safepoint_Verifier nsv);
   36.12 @@ -3028,7 +3028,7 @@
   36.13    // is called!
   36.14    Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name());
   36.15    if (method->is_obsolete()) {
   36.16 -    return false;
   36.17 +    return NULL;
   36.18    } else if (method->is_old()) {
   36.19      // Replace method with redefined version
   36.20      java_lang_invoke_MemberName::set_vmtarget(mem_name(), method_with_idnum(method->method_idnum()));
   36.21 @@ -3037,8 +3037,11 @@
   36.22    if (_member_names == NULL) {
   36.23      _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count());
   36.24    }
   36.25 -  _member_names->add_member_name(mem_name_wref);
   36.26 -  return true;
   36.27 +  if (intern) {
   36.28 +    return _member_names->find_or_add_member_name(mem_name_wref);
   36.29 +  } else {
   36.30 +    return _member_names->add_member_name(mem_name_wref);
   36.31 +  }
   36.32  }
   36.33  
   36.34  // -----------------------------------------------------------------------------------------------------
    37.1 --- a/src/share/vm/oops/instanceKlass.hpp	Fri Jul 21 20:31:41 2017 -0700
    37.2 +++ b/src/share/vm/oops/instanceKlass.hpp	Mon Jul 24 09:32:40 2017 -0700
    37.3 @@ -1105,7 +1105,7 @@
    37.4    // JSR-292 support
    37.5    MemberNameTable* member_names() { return _member_names; }
    37.6    void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
    37.7 -  bool add_member_name(Handle member_name);
    37.8 +  oop add_member_name(Handle member_name, bool intern);
    37.9  
   37.10  public:
   37.11    // JVMTI support
    38.1 --- a/src/share/vm/opto/cfgnode.hpp	Fri Jul 21 20:31:41 2017 -0700
    38.2 +++ b/src/share/vm/opto/cfgnode.hpp	Mon Jul 24 09:32:40 2017 -0700
    38.3 @@ -119,6 +119,9 @@
    38.4  // input in slot 0.
    38.5  class PhiNode : public TypeNode {
    38.6    const TypePtr* const _adr_type; // non-null only for Type::MEMORY nodes.
    38.7 +  // The following fields are only used for data PhiNodes to indicate
    38.8 +  // that the PhiNode represents the value of a known instance field.
    38.9 +        int _inst_mem_id; // Instance memory id (node index of the memory Phi)
   38.10    const int _inst_id;     // Instance id of the memory slice.
   38.11    const int _inst_index;  // Alias index of the instance memory slice.
   38.12    // Array elements references have the same alias_idx but different offset.
   38.13 @@ -138,11 +141,13 @@
   38.14    };
   38.15  
   38.16    PhiNode( Node *r, const Type *t, const TypePtr* at = NULL,
   38.17 +           const int imid = -1,
   38.18             const int iid = TypeOopPtr::InstanceTop,
   38.19             const int iidx = Compile::AliasIdxTop,
   38.20             const int ioffs = Type::OffsetTop )
   38.21      : TypeNode(t,r->req()),
   38.22        _adr_type(at),
   38.23 +      _inst_mem_id(imid),
   38.24        _inst_id(iid),
   38.25        _inst_index(iidx),
   38.26        _inst_offset(ioffs)
   38.27 @@ -187,11 +192,14 @@
   38.28    virtual bool pinned() const { return in(0) != 0; }
   38.29    virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
   38.30  
   38.31 +  void  set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; }
   38.32 +  const int inst_mem_id() const { return _inst_mem_id; }
   38.33    const int inst_id()     const { return _inst_id; }
   38.34    const int inst_index()  const { return _inst_index; }
   38.35    const int inst_offset() const { return _inst_offset; }
   38.36 -  bool is_same_inst_field(const Type* tp, int id, int index, int offset) {
   38.37 +  bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) {
   38.38      return type()->basic_type() == tp->basic_type() &&
   38.39 +           inst_mem_id() == mem_id &&
   38.40             inst_id()     == id     &&
   38.41             inst_index()  == index  &&
   38.42             inst_offset() == offset &&
    39.1 --- a/src/share/vm/opto/macro.cpp	Fri Jul 21 20:31:41 2017 -0700
    39.2 +++ b/src/share/vm/opto/macro.cpp	Mon Jul 24 09:32:40 2017 -0700
    39.3 @@ -401,7 +401,7 @@
    39.4    for (DUIterator_Fast kmax, k = region->fast_outs(kmax); k < kmax; k++) {
    39.5      Node* phi = region->fast_out(k);
    39.6      if (phi->is_Phi() && phi != mem &&
    39.7 -        phi->as_Phi()->is_same_inst_field(phi_type, instance_id, alias_idx, offset)) {
    39.8 +        phi->as_Phi()->is_same_inst_field(phi_type, (int)mem->_idx, instance_id, alias_idx, offset)) {
    39.9        return phi;
   39.10      }
   39.11    }
   39.12 @@ -420,7 +420,7 @@
   39.13    GrowableArray <Node *> values(length, length, NULL, false);
   39.14  
   39.15    // create a new Phi for the value
   39.16 -  PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, instance_id, alias_idx, offset);
   39.17 +  PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, mem->_idx, instance_id, alias_idx, offset);
   39.18    transform_later(phi);
   39.19    value_phis->push(phi, mem->_idx);
   39.20  
    40.1 --- a/src/share/vm/opto/memnode.cpp	Fri Jul 21 20:31:41 2017 -0700
    40.2 +++ b/src/share/vm/opto/memnode.cpp	Mon Jul 24 09:32:40 2017 -0700
    40.3 @@ -1155,7 +1155,7 @@
    40.4      for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
    40.5        Node* phi = region->fast_out(i);
    40.6        if (phi->is_Phi() && phi != mem &&
    40.7 -          phi->as_Phi()->is_same_inst_field(this_type, this_iid, this_index, this_offset)) {
    40.8 +          phi->as_Phi()->is_same_inst_field(this_type, (int)mem->_idx, this_iid, this_index, this_offset)) {
    40.9          return phi;
   40.10        }
   40.11      }
   40.12 @@ -1400,7 +1400,7 @@
   40.13      this_iid = base->_idx;
   40.14    }
   40.15    PhaseIterGVN* igvn = phase->is_IterGVN();
   40.16 -  Node* phi = new (C) PhiNode(region, this_type, NULL, this_iid, this_index, this_offset);
   40.17 +  Node* phi = new (C) PhiNode(region, this_type, NULL, mem->_idx, this_iid, this_index, this_offset);
   40.18    for (uint i = 1; i < region->req(); i++) {
   40.19      Node* x;
   40.20      Node* the_clone = NULL;
    41.1 --- a/src/share/vm/opto/phaseX.cpp	Fri Jul 21 20:31:41 2017 -0700
    41.2 +++ b/src/share/vm/opto/phaseX.cpp	Mon Jul 24 09:32:40 2017 -0700
    41.3 @@ -481,6 +481,8 @@
    41.4    uint current_idx = 0; // The current new node ID. Incremented after every assignment.
    41.5    for (uint i = 0; i < _useful.size(); i++) {
    41.6      Node* n = _useful.at(i);
    41.7 +    // Sanity check that fails if we ever decide to execute this phase after EA
    41.8 +    assert(!n->is_Phi() || n->as_Phi()->inst_mem_id() == -1, "should not be linked to data Phi");
    41.9      const Type* type = gvn->type_or_null(n);
   41.10      new_type_array.map(current_idx, type);
   41.11  
   41.12 @@ -1378,6 +1380,18 @@
   41.13      i -= num_edges;    // we deleted 1 or more copies of this edge
   41.14    }
   41.15  
   41.16 +  // Search for instance field data PhiNodes in the same region pointing to the old
   41.17 +  // memory PhiNode and update their instance memory ids to point to the new node.
   41.18 +  if (old->is_Phi() && old->as_Phi()->type()->has_memory() && old->in(0) != NULL) {
   41.19 +    Node* region = old->in(0);
   41.20 +    for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
   41.21 +      PhiNode* phi = region->fast_out(i)->isa_Phi();
   41.22 +      if (phi != NULL && phi->inst_mem_id() == (int)old->_idx) {
   41.23 +        phi->set_inst_mem_id((int)nn->_idx);
   41.24 +      }
   41.25 +    }
   41.26 +  }
   41.27 +
   41.28    // Smash all inputs to 'old', isolating him completely
   41.29    Node *temp = new (C) Node(1);
   41.30    temp->init_req(0,nn);     // Add a use to nn to prevent him from dying
    42.1 --- a/src/share/vm/opto/type.hpp	Fri Jul 21 20:31:41 2017 -0700
    42.2 +++ b/src/share/vm/opto/type.hpp	Mon Jul 24 09:32:40 2017 -0700
    42.3 @@ -882,7 +882,7 @@
    42.4  
    42.5    // If not InstanceTop or InstanceBot, indicates that this is
    42.6    // a particular instance of this type which is distinct.
    42.7 -  // This is the the node index of the allocation node creating this instance.
    42.8 +  // This is the node index of the allocation node creating this instance.
    42.9    int           _instance_id;
   42.10  
   42.11    // Extra type information profiling gave us. We propagate it the
    43.1 --- a/src/share/vm/prims/jni.cpp	Fri Jul 21 20:31:41 2017 -0700
    43.2 +++ b/src/share/vm/prims/jni.cpp	Mon Jul 24 09:32:40 2017 -0700
    43.3 @@ -5129,6 +5129,7 @@
    43.4      run_unit_test(TestKlass_test());
    43.5      run_unit_test(Test_linked_list());
    43.6      run_unit_test(TestChunkedList_test());
    43.7 +    run_unit_test(ObjectMonitor::sanity_checks());
    43.8  #if INCLUDE_VM_STRUCTS
    43.9      run_unit_test(VMStructs::test());
   43.10  #endif
    44.1 --- a/src/share/vm/prims/jvm.cpp	Fri Jul 21 20:31:41 2017 -0700
    44.2 +++ b/src/share/vm/prims/jvm.cpp	Mon Jul 24 09:32:40 2017 -0700
    44.3 @@ -643,7 +643,7 @@
    44.4        // This can safepoint and redefine method, so need both new_obj and method
    44.5        // in a handle, for two different reasons.  new_obj can move, method can be
    44.6        // deleted if nothing is using it on the stack.
    44.7 -      m->method_holder()->add_member_name(new_obj());
    44.8 +      m->method_holder()->add_member_name(new_obj(), false);
    44.9      }
   44.10    }
   44.11  
    45.1 --- a/src/share/vm/prims/methodHandles.cpp	Fri Jul 21 20:31:41 2017 -0700
    45.2 +++ b/src/share/vm/prims/methodHandles.cpp	Mon Jul 24 09:32:40 2017 -0700
    45.3 @@ -173,7 +173,7 @@
    45.4    return NULL;
    45.5  }
    45.6  
    45.7 -oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info) {
    45.8 +oop MethodHandles::init_method_MemberName(Handle mname, CallInfo& info, bool intern) {
    45.9    assert(info.resolved_appendix().is_null(), "only normal methods here");
   45.10    methodHandle m = info.resolved_method();
   45.11    KlassHandle m_klass = m->method_holder();
   45.12 @@ -270,13 +270,7 @@
   45.13    // If relevant, the vtable or itable value is stored as vmindex.
   45.14    // This is done eagerly, since it is readily available without
   45.15    // constructing any new objects.
   45.16 -  // TO DO: maybe intern mname_oop
   45.17 -  if (m->method_holder()->add_member_name(mname)) {
   45.18 -    return mname();
   45.19 -  } else {
   45.20 -    // Redefinition caused this to fail.  Return NULL (and an exception?)
   45.21 -    return NULL;
   45.22 -  }
   45.23 +  return m->method_holder()->add_member_name(mname, intern);
   45.24  }
   45.25  
   45.26  oop MethodHandles::init_field_MemberName(Handle mname, fieldDescriptor& fd, bool is_setter) {
   45.27 @@ -917,7 +911,9 @@
   45.28          if (!java_lang_invoke_MemberName::is_instance(result()))
   45.29            return -99;  // caller bug!
   45.30          CallInfo info(m);
   45.31 -        oop saved = MethodHandles::init_method_MemberName(result, info);
   45.32 +        // Since this is going through the methods to create MemberNames, don't search
   45.33 +        // for matching methods already in the table
   45.34 +        oop saved = MethodHandles::init_method_MemberName(result, info, /*intern*/false);
   45.35          if (saved != result())
   45.36            results->obj_at_put(rfill-1, saved);  // show saved instance to user
   45.37        } else if (++overflow >= overflow_limit) {
   45.38 @@ -949,9 +945,34 @@
   45.39    }
   45.40  }
   45.41  
   45.42 -void MemberNameTable::add_member_name(jweak mem_name_wref) {
   45.43 +oop MemberNameTable::add_member_name(jweak mem_name_wref) {
   45.44    assert_locked_or_safepoint(MemberNameTable_lock);
   45.45    this->push(mem_name_wref);
   45.46 +  return JNIHandles::resolve(mem_name_wref);
   45.47 +}
   45.48 +
   45.49 +oop MemberNameTable::find_or_add_member_name(jweak mem_name_wref) {
   45.50 +  assert_locked_or_safepoint(MemberNameTable_lock);
   45.51 +  oop new_mem_name = JNIHandles::resolve(mem_name_wref);
   45.52 +
   45.53 +  // Find matching member name in the list.
   45.54 +  // This is linear because these are short lists.
   45.55 +  int len = this->length();
   45.56 +  int new_index = len;
   45.57 +  for (int idx = 0; idx < len; idx++) {
   45.58 +    oop mname = JNIHandles::resolve(this->at(idx));
   45.59 +    if (mname == NULL) {
   45.60 +      new_index = idx;
   45.61 +      continue;
   45.62 +    }
   45.63 +    if (java_lang_invoke_MemberName::equals(new_mem_name, mname)) {
   45.64 +      JNIHandles::destroy_weak_global(mem_name_wref);
   45.65 +      return mname;
   45.66 +    }
   45.67 +  }
   45.68 +  // Not found, push the new one, or reuse empty slot
   45.69 +  this->at_put_grow(new_index, mem_name_wref);
   45.70 +  return new_mem_name;
   45.71  }
   45.72  
   45.73  #if INCLUDE_JVMTI
    46.1 --- a/src/share/vm/prims/methodHandles.hpp	Fri Jul 21 20:31:41 2017 -0700
    46.2 +++ b/src/share/vm/prims/methodHandles.hpp	Mon Jul 24 09:32:40 2017 -0700
    46.3 @@ -1,5 +1,5 @@
    46.4  /*
    46.5 - * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
    46.6 + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
    46.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    46.8   *
    46.9   * This code is free software; you can redistribute it and/or modify it
   46.10 @@ -60,7 +60,7 @@
   46.11    static Handle new_MemberName(TRAPS);  // must be followed by init_MemberName
   46.12    static oop init_MemberName(Handle mname_h, Handle target_h); // compute vmtarget/vmindex from target
   46.13    static oop init_field_MemberName(Handle mname_h, fieldDescriptor& fd, bool is_setter = false);
   46.14 -  static oop init_method_MemberName(Handle mname_h, CallInfo& info);
   46.15 +  static oop init_method_MemberName(Handle mname_h, CallInfo& info, bool intern = true);
   46.16    static int method_ref_kind(Method* m, bool do_dispatch_if_possible = true);
   46.17    static int find_MemberNames(KlassHandle k, Symbol* name, Symbol* sig,
   46.18                                int mflags, KlassHandle caller,
   46.19 @@ -236,7 +236,8 @@
   46.20   public:
   46.21    MemberNameTable(int methods_cnt);
   46.22    ~MemberNameTable();
   46.23 -  void add_member_name(jweak mem_name_ref);
   46.24 +  oop add_member_name(jweak mem_name_ref);
   46.25 +  oop find_or_add_member_name(jweak mem_name_ref);
   46.26  
   46.27  #if INCLUDE_JVMTI
   46.28    // RedefineClasses() API support:
    47.1 --- a/src/share/vm/runtime/objectMonitor.cpp	Fri Jul 21 20:31:41 2017 -0700
    47.2 +++ b/src/share/vm/runtime/objectMonitor.cpp	Mon Jul 24 09:32:40 2017 -0700
    47.3 @@ -2529,6 +2529,10 @@
    47.4    SETKNOB(FastHSSEC) ;
    47.5    #undef SETKNOB
    47.6  
    47.7 +  if (Knob_Verbose) {
    47.8 +    sanity_checks();
    47.9 +  }
   47.10 +
   47.11    if (os::is_MP()) {
   47.12       BackOffMask = (1 << Knob_SpinBackOff) - 1 ;
   47.13       if (Knob_ReportSettings) ::printf ("BackOffMask=%X\n", BackOffMask) ;
   47.14 @@ -2549,6 +2553,66 @@
   47.15    InitDone = 1 ;
   47.16  }
   47.17  
   47.18 +void ObjectMonitor::sanity_checks() {
   47.19 +  int error_cnt = 0;
   47.20 +  int warning_cnt = 0;
   47.21 +  bool verbose = Knob_Verbose != 0 NOT_PRODUCT(|| VerboseInternalVMTests);
   47.22 +
   47.23 +  if (verbose) {
   47.24 +    tty->print_cr("INFO: sizeof(ObjectMonitor)=" SIZE_FORMAT,
   47.25 +                  sizeof(ObjectMonitor));
   47.26 +  }
   47.27 +
   47.28 +  uint cache_line_size = VM_Version::L1_data_cache_line_size();
   47.29 +  if (verbose) {
   47.30 +    tty->print_cr("INFO: L1_data_cache_line_size=%u", cache_line_size);
   47.31 +  }
   47.32 +
   47.33 +  ObjectMonitor dummy;
   47.34 +  u_char *addr_begin  = (u_char*)&dummy;
   47.35 +  u_char *addr_header = (u_char*)&dummy._header;
   47.36 +  u_char *addr_owner  = (u_char*)&dummy._owner;
   47.37 +
   47.38 +  uint offset_header = (uint)(addr_header - addr_begin);
   47.39 +  if (verbose) tty->print_cr("INFO: offset(_header)=%u", offset_header);
   47.40 +
   47.41 +  uint offset_owner = (uint)(addr_owner - addr_begin);
   47.42 +  if (verbose) tty->print_cr("INFO: offset(_owner)=%u", offset_owner);
   47.43 +
   47.44 +  if ((uint)(addr_header - addr_begin) != 0) {
   47.45 +    tty->print_cr("ERROR: offset(_header) must be zero (0).");
   47.46 +    error_cnt++;
   47.47 +  }
   47.48 +
   47.49 +  if (cache_line_size != 0) {
   47.50 +    // We were able to determine the L1 data cache line size so
   47.51 +    // do some cache line specific sanity checks
   47.52 +
   47.53 +    if ((offset_owner - offset_header) < cache_line_size) {
   47.54 +      tty->print_cr("WARNING: the _header and _owner fields are closer "
   47.55 +                    "than a cache line which permits false sharing.");
   47.56 +      warning_cnt++;
   47.57 +    }
   47.58 +
   47.59 +    if ((sizeof(ObjectMonitor) % cache_line_size) != 0) {
   47.60 +      tty->print_cr("WARNING: ObjectMonitor size is not a multiple of "
   47.61 +                    "a cache line which permits false sharing.");
   47.62 +      warning_cnt++;
   47.63 +    }
   47.64 +  }
   47.65 +
   47.66 +  ObjectSynchronizer::sanity_checks(verbose, cache_line_size, &error_cnt,
   47.67 +                                    &warning_cnt);
   47.68 +
   47.69 +  if (verbose || error_cnt != 0 || warning_cnt != 0) {
   47.70 +    tty->print_cr("INFO: error_cnt=%d", error_cnt);
   47.71 +    tty->print_cr("INFO: warning_cnt=%d", warning_cnt);
   47.72 +  }
   47.73 +
   47.74 +  guarantee(error_cnt == 0,
   47.75 +            "Fatal error(s) found in ObjectMonitor::sanity_checks()");
   47.76 +}
   47.77 +
   47.78  #ifndef PRODUCT
   47.79  void ObjectMonitor::verify() {
   47.80  }
    48.1 --- a/src/share/vm/runtime/objectMonitor.hpp	Fri Jul 21 20:31:41 2017 -0700
    48.2 +++ b/src/share/vm/runtime/objectMonitor.hpp	Mon Jul 24 09:32:40 2017 -0700
    48.3 @@ -189,6 +189,8 @@
    48.4    bool      check(TRAPS);       // true if the thread owns the monitor.
    48.5    void      check_slow(TRAPS);
    48.6    void      clear();
    48.7 +  static void sanity_checks();  // public for -XX:+ExecuteInternalVMTests
    48.8 +                                // in PRODUCT for -XX:SyncKnobs=Verbose=1
    48.9  #ifndef PRODUCT
   48.10    void      verify();
   48.11    void      print();
   48.12 @@ -234,8 +236,6 @@
   48.13  
   48.14    // WARNING: this must be the very first word of ObjectMonitor
   48.15    // This means this class can't use any virtual member functions.
   48.16 -  // TODO-FIXME: assert that offsetof(_header) is 0 or get rid of the
   48.17 -  // implicit 0 offset in emitted code.
   48.18  
   48.19    volatile markOop   _header;       // displaced object header word - mark
   48.20    void*     volatile _object;       // backward object pointer - strong root
    49.1 --- a/src/share/vm/runtime/sweeper.cpp	Fri Jul 21 20:31:41 2017 -0700
    49.2 +++ b/src/share/vm/runtime/sweeper.cpp	Mon Jul 24 09:32:40 2017 -0700
    49.3 @@ -319,6 +319,7 @@
    49.4  }
    49.5  
    49.6  void NMethodSweeper::sweep_code_cache() {
    49.7 +  ResourceMark rm;
    49.8    Ticks sweep_start_counter = Ticks::now();
    49.9  
   49.10    _flushed_count                = 0;
   49.11 @@ -626,6 +627,7 @@
   49.12  // state of the code cache if it's requested.
   49.13  void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
   49.14    if (PrintMethodFlushing) {
   49.15 +    ResourceMark rm;
   49.16      stringStream s;
   49.17      // Dump code cache state into a buffer before locking the tty,
   49.18      // because log_state() will use locks causing lock conflicts.
   49.19 @@ -643,6 +645,7 @@
   49.20    }
   49.21  
   49.22    if (LogCompilation && (xtty != NULL)) {
   49.23 +    ResourceMark rm;
   49.24      stringStream s;
   49.25      // Dump code cache state into a buffer before locking the tty,
   49.26      // because log_state() will use locks causing lock conflicts.
    50.1 --- a/src/share/vm/runtime/synchronizer.cpp	Fri Jul 21 20:31:41 2017 -0700
    50.2 +++ b/src/share/vm/runtime/synchronizer.cpp	Mon Jul 24 09:32:40 2017 -0700
    50.3 @@ -437,19 +437,22 @@
    50.4  // Hash Code handling
    50.5  //
    50.6  // Performance concern:
    50.7 -// OrderAccess::storestore() calls release() which STs 0 into the global volatile
    50.8 -// OrderAccess::Dummy variable.  This store is unnecessary for correctness.
    50.9 -// Many threads STing into a common location causes considerable cache migration
   50.10 -// or "sloshing" on large SMP system.  As such, I avoid using OrderAccess::storestore()
   50.11 -// until it's repaired.  In some cases OrderAccess::fence() -- which incurs local
   50.12 -// latency on the executing processor -- is a better choice as it scales on SMP
   50.13 -// systems.  See http://blogs.sun.com/dave/entry/biased_locking_in_hotspot for a
   50.14 -// discussion of coherency costs.  Note that all our current reference platforms
   50.15 -// provide strong ST-ST order, so the issue is moot on IA32, x64, and SPARC.
   50.16 +// OrderAccess::storestore() calls release() which at one time stored 0
   50.17 +// into the global volatile OrderAccess::dummy variable. This store was
   50.18 +// unnecessary for correctness. Many threads storing into a common location
   50.19 +// causes considerable cache migration or "sloshing" on large SMP systems.
   50.20 +// As such, I avoided using OrderAccess::storestore(). In some cases
   50.21 +// OrderAccess::fence() -- which incurs local latency on the executing
   50.22 +// processor -- is a better choice as it scales on SMP systems.
   50.23 +//
   50.24 +// See http://blogs.oracle.com/dave/entry/biased_locking_in_hotspot for
   50.25 +// a discussion of coherency costs. Note that all our current reference
   50.26 +// platforms provide strong ST-ST order, so the issue is moot on IA32,
   50.27 +// x64, and SPARC.
   50.28  //
   50.29  // As a general policy we use "volatile" to control compiler-based reordering
   50.30 -// and explicit fences (barriers) to control for architectural reordering performed
   50.31 -// by the CPU(s) or platform.
   50.32 +// and explicit fences (barriers) to control for architectural reordering
   50.33 +// performed by the CPU(s) or platform.
   50.34  
   50.35  struct SharedGlobals {
   50.36      // These are highly shared mostly-read variables.
   50.37 @@ -1636,7 +1639,55 @@
   50.38  }
   50.39  
   50.40  //------------------------------------------------------------------------------
   50.41 -// Non-product code
   50.42 +// Debugging code
   50.43 +
   50.44 +void ObjectSynchronizer::sanity_checks(const bool verbose,
   50.45 +                                       const uint cache_line_size,
   50.46 +                                       int *error_cnt_ptr,
   50.47 +                                       int *warning_cnt_ptr) {
   50.48 +  u_char *addr_begin      = (u_char*)&GVars;
   50.49 +  u_char *addr_stwRandom  = (u_char*)&GVars.stwRandom;
   50.50 +  u_char *addr_hcSequence = (u_char*)&GVars.hcSequence;
   50.51 +
   50.52 +  if (verbose) {
   50.53 +    tty->print_cr("INFO: sizeof(SharedGlobals)=" SIZE_FORMAT,
   50.54 +                  sizeof(SharedGlobals));
   50.55 +  }
   50.56 +
   50.57 +  uint offset_stwRandom = (uint)(addr_stwRandom - addr_begin);
   50.58 +  if (verbose) tty->print_cr("INFO: offset(stwRandom)=%u", offset_stwRandom);
   50.59 +
   50.60 +  uint offset_hcSequence = (uint)(addr_hcSequence - addr_begin);
   50.61 +  if (verbose) {
   50.62 +    tty->print_cr("INFO: offset(_hcSequence)=%u", offset_hcSequence);
   50.63 +  }
   50.64 +
   50.65 +  if (cache_line_size != 0) {
   50.66 +    // We were able to determine the L1 data cache line size so
   50.67 +    // do some cache line specific sanity checks
   50.68 +
   50.69 +    if (offset_stwRandom < cache_line_size) {
   50.70 +      tty->print_cr("WARNING: the SharedGlobals.stwRandom field is closer "
   50.71 +                    "to the struct beginning than a cache line which permits "
   50.72 +                    "false sharing.");
   50.73 +      (*warning_cnt_ptr)++;
   50.74 +    }
   50.75 +
   50.76 +    if ((offset_hcSequence - offset_stwRandom) < cache_line_size) {
   50.77 +      tty->print_cr("WARNING: the SharedGlobals.stwRandom and "
   50.78 +                    "SharedGlobals.hcSequence fields are closer than a cache "
   50.79 +                    "line which permits false sharing.");
   50.80 +      (*warning_cnt_ptr)++;
   50.81 +    }
   50.82 +
   50.83 +    if ((sizeof(SharedGlobals) - offset_hcSequence) < cache_line_size) {
   50.84 +      tty->print_cr("WARNING: the SharedGlobals.hcSequence field is closer "
   50.85 +                    "to the struct end than a cache line which permits false "
   50.86 +                    "sharing.");
   50.87 +      (*warning_cnt_ptr)++;
   50.88 +    }
   50.89 +  }
   50.90 +}
   50.91  
   50.92  #ifndef PRODUCT
   50.93  
    51.1 --- a/src/share/vm/runtime/synchronizer.hpp	Fri Jul 21 20:31:41 2017 -0700
    51.2 +++ b/src/share/vm/runtime/synchronizer.hpp	Mon Jul 24 09:32:40 2017 -0700
    51.3 @@ -121,6 +121,9 @@
    51.4    static void oops_do(OopClosure* f);
    51.5  
    51.6    // debugging
    51.7 +  static void sanity_checks(const bool verbose,
    51.8 +                            const unsigned int cache_line_size,
    51.9 +                            int *error_cnt_ptr, int *warning_cnt_ptr);
   51.10    static void verify() PRODUCT_RETURN;
   51.11    static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
   51.12  
    52.1 --- a/src/share/vm/runtime/vm_version.cpp	Fri Jul 21 20:31:41 2017 -0700
    52.2 +++ b/src/share/vm/runtime/vm_version.cpp	Mon Jul 24 09:32:40 2017 -0700
    52.3 @@ -50,6 +50,7 @@
    52.4  bool Abstract_VM_Version::_supports_atomic_getadd4 = false;
    52.5  bool Abstract_VM_Version::_supports_atomic_getadd8 = false;
    52.6  unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
    52.7 +unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
    52.8  int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
    52.9  
   52.10  #ifndef HOTSPOT_RELEASE_VERSION
    53.1 --- a/src/share/vm/runtime/vm_version.hpp	Fri Jul 21 20:31:41 2017 -0700
    53.2 +++ b/src/share/vm/runtime/vm_version.hpp	Mon Jul 24 09:32:40 2017 -0700
    53.3 @@ -1,5 +1,5 @@
    53.4  /*
    53.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    53.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    53.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    53.8   *
    53.9   * This code is free software; you can redistribute it and/or modify it
   53.10 @@ -42,6 +42,7 @@
   53.11    static bool         _supports_atomic_getadd4;
   53.12    static bool         _supports_atomic_getadd8;
   53.13    static unsigned int _logical_processors_per_package;
   53.14 +  static unsigned int _L1_data_cache_line_size;
   53.15    static int          _vm_major_version;
   53.16    static int          _vm_minor_version;
   53.17    static int          _vm_build_number;
   53.18 @@ -114,6 +115,10 @@
   53.19      return _logical_processors_per_package;
   53.20    }
   53.21  
   53.22 +  static unsigned int L1_data_cache_line_size() {
   53.23 +    return _L1_data_cache_line_size;
   53.24 +  }
   53.25 +
   53.26    // Need a space at the end of TLAB for prefetch instructions
   53.27    // which may fault when accessing memory outside of heap.
   53.28    static int reserve_for_allocation_prefetch() {
    54.1 --- a/src/share/vm/services/lowMemoryDetector.cpp	Fri Jul 21 20:31:41 2017 -0700
    54.2 +++ b/src/share/vm/services/lowMemoryDetector.cpp	Mon Jul 24 09:32:40 2017 -0700
    54.3 @@ -1,5 +1,5 @@
    54.4  /*
    54.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
    54.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
    54.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    54.8   *
    54.9   * This code is free software; you can redistribute it and/or modify it
   54.10 @@ -298,19 +298,41 @@
   54.11      Klass* k = Management::sun_management_Sensor_klass(CHECK);
   54.12      instanceKlassHandle sensorKlass (THREAD, k);
   54.13      Handle sensor_h(THREAD, _sensor_obj);
   54.14 -    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, CHECK);
   54.15 +
   54.16 +    Symbol* trigger_method_signature;
   54.17  
   54.18      JavaValue result(T_VOID);
   54.19      JavaCallArguments args(sensor_h);
   54.20      args.push_int((int) count);
   54.21 -    args.push_oop(usage_h);
   54.22 +
   54.23 +    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, THREAD);
   54.24 +    // Call Sensor::trigger(int, MemoryUsage) to send notification to listeners.
   54.25 +    // When OOME occurs and fails to allocate MemoryUsage object, call
   54.26 +    // Sensor::trigger(int) instead.  The pending request will be processed
   54.27 +    // but no notification will be sent.
   54.28 +    if (HAS_PENDING_EXCEPTION) {
   54.29 +       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
   54.30 +       CLEAR_PENDING_EXCEPTION;
   54.31 +       trigger_method_signature = vmSymbols::int_void_signature();
   54.32 +    } else {
   54.33 +       trigger_method_signature = vmSymbols::trigger_method_signature();
   54.34 +       args.push_oop(usage_h);
   54.35 +    }
   54.36  
   54.37      JavaCalls::call_virtual(&result,
   54.38                              sensorKlass,
   54.39                              vmSymbols::trigger_name(),
   54.40 -                            vmSymbols::trigger_method_signature(),
   54.41 +                            trigger_method_signature,
   54.42                              &args,
   54.43 -                            CHECK);
   54.44 +                            THREAD);
   54.45 +
   54.46 +    if (HAS_PENDING_EXCEPTION) {
   54.47 +       // We just clear the OOM pending exception that we might have encountered
   54.48 +       // in Java's tiggerAction(), and continue with updating the counters since
   54.49 +       // the Java counters have been updated too.
   54.50 +       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
   54.51 +       CLEAR_PENDING_EXCEPTION;
   54.52 +     }
   54.53    }
   54.54  
   54.55    {

mercurial