changeset 51438:24ec1f500aa5

Merge
author mikael
date Tue, 21 Aug 2018 01:21:58 -0700
parents 03f5e2c372e6 ef57958c7c51
children 7f742456bf8b
files make/conf/jib-profiles.js src/hotspot/os/linux/os_linux.cpp src/hotspot/share/gc/shared/genCollectedHeap.cpp src/hotspot/share/runtime/simpleThresholdPolicy.cpp src/hotspot/share/runtime/simpleThresholdPolicy.hpp src/hotspot/share/runtime/simpleThresholdPolicy.inline.hpp test/hotspot/jtreg/gc/g1/TestStringSymbolTableStats.java test/hotspot/jtreg/vmTestbase/vm/mlvm/meth/share/transform/v2/MHSamTF.java test/jdk/TEST.ROOT test/jdk/com/sun/jdi/ArrayLengthDumpTest.sh test/jdk/com/sun/jdi/BreakpointWithFullGC.sh test/jtreg-ext/requires/VMProps.java
diffstat 1225 files changed, 27036 insertions(+), 9470 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Aug 02 14:44:58 2018 -0700
+++ b/.hgtags	Tue Aug 21 01:21:58 2018 -0700
@@ -498,6 +498,10 @@
 9937ef7499dcd7673714517fd5e450410c14ba4e jdk-11+22
 1edcf36fe15f79d6228d1a63eb680878e2386480 jdk-11+23
 ea900a7dc7d77dee30865c60eabd87fc24b1037c jdk-11+24
+331888ea4a788df801b1edf8836646cd25fc758b jdk-11+25
+945ba9278a272a5477ffb1b3ea1b04174fed8036 jdk-11+26
 69b438908512d3dfef5852c6a843a5778333a309 jdk-12+2
 990db216e7199b2ba9989d8fa20b657e0ca7d969 jdk-12+3
 499b873761d8e8a1cc4aa649daf04cbe98cbce77 jdk-12+4
+f8696e0ab9b795030429fc3374ec03e378fd9ed7 jdk-12+5
+7939b3c4e4088bf4f70ec5bbd8030393b653372f jdk-12+6
--- a/make/autoconf/flags-cflags.m4	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/autoconf/flags-cflags.m4	Tue Aug 21 01:21:58 2018 -0700
@@ -543,14 +543,14 @@
   fi
   if test "x$TOOLCHAIN_TYPE" = xgcc; then
     WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
-    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual"
+    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wunused-value -Woverloaded-virtual -Wreorder"
 
     if ! HOTSPOT_CHECK_JVM_VARIANT(zero); then
       # Non-zero builds have stricter warnings
       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wreturn-type"
     fi
   elif test "x$TOOLCHAIN_TYPE" = xclang; then
-    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated"
+    WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-deprecated -Wreorder"
     if test "x$OPENJDK_TARGET_OS" = xlinux; then
       WARNING_CFLAGS_JVM="$WARNING_CFLAGS_JVM -Wno-sometimes-uninitialized"
       WARNING_CFLAGS_JDK="-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2"
--- a/make/conf/jib-profiles.js	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/conf/jib-profiles.js	Tue Aug 21 01:21:58 2018 -0700
@@ -920,7 +920,7 @@
         jtreg: {
             server: "javare",
             revision: "4.2",
-            build_number: "b12",
+            build_number: "b13",
             checksum_file: "MD5_VALUES",
             file: "jtreg_bin-4.2.zip",
             environment_name: "JT_HOME",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/data/charsetmapping/IBM1129.c2b	Tue Aug 21 01:21:58 2018 -0700
@@ -0,0 +1,94 @@
+0x21	U+ff01
+0x22	U+ff02
+0x23	U+ff03
+0x24	U+ff04
+0x25	U+ff05
+0x26	U+ff06
+0x27	U+ff07
+0x28	U+ff08
+0x29	U+ff09
+0x2a	U+ff0a
+0x2b	U+ff0b
+0x2c	U+ff0c
+0x2d	U+ff0d
+0x2e	U+ff0e
+0x2f	U+ff0f
+0x30	U+ff10
+0x31	U+ff11
+0x32	U+ff12
+0x33	U+ff13
+0x34	U+ff14
+0x35	U+ff15
+0x36	U+ff16
+0x37	U+ff17
+0x38	U+ff18
+0x39	U+ff19
+0x3a	U+ff1a
+0x3b	U+ff1b
+0x3c	U+ff1c
+0x3d	U+ff1d
+0x3e	U+ff1e
+0x3f	U+ff1f
+0x40	U+ff20
+0x41	U+ff21
+0x42	U+ff22
+0x43	U+ff23
+0x44	U+ff24
+0x45	U+ff25
+0x46	U+ff26
+0x47	U+ff27
+0x48	U+ff28
+0x49	U+ff29
+0x4a	U+ff2a
+0x4b	U+ff2b
+0x4c	U+ff2c
+0x4d	U+ff2d
+0x4e	U+ff2e
+0x4f	U+ff2f
+0x50	U+ff30
+0x51	U+ff31
+0x52	U+ff32
+0x53	U+ff33
+0x54	U+ff34
+0x55	U+ff35
+0x56	U+ff36
+0x57	U+ff37
+0x58	U+ff38
+0x59	U+ff39
+0x5a	U+ff3a
+0x5b	U+ff3b
+0x5c	U+ff3c
+0x5d	U+ff3d
+0x5e	U+ff3e
+0x5f	U+ff3f
+0x60	U+ff40
+0x61	U+ff41
+0x62	U+ff42
+0x63	U+ff43
+0x64	U+ff44
+0x65	U+ff45
+0x66	U+ff46
+0x67	U+ff47
+0x68	U+ff48
+0x69	U+ff49
+0x6a	U+ff4a
+0x6b	U+ff4b
+0x6c	U+ff4c
+0x6d	U+ff4d
+0x6e	U+ff4e
+0x6f	U+ff4f
+0x70	U+ff50
+0x71	U+ff51
+0x72	U+ff52
+0x73	U+ff53
+0x74	U+ff54
+0x75	U+ff55
+0x76	U+ff56
+0x77	U+ff57
+0x78	U+ff58
+0x79	U+ff59
+0x7a	U+ff5a
+0x7b	U+ff5b
+0x7c	U+ff5c
+0x7d	U+ff5d
+0x7e	U+ff5e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/data/charsetmapping/IBM1129.map	Tue Aug 21 01:21:58 2018 -0700
@@ -0,0 +1,256 @@
+0x00	U+0000
+0x01	U+0001
+0x02	U+0002
+0x03	U+0003
+0x04	U+0004
+0x05	U+0005
+0x06	U+0006
+0x07	U+0007
+0x08	U+0008
+0x09	U+0009
+0x0a	U+000a
+0x0b	U+000b
+0x0c	U+000c
+0x0d	U+000d
+0x0e	U+000e
+0x0f	U+000f
+0x10	U+0010
+0x11	U+0011
+0x12	U+0012
+0x13	U+0013
+0x14	U+0014
+0x15	U+0015
+0x16	U+0016
+0x17	U+0017
+0x18	U+0018
+0x19	U+0019
+0x1a	U+001a
+0x1b	U+001b
+0x1c	U+001c
+0x1d	U+001d
+0x1e	U+001e
+0x1f	U+001f
+0x20	U+0020
+0x21	U+0021
+0x22	U+0022
+0x23	U+0023
+0x24	U+0024
+0x25	U+0025
+0x26	U+0026
+0x27	U+0027
+0x28	U+0028
+0x29	U+0029
+0x2a	U+002a
+0x2b	U+002b
+0x2c	U+002c
+0x2d	U+002d
+0x2e	U+002e
+0x2f	U+002f
+0x30	U+0030
+0x31	U+0031
+0x32	U+0032
+0x33	U+0033
+0x34	U+0034
+0x35	U+0035
+0x36	U+0036
+0x37	U+0037
+0x38	U+0038
+0x39	U+0039
+0x3a	U+003a
+0x3b	U+003b
+0x3c	U+003c
+0x3d	U+003d
+0x3e	U+003e
+0x3f	U+003f
+0x40	U+0040
+0x41	U+0041
+0x42	U+0042
+0x43	U+0043
+0x44	U+0044
+0x45	U+0045
+0x46	U+0046
+0x47	U+0047
+0x48	U+0048
+0x49	U+0049
+0x4a	U+004a
+0x4b	U+004b
+0x4c	U+004c
+0x4d	U+004d
+0x4e	U+004e
+0x4f	U+004f
+0x50	U+0050
+0x51	U+0051
+0x52	U+0052
+0x53	U+0053
+0x54	U+0054
+0x55	U+0055
+0x56	U+0056
+0x57	U+0057
+0x58	U+0058
+0x59	U+0059
+0x5a	U+005a
+0x5b	U+005b
+0x5c	U+005c
+0x5d	U+005d
+0x5e	U+005e
+0x5f	U+005f
+0x60	U+0060
+0x61	U+0061
+0x62	U+0062
+0x63	U+0063
+0x64	U+0064
+0x65	U+0065
+0x66	U+0066
+0x67	U+0067
+0x68	U+0068
+0x69	U+0069
+0x6a	U+006a
+0x6b	U+006b
+0x6c	U+006c
+0x6d	U+006d
+0x6e	U+006e
+0x6f	U+006f
+0x70	U+0070
+0x71	U+0071
+0x72	U+0072
+0x73	U+0073
+0x74	U+0074
+0x75	U+0075
+0x76	U+0076
+0x77	U+0077
+0x78	U+0078
+0x79	U+0079
+0x7a	U+007a
+0x7b	U+007b
+0x7c	U+007c
+0x7d	U+007d
+0x7e	U+007e
+0x7f	U+007f
+0x80	U+0080
+0x81	U+0081
+0x82	U+0082
+0x83	U+0083
+0x84	U+0084
+0x85	U+0085
+0x86	U+0086
+0x87	U+0087
+0x88	U+0088
+0x89	U+0089
+0x8a	U+008a
+0x8b	U+008b
+0x8c	U+008c
+0x8d	U+008d
+0x8e	U+008e
+0x8f	U+008f
+0x90	U+0090
+0x91	U+0091
+0x92	U+0092
+0x93	U+0093
+0x94	U+0094
+0x95	U+0095
+0x96	U+0096
+0x97	U+0097
+0x98	U+0098
+0x99	U+0099
+0x9a	U+009a
+0x9b	U+009b
+0x9c	U+009c
+0x9d	U+009d
+0x9e	U+009e
+0x9f	U+009f
+0xa0	U+00a0
+0xa1	U+00a1
+0xa2	U+00a2
+0xa3	U+00a3
+0xa4	U+00a4
+0xa5	U+00a5
+0xa6	U+00a6
+0xa7	U+00a7
+0xa8	U+0153
+0xa9	U+00a9
+0xaa	U+00aa
+0xab	U+00ab
+0xac	U+00ac
+0xad	U+00ad
+0xae	U+00ae
+0xaf	U+00af
+0xb0	U+00b0
+0xb1	U+00b1
+0xb2	U+00b2
+0xb3	U+00b3
+0xb4	U+0178
+0xb5	U+00b5
+0xb6	U+00b6
+0xb7	U+00b7
+0xb8	U+0152
+0xb9	U+00b9
+0xba	U+00ba
+0xbb	U+00bb
+0xbc	U+00bc
+0xbd	U+00bd
+0xbe	U+00be
+0xbf	U+00bf
+0xc0	U+00c0
+0xc1	U+00c1
+0xc2	U+00c2
+0xc3	U+0102
+0xc4	U+00c4
+0xc5	U+00c5
+0xc6	U+00c6
+0xc7	U+00c7
+0xc8	U+00c8
+0xc9	U+00c9
+0xca	U+00ca
+0xcb	U+00cb
+0xcc	U+0300
+0xcd	U+00cd
+0xce	U+00ce
+0xcf	U+00cf
+0xd0	U+0110
+0xd1	U+00d1
+0xd2	U+0309
+0xd3	U+00d3
+0xd4	U+00d4
+0xd5	U+01a0
+0xd6	U+00d6
+0xd7	U+00d7
+0xd8	U+00d8
+0xd9	U+00d9
+0xda	U+00da
+0xdb	U+00db
+0xdc	U+00dc
+0xdd	U+01af
+0xde	U+0303
+0xdf	U+00df
+0xe0	U+00e0
+0xe1	U+00e1
+0xe2	U+00e2
+0xe3	U+0103
+0xe4	U+00e4
+0xe5	U+00e5
+0xe6	U+00e6
+0xe7	U+00e7
+0xe8	U+00e8
+0xe9	U+00e9
+0xea	U+00ea
+0xeb	U+00eb
+0xec	U+0301
+0xed	U+00ed
+0xee	U+00ee
+0xef	U+00ef
+0xf0	U+0111
+0xf1	U+00f1
+0xf2	U+0323
+0xf3	U+00f3
+0xf4	U+00f4
+0xf5	U+01a1
+0xf6	U+00f6
+0xf7	U+00f7
+0xf8	U+00f8
+0xf9	U+00f9
+0xfa	U+00fa
+0xfb	U+00fb
+0xfc	U+00fc
+0xfd	U+01b0
+0xfe	U+20ab
+0xff	U+00ff
--- a/make/data/charsetmapping/charsets	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/data/charsetmapping/charsets	Tue Aug 21 01:21:58 2018 -0700
@@ -1241,6 +1241,16 @@
     alias   ibm-1124
     alias   1124
 
+charset x-IBM1129 IBM1129
+    package sun.nio.cs.ext
+    type    sbcs
+    hisname Cp1129
+    ascii   false
+    alias   cp1129               # JDK historical
+    alias   ibm1129
+    alias   ibm-1129
+    alias   1129
+
 charset x-IBM1364 IBM1364
     package sun.nio.cs.ext
     type    ebcdic
--- a/make/data/charsetmapping/stdcs-aix	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/data/charsetmapping/stdcs-aix	Tue Aug 21 01:21:58 2018 -0700
@@ -19,6 +19,7 @@
 IBM970
 IBM1046
 IBM1124
+IBM1129
 IBM1383
 ISO_8859_6
 ISO_8859_8
--- a/make/data/docs-resources/resources/jdk-default.css	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/data/docs-resources/resources/jdk-default.css	Tue Aug 21 01:21:58 2018 -0700
@@ -75,7 +75,7 @@
 }
 
 a:link {
-  color: #437291;
+  color: #4A6782;
 }
 
 a:visited {
@@ -117,7 +117,7 @@
 }
 
 tr:nth-child(even), tr:nth-child(even) th[scope=row] {
-  background: #DDD;
+  background: #E3E3E3;
 }
 
 tr:nth-child(odd), tr:nth-child(odd) th[scope=row] {
--- a/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/gensrc/Gensrc-jdk.internal.vm.compiler.gmk	Tue Aug 21 01:21:58 2018 -0700
@@ -123,7 +123,8 @@
 $(GENSRC_DIR)/module-info.java.extra: $(GENSRC_DIR)/_gensrc_proc_done
 	($(CD) $(GENSRC_DIR)/META-INF/providers && \
 	    p=""; \
-	    for i in $$($(LS) | $(SORT)); do \
+	    impl=""; \
+	    for i in $$($(GREP) '^' * | $(SORT) -t ':' -k 2 | $(SED) 's/:.*//'); do \
 	      c=$$($(CAT) $$i | $(TR) -d '\n\r'); \
 	      if test x$$p != x$$c; then \
                 if test x$$p != x; then \
@@ -131,15 +132,27 @@
 	        fi; \
 	        $(ECHO) "provides $$c with" >> $@; \
                 p=$$c; \
+	        impl=""; \
 	      fi; \
-	      $(ECHO) "    $$i," >> $@; \
+              if test x$$impl != x; then \
+	        $(ECHO) "  , $$i" >> $@; \
+              else \
+	        $(ECHO) "    $$i" >> $@; \
+              fi; \
+              impl=$$i; \
 	    done); \
             $(ECHO) "    ;" >> $@; \
 	$(ECHO) "uses org.graalvm.compiler.options.OptionDescriptors;" >> $@; \
 	$(ECHO) "provides org.graalvm.compiler.options.OptionDescriptors with" >> $@; \
+        impl=""; \
 	for i in $$($(FIND) $(GENSRC_DIR) -name '*_OptionDescriptors.java' | $(SORT)); do \
 	    c=$$($(ECHO) $$i | $(SED) 's:.*/jdk\.internal\.vm\.compiler/\(.*\)\.java:\1:' | $(TR) '/' '.'); \
-	    $(ECHO) "    $$c," >> $@; \
+            if test x$$impl != x; then \
+	      $(ECHO) "  , $$c" >> $@; \
+            else \
+	      $(ECHO) "    $$c" >> $@; \
+            fi; \
+            impl=$$c; \
 	done; \
 	$(ECHO) "    ;" >> $@;
 
--- a/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/hotspot/src/native/dtrace/generateJvmOffsets.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -40,6 +40,7 @@
 
 #include <proc_service.h>
 #include "gc/shared/collectedHeap.hpp"
+#include "memory/heap.hpp"
 #include "runtime/vmStructs.hpp"
 
 typedef enum GEN_variant {
--- a/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java	Tue Aug 21 01:21:58 2018 -0700
@@ -37,7 +37,9 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import static java.util.stream.Collectors.*;
 
@@ -131,7 +133,7 @@
         // parse module-info.java.extra
         this.extras = new ModuleInfo();
         for (Path file : extraFiles) {
-            extras.parse(file);
+            extras.parseExtra(file);
         }
 
         // merge with module-info.java.extra
@@ -177,6 +179,7 @@
         final Map<String, Statement> provides = new HashMap<>();
 
         Statement getStatement(String directive, String name) {
+            Objects.requireNonNull(name);
             switch (directive) {
                 case "exports":
                     if (moduleInfo.exports.containsKey(name) &&
@@ -223,49 +226,49 @@
             extraFiles.exports.entrySet()
                 .stream()
                 .filter(e -> exports.containsKey(e.getKey()) &&
-                                e.getValue().filter(modules))
+                    e.getValue().filter(modules))
                 .forEach(e -> mergeExportsOrOpens(exports.get(e.getKey()),
-                                                  e.getValue(),
-                                                  modules));
+                    e.getValue(),
+                    modules));
 
             // add exports that are not defined in the original module-info.java
             extraFiles.exports.entrySet()
                 .stream()
                 .filter(e -> !exports.containsKey(e.getKey()) &&
-                                e.getValue().filter(modules))
+                    e.getValue().filter(modules))
                 .forEach(e -> addTargets(getStatement("exports", e.getKey()),
-                                         e.getValue(),
-                                         modules));
+                    e.getValue(),
+                    modules));
 
             // API package opened in the original module-info.java
             extraFiles.opens.entrySet()
                 .stream()
                 .filter(e -> opens.containsKey(e.getKey()) &&
-                                e.getValue().filter(modules))
+                    e.getValue().filter(modules))
                 .forEach(e -> mergeExportsOrOpens(opens.get(e.getKey()),
-                                                  e.getValue(),
-                                                  modules));
+                    e.getValue(),
+                    modules));
 
             // add opens that are not defined in the original module-info.java
             extraFiles.opens.entrySet()
                 .stream()
                 .filter(e -> !opens.containsKey(e.getKey()) &&
-                                e.getValue().filter(modules))
+                    e.getValue().filter(modules))
                 .forEach(e -> addTargets(getStatement("opens", e.getKey()),
-                                         e.getValue(),
-                                         modules));
+                    e.getValue(),
+                    modules));
 
             // provides
             extraFiles.provides.keySet()
                 .stream()
                 .filter(service -> provides.containsKey(service))
                 .forEach(service -> mergeProvides(service,
-                                                  extraFiles.provides.get(service)));
+                    extraFiles.provides.get(service)));
             extraFiles.provides.keySet()
                 .stream()
                 .filter(service -> !provides.containsKey(service))
                 .forEach(service -> provides.put(service,
-                                                 extraFiles.provides.get(service)));
+                    extraFiles.provides.get(service)));
 
             // uses
             extraFiles.uses.keySet()
@@ -280,8 +283,8 @@
                                 Set<String> modules)
         {
             extra.targets.stream()
-                 .filter(mn -> modules.contains(mn))
-                 .forEach(mn -> statement.addTarget(mn));
+                .filter(mn -> modules.contains(mn))
+                .forEach(mn -> statement.addTarget(mn));
         }
 
         private void mergeExportsOrOpens(Statement statement,
@@ -319,7 +322,7 @@
             }
 
             extra.targets.stream()
-                 .forEach(mn -> statement.addTarget(mn));
+                .forEach(mn -> statement.addTarget(mn));
         }
 
 
@@ -358,189 +361,173 @@
                 .forEach(e -> writer.println(e.getValue()));
         }
 
-        private void parse(Path sourcefile) throws IOException {
-            List<String> lines = Files.readAllLines(sourcefile);
-            Statement statement = null;
-            boolean hasTargets = false;
 
-            for (int lineNumber = 1; lineNumber <= lines.size(); ) {
-                String l = lines.get(lineNumber-1).trim();
-                int index = 0;
+        private void parse(Path file) throws IOException {
+            Parser parser = new Parser(file);
+            parser.run();
+            if (verbose) {
+                parser.dump();
+            }
+            process(parser, false);
+        }
 
-                if (l.isEmpty()) {
-                    lineNumber++;
+        private void parseExtra(Path file) throws IOException {
+            Parser parser = new Parser(file);
+            parser.run();
+            if (verbose) {
+                parser.dump();
+            }
+            process(parser, true);
+        }
+
+
+        private void process(Parser parser, boolean extraFile) throws IOException {
+            // no duplicate statement local in each file
+            Map<String, Statement> exports = new HashMap<>();
+            Map<String, Statement> opens = new HashMap<>();
+            Map<String, Statement> uses = new HashMap<>();
+            Map<String, Statement> provides = new HashMap<>();
+
+            String token = null;
+            boolean hasCurlyBracket = false;
+            while ((token = parser.nextToken()) != null) {
+                if (token.equals("module")) {
+                    String modulename = nextIdentifier(parser);
+                    if (extraFile) {
+                        throw parser.newError("cannot declare module in " + parser.sourceFile);
+                    }
+                    skipTokenOrThrow(parser, "{", "missing {");
+                    hasCurlyBracket = true;
+                } else if (token.equals("requires")) {
+                    token = nextIdentifier(parser);
+                    if (token.equals("transitive")) {
+                        token = nextIdentifier(parser);
+                    }
+                    if (extraFile) {
+                        throw parser.newError("cannot declare requires in " + parser.sourceFile);
+                    }
+                    skipTokenOrThrow(parser, ";", "missing semicolon");
+                } else if (isExportsOpensProvidesUses(token)) {
+                    // new statement
+                    String keyword = token;
+                    String name = nextIdentifier(parser);
+                    Statement statement = getStatement(keyword, name);
+                    switch (keyword) {
+                        case "exports":
+                            if (exports.containsKey(name)) {
+                                throw parser.newError("multiple " + keyword + " " + name);
+                            }
+                            exports.put(name, statement);
+                            break;
+                        case "opens":
+                            if (opens.containsKey(name)) {
+                                throw parser.newError("multiple " + keyword + " " + name);
+                            }
+                            opens.put(name, statement);
+                            break;
+                        case "uses":
+                            if (uses.containsKey(name)) {
+                                throw parser.newError("multiple " + keyword + " " + name);
+                            }
+                            uses.put(name, statement);
+                            break;
+                        /*  Disable this check until jdk.internal.vm.compiler generated file is fixed.
+                        case "provides":
+                            if (provides.containsKey(name)) {
+                                throw parser.newError("multiple " + keyword + " " + name);
+                            }
+                            provides.put(name, statement);
+                            break;
+                        */
+                    }
+                    String lookAhead = lookAhead(parser);
+                    if (lookAhead.equals(statement.qualifier)) {
+                        parser.nextToken(); // skip qualifier
+                        while ((lookAhead = parser.peekToken()) != null) {
+                            // add target name
+                            name = nextIdentifier(parser);
+                            statement.addTarget(name);
+                            lookAhead = lookAhead(parser);
+                            if (lookAhead.equals(",") || lookAhead.equals(";")) {
+                                parser.nextToken();
+                            } else {
+                                throw parser.newError("missing semicolon");
+                            }
+                            if (lookAhead.equals(";")) {
+                                break;
+                            }
+                        }
+                    } else {
+                        skipTokenOrThrow(parser, ";", "missing semicolon");
+                    }
+                } else if (token.equals(";")) {
                     continue;
+                } else if (hasCurlyBracket && token.equals("}")) {
+                    hasCurlyBracket = false;
+                    if (parser.peekToken() != null) {  // must be EOF
+                        throw parser.newError("is malformed");
+                    }
+                } else {
+                    throw parser.newError("missing keyword");
                 }
+            }
+            if (hasCurlyBracket) {
+                parser.newError("missing }");
+            }
+        }
 
-                // comment block starts
-                if (l.startsWith("/*")) {
-                    while (l.indexOf("*/") == -1) { // end comment block
-                        l = lines.get(lineNumber++).trim();
-                    }
-                    index = l.indexOf("*/") + 2;
-                    if (index >= l.length()) {
-                        lineNumber++;
-                        continue;
-                    } else {
-                        // rest of the line
-                        l = l.substring(index, l.length()).trim();
-                        index = 0;
-                    }
-                }
+        private boolean isExportsOpensProvidesUses(String word) {
+            switch (word) {
+                case "exports":
+                case "opens":
+                case "provides":
+                case "uses":
+                    return true;
+                default:
+                    return false;
+            }
+        }
 
-                // skip comment and annotations
-                if (l.startsWith("//") || l.startsWith("@")) {
-                    lineNumber++;
-                    continue;
-                }
+        private String lookAhead(Parser parser) {
+            String lookAhead = parser.peekToken();
+            if (lookAhead == null) { // EOF
+                throw parser.newError("reach end of file");
+            }
+            return lookAhead;
+        }
 
-                int current = lineNumber;
-                int count = 0;
-                while (index < l.length()) {
-                    if (current == lineNumber && ++count > 20)
-                        throw new Error("Fail to parse line " + lineNumber + " " + sourcefile);
+        private String nextIdentifier(Parser parser) {
+            String lookAhead = parser.peekToken();
+            boolean maybeIdentifier = true;
+            switch (lookAhead) {
+                case "module":
+                case "requires":
+                case "exports":
+                case "opens":
+                case "provides":
+                case "uses":
+                case "to":
+                case "with":
+                case ",":
+                case ";":
+                case "{":
+                case "}":
+                    maybeIdentifier = false;
+            }
+            if (lookAhead == null || !maybeIdentifier) {
+                throw parser.newError("<identifier> missing");
+            }
 
-                    int end = l.indexOf(';');
-                    if (end == -1)
-                        end = l.length();
-                    String content = l.substring(0, end).trim();
-                    if (content.isEmpty()) {
-                        index = end+1;
-                        if (index < l.length()) {
-                            // rest of the line
-                            l = l.substring(index, l.length()).trim();
-                            index = 0;
-                        }
-                        continue;
-                    }
+            return parser.nextToken();
+        }
 
-                    String[] s = content.split("\\s+");
-                    String keyword = s[0].trim();
-
-                    String name = s.length > 1 ? s[1].trim() : null;
-                    trace("%d: %s index=%d len=%d%n", lineNumber, l, index, l.length());
-                    switch (keyword) {
-                        case "module":
-                        case "requires":
-                        case "}":
-                            index = l.length();  // skip to the end
-                            continue;
-
-                        case "exports":
-                        case "opens":
-                        case "provides":
-                        case "uses":
-                            // assume name immediately after exports, opens, provides, uses
-                            statement = getStatement(keyword, name);
-                            hasTargets = false;
-
-                            int i = l.indexOf(name, keyword.length()+1) + name.length() + 1;
-                            l = i < l.length() ? l.substring(i, l.length()).trim() : "";
-                            index = 0;
-
-                            if (s.length >= 3) {
-                                if (!s[2].trim().equals(statement.qualifier)) {
-                                    throw new RuntimeException(sourcefile + ", line " +
-                                        lineNumber + ", is malformed: " + s[2]);
-                                }
-                            }
-
-                            break;
-
-                        case "to":
-                        case "with":
-                            if (statement == null) {
-                                throw new RuntimeException(sourcefile + ", line " +
-                                    lineNumber + ", is malformed");
-                            }
-
-                            hasTargets = true;
-                            String qualifier = statement.qualifier;
-                            i = l.indexOf(qualifier, index) + qualifier.length() + 1;
-                            l = i < l.length() ? l.substring(i, l.length()).trim() : "";
-                            index = 0;
-                            break;
-                    }
-
-                    if (index >= l.length()) {
-                        // skip to next line
-                        continue;
-                    }
-
-                        // comment block starts
-                    if (l.startsWith("/*")) {
-                        while (l.indexOf("*/") == -1) { // end comment block
-                            l = lines.get(lineNumber++).trim();
-                        }
-                        index = l.indexOf("*/") + 2;
-                        if (index >= l.length()) {
-                            continue;
-                        } else {
-                            // rest of the line
-                            l = l.substring(index, l.length()).trim();
-                            index = 0;
-                        }
-                    }
-
-                    if (l.startsWith("//")) {
-                        index = l.length();
-                        continue;
-                    }
-
-                    if (statement == null) {
-                        throw new RuntimeException(sourcefile + ", line " +
-                            lineNumber + ": missing keyword?");
-                    }
-
-                    if (!hasTargets) {
-                        continue;
-                    }
-
-                    if (index >= l.length()) {
-                        throw new RuntimeException(sourcefile + ", line " +
-                            lineNumber + ": " + l);
-                    }
-
-                    // parse the target module of exports, opens, or provides
-                    Statement stmt = statement;
-
-                    int terminal = l.indexOf(';', index);
-                    // determine up to which position to parse
-                    int pos = terminal != -1 ? terminal : l.length();
-                    // parse up to comments
-                    int pos1 = l.indexOf("//", index);
-                    if (pos1 != -1 && pos1 < pos) {
-                        pos = pos1;
-                    }
-                    int pos2 = l.indexOf("/*", index);
-                    if (pos2 != -1 && pos2 < pos) {
-                        pos = pos2;
-                    }
-                    // target module(s) for qualitifed exports or opens
-                    // or provider implementation class(es)
-                    String rhs = l.substring(index, pos).trim();
-                    index += rhs.length();
-                    trace("rhs: index=%d [%s] [line: %s]%n", index, rhs, l);
-
-                    String[] targets = rhs.split(",");
-                    for (String t : targets) {
-                        String n = t.trim();
-                        if (n.length() > 0)
-                            stmt.addTarget(n);
-                    }
-
-                    // start next statement
-                    if (pos == terminal) {
-                        statement = null;
-                        hasTargets = false;
-                        index = terminal + 1;
-                    }
-                    l = index < l.length() ? l.substring(index, l.length()).trim() : "";
-                    index = 0;
-                }
-
-                lineNumber++;
+        private String skipTokenOrThrow(Parser parser, String token, String msg) {
+            // look ahead to report the proper line number
+            String lookAhead = parser.peekToken();
+            if (!token.equals(lookAhead)) {
+                throw parser.newError(msg);
             }
+            return parser.nextToken();
         }
     }
 
@@ -620,4 +607,175 @@
             System.out.format(fmt, params);
         }
     }
+
+    static class Parser {
+        private static final List<String> EMPTY = List.of();
+
+        private final Path sourceFile;
+        private boolean inCommentBlock = false;
+        private List<List<String>> tokens = new ArrayList<>();
+        private int lineNumber = 1;
+        private int index = 0;
+
+        Parser(Path file) {
+            this.sourceFile = file;
+        }
+
+        void run() throws IOException {
+            List<String> lines = Files.readAllLines(sourceFile);
+            for (int lineNumber = 1; lineNumber <= lines.size(); lineNumber++) {
+                String l = lines.get(lineNumber - 1).trim();
+                tokenize(l);
+            }
+        }
+
+        /*
+         * Tokenize the given string.  Comments are skipped.
+         */
+        List<String> tokenize(String l) {
+            while (!l.isEmpty()) {
+                if (inCommentBlock) {
+                    int comment = l.indexOf("*/");
+                    if (comment == -1)
+                        return emptyTokens();
+
+                    // end comment block
+                    inCommentBlock = false;
+                    if ((comment + 2) >= l.length()) {
+                        return emptyTokens();
+                    }
+                    l = l.substring(comment + 2, l.length()).trim();
+                }
+
+                // skip comment
+                int comment = l.indexOf("//");
+                if (comment >= 0) {
+                    l = l.substring(0, comment).trim();
+                    if (l.isEmpty()) return emptyTokens();
+                }
+
+                if (l.isEmpty()) {
+                    return emptyTokens();
+                }
+
+                int beginComment = l.indexOf("/*");
+                int endComment = l.indexOf("*/");
+                if (beginComment == -1)
+                    return tokens(l);
+
+                String s1 = l.substring(0, beginComment).trim();
+                if (endComment > 0) {
+                    String s2 = l.substring(endComment + 2, l.length()).trim();
+                    if (s1.isEmpty()) {
+                        l = s2;
+                    } else if (s2.isEmpty()) {
+                        l = s1;
+                    } else {
+                        l = s1 + " " + s2;
+                    }
+                } else {
+                    inCommentBlock = true;
+                    return tokens(s1);
+                }
+            }
+            return tokens(l);
+        }
+
+        private List<String> emptyTokens() {
+            this.tokens.add(EMPTY);
+            return EMPTY;
+        }
+        private List<String> tokens(String l) {
+            List<String> tokens = new ArrayList<>();
+            for (String s : l.split("\\s+")) {
+                int pos=0;
+                s = s.trim();
+                if (s.isEmpty())
+                     continue;
+
+                int i = s.indexOf(',', pos);
+                int j = s.indexOf(';', pos);
+                while ((i >= 0 && i < s.length()) || (j >= 0 && j < s.length())) {
+                    if (j == -1 || (i >= 0 && i < j)) {
+                        String n = s.substring(pos, i).trim();
+                        if (!n.isEmpty()) {
+                            tokens.add(n);
+                        }
+                        tokens.add(s.substring(i, i + 1));
+                        pos = i + 1;
+                        i = s.indexOf(',', pos);
+                    } else {
+                        String n = s.substring(pos, j).trim();
+                        if (!n.isEmpty()) {
+                            tokens.add(n);
+                        }
+                        tokens.add(s.substring(j, j + 1));
+                        pos = j + 1;
+                        j = s.indexOf(';', pos);
+                    }
+                }
+
+                String n = s.substring(pos).trim();
+                if (!n.isEmpty()) {
+                    tokens.add(n);
+                }
+            }
+            this.tokens.add(tokens);
+            return tokens;
+        }
+
+        /*
+         * Returns next token.
+         */
+        String nextToken() {
+            while (lineNumber <= tokens.size()) {
+                List<String> l = tokens.get(lineNumber-1);
+                if (index < l.size()) {
+                    return l.get(index++);
+                } else {
+                    lineNumber++;
+                    index = 0;
+                }
+            }
+            return null;
+        }
+
+        /*
+         * Peeks next token.
+         */
+        String peekToken() {
+            int ln = lineNumber;
+            int i = index;
+            while (ln <= tokens.size()) {
+                List<String> l = tokens.get(ln-1);
+                if (i < l.size()) {
+                    return l.get(i++);
+                } else {
+                    ln++;
+                    i = 0;
+                }
+            }
+            return null;
+        }
+
+        Error newError(String msg) {
+            if (lineNumber <= tokens.size()) {
+                throw new Error(sourceFile + ", line " +
+                    lineNumber + ", " + msg + " \"" + lineAt(lineNumber) + "\"");
+            } else {
+                throw new Error(sourceFile + ", line " + lineNumber + ", " + msg);
+            }
+        }
+
+        void dump() {
+            for (int i = 1; i <= tokens.size(); i++) {
+                System.out.format("%d: %s%n", i, lineAt(i));
+            }
+        }
+
+        private String lineAt(int i) {
+            return tokens.get(i-1).stream().collect(Collectors.joining(" "));
+        }
+    }
 }
+
--- a/make/jdk/src/classes/build/tools/module/ModuleInfoExtraTest.java	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/jdk/src/classes/build/tools/module/ModuleInfoExtraTest.java	Tue Aug 21 01:21:58 2018 -0700
@@ -28,6 +28,7 @@
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.UncheckedIOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -35,6 +36,7 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import build.tools.module.GenModuleInfoSource.Statement;
 
@@ -42,29 +44,36 @@
  * Sanity test for GenModuleInfoSource tool
  */
 public class ModuleInfoExtraTest {
-    private static final Path DIR = Paths.get("test");
+    private static final Path DIR = Paths.get("gen-module-info-test");
+    private static boolean verbose = false;
     public static void main(String... args) throws Exception {
         if (args.length != 0)
-            GenModuleInfoSource.verbose = true;
+            verbose = true;
 
+        GenModuleInfoSource.verbose = verbose;
         ModuleInfoExtraTest test = new ModuleInfoExtraTest("m", "m1", "m2", "m3");
-        test.run();
+        test.testModuleInfo();
+        test.errorCases();
     }
 
     String[] moduleInfo = new String[] {
-        "exports p",
-        "to",
-        "   // comment",
-        "   /* comment */ m1",
+        "module m {",
+        "    requires m1;",
+        "    requires transitive m2;",
+        "    exports p",
+        "    to",
+        "               // comment ... ",
+        "    /* comment */ m1",
         ",",
-        "m2,m3",
-        "   ;",
-        "exports q to m1;",
-        "provides s with /* ",
-        "  comment */ impl     ;    // comment",
-        "provides s1",
-        "    with  ",
-        "    impl1, impl2;"
+        "       m2,m3",
+        "  ;",
+        "    exports q to m1;",
+        "    provides s with /*   ",
+        "    comment */ impl     ;    // comment",
+        "    provides s1",
+        "       with  ",
+        "       impl1, impl2;",
+        "}"
     };
 
     String[] moduleInfoExtra = new String[] {
@@ -76,33 +85,8 @@
         "opens p.q ",
         "   to /* comment */ m3",
         "   , // m1",
-        "   /* comment */, m4;",
-        "provides s1 with impl3;"
-    };
-
-    String[] test1 = new String[] {
-        "exports p1 to m1;",
-        "exports p2"
-    };
-
-    String[] test2 = new String[] {
-        "exports to m1;"
-    };
-
-    String[] test3 = new String[]{
-        "exports p3 to m1;",
-        "    m2, m3;"
-    };
-
-    String[] test4 = new String[]{
-        "provides s with impl1;",   // typo ; should be ,
-        "   impl2, impl3;"
-    };
-
-    String[] test5 = new String[]{
-        "uses s3",
-        "provides s3 with impl1,",
-        "   impl2, impl3;"
+        "   /* comment */ m4; uses p.I",
+        ";   provides s1 with impl3;"
     };
 
     final Builder builder;
@@ -110,11 +94,6 @@
         this.builder = new Builder(name).modules(modules);
     }
 
-    void run() throws IOException {
-        testModuleInfo();
-        errorCases();
-    }
-
 
     void testModuleInfo() throws IOException {
         GenModuleInfoSource source = builder.sourceFile(moduleInfo).build();
@@ -155,7 +134,9 @@
                Set<String> opensPQ,
                Set<String> providerS,
                Set<String> providerS1) {
-        source.moduleInfo.print(new PrintWriter(System.out, true));
+        if (verbose)
+            source.moduleInfo.print(new PrintWriter(System.out, true));
+
         Statement export = source.moduleInfo.exports.get("p");
         if (!export.targets.equals(targetsP)) {
             throw new Error("unexpected: " + export);
@@ -177,24 +158,112 @@
         }
     }
 
+    final Map<String[], String> badModuleInfos = Map.of(
+        new String[] {
+            "module x {",
+            "   exports p1 to ",
+            "           m1",
+            "}"
+        },                      ".*, line .*, missing semicolon.*",
+        new String[] {
+            "module x ",
+            "   exports p1;"
+        },                      ".*, line .*, missing \\{.*",
+        new String[] {
+            "module x {",
+            "   requires m1;",
+            "   requires",
+            "}"
+        },                      ".*, line .*, <identifier> missing.*",
+        new String[] {
+            "module x {",
+            "   requires transitive m1",
+            "}"
+        },                      ".*, line .*, missing semicolon.*",
+        new String[] {
+            "module x {",
+            "   exports p1 to m1;",
+            "   exports p1 to m2;",
+            "}"
+        },                      ".*, line .*, multiple exports p1.*"
+    );
 
+    final Map<String[], String> badExtraFiles = Map.of(
+            new String[] {
+                "requires m2;"     // not allowed
+            },                      ".*, line .*, cannot declare requires .*",
+            new String[] {
+                "exports p1 to m1;",
+                "exports p2"            // missing semicolon
+            },                      ".*, line .*, reach end of file.*",
+            new String[] {
+                "exports to m1;"        // missing <identifier>
+            },                      ".*, line .*, <identifier> missing.*",
+            new String[] {
+                "exports p3 to m1;",
+                "    m2, m3;"           // missing keyword
+            },                      ".*, line .*, missing keyword.*",
+            new String[] {
+                "provides s with impl1;",   // typo ; should be ,
+                "   impl2, impl3;"
+            },                      ".*, line .*, missing keyword.*",
+            new String[] {
+                "uses s3",                  // missing semicolon
+                "provides s3 with impl1,",
+                "   impl2, impl3;"
+            },                      ".*, line .*, missing semicolon.*",
+            new String[] {
+                "opens p1 to m1,, m2;"     // missing identifier
+            },                      ".*, line .*, <identifier> missing.*"
+    );
 
-    void errorCases() throws IOException {
-        fail(test1);
-        fail(test2);
-        fail(test3);
-        fail(test4);
-        fail(test5);
+    final Map<String[], String> duplicates = Map.of(
+            new String[] {
+                "   exports p1 to m1, m2;",
+                "   exports p1 to m3;",
+            },                      ".*, line .*, multiple exports p1.*",
+            new String[] {
+                "   opens p1 to m1, m2;",
+                "   exports p1 to m3;",
+                "   opens p1 to m3;"
+            },                      ".*, line .*, multiple opens p1.*",
+            new String[] {
+                "   uses s;",
+                "   uses s;"
+            },                      ".*, line .*, multiple uses s.*"
+    );
+
+    void errorCases() {
+        badModuleInfos.entrySet().stream().forEach(e -> badModuleInfoFile(e.getKey(), e.getValue()));
+        badExtraFiles.entrySet().stream().forEach(e -> badExtraFile(e.getKey(), e.getValue()));
+        duplicates.entrySet().stream().forEach(e -> badExtraFile(e.getKey(), e.getValue()));
     }
 
-    void fail(String... extras) throws IOException {
+    void badModuleInfoFile(String[] lines, String regex)  {
+        Builder builder = new Builder("x").modules("m1", "m2", "m3");
+        try {
+            GenModuleInfoSource source = builder.sourceFile(lines).build();
+            throw new RuntimeException("Expected error: " + Arrays.toString(lines));
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        } catch (Error e) {
+            if (!e.getMessage().matches(regex)) {
+                throw e;
+            }
+        }
+    }
+
+    void badExtraFile(String[] extras, String regex)  {
         Path file = DIR.resolve("test1");
-        Files.write(file, Arrays.asList(extras));
         try {
+            Files.write(file, Arrays.asList(extras));
             builder.build(file);
-        } catch (RuntimeException e) {
-            if (!e.getMessage().matches("test/test1, line .* is malformed.*") &&
-                !e.getMessage().matches("test/test1, line .* missing keyword.*")) {
+            Files.deleteIfExists(file);
+            throw new RuntimeException("Expected error: " + Arrays.toString(extras));
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        } catch (Error e) {
+            if (!e.getMessage().matches(regex)) {
                 throw e;
             }
         }
@@ -218,11 +287,9 @@
             Files.createDirectories(sourceFile.getParent());
             try (BufferedWriter bw = Files.newBufferedWriter(sourceFile);
                  PrintWriter writer = new PrintWriter(bw)) {
-                writer.format("module %s {%n", moduleName);
                 for (String l : lines) {
                     writer.println(l);
                 }
-                writer.println("}");
             }
             return this;
         }
--- a/make/lib/Awt2dLibraries.gmk	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/lib/Awt2dLibraries.gmk	Tue Aug 21 01:21:58 2018 -0700
@@ -796,6 +796,12 @@
 
   LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0
 
+  ifeq ($(OPENJDK_TARGET_OS), linux)
+    ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc)
+      LIBSPLASHSCREEN_CFLAGS += -DPNG_POWERPC_VSX_OPT=0
+    endif
+  endif
+
   ifeq ($(OPENJDK_TARGET_OS), macosx)
     LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX
 
--- a/make/lib/Lib-jdk.jdi.gmk	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/lib/Lib-jdk.jdi.gmk	Tue Aug 21 01:21:58 2018 -0700
@@ -32,7 +32,7 @@
   $(eval $(call SetupJdkLibrary, BUILD_LIBDT_SHMEM, \
       NAME := dt_shmem, \
       OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP, \
+      CFLAGS := $(CFLAGS_JDKLIB), \
       EXTRA_HEADER_DIRS := \
           jdk.jdwp.agent:include \
           jdk.jdwp.agent:libjdwp/export, \
--- a/make/lib/Lib-jdk.jdwp.agent.gmk	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/lib/Lib-jdk.jdwp.agent.gmk	Tue Aug 21 01:21:58 2018 -0700
@@ -30,8 +30,7 @@
 $(eval $(call SetupJdkLibrary, BUILD_LIBDT_SOCKET, \
     NAME := dt_socket, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) -DUSE_MMAP \
-        $(LIBDT_SOCKET_CPPFLAGS), \
+    CFLAGS := $(CFLAGS_JDKLIB) $(LIBDT_SOCKET_CPPFLAGS), \
     EXTRA_HEADER_DIRS := \
         include \
         libjdwp/export, \
--- a/make/nb_native/nbproject/configurations.xml	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/nb_native/nbproject/configurations.xml	Tue Aug 21 01:21:58 2018 -0700
@@ -116,6 +116,7 @@
             <in>IBM1122.map</in>
             <in>IBM1123.map</in>
             <in>IBM1124.map</in>
+            <in>IBM1129.map</in>
             <in>IBM1140.map</in>
             <in>IBM1141.map</in>
             <in>IBM1142.map</in>
@@ -16285,6 +16286,11 @@
             tool="3"
             flavor2="0">
       </item>
+      <item path="../../make/data/charsetmapping/IBM1129.map"
+            ex="false"
+            tool="3"
+            flavor2="0">
+      </item>
       <item path="../../make/data/charsetmapping/IBM1140.map"
             ex="false"
             tool="3"
--- a/make/test/JtregGraalUnit.gmk	Thu Aug 02 14:44:58 2018 -0700
+++ b/make/test/JtregGraalUnit.gmk	Tue Aug 21 01:21:58 2018 -0700
@@ -46,6 +46,20 @@
     COMPILE_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/test/graalunit
     LIB_OUTPUTDIR := $(TEST_IMAGE_DIR)/hotspot/jtreg/graal
 
+    TEST_COMPILE_CP := \
+        $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.compiler \
+        $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.ci \
+        $(LIB_OUTPUTDIR)/junit-4.12.jar \
+        $(LIB_OUTPUTDIR)/asm-5.0.4.jar \
+        $(LIB_OUTPUTDIR)/asm-tree-5.0.4.jar \
+        $(LIB_OUTPUTDIR)/java-allocation-instrumenter.jar \
+        $(LIB_OUTPUTDIR)/hamcrest-core-1.3.jar
+
+    TEST_JAVAC_FLAGS := \
+        -Xlint:none \
+        -processorpath $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.replacements.verifier.jar \
+        --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED \
+
     ### Copy 3rd party libs
     $(eval $(call SetupCopyFiles, COPY_GRAALUNIT_LIBS, \
         FILES := $(wildcard $(GRAALUNIT_LIB)/*.jar), \
@@ -54,7 +68,7 @@
 
     TARGETS_EXTRA_LIB += $(COPY_GRAALUNIT_LIBS)
 
-    ### Compile and build graalunit tests
+    ### Compile graalunit tests
     $(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_TESTS, \
         SETUP := GENERATE_USINGJDKBYTECODE, \
         SRC := \
@@ -84,26 +98,41 @@
             $(SRC_DIR)/org.graalvm.compiler.jtt/src \
             $(SRC_DIR)/org.graalvm.compiler.lir.jtt/src \
             , \
+        EXCLUDE_FILES := org/graalvm/compiler/core/test/VerifyDebugUsageTest.java, \
         BIN := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
-        JAR := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests.jar, \
-        CLASSPATH := \
-            $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.compiler \
-            $(JDK_OUTPUTDIR)/modules/jdk.internal.vm.ci \
-            $(LIB_OUTPUTDIR)/junit-4.12.jar \
-            $(LIB_OUTPUTDIR)/asm-5.0.4.jar \
-            $(LIB_OUTPUTDIR)/asm-tree-5.0.4.jar \
-            $(LIB_OUTPUTDIR)/java-allocation-instrumenter.jar \
-            $(LIB_OUTPUTDIR)/hamcrest-core-1.3.jar \
-            , \
-        ADD_JAVAC_FLAGS := \
-            -Xlint:none -processorpath \
-            $(BUILDTOOLS_OUTPUTDIR)/jdk.vm.compiler.replacements.verifier.jar \
-            --add-exports jdk.unsupported/sun.misc=ALL-UNNAMED \
-            , \
+        CLASSPATH := $(TEST_COMPILE_CP), \
+        ADD_JAVAC_FLAGS := $(TEST_JAVAC_FLAGS), \
     ))
 
     TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS)
 
+    ### Compile graalunit tests which require -XDstringConcat=inline
+    $(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_TESTS_SET2, \
+        SETUP := GENERATE_USINGJDKBYTECODE, \
+        DEPENDS := $(BUILD_VM_COMPILER_TESTS), \
+        SRC := $(SRC_DIR)/org.graalvm.compiler.core.test/src, \
+        INCLUDE_FILES := org/graalvm/compiler/core/test/VerifyDebugUsageTest.java, \
+        BIN := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
+        CLASSPATH := \
+            $(TEST_COMPILE_CP) \
+            $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests \
+            , \
+        ADD_JAVAC_FLAGS := \
+            $(TEST_JAVAC_FLAGS) \
+            -XDstringConcat=inline \
+            , \
+    ))
+
+    TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS_SET2)
+
+    ### Generate jdk.vm.compiler.tests.jar
+    $(eval $(call SetupJarArchive, BUILD_VM_COMPILER_TESTS_JAR, \
+        DEPENDENCIES := $(BUILD_VM_COMPILER_TESTS) $(BUILD_VM_COMPILER_TESTS_SET2), \
+        SRCS := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests, \
+        JAR := $(COMPILE_OUTPUTDIR)/jdk.vm.compiler.tests.jar, \
+    ))
+
+    TARGETS_BUILD += $(BUILD_VM_COMPILER_TESTS_JAR)
 
     ### Compile and build mxtool
     $(eval $(call SetupJavaCompilation, BUILD_MXTOOL, \
--- a/src/hotspot/.mx.jvmci/suite.py	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/.mx.jvmci/suite.py	Tue Aug 21 01:21:58 2018 -0700
@@ -43,7 +43,8 @@
     "jdk.vm.ci.services" : {
       "subDir" : "../jdk.internal.vm.ci/share/classes",
       "sourceDirs" : ["src"],
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
+      "checkstyleVersion" : "8.8",
       "workingSets" : "API,JVMCI",
     },
 
@@ -53,7 +54,7 @@
       "subDir" : "../jdk.internal.vm.ci/share/classes",
       "sourceDirs" : ["src"],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -61,7 +62,7 @@
       "subDir" : "../jdk.internal.vm.ci/share/classes",
       "sourceDirs" : ["src"],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -70,7 +71,7 @@
       "sourceDirs" : ["src"],
       "dependencies" : ["jdk.vm.ci.meta"],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -85,7 +86,7 @@
         "jdk.vm.ci.hotspot",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -97,7 +98,7 @@
         "jdk.vm.ci.services",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -110,7 +111,7 @@
         "jdk.vm.ci.runtime",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -121,7 +122,7 @@
       "sourceDirs" : ["src"],
       "dependencies" : ["jdk.vm.ci.code"],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI,AArch64",
     },
 
@@ -130,7 +131,7 @@
       "sourceDirs" : ["src"],
       "dependencies" : ["jdk.vm.ci.code"],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI,AMD64",
     },
 
@@ -139,7 +140,7 @@
       "sourceDirs" : ["src"],
       "dependencies" : ["jdk.vm.ci.code"],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI,SPARC",
     },
 
@@ -156,7 +157,7 @@
         "jdk.internal.org.objectweb.asm",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI",
     },
 
@@ -168,7 +169,7 @@
         "jdk.vm.ci.hotspot",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "API,JVMCI",
     },
 
@@ -180,7 +181,7 @@
         "jdk.vm.ci.hotspot",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI,HotSpot,AArch64",
     },
 
@@ -192,7 +193,7 @@
         "jdk.vm.ci.hotspot",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI,HotSpot,AMD64",
     },
 
@@ -204,7 +205,7 @@
         "jdk.vm.ci.hotspot",
       ],
       "checkstyle" : "jdk.vm.ci.services",
-      "javaCompliance" : "9",
+      "javaCompliance" : "9+",
       "workingSets" : "JVMCI,HotSpot,SPARC",
     },
 
--- a/src/hotspot/cpu/aarch64/aarch64.ad	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/aarch64.ad	Tue Aug 21 01:21:58 2018 -0700
@@ -14471,7 +14471,7 @@
   format %{ "cmp   $op1, $op2\t# overflow check long" %}
   ins_cost(INSN_COST);
   ins_encode %{
-    __ cmp($op1$$Register, $op2$$constant);
+    __ subs(zr, $op1$$Register, $op2$$constant);
   %}
 
   ins_pipe(icmp_reg_imm);
--- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -295,7 +295,7 @@
   int _offset;
   Register _r;
 public:
-  PrePost(Register reg, int o) : _r(reg), _offset(o) { }
+  PrePost(Register reg, int o) : _offset(o), _r(reg) { }
   int offset() { return _offset; }
   Register reg() { return _r; }
 };
@@ -353,7 +353,7 @@
     ext::operation _op;
   public:
     extend() { }
-    extend(int s, int o, ext::operation op) : _shift(s), _option(o), _op(op) { }
+    extend(int s, int o, ext::operation op) : _option(o), _shift(s), _op(op) { }
     int option() const{ return _option; }
     int shift() const { return _shift; }
     ext::operation op() const { return _op; }
@@ -398,26 +398,25 @@
   Address()
     : _mode(no_mode) { }
   Address(Register r)
-    : _mode(base_plus_offset), _base(r), _offset(0), _index(noreg), _target(0) { }
+    : _base(r), _index(noreg), _offset(0), _mode(base_plus_offset), _target(0) { }
   Address(Register r, int o)
-    : _mode(base_plus_offset), _base(r), _offset(o), _index(noreg), _target(0) { }
+    : _base(r), _index(noreg), _offset(o), _mode(base_plus_offset), _target(0) { }
   Address(Register r, long o)
-    : _mode(base_plus_offset), _base(r), _offset(o), _index(noreg), _target(0) { }
+    : _base(r), _index(noreg), _offset(o), _mode(base_plus_offset), _target(0) { }
   Address(Register r, unsigned long o)
-    : _mode(base_plus_offset), _base(r), _offset(o), _index(noreg), _target(0) { }
+    : _base(r), _index(noreg), _offset(o), _mode(base_plus_offset), _target(0) { }
 #ifdef ASSERT
   Address(Register r, ByteSize disp)
-    : _mode(base_plus_offset), _base(r), _offset(in_bytes(disp)),
-      _index(noreg), _target(0) { }
+    : _base(r), _index(noreg), _offset(in_bytes(disp)), _mode(base_plus_offset), _target(0) { }
 #endif
   Address(Register r, Register r1, extend ext = lsl())
-    : _mode(base_plus_offset_reg), _base(r), _index(r1),
-    _ext(ext), _offset(0), _target(0) { }
+    : _base(r), _index(r1), _offset(0), _mode(base_plus_offset_reg),
+      _ext(ext), _target(0) { }
   Address(Pre p)
-    : _mode(pre), _base(p.reg()), _offset(p.offset()) { }
+    : _base(p.reg()), _offset(p.offset()), _mode(pre) { }
   Address(Post p)
-    : _mode(p.idx_reg() == NULL ? post : post_reg), _base(p.reg()),
-      _offset(p.offset()), _target(0), _index(p.idx_reg()) { }
+    : _base(p.reg()),  _index(p.idx_reg()), _offset(p.offset()),
+      _mode(p.idx_reg() == NULL ? post : post_reg), _target(0) { }
   Address(address target, RelocationHolder const& rspec)
     : _mode(literal),
       _rspec(rspec),
@@ -426,7 +425,7 @@
   Address(address target, relocInfo::relocType rtype = relocInfo::external_word_type);
   Address(Register base, RegisterOrConstant index, extend ext = lsl())
     : _base (base),
-      _ext(ext), _offset(0), _target(0) {
+      _offset(0), _ext(ext), _target(0) {
     if (index.is_register()) {
       _mode = base_plus_offset_reg;
       _index = index.as_register();
--- a/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/c1_CodeStubs_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -50,13 +50,13 @@
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
-  : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) {
+  : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
-  : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) {
+  : _index(index), _array(NULL), _throw_index_out_of_bounds_exception(true) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
--- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1922,7 +1922,7 @@
         if (is_32bit)
           __ cmpw(reg1, imm);
         else
-          __ cmp(reg1, imm);
+          __ subs(zr, reg1, imm);
         return;
       } else {
         __ mov(rscratch1, imm);
@@ -2705,7 +2705,7 @@
 
         if (TypeEntries::is_type_none(current_klass)) {
           __ cbz(rscratch2, none);
-          __ cmp(rscratch2, TypeEntries::null_seen);
+          __ cmp(rscratch2, (u1)TypeEntries::null_seen);
           __ br(Assembler::EQ, none);
           // There is a chance that the checks above (re-reading profiling
           // data from memory) fail if another thread has just set the
@@ -2750,7 +2750,7 @@
           Label ok;
           __ ldr(rscratch1, mdo_addr);
           __ cbz(rscratch1, ok);
-          __ cmp(rscratch1, TypeEntries::null_seen);
+          __ cmp(rscratch1, (u1)TypeEntries::null_seen);
           __ br(Assembler::EQ, ok);
           // may have been set by another thread
           __ dmb(Assembler::ISHLD);
--- a/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -712,7 +712,7 @@
           {
             Label ok, not_ok;
             __ ldrw(obj_size, Address(klass, Klass::layout_helper_offset()));
-            __ cmp(obj_size, 0u);
+            __ cmp(obj_size, (u1)0);
             __ br(Assembler::LE, not_ok);  // make sure it's an instance (LH > 0)
             __ tstw(obj_size, Klass::_lh_instance_slow_path_bit);
             __ br(Assembler::EQ, ok);
--- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetAssembler_aarch64.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -48,6 +48,10 @@
   virtual void obj_equals(MacroAssembler* masm,
                           Register obj1, Register obj2);
 
+  virtual void resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj) {
+    // Default implementation does not need to do anything.
+  }
+
   virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
                                              Register obj, Register tmp, Label& slowpath);
 
--- a/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1636,7 +1636,7 @@
 
   ldr(rscratch1, mdo_addr);
   cbz(rscratch1, none);
-  cmp(rscratch1, TypeEntries::null_seen);
+  cmp(rscratch1, (u1)TypeEntries::null_seen);
   br(Assembler::EQ, none);
   // There is a chance that the checks above (re-reading profiling
   // data from memory) fail if another thread has just set the
@@ -1670,7 +1670,7 @@
     int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size());
 
     ldrb(rscratch1, Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start));
-    cmp(rscratch1, is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag);
+    cmp(rscratch1, u1(is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag));
     br(Assembler::NE, profile_continue);
 
     if (MethodData::profile_arguments()) {
@@ -1682,7 +1682,7 @@
           // If return value type is profiled we may have no argument to profile
           ldr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
           sub(tmp, tmp, i*TypeStackSlotEntries::per_arg_count());
-          cmp(tmp, TypeStackSlotEntries::per_arg_count());
+          cmp(tmp, (u1)TypeStackSlotEntries::per_arg_count());
           add(rscratch1, mdp, off_to_args);
           br(Assembler::LT, done);
         }
@@ -1752,13 +1752,13 @@
       // length
       Label do_profile;
       ldrb(rscratch1, Address(rbcp, 0));
-      cmp(rscratch1, Bytecodes::_invokedynamic);
+      cmp(rscratch1, (u1)Bytecodes::_invokedynamic);
       br(Assembler::EQ, do_profile);
-      cmp(rscratch1, Bytecodes::_invokehandle);
+      cmp(rscratch1, (u1)Bytecodes::_invokehandle);
       br(Assembler::EQ, do_profile);
       get_method(tmp);
       ldrh(rscratch1, Address(tmp, Method::intrinsic_id_offset_in_bytes()));
-      cmp(rscratch1, vmIntrinsics::_compiledLambdaForm);
+      subs(zr, rscratch1, vmIntrinsics::_compiledLambdaForm);
       br(Assembler::NE, profile_continue);
 
       bind(do_profile);
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -494,7 +494,7 @@
     ldr(swap_reg, mark_addr);
   }
   andr(tmp_reg, swap_reg, markOopDesc::biased_lock_mask_in_place);
-  cmp(tmp_reg, markOopDesc::biased_lock_pattern);
+  cmp(tmp_reg, (u1)markOopDesc::biased_lock_pattern);
   br(Assembler::NE, cas_label);
   // The bias pattern is present in the object's header. Need to check
   // whether the bias owner and the epoch are both still current.
@@ -633,7 +633,7 @@
   // the bias bit would be clear.
   ldr(temp_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
   andr(temp_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
-  cmp(temp_reg, markOopDesc::biased_lock_pattern);
+  cmp(temp_reg, (u1)markOopDesc::biased_lock_pattern);
   br(Assembler::EQ, done);
 }
 
@@ -1137,7 +1137,7 @@
 
   if (super_check_offset.is_register()) {
     br(Assembler::EQ, *L_success);
-    cmp(super_check_offset.as_register(), sc_offset);
+    subs(zr, super_check_offset.as_register(), sc_offset);
     if (L_failure == &L_fallthrough) {
       br(Assembler::EQ, *L_slow_path);
     } else {
@@ -3312,7 +3312,7 @@
     add(table3, table0, 3*256*sizeof(juint));
 
   if (UseNeon) {
-      cmp(len, 64);
+      cmp(len, (u1)64);
       br(Assembler::LT, L_by16);
       eor(v16, T16B, v16, v16);
 
@@ -3990,6 +3990,15 @@
   }
 }
 
+void MacroAssembler::resolve(DecoratorSet decorators, Register obj) {
+  // Use stronger ACCESS_WRITE|ACCESS_READ by default.
+  if ((decorators & (ACCESS_READ | ACCESS_WRITE)) == 0) {
+    decorators |= ACCESS_READ | ACCESS_WRITE;
+  }
+  BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+  return bs->resolve(this, decorators, obj);
+}
+
 void MacroAssembler::load_heap_oop(Register dst, Address src, Register tmp1,
                                    Register thread_tmp, DecoratorSet decorators) {
   access_load_at(T_OBJECT, IN_HEAP | decorators, dst, src, tmp1, thread_tmp);
@@ -4362,10 +4371,10 @@
 
   if (icnt1 == -1) {
     sub(result_tmp, cnt2, cnt1);
-    cmp(cnt1, 8);             // Use Linear Scan if cnt1 < 8 || cnt1 >= 256
+    cmp(cnt1, (u1)8);             // Use Linear Scan if cnt1 < 8 || cnt1 >= 256
     br(LT, LINEARSEARCH);
     dup(v0, T16B, cnt1); // done in separate FPU pipeline. Almost no penalty
-    cmp(cnt1, 256);
+    subs(zr, cnt1, 256);
     lsr(tmp1, cnt2, 2);
     ccmp(cnt1, tmp1, 0b0000, LT); // Source must be 4 * pattern for BM
     br(GE, LINEARSTUB);
@@ -4471,7 +4480,7 @@
     BIND(BCLOOP);
       (this->*str1_load_1chr)(ch1, Address(post(tmp3, str1_chr_size)));
       if (!str1_isL) {
-        cmp(ch1, ASIZE);
+        subs(zr, ch1, ASIZE);
         br(HS, BCSKIP);
       }
       strb(ch2, Address(sp, ch1));
@@ -4535,7 +4544,7 @@
         } else {
           mov(result_tmp, 1);
         }
-        cmp(skipch, ASIZE);
+        subs(zr, skipch, ASIZE);
         br(HS, BMADV);
       }
       ldrb(result_tmp, Address(sp, skipch)); // load skip distance
@@ -4556,7 +4565,7 @@
       b(DONE);
 
     BIND(LINEARSTUB);
-    cmp(cnt1, 16); // small patterns still should be handled by simple algorithm
+    cmp(cnt1, (u1)16); // small patterns still should be handled by simple algorithm
     br(LT, LINEAR_MEDIUM);
     mov(result, zr);
     RuntimeAddress stub = NULL;
@@ -4585,7 +4594,7 @@
     {
         Label DOSHORT, FIRST_LOOP, STR2_NEXT, STR1_LOOP, STR1_NEXT;
 
-        cmp(cnt1, str1_isL == str2_isL ? 4 : 2);
+        cmp(cnt1, u1(str1_isL == str2_isL ? 4 : 2));
         br(LT, DOSHORT);
       BIND(LINEAR_MEDIUM);
         (this->*str1_load_1chr)(first, Address(str1));
@@ -4620,7 +4629,7 @@
 
       BIND(DOSHORT);
       if (str1_isL == str2_isL) {
-        cmp(cnt1, 2);
+        cmp(cnt1, (u1)2);
         br(LT, DO1);
         br(GT, DO3);
       }
@@ -4695,7 +4704,7 @@
 
       BIND(DO1);
         (this->*str1_load_1chr)(ch1, str1);
-        cmp(cnt2, 8);
+        cmp(cnt2, (u1)8);
         br(LT, DO1_SHORT);
 
         sub(result_tmp, cnt2, 8/str2_chr_size);
@@ -4718,7 +4727,7 @@
         adds(cnt2_neg, cnt2_neg, 8);
         br(LT, CH1_LOOP);
 
-        cmp(cnt2_neg, 8);
+        cmp(cnt2_neg, (u1)8);
         mov(cnt2_neg, 0);
         br(LT, CH1_LOOP);
         b(NOMATCH);
@@ -4761,7 +4770,7 @@
   Register ch1 = rscratch1;
   Register result_tmp = rscratch2;
 
-  cmp(cnt1, 4);
+  cmp(cnt1, (u1)4);
   br(LT, DO1_SHORT);
 
   orr(ch, ch, ch, LSL, 16);
@@ -4784,7 +4793,7 @@
     adds(cnt1_neg, cnt1_neg, 8);
     br(LT, CH1_LOOP);
 
-    cmp(cnt1_neg, 8);
+    cmp(cnt1_neg, (u1)8);
     mov(cnt1_neg, 0);
     br(LT, CH1_LOOP);
     b(NOMATCH);
@@ -4821,7 +4830,7 @@
       DIFFERENCE, NEXT_WORD, SHORT_LOOP_TAIL, SHORT_LAST2, SHORT_LAST_INIT,
       SHORT_LOOP_START, TAIL_CHECK;
 
-  const int STUB_THRESHOLD = 64 + 8;
+  const u1 STUB_THRESHOLD = 64 + 8;
   bool isLL = ae == StrIntrinsicNode::LL;
   bool isLU = ae == StrIntrinsicNode::LU;
   bool isUL = ae == StrIntrinsicNode::UL;
@@ -5216,10 +5225,10 @@
     ldrw(cnt2, Address(a2, length_offset));
     // on most CPUs a2 is still "locked"(surprisingly) in ldrw and it's
     // faster to perform another branch before comparing a1 and a2
-    cmp(cnt1, elem_per_word);
+    cmp(cnt1, (u1)elem_per_word);
     br(LE, SHORT); // short or same
     ldr(tmp3, Address(pre(a1, base_offset)));
-    cmp(cnt1, stubBytesThreshold);
+    subs(zr, cnt1, stubBytesThreshold);
     br(GE, STUB);
     ldr(tmp4, Address(pre(a2, base_offset)));
     sub(tmp5, zr, cnt1, LSL, 3 + log_elem_size);
@@ -5236,7 +5245,7 @@
       cbnz(tmp4, DONE);
       ldr(tmp3, Address(pre(a1, wordSize)));
       ldr(tmp4, Address(pre(a2, wordSize)));
-      cmp(cnt1, elem_per_word);
+      cmp(cnt1, (u1)elem_per_word);
       br(LE, TAIL2);
       cmp(tmp1, tmp2);
     } br(EQ, NEXT_DWORD);
@@ -5409,7 +5418,7 @@
   assert(ptr == r10 && cnt == r11, "mismatch in register usage");
 
   BLOCK_COMMENT("zero_words {");
-  cmp(cnt, zero_words_block_size);
+  cmp(cnt, (u1)zero_words_block_size);
   Label around, done, done16;
   br(LO, around);
   {
@@ -5590,15 +5599,15 @@
       mov(result, len); // Save initial len
 
 #ifndef BUILTIN_SIM
-      cmp(len, 8); // handle shortest strings first
+      cmp(len, (u1)8); // handle shortest strings first
       br(LT, LOOP_1);
-      cmp(len, 32);
+      cmp(len, (u1)32);
       br(LT, NEXT_8);
       // The following code uses the SIMD 'uzp1' and 'uzp2' instructions
       // to convert chars to bytes
       if (SoftwarePrefetchHintDistance >= 0) {
         ld1(Vtmp1, Vtmp2, Vtmp3, Vtmp4, T8H, src);
-        cmp(len, SoftwarePrefetchHintDistance/2 + 16);
+        subs(tmp2, len, SoftwarePrefetchHintDistance/2 + 16);
         br(LE, NEXT_32_START);
         b(NEXT_32_PRFM_START);
         BIND(NEXT_32_PRFM);
@@ -5618,9 +5627,9 @@
           sub(len, len, 32);
           add(dst, dst, 32);
           add(src, src, 64);
-          cmp(len, SoftwarePrefetchHintDistance/2 + 16);
+          subs(tmp2, len, SoftwarePrefetchHintDistance/2 + 16);
           br(GE, NEXT_32_PRFM);
-          cmp(len, 32);
+          cmp(len, (u1)32);
           br(LT, LOOP_8);
         BIND(NEXT_32);
           ld1(Vtmp1, Vtmp2, Vtmp3, Vtmp4, T8H, src);
@@ -5643,12 +5652,12 @@
       sub(len, len, 32);
       add(dst, dst, 32);
       add(src, src, 64);
-      cmp(len, 32);
+      cmp(len, (u1)32);
       br(GE, NEXT_32);
       cbz(len, DONE);
 
     BIND(LOOP_8);
-      cmp(len, 8);
+      cmp(len, (u1)8);
       br(LT, LOOP_1);
     BIND(NEXT_8);
       ld1(Vtmp1, T8H, src);
@@ -5661,7 +5670,7 @@
       sub(len, len, 8);
       add(dst, dst, 8);
       add(src, src, 16);
-      cmp(len, 8);
+      cmp(len, (u1)8);
       br(GE, NEXT_8);
 
     BIND(LOOP_1);
@@ -5738,7 +5747,7 @@
       const int large_loop_threshold = (64 + 16)/8;
       ldrd(vtmp2, post(src, 8));
       andw(len, len, 7);
-      cmp(tmp4, large_loop_threshold);
+      cmp(tmp4, (u1)large_loop_threshold);
       br(GE, to_stub);
       b(loop_start);
 
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -180,8 +180,9 @@
 
   template<class T>
   inline void cmpw(Register Rd, T imm)  { subsw(zr, Rd, imm); }
-  // imm is limited to 12 bits.
-  inline void cmp(Register Rd, unsigned imm)  { subs(zr, Rd, imm); }
+
+  inline void cmp(Register Rd, unsigned char imm8)  { subs(zr, Rd, imm8); }
+  inline void cmp(Register Rd, unsigned imm) __attribute__ ((deprecated));
 
   inline void cmnw(Register Rd, unsigned imm) { addsw(zr, Rd, imm); }
   inline void cmn(Register Rd, unsigned imm) { adds(zr, Rd, imm); }
@@ -795,6 +796,10 @@
   void access_store_at(BasicType type, DecoratorSet decorators, Address dst, Register src,
                        Register tmp1, Register tmp_thread);
 
+  // Resolves obj for access. Result is placed in the same register.
+  // All other registers are preserved.
+  void resolve(DecoratorSet decorators, Register obj);
+
   void load_heap_oop(Register dst, Address src, Register tmp1 = noreg,
                      Register thread_tmp = noreg, DecoratorSet decorators = 0);
 
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64_log.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64_log.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -292,7 +292,7 @@
     // vtmp1 = AS_DOUBLE_BITS(0x77F0 << 48 | mantissa(X)) == mx
     fmovd(vtmp1, tmp4);
     subw(tmp2, tmp2, 16);
-    cmp(tmp2, 0x8000);
+    subs(zr, tmp2, 0x8000);
     br(GE, SMALL_VALUE);
   bind(MAIN);
     fmovs(tmp3, vtmp5);                        // int intB0 = AS_INT_BITS(B);
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64_trig.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64_trig.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -297,7 +297,7 @@
       fmsubd(v3, v2, v6, v31); // v3 = r = t - fn * pio2_1
       fmuld(v26, v2, v7);      // v26 = w = fn * pio2_1t
       fsubd(v4, v3, v26);      // y[0] = r - w. Calculated before branch
-      cmp(n, 32);
+      cmp(n, (u1)32);
       br(GT, LARGE_ELSE);
       subw(tmp5, n, 1);        // tmp5 = n - 1
       ldrw(jv, Address(ih, tmp5, Address::lsl(2)));
@@ -312,7 +312,7 @@
           sub(tmp3, tmp5, jx, LSR, 32 + 20 + 1);   // r7 = j-(((*(i0+(int*)&y[0]))>>20)&0x7ff);
 
           block_comment("if(i>16)"); {
-            cmp(tmp3, 16);
+            cmp(tmp3, (u1)16);
             br(LE, X_IS_MEDIUM_BRANCH_DONE);
             // i > 16. 2nd iteration needed
             ldpd(v6, v7, Address(ih, -32));
@@ -328,7 +328,7 @@
             sub(tmp3, tmp5, jx, LSR, 32 + 20 + 1); // r7 = j-(((*(i0+(int*)&y[0]))>>20)&0x7ff);
 
             block_comment("if(i>49)"); {
-              cmp(tmp3, 49);
+              cmp(tmp3, (u1)49);
               br(LE, X_IS_MEDIUM_BRANCH_DONE);
               // 3rd iteration need, 151 bits acc
               ldpd(v6, v7, Address(ih, -16));
--- a/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -196,7 +196,7 @@
     Label L;
     BLOCK_COMMENT("verify_intrinsic_id {");
     __ ldrh(rscratch1, Address(rmethod, Method::intrinsic_id_offset_in_bytes()));
-    __ cmp(rscratch1, (int) iid);
+    __ subs(zr, rscratch1, (int) iid);
     __ br(Assembler::EQ, L);
     if (iid == vmIntrinsics::_linkToVirtual ||
         iid == vmIntrinsics::_linkToSpecial) {
--- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1152,12 +1152,12 @@
    public:
     MoveOperation(int src_index, VMRegPair src, int dst_index, VMRegPair dst):
       _src(src)
+    , _dst(dst)
     , _src_index(src_index)
-    , _dst(dst)
     , _dst_index(dst_index)
+    , _processed(false)
     , _next(NULL)
-    , _prev(NULL)
-    , _processed(false) { Unimplemented(); }
+    , _prev(NULL) { Unimplemented(); }
 
     VMRegPair src() const              { Unimplemented(); return _src; }
     int src_id() const                 { Unimplemented(); return 0; }
@@ -1839,6 +1839,8 @@
     // Load the oop from the handle
     __ ldr(obj_reg, Address(oop_handle_reg, 0));
 
+    __ resolve(IS_NOT_NULL, obj_reg);
+
     if (UseBiasedLocking) {
       __ biased_locking_enter(lock_reg, obj_reg, swap_reg, tmp, false, lock_done, &slow_path_lock);
     }
@@ -2001,6 +2003,8 @@
     // Get locked oop from the handle we passed to jni
     __ ldr(obj_reg, Address(oop_handle_reg, 0));
 
+    __ resolve(IS_NOT_NULL, obj_reg);
+
     Label done;
 
     if (UseBiasedLocking) {
--- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -265,7 +265,7 @@
     {
       Label L;
       __ ldr(rscratch1, Address(rthread, in_bytes(Thread::pending_exception_offset())));
-      __ cmp(rscratch1, (unsigned)NULL_WORD);
+      __ cmp(rscratch1, (u1)NULL_WORD);
       __ br(Assembler::EQ, L);
       __ stop("StubRoutines::call_stub: entered with pending exception");
       __ BIND(L);
@@ -322,13 +322,13 @@
     __ ldr(j_rarg2, result);
     Label is_long, is_float, is_double, exit;
     __ ldr(j_rarg1, result_type);
-    __ cmp(j_rarg1, T_OBJECT);
+    __ cmp(j_rarg1, (u1)T_OBJECT);
     __ br(Assembler::EQ, is_long);
-    __ cmp(j_rarg1, T_LONG);
+    __ cmp(j_rarg1, (u1)T_LONG);
     __ br(Assembler::EQ, is_long);
-    __ cmp(j_rarg1, T_FLOAT);
+    __ cmp(j_rarg1, (u1)T_FLOAT);
     __ br(Assembler::EQ, is_float);
-    __ cmp(j_rarg1, T_DOUBLE);
+    __ cmp(j_rarg1, (u1)T_DOUBLE);
     __ br(Assembler::EQ, is_double);
 
     // handle T_INT case
@@ -743,7 +743,7 @@
     // Make sure we are never given < 8 words
     {
       Label L;
-      __ cmp(count, 8);
+      __ cmp(count, (u1)8);
       __ br(Assembler::GE, L);
       __ stop("genrate_copy_longs called with < 8 words");
       __ bind(L);
@@ -1103,19 +1103,19 @@
 
     if (PrefetchCopyIntervalInBytes > 0)
       __ prfm(Address(s, 0), PLDL1KEEP);
-    __ cmp(count, (UseSIMDForMemoryOps ? 96:80)/granularity);
+    __ cmp(count, u1((UseSIMDForMemoryOps ? 96:80)/granularity));
     __ br(Assembler::HI, copy_big);
 
     __ lea(send, Address(s, count, Address::lsl(exact_log2(granularity))));
     __ lea(dend, Address(d, count, Address::lsl(exact_log2(granularity))));
 
-    __ cmp(count, 16/granularity);
+    __ cmp(count, u1(16/granularity));
     __ br(Assembler::LS, copy16);
 
-    __ cmp(count, 64/granularity);
+    __ cmp(count, u1(64/granularity));
     __ br(Assembler::HI, copy80);
 
-    __ cmp(count, 32/granularity);
+    __ cmp(count, u1(32/granularity));
     __ br(Assembler::LS, copy32);
 
     // 33..64 bytes
@@ -1170,7 +1170,7 @@
 
     // 0..16 bytes
     __ bind(copy16);
-    __ cmp(count, 8/granularity);
+    __ cmp(count, u1(8/granularity));
     __ br(Assembler::LO, copy8);
 
     // 8..16 bytes
@@ -3270,7 +3270,7 @@
 
     // The pipelined loop needs at least 16 elements for 1 iteration
     // It does check this, but it is more effective to skip to the cleanup loop
-    __ cmp(len, 16);
+    __ cmp(len, (u1)16);
     __ br(Assembler::HS, L_nmax);
     __ cbz(len, L_combine);
 
@@ -3654,7 +3654,7 @@
 
   address generate_has_negatives(address &has_negatives_long) {
     StubCodeMark mark(this, "StubRoutines", "has_negatives");
-    const int large_loop_size = 64;
+    const u1 large_loop_size = 64;
     const uint64_t UPPER_BIT_MASK=0x8080808080808080;
     int dcache_line = VM_Version::dcache_line_size();
 
@@ -3668,7 +3668,7 @@
   Label RET_TRUE, RET_TRUE_NO_POP, RET_FALSE, ALIGNED, LOOP16, CHECK_16, DONE,
         LARGE_LOOP, POST_LOOP16, LEN_OVER_15, LEN_OVER_8, POST_LOOP16_LOAD_TAIL;
 
-  __ cmp(len, 15);
+  __ cmp(len, (u1)15);
   __ br(Assembler::GT, LEN_OVER_15);
   // The only case when execution falls into this code is when pointer is near
   // the end of memory page and we have to avoid reading next page
@@ -3764,7 +3764,7 @@
     __ br(Assembler::GE, LARGE_LOOP);
 
   __ bind(CHECK_16); // small 16-byte load pre-loop
-    __ cmp(len, 16);
+    __ cmp(len, (u1)16);
     __ br(Assembler::LT, POST_LOOP16);
 
   __ bind(LOOP16); // small 16-byte load loop
@@ -3773,11 +3773,11 @@
     __ orr(tmp2, tmp2, tmp3);
     __ tst(tmp2, UPPER_BIT_MASK);
     __ br(Assembler::NE, RET_TRUE);
-    __ cmp(len, 16);
+    __ cmp(len, (u1)16);
     __ br(Assembler::GE, LOOP16); // 16-byte load loop end
 
   __ bind(POST_LOOP16); // 16-byte aligned, so we can read unconditionally
-    __ cmp(len, 8);
+    __ cmp(len, (u1)8);
     __ br(Assembler::LE, POST_LOOP16_LOAD_TAIL);
     __ ldr(tmp3, Address(__ post(ary1, 8)));
     __ sub(len, len, 8);
@@ -3942,7 +3942,7 @@
         __ br(__ LE, NO_PREFETCH_LARGE_LOOP);
         generate_large_array_equals_loop_simd(prefetchLoopThreshold,
             /* prfm = */ true, NOT_EQUAL);
-        __ cmp(cnt1, nonPrefetchLoopThreshold);
+        __ subs(zr, cnt1, nonPrefetchLoopThreshold);
         __ br(__ LT, TAIL);
       }
       __ bind(NO_PREFETCH_LARGE_LOOP);
@@ -3955,7 +3955,7 @@
         __ br(__ LE, NO_PREFETCH_LARGE_LOOP);
         generate_large_array_equals_loop_nonsimd(prefetchLoopThreshold,
             /* prfm = */ true, NOT_EQUAL);
-        __ cmp(cnt1, nonPrefetchLoopThreshold);
+        __ subs(zr, cnt1, nonPrefetchLoopThreshold);
         __ br(__ LT, TAIL);
       }
       __ bind(NO_PREFETCH_LARGE_LOOP);
@@ -4106,7 +4106,7 @@
     __ ldr(tmp3, Address(__ post(cnt1, 8)));
 
     if (SoftwarePrefetchHintDistance >= 0) {
-      __ cmp(cnt2, prefetchLoopExitCondition);
+      __ subs(rscratch2, cnt2, prefetchLoopExitCondition);
       __ br(__ LT, SMALL_LOOP);
       __ bind(LARGE_LOOP_PREFETCH);
         __ prfm(Address(tmp2, SoftwarePrefetchHintDistance));
@@ -4123,7 +4123,7 @@
           __ subs(tmp4, tmp4, 1);
           __ br(__ GT, LARGE_LOOP_PREFETCH_REPEAT2);
           __ sub(cnt2, cnt2, 64);
-          __ cmp(cnt2, prefetchLoopExitCondition);
+          __ subs(rscratch2, cnt2, prefetchLoopExitCondition);
           __ br(__ GE, LARGE_LOOP_PREFETCH);
     }
     __ cbz(cnt2, LOAD_LAST); // no characters left except last load
@@ -4137,7 +4137,7 @@
       __ br(__ GE, SMALL_LOOP);
       __ cbz(cnt2, LOAD_LAST);
     __ bind(TAIL); // 1..15 characters left
-      __ cmp(cnt2, -8);
+      __ subs(zr, cnt2, -8);
       __ br(__ GT, TAIL_LOAD_16);
       __ ldrd(vtmp, Address(tmp2));
       __ zip1(vtmp3, __ T8B, vtmp, vtmpZ);
@@ -4240,7 +4240,7 @@
         compare_string_16_bytes_same(DIFF, DIFF2);
         __ sub(cnt2, cnt2, isLL ? 64 : 32);
         compare_string_16_bytes_same(DIFF, DIFF2);
-        __ cmp(cnt2, largeLoopExitCondition);
+        __ subs(rscratch2, cnt2, largeLoopExitCondition);
         compare_string_16_bytes_same(DIFF, DIFF2);
         __ br(__ GT, LARGE_LOOP_PREFETCH);
         __ cbz(cnt2, LAST_CHECK_AND_LENGTH_DIFF); // no more chars left?
@@ -4416,7 +4416,7 @@
       __ add(result, result, wordSize/str2_chr_size);
       __ br(__ GE, L_LOOP);
     __ BIND(L_POST_LOOP);
-      __ cmp(cnt2, -wordSize/str2_chr_size); // no extra characters to check
+      __ subs(zr, cnt2, -wordSize/str2_chr_size); // no extra characters to check
       __ br(__ LE, NOMATCH);
       __ ldr(ch2, Address(str2));
       __ sub(cnt2, zr, cnt2, __ LSL, LogBitsPerByte + str2_chr_shift);
@@ -4446,7 +4446,7 @@
       __ br(__ EQ, NOMATCH);
     __ BIND(L_SMALL_HAS_ZERO_LOOP);
       __ clz(tmp4, tmp2); // potentially long. Up to 4 cycles on some cpu's
-      __ cmp(cnt1, wordSize/str2_chr_size);
+      __ cmp(cnt1, u1(wordSize/str2_chr_size));
       __ br(__ LE, L_SMALL_CMP_LOOP_LAST_CMP2);
       if (str2_isL) { // LL
         __ add(str2, str2, tmp4, __ LSR, LogBitsPerByte); // address of "index"
@@ -4659,7 +4659,7 @@
     __ zip1(v2, __ T16B, v2, v0);
     __ st1(v1, v2, __ T16B, __ post(dst, 32));
     __ ld1(v3, v4, v5, v6, __ T16B, Address(__ post(src, 64)));
-    __ cmp(octetCounter, large_loop_threshold);
+    __ subs(rscratch1, octetCounter, large_loop_threshold);
     __ br(__ LE, LOOP_START);
     __ b(LOOP_PRFM_START);
     __ bind(LOOP_PRFM);
@@ -4667,17 +4667,17 @@
     __ bind(LOOP_PRFM_START);
       __ prfm(Address(src, SoftwarePrefetchHintDistance));
       __ sub(octetCounter, octetCounter, 8);
-      __ cmp(octetCounter, large_loop_threshold);
+      __ subs(rscratch1, octetCounter, large_loop_threshold);
       inflate_and_store_2_fp_registers(true, v3, v4);
       inflate_and_store_2_fp_registers(true, v5, v6);
       __ br(__ GT, LOOP_PRFM);
-      __ cmp(octetCounter, 8);
+      __ cmp(octetCounter, (u1)8);
       __ br(__ LT, DONE);
     __ bind(LOOP);
       __ ld1(v3, v4, v5, v6, __ T16B, Address(__ post(src, 64)));
       __ bind(LOOP_START);
       __ sub(octetCounter, octetCounter, 8);
-      __ cmp(octetCounter, 8);
+      __ cmp(octetCounter, (u1)8);
       inflate_and_store_2_fp_registers(false, v3, v4);
       inflate_and_store_2_fp_registers(false, v5, v6);
       __ br(__ GE, LOOP);
@@ -5308,7 +5308,7 @@
       {
         ldr(Rn, Address(Pn_base, 0));
         mul(Rlo_mn, Rn, inv);
-        cmp(Rlo_mn, -1);
+        subs(zr, Rlo_mn, -1);
         Label ok;
         br(EQ, ok); {
           stop("broken inverse in Montgomery multiply");
--- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -836,6 +836,7 @@
 #endif // ASSERT
 
     __ bind(done);
+    __ resolve(IS_NOT_NULL, r0);
   }
 
   // add space for monitor & lock
@@ -1062,6 +1063,7 @@
       __ ldrw(crc,   Address(esp, 4*wordSize)); // Initial CRC
     } else {
       __ ldr(buf, Address(esp, 2*wordSize)); // byte[] array
+      __ resolve(IS_NOT_NULL | ACCESS_READ, buf);
       __ add(buf, buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
       __ ldrw(off, Address(esp, wordSize)); // offset
       __ add(buf, buf, off); // + offset
@@ -1106,6 +1108,9 @@
     __ ldrw(off, Address(esp, wordSize)); // int offset
     __ sub(len, end, off);
     __ ldr(buf, Address(esp, 2*wordSize)); // byte[] buf | long buf
+    if (kind == Interpreter::java_util_zip_CRC32C_updateBytes) {
+      __ resolve(IS_NOT_NULL | ACCESS_READ, buf);
+    }
     __ add(buf, buf, off); // + offset
     if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) {
       __ ldrw(crc, Address(esp, 4*wordSize)); // long crc
@@ -1355,7 +1360,7 @@
   {
     Label L;
     __ ldrw(t, Address(rthread, JavaThread::thread_state_offset()));
-    __ cmp(t, _thread_in_Java);
+    __ cmp(t, (u1)_thread_in_Java);
     __ br(Assembler::EQ, L);
     __ stop("Wrong thread state in native stub");
     __ bind(L);
@@ -1462,7 +1467,7 @@
     Label no_reguard;
     __ lea(rscratch1, Address(rthread, in_bytes(JavaThread::stack_guard_state_offset())));
     __ ldrw(rscratch1, Address(rscratch1));
-    __ cmp(rscratch1, JavaThread::stack_guard_yellow_reserved_disabled);
+    __ cmp(rscratch1, (u1)JavaThread::stack_guard_yellow_reserved_disabled);
     __ br(Assembler::NE, no_reguard);
 
     __ pusha(); // XXX only save smashed registers
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -331,16 +331,16 @@
   __ ldarb(r3, r3);
 
   // unresolved class - get the resolved class
-  __ cmp(r3, JVM_CONSTANT_UnresolvedClass);
+  __ cmp(r3, (u1)JVM_CONSTANT_UnresolvedClass);
   __ br(Assembler::EQ, call_ldc);
 
   // unresolved class in error state - call into runtime to throw the error
   // from the first resolution attempt
-  __ cmp(r3, JVM_CONSTANT_UnresolvedClassInError);
+  __ cmp(r3, (u1)JVM_CONSTANT_UnresolvedClassInError);
   __ br(Assembler::EQ, call_ldc);
 
   // resolved class - need to call vm to get java mirror of the class
-  __ cmp(r3, JVM_CONSTANT_Class);
+  __ cmp(r3, (u1)JVM_CONSTANT_Class);
   __ br(Assembler::NE, notClass);
 
   __ bind(call_ldc);
@@ -351,7 +351,7 @@
   __ b(Done);
 
   __ bind(notClass);
-  __ cmp(r3, JVM_CONSTANT_Float);
+  __ cmp(r3, (u1)JVM_CONSTANT_Float);
   __ br(Assembler::NE, notFloat);
   // ftos
   __ adds(r1, r2, r1, Assembler::LSL, 3);
@@ -361,7 +361,7 @@
 
   __ bind(notFloat);
 
-  __ cmp(r3, JVM_CONSTANT_Integer);
+  __ cmp(r3, (u1)JVM_CONSTANT_Integer);
   __ br(Assembler::NE, notInt);
 
   // itos
@@ -2333,7 +2333,7 @@
 
   assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
   __ get_cache_and_index_and_bytecode_at_bcp(Rcache, index, temp, byte_no, 1, index_size);
-  __ cmp(temp, (int) code);  // have we resolved this bytecode?
+  __ subs(zr, temp, (int) code);  // have we resolved this bytecode?
   __ br(Assembler::EQ, resolved);
 
   // resolve first time through
@@ -2515,7 +2515,7 @@
   __ b(Done);
 
   __ bind(notByte);
-  __ cmp(flags, ztos);
+  __ cmp(flags, (u1)ztos);
   __ br(Assembler::NE, notBool);
 
   // ztos (same code as btos)
@@ -2529,7 +2529,7 @@
   __ b(Done);
 
   __ bind(notBool);
-  __ cmp(flags, atos);
+  __ cmp(flags, (u1)atos);
   __ br(Assembler::NE, notObj);
   // atos
   do_oop_load(_masm, field, r0, IN_HEAP);
@@ -2540,7 +2540,7 @@
   __ b(Done);
 
   __ bind(notObj);
-  __ cmp(flags, itos);
+  __ cmp(flags, (u1)itos);
   __ br(Assembler::NE, notInt);
   // itos
   __ access_load_at(T_INT, IN_HEAP, r0, field, noreg, noreg);
@@ -2552,7 +2552,7 @@
   __ b(Done);
 
   __ bind(notInt);
-  __ cmp(flags, ctos);
+  __ cmp(flags, (u1)ctos);
   __ br(Assembler::NE, notChar);
   // ctos
   __ access_load_at(T_CHAR, IN_HEAP, r0, field, noreg, noreg);
@@ -2564,7 +2564,7 @@
   __ b(Done);
 
   __ bind(notChar);
-  __ cmp(flags, stos);
+  __ cmp(flags, (u1)stos);
   __ br(Assembler::NE, notShort);
   // stos
   __ access_load_at(T_SHORT, IN_HEAP, r0, field, noreg, noreg);
@@ -2576,7 +2576,7 @@
   __ b(Done);
 
   __ bind(notShort);
-  __ cmp(flags, ltos);
+  __ cmp(flags, (u1)ltos);
   __ br(Assembler::NE, notLong);
   // ltos
   __ access_load_at(T_LONG, IN_HEAP, r0, field, noreg, noreg);
@@ -2588,7 +2588,7 @@
   __ b(Done);
 
   __ bind(notLong);
-  __ cmp(flags, ftos);
+  __ cmp(flags, (u1)ftos);
   __ br(Assembler::NE, notFloat);
   // ftos
   __ access_load_at(T_FLOAT, IN_HEAP, noreg /* ftos */, field, noreg, noreg);
@@ -2601,7 +2601,7 @@
 
   __ bind(notFloat);
 #ifdef ASSERT
-  __ cmp(flags, dtos);
+  __ cmp(flags, (u1)dtos);
   __ br(Assembler::NE, notDouble);
 #endif
   // dtos
@@ -2751,7 +2751,7 @@
   }
 
   __ bind(notByte);
-  __ cmp(flags, ztos);
+  __ cmp(flags, (u1)ztos);
   __ br(Assembler::NE, notBool);
 
   // ztos
@@ -2766,7 +2766,7 @@
   }
 
   __ bind(notBool);
-  __ cmp(flags, atos);
+  __ cmp(flags, (u1)atos);
   __ br(Assembler::NE, notObj);
 
   // atos
@@ -2782,7 +2782,7 @@
   }
 
   __ bind(notObj);
-  __ cmp(flags, itos);
+  __ cmp(flags, (u1)itos);
   __ br(Assembler::NE, notInt);
 
   // itos
@@ -2797,7 +2797,7 @@
   }
 
   __ bind(notInt);
-  __ cmp(flags, ctos);
+  __ cmp(flags, (u1)ctos);
   __ br(Assembler::NE, notChar);
 
   // ctos
@@ -2812,7 +2812,7 @@
   }
 
   __ bind(notChar);
-  __ cmp(flags, stos);
+  __ cmp(flags, (u1)stos);
   __ br(Assembler::NE, notShort);
 
   // stos
@@ -2827,7 +2827,7 @@
   }
 
   __ bind(notShort);
-  __ cmp(flags, ltos);
+  __ cmp(flags, (u1)ltos);
   __ br(Assembler::NE, notLong);
 
   // ltos
@@ -2842,7 +2842,7 @@
   }
 
   __ bind(notLong);
-  __ cmp(flags, ftos);
+  __ cmp(flags, (u1)ftos);
   __ br(Assembler::NE, notFloat);
 
   // ftos
@@ -2858,7 +2858,7 @@
 
   __ bind(notFloat);
 #ifdef ASSERT
-  __ cmp(flags, dtos);
+  __ cmp(flags, (u1)dtos);
   __ br(Assembler::NE, notDouble);
 #endif
 
@@ -3534,7 +3534,7 @@
   __ lea(rscratch1, Address(r0, r3, Address::lsl(0)));
   __ lea(rscratch1, Address(rscratch1, tags_offset));
   __ ldarb(rscratch1, rscratch1);
-  __ cmp(rscratch1, JVM_CONSTANT_Class);
+  __ cmp(rscratch1, (u1)JVM_CONSTANT_Class);
   __ br(Assembler::NE, slow_case);
 
   // get InstanceKlass
@@ -3543,7 +3543,7 @@
   // make sure klass is initialized & doesn't have finalizer
   // make sure klass is fully initialized
   __ ldrb(rscratch1, Address(r4, InstanceKlass::init_state_offset()));
-  __ cmp(rscratch1, InstanceKlass::fully_initialized);
+  __ cmp(rscratch1, (u1)InstanceKlass::fully_initialized);
   __ br(Assembler::NE, slow_case);
 
   // get instance_size in InstanceKlass (scaled to a count of bytes)
@@ -3683,7 +3683,7 @@
   __ add(rscratch1, r3, Array<u1>::base_offset_in_bytes());
   __ lea(r1, Address(rscratch1, r19));
   __ ldarb(r1, r1);
-  __ cmp(r1, JVM_CONSTANT_Class);
+  __ cmp(r1, (u1)JVM_CONSTANT_Class);
   __ br(Assembler::EQ, quicked);
 
   __ push(atos); // save receiver for result, and for GC
@@ -3737,7 +3737,7 @@
   __ add(rscratch1, r3, Array<u1>::base_offset_in_bytes());
   __ lea(r1, Address(rscratch1, r19));
   __ ldarb(r1, r1);
-  __ cmp(r1, JVM_CONSTANT_Class);
+  __ cmp(r1, (u1)JVM_CONSTANT_Class);
   __ br(Assembler::EQ, quicked);
 
   __ push(atos); // save receiver for result, and for GC
@@ -3840,6 +3840,8 @@
   // check for NULL object
   __ null_check(r0);
 
+  __ resolve(IS_NOT_NULL, r0);
+
   const Address monitor_block_top(
         rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
   const Address monitor_block_bot(
@@ -3939,6 +3941,8 @@
   // check for NULL object
   __ null_check(r0);
 
+  __ resolve(IS_NOT_NULL, r0);
+
   const Address monitor_block_top(
         rfp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
   const Address monitor_block_bot(
--- a/src/hotspot/cpu/arm/assembler_arm_32.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/arm/assembler_arm_32.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1083,6 +1083,7 @@
       break;
     default:
       ShouldNotReachHere();
+      return;
     }
     emit_int32(0xf << 28 | 0x1 << 25 | 0x1 << 23 | 0x1 << 4 |
               (imm8 >> 7) << 24 | ((imm8 & 0x70) >> 4) << 16 | (imm8 & 0xf) |
@@ -1113,6 +1114,7 @@
       break;
     default:
       ShouldNotReachHere();
+      return;
     }
     emit_int32(cond << 28 | 0x1D /* 0b11101 */ << 23 | 0xB /* 0b1011 */ << 8 | 0x1 << 4 |
               quad << 21 | b << 22 |  e << 5 | Rs->encoding() << 12 |
@@ -1143,6 +1145,7 @@
       break;
     default:
       ShouldNotReachHere();
+      return;
     }
     emit_int32(0xF /* 0b1111 */ << 28 | 0x3B /* 0b00111011 */ << 20 | 0x6 /* 0b110 */ << 9 |
                quad << 6 | imm4 << 16 |
--- a/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/arm/c1_CodeStubs_arm.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -52,13 +52,13 @@
 
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
-  : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) {
+  : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
-  : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) {
+  : _index(index), _array(NULL), _throw_index_out_of_bounds_exception(true) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
--- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1778,8 +1778,12 @@
 #else
   // FIXME: membar_release
   __ membar(MacroAssembler::Membar_mask_bits(MacroAssembler::StoreStore | MacroAssembler::LoadStore), Rtemp);
+  Register addr = op->addr()->is_register() ?
+    op->addr()->as_pointer_register() :
+    op->addr()->as_address_ptr()->base()->as_pointer_register();
+  assert(op->addr()->is_register() || op->addr()->as_address_ptr()->disp() == 0, "unexpected disp");
+  assert(op->addr()->is_register() || op->addr()->as_address_ptr()->index() == LIR_OprDesc::illegalOpr(), "unexpected index");
   if (op->code() == lir_cas_int || op->code() == lir_cas_obj) {
-    Register addr = op->addr()->as_register();
     Register cmpval = op->cmp_value()->as_register();
     Register newval = op->new_value()->as_register();
     Register dest = op->result_opr()->as_register();
@@ -1790,7 +1794,6 @@
     __ mov(dest, 0, ne);
   } else if (op->code() == lir_cas_long) {
     assert(VM_Version::supports_cx8(), "wrong machine");
-    Register addr = op->addr()->as_pointer_register();
     Register cmp_value_lo = op->cmp_value()->as_register_lo();
     Register cmp_value_hi = op->cmp_value()->as_register_hi();
     Register new_value_lo = op->new_value()->as_register_lo();
@@ -3083,7 +3086,7 @@
 
   Label ok;
   if (op->condition() != lir_cond_always) {
-    AsmCondition acond;
+    AsmCondition acond = al;
     switch (op->condition()) {
       case lir_cond_equal:        acond = eq; break;
       case lir_cond_notEqual:     acond = ne; break;
@@ -3468,7 +3471,12 @@
 }
 
 void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp) {
+#ifdef AARCH64
   Register ptr = src->as_pointer_register();
+#else
+  assert(src->is_address(), "sanity");
+  Address addr = as_Address(src->as_address_ptr());
+#endif
 
   if (code == lir_xchg) {
 #ifdef AARCH64
@@ -3493,15 +3501,15 @@
 #ifdef AARCH64
     __ ldaxr_w(dst, ptr);
 #else
-    __ ldrex(dst, Address(ptr));
+    __ ldrex(dst, addr);
 #endif
     if (code == lir_xadd) {
       Register tmp_reg = tmp->as_register();
       if (data->is_constant()) {
-        assert_different_registers(dst, ptr, tmp_reg);
+        assert_different_registers(dst, tmp_reg);
         __ add_32(tmp_reg, dst, data->as_constant_ptr()->as_jint());
       } else {
-        assert_different_registers(dst, ptr, tmp_reg, data->as_register());
+        assert_different_registers(dst, tmp_reg, data->as_register());
         __ add_32(tmp_reg, dst, data->as_register());
       }
       new_val = tmp_reg;
@@ -3511,12 +3519,12 @@
       } else {
         new_val = data->as_register();
       }
-      assert_different_registers(dst, ptr, new_val);
+      assert_different_registers(dst, new_val);
     }
 #ifdef AARCH64
     __ stlxr_w(Rtemp, new_val, ptr);
 #else
-    __ strex(Rtemp, new_val, Address(ptr));
+    __ strex(Rtemp, new_val, addr);
 #endif // AARCH64
 
 #ifdef AARCH64
@@ -3551,7 +3559,7 @@
     assert((dst_lo->encoding() & 0x1) == 0, "misaligned register pair");
 
     __ bind(retry);
-    __ ldrexd(dst_lo, Address(ptr));
+    __ ldrexd(dst_lo, addr);
     if (code == lir_xadd) {
       Register tmp_lo = tmp->as_register_lo();
       Register tmp_hi = tmp->as_register_hi();
@@ -3562,7 +3570,7 @@
       if (data->is_constant()) {
         jlong c = data->as_constant_ptr()->as_jlong();
         assert((jlong)((jint)c) == c, "overflow");
-        assert_different_registers(dst_lo, dst_hi, ptr, tmp_lo, tmp_hi);
+        assert_different_registers(dst_lo, dst_hi, tmp_lo, tmp_hi);
         __ adds(tmp_lo, dst_lo, (jint)c);
         __ adc(tmp_hi, dst_hi, 0);
       } else {
@@ -3570,18 +3578,18 @@
         Register new_val_hi = data->as_register_hi();
         __ adds(tmp_lo, dst_lo, new_val_lo);
         __ adc(tmp_hi, dst_hi, new_val_hi);
-        assert_different_registers(dst_lo, dst_hi, ptr, tmp_lo, tmp_hi, new_val_lo, new_val_hi);
+        assert_different_registers(dst_lo, dst_hi, tmp_lo, tmp_hi, new_val_lo, new_val_hi);
       }
       new_val_lo = tmp_lo;
     } else {
       new_val_lo = data->as_register_lo();
       Register new_val_hi = data->as_register_hi();
 
-      assert_different_registers(dst_lo, dst_hi, ptr, new_val_lo, new_val_hi);
+      assert_different_registers(dst_lo, dst_hi, new_val_lo, new_val_hi);
       assert(new_val_hi->encoding() == new_val_lo->encoding() + 1, "non aligned register pair");
       assert((new_val_lo->encoding() & 0x1) == 0, "misaligned register pair");
     }
-    __ strexd(Rtemp, new_val_lo, Address(ptr));
+    __ strexd(Rtemp, new_val_lo, addr);
 #endif // AARCH64
   } else {
     ShouldNotReachHere();
--- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -733,6 +733,7 @@
 
     default:
       ShouldNotReachHere();
+      return;
   }
 #else
   switch (x->op()) {
@@ -757,6 +758,7 @@
         break;
       default:
         ShouldNotReachHere();
+        return;
       }
       LIR_Opr result = call_runtime(x->y(), x->x(), entry, x->type(), NULL);
       set_result(x, result);
@@ -824,7 +826,7 @@
       if (x->op() == Bytecodes::_irem) {
         out_reg = FrameMap::R0_opr;
         __ irem(left_arg->result(), right_arg->result(), out_reg, tmp, info);
-      } else if (x->op() == Bytecodes::_idiv) {
+      } else { // (x->op() == Bytecodes::_idiv)
         out_reg = FrameMap::R1_opr;
         __ idiv(left_arg->result(), right_arg->result(), out_reg, tmp, info);
       }
--- a/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/ppc/c1_CodeStubs_ppc.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -39,13 +39,13 @@
 
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
-  : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) {
+  : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
-  : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) {
+  : _index(index), _array(NULL), _throw_index_out_of_bounds_exception(true) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
--- a/src/hotspot/cpu/ppc/frame_ppc.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/ppc/frame_ppc.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -359,13 +359,13 @@
   //            ...
   //
 
-  // frame pointer for this frame
-  intptr_t* _fp;
-
   // The frame's stack pointer before it has been extended by a c2i adapter;
   // needed by deoptimization
   intptr_t* _unextended_sp;
 
+  // frame pointer for this frame
+  intptr_t* _fp;
+
  public:
 
   // Accessors for fields
--- a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -55,7 +55,7 @@
 // Constructors
 
 // Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state.
-inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {}
+inline frame::frame() : _sp(NULL), _pc(NULL), _cb(NULL),  _deopt_state(unknown), _unextended_sp(NULL), _fp(NULL) {}
 
 inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) {
   find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->lr); // also sets _fp and adjusts _unextended_sp
--- a/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/ppc/gc/g1/g1BarrierSetAssembler_ppc.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -29,6 +29,7 @@
 #include "gc/g1/g1BarrierSetAssembler.hpp"
 #include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
+#include "gc/g1/g1SATBMarkQueueSet.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "interpreter/interp_masm.hpp"
@@ -458,7 +459,7 @@
   __ mflr(R0);
   __ std(R0, _abi(lr), R1_SP);
   __ push_frame_reg_args(nbytes_save, R0); // dummy frame for C call
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread), R16_thread);
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1SATBMarkQueueSet::handle_zero_index_for_thread), R16_thread);
   __ pop_frame();
   __ ld(R0, _abi(lr), R1_SP);
   __ mtlr(R0);
--- a/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/s390/c1_CodeStubs_s390.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -41,13 +41,13 @@
 #define CHECK_BAILOUT() { if (ce->compilation()->bailed_out()) return; }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
-  : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) {
+  : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
-  : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) {
+  : _index(index), _array(NULL), _throw_index_out_of_bounds_exception(true) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
--- a/src/hotspot/cpu/s390/frame_s390.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/s390/frame_s390.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -444,12 +444,12 @@
 
   // NOTE: Stack pointer is now held in the base class, so remove it from here.
 
+  // Needed by deoptimization.
+  intptr_t* _unextended_sp;
+
   // Frame pointer for this frame.
   intptr_t* _fp;
 
-  // Needed by deoptimization.
-  intptr_t* _unextended_sp;
-
  public:
 
   // Interface for all frames:
--- a/src/hotspot/cpu/s390/frame_s390.inline.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/s390/frame_s390.inline.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -54,7 +54,7 @@
 // Constructors
 
 // Initialize all fields, _unextended_sp will be adjusted in find_codeblob_and_set_pc_and_deopt_state.
-inline frame::frame() : _sp(NULL), _unextended_sp(NULL), _fp(NULL), _cb(NULL), _pc(NULL), _deopt_state(unknown) {}
+inline frame::frame() : _sp(NULL), _pc(NULL), _cb(NULL), _deopt_state(unknown), _unextended_sp(NULL), _fp(NULL) {}
 
 inline frame::frame(intptr_t* sp) : _sp(sp), _unextended_sp(sp) {
   find_codeblob_and_set_pc_and_deopt_state((address)own_abi()->return_pc);
@@ -71,7 +71,7 @@
 // Generic constructor. Used by pns() in debug.cpp only
 #ifndef PRODUCT
 inline frame::frame(void* sp, void* pc, void* unextended_sp) :
-  _sp((intptr_t*)sp), _unextended_sp((intptr_t*)unextended_sp), _cb(NULL), _pc(NULL) {
+  _sp((intptr_t*)sp), _pc(NULL), _cb(NULL), _unextended_sp((intptr_t*)unextended_sp) {
   find_codeblob_and_set_pc_and_deopt_state((address)pc); // Also sets _fp and adjusts _unextended_sp.
 }
 #endif
--- a/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/s390/gc/g1/g1BarrierSetAssembler_s390.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -30,6 +30,7 @@
 #include "gc/g1/g1BarrierSet.hpp"
 #include "gc/g1/g1BarrierSetAssembler.hpp"
 #include "gc/g1/g1BarrierSetRuntime.hpp"
+#include "gc/g1/g1SATBMarkQueueSet.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "interpreter/interp_masm.hpp"
@@ -520,7 +521,7 @@
   __ bind(refill);
   save_volatile_registers(sasm);
   __ z_lgr(tmp, pre_val); // save pre_val
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread),
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, G1SATBMarkQueueSet::handle_zero_index_for_thread),
                   Z_thread);
   __ z_lgr(pre_val, tmp); // restore pre_val
   restore_volatile_registers(sasm);
--- a/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/sparc/gc/g1/g1BarrierSetAssembler_sparc.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -28,6 +28,7 @@
 #include "gc/g1/g1BarrierSetAssembler.hpp"
 #include "gc/g1/g1BarrierSetRuntime.hpp"
 #include "gc/g1/g1CardTable.hpp"
+#include "gc/g1/g1SATBMarkQueueSet.hpp"
 #include "gc/g1/g1ThreadLocalData.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "interpreter/interp_masm.hpp"
@@ -160,7 +161,7 @@
 
   address handle_zero =
     CAST_FROM_FN_PTR(address,
-                     &SATBMarkQueueSet::handle_zero_index_for_thread);
+                     &G1SATBMarkQueueSet::handle_zero_index_for_thread);
   // This should be rare enough that we can afford to save all the
   // scratch registers that the calling context might be using.
   __ mov(G1_scratch, L0);
@@ -606,8 +607,8 @@
 
   __ call_VM_leaf(L7_thread_cache,
                   CAST_FROM_FN_PTR(address,
-                                   SATBMarkQueueSet::handle_zero_index_for_thread),
-                                   G2_thread);
+                                   G1SATBMarkQueueSet::handle_zero_index_for_thread),
+                  G2_thread);
 
   __ restore_live_registers(true);
 
@@ -694,7 +695,7 @@
   __ call_VM_leaf(L7_thread_cache,
                   CAST_FROM_FN_PTR(address,
                                    DirtyCardQueueSet::handle_zero_index_for_thread),
-                                   G2_thread);
+                  G2_thread);
 
   __ restore_live_registers(true);
 
--- a/src/hotspot/cpu/x86/assembler_x86.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/assembler_x86.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -2219,8 +2219,8 @@
       _evex_encoding(0),
       _is_clear_context(true),
       _is_extended_context(false),
-      _current_assembler(NULL),
-      _embedded_opmask_register_specifier(1) { // hard code k1, it will be initialized for now
+      _embedded_opmask_register_specifier(1), // hard code k1, it will be initialized for now
+      _current_assembler(NULL) {
     if (UseAVX < 3) _legacy_mode = true;
   }
 
--- a/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -89,13 +89,13 @@
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, LIR_Opr array)
-  : _throw_index_out_of_bounds_exception(false), _index(index), _array(array) {
+  : _index(index), _array(array), _throw_index_out_of_bounds_exception(false) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
 
 RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index)
-  : _throw_index_out_of_bounds_exception(true), _index(index), _array(NULL) {
+  : _index(index), _array(NULL), _throw_index_out_of_bounds_exception(true) {
   assert(info != NULL, "must have info");
   _info = new CodeEmitInfo(info);
 }
--- a/src/hotspot/cpu/x86/c1_LinearScan_x86.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/c1_LinearScan_x86.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -110,9 +110,9 @@
 
 FpuStackAllocator::FpuStackAllocator(Compilation* compilation, LinearScan* allocator)
   : _compilation(compilation)
+  , _allocator(allocator)
   , _lir(NULL)
   , _pos(-1)
-  , _allocator(allocator)
   , _sim(compilation)
   , _temp_sim(compilation)
 {}
--- a/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -61,6 +61,10 @@
   virtual void obj_equals(MacroAssembler* masm,
                           Register obj1, Address obj2);
 
+  virtual void resolve(MacroAssembler* masm, DecoratorSet decorators, Register obj) {
+    // Default implementation does not need to do anything.
+  }
+
   // Support for jniFastGetField to try resolving a jobject/jweak in native
   virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env,
                                              Register obj, Register tmp, Label& slowpath);
--- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -6287,6 +6287,15 @@
   }
 }
 
+void MacroAssembler::resolve(DecoratorSet decorators, Register obj) {
+  // Use stronger ACCESS_WRITE|ACCESS_READ by default.
+  if ((decorators & (ACCESS_READ | ACCESS_WRITE)) == 0) {
+    decorators |= ACCESS_READ | ACCESS_WRITE;
+  }
+  BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
+  return bs->resolve(this, decorators, obj);
+}
+
 void MacroAssembler::load_heap_oop(Register dst, Address src, Register tmp1,
                                    Register thread_tmp, DecoratorSet decorators) {
   access_load_at(T_OBJECT, IN_HEAP | decorators, dst, src, tmp1, thread_tmp);
@@ -10558,7 +10567,7 @@
   XMMRegister tmp1Reg, XMMRegister tmp2Reg,
   XMMRegister tmp3Reg, XMMRegister tmp4Reg,
   Register tmp5, Register result) {
-  Label copy_chars_loop, return_length, return_zero, done, below_threshold;
+  Label copy_chars_loop, return_length, return_zero, done;
 
   // rsi: src
   // rdi: dst
@@ -10581,13 +10590,12 @@
 
     set_vector_masking();  // opening of the stub context for programming mask registers
 
-    Label copy_32_loop, copy_loop_tail, restore_k1_return_zero;
-
-    // alignement
-    Label post_alignement;
-
-    // if length of the string is less than 16, handle it in an old fashioned
-    // way
+    Label copy_32_loop, copy_loop_tail, restore_k1_return_zero, below_threshold;
+
+    // alignment
+    Label post_alignment;
+
+    // if length of the string is less than 16, handle it in an old fashioned way
     testl(len, -32);
     jcc(Assembler::zero, below_threshold);
 
@@ -10600,7 +10608,7 @@
     kmovql(k3, k1);
 
     testl(len, -64);
-    jcc(Assembler::zero, post_alignement);
+    jcc(Assembler::zero, post_alignment);
 
     movl(tmp5, dst);
     andl(tmp5, (32 - 1));
@@ -10609,7 +10617,7 @@
 
     // bail out when there is nothing to be done
     testl(tmp5, 0xFFFFFFFF);
-    jcc(Assembler::zero, post_alignement);
+    jcc(Assembler::zero, post_alignment);
 
     // ~(~0 << len), where len is the # of remaining elements to process
     movl(result, 0xFFFFFFFF);
@@ -10629,8 +10637,8 @@
     addptr(dst, tmp5);
     subl(len, tmp5);
 
-    bind(post_alignement);
-    // end of alignement
+    bind(post_alignment);
+    // end of alignment
 
     movl(tmp5, len);
     andl(tmp5, (32 - 1));    // tail count (in chars)
@@ -10685,12 +10693,13 @@
     jmp(return_zero);
 
     clear_vector_masking();   // closing of the stub context for programming mask registers
-  }
+
+    bind(below_threshold);
+  }
+
   if (UseSSE42Intrinsics) {
     Label copy_32_loop, copy_16, copy_tail;
 
-    bind(below_threshold);
-
     movl(result, len);
 
     movl(tmp5, 0xff00ff00);   // create mask to test for Unicode chars in vectors
@@ -10803,8 +10812,7 @@
     Label copy_32_loop, copy_tail;
     Register tmp3_aliased = len;
 
-    // if length of the string is less than 16, handle it in an old fashioned
-    // way
+    // if length of the string is less than 16, handle it in an old fashioned way
     testl(len, -16);
     jcc(Assembler::zero, below_threshold);
 
@@ -10918,7 +10926,10 @@
     addptr(dst, 8);
 
     bind(copy_bytes);
-  }
+  } else {
+    bind(below_threshold);
+  }
+
   testl(len, len);
   jccb(Assembler::zero, done);
   lea(src, Address(src, len, Address::times_1));
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -319,6 +319,10 @@
   void access_store_at(BasicType type, DecoratorSet decorators, Address dst, Register src,
                        Register tmp1, Register tmp2);
 
+  // Resolves obj access. Result is placed in the same register.
+  // All other registers are preserved.
+  void resolve(DecoratorSet decorators, Register obj);
+
   void load_heap_oop(Register dst, Address src, Register tmp1 = noreg,
                      Register thread_tmp = noreg, DecoratorSet decorators = 0);
   void load_heap_oop_not_null(Register dst, Address src, Register tmp1 = noreg,
--- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -32,6 +32,7 @@
 #include "code/icBuffer.hpp"
 #include "code/nativeInst.hpp"
 #include "code/vtableStubs.hpp"
+#include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/gcLocker.hpp"
 #include "interpreter/interpreter.hpp"
 #include "logging/log.hpp"
@@ -1434,6 +1435,64 @@
   }
 }
 
+// Pin object, return pinned object or null in rax
+static void gen_pin_object(MacroAssembler* masm,
+                           VMRegPair reg) {
+  __ block_comment("gen_pin_object {");
+
+  // rax always contains oop, either incoming or
+  // pinned.
+  Register tmp_reg = rax;
+
+  Label is_null;
+  VMRegPair tmp;
+  VMRegPair in_reg = reg;
+
+  tmp.set_ptr(tmp_reg->as_VMReg());
+  if (reg.first()->is_stack()) {
+    // Load the arg up from the stack
+    move_ptr(masm, reg, tmp);
+    reg = tmp;
+  } else {
+    __ movptr(rax, reg.first()->as_Register());
+  }
+  __ testptr(reg.first()->as_Register(), reg.first()->as_Register());
+  __ jccb(Assembler::equal, is_null);
+
+  if (reg.first()->as_Register() != c_rarg1) {
+    __ movptr(c_rarg1, reg.first()->as_Register());
+  }
+
+  __ call_VM_leaf(
+    CAST_FROM_FN_PTR(address, SharedRuntime::pin_object),
+    r15_thread, c_rarg1);
+
+  __ bind(is_null);
+  __ block_comment("} gen_pin_object");
+}
+
+// Unpin object
+static void gen_unpin_object(MacroAssembler* masm,
+                             VMRegPair reg) {
+  __ block_comment("gen_unpin_object {");
+  Label is_null;
+
+  if (reg.first()->is_stack()) {
+    __ movptr(c_rarg1, Address(rbp, reg2offset_in(reg.first())));
+  } else if (reg.first()->as_Register() != c_rarg1) {
+    __ movptr(c_rarg1, reg.first()->as_Register());
+  }
+
+  __ testptr(c_rarg1, c_rarg1);
+  __ jccb(Assembler::equal, is_null);
+
+  __ call_VM_leaf(
+    CAST_FROM_FN_PTR(address, SharedRuntime::unpin_object),
+    r15_thread, c_rarg1);
+
+  __ bind(is_null);
+  __ block_comment("} gen_unpin_object");
+}
 
 // Check GCLocker::needs_gc and enter the runtime if it's true.  This
 // keeps a new JNI critical region from starting until a GC has been
@@ -1574,12 +1633,12 @@
    public:
     MoveOperation(int src_index, VMRegPair src, int dst_index, VMRegPair dst):
       _src(src)
+    , _dst(dst)
     , _src_index(src_index)
-    , _dst(dst)
     , _dst_index(dst_index)
+    , _processed(false)
     , _next(NULL)
-    , _prev(NULL)
-    , _processed(false) {
+    , _prev(NULL) {
     }
 
     VMRegPair src() const              { return _src; }
@@ -2129,7 +2188,7 @@
 
   const Register oop_handle_reg = r14;
 
-  if (is_critical_native) {
+  if (is_critical_native && !Universe::heap()->supports_object_pinning()) {
     check_needs_gc_for_critical_native(masm, stack_slots, total_c_args, total_in_args,
                                        oop_handle_offset, oop_maps, in_regs, in_sig_bt);
   }
@@ -2186,6 +2245,11 @@
   // the incoming and outgoing registers are offset upwards and for
   // critical natives they are offset down.
   GrowableArray<int> arg_order(2 * total_in_args);
+  // Inbound arguments that need to be pinned for critical natives
+  GrowableArray<int> pinned_args(total_in_args);
+  // Current stack slot for storing register based array argument
+  int pinned_slot = oop_handle_offset;
+
   VMRegPair tmp_vmreg;
   tmp_vmreg.set2(rbx->as_VMReg());
 
@@ -2233,6 +2297,23 @@
     switch (in_sig_bt[i]) {
       case T_ARRAY:
         if (is_critical_native) {
+          // pin before unpack
+          if (Universe::heap()->supports_object_pinning()) {
+            save_args(masm, total_c_args, 0, out_regs);
+            gen_pin_object(masm, in_regs[i]);
+            pinned_args.append(i);
+            restore_args(masm, total_c_args, 0, out_regs);
+
+            // rax has pinned array
+            VMRegPair result_reg;
+            result_reg.set_ptr(rax->as_VMReg());
+            move_ptr(masm, result_reg, in_regs[i]);
+            if (!in_regs[i].first()->is_stack()) {
+              assert(pinned_slot <= stack_slots, "overflow");
+              move_ptr(masm, result_reg, VMRegImpl::stack2reg(pinned_slot));
+              pinned_slot += VMRegImpl::slots_per_word;
+            }
+          }
           unpack_array_argument(masm, in_regs[i], in_elem_bt[i], out_regs[c_arg + 1], out_regs[c_arg]);
           c_arg++;
 #ifdef ASSERT
@@ -2369,6 +2450,7 @@
     // Load the oop from the handle
     __ movptr(obj_reg, Address(oop_handle_reg, 0));
 
+    __ resolve(IS_NOT_NULL, obj_reg);
     if (UseBiasedLocking) {
       __ biased_locking_enter(lock_reg, obj_reg, swap_reg, rscratch1, false, lock_done, &slow_path_lock);
     }
@@ -2449,6 +2531,24 @@
   default       : ShouldNotReachHere();
   }
 
+  // unpin pinned arguments
+  pinned_slot = oop_handle_offset;
+  if (pinned_args.length() > 0) {
+    // save return value that may be overwritten otherwise.
+    save_native_result(masm, ret_type, stack_slots);
+    for (int index = 0; index < pinned_args.length(); index ++) {
+      int i = pinned_args.at(index);
+      assert(pinned_slot <= stack_slots, "overflow");
+      if (!in_regs[i].first()->is_stack()) {
+        int offset = pinned_slot * VMRegImpl::stack_slot_size;
+        __ movq(in_regs[i].first()->as_Register(), Address(rsp, offset));
+        pinned_slot += VMRegImpl::slots_per_word;
+      }
+      gen_unpin_object(masm, in_regs[i]);
+    }
+    restore_native_result(masm, ret_type, stack_slots);
+  }
+
   // Switch thread to "native transition" state before reading the synchronization state.
   // This additional state is necessary because reading and testing the synchronization
   // state is not atomic w.r.t. GC, as this scenario demonstrates:
@@ -2536,6 +2636,7 @@
 
     // Get locked oop from the handle we passed to jni
     __ movptr(obj_reg, Address(oop_handle_reg, 0));
+    __ resolve(IS_NOT_NULL, obj_reg);
 
     Label done;
 
--- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -635,6 +635,7 @@
 #endif // ASSERT
 
     __ bind(done);
+    __ resolve(IS_NOT_NULL, rax);
   }
 
   // add space for monitor & lock
--- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -257,6 +257,7 @@
       __ movl(crc,   Address(rsp, 5*wordSize)); // Initial CRC
     } else {
       __ movptr(buf, Address(rsp, 3*wordSize)); // byte[] array
+      __ resolve(IS_NOT_NULL | ACCESS_READ, buf);
       __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
       __ movl2ptr(off, Address(rsp, 2*wordSize)); // offset
       __ addq(buf, off); // + offset
@@ -312,6 +313,7 @@
       //    "When calculating operand stack length, values of type long and double have length two."
     } else {
       __ movptr(buf, Address(rsp, 3 * wordSize)); // byte[] array
+      __ resolve(IS_NOT_NULL | ACCESS_READ, buf);
       __ addptr(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE)); // + header size
       __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset
       __ addq(buf, off); // + offset
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -4357,6 +4357,8 @@
   // check for NULL object
   __ null_check(rax);
 
+  __ resolve(IS_NOT_NULL, rax);
+
   const Address monitor_block_top(
         rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
   const Address monitor_block_bot(
@@ -4454,6 +4456,8 @@
   // check for NULL object
   __ null_check(rax);
 
+  __ resolve(IS_NOT_NULL, rax);
+
   const Address monitor_block_top(
         rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
   const Address monitor_block_bot(
--- a/src/hotspot/os/aix/os_aix.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/aix/os_aix.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -2705,10 +2705,6 @@
   return (ret == 0) ? OS_OK : OS_ERR;
 }
 
-// Hint to the underlying OS that a task switch would not be good.
-// Void return because it's a hint and can fail.
-void os::hint_no_preempt() {}
-
 ////////////////////////////////////////////////////////////////////////////////
 // suspend/resume support
 
--- a/src/hotspot/os/bsd/os_bsd.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -2465,10 +2465,6 @@
   return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR);
 }
 
-// Hint to the underlying OS that a task switch would not be good.
-// Void return because it's a hint and can fail.
-void os::hint_no_preempt() {}
-
 ////////////////////////////////////////////////////////////////////////////////
 // suspend/resume support
 
--- a/src/hotspot/os/linux/os_linux.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/linux/os_linux.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -4211,10 +4211,6 @@
   return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR);
 }
 
-// Hint to the underlying OS that a task switch would not be good.
-// Void return because it's a hint and can fail.
-void os::hint_no_preempt() {}
-
 ////////////////////////////////////////////////////////////////////////////////
 // suspend/resume support
 
@@ -5875,11 +5871,21 @@
     core_pattern[ret] = '\0';
   }
 
+  // Replace the %p in the core pattern with the process id. NOTE: we do this
+  // only if the pattern doesn't start with "|", and we support only one %p in
+  // the pattern.
   char *pid_pos = strstr(core_pattern, "%p");
+  const char* tail = (pid_pos != NULL) ? (pid_pos + 2) : "";  // skip over the "%p"
   int written;
 
   if (core_pattern[0] == '/') {
-    written = jio_snprintf(buffer, bufferSize, "%s", core_pattern);
+    if (pid_pos != NULL) {
+      *pid_pos = '\0';
+      written = jio_snprintf(buffer, bufferSize, "%s%d%s", core_pattern,
+                             current_process_id(), tail);
+    } else {
+      written = jio_snprintf(buffer, bufferSize, "%s", core_pattern);
+    }
   } else {
     char cwd[PATH_MAX];
 
@@ -5892,6 +5898,10 @@
       written = jio_snprintf(buffer, bufferSize,
                              "\"%s\" (or dumping to %s/core.%d)",
                              &core_pattern[1], p, current_process_id());
+    } else if (pid_pos != NULL) {
+      *pid_pos = '\0';
+      written = jio_snprintf(buffer, bufferSize, "%s/%s%d%s", p, core_pattern,
+                             current_process_id(), tail);
     } else {
       written = jio_snprintf(buffer, bufferSize, "%s/%s", p, core_pattern);
     }
--- a/src/hotspot/os/linux/os_perf_linux.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/linux/os_perf_linux.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1094,7 +1094,7 @@
 
   NetworkInterface* ret = NULL;
   for (cur_address = addresses; cur_address != NULL; cur_address = cur_address->ifa_next) {
-    if (cur_address->ifa_addr->sa_family != AF_PACKET) {
+    if ((cur_address->ifa_addr == NULL) || (cur_address->ifa_addr->sa_family != AF_PACKET)) {
       continue;
     }
 
@@ -1105,6 +1105,7 @@
     ret = cur;
   }
 
+  freeifaddrs(addresses);
   *network_interfaces = ret;
 
   return OS_OK;
--- a/src/hotspot/os/solaris/os_perf_solaris.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/solaris/os_perf_solaris.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -808,6 +808,7 @@
     }
   }
 
+  kstat_close(ctl);
   *network_interfaces = ret;
 
   return OS_OK;
--- a/src/hotspot/os/solaris/os_solaris.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -78,7 +78,6 @@
 # include <link.h>
 # include <poll.h>
 # include <pthread.h>
-# include <schedctl.h>
 # include <setjmp.h>
 # include <signal.h>
 # include <stdio.h>
@@ -742,7 +741,6 @@
   OSThread* osthr = thread->osthread();
 
   osthr->set_lwp_id(_lwp_self());  // Store lwp in case we are bound
-  thread->_schedctl = (void *) schedctl_init();
 
   log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").",
     os::current_thread_id());
@@ -812,7 +810,6 @@
   // Store info on the Solaris thread into the OSThread
   osthread->set_thread_id(thread_id);
   osthread->set_lwp_id(_lwp_self());
-  thread->_schedctl = (void *) schedctl_init();
 
   if (UseNUMA) {
     int lgrp_id = os::numa_get_group_id();
@@ -3407,13 +3404,6 @@
   return OS_OK;
 }
 
-
-// Hint to the underlying OS that a task switch would not be good.
-// Void return because it's a hint and can fail.
-void os::hint_no_preempt() {
-  schedctl_start(schedctl_init());
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // suspend/resume support
 
--- a/src/hotspot/os/windows/os_windows.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/os/windows/os_windows.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -3609,11 +3609,6 @@
   return OS_OK;
 }
 
-
-// Hint to the underlying OS that a task switch would not be good.
-// Void return because it's a hint and can fail.
-void os::hint_no_preempt() {}
-
 void os::interrupt(Thread* thread) {
   debug_only(Thread::check_for_dangling_thread_pointer(thread);)
 
--- a/src/hotspot/share/adlc/output_h.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/adlc/output_h.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1006,19 +1006,19 @@
   fprintf(fp_hpp, "           enum machPipelineStages * const stage,\n");
   fprintf(fp_hpp, "           uint                    * const cycles,\n");
   fprintf(fp_hpp, "           Pipeline_Use                    resource_use)\n");
-  fprintf(fp_hpp, "  : _write_stage(write_stage)\n");
-  fprintf(fp_hpp, "  , _read_stage_count(count)\n");
+  fprintf(fp_hpp, "  : _read_stage_count(count)\n");
+  fprintf(fp_hpp, "  , _write_stage(write_stage)\n");
+  fprintf(fp_hpp, "  , _fixed_latency(fixed_latency)\n");
+  fprintf(fp_hpp, "  , _instruction_count(instruction_count)\n");
   fprintf(fp_hpp, "  , _has_fixed_latency(has_fixed_latency)\n");
-  fprintf(fp_hpp, "  , _fixed_latency(fixed_latency)\n");
+  fprintf(fp_hpp, "  , _has_branch_delay(has_branch_delay)\n");
+  fprintf(fp_hpp, "  , _has_multiple_bundles(has_multiple_bundles)\n");
+  fprintf(fp_hpp, "  , _force_serialization(force_serialization)\n");
+  fprintf(fp_hpp, "  , _may_have_no_code(may_have_no_code)\n");
   fprintf(fp_hpp, "  , _read_stages(dst)\n");
   fprintf(fp_hpp, "  , _resource_stage(stage)\n");
   fprintf(fp_hpp, "  , _resource_cycles(cycles)\n");
   fprintf(fp_hpp, "  , _resource_use(resource_use)\n");
-  fprintf(fp_hpp, "  , _instruction_count(instruction_count)\n");
-  fprintf(fp_hpp, "  , _has_branch_delay(has_branch_delay)\n");
-  fprintf(fp_hpp, "  , _has_multiple_bundles(has_multiple_bundles)\n");
-  fprintf(fp_hpp, "  , _force_serialization(force_serialization)\n");
-  fprintf(fp_hpp, "  , _may_have_no_code(may_have_no_code)\n");
   fprintf(fp_hpp, "  {};\n");
   fprintf(fp_hpp, "\n");
   fprintf(fp_hpp, "  uint writeStage() const {\n");
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -714,7 +714,7 @@
 void AOTCodeHeap::sweep_method(AOTCompiledMethod *aot) {
   int indexes[] = {aot->method_index()};
   sweep_dependent_methods(indexes, 1);
-  vmassert(aot->method()->code() != aot && aot->method()->aot_code() == NULL, "method still active");
+  vmassert(aot->method()->code() != aot TIERED_ONLY( && aot->method()->aot_code() == NULL), "method still active");
 }
 
 
--- a/src/hotspot/share/aot/aotCompiledMethod.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/aot/aotCompiledMethod.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -206,6 +206,7 @@
   return true;
 }
 
+#ifdef TIERED
 bool AOTCompiledMethod::make_entrant() {
   assert(!method()->is_old(), "reviving evolved method!");
   assert(*_state_adr != not_entrant, "%s", method()->has_aot_code() ? "has_aot_code() not cleared" : "caller didn't check has_aot_code()");
@@ -240,6 +241,7 @@
 
   return true;
 }
+#endif // TIERED
 
 // We don't have full dependencies for AOT methods, so flushing is
 // more conservative than for nmethods.
--- a/src/hotspot/share/aot/aotCompiledMethod.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/aot/aotCompiledMethod.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -138,8 +138,8 @@
     _heap(heap),
     _name(name),
     _metadata_size(metadata_size),
-    _method_index(method_index),
-    _aot_id(aot_id) {
+    _aot_id(aot_id),
+    _method_index(method_index) {
 
     _is_far_code = CodeCache::is_far_target(code) ||
                    CodeCache::is_far_target(code + meta->code_size());
@@ -194,7 +194,7 @@
   virtual address verified_entry_point() const { return _code + _meta->verified_entry_offset(); }
   virtual void log_identity(xmlStream* stream) const;
   virtual void log_state_change() const;
-  virtual bool make_entrant();
+  virtual bool make_entrant() NOT_TIERED({ ShouldNotReachHere(); return false; });
   virtual bool make_not_entrant() { return make_not_entrant_helper(not_entrant); }
   virtual bool make_not_used() { return make_not_entrant_helper(not_used); }
   virtual address entry_point() const { return _code + _meta->entry_offset(); }
--- a/src/hotspot/share/c1/c1_CodeStubs.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_CodeStubs.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -218,7 +218,7 @@
 
  public:
   ImplicitNullCheckStub(int offset, CodeEmitInfo* info)
-    : _offset(offset), _info(info) {
+    : _info(info), _offset(offset) {
   }
   virtual void emit_code(LIR_Assembler* e);
   virtual CodeEmitInfo* info() const             { return _info; }
@@ -479,7 +479,7 @@
 
  public:
   SimpleExceptionStub(Runtime1::StubID stub, LIR_Opr obj, CodeEmitInfo* info):
-    _obj(obj), _info(info), _stub(stub) {
+    _obj(obj), _stub(stub), _info(info) {
   }
 
   void set_obj(LIR_Opr obj) {
--- a/src/hotspot/share/c1/c1_Compilation.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_Compilation.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -538,12 +538,13 @@
   }
 }
 
-
 Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method,
                          int osr_bci, BufferBlob* buffer_blob, DirectiveSet* directive)
-: _compiler(compiler)
+: _next_id(0)
+, _next_block_id(0)
+, _compiler(compiler)
+, _directive(directive)
 , _env(env)
-, _directive(directive)
 , _log(env->log())
 , _method(method)
 , _osr_bci(osr_bci)
@@ -553,19 +554,17 @@
 , _masm(NULL)
 , _has_exception_handlers(false)
 , _has_fpu_code(true)   // pessimistic assumption
+, _has_unsafe_access(false)
 , _would_profile(false)
-, _has_unsafe_access(false)
 , _has_method_handle_invokes(false)
 , _has_reserved_stack_access(method->has_reserved_stack_access())
 , _bailout_msg(NULL)
 , _exception_info_list(NULL)
 , _allocator(NULL)
-, _next_id(0)
-, _next_block_id(0)
 , _code(buffer_blob)
 , _has_access_indexed(false)
+, _interpreter_frame_size(0)
 , _current_instruction(NULL)
-, _interpreter_frame_size(0)
 #ifndef PRODUCT
 , _last_instruction_printed(NULL)
 , _cfg_printer_output(NULL)
--- a/src/hotspot/share/c1/c1_GraphBuilder.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -102,11 +102,11 @@
  , _scope(scope)
  , _blocks(16)
  , _bci2block(new BlockList(scope->method()->code_size(), NULL))
- , _next_block_number(0)
  , _active()         // size not known yet
  , _visited()        // size not known yet
+ , _loop_map() // size not known yet
  , _next_loop_index(0)
- , _loop_map() // size not known yet
+ , _next_block_number(0)
 {
   set_entries(osr_bci);
   set_leaders();
@@ -680,10 +680,10 @@
   , _has_handler(false)
   , _stream(NULL)
   , _work_list(NULL)
+  , _caller_stack_size(-1)
+  , _continuation(NULL)
   , _parsing_jsr(false)
   , _jsr_xhandlers(NULL)
-  , _caller_stack_size(-1)
-  , _continuation(NULL)
   , _num_returns(0)
   , _cleanup_block(NULL)
   , _cleanup_return_prev(NULL)
@@ -3195,11 +3195,11 @@
 
 GraphBuilder::GraphBuilder(Compilation* compilation, IRScope* scope)
   : _scope_data(NULL)
+  , _compilation(compilation)
+  , _memory(new MemoryBuffer())
+  , _inline_bailout_msg(NULL)
   , _instruction_count(0)
   , _osr_entry(NULL)
-  , _memory(new MemoryBuffer())
-  , _compilation(compilation)
-  , _inline_bailout_msg(NULL)
 {
   int osr_bci = compilation->osr_bci();
 
--- a/src/hotspot/share/c1/c1_IR.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_IR.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -132,8 +132,8 @@
 
 
 IRScope::IRScope(Compilation* compilation, IRScope* caller, int caller_bci, ciMethod* method, int osr_bci, bool create_graph)
-: _callees(2)
-, _compilation(compilation)
+: _compilation(compilation)
+, _callees(2)
 , _requires_phi_function(method->max_locals())
 {
   _caller             = caller;
@@ -184,11 +184,11 @@
 
 // Stack must be NON-null
 CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception)
-  : _scope(stack->scope())
-  , _scope_debug_info(NULL)
+  : _scope_debug_info(NULL)
+  , _scope(stack->scope())
+  , _exception_handlers(exception_handlers)
   , _oop_map(NULL)
   , _stack(stack)
-  , _exception_handlers(exception_handlers)
   , _is_method_handle_invoke(false)
   , _deoptimize_on_exception(deoptimize_on_exception) {
   assert(_stack != NULL, "must be non null");
@@ -196,9 +196,9 @@
 
 
 CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack)
-  : _scope(info->_scope)
+  : _scope_debug_info(NULL)
+  , _scope(info->_scope)
   , _exception_handlers(NULL)
-  , _scope_debug_info(NULL)
   , _oop_map(NULL)
   , _stack(stack == NULL ? info->_stack : stack)
   , _is_method_handle_invoke(info->_is_method_handle_invoke)
@@ -497,6 +497,7 @@
   // computation of final block order
   BlockBegin* common_dominator(BlockBegin* a, BlockBegin* b);
   void compute_dominator(BlockBegin* cur, BlockBegin* parent);
+  void compute_dominator_impl(BlockBegin* cur, BlockBegin* parent);
   int  compute_weight(BlockBegin* cur);
   bool ready_for_processing(BlockBegin* cur);
   void sort_into_work_list(BlockBegin* b);
@@ -526,14 +527,14 @@
   _num_blocks(0),
   _num_loops(0),
   _iterative_dominators(false),
+  _linear_scan_order(NULL), // initialized later with correct size
   _visited_blocks(_max_block_id),
   _active_blocks(_max_block_id),
   _dominator_blocks(_max_block_id),
   _forward_branches(_max_block_id, _max_block_id, 0),
   _loop_end_blocks(8),
+  _loop_map(0),             // initialized later with correct size
   _work_list(8),
-  _linear_scan_order(NULL), // initialized later with correct size
-  _loop_map(0),             // initialized later with correct size
   _compilation(c)
 {
   TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order"));
@@ -770,6 +771,14 @@
 }
 
 void ComputeLinearScanOrder::compute_dominator(BlockBegin* cur, BlockBegin* parent) {
+  init_visited();
+  compute_dominator_impl(cur, parent);
+}
+
+void ComputeLinearScanOrder::compute_dominator_impl(BlockBegin* cur, BlockBegin* parent) {
+  // Mark as visited to avoid recursive calls with same parent
+  set_visited(cur);
+
   if (cur->dominator() == NULL) {
     TRACE_LINEAR_SCAN(4, tty->print_cr("DOM: initializing dominator of B%d to B%d", cur->block_id(), parent->block_id()));
     cur->set_dominator(parent);
@@ -788,7 +797,9 @@
   int num_cur_xhandler = cur->number_of_exception_handlers();
   for (int j = 0; j < num_cur_xhandler; j++) {
     BlockBegin* xhandler = cur->exception_handler_at(j);
-    compute_dominator(xhandler, parent);
+    if (!is_visited(xhandler)) {
+      compute_dominator_impl(xhandler, parent);
+    }
   }
 }
 
--- a/src/hotspot/share/c1/c1_IR.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_IR.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -215,8 +215,8 @@
                    GrowableArray<MonitorValue*>* monitors,
                    IRScopeDebugInfo*             caller):
       _scope(scope)
+    , _bci(bci)
     , _locals(locals)
-    , _bci(bci)
     , _expressions(expressions)
     , _monitors(monitors)
     , _caller(caller) {}
--- a/src/hotspot/share/c1/c1_Instruction.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_Instruction.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -410,19 +410,20 @@
 
   // creation
   Instruction(ValueType* type, ValueStack* state_before = NULL, bool type_is_constant = false)
-  : _use_count(0)
+  :
 #ifndef PRODUCT
-  , _printable_bci(-99)
+  _printable_bci(-99),
 #endif
+    _use_count(0)
   , _pin_state(0)
   , _type(type)
   , _next(NULL)
-  , _block(NULL)
   , _subst(NULL)
+  , _operand(LIR_OprFact::illegalOpr)
   , _flags(0)
-  , _operand(LIR_OprFact::illegalOpr)
   , _state_before(state_before)
   , _exception_handlers(NULL)
+  , _block(NULL)
   {
     check_state(state_before);
     assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist");
@@ -705,8 +706,8 @@
   Local(ciType* declared, ValueType* type, int index, bool receiver)
     : Instruction(type)
     , _java_index(index)
+    , _is_receiver(receiver)
     , _declared_type(declared)
-    , _is_receiver(receiver)
   {
     NOT_PRODUCT(set_printable_bci(-1));
   }
@@ -1664,19 +1665,21 @@
   , _bci(bci)
   , _depth_first_number(-1)
   , _linear_scan_number(-1)
+  , _dominator_depth(-1)
   , _loop_depth(0)
+  , _loop_index(-1)
   , _flags(0)
-  , _dominator_depth(-1)
+  , _total_preds(0)
+  , _stores_to_locals()
+  , _successors(2)
+  , _predecessors(2)
+  , _dominates(2)
   , _dominator(NULL)
   , _end(NULL)
-  , _predecessors(2)
-  , _successors(2)
-  , _dominates(2)
   , _exception_handlers(1)
   , _exception_states(NULL)
   , _exception_handler_pco(-1)
   , _lir(NULL)
-  , _loop_index(-1)
   , _live_in()
   , _live_out()
   , _live_gen()
@@ -1685,8 +1688,6 @@
   , _fpu_stack_state(NULL)
   , _first_lir_instruction_id(-1)
   , _last_lir_instruction_id(-1)
-  , _total_preds(0)
-  , _stores_to_locals()
   {
     _block = this;
 #ifndef PRODUCT
@@ -1872,18 +1873,18 @@
   // creation
   Goto(BlockBegin* sux, ValueStack* state_before, bool is_safepoint = false)
     : BlockEnd(illegalType, state_before, is_safepoint)
-    , _direction(none)
     , _profiled_method(NULL)
-    , _profiled_bci(0) {
+    , _profiled_bci(0)
+    , _direction(none) {
     BlockList* s = new BlockList(1);
     s->append(sux);
     set_sux(s);
   }
 
   Goto(BlockBegin* sux, bool is_safepoint) : BlockEnd(illegalType, NULL, is_safepoint)
-                                           , _direction(none)
                                            , _profiled_method(NULL)
-                                           , _profiled_bci(0) {
+                                           , _profiled_bci(0)
+                                           , _direction(none) {
     BlockList* s = new BlockList(1);
     s->append(sux);
     set_sux(s);
@@ -2550,9 +2551,9 @@
  public:
   RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
     : Instruction(type)
+    , _entry_name(entry_name)
     , _entry(entry)
     , _args(args)
-    , _entry_name(entry_name)
     , _pass_thread(pass_thread) {
     ASSERT_VALUES
     pin();
--- a/src/hotspot/share/c1/c1_InstructionPrinter.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_InstructionPrinter.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -47,8 +47,8 @@
 
  public:
   InstructionPrinter(bool print_phis = true, outputStream* output = tty)
-    : _print_phis(print_phis)
-    , _output(output)
+    : _output(output)
+    , _print_phis(print_phis)
   {}
 
   outputStream* output() { return _output; }
--- a/src/hotspot/share/c1/c1_LIR.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIR.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -321,9 +321,9 @@
   , _tmp2(tmp2)
   , _tmp3(tmp3)
   , _fast_check(fast_check)
-  , _stub(stub)
   , _info_for_patch(info_for_patch)
   , _info_for_exception(info_for_exception)
+  , _stub(stub)
   , _profiled_method(NULL)
   , _profiled_bci(-1)
   , _should_profile(false)
@@ -348,9 +348,9 @@
   , _tmp2(tmp2)
   , _tmp3(tmp3)
   , _fast_check(false)
-  , _stub(NULL)
   , _info_for_patch(NULL)
   , _info_for_exception(info_for_exception)
+  , _stub(NULL)
   , _profiled_method(NULL)
   , _profiled_bci(-1)
   , _should_profile(false)
@@ -367,14 +367,14 @@
 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
-  , _tmp(tmp)
   , _src(src)
   , _src_pos(src_pos)
   , _dst(dst)
   , _dst_pos(dst_pos)
-  , _flags(flags)
+  , _length(length)
+  , _tmp(tmp)
   , _expected_type(expected_type)
-  , _length(length) {
+  , _flags(flags) {
   _stub = new ArrayCopyStub(this);
 }
 
--- a/src/hotspot/share/c1/c1_LIR.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIR.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -516,36 +516,36 @@
        _base(base)
      , _index(index)
      , _scale(times_1)
-     , _type(type)
-     , _disp(0) { verify(); }
+     , _disp(0)
+     , _type(type) { verify(); }
 
   LIR_Address(LIR_Opr base, intx disp, BasicType type):
        _base(base)
      , _index(LIR_OprDesc::illegalOpr())
      , _scale(times_1)
-     , _type(type)
-     , _disp(disp) { verify(); }
+     , _disp(disp)
+     , _type(type) { verify(); }
 
   LIR_Address(LIR_Opr base, BasicType type):
        _base(base)
      , _index(LIR_OprDesc::illegalOpr())
      , _scale(times_1)
-     , _type(type)
-     , _disp(0) { verify(); }
+     , _disp(0)
+     , _type(type) { verify(); }
 
   LIR_Address(LIR_Opr base, LIR_Opr index, intx disp, BasicType type):
        _base(base)
      , _index(index)
      , _scale(times_1)
-     , _type(type)
-     , _disp(disp) { verify(); }
+     , _disp(disp)
+     , _type(type) { verify(); }
 
   LIR_Address(LIR_Opr base, LIR_Opr index, Scale scale, intx disp, BasicType type):
        _base(base)
      , _index(index)
      , _scale(scale)
-     , _type(type)
-     , _disp(disp) { verify(); }
+     , _disp(disp)
+     , _type(type) { verify(); }
 
   LIR_Opr base()  const                          { return _base;  }
   LIR_Opr index() const                          { return _index; }
@@ -1058,30 +1058,32 @@
 
  public:
   LIR_Op()
-    : _result(LIR_OprFact::illegalOpr)
+    :
+#ifdef ASSERT
+      _file(NULL)
+    , _line(0),
+#endif
+      _result(LIR_OprFact::illegalOpr)
     , _code(lir_none)
     , _flags(0)
     , _info(NULL)
-#ifdef ASSERT
-    , _file(NULL)
-    , _line(0)
-#endif
+    , _id(-1)
     , _fpu_pop_count(0)
-    , _source(NULL)
-    , _id(-1)                             {}
+    , _source(NULL) {}
 
   LIR_Op(LIR_Code code, LIR_Opr result, CodeEmitInfo* info)
-    : _result(result)
+    :
+#ifdef ASSERT
+      _file(NULL)
+    , _line(0),
+#endif
+      _result(result)
     , _code(code)
     , _flags(0)
     , _info(info)
-#ifdef ASSERT
-    , _file(NULL)
-    , _line(0)
-#endif
+    , _id(-1)
     , _fpu_pop_count(0)
-    , _source(NULL)
-    , _id(-1)                             {}
+    , _source(NULL) {}
 
   CodeEmitInfo* info() const                  { return _info;   }
   LIR_Code code()      const                  { return (LIR_Code)_code;   }
@@ -1153,8 +1155,8 @@
   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
              LIR_OprList* arguments, CodeEmitInfo* info = NULL)
     : LIR_Op(code, result, info)
-    , _arguments(arguments)
-    , _addr(addr) {}
+    , _addr(addr)
+    , _arguments(arguments) {}
 
  public:
   address addr() const                           { return _addr; }
@@ -1180,8 +1182,8 @@
                  address addr, LIR_OprList* arguments,
                  CodeEmitInfo* info)
   : LIR_OpCall(code, addr, result, arguments, info)
+  , _method(method)
   , _receiver(receiver)
-  , _method(method)
   , _method_handle_invoke_SP_save_opr(LIR_OprFact::illegalOpr)
   { assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }
 
@@ -1189,8 +1191,8 @@
                  LIR_Opr receiver, LIR_Opr result, intptr_t vtable_offset,
                  LIR_OprList* arguments, CodeEmitInfo* info)
   : LIR_OpCall(code, (address)vtable_offset, result, arguments, info)
+  , _method(method)
   , _receiver(receiver)
-  , _method(method)
   , _method_handle_invoke_SP_save_opr(LIR_OprFact::illegalOpr)
   { assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }
 
@@ -1345,14 +1347,14 @@
   LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result = LIR_OprFact::illegalOpr, BasicType type = T_ILLEGAL, LIR_PatchCode patch = lir_patch_none, CodeEmitInfo* info = NULL)
     : LIR_Op(code, result, info)
     , _opr(opr)
-    , _patch(patch)
-    , _type(type)                      { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
+    , _type(type)
+    , _patch(patch)                    { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
 
   LIR_Op1(LIR_Code code, LIR_Opr opr, LIR_Opr result, BasicType type, LIR_PatchCode patch, CodeEmitInfo* info, LIR_MoveKind kind)
     : LIR_Op(code, result, info)
     , _opr(opr)
-    , _patch(patch)
-    , _type(type)                      {
+    , _type(type)
+    , _patch(patch)                    {
     assert(code == lir_move, "must be");
     set_kind(kind);
   }
@@ -1360,8 +1362,8 @@
   LIR_Op1(LIR_Code code, LIR_Opr opr, CodeEmitInfo* info)
     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
     , _opr(opr)
-    , _patch(lir_patch_none)
-    , _type(T_ILLEGAL)                 { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
+    , _type(T_ILLEGAL)
+    , _patch(lir_patch_none)           { assert(is_in_range(code, begin_op1, end_op1), "code check"); }
 
   LIR_Opr in_opr()           const               { return _opr;   }
   LIR_PatchCode patch_code() const               { return _patch; }
@@ -1462,8 +1464,8 @@
  public:
    LIR_OpConvert(Bytecodes::Code code, LIR_Opr opr, LIR_Opr result, ConversionStub* stub)
      : LIR_Op1(lir_convert, opr, result)
-     , _stub(stub)
-     , _bytecode(code)                           {}
+     , _bytecode(code)
+     , _stub(stub)                               {}
 
   Bytecodes::Code bytecode() const               { return _bytecode; }
   ConversionStub* stub() const                   { return _stub; }
@@ -1501,8 +1503,8 @@
     , _tmp4(t4)
     , _hdr_size(hdr_size)
     , _obj_size(obj_size)
-    , _init_check(init_check)
-    , _stub(stub)                                { }
+    , _stub(stub)
+    , _init_check(init_check)                    { }
 
   LIR_Opr klass()        const                   { return in_opr();     }
   LIR_Opr obj()          const                   { return result_opr(); }
@@ -1611,31 +1613,31 @@
  public:
   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = NULL)
     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
+    , _fpu_stack_size(0)
     , _opr1(opr1)
     , _opr2(opr2)
     , _type(T_ILLEGAL)
-    , _condition(condition)
-    , _fpu_stack_size(0)
     , _tmp1(LIR_OprFact::illegalOpr)
     , _tmp2(LIR_OprFact::illegalOpr)
     , _tmp3(LIR_OprFact::illegalOpr)
     , _tmp4(LIR_OprFact::illegalOpr)
-    , _tmp5(LIR_OprFact::illegalOpr) {
+    , _tmp5(LIR_OprFact::illegalOpr)
+    , _condition(condition) {
     assert(code == lir_cmp || code == lir_assert, "code check");
   }
 
   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)
     : LIR_Op(code, result, NULL)
+    , _fpu_stack_size(0)
     , _opr1(opr1)
     , _opr2(opr2)
     , _type(type)
-    , _condition(condition)
-    , _fpu_stack_size(0)
     , _tmp1(LIR_OprFact::illegalOpr)
     , _tmp2(LIR_OprFact::illegalOpr)
     , _tmp3(LIR_OprFact::illegalOpr)
     , _tmp4(LIR_OprFact::illegalOpr)
-    , _tmp5(LIR_OprFact::illegalOpr) {
+    , _tmp5(LIR_OprFact::illegalOpr)
+    , _condition(condition) {
     assert(code == lir_cmove, "code check");
     assert(type != T_ILLEGAL, "cmove should have type");
   }
@@ -1643,32 +1645,32 @@
   LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result = LIR_OprFact::illegalOpr,
           CodeEmitInfo* info = NULL, BasicType type = T_ILLEGAL)
     : LIR_Op(code, result, info)
+    , _fpu_stack_size(0)
     , _opr1(opr1)
     , _opr2(opr2)
     , _type(type)
-    , _condition(lir_cond_unknown)
-    , _fpu_stack_size(0)
     , _tmp1(LIR_OprFact::illegalOpr)
     , _tmp2(LIR_OprFact::illegalOpr)
     , _tmp3(LIR_OprFact::illegalOpr)
     , _tmp4(LIR_OprFact::illegalOpr)
-    , _tmp5(LIR_OprFact::illegalOpr) {
+    , _tmp5(LIR_OprFact::illegalOpr)
+    , _condition(lir_cond_unknown) {
     assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");
   }
 
   LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, LIR_Opr tmp1, LIR_Opr tmp2 = LIR_OprFact::illegalOpr,
           LIR_Opr tmp3 = LIR_OprFact::illegalOpr, LIR_Opr tmp4 = LIR_OprFact::illegalOpr, LIR_Opr tmp5 = LIR_OprFact::illegalOpr)
     : LIR_Op(code, result, NULL)
+    , _fpu_stack_size(0)
     , _opr1(opr1)
     , _opr2(opr2)
     , _type(T_ILLEGAL)
-    , _condition(lir_cond_unknown)
-    , _fpu_stack_size(0)
     , _tmp1(tmp1)
     , _tmp2(tmp2)
     , _tmp3(tmp3)
     , _tmp4(tmp4)
-    , _tmp5(tmp5) {
+    , _tmp5(tmp5)
+    , _condition(lir_cond_unknown) {
     assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");
   }
 
@@ -1833,8 +1835,8 @@
  public:
   LIR_OpAssert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt)
     : LIR_Op2(lir_assert, condition, opr1, opr2)
-    , _halt(halt)
-    , _msg(msg) {
+    , _msg(msg)
+    , _halt(halt) {
   }
 
   const char* msg() const                        { return _msg; }
@@ -1942,9 +1944,9 @@
     : LIR_Op(lir_profile_type, LIR_OprFact::illegalOpr, NULL)  // no result, no info
     , _mdp(mdp)
     , _obj(obj)
+    , _tmp(tmp)
     , _exact_klass(exact_klass)
     , _current_klass(current_klass)
-    , _tmp(tmp)
     , _not_null(not_null)
     , _no_conflict(no_conflict) { }
 
--- a/src/hotspot/share/c1/c1_LIRAssembler.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIRAssembler.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -99,9 +99,9 @@
 
 
 LIR_Assembler::LIR_Assembler(Compilation* c):
-   _compilation(c)
- , _masm(c->masm())
+   _masm(c->masm())
  , _bs(BarrierSet::barrier_set())
+ , _compilation(c)
  , _frame_map(c->frame_map())
  , _current_block(NULL)
  , _pending_non_safepoint(NULL)
--- a/src/hotspot/share/c1/c1_LIRGenerator.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1285,9 +1285,10 @@
   // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
   // meaning of these two is mixed up (see JDK-8026837).
   __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), temp, info);
-  __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), result);
+  __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), temp);
   // mirror = ((OopHandle)mirror)->resolve();
-  __ move_wide(new LIR_Address(result, T_OBJECT), result);
+  access_load(IN_NATIVE, T_OBJECT,
+              LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), result);
 }
 
 // java.lang.Class::isPrimitive()
@@ -1623,6 +1624,18 @@
   }
 }
 
+void LIRGenerator::access_load(DecoratorSet decorators, BasicType type,
+                               LIR_Opr addr, LIR_Opr result) {
+  decorators |= C1_READ_ACCESS;
+  LIRAccess access(this, decorators, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, type);
+  access.set_resolved_addr(addr);
+  if (access.is_raw()) {
+    _barrier_set->BarrierSetC1::load(access, result);
+  } else {
+    _barrier_set->load(access, result);
+  }
+}
+
 void LIRGenerator::access_store_at(DecoratorSet decorators, BasicType type,
                                    LIRItem& base, LIR_Opr offset, LIR_Opr value,
                                    CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) {
--- a/src/hotspot/share/c1/c1_LIRGenerator.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_LIRGenerator.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -288,6 +288,9 @@
                       LIRItem& base, LIR_Opr offset, LIR_Opr result,
                       CodeEmitInfo* patch_info = NULL, CodeEmitInfo* load_emit_info = NULL);
 
+  void access_load(DecoratorSet decorators, BasicType type,
+                   LIR_Opr addr, LIR_Opr result);
+
   LIR_Opr access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
                                    LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value);
 
--- a/src/hotspot/share/c1/c1_LinearScan.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_LinearScan.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -74,6 +74,7 @@
  , _ir(ir)
  , _gen(gen)
  , _frame_map(frame_map)
+ , _cached_blocks(*ir->linear_scan_order())
  , _num_virtual_regs(gen->max_virtual_register_number())
  , _has_fpu_registers(false)
  , _num_calls(-1)
@@ -87,9 +88,8 @@
  , _block_of_op(0) // initialized later with correct length
  , _has_info(0)
  , _has_call(0)
+ , _interval_in_loop(0)  // initialized later with correct length
  , _scope_value_cache(0) // initialized later with correct length
- , _interval_in_loop(0)  // initialized later with correct length
- , _cached_blocks(*ir->linear_scan_order())
 #ifdef X86
  , _fpu_stack_allocator(NULL)
 #endif
@@ -3717,13 +3717,13 @@
 
 MoveResolver::MoveResolver(LinearScan* allocator) :
   _allocator(allocator),
-  _multiple_reads_allowed(false),
+  _insert_list(NULL),
+  _insert_idx(-1),
+  _insertion_buffer(),
   _mapping_from(8),
   _mapping_from_opr(8),
   _mapping_to(8),
-  _insert_list(NULL),
-  _insert_idx(-1),
-  _insertion_buffer()
+  _multiple_reads_allowed(false)
 {
   for (int i = 0; i < LinearScan::nof_regs; i++) {
     _register_blocked[i] = 0;
@@ -4127,9 +4127,9 @@
   _split_children(0),
   _canonical_spill_slot(-1),
   _insert_move_when_activated(false),
-  _register_hint(NULL),
   _spill_state(noDefinitionFound),
-  _spill_definition_pos(-1)
+  _spill_definition_pos(-1),
+  _register_hint(NULL)
 {
   _split_parent = this;
   _current_split_child = this;
--- a/src/hotspot/share/c1/c1_Optimizer.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_Optimizer.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -47,7 +47,7 @@
   int _has_substitution;
 
  public:
-  CE_Eliminator(IR* hir) : _cee_count(0), _ifop_count(0), _hir(hir) {
+  CE_Eliminator(IR* hir) : _hir(hir), _cee_count(0), _ifop_count(0) {
     _has_substitution = false;
     _hir->iterate_preorder(this);
     if (_has_substitution) {
@@ -592,10 +592,10 @@
   // constructor
   NullCheckEliminator(Optimizer* opt)
     : _opt(opt)
+    , _work_list(new BlockList())
     , _set(new ValueSet())
-    , _last_explicit_null_check(NULL)
     , _block_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL)
-    , _work_list(new BlockList()) {
+    , _last_explicit_null_check(NULL) {
     _visitable_instructions = new ValueSet();
     _visitor.set_eliminator(this);
     CompileLog* log = _opt->ir()->compilation()->log();
--- a/src/hotspot/share/c1/c1_Runtime1.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_Runtime1.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -568,6 +568,7 @@
     if (log_is_enabled(Info, exceptions)) {
       ResourceMark rm;
       stringStream tempst;
+      assert(nm->method() != NULL, "Unexpected NULL method()");
       tempst.print("compiled method <%s>\n"
                    " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
                    nm->method()->print_value_string(), p2i(pc), p2i(thread));
--- a/src/hotspot/share/c1/c1_ValueMap.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_ValueMap.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -485,9 +485,9 @@
 
 
 GlobalValueNumbering::GlobalValueNumbering(IR* ir)
-  : _current_map(NULL)
+  : _compilation(ir->compilation())
+  , _current_map(NULL)
   , _value_maps(ir->linear_scan_order()->length(), ir->linear_scan_order()->length(), NULL)
-  , _compilation(ir->compilation())
 {
   TRACE_VALUE_NUMBERING(tty->print_cr("****** start of global value numbering"));
 
--- a/src/hotspot/share/c1/c1_ValueType.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/c1/c1_ValueType.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -104,7 +104,7 @@
   const ValueTag _tag;
   ValueType();
  protected:
-  ValueType(ValueTag tag, int size): _tag(tag), _size(size) {}
+  ValueType(ValueTag tag, int size): _size(size), _tag(tag) {}
 
  public:
   // initialization
--- a/src/hotspot/share/ci/bcEscapeAnalyzer.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/ci/bcEscapeAnalyzer.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -1447,8 +1447,8 @@
 #endif
 
 BCEscapeAnalyzer::BCEscapeAnalyzer(ciMethod* method, BCEscapeAnalyzer* parent)
-    : _conservative(method == NULL || !EstimateArgEscape)
-    , _arena(CURRENT_ENV->arena())
+    : _arena(CURRENT_ENV->arena())
+    , _conservative(method == NULL || !EstimateArgEscape)
     , _method(method)
     , _methodData(method ? method->method_data() : NULL)
     , _arg_size(method ? method->arg_size() : 0)
--- a/src/hotspot/share/ci/ciInstanceKlass.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/ci/ciInstanceKlass.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -596,6 +596,7 @@
     // Go into the VM to fetch the implementor.
     {
       VM_ENTRY_MARK;
+      MutexLocker ml(Compile_lock);
       Klass* k = get_instanceKlass()->implementor();
       if (k != NULL) {
         if (k == get_instanceKlass()) {
--- a/src/hotspot/share/ci/ciMethod.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/ci/ciMethod.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -166,16 +166,16 @@
   ciMetadata((Metadata*)NULL),
   _name(                   name),
   _holder(                 holder),
+  _method_data(            NULL),
+  _method_blocks(          NULL),
   _intrinsic_id(           vmIntrinsics::_none),
-  _liveness(               NULL),
+  _instructions_size(-1),
   _can_be_statically_bound(false),
-  _method_blocks(          NULL),
-  _method_data(            NULL)
+  _liveness(               NULL)
 #if defined(COMPILER2)
   ,
   _flow(                   NULL),
-  _bcea(                   NULL),
-  _instructions_size(-1)
+  _bcea(                   NULL)
 #endif // COMPILER2
 {
   // Usually holder and accessor are the same type but in some cases
--- a/src/hotspot/share/ci/ciMethodBlocks.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/ci/ciMethodBlocks.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -345,13 +345,13 @@
 }
 #endif
 
-
 ciBlock::ciBlock(ciMethod *method, int index, int start_bci) :
+                         _idx(index), _start_bci(start_bci), _limit_bci(-1), _control_bci(fall_through_bci),
+                         _flags(0), _ex_start_bci(-1), _ex_limit_bci(-1)
 #ifndef PRODUCT
-                         _method(method),
+                         , _method(method)
 #endif
-                         _idx(index), _flags(0), _start_bci(start_bci), _limit_bci(-1), _control_bci(fall_through_bci),
-                         _ex_start_bci(-1), _ex_limit_bci(-1) {
+{
 }
 
 void ciBlock::set_exception_range(int start_bci, int limit_bci)  {
--- a/src/hotspot/share/ci/ciTypeFlow.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/ci/ciTypeFlow.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -724,8 +724,8 @@
 
   public:
     Loop(Block* head, Block* tail) :
+      _parent(NULL), _sibling(NULL), _child(NULL),
       _head(head),   _tail(tail),
-      _parent(NULL), _sibling(NULL), _child(NULL),
       _irreducible(false), _def_locals() {}
 
     Loop* parent()  const { return _parent; }
--- a/src/hotspot/share/classfile/classFileParser.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -922,10 +922,10 @@
   assert(has_nonstatic_concrete_methods != NULL, "invariant");
 
   if (itfs_len == 0) {
-    _local_interfaces = Universe::the_empty_klass_array();
+    _local_interfaces = Universe::the_empty_instance_klass_array();
   } else {
     assert(itfs_len > 0, "only called for len>0");
-    _local_interfaces = MetadataFactory::new_array<Klass*>(_loader_data, itfs_len, NULL, CHECK);
+    _local_interfaces = MetadataFactory::new_array<InstanceKlass*>(_loader_data, itfs_len, NULL, CHECK);
 
     int index;
     for (index = 0; index < itfs_len; index++) {
@@ -966,7 +966,7 @@
       if (InstanceKlass::cast(interf)->has_nonstatic_concrete_methods()) {
         *has_nonstatic_concrete_methods = true;
       }
-      _local_interfaces->at_put(index, interf);
+      _local_interfaces->at_put(index, InstanceKlass::cast(interf));
     }
 
     if (!_need_verify || itfs_len <= 1) {
@@ -984,8 +984,8 @@
     {
       debug_only(NoSafepointVerifier nsv;)
       for (index = 0; index < itfs_len; index++) {
-        const Klass* const k = _local_interfaces->at(index);
-        name = InstanceKlass::cast(k)->name();
+        const InstanceKlass* const k = _local_interfaces->at(index);
+        name = k->name();
         // If no duplicates, add (name, NULL) in hashtable interface_names.
         if (!put_after_lookup(name, NULL, interface_names)) {
           dup = true;
@@ -3572,6 +3572,9 @@
                          "Nest-host class_info_index %u has bad constant type in class file %s",
                          class_info_index, CHECK);
           _nest_host = class_info_index;
+        } else {
+          // Unknown attribute
+          cfs->skip_u1(attribute_length, CHECK);
         }
       } else {
         // Unknown attribute
@@ -4493,7 +4496,7 @@
     }
 
     // add super interface dependencies
-    const Array<Klass*>* const local_interfaces = defined_klass->local_interfaces();
+    const Array<InstanceKlass*>* const local_interfaces = defined_klass->local_interfaces();
     if (local_interfaces != NULL) {
       const int length = local_interfaces->length();
       for (int i = 0; i < length; i++) {
@@ -4505,21 +4508,21 @@
 
 // utility methods for appending an array with check for duplicates
 
-static void append_interfaces(GrowableArray<Klass*>* result,
-                              const Array<Klass*>* const ifs) {
+static void append_interfaces(GrowableArray<InstanceKlass*>* result,
+                              const Array<InstanceKlass*>* const ifs) {
   // iterate over new interfaces
   for (int i = 0; i < ifs->length(); i++) {
-    Klass* const e = ifs->at(i);
-    assert(e->is_klass() && InstanceKlass::cast(e)->is_interface(), "just checking");
+    InstanceKlass* const e = ifs->at(i);
+    assert(e->is_klass() && e->is_interface(), "just checking");
     // add new interface
     result->append_if_missing(e);
   }
 }
 
-static Array<Klass*>* compute_transitive_interfaces(const InstanceKlass* super,
-                                                    Array<Klass*>* local_ifs,
-                                                    ClassLoaderData* loader_data,
-                                                    TRAPS) {
+static Array<InstanceKlass*>* compute_transitive_interfaces(const InstanceKlass* super,
+                                                            Array<InstanceKlass*>* local_ifs,
+                                                            ClassLoaderData* loader_data,
+                                                            TRAPS) {
   assert(local_ifs != NULL, "invariant");
   assert(loader_data != NULL, "invariant");
 
@@ -4534,15 +4537,15 @@
   // Add local interfaces' super interfaces
   const int local_size = local_ifs->length();
   for (int i = 0; i < local_size; i++) {
-    Klass* const l = local_ifs->at(i);
-    max_transitive_size += InstanceKlass::cast(l)->transitive_interfaces()->length();
+    InstanceKlass* const l = local_ifs->at(i);
+    max_transitive_size += l->transitive_interfaces()->length();
   }
   // Finally add local interfaces
   max_transitive_size += local_size;
   // Construct array
   if (max_transitive_size == 0) {
     // no interfaces, use canonicalized array
-    return Universe::the_empty_klass_array();
+    return Universe::the_empty_instance_klass_array();
   } else if (max_transitive_size == super_size) {
     // no new local interfaces added, share superklass' transitive interface array
     return super->transitive_interfaces();
@@ -4551,7 +4554,7 @@
     return local_ifs;
   } else {
     ResourceMark rm;
-    GrowableArray<Klass*>* const result = new GrowableArray<Klass*>(max_transitive_size);
+    GrowableArray<InstanceKlass*>* const result = new GrowableArray<InstanceKlass*>(max_transitive_size);
 
     // Copy down from superclass
     if (super != NULL) {
@@ -4560,8 +4563,8 @@
 
     // Copy down from local interfaces' superinterfaces
     for (int i = 0; i < local_size; i++) {
-      Klass* const l = local_ifs->at(i);
-      append_interfaces(result, InstanceKlass::cast(l)->transitive_interfaces());
+      InstanceKlass* const l = local_ifs->at(i);
+      append_interfaces(result, l->transitive_interfaces());
     }
     // Finally add local interfaces
     append_interfaces(result, local_ifs);
@@ -4569,10 +4572,10 @@
     // length will be less than the max_transitive_size if duplicates were removed
     const int length = result->length();
     assert(length <= max_transitive_size, "just checking");
-    Array<Klass*>* const new_result =
-      MetadataFactory::new_array<Klass*>(loader_data, length, CHECK_NULL);
+    Array<InstanceKlass*>* const new_result =
+      MetadataFactory::new_array<InstanceKlass*>(loader_data, length, CHECK_NULL);
     for (int i = 0; i < length; i++) {
-      Klass* const e = result->at(i);
+      InstanceKlass* const e = result->at(i);
       assert(e != NULL, "just checking");
       new_result->at_put(i, e);
     }
@@ -4640,17 +4643,17 @@
 
 static void check_super_interface_access(const InstanceKlass* this_klass, TRAPS) {
   assert(this_klass != NULL, "invariant");
-  const Array<Klass*>* const local_interfaces = this_klass->local_interfaces();
+  const Array<InstanceKlass*>* const local_interfaces = this_klass->local_interfaces();
   const int lng = local_interfaces->length();
   for (int i = lng - 1; i >= 0; i--) {
-    Klass* const k = local_interfaces->at(i);
+    InstanceKlass* const k = local_interfaces->at(i);
     assert (k != NULL && k->is_interface(), "invalid interface");
     Reflection::VerifyClassAccessResults vca_result =
-      Reflection::verify_class_access(this_klass, InstanceKlass::cast(k), false);
+      Reflection::verify_class_access(this_klass, k, false);
     if (vca_result != Reflection::ACCESS_OK) {
       ResourceMark rm(THREAD);
       char* msg = Reflection::verify_class_access_msg(this_klass,
-                                                      InstanceKlass::cast(k),
+                                                      k,
                                                       vca_result);
       if (msg == NULL) {
         bool same_module = (this_klass->module() == k->module());
@@ -5732,11 +5735,11 @@
                    ik->java_super()->external_name());
       }
       // print out each of the interface classes referred to by this class.
-      const Array<Klass*>* const local_interfaces = ik->local_interfaces();
+      const Array<InstanceKlass*>* const local_interfaces = ik->local_interfaces();
       if (local_interfaces != NULL) {
         const int length = local_interfaces->length();
         for (int i = 0; i < length; i++) {
-          const Klass* const k = local_interfaces->at(i);
+          const InstanceKlass* const k = local_interfaces->at(i);
           const char * to = k->external_name();
           log_debug(class, resolve)("%s %s (interface)", from, to);
         }
@@ -6269,7 +6272,7 @@
   assert(_loader_data != NULL, "invariant");
 
   if (_class_name == vmSymbols::java_lang_Object()) {
-    check_property(_local_interfaces == Universe::the_empty_klass_array(),
+    check_property(_local_interfaces == Universe::the_empty_instance_klass_array(),
                    "java.lang.Object cannot implement an interface in class file %s",
                    CHECK);
   }
--- a/src/hotspot/share/classfile/classFileParser.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classFileParser.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -99,8 +99,8 @@
   Array<u2>* _inner_classes;
   Array<u2>* _nest_members;
   u2 _nest_host;
-  Array<Klass*>* _local_interfaces;
-  Array<Klass*>* _transitive_interfaces;
+  Array<InstanceKlass*>* _local_interfaces;
+  Array<InstanceKlass*>* _transitive_interfaces;
   Annotations* _combined_annotations;
   AnnotationArray* _annotations;
   AnnotationArray* _type_annotations;
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -95,7 +95,7 @@
   ClassLoaderDataGraph::_head = _the_null_class_loader_data;
   assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be");
 
-  LogTarget(Debug, class, loader, data) lt;
+  LogTarget(Trace, class, loader, data) lt;
   if (lt.is_enabled()) {
     ResourceMark rm;
     LogStream ls(lt);
@@ -142,19 +142,22 @@
 }
 
 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous) :
-  _is_anonymous(is_anonymous),
+  _metaspace(NULL),
+  _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
+                            Monitor::_safepoint_check_never)),
+  _unloading(false), _is_anonymous(is_anonymous),
+  _modified_oops(true), _accumulated_modified_oops(false),
   // An anonymous class loader data doesn't have anything to keep
   // it from being unloaded during parsing of the anonymous class.
   // The null-class-loader should always be kept alive.
   _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
-  _metaspace(NULL), _unloading(false), _klasses(NULL),
-  _modules(NULL), _packages(NULL), _unnamed_module(NULL), _dictionary(NULL),
-  _claimed(0), _modified_oops(true), _accumulated_modified_oops(false),
-  _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
+  _claimed(0),
+  _handles(),
+  _klasses(NULL), _packages(NULL), _modules(NULL), _unnamed_module(NULL), _dictionary(NULL),
+  _jmethod_ids(NULL),
+  _deallocate_list(NULL),
   _next(NULL),
-  _class_loader_klass(NULL), _name(NULL), _name_and_id(NULL),
-  _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
-                            Monitor::_safepoint_check_never)) {
+  _class_loader_klass(NULL), _name(NULL), _name_and_id(NULL) {
 
   if (!h_class_loader.is_null()) {
     _class_loader = _handles.add(h_class_loader());
@@ -592,7 +595,7 @@
 void ClassLoaderData::unload() {
   _unloading = true;
 
-  LogTarget(Debug, class, loader, data) lt;
+  LogTarget(Trace, class, loader, data) lt;
   if (lt.is_enabled()) {
     ResourceMark rm;
     LogStream ls(lt);
@@ -603,7 +606,7 @@
 
   // 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();
+  free_deallocate_list_C_heap_structures();
 
   // Tell serviceability tools these classes are unloading
   // after erroneous classes are released.
@@ -846,7 +849,7 @@
 }
 
 // Add this metadata pointer to be freed when it's safe.  This is only during
-// class unloading because Handles might point to this metadata field.
+// a safepoint which checks if handles point to this metadata field.
 void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
   // Metadata in shared region isn't deleted.
   if (!m->is_shared()) {
@@ -855,6 +858,8 @@
       _deallocate_list = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(100, true);
     }
     _deallocate_list->append_if_missing(m);
+    log_debug(class, loader, data)("deallocate added for %s", m->print_value_string());
+    ClassLoaderDataGraph::set_should_clean_deallocate_lists();
   }
 }
 
@@ -888,16 +893,52 @@
       assert(!m->is_klass() || !((InstanceKlass*)m)->is_scratch_class(),
              "scratch classes on this list should be dead");
       // Also should assert that other metadata on the list was found in handles.
+      // Some cleaning remains.
+      ClassLoaderDataGraph::set_should_clean_deallocate_lists();
     }
   }
 }
 
+void ClassLoaderDataGraph::clean_deallocate_lists(bool walk_previous_versions) {
+  uint loaders_processed = 0;
+  for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
+    // is_alive check will be necessary for concurrent class unloading.
+    if (cld->is_alive()) {
+      // clean metaspace
+      if (walk_previous_versions) {
+        cld->classes_do(InstanceKlass::purge_previous_versions);
+      }
+      cld->free_deallocate_list();
+      loaders_processed++;
+    }
+  }
+  log_debug(class, loader, data)("clean_deallocate_lists: loaders processed %u %s",
+                                 loaders_processed, walk_previous_versions ? "walk_previous_versions" : "");
+}
+
+void ClassLoaderDataGraph::walk_metadata_and_clean_metaspaces() {
+  assert(SafepointSynchronize::is_at_safepoint(), "must only be called at safepoint");
+
+  _should_clean_deallocate_lists = false; // assume everything gets cleaned
+
+  // Mark metadata seen on the stack so we can delete unreferenced entries.
+  // Walk all metadata, including the expensive code cache walk, only for class redefinition.
+  // The MetadataOnStackMark walk during redefinition saves previous versions if it finds old methods
+  // on the stack or in the code cache, so we only have to repeat the full walk if
+  // they were found at that time.
+  // TODO: have redefinition clean old methods out of the code cache.  They still exist in some places.
+  bool walk_all_metadata = InstanceKlass::has_previous_versions_and_reset();
+
+  MetadataOnStackMark md_on_stack(walk_all_metadata);
+  clean_deallocate_lists(walk_all_metadata);
+}
+
 // This is distinct from free_deallocate_list.  For class loader data that are
 // unloading, this frees the C heap memory for items on the list, and unlinks
 // scratch or error classes so that unloading events aren't triggered for these
 // classes. The metadata is removed with the unloading metaspace.
 // There isn't C heap memory allocated for methods, so nothing is done for them.
-void ClassLoaderData::unload_deallocate_list() {
+void ClassLoaderData::free_deallocate_list_C_heap_structures() {
   // 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");
@@ -907,7 +948,6 @@
   // 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);
     if (m->is_constantPool()) {
       ((ConstantPool*)m)->release_C_heap_structures();
@@ -1023,6 +1063,8 @@
 ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL;
 
 bool ClassLoaderDataGraph::_should_purge = false;
+bool ClassLoaderDataGraph::_should_clean_deallocate_lists = false;
+bool ClassLoaderDataGraph::_safepoint_cleanup_needed = false;
 bool ClassLoaderDataGraph::_metaspace_oom = false;
 
 // Add a new class loader data node to the list.  Assign the newly created
@@ -1053,7 +1095,7 @@
     cld->set_next(next);
     ClassLoaderData* exchanged = Atomic::cmpxchg(cld, list_head, next);
     if (exchanged == next) {
-      LogTarget(Debug, class, loader, data) lt;
+      LogTarget(Trace, class, loader, data) lt;
       if (lt.is_enabled()) {
         ResourceMark rm;
         LogStream ls(lt);
@@ -1334,7 +1376,10 @@
 
 // Move class loader data from main list to the unloaded list for unloading
 // and deallocation later.
-bool ClassLoaderDataGraph::do_unloading(bool clean_previous_versions) {
+bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
+
+  // Indicate whether safepoint cleanup is needed.
+  _safepoint_cleanup_needed |= do_cleaning;
 
   ClassLoaderData* data = _head;
   ClassLoaderData* prev = NULL;
@@ -1342,15 +1387,6 @@
   uint loaders_processed = 0;
   uint loaders_removed = 0;
 
-  // Mark metadata seen on the stack only so we can delete unneeded entries.
-  // Only walk all metadata, including the expensive code cache walk, for Full GC
-  // and only if class redefinition and if there's previous versions of
-  // Klasses to delete.
-  bool walk_all_metadata = clean_previous_versions &&
-                           JvmtiExport::has_redefined_a_class() &&
-                           InstanceKlass::has_previous_versions_and_reset();
-  MetadataOnStackMark md_on_stack(walk_all_metadata);
-
   // Save previous _unloading pointer for CMS which may add to unloading list before
   // purging and we don't want to rewalk the previously unloaded class loader data.
   _saved_unloading = _unloading;
@@ -1358,11 +1394,6 @@
   data = _head;
   while (data != NULL) {
     if (data->is_alive()) {
-      // clean metaspace
-      if (walk_all_metadata) {
-        data->classes_do(InstanceKlass::purge_previous_versions);
-      }
-      data->free_deallocate_list();
       prev = data;
       data = data->next();
       loaders_processed++;
@@ -1387,27 +1418,6 @@
   }
 
   if (seen_dead_loader) {
-    data = _head;
-    while (data != NULL) {
-      // Remove entries in the dictionary of live class loader that have
-      // initiated loading classes in a dead class loader.
-      if (data->dictionary() != NULL) {
-        data->dictionary()->do_unloading();
-      }
-      // Walk a ModuleEntry's reads, and a PackageEntry's exports
-      // lists to determine if there are modules on those lists that are now
-      // dead and should be removed.  A module's life cycle is equivalent
-      // to its defining class loader's life cycle.  Since a module is
-      // considered dead if its class loader is dead, these walks must
-      // occur after each class loader's aliveness is determined.
-      if (data->packages() != NULL) {
-        data->packages()->purge_all_package_exports();
-      }
-      if (data->modules_defined()) {
-        data->modules()->purge_all_module_reads();
-      }
-      data = data->next();
-    }
     JFR_ONLY(post_class_unload_events();)
   }
 
@@ -1416,6 +1426,32 @@
   return seen_dead_loader;
 }
 
+// There's at least one dead class loader.  Purge refererences of healthy module
+// reads lists and package export lists to modules belonging to dead loaders.
+void ClassLoaderDataGraph::clean_module_and_package_info() {
+  ClassLoaderData* data = _head;
+  while (data != NULL) {
+    // Remove entries in the dictionary of live class loader that have
+    // initiated loading classes in a dead class loader.
+    if (data->dictionary() != NULL) {
+      data->dictionary()->do_unloading();
+    }
+    // Walk a ModuleEntry's reads, and a PackageEntry's exports
+    // lists to determine if there are modules on those lists that are now
+    // dead and should be removed.  A module's life cycle is equivalent
+    // to its defining class loader's life cycle.  Since a module is
+    // considered dead if its class loader is dead, these walks must
+    // occur after each class loader's aliveness is determined.
+    if (data->packages() != NULL) {
+      data->packages()->purge_all_package_exports();
+    }
+    if (data->modules_defined()) {
+      data->modules()->purge_all_module_reads();
+    }
+    data = data->next();
+  }
+}
+
 void ClassLoaderDataGraph::purge() {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
   ClassLoaderData* list = _unloading;
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -79,6 +79,12 @@
   static ClassLoaderData* _saved_head;
   static ClassLoaderData* _saved_unloading;
   static bool _should_purge;
+
+  // Set if there's anything to purge in the deallocate lists or previous versions
+  // during a safepoint after class unloading in a full GC.
+  static bool _should_clean_deallocate_lists;
+  static bool _safepoint_cleanup_needed;
+
   // OOM has been seen in metaspace allocation. Used to prevent some
   // allocations until class unloading
   static bool _metaspace_oom;
@@ -88,8 +94,10 @@
 
   static ClassLoaderData* add_to_graph(Handle class_loader, bool anonymous);
   static ClassLoaderData* add(Handle class_loader, bool anonymous);
+
  public:
   static ClassLoaderData* find_or_create(Handle class_loader);
+  static void clean_module_and_package_info();
   static void purge();
   static void clear_claimed_marks();
   // oops do
@@ -116,7 +124,13 @@
   static void packages_unloading_do(void f(PackageEntry*));
   static void loaded_classes_do(KlassClosure* klass_closure);
   static void classes_unloading_do(void f(Klass* const));
-  static bool do_unloading(bool clean_previous_versions);
+  static bool do_unloading(bool do_cleaning);
+
+  // Expose state to avoid logging overhead in safepoint cleanup tasks.
+  static inline bool should_clean_metaspaces_and_reset();
+  static void set_should_clean_deallocate_lists() { _should_clean_deallocate_lists = true; }
+  static void clean_deallocate_lists(bool purge_previous_versions);
+  static void walk_metadata_and_clean_metaspaces();
 
   // dictionary do
   // Iterate over all klasses in dictionary, but
@@ -185,7 +199,7 @@
       volatile juint _size;
       Chunk* _next;
 
-      Chunk(Chunk* c) : _next(c), _size(0) { }
+      Chunk(Chunk* c) : _size(0), _next(c) { }
     };
 
     Chunk* volatile _head;
@@ -297,8 +311,8 @@
   void packages_do(void f(PackageEntry*));
 
   // Deallocate free list during class unloading.
-  void free_deallocate_list();      // for the classes that are not unloaded
-  void unload_deallocate_list();    // for the classes that are unloaded
+  void free_deallocate_list();                      // for the classes that are not unloaded
+  void free_deallocate_list_C_heap_structures();    // for the classes that are unloaded
 
   // Allocate out of this class loader data
   MetaWord* allocate(size_t size);
--- a/src/hotspot/share/classfile/classLoaderData.inline.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classLoaderData.inline.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -27,6 +27,7 @@
 
 #include "classfile/classLoaderData.hpp"
 #include "classfile/javaClasses.hpp"
+#include "oops/instanceKlass.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/oopHandle.inline.hpp"
 #include "oops/weakHandle.inline.hpp"
@@ -92,4 +93,16 @@
   Atomic::sub(count, &_num_array_classes);
 }
 
+bool ClassLoaderDataGraph::should_clean_metaspaces_and_reset() {
+  // Only clean metaspaces after full GC.
+  bool do_cleaning = _safepoint_cleanup_needed;
+#if INCLUDE_JVMTI
+  do_cleaning = do_cleaning && (_should_clean_deallocate_lists || InstanceKlass::has_previous_versions());
+#else
+  do_cleaning = do_cleaning && _should_clean_deallocate_lists;
+#endif
+  _safepoint_cleanup_needed = false;  // reset
+  return do_cleaning;
+}
+
 #endif // SHARE_VM_CLASSFILE_CLASSLOADERDATA_INLINE_HPP
--- a/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classLoaderHierarchyDCmd.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -299,7 +299,7 @@
 
   LoaderTreeNode(const oop loader_oop)
     : _loader_oop(loader_oop), _cld(NULL), _child(NULL), _next(NULL),
-      _classes(NULL), _anon_classes(NULL), _num_classes(0), _num_anon_classes(0),
+      _classes(NULL), _num_classes(0), _anon_classes(NULL), _num_anon_classes(0),
       _num_folded(0)
     {}
 
--- a/src/hotspot/share/classfile/classLoaderStats.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/classLoaderStats.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -87,8 +87,8 @@
     _chunk_sz(0),
     _block_sz(0),
     _classes_count(0),
+    _anon_chunk_sz(0),
     _anon_block_sz(0),
-    _anon_chunk_sz(0),
     _anon_classes_count(0) {
   }
 };
@@ -118,11 +118,11 @@
 public:
   ClassLoaderStatsClosure(outputStream* out) :
     _out(out),
+    _stats(new StatsTable()),
     _total_loaders(0),
-    _total_block_sz(0),
+    _total_classes(0),
     _total_chunk_sz(0),
-    _total_classes(0),
-    _stats(new StatsTable()) {
+    _total_block_sz(0) {
   }
 
   virtual void do_cld(ClassLoaderData* cld);
--- a/src/hotspot/share/classfile/compactHashtable.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/compactHashtable.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -231,6 +231,10 @@
 
   // For reading from/writing to the CDS archive
   void serialize(SerializeClosure* soc);
+
+  inline bool empty() {
+    return (_entry_count == 0);
+  }
 };
 
 template <class T, class N> class CompactHashtable : public SimpleCompactHashtable {
--- a/src/hotspot/share/classfile/defaultMethods.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/defaultMethods.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -688,8 +688,8 @@
 
  public:
   FindMethodsByErasedSig(Symbol* name, Symbol* signature, bool is_interf) :
-      _method_name(name), _method_signature(signature), _cur_class_is_interface(is_interf),
-      _family(NULL) {}
+      _method_name(name), _method_signature(signature), _family(NULL),
+      _cur_class_is_interface(is_interf) {}
 
   void get_discovered_family(MethodFamily** family) {
       if (_family != NULL) {
--- a/src/hotspot/share/classfile/dictionary.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/dictionary.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -53,16 +53,16 @@
 }
 
 Dictionary::Dictionary(ClassLoaderData* loader_data, int table_size, bool resizable)
-  : _loader_data(loader_data), _resizable(resizable), _needs_resizing(false),
-  Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) {
+  : Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()),
+    _resizable(resizable), _needs_resizing(false), _loader_data(loader_data) {
 };
 
 
 Dictionary::Dictionary(ClassLoaderData* loader_data,
                        int table_size, HashtableBucket<mtClass>* t,
                        int number_of_entries, bool resizable)
-  : _loader_data(loader_data), _resizable(resizable), _needs_resizing(false),
-  Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries) {
+  : Hashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size(), t, number_of_entries),
+    _resizable(resizable), _needs_resizing(false), _loader_data(loader_data) {
 };
 
 Dictionary::~Dictionary() {
--- a/src/hotspot/share/classfile/dictionary.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/dictionary.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -182,7 +182,7 @@
     for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint
                                 current != NULL;
                                 current = current->_next) {
-      current->_pd_cache->object_no_keepalive()->verify();
+      oopDesc::verify(current->_pd_cache->object_no_keepalive());
     }
   }
 
--- a/src/hotspot/share/classfile/javaClasses.cpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Tue Aug 21 01:21:58 2018 -0700
@@ -209,7 +209,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_String::serialize(SerializeClosure* f) {
+void java_lang_String::serialize_offsets(SerializeClosure* f) {
   STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
   f->do_u4((u4*)&initialized);
 }
@@ -1534,7 +1534,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_Class::serialize(SerializeClosure* f) {
+void java_lang_Class::serialize_offsets(SerializeClosure* f) {
   f->do_u4((u4*)&offsets_computed);
   f->do_u4((u4*)&_init_lock_offset);
 
@@ -1608,7 +1608,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_Thread::serialize(SerializeClosure* f) {
+void java_lang_Thread::serialize_offsets(SerializeClosure* f) {
   THREAD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -1860,7 +1860,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_ThreadGroup::serialize(SerializeClosure* f) {
+void java_lang_ThreadGroup::serialize_offsets(SerializeClosure* f) {
   THREADGROUP_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -1878,7 +1878,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_Throwable::serialize(SerializeClosure* f) {
+void java_lang_Throwable::serialize_offsets(SerializeClosure* f) {
   THROWABLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -2005,7 +2005,7 @@
  public:
 
   // constructor for new backtrace
-  BacktraceBuilder(TRAPS): _methods(NULL), _bcis(NULL), _head(NULL), _mirrors(NULL), _names(NULL) {
+  BacktraceBuilder(TRAPS): _head(NULL), _methods(NULL), _bcis(NULL), _mirrors(NULL), _names(NULL) {
     expand(CHECK);
     _backtrace = Handle(THREAD, _head);
     _index = 0;
@@ -2102,7 +2102,7 @@
   Symbol* _name;
   Handle _mirror;
   BacktraceElement(Handle mirror, int mid, int version, int bci, Symbol* name) :
-                   _mirror(mirror), _method_id(mid), _version(version), _bci(bci), _name(name) {}
+                   _method_id(mid), _bci(bci), _version(version), _name(name), _mirror(mirror) {}
 };
 
 class BacktraceIterator : public StackObj {
@@ -2654,7 +2654,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_StackFrameInfo::serialize(SerializeClosure* f) {
+void java_lang_StackFrameInfo::serialize_offsets(SerializeClosure* f) {
   STACKFRAMEINFO_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
   STACKFRAMEINFO_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
 }
@@ -2672,7 +2672,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_LiveStackFrameInfo::serialize(SerializeClosure* f) {
+void java_lang_LiveStackFrameInfo::serialize_offsets(SerializeClosure* f) {
   LIVESTACKFRAMEINFO_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -2686,7 +2686,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_reflect_AccessibleObject::serialize(SerializeClosure* f) {
+void java_lang_reflect_AccessibleObject::serialize_offsets(SerializeClosure* f) {
   ACCESSIBLEOBJECT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -2727,7 +2727,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_reflect_Method::serialize(SerializeClosure* f) {
+void java_lang_reflect_Method::serialize_offsets(SerializeClosure* f) {
   METHOD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -2914,7 +2914,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_reflect_Constructor::serialize(SerializeClosure* f) {
+void java_lang_reflect_Constructor::serialize_offsets(SerializeClosure* f) {
   CONSTRUCTOR_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3063,7 +3063,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_reflect_Field::serialize(SerializeClosure* f) {
+void java_lang_reflect_Field::serialize_offsets(SerializeClosure* f) {
   FIELD_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3186,7 +3186,7 @@
 }
 
 #if INCLUDE_CDS
-void reflect_ConstantPool::serialize(SerializeClosure* f) {
+void reflect_ConstantPool::serialize_offsets(SerializeClosure* f) {
   CONSTANTPOOL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3203,7 +3203,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_reflect_Parameter::serialize(SerializeClosure* f) {
+void java_lang_reflect_Parameter::serialize_offsets(SerializeClosure* f) {
   PARAMETER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3281,7 +3281,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_Module::serialize(SerializeClosure* f) {
+void java_lang_Module::serialize_offsets(SerializeClosure* f) {
   MODULE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
   MODULE_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
 }
@@ -3371,7 +3371,7 @@
 }
 
 #if INCLUDE_CDS
-void reflect_UnsafeStaticFieldAccessorImpl::serialize(SerializeClosure* f) {
+void reflect_UnsafeStaticFieldAccessorImpl::serialize_offsets(SerializeClosure* f) {
   UNSAFESTATICFIELDACCESSORIMPL_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3543,7 +3543,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_ref_SoftReference::serialize(SerializeClosure* f) {
+void java_lang_ref_SoftReference::serialize_offsets(SerializeClosure* f) {
   SOFTREFERENCE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3584,7 +3584,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_DirectMethodHandle::serialize(SerializeClosure* f) {
+void java_lang_invoke_DirectMethodHandle::serialize_offsets(SerializeClosure* f) {
   DIRECTMETHODHANDLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3616,7 +3616,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_MethodHandle::serialize(SerializeClosure* f) {
+void java_lang_invoke_MethodHandle::serialize_offsets(SerializeClosure* f) {
   METHODHANDLE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3635,7 +3635,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_MemberName::serialize(SerializeClosure* f) {
+void java_lang_invoke_MemberName::serialize_offsets(SerializeClosure* f) {
   MEMBERNAME_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
   MEMBERNAME_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
 }
@@ -3648,7 +3648,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_ResolvedMethodName::serialize(SerializeClosure* f) {
+void java_lang_invoke_ResolvedMethodName::serialize_offsets(SerializeClosure* f) {
   RESOLVEDMETHOD_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3663,7 +3663,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_LambdaForm::serialize(SerializeClosure* f) {
+void java_lang_invoke_LambdaForm::serialize_offsets(SerializeClosure* f) {
   LAMBDAFORM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3815,7 +3815,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_MethodType::serialize(SerializeClosure* f) {
+void java_lang_invoke_MethodType::serialize_offsets(SerializeClosure* f) {
   METHODTYPE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3909,7 +3909,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_CallSite::serialize(SerializeClosure* f) {
+void java_lang_invoke_CallSite::serialize_offsets(SerializeClosure* f) {
   CALLSITE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3931,7 +3931,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_invoke_MethodHandleNatives_CallSiteContext::serialize(SerializeClosure* f) {
+void java_lang_invoke_MethodHandleNatives_CallSiteContext::serialize_offsets(SerializeClosure* f) {
   CALLSITECONTEXT_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -3963,7 +3963,7 @@
 }
 
 #if INCLUDE_CDS
-void java_security_AccessControlContext::serialize(SerializeClosure* f) {
+void java_security_AccessControlContext::serialize_offsets(SerializeClosure* f) {
   ACCESSCONTROLCONTEXT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -4029,7 +4029,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_ClassLoader::serialize(SerializeClosure* f) {
+void java_lang_ClassLoader::serialize_offsets(SerializeClosure* f) {
   CLASSLOADER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
   CLASSLOADER_INJECTED_FIELDS(INJECTED_FIELD_SERIALIZE_OFFSET);
 }
@@ -4143,7 +4143,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_System::serialize(SerializeClosure* f) {
+void java_lang_System::serialize_offsets(SerializeClosure* f) {
    SYSTEM_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -4250,6 +4250,12 @@
 int jdk_internal_module_ArchivedModuleGraph::_archivedSystemModules_offset;
 int jdk_internal_module_ArchivedModuleGraph::_archivedModuleFinder_offset;
 int jdk_internal_module_ArchivedModuleGraph::_archivedMainModule_offset;
+int jdk_internal_module_ArchivedModuleGraph::_archivedConfiguration_offset;
+int java_lang_Integer_IntegerCache::_archivedCache_offset;
+int java_lang_module_Configuration::_EMPTY_CONFIGURATION_offset;
+int java_util_ImmutableCollections_ListN::_EMPTY_LIST_offset;
+int java_util_ImmutableCollections_SetN::_EMPTY_SET_offset;
+int java_util_ImmutableCollections_MapN::_EMPTY_MAP_offset;
 
 #define STACKTRACEELEMENT_FIELDS_DO(macro) \
   macro(declaringClassObject_offset,  k, "declaringClassObject", class_signature, false); \
@@ -4268,7 +4274,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_StackTraceElement::serialize(SerializeClosure* f) {
+void java_lang_StackTraceElement::serialize_offsets(SerializeClosure* f) {
   STACKTRACEELEMENT_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -4343,7 +4349,7 @@
 }
 
 #if INCLUDE_CDS
-void java_lang_AssertionStatusDirectives::serialize(SerializeClosure* f) {
+void java_lang_AssertionStatusDirectives::serialize_offsets(SerializeClosure* f) {
   ASSERTIONSTATUSDIRECTIVES_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -4384,7 +4390,7 @@
 }
 
 #if INCLUDE_CDS
-void java_nio_Buffer::serialize(SerializeClosure* f) {
+void java_nio_Buffer::serialize_offsets(SerializeClosure* f) {
   BUFFER_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -4403,7 +4409,7 @@
 }
 
 #if INCLUDE_CDS
-void java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(SerializeClosure* f) {
+void java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize_offsets(SerializeClosure* f) {
   AOS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
@@ -4412,20 +4418,96 @@
   return (hardcoded_offset * heapOopSize) + instanceOopDesc::base_offset_in_bytes();
 }
 
-#define MODULEBOOTSTRAP_FIELDS_DO(macro) \
+#define INTEGERCACHE_FIELDS_DO(macro) \
+  macro(_archivedCache_offset,  k, "archivedCache",  java_lang_Integer_array_signature, true)
+
+void java_lang_Integer_IntegerCache::compute_offsets() {
+  InstanceKlass* k = SystemDictionary::Integer_IntegerCache_klass();
+  assert(k != NULL, "must be loaded");
+  INTEGERCACHE_FIELDS_DO(FIELD_COMPUTE_OFFSET);
+}
+
+#if INCLUDE_CDS
+void java_lang_Integer_IntegerCache::serialize_offsets(SerializeClosure* f) {
+  INTEGERCACHE_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
+}
+#endif
+
+#define ARCHIVEDMODULEGRAPH_FIELDS_DO(macro) \
   macro(_archivedSystemModules_offset,      k, "archivedSystemModules", systemModules_signature, true); \
   macro(_archivedModuleFinder_offset,       k, "archivedModuleFinder",  moduleFinder_signature,  true); \
-  macro(_archivedMainModule_offset,         k, "archivedMainModule",    string_signature,        true)
+  macro(_archivedMainModule_offset,         k, "archivedMainModule",    string_signature,        true); \
+  macro(_archivedConfiguration_offset,      k, "archivedConfiguration", configuration_signature, true)
 
 void jdk_internal_module_ArchivedModuleGraph::compute_offsets() {
   InstanceKlass* k = SystemDictionary::ArchivedModuleGraph_klass();
   assert(k != NULL, "must be loaded");
-  MODULEBOOTSTRAP_FIELDS_DO(FIELD_COMPUTE_OFFSET);
+  ARCHIVEDMODULEGRAPH_FIELDS_DO(FIELD_COMPUTE_OFFSET);
 }
 
 #if INCLUDE_CDS
-void jdk_internal_module_ArchivedModuleGraph::serialize(SerializeClosure* f) {
-  MODULEBOOTSTRAP_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
+void jdk_internal_module_ArchivedModuleGraph::serialize_offsets(SerializeClosure* f) {
+  ARCHIVEDMODULEGRAPH_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
+}
+#endif
+
+#define CONFIGURATION_FIELDS_DO(macro) \
+  macro(_EMPTY_CONFIGURATION_offset, k, "EMPTY_CONFIGURATION", configuration_signature, true)
+
+void java_lang_module_Configuration::compute_offsets() {
+  InstanceKlass* k = SystemDictionary::Configuration_klass();
+  assert(k != NULL, "must be loaded");
+  CONFIGURATION_FIELDS_DO(FIELD_COMPUTE_OFFSET);
+}
+
+#if INCLUDE_CDS
+void java_lang_module_Configuration::serialize_offsets(SerializeClosure* f) {
+  CONFIGURATION_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
+}
+#endif
+
+#define LISTN_FIELDS_DO(macro) \
+  macro(_EMPTY_LIST_offset, k, "EMPTY_LIST", list_signature, true)
+
+void java_util_ImmutableCollections_ListN::compute_offsets() {
+  InstanceKlass* k = SystemDictionary::ImmutableCollections_ListN_klass();
+  assert(k != NULL, "must be loaded");
+  LISTN_FIELDS_DO(FIELD_COMPUTE_OFFSET);
+}
+
+#if INCLUDE_CDS
+void java_util_ImmutableCollections_ListN::serialize_offsets(SerializeClosure* f) {
+  LISTN_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
+}
+#endif
+
+#define SETN_FIELDS_DO(macro) \
+  macro(_EMPTY_SET_offset, k, "EMPTY_SET", set_signature, true)
+
+void java_util_ImmutableCollections_SetN::compute_offsets() {
+  InstanceKlass* k = SystemDictionary::ImmutableCollections_SetN_klass();
+  assert(k != NULL, "must be loaded");
+  SETN_FIELDS_DO(FIELD_COMPUTE_OFFSET);
+}
+
+#if INCLUDE_CDS
+void java_util_ImmutableCollections_SetN::serialize_offsets(SerializeClosure* f) {
+  SETN_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
+}
+#endif
+
+#define MAPN_FIELDS_DO(macro) \
+  macro(_EMPTY_MAP_offset, k, "EMPTY_MAP", map_signature, true)
+
+void java_util_ImmutableCollections_MapN::compute_offsets() {
+  InstanceKlass* k = SystemDictionary::ImmutableCollections_MapN_klass();
+  assert(k != NULL, "must be loaded");
+  MAPN_FIELDS_DO(FIELD_COMPUTE_OFFSET);
+}
+
+#if INCLUDE_CDS
+void java_util_ImmutableCollections_MapN::serialize_offsets(SerializeClosure* f) {
+  MAPN_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
 }
 #endif
 
@@ -4445,6 +4527,7 @@
   java_lang_ref_Reference::discovered_offset  = member_offset(java_lang_ref_Reference::hc_discovered_offset);
 }
 
+#define DO_COMPUTE_OFFSETS(k) k::compute_offsets();
 
 // Compute non-hard-coded field offsets of all the classes in this file
 void JavaClasses::compute_offsets() {
@@ -4452,47 +4535,24 @@
     return; // field offsets are loaded from archive
   }
 
-  // java_lang_Class::compute_offsets was called earlier in bootstrap
-  java_lang_System::compute_offsets();
-  java_lang_ClassLoader::compute_offsets();
-  java_lang_Throwable::compute_offsets();
-  java_lang_Thread::compute_offsets();
-  java_lang_ThreadGroup::compute_offsets();
-  java_lang_AssertionStatusDirectives::compute_offsets();
-  java_lang_ref_SoftReference::compute_offsets();
-  java_lang_invoke_MethodHandle::compute_offsets();
-  java_lang_invoke_DirectMethodHandle::compute_offsets();
-  java_lang_invoke_MemberName::compute_offsets();
-  java_lang_invoke_ResolvedMethodName::compute_offsets();
-  java_lang_invoke_LambdaForm::compute_offsets();
-  java_lang_invoke_MethodType::compute_offsets();
-  java_lang_invoke_CallSite::compute_offsets();
-  java_lang_invoke_MethodHandleNatives_CallSiteContext::compute_offsets();
-  java_security_AccessControlContext::compute_offsets();
-  // Initialize reflection classes. The layouts of these classes
-  // changed with the new reflection implementation in JDK 1.4, and
-  // since the Universe doesn't know what JDK version it is until this
-  // point we defer computation of these offsets until now.
-  java_lang_reflect_AccessibleObject::compute_offsets();
-  java_lang_reflect_Method::compute_offsets();
-  java_lang_reflect_Constructor::compute_offsets();
-  java_lang_reflect_Field::compute_offsets();
-  java_nio_Buffer::compute_offsets();
-  reflect_ConstantPool::compute_offsets();
-  reflect_UnsafeStaticFieldAccessorImpl::compute_offsets();
-  java_lang_reflect_Parameter::compute_offsets();
-  java_lang_Module::compute_offsets();
-  java_lang_StackTraceElement::compute_offsets();
-  java_lang_StackFrameInfo::compute_offsets();
-  java_lang_LiveStackFrameInfo::compute_offsets();
-  java_util_concurrent_locks_AbstractOwnableSynchronizer::compute_offsets();
-
-  jdk_internal_module_ArchivedModuleGraph::compute_offsets();
+  // We have already called the compute_offsets() of the
+  // BASIC_JAVA_CLASSES_DO_PART1 classes (java_lang_String and java_lang_Class)
+  // earlier inside SystemDictionary::resolve_preloaded_classes()
+  BASIC_JAVA_CLASSES_DO_PART2(DO_COMPUTE_OFFSETS);
 
   // generated interpreter code wants to know about the offsets we just computed:
   AbstractAssembler::update_delayed_values();
 }
 
+#if INCLUDE_CDS
+#define DO_SERIALIZE_OFFSETS(k) k::serialize_offsets(soc);
+
+void JavaClasses::serialize_offsets(SerializeClosure* soc) {
+  BASIC_JAVA_CLASSES_DO(DO_SERIALIZE_OFFSETS);
+}
+#endif
+
+
 #ifndef PRODUCT
 
 // These functions exist to assert the validity of hard-coded field offsets to guard
--- a/src/hotspot/share/classfile/javaClasses.hpp	Thu Aug 02 14:44:58 2018 -0700
+++ b/src/hotspot/share/classfile/javaClasses.hpp	Tue Aug 21 01:21:58 2018 -0700
@@ -47,6 +47,52 @@
 // correspondingly. The names in the enums must be identical to the actual field
 // names in order for the verification code to work.
 
+#define BASIC_JAVA_CLASSES_DO_PART1(f) \
+  f(java_lang_Class) \
+  f(java_lang_String) \
+  //end
+
+#define BASIC_JAVA_CLASSES_DO_PART2(f) \
+  f(java_lang_System) \
+  f(java_lang_ClassLoader) \
+  f(java_lang_Throwable) \
+  f(java_lang_Thread) \
+  f(java_lang_ThreadGroup) \
+  f(java_lang_AssertionStatusDirectives) \
+  f(java_lang_ref_SoftReference) \
+  f(java_lang_invoke_MethodHandle) \
+  f(java_lang_invoke_DirectMethodHandle) \
+  f(java_lang_invoke_MemberName) \
+  f(java_lang_invoke_ResolvedMethodName) \
+  f(java_lang_invoke_LambdaForm) \
+  f(java_lang_invoke_MethodType) \
+  f(java_lang_invoke_CallSite) \
+  f(java_lang_invoke_MethodHandleNatives_CallSiteContext) \
+  f(java_security_AccessControlContext) \
+  f(java_lang_reflect_AccessibleObject) \
+  f(java_lang_reflect_Method) \
+  f(java_lang_reflect_Constructor) \
+  f(java_lang_reflect_Field) \
+  f(java_nio_Buffer) \
+  f(reflect_ConstantPool) \
+  f(reflect_UnsafeStaticFieldAccessorImpl) \
+  f(java_lang_reflect_Parameter) \
+  f(java_lang_Module) \
+  f(java_lang_StackTraceElement) \
+  f(java_lang_StackFrameInfo) \
+  f(java_lang_LiveStackFrameInfo) \
+  f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
+  f(jdk_internal_module_ArchivedModuleGraph) \
+  f(java_lang_Integer_IntegerCache) \
+  f(java_lang_module_Configuration) \
+  f(java_util_ImmutableCollections_ListN) \
+  f(java_util_ImmutableCollections_MapN) \
+  f(java_util_ImmutableCollections_SetN) \
+  //end
+
+#define BASIC_JAVA_CLASSES_DO(f) \
+        BASIC_JAVA_CLASSES_DO_PART1(f) \
+        BASIC_JAVA_CLASSES_DO_PART2(f)
 
 // Interface to java.lang.String objects
 
@@ -71,7 +117,7 @@
   };
 
   static void compute_offsets();
-  static void serialize(SerializeClosure* f) NOT_CDS_RETURN;
+  static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 
   // Instance creation
   static Handle create_from_unicode(jchar* unicode, int len, TRAPS);
@@ -224,7 +270,7 @@
   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
 
   // Archiving
-  static void serialize(SerializeClosure* f) NOT_CDS_RETURN;
+  static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
   static void archive_basic_type_mirrors(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
   static oop  archive_mirror(Klass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(NULL);
   static oop  process_archived_mirror(Klass* k, oop mirror, oop archived_mirror, Thread *THREAD)
@@ -317,7 +363,7 @@
   static void compute_offsets();
 
  public:
-  static void serialize(SerializeClosure* f) NOT_CDS_RETURN;
+  static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 
   // Instance creation
   static oop create();
@@ -419,7 +465,7 @@
   static void compute_offsets();
 
  public:
-  static void serialize(SerializeClosure* f) NOT_CDS_RETURN;
+  static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 
   // parent ThreadGroup
   static oop  parent(o