Merge

Tue, 05 Jan 2016 08:28:01 -0800

author
asaha
date
Tue, 05 Jan 2016 08:28:01 -0800
changeset 8270
c3091ebd2811
parent 8269
f796867c1bcb
parent 8205
80959a760b85
child 8277
ac9a68124ba9

Merge

.hgtags file | annotate | diff | comparison | revisions
     1.1 --- a/.hgtags	Tue Dec 15 22:59:18 2015 -0800
     1.2 +++ b/.hgtags	Tue Jan 05 08:28:01 2016 -0800
     1.3 @@ -792,3 +792,5 @@
     1.4  b8e7dd0e21173ad829b40361763d27cb6ac532e9 jdk8u72-b12
     1.5  a8e4754b89aecc388623394a20f6d43d4c58f083 jdk8u72-b13
     1.6  d7b01fb81aa8a5437cb03bc36afe15cf0e55fb89 jdk8u76-b00
     1.7 +c1679cc87ba045219169cabb6b9b378c2b5cc578 jdk8u76-b01
     1.8 +218483967e52b419d885d34af4488a81c5133804 jdk8u76-b02
     2.1 --- a/agent/src/os/linux/LinuxDebuggerLocal.c	Tue Dec 15 22:59:18 2015 -0800
     2.2 +++ b/agent/src/os/linux/LinuxDebuggerLocal.c	Tue Jan 05 08:28:01 2016 -0800
     2.3 @@ -209,9 +209,12 @@
     2.4    verifyBitness(env, (char *) &buf);
     2.5    CHECK_EXCEPTION;
     2.6  
     2.7 +  char err_buf[200];
     2.8    struct ps_prochandle* ph;
     2.9 -  if ( (ph = Pgrab(jpid)) == NULL) {
    2.10 -    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
    2.11 +  if ( (ph = Pgrab(jpid, err_buf, sizeof(err_buf))) == NULL) {
    2.12 +    char msg[230];
    2.13 +    snprintf(msg, sizeof(msg), "Can't attach to the process: %s", err_buf);
    2.14 +    THROW_NEW_DEBUGGER_EXCEPTION(msg);
    2.15    }
    2.16    (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
    2.17    fillThreadsAndLoadObjects(env, this_obj, ph);
     3.1 --- a/agent/src/os/linux/libproc.h	Tue Dec 15 22:59:18 2015 -0800
     3.2 +++ b/agent/src/os/linux/libproc.h	Tue Jan 05 08:28:01 2016 -0800
     3.3 @@ -69,6 +69,7 @@
     3.4  
     3.5  
     3.6  #if defined(sparc) || defined(sparcv9) || defined(ppc64)
     3.7 +#include <asm/ptrace.h>
     3.8  #define user_regs_struct  pt_regs
     3.9  #endif
    3.10  
    3.11 @@ -82,7 +83,7 @@
    3.12  struct ps_prochandle;
    3.13  
    3.14  // attach to a process
    3.15 -struct ps_prochandle* Pgrab(pid_t pid);
    3.16 +struct ps_prochandle* Pgrab(pid_t pid, char* err_buf, size_t err_buf_len);
    3.17  
    3.18  // attach to a core dump
    3.19  struct ps_prochandle* Pgrab_core(const char* execfile, const char* corefile);
     4.1 --- a/agent/src/os/linux/ps_proc.c	Tue Dec 15 22:59:18 2015 -0800
     4.2 +++ b/agent/src/os/linux/ps_proc.c	Tue Jan 05 08:28:01 2016 -0800
     4.3 @@ -215,9 +215,12 @@
     4.4  }
     4.5  
     4.6  // attach to a process/thread specified by "pid"
     4.7 -static bool ptrace_attach(pid_t pid) {
     4.8 +static bool ptrace_attach(pid_t pid, char* err_buf, size_t err_buf_len) {
     4.9    if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
    4.10 -    print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
    4.11 +    char buf[200];
    4.12 +    char* msg = strerror_r(errno, buf, sizeof(buf));
    4.13 +    snprintf(err_buf, err_buf_len, "ptrace(PTRACE_ATTACH, ..) failed for %d: %s", pid, msg);
    4.14 +    print_debug("%s\n", err_buf);
    4.15      return false;
    4.16    } else {
    4.17      return ptrace_waitpid(pid);
    4.18 @@ -339,16 +342,17 @@
    4.19  };
    4.20  
    4.21  // attach to the process. One and only one exposed stuff
    4.22 -struct ps_prochandle* Pgrab(pid_t pid) {
    4.23 +struct ps_prochandle* Pgrab(pid_t pid, char* err_buf, size_t err_buf_len) {
    4.24    struct ps_prochandle* ph = NULL;
    4.25    thread_info* thr = NULL;
    4.26  
    4.27    if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) {
    4.28 -     print_debug("can't allocate memory for ps_prochandle\n");
    4.29 +     snprintf(err_buf, err_buf_len, "can't allocate memory for ps_prochandle");
    4.30 +     print_debug("%s\n", err_buf);
    4.31       return NULL;
    4.32    }
    4.33  
    4.34 -  if (ptrace_attach(pid) != true) {
    4.35 +  if (ptrace_attach(pid, err_buf, err_buf_len) != true) {
    4.36       free(ph);
    4.37       return NULL;
    4.38    }
    4.39 @@ -371,7 +375,7 @@
    4.40    thr = ph->threads;
    4.41    while (thr) {
    4.42       // don't attach to the main thread again
    4.43 -     if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id) != true) {
    4.44 +    if (ph->pid != thr->lwp_id && ptrace_attach(thr->lwp_id, err_buf, err_buf_len) != true) {
    4.45          // even if one attach fails, we get return NULL
    4.46          Prelease(ph);
    4.47          return NULL;
     5.1 --- a/make/linux/Makefile	Tue Dec 15 22:59:18 2015 -0800
     5.2 +++ b/make/linux/Makefile	Tue Jan 05 08:28:01 2016 -0800
     5.3 @@ -67,8 +67,12 @@
     5.4    endif
     5.5  endif
     5.6  # C1 is not ported on ppc64, so we cannot build a tiered VM:
     5.7 -ifeq ($(ARCH),ppc64)
     5.8 -  FORCE_TIERED=0
     5.9 +# Notice: after 8046471 ARCH will be 'ppc' for top-level ppc64 builds but
    5.10 +# 'ppc64' for HotSpot-only ppc64 builds. Need to detect both variants here!
    5.11 +ifneq (,$(findstring $(ARCH), ppc ppc64))
    5.12 +  ifeq ($(ARCH_DATA_MODEL), 64)
    5.13 +    FORCE_TIERED=0
    5.14 +  endif
    5.15  endif
    5.16  
    5.17  ifdef LP64
     6.1 --- a/make/linux/makefiles/defs.make	Tue Dec 15 22:59:18 2015 -0800
     6.2 +++ b/make/linux/makefiles/defs.make	Tue Jan 05 08:28:01 2016 -0800
     6.3 @@ -69,7 +69,7 @@
     6.4  endif
     6.5  
     6.6  # sparc
     6.7 -ifeq ($(ARCH), sparc64)
     6.8 +ifneq (,$(findstring $(ARCH), sparc))
     6.9    ifeq ($(ARCH_DATA_MODEL), 64)
    6.10      ARCH_DATA_MODEL  = 64
    6.11      MAKE_ARGS        += LP64=1
    6.12 @@ -83,39 +83,35 @@
    6.13    HS_ARCH            = sparc
    6.14  endif
    6.15  
    6.16 -# amd64/x86_64
    6.17 -ifneq (,$(findstring $(ARCH), amd64 x86_64))
    6.18 +# i686/i586 and amd64/x86_64
    6.19 +ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586))
    6.20    ifeq ($(ARCH_DATA_MODEL), 64)
    6.21      ARCH_DATA_MODEL = 64
    6.22      MAKE_ARGS       += LP64=1
    6.23      PLATFORM        = linux-amd64
    6.24      VM_PLATFORM     = linux_amd64
    6.25 -    HS_ARCH         = x86
    6.26    else
    6.27      ARCH_DATA_MODEL = 32
    6.28      PLATFORM        = linux-i586
    6.29      VM_PLATFORM     = linux_i486
    6.30 -    HS_ARCH         = x86
    6.31 -    # We have to reset ARCH to i686 since SRCARCH relies on it
    6.32 -    ARCH            = i686
    6.33    endif
    6.34 +  HS_ARCH           = x86
    6.35  endif
    6.36  
    6.37 -# i686/i586 ie 32-bit x86
    6.38 -ifneq (,$(findstring $(ARCH), i686 i586))
    6.39 -  ARCH_DATA_MODEL  = 32
    6.40 -  PLATFORM         = linux-i586
    6.41 -  VM_PLATFORM      = linux_i486
    6.42 -  HS_ARCH          = x86
    6.43 -endif
    6.44 -
    6.45 -# PPC64
    6.46 -ifeq ($(ARCH), ppc64)
    6.47 -  ARCH_DATA_MODEL  = 64
    6.48 -  MAKE_ARGS        += LP64=1
    6.49 -  PLATFORM         = linux-ppc64
    6.50 -  VM_PLATFORM      = linux_ppc64
    6.51 -  HS_ARCH          = ppc
    6.52 +# PPC
    6.53 +# Notice: after 8046471 ARCH will be 'ppc' for top-level ppc64 builds but
    6.54 +# 'ppc64' for HotSpot-only ppc64 builds. Need to detect both variants here!
    6.55 +ifneq (,$(findstring $(ARCH), ppc ppc64))
    6.56 +  ifeq ($(ARCH_DATA_MODEL), 64)
    6.57 +    MAKE_ARGS        += LP64=1
    6.58 +    PLATFORM         = linux-ppc64
    6.59 +    VM_PLATFORM      = linux_ppc64
    6.60 +  else
    6.61 +    ARCH_DATA_MODEL  = 32
    6.62 +    PLATFORM         = linux-ppc
    6.63 +    VM_PLATFORM      = linux_ppc
    6.64 +  endif
    6.65 +  HS_ARCH = ppc
    6.66  endif
    6.67  
    6.68  # On 32 bit linux we build server and client, on 64 bit just server.
     7.1 --- a/src/cpu/sparc/vm/frame_sparc.cpp	Tue Dec 15 22:59:18 2015 -0800
     7.2 +++ b/src/cpu/sparc/vm/frame_sparc.cpp	Tue Jan 05 08:28:01 2016 -0800
     7.3 @@ -1,5 +1,5 @@
     7.4  /*
     7.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     7.6 + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     7.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.8   *
     7.9   * This code is free software; you can redistribute it and/or modify it
    7.10 @@ -447,32 +447,6 @@
    7.11  }
    7.12  #endif // CC_INTERP
    7.13  
    7.14 -
    7.15 -#ifdef ASSERT
    7.16 -// Debugging aid
    7.17 -static frame nth_sender(int n) {
    7.18 -  frame f = JavaThread::current()->last_frame();
    7.19 -
    7.20 -  for(int i = 0; i < n; ++i)
    7.21 -    f = f.sender((RegisterMap*)NULL);
    7.22 -
    7.23 -  printf("first frame %d\n",          f.is_first_frame()       ? 1 : 0);
    7.24 -  printf("interpreted frame %d\n",    f.is_interpreted_frame() ? 1 : 0);
    7.25 -  printf("java frame %d\n",           f.is_java_frame()        ? 1 : 0);
    7.26 -  printf("entry frame %d\n",          f.is_entry_frame()       ? 1 : 0);
    7.27 -  printf("native frame %d\n",         f.is_native_frame()      ? 1 : 0);
    7.28 -  if (f.is_compiled_frame()) {
    7.29 -    if (f.is_deoptimized_frame())
    7.30 -      printf("deoptimized frame 1\n");
    7.31 -    else
    7.32 -      printf("compiled frame 1\n");
    7.33 -  }
    7.34 -
    7.35 -  return f;
    7.36 -}
    7.37 -#endif
    7.38 -
    7.39 -
    7.40  frame frame::sender_for_entry_frame(RegisterMap *map) const {
    7.41    assert(map != NULL, "map must be set");
    7.42    // Java frame called from C; skip all C frames and return top C
     8.1 --- a/src/share/vm/c1/c1_ValueType.cpp	Tue Dec 15 22:59:18 2015 -0800
     8.2 +++ b/src/share/vm/c1/c1_ValueType.cpp	Tue Jan 05 08:28:01 2016 -0800
     8.3 @@ -153,7 +153,19 @@
     8.4      case T_FLOAT  : return new FloatConstant (value.as_float ());
     8.5      case T_DOUBLE : return new DoubleConstant(value.as_double());
     8.6      case T_ARRAY  : // fall through (ciConstant doesn't have an array accessor)
     8.7 -    case T_OBJECT : return new ObjectConstant(value.as_object());
     8.8 +    case T_OBJECT : {
     8.9 +      // TODO: Common the code with GraphBuilder::load_constant?
    8.10 +      ciObject* obj = value.as_object();
    8.11 +      if (obj->is_null_object())
    8.12 +        return objectNull;
    8.13 +      if (obj->is_loaded()) {
    8.14 +        if (obj->is_array())
    8.15 +          return new ArrayConstant(obj->as_array());
    8.16 +        else if (obj->is_instance())
    8.17 +          return new InstanceConstant(obj->as_instance());
    8.18 +      }
    8.19 +      return new ObjectConstant(obj);
    8.20 +    }
    8.21    }
    8.22    ShouldNotReachHere();
    8.23    return illegalType;
     9.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Dec 15 22:59:18 2015 -0800
     9.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Jan 05 08:28:01 2016 -0800
     9.3 @@ -2331,6 +2331,7 @@
     9.4      case GCCause::_java_lang_system_gc:     return ExplicitGCInvokesConcurrent;
     9.5      case GCCause::_g1_humongous_allocation: return true;
     9.6      case GCCause::_update_allocation_context_stats_inc: return true;
     9.7 +    case GCCause::_wb_conc_mark:            return true;
     9.8      default:                                return false;
     9.9    }
    9.10  }
    10.1 --- a/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Tue Dec 15 22:59:18 2015 -0800
    10.2 +++ b/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Tue Jan 05 08:28:01 2016 -0800
    10.3 @@ -90,12 +90,8 @@
    10.4  
    10.5  void VM_G1IncCollectionPause::doit() {
    10.6    G1CollectedHeap* g1h = G1CollectedHeap::heap();
    10.7 -  assert(!_should_initiate_conc_mark ||
    10.8 -  ((_gc_cause == GCCause::_gc_locker && GCLockerInvokesConcurrent) ||
    10.9 -   (_gc_cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent) ||
   10.10 -    _gc_cause == GCCause::_g1_humongous_allocation ||
   10.11 -    _gc_cause == GCCause::_update_allocation_context_stats_inc),
   10.12 -      "only a GC locker, a System.gc(), stats update or a hum allocation induced GC should start a cycle");
   10.13 +  assert(!_should_initiate_conc_mark || g1h->should_do_concurrent_full_gc(_gc_cause),
   10.14 +      "only a GC locker, a System.gc(), stats update, whitebox, or a hum allocation induced GC should start a cycle");
   10.15  
   10.16    if (_word_size > 0) {
   10.17      // An allocation has been requested. So, try to do that first.
    11.1 --- a/src/share/vm/gc_interface/gcCause.cpp	Tue Dec 15 22:59:18 2015 -0800
    11.2 +++ b/src/share/vm/gc_interface/gcCause.cpp	Tue Jan 05 08:28:01 2016 -0800
    11.3 @@ -54,6 +54,9 @@
    11.4      case _wb_young_gc:
    11.5        return "WhiteBox Initiated Young GC";
    11.6  
    11.7 +    case _wb_conc_mark:
    11.8 +      return "WhiteBox Initiated Concurrent Mark";
    11.9 +
   11.10      case _update_allocation_context_stats_inc:
   11.11      case _update_allocation_context_stats_full:
   11.12        return "Update Allocation Context Stats";
    12.1 --- a/src/share/vm/gc_interface/gcCause.hpp	Tue Dec 15 22:59:18 2015 -0800
    12.2 +++ b/src/share/vm/gc_interface/gcCause.hpp	Tue Jan 05 08:28:01 2016 -0800
    12.3 @@ -47,6 +47,7 @@
    12.4      _heap_inspection,
    12.5      _heap_dump,
    12.6      _wb_young_gc,
    12.7 +    _wb_conc_mark,
    12.8      _update_allocation_context_stats_inc,
    12.9      _update_allocation_context_stats_full,
   12.10  
    13.1 --- a/src/share/vm/opto/c2_globals.hpp	Tue Dec 15 22:59:18 2015 -0800
    13.2 +++ b/src/share/vm/opto/c2_globals.hpp	Tue Jan 05 08:28:01 2016 -0800
    13.3 @@ -205,6 +205,9 @@
    13.4    notproduct(bool, TraceProfileTripCount, false,                            \
    13.5            "Trace profile loop trip count information")                      \
    13.6                                                                              \
    13.7 +  product(bool, UseCountedLoopSafepoints, false,                            \
    13.8 +          "Force counted loops to keep a safepoint")                        \
    13.9 +                                                                            \
   13.10    product(bool, UseLoopPredicate, true,                                     \
   13.11            "Generate a predicate to select fast/slow loop versions")         \
   13.12                                                                              \
   13.13 @@ -669,6 +672,9 @@
   13.14    product_pd(bool, TrapBasedRangeChecks,                                    \
   13.15            "Generate code for range checks that uses a cmp and trap "        \
   13.16            "instruction raising SIGTRAP. Used on PPC64.")                    \
   13.17 +                                                                            \
   13.18 +  develop(bool, RenumberLiveNodes, true,                                    \
   13.19 +          "Renumber live nodes")                                            \
   13.20  
   13.21  C2_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG)
   13.22  
    14.1 --- a/src/share/vm/opto/compile.cpp	Tue Dec 15 22:59:18 2015 -0800
    14.2 +++ b/src/share/vm/opto/compile.cpp	Tue Jan 05 08:28:01 2016 -0800
    14.3 @@ -2093,6 +2093,20 @@
    14.4    // so keep only the actual candidates for optimizations.
    14.5    cleanup_expensive_nodes(igvn);
    14.6  
    14.7 +  if (!failing() && RenumberLiveNodes && live_nodes() + NodeLimitFudgeFactor < unique()) {
    14.8 +    NOT_PRODUCT(Compile::TracePhase t2("", &_t_renumberLive, TimeCompiler);)
    14.9 +    initial_gvn()->replace_with(&igvn);
   14.10 +    for_igvn()->clear();
   14.11 +    Unique_Node_List new_worklist(C->comp_arena());
   14.12 +    {
   14.13 +      ResourceMark rm;
   14.14 +      PhaseRenumberLive prl = PhaseRenumberLive(initial_gvn(), for_igvn(), &new_worklist);
   14.15 +    }
   14.16 +    set_for_igvn(&new_worklist);
   14.17 +    igvn = PhaseIterGVN(initial_gvn());
   14.18 +    igvn.optimize();
   14.19 +  }
   14.20 +
   14.21    // Perform escape analysis
   14.22    if (_do_escape_analysis && ConnectionGraph::has_candidates(this)) {
   14.23      if (has_loops()) {
    15.1 --- a/src/share/vm/opto/loopnode.cpp	Tue Dec 15 22:59:18 2015 -0800
    15.2 +++ b/src/share/vm/opto/loopnode.cpp	Tue Jan 05 08:28:01 2016 -0800
    15.3 @@ -685,14 +685,16 @@
    15.4  
    15.5    } // LoopLimitCheck
    15.6  
    15.7 -  // Check for SafePoint on backedge and remove
    15.8 -  Node *sfpt = x->in(LoopNode::LoopBackControl);
    15.9 -  if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) {
   15.10 -    lazy_replace( sfpt, iftrue );
   15.11 -    if (loop->_safepts != NULL) {
   15.12 -      loop->_safepts->yank(sfpt);
   15.13 +  if (!UseCountedLoopSafepoints) {
   15.14 +    // Check for SafePoint on backedge and remove
   15.15 +    Node *sfpt = x->in(LoopNode::LoopBackControl);
   15.16 +    if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) {
   15.17 +      lazy_replace( sfpt, iftrue );
   15.18 +      if (loop->_safepts != NULL) {
   15.19 +        loop->_safepts->yank(sfpt);
   15.20 +      }
   15.21 +      loop->_tail = iftrue;
   15.22      }
   15.23 -    loop->_tail = iftrue;
   15.24    }
   15.25  
   15.26    // Build a canonical trip test.
   15.27 @@ -781,12 +783,14 @@
   15.28    lazy_replace( x, l );
   15.29    set_idom(l, init_control, dom_depth(x));
   15.30  
   15.31 -  // Check for immediately preceding SafePoint and remove
   15.32 -  Node *sfpt2 = le->in(0);
   15.33 -  if (sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2)) {
   15.34 -    lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control));
   15.35 -    if (loop->_safepts != NULL) {
   15.36 -      loop->_safepts->yank(sfpt2);
   15.37 +  if (!UseCountedLoopSafepoints) {
   15.38 +    // Check for immediately preceding SafePoint and remove
   15.39 +    Node *sfpt2 = le->in(0);
   15.40 +    if (sfpt2->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt2)) {
   15.41 +      lazy_replace( sfpt2, sfpt2->in(TypeFunc::Control));
   15.42 +      if (loop->_safepts != NULL) {
   15.43 +        loop->_safepts->yank(sfpt2);
   15.44 +      }
   15.45      }
   15.46    }
   15.47  
   15.48 @@ -1806,6 +1810,37 @@
   15.49    }
   15.50  }
   15.51  
   15.52 +void IdealLoopTree::remove_safepoints(PhaseIdealLoop* phase, bool keep_one) {
   15.53 +  Node* keep = NULL;
   15.54 +  if (keep_one) {
   15.55 +    // Look for a safepoint on the idom-path.
   15.56 +    for (Node* i = tail(); i != _head; i = phase->idom(i)) {
   15.57 +      if (i->Opcode() == Op_SafePoint && phase->get_loop(i) == this) {
   15.58 +        keep = i;
   15.59 +        break; // Found one
   15.60 +      }
   15.61 +    }
   15.62 +  }
   15.63 +
   15.64 +  // Don't remove any safepoints if it is requested to keep a single safepoint and
   15.65 +  // no safepoint was found on idom-path. It is not safe to remove any safepoint
   15.66 +  // in this case since there's no safepoint dominating all paths in the loop body.
   15.67 +  bool prune = !keep_one || keep != NULL;
   15.68 +
   15.69 +  // Delete other safepoints in this loop.
   15.70 +  Node_List* sfpts = _safepts;
   15.71 +  if (prune && sfpts != NULL) {
   15.72 +    assert(keep == NULL || keep->Opcode() == Op_SafePoint, "not safepoint");
   15.73 +    for (uint i = 0; i < sfpts->size(); i++) {
   15.74 +      Node* n = sfpts->at(i);
   15.75 +      assert(phase->get_loop(n) == this, "");
   15.76 +      if (n != keep && phase->is_deleteable_safept(n)) {
   15.77 +        phase->lazy_replace(n, n->in(TypeFunc::Control));
   15.78 +      }
   15.79 +    }
   15.80 +  }
   15.81 +}
   15.82 +
   15.83  //------------------------------counted_loop-----------------------------------
   15.84  // Convert to counted loops where possible
   15.85  void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
   15.86 @@ -1817,42 +1852,23 @@
   15.87  
   15.88    if (_head->is_CountedLoop() ||
   15.89        phase->is_counted_loop(_head, this)) {
   15.90 -    _has_sfpt = 1;              // Indicate we do not need a safepoint here
   15.91 -
   15.92 -    // Look for safepoints to remove.
   15.93 -    Node_List* sfpts = _safepts;
   15.94 -    if (sfpts != NULL) {
   15.95 -      for (uint i = 0; i < sfpts->size(); i++) {
   15.96 -        Node* n = sfpts->at(i);
   15.97 -        assert(phase->get_loop(n) == this, "");
   15.98 -        if (phase->is_deleteable_safept(n)) {
   15.99 -          phase->lazy_replace(n, n->in(TypeFunc::Control));
  15.100 -        }
  15.101 -      }
  15.102 +
  15.103 +    if (!UseCountedLoopSafepoints) {
  15.104 +      // Indicate we do not need a safepoint here
  15.105 +      _has_sfpt = 1;
  15.106      }
  15.107  
  15.108 +    // Remove safepoints
  15.109 +    bool keep_one_sfpt = !(_has_call || _has_sfpt);
  15.110 +    remove_safepoints(phase, keep_one_sfpt);
  15.111 +
  15.112      // Look for induction variables
  15.113      phase->replace_parallel_iv(this);
  15.114  
  15.115    } else if (_parent != NULL && !_irreducible) {
  15.116 -    // Not a counted loop.
  15.117 -    // Look for a safepoint on the idom-path.
  15.118 -    Node* sfpt = tail();
  15.119 -    for (; sfpt != _head; sfpt = phase->idom(sfpt)) {
  15.120 -      if (sfpt->Opcode() == Op_SafePoint && phase->get_loop(sfpt) == this)
  15.121 -        break; // Found one
  15.122 -    }
  15.123 -    // Delete other safepoints in this loop.
  15.124 -    Node_List* sfpts = _safepts;
  15.125 -    if (sfpts != NULL && sfpt != _head && sfpt->Opcode() == Op_SafePoint) {
  15.126 -      for (uint i = 0; i < sfpts->size(); i++) {
  15.127 -        Node* n = sfpts->at(i);
  15.128 -        assert(phase->get_loop(n) == this, "");
  15.129 -        if (n != sfpt && phase->is_deleteable_safept(n)) {
  15.130 -          phase->lazy_replace(n, n->in(TypeFunc::Control));
  15.131 -        }
  15.132 -      }
  15.133 -    }
  15.134 +    // Not a counted loop. Keep one safepoint.
  15.135 +    bool keep_one_sfpt = true;
  15.136 +    remove_safepoints(phase, keep_one_sfpt);
  15.137    }
  15.138  
  15.139    // Recursively
  15.140 @@ -1906,6 +1922,15 @@
  15.141      if (cl->is_main_loop()) tty->print(" main");
  15.142      if (cl->is_post_loop()) tty->print(" post");
  15.143    }
  15.144 +  if (_has_call) tty->print(" has_call");
  15.145 +  if (_has_sfpt) tty->print(" has_sfpt");
  15.146 +  if (_rce_candidate) tty->print(" rce");
  15.147 +  if (_safepts != NULL && _safepts->size() > 0) {
  15.148 +    tty->print(" sfpts={"); _safepts->dump_simple(); tty->print(" }");
  15.149 +  }
  15.150 +  if (_required_safept != NULL && _required_safept->size() > 0) {
  15.151 +    tty->print(" req={"); _required_safept->dump_simple(); tty->print(" }");
  15.152 +  }
  15.153    tty->cr();
  15.154  }
  15.155  
    16.1 --- a/src/share/vm/opto/loopnode.hpp	Tue Dec 15 22:59:18 2015 -0800
    16.2 +++ b/src/share/vm/opto/loopnode.hpp	Tue Jan 05 08:28:01 2016 -0800
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
    16.6 + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
   16.10 @@ -403,6 +403,9 @@
   16.11    // encountered.
   16.12    void allpaths_check_safepts(VectorSet &visited, Node_List &stack);
   16.13  
   16.14 +  // Remove safepoints from loop. Optionally keeping one.
   16.15 +  void remove_safepoints(PhaseIdealLoop* phase, bool keep_one);
   16.16 +
   16.17    // Convert to counted loops where possible
   16.18    void counted_loop( PhaseIdealLoop *phase );
   16.19  
    17.1 --- a/src/share/vm/opto/node.cpp	Tue Dec 15 22:59:18 2015 -0800
    17.2 +++ b/src/share/vm/opto/node.cpp	Tue Jan 05 08:28:01 2016 -0800
    17.3 @@ -325,6 +325,9 @@
    17.4  // Create a Node, with a given number of required edges.
    17.5  Node::Node(uint req)
    17.6    : _idx(IDX_INIT(req))
    17.7 +#ifdef ASSERT
    17.8 +  , _parse_idx(_idx)
    17.9 +#endif
   17.10  {
   17.11    assert( req < Compile::current()->max_node_limit() - NodeLimitFudgeFactor, "Input limit exceeded" );
   17.12    debug_only( verify_construction() );
   17.13 @@ -344,6 +347,9 @@
   17.14  //------------------------------Node-------------------------------------------
   17.15  Node::Node(Node *n0)
   17.16    : _idx(IDX_INIT(1))
   17.17 +#ifdef ASSERT
   17.18 +  , _parse_idx(_idx)
   17.19 +#endif
   17.20  {
   17.21    debug_only( verify_construction() );
   17.22    NOT_PRODUCT(nodes_created++);
   17.23 @@ -356,6 +362,9 @@
   17.24  //------------------------------Node-------------------------------------------
   17.25  Node::Node(Node *n0, Node *n1)
   17.26    : _idx(IDX_INIT(2))
   17.27 +#ifdef ASSERT
   17.28 +  , _parse_idx(_idx)
   17.29 +#endif
   17.30  {
   17.31    debug_only( verify_construction() );
   17.32    NOT_PRODUCT(nodes_created++);
   17.33 @@ -370,6 +379,9 @@
   17.34  //------------------------------Node-------------------------------------------
   17.35  Node::Node(Node *n0, Node *n1, Node *n2)
   17.36    : _idx(IDX_INIT(3))
   17.37 +#ifdef ASSERT
   17.38 +  , _parse_idx(_idx)
   17.39 +#endif
   17.40  {
   17.41    debug_only( verify_construction() );
   17.42    NOT_PRODUCT(nodes_created++);
   17.43 @@ -386,6 +398,9 @@
   17.44  //------------------------------Node-------------------------------------------
   17.45  Node::Node(Node *n0, Node *n1, Node *n2, Node *n3)
   17.46    : _idx(IDX_INIT(4))
   17.47 +#ifdef ASSERT
   17.48 +  , _parse_idx(_idx)
   17.49 +#endif
   17.50  {
   17.51    debug_only( verify_construction() );
   17.52    NOT_PRODUCT(nodes_created++);
   17.53 @@ -404,6 +419,9 @@
   17.54  //------------------------------Node-------------------------------------------
   17.55  Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4)
   17.56    : _idx(IDX_INIT(5))
   17.57 +#ifdef ASSERT
   17.58 +  , _parse_idx(_idx)
   17.59 +#endif
   17.60  {
   17.61    debug_only( verify_construction() );
   17.62    NOT_PRODUCT(nodes_created++);
   17.63 @@ -425,6 +443,9 @@
   17.64  Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
   17.65                       Node *n4, Node *n5)
   17.66    : _idx(IDX_INIT(6))
   17.67 +#ifdef ASSERT
   17.68 +  , _parse_idx(_idx)
   17.69 +#endif
   17.70  {
   17.71    debug_only( verify_construction() );
   17.72    NOT_PRODUCT(nodes_created++);
   17.73 @@ -448,6 +469,9 @@
   17.74  Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
   17.75                       Node *n4, Node *n5, Node *n6)
   17.76    : _idx(IDX_INIT(7))
   17.77 +#ifdef ASSERT
   17.78 +  , _parse_idx(_idx)
   17.79 +#endif
   17.80  {
   17.81    debug_only( verify_construction() );
   17.82    NOT_PRODUCT(nodes_created++);
   17.83 @@ -2083,6 +2107,17 @@
   17.84  #endif
   17.85  }
   17.86  
   17.87 +void Node_List::dump_simple() const {
   17.88 +#ifndef PRODUCT
   17.89 +  for( uint i = 0; i < _cnt; i++ )
   17.90 +    if( _nodes[i] ) {
   17.91 +      tty->print(" %d", _nodes[i]->_idx);
   17.92 +    } else {
   17.93 +      tty->print(" NULL");
   17.94 +    }
   17.95 +#endif
   17.96 +}
   17.97 +
   17.98  //=============================================================================
   17.99  //------------------------------remove-----------------------------------------
  17.100  void Unique_Node_List::remove( Node *n ) {
    18.1 --- a/src/share/vm/opto/node.hpp	Tue Dec 15 22:59:18 2015 -0800
    18.2 +++ b/src/share/vm/opto/node.hpp	Tue Jan 05 08:28:01 2016 -0800
    18.3 @@ -294,10 +294,16 @@
    18.4  
    18.5   public:
    18.6    // Each Node is assigned a unique small/dense number.  This number is used
    18.7 -  // to index into auxiliary arrays of data and bitvectors.
    18.8 -  // It is declared const to defend against inadvertant assignment,
    18.9 -  // since it is used by clients as a naked field.
   18.10 +  // to index into auxiliary arrays of data and bit vectors.
   18.11 +  // The field _idx is declared constant to defend against inadvertent assignments,
   18.12 +  // since it is used by clients as a naked field. However, the field's value can be
   18.13 +  // changed using the set_idx() method.
   18.14 +  //
   18.15 +  // The PhaseRenumberLive phase renumbers nodes based on liveness information.
   18.16 +  // Therefore, it updates the value of the _idx field. The parse-time _idx is
   18.17 +  // preserved in _parse_idx.
   18.18    const node_idx_t _idx;
   18.19 +  DEBUG_ONLY(const node_idx_t _parse_idx;)
   18.20  
   18.21    // Get the (read-only) number of input edges
   18.22    uint req() const { return _cnt; }
   18.23 @@ -1368,6 +1374,7 @@
   18.24    void clear() { _cnt = 0; Node_Array::clear(); } // retain storage
   18.25    uint size() const { return _cnt; }
   18.26    void dump() const;
   18.27 +  void dump_simple() const;
   18.28  };
   18.29  
   18.30  //------------------------------Unique_Node_List-------------------------------
    19.1 --- a/src/share/vm/opto/phase.cpp	Tue Dec 15 22:59:18 2015 -0800
    19.2 +++ b/src/share/vm/opto/phase.cpp	Tue Jan 05 08:28:01 2016 -0800
    19.3 @@ -67,6 +67,8 @@
    19.4  elapsedTimer   Phase::_t_iterGVN;
    19.5  elapsedTimer   Phase::_t_iterGVN2;
    19.6  elapsedTimer   Phase::_t_incrInline;
    19.7 +elapsedTimer   Phase::_t_renumberLive;
    19.8 +
    19.9  
   19.10  // Subtimers for _t_registerAllocation
   19.11  elapsedTimer   Phase::_t_ctorChaitin;
   19.12 @@ -115,13 +117,14 @@
   19.13      }
   19.14      tty->print_cr ("      iterGVN        : %3.3f sec", Phase::_t_iterGVN.seconds());
   19.15      tty->print_cr ("      incrInline     : %3.3f sec", Phase::_t_incrInline.seconds());
   19.16 +    tty->print_cr ("      renumberLive   : %3.3f sec", Phase::_t_renumberLive.seconds());
   19.17      tty->print_cr ("      idealLoop      : %3.3f sec", Phase::_t_idealLoop.seconds());
   19.18      tty->print_cr ("      idealLoopVerify: %3.3f sec", Phase::_t_idealLoopVerify.seconds());
   19.19      tty->print_cr ("      ccp            : %3.3f sec", Phase::_t_ccp.seconds());
   19.20      tty->print_cr ("      iterGVN2       : %3.3f sec", Phase::_t_iterGVN2.seconds());
   19.21      tty->print_cr ("      macroExpand    : %3.3f sec", Phase::_t_macroExpand.seconds());
   19.22      tty->print_cr ("      graphReshape   : %3.3f sec", Phase::_t_graphReshaping.seconds());
   19.23 -    double optimizer_subtotal = Phase::_t_iterGVN.seconds() + Phase::_t_iterGVN2.seconds() +
   19.24 +    double optimizer_subtotal = Phase::_t_iterGVN.seconds() + Phase::_t_iterGVN2.seconds() + Phase::_t_renumberLive.seconds() +
   19.25        Phase::_t_escapeAnalysis.seconds() + Phase::_t_macroEliminate.seconds() +
   19.26        Phase::_t_idealLoop.seconds() + Phase::_t_ccp.seconds() +
   19.27        Phase::_t_macroExpand.seconds() + Phase::_t_graphReshaping.seconds();
    20.1 --- a/src/share/vm/opto/phase.hpp	Tue Dec 15 22:59:18 2015 -0800
    20.2 +++ b/src/share/vm/opto/phase.hpp	Tue Jan 05 08:28:01 2016 -0800
    20.3 @@ -40,22 +40,23 @@
    20.4  class Phase : public StackObj {
    20.5  public:
    20.6    enum PhaseNumber {
    20.7 -    Compiler,                   // Top-level compiler phase
    20.8 -    Parser,                     // Parse bytecodes
    20.9 -    Remove_Useless,             // Remove useless nodes
   20.10 -    Optimistic,                 // Optimistic analysis phase
   20.11 -    GVN,                        // Pessimistic global value numbering phase
   20.12 -    Ins_Select,                 // Instruction selection phase
   20.13 -    CFG,                        // Build a CFG
   20.14 -    BlockLayout,                // Linear ordering of blocks
   20.15 -    Register_Allocation,        // Register allocation, duh
   20.16 -    LIVE,                       // Dragon-book LIVE range problem
   20.17 -    StringOpts,                 // StringBuilder related optimizations
   20.18 -    Interference_Graph,         // Building the IFG
   20.19 -    Coalesce,                   // Coalescing copies
   20.20 -    Ideal_Loop,                 // Find idealized trip-counted loops
   20.21 -    Macro_Expand,               // Expand macro nodes
   20.22 -    Peephole,                   // Apply peephole optimizations
   20.23 +    Compiler,                         // Top-level compiler phase
   20.24 +    Parser,                           // Parse bytecodes
   20.25 +    Remove_Useless,                   // Remove useless nodes
   20.26 +    Remove_Useless_And_Renumber_Live, // First, remove useless nodes from the graph. Then, renumber live nodes.
   20.27 +    Optimistic,                       // Optimistic analysis phase
   20.28 +    GVN,                              // Pessimistic global value numbering phase
   20.29 +    Ins_Select,                       // Instruction selection phase
   20.30 +    CFG,                              // Build a CFG
   20.31 +    BlockLayout,                      // Linear ordering of blocks
   20.32 +    Register_Allocation,              // Register allocation, duh
   20.33 +    LIVE,                             // Dragon-book LIVE range problem
   20.34 +    StringOpts,                       // StringBuilder related optimizations
   20.35 +    Interference_Graph,               // Building the IFG
   20.36 +    Coalesce,                         // Coalescing copies
   20.37 +    Ideal_Loop,                       // Find idealized trip-counted loops
   20.38 +    Macro_Expand,                     // Expand macro nodes
   20.39 +    Peephole,                         // Apply peephole optimizations
   20.40      last_phase
   20.41    };
   20.42  protected:
   20.43 @@ -102,6 +103,7 @@
   20.44    static elapsedTimer   _t_iterGVN;
   20.45    static elapsedTimer   _t_iterGVN2;
   20.46    static elapsedTimer   _t_incrInline;
   20.47 +  static elapsedTimer   _t_renumberLive;
   20.48  
   20.49  // Subtimers for _t_registerAllocation
   20.50    static elapsedTimer   _t_ctorChaitin;
    21.1 --- a/src/share/vm/opto/phaseX.cpp	Tue Dec 15 22:59:18 2015 -0800
    21.2 +++ b/src/share/vm/opto/phaseX.cpp	Tue Jan 05 08:28:01 2016 -0800
    21.3 @@ -398,7 +398,7 @@
    21.4  //=============================================================================
    21.5  //------------------------------PhaseRemoveUseless-----------------------------
    21.6  // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
    21.7 -PhaseRemoveUseless::PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ) : Phase(Remove_Useless),
    21.8 +PhaseRemoveUseless::PhaseRemoveUseless(PhaseGVN *gvn, Unique_Node_List *worklist, PhaseNumber phase_num) : Phase(phase_num),
    21.9    _useful(Thread::current()->resource_area()) {
   21.10  
   21.11    // Implementation requires 'UseLoopSafepoints == true' and an edge from root
   21.12 @@ -435,6 +435,82 @@
   21.13    }
   21.14  }
   21.15  
   21.16 +//=============================================================================
   21.17 +//------------------------------PhaseRenumberLive------------------------------
   21.18 +// First, remove useless nodes (equivalent to identifying live nodes).
   21.19 +// Then, renumber live nodes.
   21.20 +//
   21.21 +// The set of live nodes is returned by PhaseRemoveUseless in the _useful structure.
   21.22 +// If the number of live nodes is 'x' (where 'x' == _useful.size()), then the
   21.23 +// PhaseRenumberLive updates the node ID of each node (the _idx field) with a unique
   21.24 +// value in the range [0, x).
   21.25 +//
   21.26 +// At the end of the PhaseRenumberLive phase, the compiler's count of unique nodes is
   21.27 +// updated to 'x' and the list of dead nodes is reset (as there are no dead nodes).
   21.28 +//
   21.29 +// The PhaseRenumberLive phase updates two data structures with the new node IDs.
   21.30 +// (1) The worklist is used by the PhaseIterGVN phase to identify nodes that must be
   21.31 +// processed. A new worklist (with the updated node IDs) is returned in 'new_worklist'.
   21.32 +// (2) Type information (the field PhaseGVN::_types) maps type information to each
   21.33 +// node ID. The mapping is updated to use the new node IDs as well. Updated type
   21.34 +// information is returned in PhaseGVN::_types.
   21.35 +//
   21.36 +// The PhaseRenumberLive phase does not preserve the order of elements in the worklist.
   21.37 +//
   21.38 +// Other data structures used by the compiler are not updated. The hash table for value
   21.39 +// numbering (the field PhaseGVN::_table) is not updated because computing the hash
   21.40 +// values is not based on node IDs. The field PhaseGVN::_nodes is not updated either
   21.41 +// because it is empty wherever PhaseRenumberLive is used.
   21.42 +PhaseRenumberLive::PhaseRenumberLive(PhaseGVN* gvn,
   21.43 +                                     Unique_Node_List* worklist, Unique_Node_List* new_worklist,
   21.44 +                                     PhaseNumber phase_num) :
   21.45 +  PhaseRemoveUseless(gvn, worklist, Remove_Useless_And_Renumber_Live) {
   21.46 +
   21.47 +  assert(RenumberLiveNodes, "RenumberLiveNodes must be set to true for node renumbering to take place");
   21.48 +  assert(C->live_nodes() == _useful.size(), "the number of live nodes must match the number of useful nodes");
   21.49 +  assert(gvn->nodes_size() == 0, "GVN must not contain any nodes at this point");
   21.50 +
   21.51 +  uint old_unique_count = C->unique();
   21.52 +  uint live_node_count = C->live_nodes();
   21.53 +  uint worklist_size = worklist->size();
   21.54 +
   21.55 +  // Storage for the updated type information.
   21.56 +  Type_Array new_type_array(C->comp_arena());
   21.57 +
   21.58 +  // Iterate over the set of live nodes.
   21.59 +  uint current_idx = 0; // The current new node ID. Incremented after every assignment.
   21.60 +  for (uint i = 0; i < _useful.size(); i++) {
   21.61 +    Node* n = _useful.at(i);
   21.62 +    const Type* type = gvn->type_or_null(n);
   21.63 +    new_type_array.map(current_idx, type);
   21.64 +
   21.65 +    bool in_worklist = false;
   21.66 +    if (worklist->member(n)) {
   21.67 +      in_worklist = true;
   21.68 +    }
   21.69 +
   21.70 +    n->set_idx(current_idx); // Update node ID.
   21.71 +
   21.72 +    if (in_worklist) {
   21.73 +      new_worklist->push(n);
   21.74 +    }
   21.75 +
   21.76 +    current_idx++;
   21.77 +  }
   21.78 +
   21.79 +  assert(worklist_size == new_worklist->size(), "the new worklist must have the same size as the original worklist");
   21.80 +  assert(live_node_count == current_idx, "all live nodes must be processed");
   21.81 +
   21.82 +  // Replace the compiler's type information with the updated type information.
   21.83 +  gvn->replace_types(new_type_array);
   21.84 +
   21.85 +  // Update the unique node count of the compilation to the number of currently live nodes.
   21.86 +  C->set_unique(live_node_count);
   21.87 +
   21.88 +  // Set the dead node count to 0 and reset dead node list.
   21.89 +  C->reset_dead_node_list();
   21.90 +}
   21.91 +
   21.92  
   21.93  //=============================================================================
   21.94  //------------------------------PhaseTransform---------------------------------
    22.1 --- a/src/share/vm/opto/phaseX.hpp	Tue Dec 15 22:59:18 2015 -0800
    22.2 +++ b/src/share/vm/opto/phaseX.hpp	Tue Jan 05 08:28:01 2016 -0800
    22.3 @@ -148,11 +148,21 @@
    22.4    Unique_Node_List _useful;   // Nodes reachable from root
    22.5                                // list is allocated from current resource area
    22.6  public:
    22.7 -  PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist );
    22.8 +  PhaseRemoveUseless(PhaseGVN *gvn, Unique_Node_List *worklist, PhaseNumber phase_num = Remove_Useless);
    22.9  
   22.10    Unique_Node_List *get_useful() { return &_useful; }
   22.11  };
   22.12  
   22.13 +//------------------------------PhaseRenumber----------------------------------
   22.14 +// Phase that first performs a PhaseRemoveUseless, then it renumbers compiler
   22.15 +// structures accordingly.
   22.16 +class PhaseRenumberLive : public PhaseRemoveUseless {
   22.17 +public:
   22.18 +  PhaseRenumberLive(PhaseGVN* gvn,
   22.19 +                    Unique_Node_List* worklist, Unique_Node_List* new_worklist,
   22.20 +                    PhaseNumber phase_num = Remove_Useless_And_Renumber_Live);
   22.21 +};
   22.22 +
   22.23  
   22.24  //------------------------------PhaseTransform---------------------------------
   22.25  // Phases that analyze, then transform.  Constructing the Phase object does any
   22.26 @@ -162,7 +172,7 @@
   22.27  class PhaseTransform : public Phase {
   22.28  protected:
   22.29    Arena*     _arena;
   22.30 -  Node_Array _nodes;           // Map old node indices to new nodes.
   22.31 +  Node_List  _nodes;           // Map old node indices to new nodes.
   22.32    Type_Array _types;           // Map old node indices to Types.
   22.33  
   22.34    // ConNode caches:
   22.35 @@ -187,7 +197,13 @@
   22.36  
   22.37    Arena*      arena()   { return _arena; }
   22.38    Type_Array& types()   { return _types; }
   22.39 +  void replace_types(Type_Array new_types) {
   22.40 +    _types = new_types;
   22.41 +  }
   22.42    // _nodes is used in varying ways by subclasses, which define local accessors
   22.43 +  uint nodes_size() {
   22.44 +    return _nodes.size();
   22.45 +  }
   22.46  
   22.47  public:
   22.48    // Get a previously recorded type for the node n.
    23.1 --- a/src/share/vm/prims/whitebox.cpp	Tue Dec 15 22:59:18 2015 -0800
    23.2 +++ b/src/share/vm/prims/whitebox.cpp	Tue Jan 05 08:28:01 2016 -0800
    23.3 @@ -45,6 +45,7 @@
    23.4  #if INCLUDE_ALL_GCS
    23.5  #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
    23.6  #include "gc_implementation/g1/concurrentMark.hpp"
    23.7 +#include "gc_implementation/g1/concurrentMarkThread.hpp"
    23.8  #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
    23.9  #include "gc_implementation/g1/heapRegionRemSet.hpp"
   23.10  #endif // INCLUDE_ALL_GCS
   23.11 @@ -323,8 +324,16 @@
   23.12  
   23.13  WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
   23.14    G1CollectedHeap* g1 = G1CollectedHeap::heap();
   23.15 -  ConcurrentMark* cm = g1->concurrent_mark();
   23.16 -  return cm->concurrent_marking_in_progress();
   23.17 +  return g1->concurrent_mark()->cmThread()->during_cycle();
   23.18 +WB_END
   23.19 +
   23.20 +WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
   23.21 +  G1CollectedHeap* g1h = G1CollectedHeap::heap();
   23.22 +  if (!g1h->concurrent_mark()->cmThread()->during_cycle()) {
   23.23 +    g1h->collect(GCCause::_wb_conc_mark);
   23.24 +    return true;
   23.25 +  }
   23.26 +  return false;
   23.27  WB_END
   23.28  
   23.29  WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
   23.30 @@ -1031,6 +1040,7 @@
   23.31    {CC"g1NumMaxRegions",    CC"()J",                   (void*)&WB_G1NumMaxRegions  },
   23.32    {CC"g1NumFreeRegions",   CC"()J",                   (void*)&WB_G1NumFreeRegions  },
   23.33    {CC"g1RegionSize",       CC"()I",                   (void*)&WB_G1RegionSize      },
   23.34 +  {CC"g1StartConcMarkCycle",       CC"()Z",           (void*)&WB_G1StartMarkCycle  },
   23.35    {CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
   23.36                                                        (void*)&WB_G1AuxiliaryMemoryUsage  },
   23.37  #endif // INCLUDE_ALL_GCS
    24.1 --- a/src/share/vm/runtime/safepoint.cpp	Tue Dec 15 22:59:18 2015 -0800
    24.2 +++ b/src/share/vm/runtime/safepoint.cpp	Tue Jan 05 08:28:01 2016 -0800
    24.3 @@ -1,5 +1,5 @@
    24.4  /*
    24.5 - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
    24.6 + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
    24.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.8   *
    24.9   * This code is free software; you can redistribute it and/or modify it
   24.10 @@ -739,80 +739,12 @@
   24.11  // ------------------------------------------------------------------------------------------------------
   24.12  // Exception handlers
   24.13  
   24.14 -#ifndef PRODUCT
   24.15 -
   24.16 -#ifdef SPARC
   24.17 -
   24.18 -#ifdef _LP64
   24.19 -#define PTR_PAD ""
   24.20 -#else
   24.21 -#define PTR_PAD "        "
   24.22 -#endif
   24.23 -
   24.24 -static void print_ptrs(intptr_t oldptr, intptr_t newptr, bool wasoop) {
   24.25 -  bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false;
   24.26 -  tty->print_cr(PTR_FORMAT PTR_PAD " %s %c " PTR_FORMAT PTR_PAD " %s %s",
   24.27 -                oldptr, wasoop?"oop":"   ", oldptr == newptr ? ' ' : '!',
   24.28 -                newptr, is_oop?"oop":"   ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":"     "));
   24.29 -}
   24.30 -
   24.31 -static void print_longs(jlong oldptr, jlong newptr, bool wasoop) {
   24.32 -  bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false;
   24.33 -  tty->print_cr(PTR64_FORMAT " %s %c " PTR64_FORMAT " %s %s",
   24.34 -                oldptr, wasoop?"oop":"   ", oldptr == newptr ? ' ' : '!',
   24.35 -                newptr, is_oop?"oop":"   ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":"     "));
   24.36 -}
   24.37 -
   24.38 -static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) {
   24.39 -#ifdef _LP64
   24.40 -  tty->print_cr("--------+------address-----+------before-----------+-------after----------+");
   24.41 -  const int incr = 1;           // Increment to skip a long, in units of intptr_t
   24.42 -#else
   24.43 -  tty->print_cr("--------+--address-+------before-----------+-------after----------+");
   24.44 -  const int incr = 2;           // Increment to skip a long, in units of intptr_t
   24.45 -#endif
   24.46 -  tty->print_cr("---SP---|");
   24.47 -  for( int i=0; i<16; i++ ) {
   24.48 -    tty->print("blob %c%d |"PTR_FORMAT" ","LO"[i>>3],i&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
   24.49 -  tty->print_cr("--------|");
   24.50 -  for( int i1=0; i1<frame::memory_parameter_word_sp_offset-16; i1++ ) {
   24.51 -    tty->print("argv pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
   24.52 -  tty->print("     pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++);
   24.53 -  tty->print_cr("--------|");
   24.54 -  tty->print(" G1     |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
   24.55 -  tty->print(" G3     |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
   24.56 -  tty->print(" G4     |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
   24.57 -  tty->print(" G5     |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
   24.58 -  tty->print_cr(" FSR    |"PTR_FORMAT" "PTR64_FORMAT"       "PTR64_FORMAT,new_sp,*(jlong*)old_sp,*(jlong*)new_sp);
   24.59 -  old_sp += incr; new_sp += incr; was_oops += incr;
   24.60 -  // Skip the floats
   24.61 -  tty->print_cr("--Float-|"PTR_FORMAT,new_sp);
   24.62 -  tty->print_cr("---FP---|");
   24.63 -  old_sp += incr*32;  new_sp += incr*32;  was_oops += incr*32;
   24.64 -  for( int i2=0; i2<16; i2++ ) {
   24.65 -    tty->print("call %c%d |"PTR_FORMAT" ","LI"[i2>>3],i2&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
   24.66 -  tty->cr();
   24.67 -}
   24.68 -#endif  // SPARC
   24.69 -#endif  // PRODUCT
   24.70 -
   24.71  
   24.72  void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
   24.73    assert(thread->is_Java_thread(), "polling reference encountered by VM thread");
   24.74    assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
   24.75    assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
   24.76  
   24.77 -  // Uncomment this to get some serious before/after printing of the
   24.78 -  // Sparc safepoint-blob frame structure.
   24.79 -  /*
   24.80 -  intptr_t* sp = thread->last_Java_sp();
   24.81 -  intptr_t stack_copy[150];
   24.82 -  for( int i=0; i<150; i++ ) stack_copy[i] = sp[i];
   24.83 -  bool was_oops[150];
   24.84 -  for( int i=0; i<150; i++ )
   24.85 -    was_oops[i] = stack_copy[i] ? ((oop)stack_copy[i])->is_oop() : false;
   24.86 -  */
   24.87 -
   24.88    if (ShowSafepointMsgs) {
   24.89      tty->print("handle_polling_page_exception: ");
   24.90    }
   24.91 @@ -824,7 +756,6 @@
   24.92    ThreadSafepointState* state = thread->safepoint_state();
   24.93  
   24.94    state->handle_polling_page_exception();
   24.95 -  // print_me(sp,stack_copy,was_oops);
   24.96  }
   24.97  
   24.98  
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/compiler/loopopts/UseCountedLoopSafepoints.java	Tue Jan 05 08:28:01 2016 -0800
    25.3 @@ -0,0 +1,67 @@
    25.4 +/*
    25.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + *
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + *
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + *
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + *
   25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 + * or visit www.oracle.com if you need additional information or have any
   25.24 + * questions.
   25.25 + *
   25.26 + */
   25.27 +
   25.28 +/**
   25.29 + * @test
   25.30 + * @bug 6869327
   25.31 + * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop
   25.32 + * @library /testlibrary
   25.33 + * @run main UseCountedLoopSafepoints
   25.34 + */
   25.35 +
   25.36 +import java.util.concurrent.atomic.AtomicLong;
   25.37 +import com.oracle.java.testlibrary.ProcessTools;
   25.38 +import com.oracle.java.testlibrary.OutputAnalyzer;
   25.39 +
   25.40 +public class UseCountedLoopSafepoints {
   25.41 +    private static final AtomicLong _num = new AtomicLong(0);
   25.42 +
   25.43 +    // Uses the fact that an EnableBiasedLocking vmop will be started
   25.44 +    // after 500ms, while we are still in the loop. If there is a
   25.45 +    // safepoint in the counted loop, then we will reach safepoint
   25.46 +    // very quickly. Otherwise SafepointTimeout will be hit.
   25.47 +    public static void main (String args[]) throws Exception {
   25.48 +        if (args.length == 1) {
   25.49 +            final int loops = Integer.parseInt(args[0]);
   25.50 +            for (int i = 0; i < loops; i++) {
   25.51 +                _num.addAndGet(1);
   25.52 +            }
   25.53 +        } else {
   25.54 +            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
   25.55 +                    "-XX:+IgnoreUnrecognizedVMOptions",
   25.56 +                    "-XX:-TieredCompilation",
   25.57 +                    "-XX:+UseBiasedLocking",
   25.58 +                    "-XX:BiasedLockingStartupDelay=500",
   25.59 +                    "-XX:+SafepointTimeout",
   25.60 +                    "-XX:SafepointTimeoutDelay=2000",
   25.61 +                    "-XX:+UseCountedLoopSafepoints",
   25.62 +                    "UseCountedLoopSafepoints",
   25.63 +                    "2000000000"
   25.64 +                    );
   25.65 +            OutputAnalyzer output = new OutputAnalyzer(pb.start());
   25.66 +            output.shouldNotContain("Timeout detected");
   25.67 +            output.shouldHaveExitValue(0);
   25.68 +        }
   25.69 +    }
   25.70 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/gc/whitebox/TestConcMarkCycleWB.java	Tue Jan 05 08:28:01 2016 -0800
    26.3 @@ -0,0 +1,57 @@
    26.4 +/*
    26.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + *
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.
   26.11 + *
   26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 + * version 2 for more details (a copy is included in the LICENSE file that
   26.16 + * accompanied this code).
   26.17 + *
   26.18 + * You should have received a copy of the GNU General Public License version
   26.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 + *
   26.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 + * or visit www.oracle.com if you need additional information or have any
   26.24 + * questions.
   26.25 + */
   26.26 +
   26.27 +/*
   26.28 + * @test TestConMarkCycleWB
   26.29 + * @bug 8065579
   26.30 + * @requires vm.gc=="null" | vm.gc=="G1"
   26.31 + * @library /testlibrary /testlibrary/whitebox
   26.32 + * @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.WhiteBox TestConcMarkCycleWB
   26.33 + * @run main ClassFileInstaller sun.hotspot.WhiteBox
   26.34 + *                              sun.hotspot.WhiteBox$WhiteBoxPermission
   26.35 + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC TestConcMarkCycleWB
   26.36 + * @summary Verifies that ConcurrentMarking-related WB works properly
   26.37 + */
   26.38 +import static com.oracle.java.testlibrary.Asserts.assertFalse;
   26.39 +import static com.oracle.java.testlibrary.Asserts.assertTrue;
   26.40 +import sun.hotspot.WhiteBox;
   26.41 +
   26.42 +public class TestConcMarkCycleWB {
   26.43 +
   26.44 +    public static void main(String[] args) throws Exception {
   26.45 +        WhiteBox wb = WhiteBox.getWhiteBox();
   26.46 +
   26.47 +        wb.youngGC();
   26.48 +        assertTrue(wb.g1StartConcMarkCycle());
   26.49 +        while (wb.g1InConcurrentMark()) {
   26.50 +            Thread.sleep(5);
   26.51 +        }
   26.52 +
   26.53 +        wb.fullGC();
   26.54 +        assertTrue(wb.g1StartConcMarkCycle());
   26.55 +        while (wb.g1InConcurrentMark()) {
   26.56 +            Thread.sleep(5);
   26.57 +        }
   26.58 +        assertTrue(wb.g1StartConcMarkCycle());
   26.59 +    }
   26.60 +}
    27.1 --- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Tue Dec 15 22:59:18 2015 -0800
    27.2 +++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Tue Jan 05 08:28:01 2016 -0800
    27.3 @@ -174,12 +174,16 @@
    27.4    public native long incMetaspaceCapacityUntilGC(long increment);
    27.5    public native long metaspaceCapacityUntilGC();
    27.6  
    27.7 -  // force Young GC
    27.8 +  // Force Young GC
    27.9    public native void youngGC();
   27.10  
   27.11 -  // force Full GC
   27.12 +  // Force Full GC
   27.13    public native void fullGC();
   27.14  
   27.15 +  // Method tries to start concurrent mark cycle.
   27.16 +  // It returns false if CM Thread is always in concurrent cycle.
   27.17 +  public native boolean g1StartConcMarkCycle();
   27.18 +
   27.19    // Tests on ReservedSpace/VirtualSpace classes
   27.20    public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
   27.21    public native void runMemoryUnitTests();

mercurial