Merge
authorjwilhelm
Wed, 20 Dec 2017 20:55:07 +0100
changeset 48404 177e1783d886
parent 48380 597f69e5f1e3 (current diff)
parent 48403 6d4e1efac80a (diff)
child 48405 5f1c30b80554
Merge
src/hotspot/share/opto/library_call.cpp
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CooperativePhaseTest.java
--- a/.hgignore	Wed Dec 20 21:40:11 2017 +0100
+++ b/.hgignore	Wed Dec 20 20:55:07 2017 +0100
@@ -11,3 +11,5 @@
 test/nashorn/script/external
 test/nashorn/lib
 NashornProfile.txt
+.*/JTreport/.*
+.*/JTwork/.*
--- a/make/test/JtregNativeHotspot.gmk	Wed Dec 20 21:40:11 2017 +0100
+++ b/make/test/JtregNativeHotspot.gmk	Wed Dec 20 20:55:07 2017 +0100
@@ -113,6 +113,8 @@
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libHandshakeTransitionTest := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libHasNoEntryPoint := -lc
     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libReturnError := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libCNLookUp := -lc
+    BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libTestCheckedEnsureLocalCapacity := -lc
 endif
 
 ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/cpu/x86/macroAssembler_x86_pow.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -765,6 +765,11 @@
     0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL
 };
 
+ALIGNED_(8) juint _DOUBLE2[] =
+{
+    0x00000000UL, 0x40000000UL
+};
+
 //registers,
 // input: xmm0, xmm1
 // scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7
@@ -803,6 +808,7 @@
   address HIGHMASK_LOG_X = (address)_HIGHMASK_LOG_X;
   address HALFMASK = (address)_HALFMASK;
   address log2 = (address)_log2_pow;
+  address DOUBLE2 = (address)_DOUBLE2;
 
 
   bind(start);
@@ -810,6 +816,13 @@
   movsd(Address(rsp, 8), xmm0);
   movsd(Address(rsp, 16), xmm1);
 
+  // Special case: pow(x, 2.0) => x * x
+  movdq(tmp1, xmm1);
+  cmp64(tmp1, ExternalAddress(DOUBLE2));
+  jccb(Assembler::notEqual, B1_2);
+  mulsd(xmm0, xmm0);
+  jmp(B1_5);
+
   bind(B1_2);
   pextrw(eax, xmm0, 3);
   xorpd(xmm2, xmm2);
--- a/src/hotspot/share/classfile/classListParser.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/classfile/classListParser.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -315,12 +315,13 @@
   return k;
 }
 
-InstanceKlass* ClassListParser::load_current_class(TRAPS) {
+Klass* ClassListParser::load_current_class(TRAPS) {
   TempNewSymbol class_name_symbol = SymbolTable::new_symbol(_class_name, THREAD);
   guarantee(!HAS_PENDING_EXCEPTION, "Exception creating a symbol.");
 
-  InstanceKlass *klass = NULL;
+  Klass *klass = NULL;
   if (!is_loading_from_source()) {
+    // Load classes for the boot/platform/app loaders only.
     if (is_super_specified()) {
       error("If source location is not specified, super class must not be specified");
     }
@@ -330,40 +331,36 @@
 
     bool non_array = !FieldType::is_array(class_name_symbol);
 
-    Handle s = java_lang_String::create_from_symbol(class_name_symbol, CHECK_0);
-    // Translate to external class name format, i.e., convert '/' chars to '.'
-    Handle string = java_lang_String::externalize_classname(s, CHECK_0);
     JavaValue result(T_OBJECT);
-    InstanceKlass* spec_klass =  non_array ?
-      SystemDictionary::ClassLoader_klass() : SystemDictionary::Class_klass();
-    Symbol* method_name = non_array ?
-      vmSymbols::loadClass_name() : vmSymbols::forName_name();
-    Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+    if (non_array) {
+      // At this point, we are executing in the context of the boot loader. We
+      // cannot call Class.forName because that is context dependent and
+      // would load only classes for the boot loader.
+      //
+      // Instead, let's call java_system_loader().loadClass() directly, which will
+      // delegate to the correct loader (boot, platform or app) depending on
+      // the class name.
 
-    if (non_array) {
+      Handle s = java_lang_String::create_from_symbol(class_name_symbol, CHECK_0);
+      // ClassLoader.loadClass() wants external class name format, i.e., convert '/' chars to '.'
+      Handle ext_class_name = java_lang_String::externalize_classname(s, CHECK_0);
+      Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+
       JavaCalls::call_virtual(&result,
                               loader, //SystemDictionary::java_system_loader(),
-                              spec_klass,
-                              method_name, //vmSymbols::loadClass_name(),
+                              SystemDictionary::ClassLoader_klass(),
+                              vmSymbols::loadClass_name(),
                               vmSymbols::string_class_signature(),
-                              string,
+                              ext_class_name,
                               THREAD);
     } else {
-      JavaCalls::call_static(&result,
-                             spec_klass,
-                             method_name,
-                             vmSymbols::string_class_signature(),
-                             string,
-                             CHECK_NULL);
+      // array classes are not supported in class list.
+      THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
     }
     assert(result.get_type() == T_OBJECT, "just checking");
     oop obj = (oop) result.get_jobject();
     if (!HAS_PENDING_EXCEPTION && (obj != NULL)) {
-      if (non_array) {
-        klass = InstanceKlass::cast(java_lang_Class::as_Klass(obj));
-      } else {
-        klass = static_cast<InstanceKlass*>(java_lang_Class::array_klass_acquire(obj));
-      }
+      klass = java_lang_Class::as_Klass(obj);
     } else { // load classes in bootclasspath/a
       if (HAS_PENDING_EXCEPTION) {
         CLEAR_PENDING_EXCEPTION;
@@ -372,7 +369,7 @@
       if (non_array) {
         Klass* k = SystemDictionary::resolve_or_null(class_name_symbol, CHECK_NULL);
         if (k != NULL) {
-          klass = InstanceKlass::cast(k);
+          klass = k;
         } else {
           if (!HAS_PENDING_EXCEPTION) {
             THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
@@ -388,14 +385,15 @@
     }
   }
 
-  if (klass != NULL && is_id_specified()) {
+  if (klass != NULL && klass->is_instance_klass() && is_id_specified()) {
+    InstanceKlass* ik = InstanceKlass::cast(klass);
     int id = this->id();
-    SystemDictionaryShared::update_shared_entry(klass, id);
+    SystemDictionaryShared::update_shared_entry(ik, id);
     InstanceKlass* old = table()->lookup(id);
-    if (old != NULL && old != klass) {
+    if (old != NULL && old != ik) {
       error("Duplicated ID %d for class %s", id, _class_name);
     }
-    table()->add(id, klass);
+    table()->add(id, ik);
   }
 
   return klass;
--- a/src/hotspot/share/classfile/classListParser.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/classfile/classListParser.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -136,7 +136,7 @@
     return _class_name;
   }
 
-  InstanceKlass* load_current_class(TRAPS);
+  Klass* load_current_class(TRAPS);
 
   bool is_loading_from_source();
 
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -574,9 +574,9 @@
     ls.cr();
   }
 
-  // In some rare cases items added to this list will not be freed elsewhere.
-  // To keep it simple, just free everything in it here.
-  free_deallocate_list();
+  // Some items on the _deallocate_list need to free their C heap structures
+  // if they are not already on the _klasses list.
+  unload_deallocate_list();
 
   // Clean up global class iterator for compiler
   static_klass_iterator.adjust_saved_class(this);
@@ -755,6 +755,7 @@
 }
 
 void ClassLoaderData::remove_handle(OopHandle h) {
+  assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading");
   oop* ptr = h.ptr_raw();
   if (ptr != NULL) {
     assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
@@ -799,6 +800,7 @@
 void ClassLoaderData::free_deallocate_list() {
   // Don't need lock, at safepoint
   assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
+  assert(!is_unloading(), "only called for ClassLoaderData that are not unloading");
   if (_deallocate_list == NULL) {
     return;
   }
@@ -828,6 +830,29 @@
   }
 }
 
+// This is distinct from free_deallocate_list.  For class loader data that are
+// unloading, this frees the C heap memory for constant pools on the list.  If there
+// were C heap memory allocated for methods, it would free that too.  The C heap memory
+// for InstanceKlasses on this list is freed in the ClassLoaderData destructor.
+void ClassLoaderData::unload_deallocate_list() {
+  // Don't need lock, at safepoint
+  assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
+  assert(is_unloading(), "only called for ClassLoaderData that are unloading");
+  if (_deallocate_list == NULL) {
+    return;
+  }
+  // Go backwards because this removes entries that are freed.
+  for (int i = _deallocate_list->length() - 1; i >= 0; i--) {
+    Metadata* m = _deallocate_list->at(i);
+    assert (!m->on_stack(), "wouldn't be unloading if this were so");
+    _deallocate_list->remove_at(i);
+    // Only constant pool entries have C heap memory to free.
+    if (m->is_constantPool()) {
+      ((ConstantPool*)m)->release_C_heap_structures();
+    }
+  }
+}
+
 // These anonymous class loaders are to contain classes used for JSR292
 ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(oop loader, TRAPS) {
   // Add a new class loader data to the graph.
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -307,7 +307,8 @@
   void packages_do(void f(PackageEntry*));
 
   // Deallocate free list during class unloading.
-  void free_deallocate_list();
+  void free_deallocate_list();      // for the classes that are not unloaded
+  void unload_deallocate_list();    // for the classes that are unloaded
 
   // Allocate out of this class loader data
   MetaWord* allocate(size_t size);
--- a/src/hotspot/share/compiler/compileBroker.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/compiler/compileBroker.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -1852,17 +1852,23 @@
     TraceTime t1("compilation", &time);
     EventCompilation event;
 
-    JVMCIEnv env(task, system_dictionary_modification_counter);
-    methodHandle method(thread, target_handle);
-    jvmci->compile_method(method, osr_bci, &env);
-
-    post_compile(thread, task, event, task->code() != NULL, NULL);
+    // Skip redefined methods
+    if (target_handle->is_old()) {
+        failure_reason = "redefined method";
+        retry_message = "not retryable";
+        compilable = ciEnv::MethodCompilable_never;
+    } else {
+        JVMCIEnv env(task, system_dictionary_modification_counter);
+        methodHandle method(thread, target_handle);
+        jvmci->compile_method(method, osr_bci, &env);
 
-    failure_reason = env.failure_reason();
-    if (!env.retryable()) {
-      retry_message = "not retryable";
-      compilable = ciEnv::MethodCompilable_not_at_tier;
+        failure_reason = env.failure_reason();
+        if (!env.retryable()) {
+          retry_message = "not retryable";
+          compilable = ciEnv::MethodCompilable_not_at_tier;
+        }
     }
+    post_compile(thread, task, event, task->code() != NULL, NULL);
 
   } else
 #endif // INCLUDE_JVMCI
--- a/src/hotspot/share/gc/g1/g1AllocRegion.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/gc/g1/g1AllocRegion.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,17 +42,17 @@
 
   // Make sure that any allocation attempt on this region will fail
   // and will not trigger any asserts.
-  assert(allocate(dummy_region, 1, false) == NULL, "should fail");
-  assert(par_allocate(dummy_region, 1, false) == NULL, "should fail");
-  assert(allocate(dummy_region, 1, true) == NULL, "should fail");
-  assert(par_allocate(dummy_region, 1, true) == NULL, "should fail");
+  assert(dummy_region->allocate_no_bot_updates(1) == NULL, "should fail");
+  assert(dummy_region->allocate(1) == NULL, "should fail");
+  DEBUG_ONLY(size_t assert_tmp);
+  assert(dummy_region->par_allocate_no_bot_updates(1, 1, &assert_tmp) == NULL, "should fail");
+  assert(dummy_region->par_allocate(1, 1, &assert_tmp) == NULL, "should fail");
 
   _g1h = g1h;
   _dummy_region = dummy_region;
 }
 
-size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region,
-                                              bool bot_updates) {
+size_t G1AllocRegion::fill_up_remaining_space(HeapRegion* alloc_region) {
   assert(alloc_region != NULL && alloc_region != _dummy_region,
          "pre-condition");
   size_t result = 0;
@@ -74,7 +74,7 @@
   size_t min_word_size_to_fill = CollectedHeap::min_fill_size();
 
   while (free_word_size >= min_word_size_to_fill) {
-    HeapWord* dummy = par_allocate(alloc_region, free_word_size, bot_updates);
+    HeapWord* dummy = par_allocate(alloc_region, free_word_size);
     if (dummy != NULL) {
       // If the allocation was successful we should fill in the space.
       CollectedHeap::fill_with_object(dummy, free_word_size);
@@ -110,7 +110,7 @@
                            "the alloc region should never be empty");
 
     if (fill_up) {
-      result = fill_up_remaining_space(alloc_region, _bot_updates);
+      result = fill_up_remaining_space(alloc_region);
     }
 
     assert_alloc_region(alloc_region->used() >= _used_bytes_before, "invariant");
@@ -135,7 +135,7 @@
     new_alloc_region->reset_pre_dummy_top();
     // Need to do this before the allocation
     _used_bytes_before = new_alloc_region->used();
-    HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates);
+    HeapWord* result = allocate(new_alloc_region, word_size);
     assert_alloc_region(result != NULL, "the allocation should succeeded");
 
     OrderAccess::storestore();
@@ -301,7 +301,7 @@
       // possible object. In this case this region will not be retained, so the
       // original problem cannot occur.
       if (to_allocate_words >= G1CollectedHeap::min_fill_size()) {
-        HeapWord* dummy = attempt_allocation(to_allocate_words, true /* bot_updates */);
+        HeapWord* dummy = attempt_allocation(to_allocate_words);
         CollectedHeap::fill_with_object(dummy, to_allocate_words);
       }
     }
--- a/src/hotspot/share/gc/g1/g1AllocRegion.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/gc/g1/g1AllocRegion.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,37 +83,27 @@
   // whether the _alloc_region is NULL or not.
   static HeapRegion* _dummy_region;
 
-  // Some of the methods below take a bot_updates parameter. Its value
-  // should be the same as the _bot_updates field. The idea is that
-  // the parameter will be a constant for a particular alloc region
-  // and, given that these methods will be hopefully inlined, the
-  // compiler should compile out the test.
-
   // Perform a non-MT-safe allocation out of the given region.
-  static inline HeapWord* allocate(HeapRegion* alloc_region,
-                                   size_t word_size,
-                                   bool bot_updates);
+  inline HeapWord* allocate(HeapRegion* alloc_region,
+                            size_t word_size);
 
   // Perform a MT-safe allocation out of the given region.
-  static inline HeapWord* par_allocate(HeapRegion* alloc_region,
-                                       size_t word_size,
-                                       bool bot_updates);
+  inline HeapWord* par_allocate(HeapRegion* alloc_region,
+                                size_t word_size);
   // Perform a MT-safe allocation out of the given region, with the given
   // minimum and desired size. Returns the actual size allocated (between
   // minimum and desired size) in actual_word_size if the allocation has been
   // successful.
-  static inline HeapWord* par_allocate(HeapRegion* alloc_region,
-                                       size_t min_word_size,
-                                       size_t desired_word_size,
-                                       size_t* actual_word_size,
-                                       bool bot_updates);
+  inline HeapWord* par_allocate(HeapRegion* alloc_region,
+                                size_t min_word_size,
+                                size_t desired_word_size,
+                                size_t* actual_word_size);
 
   // Ensure that the region passed as a parameter has been filled up
   // so that noone else can allocate out of it any more.
   // Returns the number of bytes that have been wasted by filled up
   // the space.
-  static size_t fill_up_remaining_space(HeapRegion* alloc_region,
-                                        bool bot_updates);
+  size_t fill_up_remaining_space(HeapRegion* alloc_region);
 
   // After a region is allocated by alloc_new_region, this
   // method is used to set it as the active alloc_region
@@ -160,8 +150,7 @@
   // First-level allocation: Should be called without holding a
   // lock. It will try to allocate lock-free out of the active region,
   // or return NULL if it was unable to.
-  inline HeapWord* attempt_allocation(size_t word_size,
-                                      bool bot_updates);
+  inline HeapWord* attempt_allocation(size_t word_size);
   // Perform an allocation out of the current allocation region, with the given
   // minimum and desired size. Returns the actual size allocated (between
   // minimum and desired size) in actual_word_size if the allocation has been
@@ -170,8 +159,7 @@
   // out of the active region, or return NULL if it was unable to.
   inline HeapWord* attempt_allocation(size_t min_word_size,
                                       size_t desired_word_size,
-                                      size_t* actual_word_size,
-                                      bool bot_updates);
+                                      size_t* actual_word_size);
 
   // Second-level allocation: Should be called while holding a
   // lock. It will try to first allocate lock-free out of the active
@@ -179,23 +167,20 @@
   // alloc region with a new one. We require that the caller takes the
   // appropriate lock before calling this so that it is easier to make
   // it conform to its locking protocol.
-  inline HeapWord* attempt_allocation_locked(size_t word_size,
-                                             bool bot_updates);
+  inline HeapWord* attempt_allocation_locked(size_t word_size);
   // Same as attempt_allocation_locked(size_t, bool), but allowing specification
   // of minimum word size of the block in min_word_size, and the maximum word
   // size of the allocation in desired_word_size. The actual size of the block is
   // returned in actual_word_size.
   inline HeapWord* attempt_allocation_locked(size_t min_word_size,
                                              size_t desired_word_size,
-                                             size_t* actual_word_size,
-                                             bool bot_updates);
+                                             size_t* actual_word_size);
 
   // Should be called to allocate a new region even if the max of this
   // type of regions has been reached. Should only be called if other
   // allocation attempts have failed and we are not holding a valid
   // active region.
-  inline HeapWord* attempt_allocation_force(size_t word_size,
-                                            bool bot_updates);
+  inline HeapWord* attempt_allocation_force(size_t word_size);
 
   // Should be called before we start using this object.
   void init();
@@ -236,7 +221,7 @@
   virtual void retire_region(HeapRegion* alloc_region, size_t allocated_bytes);
 
   virtual size_t retire(bool fill_up);
-public:
+
   G1GCAllocRegion(const char* name, bool bot_updates, G1EvacStats* stats, InCSetState::in_cset_state_t purpose)
   : G1AllocRegion(name, bot_updates), _stats(stats), _purpose(purpose) {
     assert(stats != NULL, "Must pass non-NULL PLAB statistics");
--- a/src/hotspot/share/gc/g1/g1AllocRegion.inline.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/gc/g1/g1AllocRegion.inline.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,52 +37,47 @@
 
 
 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
-                                         size_t word_size,
-                                         bool bot_updates) {
+                                         size_t word_size) {
   assert(alloc_region != NULL, "pre-condition");
 
-  if (!bot_updates) {
+  if (!_bot_updates) {
     return alloc_region->allocate_no_bot_updates(word_size);
   } else {
     return alloc_region->allocate(word_size);
   }
 }
 
-inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size, bool bot_updates) {
+inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size) {
   size_t temp;
-  return par_allocate(alloc_region, word_size, word_size, &temp, bot_updates);
+  return par_allocate(alloc_region, word_size, word_size, &temp);
 }
 
 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
                                              size_t min_word_size,
                                              size_t desired_word_size,
-                                             size_t* actual_word_size,
-                                             bool bot_updates) {
+                                             size_t* actual_word_size) {
   assert(alloc_region != NULL, "pre-condition");
   assert(!alloc_region->is_empty(), "pre-condition");
 
-  if (!bot_updates) {
+  if (!_bot_updates) {
     return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
   } else {
     return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
   }
 }
 
-inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size, bool bot_updates) {
+inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size) {
   size_t temp;
-  return attempt_allocation(word_size, word_size, &temp, bot_updates);
+  return attempt_allocation(word_size, word_size, &temp);
 }
 
 inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
                                                    size_t desired_word_size,
-                                                   size_t* actual_word_size,
-                                                   bool bot_updates) {
-  assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
-
+                                                   size_t* actual_word_size) {
   HeapRegion* alloc_region = _alloc_region;
   assert_alloc_region(alloc_region != NULL, "not initialized properly");
 
-  HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
+  HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size);
   if (result != NULL) {
     trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
     return result;
@@ -91,19 +86,18 @@
   return NULL;
 }
 
-inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size, bool bot_updates) {
+inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size) {
   size_t temp;
-  return attempt_allocation_locked(word_size, word_size, &temp, bot_updates);
+  return attempt_allocation_locked(word_size, word_size, &temp);
 }
 
 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
                                                           size_t desired_word_size,
-                                                          size_t* actual_word_size,
-                                                          bool bot_updates) {
+                                                          size_t* actual_word_size) {
   // First we have to redo the allocation, assuming we're holding the
   // appropriate lock, in case another thread changed the region while
   // we were waiting to get the lock.
-  HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size, bot_updates);
+  HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size);
   if (result != NULL) {
     return result;
   }
@@ -119,9 +113,7 @@
   return NULL;
 }
 
-inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
-                                                         bool bot_updates) {
-  assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
+inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size) {
   assert_alloc_region(_alloc_region != NULL, "not initialized properly");
 
   trace("forcing alloc", word_size, word_size);
--- a/src/hotspot/share/gc/g1/g1Allocator.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/gc/g1/g1Allocator.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -190,14 +190,12 @@
 
   HeapWord* result = survivor_gc_alloc_region(context)->attempt_allocation(min_word_size,
                                                                            desired_word_size,
-                                                                           actual_word_size,
-                                                                           false /* bot_updates */);
+                                                                           actual_word_size);
   if (result == NULL && !survivor_is_full(context)) {
     MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
     result = survivor_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
                                                                           desired_word_size,
-                                                                          actual_word_size,
-                                                                          false /* bot_updates */);
+                                                                          actual_word_size);
     if (result == NULL) {
       set_survivor_full(context);
     }
@@ -217,14 +215,12 @@
 
   HeapWord* result = old_gc_alloc_region(context)->attempt_allocation(min_word_size,
                                                                       desired_word_size,
-                                                                      actual_word_size,
-                                                                      true /* bot_updates */);
+                                                                      actual_word_size);
   if (result == NULL && !old_is_full(context)) {
     MutexLockerEx x(FreeList_lock, Mutex::_no_safepoint_check_flag);
     result = old_gc_alloc_region(context)->attempt_allocation_locked(min_word_size,
                                                                      desired_word_size,
-                                                                     actual_word_size,
-                                                                     true /* bot_updates */);
+                                                                     actual_word_size);
     if (result == NULL) {
       set_old_full(context);
     }
--- a/src/hotspot/share/gc/g1/g1Allocator.inline.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/gc/g1/g1Allocator.inline.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -30,18 +30,18 @@
 #include "gc/shared/plab.inline.hpp"
 
 HeapWord* G1Allocator::attempt_allocation(size_t word_size, AllocationContext_t context) {
-  return mutator_alloc_region(context)->attempt_allocation(word_size, false /* bot_updates */);
+  return mutator_alloc_region(context)->attempt_allocation(word_size);
 }
 
 HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size, AllocationContext_t context) {
-  HeapWord* result = mutator_alloc_region(context)->attempt_allocation_locked(word_size, false /* bot_updates */);
+  HeapWord* result = mutator_alloc_region(context)->attempt_allocation_locked(word_size);
   assert(result != NULL || mutator_alloc_region(context)->get() == NULL,
          "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region(context)->get()));
   return result;
 }
 
 HeapWord* G1Allocator::attempt_allocation_force(size_t word_size, AllocationContext_t context) {
-  return mutator_alloc_region(context)->attempt_allocation_force(word_size, false /* bot_updates */);
+  return mutator_alloc_region(context)->attempt_allocation_force(word_size);
 }
 
 inline HeapWord* G1PLABAllocator::plab_allocate(InCSetState dest,
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -761,6 +761,10 @@
 
 C2V_VMENTRY(jboolean, isCompilable,(JNIEnv *, jobject, jobject jvmci_method))
   methodHandle method = CompilerToVM::asMethod(jvmci_method);
+  // Skip redefined methods
+  if (method->is_old()) {
+    return false;
+  }
   return !method->is_not_compilable(CompLevel_full_optimization);
 C2V_END
 
--- a/src/hotspot/share/memory/metaspace.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/memory/metaspace.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -3695,7 +3695,6 @@
   MaxMetaspaceExpansion = align_down_bounded(MaxMetaspaceExpansion, _commit_alignment);
 
   CompressedClassSpaceSize = align_down_bounded(CompressedClassSpaceSize, _reserve_alignment);
-  set_compressed_class_space_size(CompressedClassSpaceSize);
 
   // Initial virtual space size will be calculated at global_initialize()
   size_t min_metaspace_sz =
@@ -3714,6 +3713,7 @@
                   min_metaspace_sz);
   }
 
+  set_compressed_class_space_size(CompressedClassSpaceSize);
 }
 
 void Metaspace::global_initialize() {
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -1627,14 +1627,16 @@
           log_trace(cds)("Shared spaces preloaded: %s", klass->external_name());
         }
 
-        InstanceKlass* ik = InstanceKlass::cast(klass);
+        if (klass->is_instance_klass()) {
+          InstanceKlass* ik = InstanceKlass::cast(klass);
 
-        // Link the class to cause the bytecodes to be rewritten and the
-        // cpcache to be created. The linking is done as soon as classes
-        // are loaded in order that the related data structures (klass and
-        // cpCache) are located together.
-        try_link_class(ik, THREAD);
-        guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");
+          // Link the class to cause the bytecodes to be rewritten and the
+          // cpcache to be created. The linking is done as soon as classes
+          // are loaded in order that the related data structures (klass and
+          // cpCache) are located together.
+          try_link_class(ik, THREAD);
+          guarantee(!HAS_PENDING_EXCEPTION, "exception in link_class");
+        }
 
         class_count++;
       }
--- a/src/hotspot/share/opto/library_call.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/opto/library_call.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -1805,10 +1805,19 @@
     return StubRoutines::dexp() != NULL ?
       runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dexp(),  "dexp") :
       runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dexp),  "EXP");
-  case vmIntrinsics::_dpow:
-    return StubRoutines::dpow() != NULL ?
-      runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(), "dpow") :
+  case vmIntrinsics::_dpow: {
+    Node* exp = round_double_node(argument(2));
+    const TypeD* d = _gvn.type(exp)->isa_double_constant();
+    if (d != NULL && d->getd() == 2.0) {
+      // Special case: pow(x, 2.0) => x * x
+      Node* base = round_double_node(argument(0));
+      set_result(_gvn.transform(new MulDNode(base, base)));
+      return true;
+    }
+    return StubRoutines::dexp() != NULL ?
+      runtime_math(OptoRuntime::Math_DD_D_Type(), StubRoutines::dpow(),  "dpow") :
       runtime_math(OptoRuntime::Math_DD_D_Type(), FN_PTR(SharedRuntime::dpow),  "POW");
+  }
 #undef FN_PTR
 
    // These intrinsics are not yet correctly implemented
--- a/src/hotspot/share/prims/jniCheck.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/prims/jniCheck.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -826,7 +826,10 @@
     }
     jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
     if (result == JNI_OK) {
-      add_planned_handle_capacity(thr->active_handles(), capacity);
+      // increase local ref capacity if needed
+      if ((size_t)capacity > thr->active_handles()->get_planned_capacity()) {
+        add_planned_handle_capacity(thr->active_handles(), capacity);
+      }
     }
     functionExit(thr);
     return result;
--- a/src/hotspot/share/runtime/java.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/runtime/java.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -357,7 +357,7 @@
     MemTracker::final_report(tty);
   }
 
-  ThreadsSMRSupport::log_smr_statistics();
+  ThreadsSMRSupport::log_statistics();
 }
 
 #else // PRODUCT MODE STATISTICS
@@ -399,7 +399,7 @@
     Method::print_touched_methods(tty);
   }
 
-  ThreadsSMRSupport::log_smr_statistics();
+  ThreadsSMRSupport::log_statistics();
 }
 
 #endif
--- a/src/hotspot/share/runtime/thread.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/runtime/thread.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -3473,7 +3473,7 @@
              X = (JavaThread*)prefetch_and_load_ptr((void**)MACRO_current_p, (intx)MACRO_scan_interval))
 
 // All JavaThreads
-#define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_smr_java_thread_list(), X)
+#define ALL_JAVA_THREADS(X) DO_JAVA_THREADS(ThreadsSMRSupport::get_java_thread_list(), X)
 
 // All JavaThreads + all non-JavaThreads (i.e., every thread in the system)
 void Threads::threads_do(ThreadClosure* tc) {
@@ -4382,7 +4382,7 @@
   // that we do not remove thread without safepoint code notice
   { MutexLocker ml(Threads_lock);
 
-    assert(ThreadsSMRSupport::get_smr_java_thread_list()->includes(p), "p must be present");
+    assert(ThreadsSMRSupport::get_java_thread_list()->includes(p), "p must be present");
 
     // Maintain fast thread list
     ThreadsSMRSupport::remove_thread(p);
@@ -4610,7 +4610,7 @@
   }
 #endif // INCLUDE_SERVICES
 
-  ThreadsSMRSupport::print_smr_info_on(st);
+  ThreadsSMRSupport::print_info_on(st);
   st->cr();
 
   ALL_JAVA_THREADS(p) {
@@ -4679,7 +4679,7 @@
 // memory (even in resource area), it might deadlock the error handler.
 void Threads::print_on_error(outputStream* st, Thread* current, char* buf,
                              int buflen) {
-  ThreadsSMRSupport::print_smr_info_on(st);
+  ThreadsSMRSupport::print_info_on(st);
   st->cr();
 
   bool found_current = false;
--- a/src/hotspot/share/runtime/threadSMR.cpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/runtime/threadSMR.cpp	Wed Dec 20 20:55:07 2017 +0100
@@ -31,131 +31,131 @@
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/resourceHash.hpp"
 
-Monitor*              ThreadsSMRSupport::_smr_delete_lock =
-                          new Monitor(Monitor::special, "smr_delete_lock",
+Monitor*              ThreadsSMRSupport::_delete_lock =
+                          new Monitor(Monitor::special, "Thread_SMR_delete_lock",
                                       false /* allow_vm_block */,
                                       Monitor::_safepoint_check_never);
 // The '_cnt', '_max' and '_times" fields are enabled via
 // -XX:+EnableThreadSMRStatistics:
 
-// # of parallel threads in _smr_delete_lock->wait().
+// # of parallel threads in _delete_lock->wait().
 // Impl note: Hard to imagine > 64K waiting threads so this could be 16-bit,
 // but there is no nice 16-bit _FORMAT support.
-uint                  ThreadsSMRSupport::_smr_delete_lock_wait_cnt = 0;
+uint                  ThreadsSMRSupport::_delete_lock_wait_cnt = 0;
 
-// Max # of parallel threads in _smr_delete_lock->wait().
-// Impl note: See _smr_delete_lock_wait_cnt note.
-uint                  ThreadsSMRSupport::_smr_delete_lock_wait_max = 0;
+// Max # of parallel threads in _delete_lock->wait().
+// Impl note: See _delete_lock_wait_cnt note.
+uint                  ThreadsSMRSupport::_delete_lock_wait_max = 0;
 
-// Flag to indicate when an _smr_delete_lock->notify() is needed.
-// Impl note: See _smr_delete_lock_wait_cnt note.
-volatile uint         ThreadsSMRSupport::_smr_delete_notify = 0;
+// Flag to indicate when an _delete_lock->notify() is needed.
+// Impl note: See _delete_lock_wait_cnt note.
+volatile uint         ThreadsSMRSupport::_delete_notify = 0;
 
 // # of threads deleted over VM lifetime.
 // Impl note: Atomically incremented over VM lifetime so use unsigned for more
 // range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
 // isn't available everywhere (or is it?).
-volatile uint         ThreadsSMRSupport::_smr_deleted_thread_cnt = 0;
+volatile uint         ThreadsSMRSupport::_deleted_thread_cnt = 0;
 
 // Max time in millis to delete a thread.
 // Impl note: 16-bit might be too small on an overloaded machine. Use
 // unsigned since this is a time value. Set via Atomic::cmpxchg() in a
 // loop for correctness.
-volatile uint         ThreadsSMRSupport::_smr_deleted_thread_time_max = 0;
+volatile uint         ThreadsSMRSupport::_deleted_thread_time_max = 0;
 
 // Cumulative time in millis to delete threads.
 // Impl note: Atomically added to over VM lifetime so use unsigned for more
 // range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
 // isn't available everywhere (or is it?).
-volatile uint         ThreadsSMRSupport::_smr_deleted_thread_times = 0;
+volatile uint         ThreadsSMRSupport::_deleted_thread_times = 0;
 
-ThreadsList* volatile ThreadsSMRSupport::_smr_java_thread_list = new ThreadsList(0);
+ThreadsList* volatile ThreadsSMRSupport::_java_thread_list = new ThreadsList(0);
 
 // # of ThreadsLists allocated over VM lifetime.
 // Impl note: We allocate a new ThreadsList for every thread create and
 // every thread delete so we need a bigger type than the
-// _smr_deleted_thread_cnt field.
-uint64_t              ThreadsSMRSupport::_smr_java_thread_list_alloc_cnt = 1;
+// _deleted_thread_cnt field.
+uint64_t              ThreadsSMRSupport::_java_thread_list_alloc_cnt = 1;
 
 // # of ThreadsLists freed over VM lifetime.
-// Impl note: See _smr_java_thread_list_alloc_cnt note.
-uint64_t              ThreadsSMRSupport::_smr_java_thread_list_free_cnt = 0;
+// Impl note: See _java_thread_list_alloc_cnt note.
+uint64_t              ThreadsSMRSupport::_java_thread_list_free_cnt = 0;
 
 // Max size ThreadsList allocated.
 // Impl note: Max # of threads alive at one time should fit in unsigned 32-bit.
-uint                  ThreadsSMRSupport::_smr_java_thread_list_max = 0;
+uint                  ThreadsSMRSupport::_java_thread_list_max = 0;
 
 // Max # of nested ThreadsLists for a thread.
 // Impl note: Hard to imagine > 64K nested ThreadsLists so this could be
 // 16-bit, but there is no nice 16-bit _FORMAT support.
-uint                  ThreadsSMRSupport::_smr_nested_thread_list_max = 0;
+uint                  ThreadsSMRSupport::_nested_thread_list_max = 0;
 
 // # of ThreadsListHandles deleted over VM lifetime.
 // Impl note: Atomically incremented over VM lifetime so use unsigned for
 // more range. There will be fewer ThreadsListHandles than threads so
 // unsigned 32-bit should be fine.
-volatile uint         ThreadsSMRSupport::_smr_tlh_cnt = 0;
+volatile uint         ThreadsSMRSupport::_tlh_cnt = 0;
 
 // Max time in millis to delete a ThreadsListHandle.
 // Impl note: 16-bit might be too small on an overloaded machine. Use
 // unsigned since this is a time value. Set via Atomic::cmpxchg() in a
 // loop for correctness.
-volatile uint         ThreadsSMRSupport::_smr_tlh_time_max = 0;
+volatile uint         ThreadsSMRSupport::_tlh_time_max = 0;
 
 // Cumulative time in millis to delete ThreadsListHandles.
 // Impl note: Atomically added to over VM lifetime so use unsigned for more
 // range. Unsigned 64-bit would be more future proof, but 64-bit atomic inc
 // isn't available everywhere (or is it?).
-volatile uint         ThreadsSMRSupport::_smr_tlh_times = 0;
+volatile uint         ThreadsSMRSupport::_tlh_times = 0;
 
-ThreadsList*          ThreadsSMRSupport::_smr_to_delete_list = NULL;
+ThreadsList*          ThreadsSMRSupport::_to_delete_list = NULL;
 
 // # of parallel ThreadsLists on the to-delete list.
 // Impl note: Hard to imagine > 64K ThreadsLists needing to be deleted so
 // this could be 16-bit, but there is no nice 16-bit _FORMAT support.
-uint                  ThreadsSMRSupport::_smr_to_delete_list_cnt = 0;
+uint                  ThreadsSMRSupport::_to_delete_list_cnt = 0;
 
 // Max # of parallel ThreadsLists on the to-delete list.
-// Impl note: See _smr_to_delete_list_cnt note.
-uint                  ThreadsSMRSupport::_smr_to_delete_list_max = 0;
+// Impl note: See _to_delete_list_cnt note.
+uint                  ThreadsSMRSupport::_to_delete_list_max = 0;
 
 
 // 'inline' functions first so the definitions are before first use:
 
-inline void ThreadsSMRSupport::add_smr_deleted_thread_times(uint add_value) {
-  Atomic::add(add_value, &_smr_deleted_thread_times);
+inline void ThreadsSMRSupport::add_deleted_thread_times(uint add_value) {
+  Atomic::add(add_value, &_deleted_thread_times);
 }
 
-inline void ThreadsSMRSupport::inc_smr_deleted_thread_cnt() {
-  Atomic::inc(&_smr_deleted_thread_cnt);
+inline void ThreadsSMRSupport::inc_deleted_thread_cnt() {
+  Atomic::inc(&_deleted_thread_cnt);
 }
 
-inline void ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt() {
-  _smr_java_thread_list_alloc_cnt++;
+inline void ThreadsSMRSupport::inc_java_thread_list_alloc_cnt() {
+  _java_thread_list_alloc_cnt++;
 }
 
-inline void ThreadsSMRSupport::update_smr_deleted_thread_time_max(uint new_value) {
+inline void ThreadsSMRSupport::update_deleted_thread_time_max(uint new_value) {
   while (true) {
-    uint cur_value = _smr_deleted_thread_time_max;
+    uint cur_value = _deleted_thread_time_max;
     if (new_value <= cur_value) {
       // No need to update max value so we're done.
       break;
     }
-    if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
+    if (Atomic::cmpxchg(new_value, &_deleted_thread_time_max, cur_value) == cur_value) {
       // Updated max value so we're done. Otherwise try it all again.
       break;
     }
   }
 }
 
-inline void ThreadsSMRSupport::update_smr_java_thread_list_max(uint new_value) {
-  if (new_value > _smr_java_thread_list_max) {
-    _smr_java_thread_list_max = new_value;
+inline void ThreadsSMRSupport::update_java_thread_list_max(uint new_value) {
+  if (new_value > _java_thread_list_max) {
+    _java_thread_list_max = new_value;
   }
 }
 
-inline ThreadsList* ThreadsSMRSupport::xchg_smr_java_thread_list(ThreadsList* new_list) {
-  return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
+inline ThreadsList* ThreadsSMRSupport::xchg_java_thread_list(ThreadsList* new_list) {
+  return (ThreadsList*)Atomic::xchg(new_list, &_java_thread_list);
 }
 
 
@@ -268,7 +268,7 @@
     }
 
     // The current JavaThread has a hazard ptr (ThreadsList reference)
-    // which might be _smr_java_thread_list or it might be an older
+    // which might be _java_thread_list or it might be an older
     // ThreadsList that has been removed but not freed. In either case,
     // the hazard ptr is protecting all the JavaThreads on that
     // ThreadsList.
@@ -347,7 +347,7 @@
     if (Thread::is_hazard_ptr_tagged(current_list)) return;
 
     // The current JavaThread has a hazard ptr (ThreadsList reference)
-    // which might be _smr_java_thread_list or it might be an older
+    // which might be _java_thread_list or it might be an older
     // ThreadsList that has been removed but not freed. In either case,
     // the hazard ptr is protecting all the JavaThreads on that
     // ThreadsList, but we only care about matching a specific JavaThread.
@@ -476,7 +476,7 @@
   if (EnableThreadSMRStatistics) {
     _timer.stop();
     uint millis = (uint)_timer.milliseconds();
-    ThreadsSMRSupport::update_smr_tlh_stats(millis);
+    ThreadsSMRSupport::update_tlh_stats(millis);
   }
 }
 
@@ -574,12 +574,12 @@
   ThreadsList* threads;
 
   // Stable recording of a hazard ptr for SMR. This code does not use
-  // locks so its use of the _smr_java_thread_list & _threads_hazard_ptr
+  // locks so its use of the _java_thread_list & _threads_hazard_ptr
   // fields is racy relative to code that uses those fields with locks.
   // OrderAccess and Atomic functions are used to deal with those races.
   //
   while (true) {
-    threads = get_smr_java_thread_list();
+    threads = get_java_thread_list();
 
     // Publish a tagged hazard ptr to denote that the hazard ptr is not
     // yet verified as being stable. Due to the fence after the hazard
@@ -590,9 +590,9 @@
     ThreadsList* unverified_threads = Thread::tag_hazard_ptr(threads);
     self->set_threads_hazard_ptr(unverified_threads);
 
-    // If _smr_java_thread_list has changed, we have lost a race with
+    // If _java_thread_list has changed, we have lost a race with
     // Threads::add() or Threads::remove() and have to try again.
-    if (get_smr_java_thread_list() != threads) {
+    if (get_java_thread_list() != threads) {
       continue;
     }
 
@@ -634,15 +634,15 @@
   {
     // Only grab the Threads_lock if we don't already own it.
     MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
-    node = new NestedThreadsList(get_smr_java_thread_list());
+    node = new NestedThreadsList(get_java_thread_list());
     // We insert at the front of the list to match up with the delete
     // in release_stable_list().
     node->set_next(self->get_nested_threads_hazard_ptr());
     self->set_nested_threads_hazard_ptr(node);
     if (EnableThreadSMRStatistics) {
       self->inc_nested_threads_hazard_ptr_cnt();
-      if (self->nested_threads_hazard_ptr_cnt() > _smr_nested_thread_list_max) {
-        _smr_nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
+      if (self->nested_threads_hazard_ptr_cnt() > _nested_thread_list_max) {
+        _nested_thread_list_max = self->nested_threads_hazard_ptr_cnt();
       }
     }
   }
@@ -652,25 +652,101 @@
 }
 
 void ThreadsSMRSupport::add_thread(JavaThread *thread){
-  ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_smr_java_thread_list(), thread);
+  ThreadsList *new_list = ThreadsList::add_thread(ThreadsSMRSupport::get_java_thread_list(), thread);
   if (EnableThreadSMRStatistics) {
-    ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt();
-    ThreadsSMRSupport::update_smr_java_thread_list_max(new_list->length());
+    ThreadsSMRSupport::inc_java_thread_list_alloc_cnt();
+    ThreadsSMRSupport::update_java_thread_list_max(new_list->length());
   }
-  // Initial _smr_java_thread_list will not generate a "Threads::add" mesg.
+  // Initial _java_thread_list will not generate a "Threads::add" mesg.
   log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::add: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
 
-  ThreadsList *old_list = ThreadsSMRSupport::xchg_smr_java_thread_list(new_list);
-  ThreadsSMRSupport::smr_free_list(old_list);
+  ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list);
+  ThreadsSMRSupport::free_list(old_list);
+}
+
+// set_delete_notify() and clear_delete_notify() are called
+// under the protection of the delete_lock, but we also use an
+// Atomic operation to ensure the memory update is seen earlier than
+// when the delete_lock is dropped.
+//
+void ThreadsSMRSupport::clear_delete_notify() {
+  Atomic::dec(&_delete_notify);
+}
+
+bool ThreadsSMRSupport::delete_notify() {
+  // Use load_acquire() in order to see any updates to _delete_notify
+  // earlier than when delete_lock is grabbed.
+  return (OrderAccess::load_acquire(&_delete_notify) != 0);
 }
 
-// set_smr_delete_notify() and clear_smr_delete_notify() are called
-// under the protection of the smr_delete_lock, but we also use an
-// Atomic operation to ensure the memory update is seen earlier than
-// when the smr_delete_lock is dropped.
-//
-void ThreadsSMRSupport::clear_smr_delete_notify() {
-  Atomic::dec(&_smr_delete_notify);
+// Safely free a ThreadsList after a Threads::add() or Threads::remove().
+// The specified ThreadsList may not get deleted during this call if it
+// is still in-use (referenced by a hazard ptr). Other ThreadsLists
+// in the chain may get deleted by this call if they are no longer in-use.
+void ThreadsSMRSupport::free_list(ThreadsList* threads) {
+  assert_locked_or_safepoint(Threads_lock);
+
+  threads->set_next_list(_to_delete_list);
+  _to_delete_list = threads;
+  if (EnableThreadSMRStatistics) {
+    _to_delete_list_cnt++;
+    if (_to_delete_list_cnt > _to_delete_list_max) {
+      _to_delete_list_max = _to_delete_list_cnt;
+    }
+  }
+
+  // Hash table size should be first power of two higher than twice the length of the ThreadsList
+  int hash_table_size = MIN2((int)get_java_thread_list()->length(), 32) << 1;
+  hash_table_size--;
+  hash_table_size |= hash_table_size >> 1;
+  hash_table_size |= hash_table_size >> 2;
+  hash_table_size |= hash_table_size >> 4;
+  hash_table_size |= hash_table_size >> 8;
+  hash_table_size |= hash_table_size >> 16;
+  hash_table_size++;
+
+  // Gather a hash table of the current hazard ptrs:
+  ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
+  ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
+  Threads::threads_do(&scan_cl);
+
+  // Walk through the linked list of pending freeable ThreadsLists
+  // and free the ones that are not referenced from hazard ptrs.
+  ThreadsList* current = _to_delete_list;
+  ThreadsList* prev = NULL;
+  ThreadsList* next = NULL;
+  bool threads_is_freed = false;
+  while (current != NULL) {
+    next = current->next_list();
+    if (!scan_table->has_entry((void*)current)) {
+      // This ThreadsList is not referenced by a hazard ptr.
+      if (prev != NULL) {
+        prev->set_next_list(next);
+      }
+      if (_to_delete_list == current) {
+        _to_delete_list = next;
+      }
+
+      log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current));
+      if (current == threads) threads_is_freed = true;
+      delete current;
+      if (EnableThreadSMRStatistics) {
+        _java_thread_list_free_cnt++;
+        _to_delete_list_cnt--;
+      }
+    } else {
+      prev = current;
+    }
+    current = next;
+  }
+
+  if (!threads_is_freed) {
+    // Only report "is not freed" on the original call to
+    // free_list() for this ThreadsList.
+    log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads));
+  }
+
+  delete scan_table;
 }
 
 // Return true if the specified JavaThread is protected by a hazard
@@ -681,7 +757,7 @@
 
   // Hash table size should be first power of two higher than twice
   // the length of the Threads list.
-  int hash_table_size = MIN2((int)get_smr_java_thread_list()->length(), 32) << 1;
+  int hash_table_size = MIN2((int)get_java_thread_list()->length(), 32) << 1;
   hash_table_size--;
   hash_table_size |= hash_table_size >> 1;
   hash_table_size |= hash_table_size >> 2;
@@ -736,10 +812,10 @@
   self->set_threads_hazard_ptr(NULL);
 
   // We use double-check locking to reduce traffic on the system
-  // wide smr_delete_lock.
-  if (ThreadsSMRSupport::smr_delete_notify()) {
+  // wide Thread-SMR delete_lock.
+  if (ThreadsSMRSupport::delete_notify()) {
     // An exiting thread might be waiting in smr_delete(); we need to
-    // check with smr_delete_lock to be sure.
+    // check with delete_lock to be sure.
     release_stable_list_wake_up((char *) "regular hazard ptr");
   }
 }
@@ -772,7 +848,7 @@
   }
 
   // An exiting thread might be waiting in smr_delete(); we need to
-  // check with smr_delete_lock to be sure.
+  // check with delete_lock to be sure.
   release_stable_list_wake_up((char *) "nested hazard ptr");
 
   log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::release_stable_list: delete NestedThreadsList node containing ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(node->t_list()));
@@ -781,21 +857,21 @@
 }
 
 // Wake up portion of the release stable ThreadsList protocol;
-// uses the smr_delete_lock().
+// uses the delete_lock().
 //
 void ThreadsSMRSupport::release_stable_list_wake_up(char *log_str) {
   assert(log_str != NULL, "sanity check");
 
-  // Note: smr_delete_lock is held in smr_delete() for the entire
+  // Note: delete_lock is held in smr_delete() for the entire
   // hazard ptr search so that we do not lose this notify() if
   // the exiting thread has to wait. That code path also holds
-  // Threads_lock (which was grabbed before smr_delete_lock) so that
+  // Threads_lock (which was grabbed before delete_lock) so that
   // threads_do() can be called. This means the system can't start a
   // safepoint which means this thread can't take too long to get to
-  // a safepoint because of being blocked on smr_delete_lock.
+  // a safepoint because of being blocked on delete_lock.
   //
-  MonitorLockerEx ml(ThreadsSMRSupport::smr_delete_lock(), Monitor::_no_safepoint_check_flag);
-  if (ThreadsSMRSupport::smr_delete_notify()) {
+  MonitorLockerEx ml(ThreadsSMRSupport::delete_lock(), Monitor::_no_safepoint_check_flag);
+  if (ThreadsSMRSupport::delete_notify()) {
     // Notify any exiting JavaThreads that are waiting in smr_delete()
     // that we've released a ThreadsList.
     ml.notify_all();
@@ -804,23 +880,23 @@
 }
 
 void ThreadsSMRSupport::remove_thread(JavaThread *thread) {
-  ThreadsList *new_list = ThreadsList::remove_thread(ThreadsSMRSupport::get_smr_java_thread_list(), thread);
+  ThreadsList *new_list = ThreadsList::remove_thread(ThreadsSMRSupport::get_java_thread_list(), thread);
   if (EnableThreadSMRStatistics) {
-    ThreadsSMRSupport::inc_smr_java_thread_list_alloc_cnt();
+    ThreadsSMRSupport::inc_java_thread_list_alloc_cnt();
     // This list is smaller so no need to check for a "longest" update.
   }
 
-  // Final _smr_java_thread_list will not generate a "Threads::remove" mesg.
+  // Final _java_thread_list will not generate a "Threads::remove" mesg.
   log_debug(thread, smr)("tid=" UINTX_FORMAT ": Threads::remove: new ThreadsList=" INTPTR_FORMAT, os::current_thread_id(), p2i(new_list));
 
-  ThreadsList *old_list = ThreadsSMRSupport::xchg_smr_java_thread_list(new_list);
-  ThreadsSMRSupport::smr_free_list(old_list);
+  ThreadsList *old_list = ThreadsSMRSupport::xchg_java_thread_list(new_list);
+  ThreadsSMRSupport::free_list(old_list);
 }
 
-// See note for clear_smr_delete_notify().
+// See note for clear_delete_notify().
 //
-void ThreadsSMRSupport::set_smr_delete_notify() {
-  Atomic::inc(&_smr_delete_notify);
+void ThreadsSMRSupport::set_delete_notify() {
+  Atomic::inc(&_delete_notify);
 }
 
 // Safely delete a JavaThread when it is no longer in use by a
@@ -842,16 +918,16 @@
       MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
       // Cannot use a MonitorLockerEx helper here because we have
       // to drop the Threads_lock first if we wait.
-      ThreadsSMRSupport::smr_delete_lock()->lock_without_safepoint_check();
-      // Set the smr_delete_notify flag after we grab smr_delete_lock
+      ThreadsSMRSupport::delete_lock()->lock_without_safepoint_check();
+      // Set the delete_notify flag after we grab delete_lock
       // and before we scan hazard ptrs because we're doing
       // double-check locking in release_stable_list().
-      ThreadsSMRSupport::set_smr_delete_notify();
+      ThreadsSMRSupport::set_delete_notify();
 
       if (!is_a_protected_JavaThread(thread)) {
         // This is the common case.
-        ThreadsSMRSupport::clear_smr_delete_notify();
-        ThreadsSMRSupport::smr_delete_lock()->unlock();
+        ThreadsSMRSupport::clear_delete_notify();
+        ThreadsSMRSupport::delete_lock()->unlock();
         break;
       }
       if (!has_logged_once) {
@@ -865,22 +941,22 @@
     } // We have to drop the Threads_lock to wait or delete the thread
 
     if (EnableThreadSMRStatistics) {
-      _smr_delete_lock_wait_cnt++;
-      if (_smr_delete_lock_wait_cnt > _smr_delete_lock_wait_max) {
-        _smr_delete_lock_wait_max = _smr_delete_lock_wait_cnt;
+      _delete_lock_wait_cnt++;
+      if (_delete_lock_wait_cnt > _delete_lock_wait_max) {
+        _delete_lock_wait_max = _delete_lock_wait_cnt;
       }
     }
     // Wait for a release_stable_list() call before we check again. No
     // safepoint check, no timeout, and not as suspend equivalent flag
     // because this JavaThread is not on the Threads list.
-    ThreadsSMRSupport::smr_delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
+    ThreadsSMRSupport::delete_lock()->wait(Mutex::_no_safepoint_check_flag, 0,
                                      !Mutex::_as_suspend_equivalent_flag);
     if (EnableThreadSMRStatistics) {
-      _smr_delete_lock_wait_cnt--;
+      _delete_lock_wait_cnt--;
     }
 
-    ThreadsSMRSupport::clear_smr_delete_notify();
-    ThreadsSMRSupport::smr_delete_lock()->unlock();
+    ThreadsSMRSupport::clear_delete_notify();
+    ThreadsSMRSupport::delete_lock()->unlock();
     // Retry the whole scenario.
   }
 
@@ -893,166 +969,89 @@
   if (EnableThreadSMRStatistics) {
     timer.stop();
     uint millis = (uint)timer.milliseconds();
-    ThreadsSMRSupport::inc_smr_deleted_thread_cnt();
-    ThreadsSMRSupport::add_smr_deleted_thread_times(millis);
-    ThreadsSMRSupport::update_smr_deleted_thread_time_max(millis);
+    ThreadsSMRSupport::inc_deleted_thread_cnt();
+    ThreadsSMRSupport::add_deleted_thread_times(millis);
+    ThreadsSMRSupport::update_deleted_thread_time_max(millis);
   }
 
   log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
 }
 
-bool ThreadsSMRSupport::smr_delete_notify() {
-  // Use load_acquire() in order to see any updates to _smr_delete_notify
-  // earlier than when smr_delete_lock is grabbed.
-  return (OrderAccess::load_acquire(&_smr_delete_notify) != 0);
-}
-
-// Safely free a ThreadsList after a Threads::add() or Threads::remove().
-// The specified ThreadsList may not get deleted during this call if it
-// is still in-use (referenced by a hazard ptr). Other ThreadsLists
-// in the chain may get deleted by this call if they are no longer in-use.
-void ThreadsSMRSupport::smr_free_list(ThreadsList* threads) {
-  assert_locked_or_safepoint(Threads_lock);
-
-  threads->set_next_list(_smr_to_delete_list);
-  _smr_to_delete_list = threads;
-  if (EnableThreadSMRStatistics) {
-    _smr_to_delete_list_cnt++;
-    if (_smr_to_delete_list_cnt > _smr_to_delete_list_max) {
-      _smr_to_delete_list_max = _smr_to_delete_list_cnt;
-    }
-  }
-
-  // Hash table size should be first power of two higher than twice the length of the ThreadsList
-  int hash_table_size = MIN2((int)get_smr_java_thread_list()->length(), 32) << 1;
-  hash_table_size--;
-  hash_table_size |= hash_table_size >> 1;
-  hash_table_size |= hash_table_size >> 2;
-  hash_table_size |= hash_table_size >> 4;
-  hash_table_size |= hash_table_size >> 8;
-  hash_table_size |= hash_table_size >> 16;
-  hash_table_size++;
-
-  // Gather a hash table of the current hazard ptrs:
-  ThreadScanHashtable *scan_table = new ThreadScanHashtable(hash_table_size);
-  ScanHazardPtrGatherThreadsListClosure scan_cl(scan_table);
-  Threads::threads_do(&scan_cl);
-
-  // Walk through the linked list of pending freeable ThreadsLists
-  // and free the ones that are not referenced from hazard ptrs.
-  ThreadsList* current = _smr_to_delete_list;
-  ThreadsList* prev = NULL;
-  ThreadsList* next = NULL;
-  bool threads_is_freed = false;
-  while (current != NULL) {
-    next = current->next_list();
-    if (!scan_table->has_entry((void*)current)) {
-      // This ThreadsList is not referenced by a hazard ptr.
-      if (prev != NULL) {
-        prev->set_next_list(next);
-      }
-      if (_smr_to_delete_list == current) {
-        _smr_to_delete_list = next;
-      }
-
-      log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_free_list: threads=" INTPTR_FORMAT " is freed.", os::current_thread_id(), p2i(current));
-      if (current == threads) threads_is_freed = true;
-      delete current;
-      if (EnableThreadSMRStatistics) {
-        _smr_java_thread_list_free_cnt++;
-        _smr_to_delete_list_cnt--;
-      }
-    } else {
-      prev = current;
-    }
-    current = next;
-  }
-
-  if (!threads_is_freed) {
-    // Only report "is not freed" on the original call to
-    // smr_free_list() for this ThreadsList.
-    log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_free_list: threads=" INTPTR_FORMAT " is not freed.", os::current_thread_id(), p2i(threads));
-  }
-
-  delete scan_table;
-}
-
 
 // Debug, logging, and printing stuff at the end:
 
 // Log Threads class SMR info.
-void ThreadsSMRSupport::log_smr_statistics() {
+void ThreadsSMRSupport::log_statistics() {
   LogTarget(Info, thread, smr) log;
   if (log.is_enabled()) {
     LogStream out(log);
-    print_smr_info_on(&out);
+    print_info_on(&out);
   }
 }
 
 // Print Threads class SMR info.
-void ThreadsSMRSupport::print_smr_info_on(outputStream* st) {
+void ThreadsSMRSupport::print_info_on(outputStream* st) {
   // Only grab the Threads_lock if we don't already own it
   // and if we are not reporting an error.
   MutexLockerEx ml((Threads_lock->owned_by_self() || VMError::is_error_reported()) ? NULL : Threads_lock);
 
   st->print_cr("Threads class SMR info:");
-  st->print_cr("_smr_java_thread_list=" INTPTR_FORMAT ", length=%u, "
-               "elements={", p2i(_smr_java_thread_list),
-               _smr_java_thread_list->length());
-  print_smr_info_elements_on(st, _smr_java_thread_list);
+  st->print_cr("_java_thread_list=" INTPTR_FORMAT ", length=%u, "
+               "elements={", p2i(_java_thread_list),
+               _java_thread_list->length());
+  print_info_elements_on(st, _java_thread_list);
   st->print_cr("}");
-  if (_smr_to_delete_list != NULL) {
-    st->print_cr("_smr_to_delete_list=" INTPTR_FORMAT ", length=%u, "
-                 "elements={", p2i(_smr_to_delete_list),
-                 _smr_to_delete_list->length());
-    print_smr_info_elements_on(st, _smr_to_delete_list);
+  if (_to_delete_list != NULL) {
+    st->print_cr("_to_delete_list=" INTPTR_FORMAT ", length=%u, "
+                 "elements={", p2i(_to_delete_list),
+                 _to_delete_list->length());
+    print_info_elements_on(st, _to_delete_list);
     st->print_cr("}");
-    for (ThreadsList *t_list = _smr_to_delete_list->next_list();
+    for (ThreadsList *t_list = _to_delete_list->next_list();
          t_list != NULL; t_list = t_list->next_list()) {
       st->print("next-> " INTPTR_FORMAT ", length=%u, "
                 "elements={", p2i(t_list), t_list->length());
-      print_smr_info_elements_on(st, t_list);
+      print_info_elements_on(st, t_list);
       st->print_cr("}");
     }
   }
   if (!EnableThreadSMRStatistics) {
     return;
   }
-  st->print_cr("_smr_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
-               "_smr_java_thread_list_free_cnt=" UINT64_FORMAT ","
-               "_smr_java_thread_list_max=%u, "
-               "_smr_nested_thread_list_max=%u",
-               _smr_java_thread_list_alloc_cnt,
-               _smr_java_thread_list_free_cnt,
-               _smr_java_thread_list_max,
-               _smr_nested_thread_list_max);
-  if (_smr_tlh_cnt > 0) {
-    st->print_cr("_smr_tlh_cnt=%u"
-                 ", _smr_tlh_times=%u"
-                 ", avg_smr_tlh_time=%0.2f"
-                 ", _smr_tlh_time_max=%u",
-                 _smr_tlh_cnt, _smr_tlh_times,
-                 ((double) _smr_tlh_times / _smr_tlh_cnt),
-                 _smr_tlh_time_max);
+  st->print_cr("_java_thread_list_alloc_cnt=" UINT64_FORMAT ","
+               "_java_thread_list_free_cnt=" UINT64_FORMAT ","
+               "_java_thread_list_max=%u, "
+               "_nested_thread_list_max=%u",
+               _java_thread_list_alloc_cnt,
+               _java_thread_list_free_cnt,
+               _java_thread_list_max,
+               _nested_thread_list_max);
+  if (_tlh_cnt > 0) {
+    st->print_cr("_tlh_cnt=%u"
+                 ", _tlh_times=%u"
+                 ", avg_tlh_time=%0.2f"
+                 ", _tlh_time_max=%u",
+                 _tlh_cnt, _tlh_times,
+                 ((double) _tlh_times / _tlh_cnt),
+                 _tlh_time_max);
   }
-  if (_smr_deleted_thread_cnt > 0) {
-    st->print_cr("_smr_deleted_thread_cnt=%u"
-                 ", _smr_deleted_thread_times=%u"
-                 ", avg_smr_deleted_thread_time=%0.2f"
-                 ", _smr_deleted_thread_time_max=%u",
-                 _smr_deleted_thread_cnt, _smr_deleted_thread_times,
-                 ((double) _smr_deleted_thread_times / _smr_deleted_thread_cnt),
-                 _smr_deleted_thread_time_max);
+  if (_deleted_thread_cnt > 0) {
+    st->print_cr("_deleted_thread_cnt=%u"
+                 ", _deleted_thread_times=%u"
+                 ", avg_deleted_thread_time=%0.2f"
+                 ", _deleted_thread_time_max=%u",
+                 _deleted_thread_cnt, _deleted_thread_times,
+                 ((double) _deleted_thread_times / _deleted_thread_cnt),
+                 _deleted_thread_time_max);
   }
-  st->print_cr("_smr_delete_lock_wait_cnt=%u, _smr_delete_lock_wait_max=%u",
-               _smr_delete_lock_wait_cnt, _smr_delete_lock_wait_max);
-  st->print_cr("_smr_to_delete_list_cnt=%u, _smr_to_delete_list_max=%u",
-               _smr_to_delete_list_cnt, _smr_to_delete_list_max);
+  st->print_cr("_delete_lock_wait_cnt=%u, _delete_lock_wait_max=%u",
+               _delete_lock_wait_cnt, _delete_lock_wait_max);
+  st->print_cr("_to_delete_list_cnt=%u, _to_delete_list_max=%u",
+               _to_delete_list_cnt, _to_delete_list_max);
 }
 
 // Print ThreadsList elements (4 per line).
-void ThreadsSMRSupport::print_smr_info_elements_on(outputStream* st,
-                                         ThreadsList* t_list) {
+void ThreadsSMRSupport::print_info_elements_on(outputStream* st, ThreadsList* t_list) {
   uint cnt = 0;
   JavaThreadIterator jti(t_list);
   for (JavaThread *jt = jti.first(); jt != NULL; jt = jti.next()) {
--- a/src/hotspot/share/runtime/threadSMR.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/runtime/threadSMR.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -81,67 +81,68 @@
 //
 class ThreadsSMRSupport : AllStatic {
   // The coordination between ThreadsSMRSupport::release_stable_list() and
-  // ThreadsSMRSupport::smr_delete() uses the smr_delete_lock in order to
+  // ThreadsSMRSupport::smr_delete() uses the delete_lock in order to
   // reduce the traffic on the Threads_lock.
-  static Monitor*              _smr_delete_lock;
+  static Monitor*              _delete_lock;
   // The '_cnt', '_max' and '_times" fields are enabled via
   // -XX:+EnableThreadSMRStatistics (see thread.cpp for a
   // description about each field):
-  static uint                  _smr_delete_lock_wait_cnt;
-  static uint                  _smr_delete_lock_wait_max;
-  // The smr_delete_notify flag is used for proper double-check
-  // locking in order to reduce the traffic on the smr_delete_lock.
-  static volatile uint         _smr_delete_notify;
-  static volatile uint         _smr_deleted_thread_cnt;
-  static volatile uint         _smr_deleted_thread_time_max;
-  static volatile uint         _smr_deleted_thread_times;
-  static ThreadsList* volatile _smr_java_thread_list;
-  static uint64_t              _smr_java_thread_list_alloc_cnt;
-  static uint64_t              _smr_java_thread_list_free_cnt;
-  static uint                  _smr_java_thread_list_max;
-  static uint                  _smr_nested_thread_list_max;
-  static volatile uint         _smr_tlh_cnt;
-  static volatile uint         _smr_tlh_time_max;
-  static volatile uint         _smr_tlh_times;
-  static ThreadsList*          _smr_to_delete_list;
-  static uint                  _smr_to_delete_list_cnt;
-  static uint                  _smr_to_delete_list_max;
+  static uint                  _delete_lock_wait_cnt;
+  static uint                  _delete_lock_wait_max;
+  // The delete_notify flag is used for proper double-check
+  // locking in order to reduce the traffic on the system wide
+  // Thread-SMR delete_lock.
+  static volatile uint         _delete_notify;
+  static volatile uint         _deleted_thread_cnt;
+  static volatile uint         _deleted_thread_time_max;
+  static volatile uint         _deleted_thread_times;
+  static ThreadsList* volatile _java_thread_list;
+  static uint64_t              _java_thread_list_alloc_cnt;
+  static uint64_t              _java_thread_list_free_cnt;
+  static uint                  _java_thread_list_max;
+  static uint                  _nested_thread_list_max;
+  static volatile uint         _tlh_cnt;
+  static volatile uint         _tlh_time_max;
+  static volatile uint         _tlh_times;
+  static ThreadsList*          _to_delete_list;
+  static uint                  _to_delete_list_cnt;
+  static uint                  _to_delete_list_max;
 
   static ThreadsList *acquire_stable_list_fast_path(Thread *self);
   static ThreadsList *acquire_stable_list_nested_path(Thread *self);
-  static void add_smr_deleted_thread_times(uint add_value);
-  static void add_smr_tlh_times(uint add_value);
-  static void clear_smr_delete_notify();
-  static void inc_smr_deleted_thread_cnt();
-  static void inc_smr_java_thread_list_alloc_cnt();
-  static void inc_smr_tlh_cnt();
+  static void add_deleted_thread_times(uint add_value);
+  static void add_tlh_times(uint add_value);
+  static void clear_delete_notify();
+  static Monitor* delete_lock() { return _delete_lock; }
+  static bool delete_notify();
+  static void free_list(ThreadsList* threads);
+  static void inc_deleted_thread_cnt();
+  static void inc_java_thread_list_alloc_cnt();
+  static void inc_tlh_cnt();
   static bool is_a_protected_JavaThread(JavaThread *thread);
   static void release_stable_list_fast_path(Thread *self);
   static void release_stable_list_nested_path(Thread *self);
   static void release_stable_list_wake_up(char *log_str);
-  static void set_smr_delete_notify();
-  static Monitor* smr_delete_lock() { return _smr_delete_lock; }
-  static bool smr_delete_notify();
-  static void smr_free_list(ThreadsList* threads);
-  static void update_smr_deleted_thread_time_max(uint new_value);
-  static void update_smr_java_thread_list_max(uint new_value);
-  static void update_smr_tlh_time_max(uint new_value);
-  static ThreadsList* xchg_smr_java_thread_list(ThreadsList* new_list);
+  static void set_delete_notify();
+  static void update_deleted_thread_time_max(uint new_value);
+  static void update_java_thread_list_max(uint new_value);
+  static void update_tlh_time_max(uint new_value);
+  static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
 
  public:
   static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
   static void add_thread(JavaThread *thread);
-  static ThreadsList* get_smr_java_thread_list();
+  static ThreadsList* get_java_thread_list();
   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
   static void release_stable_list(Thread *self);
   static void remove_thread(JavaThread *thread);
   static void smr_delete(JavaThread *thread);
-  static void update_smr_tlh_stats(uint millis);
+  static void update_tlh_stats(uint millis);
 
   // Logging and printing support:
-  static void log_smr_statistics();
-  static void print_smr_info_elements_on(outputStream* st, ThreadsList* t_list);
-  static void print_smr_info_on(outputStream* st);
+  static void log_statistics();
+  static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
+  static void print_info_on(outputStream* st);
 };
 
 // A fast list of JavaThreads.
--- a/src/hotspot/share/runtime/threadSMR.inline.hpp	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/hotspot/share/runtime/threadSMR.inline.hpp	Wed Dec 20 20:55:07 2017 +0100
@@ -53,24 +53,24 @@
 }
 
 // These three inlines are private to ThreadsSMRSupport, but
-// they are called by public inline update_smr_tlh_stats() below:
+// they are called by public inline update_tlh_stats() below:
 
-inline void ThreadsSMRSupport::add_smr_tlh_times(uint add_value) {
-  Atomic::add(add_value, &_smr_tlh_times);
+inline void ThreadsSMRSupport::add_tlh_times(uint add_value) {
+  Atomic::add(add_value, &_tlh_times);
 }
 
-inline void ThreadsSMRSupport::inc_smr_tlh_cnt() {
-  Atomic::inc(&_smr_tlh_cnt);
+inline void ThreadsSMRSupport::inc_tlh_cnt() {
+  Atomic::inc(&_tlh_cnt);
 }
 
-inline void ThreadsSMRSupport::update_smr_tlh_time_max(uint new_value) {
+inline void ThreadsSMRSupport::update_tlh_time_max(uint new_value) {
   while (true) {
-    uint cur_value = _smr_tlh_time_max;
+    uint cur_value = _tlh_time_max;
     if (new_value <= cur_value) {
       // No need to update max value so we're done.
       break;
     }
-    if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
+    if (Atomic::cmpxchg(new_value, &_tlh_time_max, cur_value) == cur_value) {
       // Updated max value so we're done. Otherwise try it all again.
       break;
     }
@@ -85,8 +85,8 @@
   return ret;
 }
 
-inline ThreadsList* ThreadsSMRSupport::get_smr_java_thread_list() {
-  return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
+inline ThreadsList* ThreadsSMRSupport::get_java_thread_list() {
+  return (ThreadsList*)OrderAccess::load_acquire(&_java_thread_list);
 }
 
 inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
@@ -94,10 +94,10 @@
   return is_a_protected_JavaThread(thread);
 }
 
-inline void ThreadsSMRSupport::update_smr_tlh_stats(uint millis) {
-  ThreadsSMRSupport::inc_smr_tlh_cnt();
-  ThreadsSMRSupport::add_smr_tlh_times(millis);
-  ThreadsSMRSupport::update_smr_tlh_time_max(millis);
+inline void ThreadsSMRSupport::update_tlh_stats(uint millis) {
+  ThreadsSMRSupport::inc_tlh_cnt();
+  ThreadsSMRSupport::add_tlh_times(millis);
+  ThreadsSMRSupport::update_tlh_time_max(millis);
 }
 
 #endif // SHARE_VM_RUNTIME_THREADSMR_INLINE_HPP
--- a/src/java.base/share/native/libjava/System.c	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/java.base/share/native/libjava/System.c	Wed Dec 20 20:55:07 2017 +0100
@@ -186,6 +186,9 @@
     jobject ret = NULL;
     jstring jVMVal = NULL;
 
+    if ((*env)->EnsureLocalCapacity(env, 50) < 0) {
+        return NULL;
+    }
     sprops = GetJavaProperties(env);
     CHECK_NULL_RETURN(sprops, NULL);
 
--- a/src/jdk.internal.vm.compiler/.mx.graal/suite.py	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/.mx.graal/suite.py	Wed Dec 20 20:55:07 2017 +0100
@@ -107,7 +107,6 @@
       "subDir" : "share/classes",
       "dependencies" : ["JVMCI_SERVICES", "JVMCI_API", "org.graalvm.util"],
       "sourceDirs" : ["src"],
-      "dependencies" : ["org.graalvm.util"],
       "checkstyle" : "org.graalvm.compiler.graph",
       "uses" : ["org.graalvm.compiler.options.OptionDescriptors"],
       "javaCompliance" : "1.8",
@@ -148,6 +147,7 @@
       "dependencies" : [
         "JVMCI_API",
         "org.graalvm.compiler.serviceprovider",
+        "org.graalvm.graphio",
         "org.graalvm.compiler.options"
       ],
       "annotationProcessors" : ["GRAAL_OPTIONS_PROCESSOR"],
@@ -291,7 +291,6 @@
       "subDir" : "share/classes",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "org.graalvm.compiler.core.aarch64",
         "org.graalvm.compiler.hotspot",
         "org.graalvm.compiler.replacements.aarch64",
       ],
@@ -435,6 +434,7 @@
         "mx:JUNIT",
         "org.graalvm.compiler.api.test",
         "org.graalvm.compiler.graph",
+        "org.graalvm.graphio",
       ],
       "annotationProcessors" : ["GRAAL_NODEINFO_PROCESSOR"],
       "javaCompliance" : "1.8",
@@ -945,6 +945,7 @@
       "dependencies" : [
         "org.graalvm.compiler.lir.jtt",
         "org.graalvm.compiler.lir.amd64",
+        "org.graalvm.compiler.core.amd64",
         "JVMCI_HOTSPOT"
       ],
       "checkstyle" : "org.graalvm.compiler.graph",
@@ -1019,7 +1020,6 @@
       "subDir" : "share/classes",
       "sourceDirs" : ["src"],
       "dependencies" : [
-        "org.graalvm.graphio",
         "org.graalvm.compiler.core",
         "org.graalvm.compiler.java",
       ],
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64LIRKindTool.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64LIRKindTool.java	Wed Dec 20 20:55:07 2017 +0100
@@ -68,7 +68,7 @@
 
     @Override
     public LIRKind getNarrowOopKind() {
-        return LIRKind.reference(AArch64Kind.DWORD);
+        return LIRKind.compressedReference(AArch64Kind.DWORD);
     }
 
     @Override
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/LIRKind.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/LIRKind.java	Wed Dec 20 20:55:07 2017 +0100
@@ -33,8 +33,9 @@
 
 /**
  * Represents the type of values in the LIR. It is composed of a {@link PlatformKind} that gives the
- * low level representation of the value, and a {@link #referenceMask} that describes the location
- * of object references in the value, and optionally a {@link #derivedReferenceBase}.
+ * low level representation of the value, a {@link #referenceMask} that describes the location of
+ * object references in the value, a {@link #referenceCompressionMask} that indicates which of these
+ * references are compressed references, and for derived references a {@link #derivedReferenceBase}.
  *
  * <h2>Constructing {@link LIRKind} instances</h2>
  *
@@ -52,7 +53,7 @@
  * compare-and-swap. For convert operations, {@link LIRKind#combine} should be used.
  * <p>
  * If it is known that the result will be a reference (e.g. pointer arithmetic where the end result
- * is a valid oop), {@link LIRKind#reference} should be used.
+ * is a valid oop), {@link #reference} or {@link LIRKind#compressedReference} should be used.
  * <p>
  * If it is known that the result will neither be a reference nor be derived from a reference,
  * {@link LIRKind#value} can be used. If the operation producing this value has inputs, this is very
@@ -64,19 +65,28 @@
  */
 public final class LIRKind extends ValueKind<LIRKind> {
 
+    /**
+     * The location of object references in the value. If the value is a vector type, each bit
+     * represents one component of the vector.
+     */
     private final int referenceMask;
 
+    /** Mask with 1-bits indicating which references in {@link #referenceMask} are compressed. */
+    private final int referenceCompressionMask;
+
     private AllocatableValue derivedReferenceBase;
 
     private static final int UNKNOWN_REFERENCE = -1;
 
     public static final LIRKind Illegal = unknownReference(ValueKind.Illegal.getPlatformKind());
 
-    private LIRKind(PlatformKind platformKind, int referenceMask, AllocatableValue derivedReferenceBase) {
+    private LIRKind(PlatformKind platformKind, int referenceMask, int referenceCompressionMask, AllocatableValue derivedReferenceBase) {
         super(platformKind);
         this.referenceMask = referenceMask;
+        this.referenceCompressionMask = referenceCompressionMask;
         this.derivedReferenceBase = derivedReferenceBase;
 
+        assert this.referenceCompressionMask == 0 || this.referenceMask == this.referenceCompressionMask : "mixing compressed and uncompressed references is untested";
         assert derivedReferenceBase == null || !derivedReferenceBase.getValueKind(LIRKind.class).isDerivedReference() : "derived reference can't have another derived reference as base";
     }
 
@@ -86,15 +96,23 @@
      * reference. Otherwise, {@link #combine(Value...)} should be used instead.
      */
     public static LIRKind value(PlatformKind platformKind) {
-        return new LIRKind(platformKind, 0, null);
+        return new LIRKind(platformKind, 0, 0, null);
     }
 
     /**
-     * Create a {@link LIRKind} of type {@code platformKind} that contains a single tracked oop
-     * reference.
+     * Create a {@link LIRKind} of type {@code platformKind} that contains a single, tracked,
+     * uncompressed oop reference.
      */
     public static LIRKind reference(PlatformKind platformKind) {
-        return derivedReference(platformKind, null);
+        return derivedReference(platformKind, null, false);
+    }
+
+    /**
+     * Create a {@link LIRKind} of type {@code platformKind} that contains a single, tracked,
+     * compressed oop reference.
+     */
+    public static LIRKind compressedReference(PlatformKind platformKind) {
+        return derivedReference(platformKind, null, true);
     }
 
     /**
@@ -112,10 +130,12 @@
     /**
      * Create a {@link LIRKind} of type {@code platformKind} that contains a derived reference.
      */
-    public static LIRKind derivedReference(PlatformKind platformKind, AllocatableValue base) {
+    public static LIRKind derivedReference(PlatformKind platformKind, AllocatableValue base, boolean compressed) {
         int length = platformKind.getVectorLength();
         assert 0 < length && length < 32 : "vector of " + length + " references not supported";
-        return new LIRKind(platformKind, (1 << length) - 1, base);
+        int referenceMask = (1 << length) - 1;
+        int referenceCompressionMask = (compressed ? referenceMask : 0);
+        return new LIRKind(platformKind, referenceMask, referenceCompressionMask, base);
     }
 
     /**
@@ -125,7 +145,7 @@
      * used instead to automatically propagate this information.
      */
     public static LIRKind unknownReference(PlatformKind platformKind) {
-        return new LIRKind(platformKind, UNKNOWN_REFERENCE, null);
+        return new LIRKind(platformKind, UNKNOWN_REFERENCE, UNKNOWN_REFERENCE, null);
     }
 
     /**
@@ -139,9 +159,9 @@
             return makeUnknownReference();
         } else {
             if (isValue()) {
-                return derivedReference(getPlatformKind(), base);
+                return derivedReference(getPlatformKind(), base, false);
             } else {
-                return new LIRKind(getPlatformKind(), referenceMask, base);
+                return new LIRKind(getPlatformKind(), referenceMask, referenceCompressionMask, base);
             }
         }
     }
@@ -240,7 +260,7 @@
             return mergeKind;
         }
         /* {@code mergeKind} is a reference. */
-        if (mergeKind.referenceMask != inputKind.referenceMask) {
+        if (mergeKind.referenceMask != inputKind.referenceMask || mergeKind.referenceCompressionMask != inputKind.referenceCompressionMask) {
             /*
              * Reference masks do not match so the result can only be an unknown reference.
              */
@@ -284,9 +304,11 @@
         } else {
             // reference type
             int newLength = Math.min(32, newPlatformKind.getVectorLength());
-            int newReferenceMask = referenceMask & (0xFFFFFFFF >>> (32 - newLength));
+            int lengthMask = 0xFFFFFFFF >>> (32 - newLength);
+            int newReferenceMask = referenceMask & lengthMask;
+            int newReferenceCompressionMask = referenceCompressionMask & lengthMask;
             assert newReferenceMask != UNKNOWN_REFERENCE;
-            return new LIRKind(newPlatformKind, newReferenceMask, derivedReferenceBase);
+            return new LIRKind(newPlatformKind, newReferenceMask, newReferenceCompressionMask, derivedReferenceBase);
         }
     }
 
@@ -308,12 +330,14 @@
 
             // repeat reference mask to fill new kind
             int newReferenceMask = 0;
+            int newReferenceCompressionMask = 0;
             for (int i = 0; i < newLength; i += getPlatformKind().getVectorLength()) {
                 newReferenceMask |= referenceMask << i;
+                newReferenceCompressionMask |= referenceCompressionMask << i;
             }
 
             assert newReferenceMask != UNKNOWN_REFERENCE;
-            return new LIRKind(newPlatformKind, newReferenceMask, derivedReferenceBase);
+            return new LIRKind(newPlatformKind, newReferenceMask, newReferenceCompressionMask, derivedReferenceBase);
         }
     }
 
@@ -322,7 +346,7 @@
      * {@link LIRKind#unknownReference}.
      */
     public LIRKind makeUnknownReference() {
-        return new LIRKind(getPlatformKind(), UNKNOWN_REFERENCE, null);
+        return new LIRKind(getPlatformKind(), UNKNOWN_REFERENCE, UNKNOWN_REFERENCE, null);
     }
 
     /**
@@ -385,6 +409,17 @@
     }
 
     /**
+     * Check whether the {@code idx}th part of this value is a <b>compressed</b> reference.
+     *
+     * @param idx The index into the vector if this is a vector kind. Must be 0 if this is a scalar
+     *            kind.
+     */
+    public boolean isCompressedReference(int idx) {
+        assert 0 <= idx && idx < getPlatformKind().getVectorLength() : "invalid index " + idx + " in " + this;
+        return !isUnknownReference() && (referenceCompressionMask & (1 << idx)) != 0;
+    }
+
+    /**
      * Check whether this kind is a value type that doesn't need to be tracked at safepoints.
      */
     public boolean isValue() {
@@ -432,6 +467,7 @@
         result = prime * result + ((getPlatformKind() == null) ? 0 : getPlatformKind().hashCode());
         result = prime * result + ((getDerivedReferenceBase() == null) ? 0 : getDerivedReferenceBase().hashCode());
         result = prime * result + referenceMask;
+        result = prime * result + referenceCompressionMask;
         return result;
     }
 
@@ -445,7 +481,7 @@
         }
 
         LIRKind other = (LIRKind) obj;
-        if (getPlatformKind() != other.getPlatformKind() || referenceMask != other.referenceMask) {
+        if (getPlatformKind() != other.getPlatformKind() || referenceMask != other.referenceMask || referenceCompressionMask != other.referenceCompressionMask) {
             return false;
         }
         if (isDerivedReference()) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/CompilationAlarm.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/util/CompilationAlarm.java	Wed Dec 20 20:55:07 2017 +0100
@@ -22,6 +22,7 @@
  */
 package org.graalvm.compiler.core.common.util;
 
+import org.graalvm.compiler.debug.Assertions;
 import org.graalvm.compiler.options.Option;
 import org.graalvm.compiler.options.OptionKey;
 import org.graalvm.compiler.options.OptionType;
@@ -34,7 +35,8 @@
 
     public static class Options {
         // @formatter:off
-        @Option(help = "Time limit in seconds before a compilation expires (0 to disable the limit).", type = OptionType.Debug)
+        @Option(help = "Time limit in seconds before a compilation expires (0 to disable the limit). " +
+                       "The compilation alarm will be implicitly disabled if assertions are enabled.", type = OptionType.Debug)
         public static final OptionKey<Integer> CompilationExpirationPeriod = new OptionKey<>(300);
         // @formatter:on
     }
@@ -85,15 +87,16 @@
 
     /**
      * Starts an alarm for setting a time limit on a compilation if there isn't already an active
-     * alarm and {@link CompilationAlarm.Options#CompilationExpirationPeriod}{@code > 0}. The
-     * returned value can be used in a try-with-resource statement to disable the alarm once the
-     * compilation is finished.
+     * alarm, if assertions are disabled and
+     * {@link CompilationAlarm.Options#CompilationExpirationPeriod}{@code > 0}. The returned value
+     * can be used in a try-with-resource statement to disable the alarm once the compilation is
+     * finished.
      *
      * @return a {@link CompilationAlarm} if there was no current alarm for the calling thread
      *         before this call otherwise {@code null}
      */
     public static CompilationAlarm trackCompilationPeriod(OptionValues options) {
-        int period = Options.CompilationExpirationPeriod.getValue(options);
+        int period = Assertions.assertionsEnabled() ? 0 : Options.CompilationExpirationPeriod.getValue(options);
         if (period > 0) {
             CompilationAlarm current = currentAlarm.get();
             if (current == null) {
@@ -105,4 +108,5 @@
         }
         return null;
     }
+
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.sparc/src/org/graalvm/compiler/core/sparc/SPARCLIRKindTool.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.sparc/src/org/graalvm/compiler/core/sparc/SPARCLIRKindTool.java	Wed Dec 20 20:55:07 2017 +0100
@@ -68,7 +68,7 @@
 
     @Override
     public LIRKind getNarrowOopKind() {
-        return LIRKind.reference(SPARCKind.WORD);
+        return LIRKind.compressedReference(SPARCKind.WORD);
     }
 
     @Override
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CooperativePhaseTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.graalvm.compiler.core.test;
-
-import static org.graalvm.compiler.core.common.util.CompilationAlarm.Options.CompilationExpirationPeriod;
-
-import org.graalvm.compiler.core.common.RetryableBailoutException;
-import org.graalvm.compiler.core.common.util.CompilationAlarm;
-import org.graalvm.compiler.debug.GraalError;
-import org.graalvm.compiler.nodes.StructuredGraph;
-import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
-import org.graalvm.compiler.options.OptionValues;
-import org.graalvm.compiler.phases.Phase;
-import org.junit.Test;
-
-public class CooperativePhaseTest extends GraalCompilerTest {
-
-    public static void snippet() {
-        // dummy snippet
-    }
-
-    private static class CooperativePhase extends Phase {
-
-        @Override
-        protected void run(StructuredGraph graph) {
-            CompilationAlarm compilationAlarm = CompilationAlarm.current();
-            while (true) {
-                sleep(200);
-                if (compilationAlarm.hasExpired()) {
-                    return;
-                }
-            }
-        }
-
-    }
-
-    private static class UnCooperativePhase extends Phase {
-
-        @Override
-        protected void run(StructuredGraph graph) {
-            CompilationAlarm compilationAlarm = CompilationAlarm.current();
-            while (true) {
-                sleep(200);
-                if (compilationAlarm.hasExpired()) {
-                    throw new RetryableBailoutException("Expiring...");
-                }
-            }
-        }
-
-    }
-
-    private static class PartiallyCooperativePhase extends Phase {
-
-        @Override
-        protected void run(StructuredGraph graph) {
-            CompilationAlarm compilationAlarm = CompilationAlarm.current();
-            for (int i = 0; i < 10; i++) {
-                sleep(200);
-                if (compilationAlarm.hasExpired()) {
-                    throw new RuntimeException("Phase must not exit in the timeout path");
-                }
-            }
-        }
-    }
-
-    private static class CooperativePhaseWithoutAlarm extends Phase {
-
-        @Override
-        protected void run(StructuredGraph graph) {
-            CompilationAlarm compilationAlarm = CompilationAlarm.current();
-            if (compilationAlarm.hasExpired()) {
-                throw new RuntimeException("Phase must not exit in the timeout path");
-            }
-        }
-    }
-
-    private static void sleep(long millis) {
-        try {
-            Thread.sleep(millis);
-        } catch (InterruptedException e) {
-            GraalError.shouldNotReachHere(e.getCause());
-        }
-    }
-
-    @Test(timeout = 60_000)
-    @SuppressWarnings("try")
-    public void test01() {
-        initializeForTimeout();
-        OptionValues initialOptions = getInitialOptions();
-        OptionValues options = new OptionValues(initialOptions, CompilationExpirationPeriod, 1/* sec */);
-        try (CompilationAlarm c1 = CompilationAlarm.trackCompilationPeriod(options)) {
-            StructuredGraph g = parseEager("snippet", AllowAssumptions.NO, options);
-            new CooperativePhase().apply(g);
-        }
-    }
-
-    @Test(expected = RetryableBailoutException.class, timeout = 60_000)
-    @SuppressWarnings("try")
-    public void test02() {
-        initializeForTimeout();
-        OptionValues initialOptions = getInitialOptions();
-        OptionValues options = new OptionValues(initialOptions, CompilationExpirationPeriod, 1/* sec */);
-        try (CompilationAlarm c1 = CompilationAlarm.trackCompilationPeriod(options)) {
-            StructuredGraph g = parseEager("snippet", AllowAssumptions.NO, options);
-            new UnCooperativePhase().apply(g);
-        }
-    }
-
-    @Test(timeout = 60_000)
-    @SuppressWarnings("try")
-    public void test03() {
-        initializeForTimeout();
-        // 0 disables alarm utility
-        OptionValues initialOptions = getInitialOptions();
-        OptionValues options = new OptionValues(initialOptions, CompilationExpirationPeriod, 0);
-        try (CompilationAlarm c1 = CompilationAlarm.trackCompilationPeriod(options)) {
-            StructuredGraph g = parseEager("snippet", AllowAssumptions.NO, options);
-            new PartiallyCooperativePhase().apply(g);
-        }
-    }
-
-    @Test(timeout = 60_000)
-    @SuppressWarnings("try")
-    public void test04() {
-        initializeForTimeout();
-        StructuredGraph g = parseEager("snippet", AllowAssumptions.NO);
-        new CooperativePhaseWithoutAlarm().apply(g);
-    }
-}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CountedLoopTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/CountedLoopTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -264,7 +264,7 @@
     }
 
     @Override
-    protected boolean checkMidTierGraph(StructuredGraph graph) {
+    protected boolean checkHighTierGraph(StructuredGraph graph) {
         LoopsData loops = new LoopsData(graph);
         loops.detectedCountedLoops();
         for (IVPropertyNode node : graph.getNodes().filter(IVPropertyNode.class)) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/Assertions.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/Assertions.java	Wed Dec 20 20:55:07 2017 +0100
@@ -54,8 +54,8 @@
     // @formatter:off
     public static class Options {
 
-        @Option(help = "Enable expensive assertions. (Require normal assertions enabled)", type = OptionType.Debug)
-        public static final OptionKey<Boolean> DetailedAsserts = new OptionKey<>(true);
+        @Option(help = "Enable expensive assertions if normal assertions (i.e. -ea or -esa) are enabled.", type = OptionType.Debug)
+        public static final OptionKey<Boolean> DetailedAsserts = new OptionKey<>(false);
 
     }
     // @formatter:on
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Graph.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/Graph.java	Wed Dec 20 20:55:07 2017 +0100
@@ -472,6 +472,11 @@
         }
     }
 
+    public <T extends Node> T addWithoutUniqueWithInputs(T node) {
+        addInputs(node);
+        return addHelper(node);
+    }
+
     private final class AddInputsFilter extends Node.EdgeVisitor {
 
         @Override
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotForeignCallsProvider.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotForeignCallsProvider.java	Wed Dec 20 20:55:07 2017 +0100
@@ -30,6 +30,7 @@
 import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.RegisterEffect.PRESERVES_REGISTERS;
 import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF;
 import static org.graalvm.compiler.hotspot.replacements.CRC32Substitutions.UPDATE_BYTES_CRC32;
+import static org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions.UPDATE_BYTES_CRC32C;
 import static org.graalvm.word.LocationIdentity.any;
 
 import org.graalvm.compiler.core.common.LIRKind;
@@ -79,6 +80,9 @@
         if (config.useCRC32Intrinsics) {
             registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
         }
+        if (config.useCRC32CIntrinsics) {
+            registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
+        }
 
         super.initialize(providers, options);
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java	Wed Dec 20 20:55:07 2017 +0100
@@ -30,8 +30,8 @@
 
 import org.graalvm.compiler.asm.Label;
 import org.graalvm.compiler.asm.aarch64.AArch64Address.AddressingMode;
+import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag;
 import org.graalvm.compiler.asm.aarch64.AArch64Assembler.PrefetchMode;
-import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag;
 import org.graalvm.compiler.core.aarch64.AArch64ArithmeticLIRGenerator;
 import org.graalvm.compiler.core.aarch64.AArch64LIRGenerator;
 import org.graalvm.compiler.core.aarch64.AArch64LIRKindTool;
@@ -202,7 +202,7 @@
         assert inputKind.getPlatformKind() == AArch64Kind.QWORD;
         if (inputKind.isReference(0)) {
             // oop
-            Variable result = newVariable(LIRKind.reference(AArch64Kind.DWORD));
+            Variable result = newVariable(LIRKind.compressedReference(AArch64Kind.DWORD));
             append(new AArch64HotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
             return result;
         } else {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java	Wed Dec 20 20:55:07 2017 +0100
@@ -33,6 +33,7 @@
 import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF;
 import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF_NOFP;
 import static org.graalvm.compiler.hotspot.replacements.CRC32Substitutions.UPDATE_BYTES_CRC32;
+import static org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions.UPDATE_BYTES_CRC32C;
 import static org.graalvm.word.LocationIdentity.any;
 
 import org.graalvm.compiler.core.common.LIRKind;
@@ -99,6 +100,9 @@
             // This stub does callee saving
             registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
         }
+        if (config.useCRC32CIntrinsics) {
+            registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
+        }
 
         super.initialize(providers, options);
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRKindTool.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotLIRKindTool.java	Wed Dec 20 20:55:07 2017 +0100
@@ -22,14 +22,15 @@
  */
 package org.graalvm.compiler.hotspot.amd64;
 
-import jdk.vm.ci.amd64.AMD64Kind;
 import org.graalvm.compiler.core.amd64.AMD64LIRKindTool;
 import org.graalvm.compiler.core.common.LIRKind;
 
+import jdk.vm.ci.amd64.AMD64Kind;
+
 public class AMD64HotSpotLIRKindTool extends AMD64LIRKindTool {
     @Override
     public LIRKind getNarrowOopKind() {
-        return LIRKind.reference(AMD64Kind.DWORD);
+        return LIRKind.compressedReference(AMD64Kind.DWORD);
     }
 
     @Override
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc/SPARCHotSpotForeignCallsProvider.java	Wed Dec 20 20:55:07 2017 +0100
@@ -34,6 +34,7 @@
 import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.RegisterEffect.PRESERVES_REGISTERS;
 import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF_NOFP;
 import static org.graalvm.compiler.hotspot.replacements.CRC32Substitutions.UPDATE_BYTES_CRC32;
+import static org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions.UPDATE_BYTES_CRC32C;
 import static org.graalvm.word.LocationIdentity.any;
 
 import org.graalvm.compiler.core.common.LIRKind;
@@ -87,6 +88,9 @@
             // This stub does callee saving
             registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
         }
+        if (config.useCRC32CIntrinsics) {
+            registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
+        }
 
         super.initialize(providers, options);
     }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Wed Dec 20 20:55:07 2017 +0100
@@ -307,7 +307,7 @@
         assert inputKind.getPlatformKind() == XWORD : inputKind;
         if (inputKind.isReference(0)) {
             // oop
-            Variable result = newVariable(LIRKind.reference(WORD));
+            Variable result = newVariable(LIRKind.compressedReference(WORD));
             append(new SPARCHotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
             return result;
         } else {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CRC32CSubstitutionsTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.graalvm.compiler.hotspot.test;
+
+import java.io.DataInputStream;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.zip.Checksum;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+import org.graalvm.compiler.test.GraalTest;
+import org.graalvm.compiler.core.test.GraalCompilerTest;
+
+import org.junit.Test;
+
+import static org.junit.Assume.assumeFalse;
+
+/**
+ * Tests compiled calls to {@link java.util.zip.CRC32C}.
+ */
+@SuppressWarnings("javadoc")
+public class CRC32CSubstitutionsTest extends GraalCompilerTest {
+
+    public static long updateBytes(byte[] input, int offset, int end) throws Throwable {
+        Class<?> crcClass = Class.forName("java.util.zip.CRC32C");
+        MethodHandle newMH = MethodHandles.publicLookup().findConstructor(crcClass, MethodType.methodType(void.class));
+        Checksum crc = (Checksum) newMH.invoke();
+        crc.update(input, offset, end);
+        return crc.getValue();
+    }
+
+    @Test
+    public void test1() throws Throwable {
+        assumeFalse(GraalTest.Java8OrEarlier);
+        String classfileName = CRC32CSubstitutionsTest.class.getSimpleName().replace('.', '/') + ".class";
+        InputStream s = CRC32CSubstitutionsTest.class.getResourceAsStream(classfileName);
+        byte[] buf = new byte[s.available()];
+        new DataInputStream(s).readFully(buf);
+        int end = buf.length;
+        for (int offset = 0; offset < buf.length; offset++) {
+            test("updateBytes", buf, offset, end);
+        }
+    }
+
+    public static long updateByteBuffer(ByteBuffer buffer) throws Throwable {
+        Class<?> crcClass = Class.forName("java.util.zip.CRC32C");
+        MethodHandle newMH = MethodHandles.publicLookup().findConstructor(crcClass, MethodType.methodType(void.class));
+        MethodHandle updateMH = MethodHandles.publicLookup().findVirtual(crcClass, "update", MethodType.methodType(void.class, ByteBuffer.class));
+        Checksum crc = (Checksum) newMH.invoke();
+        buffer.rewind();
+        updateMH.invokeExact(crc, buffer); // Checksum.update(ByteBuffer) is also available since 9
+        return crc.getValue();
+    }
+
+    @Test
+    public void test2() throws Throwable {
+        assumeFalse(GraalTest.Java8OrEarlier);
+        String classfileName = CRC32CSubstitutionsTest.class.getSimpleName().replace('.', '/') + ".class";
+        InputStream s = CRC32CSubstitutionsTest.class.getResourceAsStream(classfileName);
+        byte[] buf = new byte[s.available()];
+        new DataInputStream(s).readFully(buf);
+
+        ByteBuffer directBuf = ByteBuffer.allocateDirect(buf.length);
+        directBuf.put(buf);
+        ByteBuffer heapBuf = ByteBuffer.wrap(buf);
+
+        test("updateByteBuffer", directBuf);
+        test("updateByteBuffer", heapBuf);
+    }
+
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java	Wed Dec 20 20:55:07 2017 +0100
@@ -466,6 +466,13 @@
             }
         }
 
+        // CRC32C intrinsics
+        if (!config.useCRC32CIntrinsics) {
+            add(IGNORE,
+                            "java/util/zip/CRC32C.updateBytes(I[BII)I",
+                            "java/util/zip/CRC32C.updateDirectByteBuffer(IJII)I");
+        }
+
         // AES intrinsics
         if (!config.useAESIntrinsics) {
             if (isJDK9OrHigher()) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/JVMCIInfopointErrorTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/JVMCIInfopointErrorTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -33,9 +33,9 @@
 import org.graalvm.compiler.core.common.LIRKind;
 import org.graalvm.compiler.core.common.type.StampFactory;
 import org.graalvm.compiler.core.test.GraalCompilerTest;
-import org.graalvm.compiler.debug.DebugHandlersFactory;
 import org.graalvm.compiler.debug.DebugContext;
 import org.graalvm.compiler.debug.DebugContext.Scope;
+import org.graalvm.compiler.debug.DebugHandlersFactory;
 import org.graalvm.compiler.graph.NodeClass;
 import org.graalvm.compiler.hotspot.HotSpotCompiledCodeBuilder;
 import org.graalvm.compiler.lir.FullInfopointOp;
@@ -150,7 +150,7 @@
         codeCache.addCode(method, compiledCode, null, null);
     }
 
-    @Test(expected = JVMCIError.class)
+    @Test(expected = Error.class)
     public void testInvalidShortOop() {
         test((tool, state, safepoint) -> {
             PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
@@ -163,14 +163,14 @@
         });
     }
 
-    @Test(expected = JVMCIError.class)
+    @Test(expected = Error.class)
     public void testInvalidShortDerivedOop() {
         test((tool, state, safepoint) -> {
             Variable baseOop = tool.newVariable(LIRKind.fromJavaKind(tool.target().arch, JavaKind.Object));
             tool.append(new ValueDef(baseOop));
 
             PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
-            LIRKind lirKind = LIRKind.derivedReference(kind, baseOop);
+            LIRKind lirKind = LIRKind.derivedReference(kind, baseOop, false);
 
             Variable var = tool.newVariable(lirKind);
             tool.append(new ValueDef(var));
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java	Wed Dec 20 20:55:07 2017 +0100
@@ -165,6 +165,7 @@
     public final boolean usePopCountInstruction = getFlag("UsePopCountInstruction", Boolean.class);
     public final boolean useAESIntrinsics = getFlag("UseAESIntrinsics", Boolean.class);
     public final boolean useCRC32Intrinsics = getFlag("UseCRC32Intrinsics", Boolean.class);
+    public final boolean useCRC32CIntrinsics = isJDK8 ? false : getFlag("UseCRC32CIntrinsics", Boolean.class);
     public final boolean threadLocalHandshakes = getFlag("ThreadLocalHandshakes", Boolean.class, false);
 
     private final boolean useMultiplyToLenIntrinsic = getFlag("UseMultiplyToLenIntrinsic", Boolean.class);
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotHostBackend.java	Wed Dec 20 20:55:07 2017 +0100
@@ -45,6 +45,7 @@
 import jdk.vm.ci.common.InitTimer;
 import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
+import jdk.vm.ci.meta.JavaKind;
 import jdk.vm.ci.meta.JavaType;
 import jdk.vm.ci.runtime.JVMCICompiler;
 
@@ -142,7 +143,8 @@
 
     @Override
     public ReferenceMapBuilder newReferenceMapBuilder(int totalFrameSize) {
-        return new HotSpotReferenceMapBuilder(totalFrameSize, config.maxOopMapStackOffset);
+        int uncompressedReferenceSize = getTarget().arch.getPlatformKind(JavaKind.Object).getSizeInBytes();
+        return new HotSpotReferenceMapBuilder(totalFrameSize, config.maxOopMapStackOffset, uncompressedReferenceSize);
     }
 
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotReferenceMapBuilder.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotReferenceMapBuilder.java	Wed Dec 20 20:55:07 2017 +0100
@@ -22,15 +22,15 @@
  */
 package org.graalvm.compiler.hotspot;
 
-import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
 import static jdk.vm.ci.code.ValueUtil.asRegister;
 import static jdk.vm.ci.code.ValueUtil.asStackSlot;
 import static jdk.vm.ci.code.ValueUtil.isRegister;
+import static org.graalvm.compiler.lir.LIRValueUtil.isJavaConstant;
 
 import java.util.ArrayList;
 
+import org.graalvm.compiler.core.common.LIRKind;
 import org.graalvm.compiler.core.common.PermanentBailoutException;
-import org.graalvm.compiler.core.common.LIRKind;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.lir.LIRFrameState;
 import org.graalvm.compiler.lir.Variable;
@@ -52,8 +52,10 @@
 
     private final int totalFrameSize;
     private final int maxOopMapStackOffset;
+    private final int uncompressedReferenceSize;
 
-    public HotSpotReferenceMapBuilder(int totalFrameSize, int maxOopMapStackOffset) {
+    public HotSpotReferenceMapBuilder(int totalFrameSize, int maxOopMapStackOffset, int uncompressedReferenceSize) {
+        this.uncompressedReferenceSize = uncompressedReferenceSize;
         this.objectValues = new ArrayList<>();
         this.objectCount = 0;
         this.maxOopMapStackOffset = maxOopMapStackOffset;
@@ -116,6 +118,7 @@
 
                 for (int i = 0; i < kind.getPlatformKind().getVectorLength(); i++) {
                     if (kind.isReference(i)) {
+                        assert kind.isCompressedReference(i) ? (bytes < uncompressedReferenceSize) : (bytes == uncompressedReferenceSize);
                         objects[idx] = toLocation(obj, i * bytes);
                         derivedBase[idx] = base;
                         sizeInBytes[idx] = bytes;
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java	Wed Dec 20 20:55:07 2017 +0100
@@ -46,6 +46,7 @@
 import org.graalvm.compiler.hotspot.replacements.AESCryptSubstitutions;
 import org.graalvm.compiler.hotspot.replacements.BigIntegerSubstitutions;
 import org.graalvm.compiler.hotspot.replacements.CRC32Substitutions;
+import org.graalvm.compiler.hotspot.replacements.CRC32CSubstitutions;
 import org.graalvm.compiler.hotspot.replacements.CallSiteTargetNode;
 import org.graalvm.compiler.hotspot.replacements.CipherBlockChainingSubstitutions;
 import org.graalvm.compiler.hotspot.replacements.ClassGetHubNode;
@@ -165,6 +166,7 @@
                 registerConstantPoolPlugins(invocationPlugins, wordTypes, config, replacementBytecodeProvider);
                 registerAESPlugins(invocationPlugins, config, replacementBytecodeProvider);
                 registerCRC32Plugins(invocationPlugins, config, replacementBytecodeProvider);
+                registerCRC32CPlugins(invocationPlugins, config, replacementBytecodeProvider);
                 registerBigIntegerPlugins(invocationPlugins, config, replacementBytecodeProvider);
                 registerSHAPlugins(invocationPlugins, config, replacementBytecodeProvider);
                 registerUnsafePlugins(invocationPlugins, replacementBytecodeProvider);
@@ -530,4 +532,12 @@
             }
         }
     }
+
+    private static void registerCRC32CPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
+        if (config.useCRC32CIntrinsics) {
+            Registration r = new Registration(plugins, "java.util.zip.CRC32C", bytecodeProvider);
+            r.registerMethodSubstitution(CRC32CSubstitutions.class, "updateBytes", int.class, byte[].class, int.class, int.class);
+            r.registerMethodSubstitution(CRC32CSubstitutions.class, "updateDirectByteBuffer", int.class, long.class, int.class, int.class);
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/CRC32CSubstitutions.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.graalvm.compiler.hotspot.replacements;
+
+import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.arrayBaseOffset;
+
+import org.graalvm.compiler.api.replacements.ClassSubstitution;
+import org.graalvm.compiler.api.replacements.MethodSubstitution;
+import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
+import org.graalvm.compiler.graph.Node.ConstantNodeParameter;
+import org.graalvm.compiler.graph.Node.NodeIntrinsic;
+import org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode;
+import org.graalvm.compiler.nodes.extended.ForeignCallNode;
+import org.graalvm.compiler.word.Word;
+import org.graalvm.word.WordBase;
+import org.graalvm.word.WordFactory;
+
+import jdk.vm.ci.meta.JavaKind;
+
+// JaCoCo Exclude
+
+/**
+ * Substitutions for java.util.zip.CRC32C.
+ */
+@ClassSubstitution(className = "java.util.zip.CRC32C", optional = true)
+public class CRC32CSubstitutions {
+
+    @MethodSubstitution
+    static int updateBytes(int crc, byte[] b, int off, int end) {
+        Word bufAddr = WordFactory.unsigned(ComputeObjectAddressNode.get(b, arrayBaseOffset(JavaKind.Byte) + off));
+        return updateBytesCRC32(UPDATE_BYTES_CRC32C, crc, bufAddr, end - off);
+    }
+
+    @MethodSubstitution
+    static int updateDirectByteBuffer(int crc, long addr, int off, int end) {
+        WordBase bufAddr = WordFactory.unsigned(addr).add(off);
+        return updateBytesCRC32(UPDATE_BYTES_CRC32C, crc, bufAddr, end - off);
+    }
+
+    public static final ForeignCallDescriptor UPDATE_BYTES_CRC32C = new ForeignCallDescriptor("updateBytesCRC32C", int.class, int.class, WordBase.class, int.class);
+
+    @NodeIntrinsic(ForeignCallNode.class)
+    public static native int updateBytesCRC32(@ConstantNodeParameter ForeignCallDescriptor descriptor, int crc, WordBase buf, int length);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.jtt/src/org/graalvm/compiler/jtt/bytecode/BC_idiv_overflow.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.graalvm.compiler.jtt.bytecode;
+
+import org.junit.Test;
+
+import org.graalvm.compiler.jtt.JTTTest;
+
+/*
+ */
+public class BC_idiv_overflow extends JTTTest {
+
+    public static int test(int a, int b) {
+        return a / (b | 1);
+    }
+
+    @Test
+    public void run0() throws Throwable {
+        runTest("test", Integer.MIN_VALUE, -1);
+    }
+
+    @Test
+    public void run1() throws Throwable {
+        runTest("test", Integer.MIN_VALUE, 1);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.jtt/src/org/graalvm/compiler/jtt/bytecode/BC_ldiv_overflow.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.graalvm.compiler.jtt.bytecode;
+
+import org.junit.Test;
+
+import org.graalvm.compiler.jtt.JTTTest;
+
+/*
+ */
+public class BC_ldiv_overflow extends JTTTest {
+
+    public static long test(long a, long b) {
+        return a / (b | 1);
+    }
+
+    @Test
+    public void run0() throws Throwable {
+        runTest("test", Long.MIN_VALUE, -1L);
+    }
+
+    @Test
+    public void run1() throws Throwable {
+        runTest("test", Long.MIN_VALUE, 1L);
+    }
+
+}
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/IfNode.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/IfNode.java	Wed Dec 20 20:55:07 2017 +0100
@@ -30,8 +30,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import jdk.vm.ci.meta.MetaAccessProvider;
-import jdk.vm.ci.meta.ResolvedJavaType;
 import org.graalvm.compiler.core.common.calc.Condition;
 import org.graalvm.compiler.core.common.type.IntegerStamp;
 import org.graalvm.compiler.core.common.type.Stamp;
@@ -67,7 +65,9 @@
 import jdk.vm.ci.meta.Constant;
 import jdk.vm.ci.meta.JavaConstant;
 import jdk.vm.ci.meta.JavaKind;
+import jdk.vm.ci.meta.MetaAccessProvider;
 import jdk.vm.ci.meta.PrimitiveConstant;
+import jdk.vm.ci.meta.ResolvedJavaType;
 
 /**
  * The {@code IfNode} represents a branch that can go one of two directions depending on the outcome
@@ -416,6 +416,7 @@
                 if (result.graph() == null) {
                     result = graph().addOrUniqueWithInputs(result);
                 }
+                result = proxyReplacement(result);
                 /*
                  * This optimization can be performed even if multiple values merge at this phi
                  * since the two inputs get simplified into one.
@@ -698,6 +699,7 @@
                     ValueNode falseValue = singlePhi.valueAt(falseEnd);
                     ValueNode conditional = canonicalizeConditionalCascade(tool, trueValue, falseValue);
                     if (conditional != null) {
+                        conditional = proxyReplacement(conditional);
                         singlePhi.setValueAt(trueEnd, conditional);
                         removeThroughFalseBranch(tool, merge);
                         return true;
@@ -729,6 +731,36 @@
         return false;
     }
 
+    private ValueNode proxyReplacement(ValueNode replacement) {
+        /*
+         * Special case: Every empty diamond we collapse to a conditional node can potentially
+         * contain loop exit nodes on both branches. See the graph below: The two loop exits
+         * (instanceof begin node) exit the same loop. The resulting phi is defined outside the
+         * loop, but the resulting conditional node will be inside the loop, so we need to proxy the
+         * resulting conditional node. Callers of this method ensure that true and false successor
+         * have no usages, therefore a and b in the graph below can never be proxies themselves.
+         */
+        // @formatter:off
+        //              +--+
+        //              |If|
+        //              +--+      +-----+ +-----+
+        //         +----+  +----+ |  a  | |  b  |
+        //         |Lex |  |Lex | +----^+ +^----+
+        //         +----+  +----+      |   |
+        //           +-------+         +---+
+        //           | Merge +---------+Phi|
+        //           +-------+         +---+
+        // @formatter:on
+        if (this.graph().hasValueProxies()) {
+            if (trueSuccessor instanceof LoopExitNode && falseSuccessor instanceof LoopExitNode) {
+                assert ((LoopExitNode) trueSuccessor).loopBegin() == ((LoopExitNode) falseSuccessor).loopBegin();
+                assert trueSuccessor.usages().isEmpty() && falseSuccessor.usages().isEmpty();
+                return this.graph().addOrUnique(new ValueProxyNode(replacement, (LoopExitNode) trueSuccessor));
+            }
+        }
+        return replacement;
+    }
+
     protected void removeThroughFalseBranch(SimplifierTool tool, AbstractMergeNode merge) {
         AbstractBeginNode trueBegin = trueSuccessor();
         LogicNode conditionNode = condition();
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/IntegerDivRemNode.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/IntegerDivRemNode.java	Wed Dec 20 20:55:07 2017 +0100
@@ -60,7 +60,8 @@
 
         // Assigning canDeopt during constructor, because it must never change during lifetime of
         // the node.
-        this.canDeopt = ((IntegerStamp) getY().stamp(NodeView.DEFAULT)).contains(0);
+        IntegerStamp yStamp = (IntegerStamp) getY().stamp(NodeView.DEFAULT);
+        this.canDeopt = yStamp.contains(0) || yStamp.contains(-1);
     }
 
     public final Op getOp() {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ProfileCompiledMethodsPhase.java	Wed Dec 20 20:55:07 2017 +0100
@@ -121,7 +121,7 @@
 
     private static void addSectionCounters(FixedWithNextNode start, Collection<Block> sectionBlocks, Collection<Loop<Block>> childLoops, ScheduleResult schedule, ControlFlowGraph cfg) {
         HashSet<Block> blocks = new HashSet<>(sectionBlocks);
-        for (Loop<?> loop : childLoops) {
+        for (Loop<Block> loop : childLoops) {
             blocks.removeAll(loop.getBlocks());
         }
         double weight = getSectionWeight(schedule, blocks) / cfg.blockFor(start).probability();
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinter.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinter.java	Wed Dec 20 20:55:07 2017 +0100
@@ -194,15 +194,26 @@
 
     static String constantToString(Object value) {
         Class<?> c = value.getClass();
+        String suffix = "";
         if (c.isArray()) {
             return constantArrayToString(value);
         } else if (value instanceof Enum) {
             return ((Enum<?>) value).name();
         } else if (isToStringTrusted(c)) {
-            return value.toString();
+            try {
+                return value.toString();
+            } catch (Throwable t) {
+                suffix = "[toString error: " + t.getClass().getName() + "]";
+                if (isToStringTrusted(t.getClass())) {
+                    try {
+                        suffix = "[toString error: " + t + "]";
+                    } catch (Throwable t2) {
+                        // No point in going further
+                    }
+                }
+            }
         }
-        return MetaUtil.getSimpleName(c, true) + "@" + Integer.toHexString(System.identityHashCode(value));
-
+        return MetaUtil.getSimpleName(c, true) + "@" + Integer.toHexString(System.identityHashCode(value)) + suffix;
     }
 
     static String constantArrayToString(Object array) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java	Wed Dec 20 20:55:07 2017 +0100
@@ -141,6 +141,7 @@
         registerJMHBlackholePlugins(plugins, bytecodeProvider);
         registerJFRThrowablePlugins(plugins, bytecodeProvider);
         registerMethodHandleImplPlugins(plugins, snippetReflection, bytecodeProvider);
+        registerJcovCollectPlugins(plugins, bytecodeProvider);
     }
 
     private static final Field STRING_VALUE_FIELD;
@@ -910,4 +911,21 @@
             }
         });
     }
+
+    /**
+     * Registers a plugin to ignore {@code com.sun.tdk.jcov.runtime.Collect.hit} within an
+     * intrinsic.
+     */
+    private static void registerJcovCollectPlugins(InvocationPlugins plugins, BytecodeProvider bytecodeProvider) {
+        Registration r = new Registration(plugins, "com.sun.tdk.jcov.runtime.Collect", bytecodeProvider);
+        r.register1("hit", int.class, new InvocationPlugin() {
+            @Override
+            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
+                if (b.parsingIntrinsic()) {
+                    return true;
+                }
+                return false;
+            }
+        });
+    }
 }
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/classfile/Classfile.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,8 +46,8 @@
     private final ResolvedJavaType type;
     private final List<ClassfileBytecode> codeAttributes;
 
-    private static final int MAJOR_VERSION_JAVA_MIN = 51;
-    private static final int MAJOR_VERSION_JAVA_MAX = 54;
+    private static final int MAJOR_VERSION_JAVA7 = 51;
+    private static final int MAJOR_VERSION_JAVA10 = 54;
     private static final int MAGIC = 0xCAFEBABE;
 
     /**
@@ -65,7 +65,7 @@
 
         int minor = stream.readUnsignedShort();
         int major = stream.readUnsignedShort();
-        if (major < MAJOR_VERSION_JAVA_MIN || major > MAJOR_VERSION_JAVA_MAX) {
+        if (major < MAJOR_VERSION_JAVA7 || major > MAJOR_VERSION_JAVA10) {
             throw new UnsupportedClassVersionError("Unsupported class file version: " + major + "." + minor);
         }
 
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/GraphEffectList.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.virtual/src/org/graalvm/compiler/virtual/phases/ea/GraphEffectList.java	Wed Dec 20 20:55:07 2017 +0100
@@ -34,7 +34,6 @@
 import org.graalvm.compiler.nodes.NodeView;
 import org.graalvm.compiler.nodes.PhiNode;
 import org.graalvm.compiler.nodes.PiNode;
-import org.graalvm.compiler.nodes.ProxyNode;
 import org.graalvm.compiler.nodes.StructuredGraph;
 import org.graalvm.compiler.nodes.ValueNode;
 import org.graalvm.compiler.nodes.debug.DynamicCounterNode;
@@ -116,14 +115,7 @@
      */
     public void addFloatingNode(ValueNode node, @SuppressWarnings("unused") String cause) {
         add("add floating node", graph -> {
-            if (node instanceof ProxyNode) {
-                ProxyNode proxyNode = (ProxyNode) node;
-                ValueNode value = proxyNode.value();
-                if (!value.isAlive()) {
-                    graph.addWithoutUnique(value);
-                }
-            }
-            graph.addWithoutUnique(node);
+            graph.addWithoutUniqueWithInputs(node);
         });
     }
 
--- a/test/hotspot/jtreg/ProblemList.txt	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/ProblemList.txt	Wed Dec 20 20:55:07 2017 +0100
@@ -77,7 +77,6 @@
 # This test is disabled since it will stress NMT and timeout during normal testing
 runtime/NMT/MallocStressTest.java 8166548 generic-all
 runtime/SharedArchiveFile/DefaultUseWithClient.java 8154204 generic-all
-runtime/AppCDS/UseAppCDS.java 8165603 windows-all
 
 #############################################################################
 
--- a/test/hotspot/jtreg/compiler/ciReplay/TestDumpReplay.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/compiler/ciReplay/TestDumpReplay.java	Wed Dec 20 20:55:07 2017 +0100
@@ -27,7 +27,8 @@
  * @modules java.base/jdk.internal.misc:+open
  * @build sun.hotspot.WhiteBox
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions
+ *                   -Xbootclasspath/a:. -XX:+WhiteBoxAPI
  *                   -Xbatch -XX:-TieredCompilation -XX:+AlwaysIncrementalInline
  *                   -XX:CompileCommand=compileonly,compiler.ciReplay.TestDumpReplay::*
  *                   compiler.ciReplay.TestDumpReplay
--- a/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -89,7 +89,7 @@
         // We should have a section of Threads class SMR info:
         Pattern.compile("Threads class SMR info:"),
         // We should have one nested ThreadsListHandle:
-        Pattern.compile(".*, _smr_nested_thread_list_max=1"),
+        Pattern.compile(".*, _nested_thread_list_max=1"),
         // The current thread (marked with '=>') in the threads list
         // should show a hazard ptr:
         Pattern.compile("=>.* JavaThread \"main\" .*_threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=1, _nested_threads_hazard_ptrs=0x.*"),
--- a/test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/SharedArchiveFile/BootAppendTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @requires vm.cds
+ * @requires vm.cds & !vm.graal.enabled
  * @summary Testing -Xbootclasspath/a support for CDS
  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
  * @library /test/lib
--- a/test/hotspot/jtreg/runtime/Thread/TestThreadDumpSMRInfo.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/Thread/TestThreadDumpSMRInfo.java	Wed Dec 20 20:55:07 2017 +0100
@@ -45,7 +45,7 @@
     // Here's a sample "Threads class SMR info" section:
     //
     // Threads class SMR info:
-    // _smr_java_thread_list=0x0000000000ce8da0, length=23, elements={
+    // _java_thread_list=0x0000000000ce8da0, length=23, elements={
     // 0x000000000043a800, 0x0000000000aee800, 0x0000000000b06800, 0x0000000000b26000,
     // 0x0000000000b28800, 0x0000000000b2b000, 0x0000000000b2e000, 0x0000000000b30000,
     // 0x0000000000b32800, 0x0000000000b35000, 0x0000000000b3f000, 0x0000000000b41800,
@@ -53,9 +53,9 @@
     // 0x0000000000b55800, 0x0000000000b57800, 0x0000000000b5a000, 0x0000000000b5c800,
     // 0x0000000000cc8800, 0x0000000000fd9800, 0x0000000000ef4800
     // }
-    // _smr_java_thread_list_alloc_cnt=24, _smr_java_thread_list_free_cnt=23, _smr_java_thread_list_max=23, _smr_nested_thread_list_max=0
-    // _smr_delete_lock_wait_cnt=0, _smr_delete_lock_wait_max=0
-    // _smr_to_delete_list_cnt=0, _smr_to_delete_list_max=1
+    // _java_thread_list_alloc_cnt=24, _java_thread_list_free_cnt=23, _java_thread_list_max=23, _nested_thread_list_max=0
+    // _delete_lock_wait_cnt=0, _delete_lock_wait_max=0
+    // _to_delete_list_cnt=0, _to_delete_list_max=1
 
     final static String HEADER_STR = "Threads class SMR info:";
 
--- a/test/hotspot/jtreg/runtime/appcds/MultiReleaseJars.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/MultiReleaseJars.java	Wed Dec 20 20:55:07 2017 +0100
@@ -72,13 +72,14 @@
         if (contents == null) {
             throw new java.lang.RuntimeException("No input for writing to file" + file);
         }
-        FileOutputStream fos = new FileOutputStream(file);
-        PrintStream ps = new PrintStream(fos);
-        for (String str : contents) {
-            ps.println(str);
+        try (
+             FileOutputStream fos = new FileOutputStream(file);
+             PrintStream ps = new PrintStream(fos)
+        ) {
+            for (String str : contents) {
+                ps.println(str);
+            }
         }
-        ps.close();
-        fos.close();
     }
 
     /* version.jar entries and files:
--- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java	Wed Dec 20 20:55:07 2017 +0100
@@ -245,11 +245,10 @@
     // Copy file with bytes deleted or inserted
     // del -- true, deleted, false, inserted
     public static void copyFile(File from, File to, boolean del) throws Exception {
-        FileChannel inputChannel = null;
-        FileChannel outputChannel = null;
-        try {
-            inputChannel = new FileInputStream(from).getChannel();
-            outputChannel = new FileOutputStream(to).getChannel();
+        try (
+            FileChannel inputChannel = new FileInputStream(from).getChannel();
+            FileChannel outputChannel = new FileOutputStream(to).getChannel()
+        ) {
             long size = inputChannel.size();
             int init_size = getFileHeaderSize(inputChannel);
             outputChannel.transferFrom(inputChannel, 0, init_size);
@@ -264,9 +263,6 @@
                 outputChannel.write(ByteBuffer.wrap(new byte[n]));
                 outputChannel.transferFrom(inputChannel, init_size + n , size - init_size);
             }
-        } finally {
-            inputChannel.close();
-            outputChannel.close();
         }
     }
 
--- a/test/hotspot/jtreg/runtime/appcds/UseAppCDS.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/UseAppCDS.java	Wed Dec 20 20:55:07 2017 +0100
@@ -108,12 +108,14 @@
 
     public static List<String> toClassNames(String filename) throws IOException {
         ArrayList<String> classes = new ArrayList<>();
-        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
-        for (; ; ) {
-            String line = br.readLine();
-            if (line == null)
-                break;
-            classes.add(line.replaceAll("/", "."));
+        try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename)))) {
+            for (; ; ) {
+                String line = br.readLine();
+                if (line == null) {
+                    break;
+                }
+                classes.add(line.replaceAll("/", "."));
+            }
         }
         return classes;
     }
--- a/test/hotspot/jtreg/runtime/appcds/cacheObject/RedefineClassTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/cacheObject/RedefineClassTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -43,7 +43,6 @@
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.VirtualMachineDescriptor;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.util.List;
 import jdk.test.lib.Asserts;
 import jdk.test.lib.cds.CDSOptions;
--- a/test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -44,7 +44,9 @@
     static String arrayClasses[] = {
         "ArrayTestHelper",
         "[Ljava/lang/Comparable;",
-        "[I"
+        "[I",
+        "[[[Ljava/lang/Object;",
+        "[[B"
     };
 
     public static void main(String[] args) throws Exception {
@@ -56,7 +58,12 @@
         String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
 
         // create an archive containing array classes
-        TestCommon.dump(appJar, TestCommon.list(arrayClasses), bootClassPath, "-verbose:class");
+        OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list(arrayClasses), bootClassPath, "-verbose:class");
+        // we currently don't support array classes during CDS dump
+        output.shouldContain("Preload Warning: Cannot find [Ljava/lang/Comparable;")
+              .shouldContain("Preload Warning: Cannot find [I")
+              .shouldContain("Preload Warning: Cannot find [[[Ljava/lang/Object;")
+              .shouldContain("Preload Warning: Cannot find [[B");
 
         List<String> argsList = new ArrayList<String>();
         argsList.add("-XX:+UnlockDiagnosticVMOptions");
@@ -67,12 +74,13 @@
         argsList.add("-verbose:class");
         argsList.add("ArrayTestHelper");
         // the following are input args to the ArrayTestHelper.
-        for (int i = 0; i < arrayClasses.length; i++) {
+        // skip checking array classes during run time
+        for (int i = 0; i < 1; i++) {
             argsList.add(arrayClasses[i]);
         }
         String[] opts = new String[argsList.size()];
         opts = argsList.toArray(opts);
-        OutputAnalyzer output = TestCommon.execCommon(opts);
+        output = TestCommon.execCommon(opts);
         TestCommon.checkExec(output);
     }
 }
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/JigsawOptionsCombo.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/JigsawOptionsCombo.java	Wed Dec 20 20:55:07 2017 +0100
@@ -27,7 +27,7 @@
  * @summary Test combinations of jigsaw options that affect the use of AppCDS
  *
  * AppCDS does not support uncompressed oops
- * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires ((vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)) & !vm.graal.enabled
  * @library /test/lib ..
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/BootAppendTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/BootAppendTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -25,7 +25,7 @@
 /**
  * @test
  * @summary AppCDS tests for testing -Xbootclasspath/a
- * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires ((vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)) & !vm.graal.enabled
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/ClassPathTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/ClassPathTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -24,7 +24,7 @@
 
 /**
  * @test
- * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires ((vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)) & !vm.graal.enabled
  * @library ../..
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java	Wed Dec 20 20:55:07 2017 +0100
@@ -29,7 +29,7 @@
  *     2) app loader will load the class from the jimage by default;
  *        app loader will load the class from the bootclasspath if the
  *        "--limit-modules java.base" option is specified
- * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires ((vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)) & !vm.graal.enabled
  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  * @modules java.base/jdk.internal.misc
  *          java.management
--- a/test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jigsaw/limitmods/LimitModsTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -24,7 +24,7 @@
 
 /**
  * @test
- * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
+ * @requires ((vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)) & !vm.graal.enabled
  * @library ../..
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/InstrumentationTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/InstrumentationTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -182,9 +182,9 @@
         // We use the flagFile to prevent the child process to make progress, until we have
         // attached to it.
         File f = new File(flagFile);
-        FileOutputStream o = new FileOutputStream(f);
-        o.write(1);
-        o.close();
+        try (FileOutputStream o = new FileOutputStream(f)) {
+            o.write(1);
+        }
         if (!f.exists()) {
             throw new RuntimeException("Failed to create " + f);
         }
--- a/test/hotspot/jtreg/runtime/appcds/test-classes/Util.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/runtime/appcds/test-classes/Util.java	Wed Dec 20 20:55:07 2017 +0100
@@ -39,7 +39,7 @@
         throws FileNotFoundException, IOException, NoSuchMethodException, IllegalAccessException,
                InvocationTargetException
     {
-        DataInputStream dis = new DataInputStream(new FileInputStream(clsFile));
+      try (DataInputStream dis = new DataInputStream(new FileInputStream(clsFile))) {
         byte[] buff = new byte[(int)clsFile.length()];
         dis.readFully(buff);
         replace(buff, fromString, toString);
@@ -57,6 +57,7 @@
         System.out.println("Loaded : " + cls);
 
         return cls;
+      }
     }
 
     /**
@@ -146,11 +147,10 @@
         JarFile jf = new JarFile(jarFile);
         JarEntry ent = jf.getJarEntry(className.replace('.', '/') + ".class");
 
-        DataInputStream dis = new DataInputStream(jf.getInputStream(ent));
-        byte[] buff = new byte[(int)ent.getSize()];
-        dis.readFully(buff);
-        dis.close();
-
-        return buff;
+        try (DataInputStream dis = new DataInputStream(jf.getInputStream(ent))) {
+            byte[] buff = new byte[(int)ent.getSize()];
+            dis.readFully(buff);
+            return buff;
+        }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/jni/checked/TestCheckedEnsureLocalCapacity.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 8193222
+ * @summary Check EnsureLocalCapacity doesn't shrink unexpectedly
+ * @library /test/lib
+ * @run main/othervm/native TestCheckedEnsureLocalCapacity launch
+ */
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class TestCheckedEnsureLocalCapacity {
+
+    static {
+        System.loadLibrary("TestCheckedEnsureLocalCapacity");
+    }
+
+    // Calls EnsureLocalCapacity(capacity) and then creates "copies" number
+    // of LocalRefs to "o".
+    // If capacity > copies no warning should ensue (with the bug fixed).
+    // If copies > capacity + warning-threshold then we still get a warning.
+    private static native void ensureCapacity(Object o, int capacity, int copies);
+
+    private static int[][] testArgs = {
+        { 60, 45 }, // good: capacity > copies
+        { 1, 45 }   // bad: copies >> capacity
+    };
+
+    private static final String EXCEED_WARNING =
+        "^WARNING: JNI local refs: \\d++, exceeds capacity:";
+
+    private static final String WARNING = "^WARNING: ";
+
+    public static void main(String[] args) throws Throwable {
+        if (args.length == 2) {
+            ensureCapacity(new Object(),
+                           Integer.parseInt(args[0]),
+                           Integer.parseInt(args[1]));
+            return;
+        }
+
+        // No warning
+        ProcessTools.executeTestJvm("-Xcheck:jni",
+                                    "TestCheckedEnsureLocalCapacity",
+                                    Integer.toString(testArgs[0][0]),
+                                    Integer.toString(testArgs[0][1])).
+            shouldHaveExitValue(0).
+            // check no capacity warning
+            stdoutShouldNotMatch(EXCEED_WARNING).
+            // check no other warning
+            stdoutShouldNotMatch(WARNING).
+            reportDiagnosticSummary();
+
+        // Warning
+        ProcessTools.executeTestJvm("-Xcheck:jni",
+                                    "TestCheckedEnsureLocalCapacity",
+                                    Integer.toString(testArgs[1][0]),
+                                    Integer.toString(testArgs[1][1])).
+            shouldHaveExitValue(0).
+            // check for capacity warning
+            stdoutShouldMatch(EXCEED_WARNING).
+            reportDiagnosticSummary();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/runtime/jni/checked/libTestCheckedEnsureLocalCapacity.c	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <jni.h>
+#include <stdio.h>
+
+void reduceLocalCapacity(JNIEnv* env) {
+    puts("reduceLocalCapacity: setting to 1");
+    (*env)->EnsureLocalCapacity(env,1);
+}
+
+JNIEXPORT void JNICALL
+Java_TestCheckedEnsureLocalCapacity_ensureCapacity(JNIEnv *env,
+                                                   jobject unused,
+                                                   jobject target,
+                                                   jint capacity,
+                                                   jint copies) {
+  int i;
+  printf("ensureCapacity: setting to %d\n", capacity);
+  (*env)->EnsureLocalCapacity(env, capacity); // set high
+  reduceLocalCapacity(env);     // sets low
+
+  printf("ensureCapacity: creating %d LocalRefs\n", copies);
+  for (i = 0; i < copies; i++) {
+    target = (*env)->NewLocalRef(env, target);
+  }
+
+  puts("ensureCapacity: done");
+}
--- a/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/libGetOwnedMonitorInfoTest.c	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/libGetOwnedMonitorInfoTest.c	Wed Dec 20 20:55:07 2017 +0100
@@ -49,6 +49,7 @@
 
 static volatile jboolean event_has_posted = JNI_FALSE;
 static volatile jint status = PASSED;
+static volatile jclass testClass = NULL;
 
 static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved);
 
@@ -66,16 +67,10 @@
 }
 
 static jboolean CheckLockObject(JNIEnv *env, jobject monitor) {
-    jclass testClass;
-
-    testClass = (*env)->FindClass(env, TEST_CLASS);
     if (testClass == NULL) {
-        fprintf(stderr, "MonitorContendedEnter: " TEST_CLASS " not found\n");
-        status = FAILED;
-        event_has_posted = JNI_TRUE;
+        // JNI_OnLoad has not been called yet, so can't possibly be an instance of TEST_CLASS.
         return JNI_FALSE;
     }
-
     return (*env)->IsInstanceOf(env, monitor, testClass);
 }
 
@@ -171,7 +166,26 @@
 
 JNIEXPORT jint JNICALL
 JNI_OnLoad(JavaVM *jvm, void *reserved) {
-    return JNI_VERSION_1_8;
+    jint res;
+    JNIEnv *env;
+
+    res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &env),
+                                   JNI_VERSION_9);
+    if (res != JNI_OK || env == NULL) {
+        fprintf(stderr, "Error: GetEnv call failed(%d)!\n", res);
+        return JNI_ERR;
+    }
+
+    testClass = (*env)->FindClass(env, TEST_CLASS);
+    if (testClass != NULL) {
+      testClass = (*env)->NewGlobalRef(env, testClass);
+    }
+    if (testClass == NULL) {
+        fprintf(stderr, "Error: Could not load class %s!\n", TEST_CLASS);
+        return JNI_ERR;
+    }
+
+    return JNI_VERSION_9;
 }
 
 static
@@ -185,7 +199,7 @@
     printf("Agent_OnLoad started\n");
 
     res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
-                                   JVMTI_VERSION_1);
+                                   JVMTI_VERSION_9);
     if (res != JNI_OK || jvmti == NULL) {
         fprintf(stderr, "Error: wrong result of a valid call to GetEnv!\n");
         return JNI_ERR;
@@ -221,6 +235,7 @@
         return JNI_ERR;
     }
 
+    memset(&callbacks, 0, sizeof(callbacks));
     callbacks.MonitorContendedEnter   = &MonitorContendedEnter;
     callbacks.MonitorContendedEntered = &MonitorContendedEntered;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+
+import jdk.test.lib.apps.LingeredApp;
+
+/*
+ * @test
+ * @bug 8193124
+ * @summary Test the clhsdb 'findpc' command
+ * @library /test/lib
+ * @run main/othervm ClhsdbFindPC
+ */
+
+public class ClhsdbFindPC {
+
+    private static void testFindPC(boolean withXcomp) throws Exception {
+        LingeredApp theApp = null;
+        try {
+            ClhsdbLauncher test = new ClhsdbLauncher();
+            theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp"))
+                               : LingeredApp.startApp(List.of("-Xint"));
+            System.out.print("Started LingeredApp ");
+            if (withXcomp) {
+                System.out.print("(-Xcomp) ");
+            } else {
+                System.out.print("(-Xint) ");
+            }
+            System.out.println("with pid " + theApp.getPid());
+
+            // Run 'jstack -v' command to get the pc
+            List<String> cmds = List.of("jstack -v");
+            String output = test.run(theApp.getPid(), cmds, null, null);
+
+            // Test the 'findpc' command passing in the pc obtained from
+            // the 'jstack -v' command
+            cmds = new ArrayList<String>();
+
+            // Output could be null if the test was skipped due to
+            // attach permission issues.
+            if (output != null) {
+                String cmdStr = null;
+                String[] parts = output.split("LingeredApp.main");
+                String[] tokens = parts[1].split(" ");
+                for (String token : tokens) {
+                    if (token.contains("pc")) {
+                        String[] address = token.split("=");
+                        // address[1] represents the address of the Method
+                        cmdStr = "findpc " + address[1].replace(",","");
+                        cmds.add(cmdStr);
+                        break;
+                    }
+                }
+
+                Map<String, List<String>> expStrMap = new HashMap<>();
+                if (withXcomp) {
+                    expStrMap.put(cmdStr, List.of(
+                            "In code in NMethod for jdk/test/lib/apps/LingeredApp.main",
+                            "content:",
+                            "oops:",
+                            "frame size:"));
+                } else {
+                    expStrMap.put(cmdStr, List.of(
+                            "In interpreter codelet",
+                            "invoke return entry points"));
+                }
+
+                test.run(theApp.getPid(), cmds, expStrMap, null);
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting the ClhsdbFindPC test");
+        testFindPC(true);
+        testFindPC(false);
+        System.out.println("Test PASSED");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import jdk.test.lib.apps.LingeredApp;
+
+/*
+ * @test
+ * @bug 8192985
+ * @summary Test the clhsdb 'inspect' command
+ * @library /test/lib
+ * @run main/othervm ClhsdbInspect
+ */
+
+public class ClhsdbInspect {
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting the ClhsdbInspect test");
+
+        LingeredAppWithLock theApp = null;
+        try {
+            ClhsdbLauncher test = new ClhsdbLauncher();
+
+            theApp = new LingeredAppWithLock();
+            LingeredApp.startApp(null, theApp);
+            System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+            // Run the 'jstack -v' command to get the address of a Method*
+            // and the oop address of a java.lang.ref.ReferenceQueue$Lock
+            // object
+            List<String> cmds = List.of("jstack -v");
+
+            String jstackOutput = test.run(theApp.getPid(), cmds, null, null);
+
+            if (jstackOutput == null) {
+                // Output could be null due to attach permission issues
+                // and if we are skipping this.
+                LingeredApp.stopApp(theApp);
+                return;
+            }
+
+            String addressString = null;
+            Map<String, String> tokensMap = new HashMap<>();
+            tokensMap.put("waiting to lock",
+                          "instance of Oop for java/lang/Class");
+            tokensMap.put("Method\\*=", "Type is Method");
+            tokensMap.put("waiting to re-lock in wait",
+                          "instance of Oop for java/lang/ref/ReferenceQueue$Lock");
+
+            for (String key: tokensMap.keySet()) {
+                cmds = new ArrayList<String>();
+                Map<String, List<String>> expStrMap = new HashMap<>();
+
+                String[] snippets = jstackOutput.split(key);
+                String[] tokens = snippets[1].split(" ");
+                for (String token: tokens) {
+                    if (token.contains("0x")) {
+                        addressString = token.replace("<", "").replace(">", "");
+                        break;
+                    }
+                }
+
+                String cmd = "inspect " + addressString;
+                cmds.add(cmd);
+                expStrMap.put(cmd, List.of(tokensMap.get(key)));
+                test.run(theApp.getPid(), cmds, expStrMap, null);
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+        System.out.println("Test PASSED");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+
+import jdk.test.lib.apps.LingeredApp;
+
+/*
+ * @test
+ * @bug 8193124
+ * @summary Test the clhsdb 'jdis' command
+ * @library /test/lib
+ * @run main/othervm ClhsdbJdis
+ */
+
+public class ClhsdbJdis {
+
+    public static void main(String[] args) throws Exception {
+        LingeredApp theApp = null;
+        System.out.println("Starting the ClhsdbJdis test");
+
+        try {
+            ClhsdbLauncher test = new ClhsdbLauncher();
+            theApp = LingeredApp.startApp();
+            System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+            // Run 'jstack -v' command to get the Method Address
+            List<String> cmds = List.of("jstack -v");
+            String output = test.run(theApp.getPid(), cmds, null, null);
+
+            // Test the 'jdis' command passing in the address obtained from
+            // the 'jstack -v' command
+            cmds = new ArrayList<String>();
+
+            // Output could be null if the test was skipped due to
+            // attach permission issues.
+            if (output != null) {
+                String cmdStr = null;
+                String[] parts = output.split("LingeredApp.main");
+                String[] tokens = parts[1].split(" ");
+                for (String token : tokens) {
+                    if (token.contains("Method")) {
+                        String[] address = token.split("=");
+                        // address[1] represents the address of the Method
+                        cmdStr = "jdis " + address[1];
+                        cmds.add(cmdStr);
+                        break;
+                    }
+                }
+
+                Map<String, List<String>> expStrMap = new HashMap<>();
+                expStrMap.put(cmdStr, List.of(
+                        "public static void main(java.lang.String[])",
+                        "Holder Class",
+                        "public class jdk.test.lib.apps.LingeredApp @",
+                        "Bytecode",
+                        "line bci   bytecode",
+                        "Exception Table",
+                        "start bci end bci handler bci catch type",
+                        "Constant Pool of [public class jdk.test.lib.apps.LingeredApp @"));
+
+                test.run(theApp.getPid(), cmds, expStrMap, null);
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+        System.out.println("Test PASSED");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import jdk.test.lib.apps.LingeredApp;
+
+/*
+ * @test
+ * @bug 8192985
+ * @summary Test the clhsdb 'printas' command
+ * @library /test/lib
+ * @run main/othervm ClhsdbPrintAs
+ */
+
+public class ClhsdbPrintAs {
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting the ClhsdbPrintAs test");
+
+        LingeredApp theApp = null;
+        try {
+            ClhsdbLauncher test = new ClhsdbLauncher();
+            theApp = LingeredApp.startApp();
+            System.out.println("Started LingeredApp with pid " + theApp.getPid());
+
+            // Run the 'jstack -v' command to get the address of a the Method*
+            // representing LingeredApp.main
+            List<String> cmds = List.of("jstack -v");
+            Map<String, List<String>> expStrMap;
+
+            String jstackOutput = test.run(theApp.getPid(), cmds, null, null);
+
+            if (jstackOutput == null) {
+                // Output could be null due to attach permission issues
+                // and if we are skipping this.
+                LingeredApp.stopApp(theApp);
+                return;
+            }
+
+            String[] snippets = jstackOutput.split("LingeredApp.main");
+            String addressString = null;
+
+            String[] tokens = snippets[1].split("Method\\*=");
+            String[] words = tokens[1].split(" ");
+            addressString = words[0];
+
+            cmds = new ArrayList<String>();
+            expStrMap = new HashMap<>();
+
+            String cmd = "printas Method " + addressString;
+            cmds.add(cmd);
+            expStrMap.put(cmd, List.of
+                ("ConstMethod", "MethodCounters", "Method::_access_flags"));
+
+            // Run the printas Method <addr> command to obtain the address
+            // of ConstMethod*
+            String methodDetailsOutput = test.run(theApp.getPid(), cmds, expStrMap, null);
+            snippets = methodDetailsOutput.split("ConstMethod*");
+
+            tokens = snippets[1].split(" ");
+            for (String token : tokens) {
+                if (token.contains("0x")) {
+                    addressString = token.replace("\n", "");
+                    break;
+                }
+            }
+
+            cmds = new ArrayList<String>();
+            expStrMap = new HashMap<>();
+
+            cmd = "printas ConstMethod " + addressString;
+            cmds.add(cmd);
+            expStrMap.put(cmd, List.of
+                ("ConstantPool", "_max_locals", "_flags"));
+
+            // Run the printas constMethod <addr> command to obtain the address
+            // of ConstantPool*
+            String constMethodDetailsOutput = test.run(theApp.getPid(), cmds, expStrMap, null);
+            snippets = constMethodDetailsOutput.split("ConstantPool*");
+
+            tokens = snippets[1].split(" ");
+            for (String token : tokens) {
+                if (token.contains("0x")) {
+                    addressString = token.replace("\n", "");
+                    break;
+                }
+            }
+
+            cmds = new ArrayList<String>();
+            expStrMap = new HashMap<>();
+
+            cmd = "printas ConstantPool " + addressString;
+            cmds.add(cmd);
+            expStrMap.put(cmd, List.of
+                ("ConstantPoolCache", "_pool_holder", "InstanceKlass*"));
+            test.run(theApp.getPid(), cmds, expStrMap, null);
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+        System.out.println("Test PASSED");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java	Wed Dec 20 20:55:07 2017 +0100
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ArrayList;
+import jdk.test.lib.Utils;
+import jdk.test.lib.apps.LingeredApp;
+
+/*
+ * @test
+ * @bug 8192985
+ * @summary Test the clhsdb 'scanoops' command
+ * @library /test/lib
+ * @run main/othervm/timeout=1200 ClhsdbScanOops
+ */
+
+public class ClhsdbScanOops {
+
+    private static void testWithGcType(String gc) throws Exception {
+
+        LingeredApp theApp = null;
+
+        try {
+            ClhsdbLauncher test = new ClhsdbLauncher();
+            List<String> vmArgs = new ArrayList<String>();
+            vmArgs.add(gc);
+            theApp = LingeredApp.startApp(vmArgs);
+
+            System.out.println ("Started LingeredApp with the GC option " + gc +
+                                " and pid " + theApp.getPid());
+
+            // Run the 'universe' command to get the address ranges
+            List<String> cmds = List.of("universe");
+
+            String universeOutput = test.run(theApp.getPid(), cmds, null, null);
+
+            if (universeOutput == null) {
+                // Output could be null due to attach permission issues
+                // and if we are skipping this.
+                LingeredApp.stopApp(theApp);
+                return;
+            }
+
+            cmds = new ArrayList<String>();
+            Map<String, List<String>> expStrMap = new HashMap<>();
+            Map<String, List<String>> unExpStrMap = new HashMap<>();
+
+            String startAddress = null;
+            String endAddress = null;
+            String[] snippets = null;
+
+            if (gc.contains("UseParallelGC")) {
+                snippets = universeOutput.split("eden =  ");
+            } else {
+                snippets = universeOutput.split("eden \\[");
+            }
+            String[] words = snippets[1].split(",");
+            // Get the addresses from Eden
+            startAddress = words[0].replace("[", "");
+            endAddress = words[1];
+            String cmd = "scanoops " + startAddress + " " + endAddress;
+            cmds.add(cmd);
+
+            expStrMap.put(cmd, List.of
+                ("java/lang/Object", "java/lang/Class", "java/lang/Thread",
+                 "java/lang/String", "[B", "[I"));
+
+            // Test the 'type' option also
+            // scanoops <start addr> <end addr> java/lang/String
+            // Ensure that only the java/lang/String oops are printed.
+            cmd = cmd + " java/lang/String";
+            cmds.add(cmd);
+            expStrMap.put(cmd, List.of("java/lang/String"));
+            unExpStrMap.put(cmd, List.of("java/lang/Thread"));
+
+            test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Starting the ClhsdbScanOops test");
+        try {
+            testWithGcType("-XX:+UseParallelGC");
+            testWithGcType("-XX:+UseSerialGC");
+        } catch (Exception e) {
+            throw new Error("Test failed with " + e);
+        }
+        System.out.println("Test PASSED");
+    }
+}
--- a/test/jdk/TEST.ROOT	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/TEST.ROOT	Wed Dec 20 20:55:07 2017 +0100
@@ -36,6 +36,7 @@
 requires.properties= \
     sun.arch.data.model \
     java.runtime.name \
+    vm.graal.enabled \
     vm.cds
 
 # Minimum jtreg version
--- a/test/jdk/com/sun/tools/attach/modules/Driver.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/com/sun/tools/attach/modules/Driver.java	Wed Dec 20 20:55:07 2017 +0100
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @requires !vm.graal.enabled
  * @modules jdk.attach
  * @build m/* Agent
  * @run main/othervm -Djdk.attach.allowAttachSelf m/p.Main jmx javaagent
--- a/test/jdk/java/lang/String/concat/WithSecurityManager.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/lang/String/concat/WithSecurityManager.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
  * @test
  * @summary String concatenation fails with a custom SecurityManager that uses concatenation
  * @bug 8155090 8158851
+ * @requires !vm.graal.enabled
  *
  * @compile WithSecurityManager.java
  *
--- a/test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Wed Dec 20 20:55:07 2017 +0100
@@ -46,6 +46,7 @@
  *          throwing NullPointerException. The test uses --limit-module
  *          to force the selection of one or the other.
  * @author danielfuchs
+ * @requires !vm.graal.enabled
  * @build LoggerFinderAPI
  * @run main/othervm --limit-modules java.base,java.logging
  *          -Djava.util.logging.SimpleFormatter.format=LOG-%4$s:-[%2$s]-%5$s%6$s%n
--- a/test/jdk/java/lang/instrument/TestAgentWithLimitMods.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/lang/instrument/TestAgentWithLimitMods.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /**
  *
  * @test
+ * @requires !vm.graal.enabled
  * @summary Tests that the -javaagent option adds the java.instrument into
  * the module graph
  *
--- a/test/jdk/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -26,6 +26,7 @@
  * @bug 8151099
  * @summary Verify platform MXBeans initialized properly with java.management
  *          module only. No other management provider
+ * @requires !vm.graal.enabled
  * @modules java.management
  * @run main/othervm --limit-modules=java.management DefaultManagementProviderTest
  */
--- a/test/jdk/java/net/SocketOption/OptionsTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/net/SocketOption/OptionsTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 8036979 8072384 8044773
+ * @requires !vm.graal.enabled
  * @run main/othervm -Xcheck:jni OptionsTest
  * @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest
  * @run main/othervm --limit-modules=java.base OptionsTest
--- a/test/jdk/java/net/SocketOption/UnsupportedOptionsTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/net/SocketOption/UnsupportedOptionsTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -32,6 +32,7 @@
  * @bug 8143554 8044773
  * @summary Test checks that UnsupportedOperationException for unsupported
  * SOCKET_OPTIONS is thrown by both getOption() and setOption() methods.
+ * @requires !vm.graal.enabled
  * @run main UnsupportedOptionsTest
  * @run main/othervm --limit-modules=java.base UnsupportedOptionsTest
  */
--- a/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 /* @test
  * @bug 4640544 8044773
  * @summary Unit test for setOption/getOption/options methods
+ * @requires !vm.graal.enabled
  * @run main SocketOptionTests
  * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
--- a/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @bug 4640544 8044773
  * @summary Unit test for ServerSocketChannel setOption/getOption/options
  *          methods.
+ * @requires !vm.graal.enabled
  * @run main SocketOptionTests
  * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
--- a/test/jdk/java/nio/channels/SocketChannel/SocketOptionTests.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/java/nio/channels/SocketChannel/SocketOptionTests.java	Wed Dec 20 20:55:07 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
  * @bug 4640544 8044773
  * @summary Unit test to check SocketChannel setOption/getOption/options
  *          methods.
+ * @requires !vm.graal.enabled
  * @run main SocketOptionTests
  * @run main/othervm --limit-modules=java.base SocketOptionTests
  */
--- a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @requires !vm.graal.enabled
  * @library /lib/testlibrary /test/lib
  * @modules java.desktop java.logging jdk.compiler
  * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
--- a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @requires !vm.graal.enabled
  * @library /lib/testlibrary /test/lib
  * @modules java.se
  * @build ListModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
--- a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java	Wed Dec 20 21:40:11 2017 +0100
+++ b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java	Wed Dec 20 20:55:07 2017 +0100
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @requires !vm.graal.enabled
  * @modules jdk.jdeps jdk.zipfs
  * @library /lib/testlibrary
  * @build ShowModuleResolutionTest jdk.testlibrary.*