changeset 27359:5b24bff4ad46

Merge.
author Doug Simon <doug.simon@oracle.com>
date Thu, 04 Feb 2016 09:20:28 +0100
parents 1ef9c76b62af e136c14f3280
children 842f795f356d
files .hgtags .mx.jvmci/mx_jvmci.py .mx.jvmci/suite.py src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp src/cpu/aarch64/vm/interpreter_aarch64.cpp src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp src/cpu/ppc/vm/abstractInterpreter_ppc.cpp src/cpu/ppc/vm/interpreter_ppc.cpp src/cpu/ppc/vm/sharedRuntime_ppc.cpp src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp src/cpu/ppc/vm/templateInterpreter_ppc.cpp src/cpu/ppc/vm/templateInterpreter_ppc.hpp src/cpu/sparc/vm/abstractInterpreter_sparc.cpp src/cpu/sparc/vm/interpreter_sparc.cpp src/cpu/sparc/vm/sharedRuntime_sparc.cpp src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp src/cpu/sparc/vm/templateInterpreter_sparc.cpp src/cpu/sparc/vm/templateTable_sparc.cpp src/cpu/sparc/vm/vm_version_sparc.cpp src/cpu/x86/vm/abstractInterpreter_x86.cpp src/cpu/x86/vm/interpreterGenerator_x86.cpp src/cpu/x86/vm/interpreter_x86_32.cpp src/cpu/x86/vm/interpreter_x86_64.cpp src/cpu/x86/vm/sharedRuntime_x86_32.cpp src/cpu/x86/vm/sharedRuntime_x86_64.cpp src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp src/cpu/x86/vm/templateInterpreter_x86.cpp src/cpu/x86/vm/vm_version_x86.cpp src/cpu/zero/vm/cppInterpreterGenerator_zero.cpp src/cpu/zero/vm/cppInterpreter_zero.cpp src/cpu/zero/vm/interp_masm_zero.cpp src/cpu/zero/vm/interpreter_zero.cpp src/cpu/zero/vm/register_definitions_zero.cpp src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ConstantReflectionProvider.java src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java src/os/aix/vm/os_aix.cpp src/os/aix/vm/os_aix.inline.hpp src/os/bsd/vm/os_bsd.cpp src/os/bsd/vm/os_bsd.inline.hpp src/os/linux/vm/os_linux.inline.hpp src/os/solaris/vm/os_solaris.cpp src/os/solaris/vm/os_solaris.inline.hpp src/os/windows/vm/os_windows.cpp src/os/windows/vm/os_windows.inline.hpp src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp src/share/vm/asm/codeBuffer.cpp src/share/vm/c1/c1_Runtime1.cpp src/share/vm/ci/ciEnv.cpp src/share/vm/ci/ciField.cpp src/share/vm/ci/ciTypeFlow.cpp src/share/vm/classfile/altHashing.cpp src/share/vm/classfile/classFileParser.cpp src/share/vm/classfile/classLoader.cpp src/share/vm/classfile/classLoaderData.cpp src/share/vm/classfile/classLoaderData.hpp src/share/vm/classfile/classLoaderData.inline.hpp src/share/vm/classfile/dictionary.cpp src/share/vm/classfile/dictionary.hpp src/share/vm/classfile/javaClasses.cpp src/share/vm/classfile/javaClasses.hpp src/share/vm/classfile/symbolTable.cpp src/share/vm/classfile/symbolTable.hpp src/share/vm/classfile/systemDictionary.cpp src/share/vm/classfile/systemDictionary.hpp src/share/vm/classfile/verifier.cpp src/share/vm/classfile/vmSymbols.hpp src/share/vm/code/codeCache.cpp src/share/vm/code/dependencies.cpp src/share/vm/code/dependencies.hpp src/share/vm/code/nmethod.cpp src/share/vm/compiler/compileBroker.cpp src/share/vm/gc/cms/cmsOopClosures.hpp src/share/vm/gc/cms/compactibleFreeListSpace.cpp src/share/vm/gc/cms/compactibleFreeListSpace.hpp src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp src/share/vm/gc/cms/concurrentMarkSweepGeneration.inline.hpp src/share/vm/gc/cms/parNewGeneration.cpp src/share/vm/gc/cms/parNewGeneration.hpp src/share/vm/gc/cms/vmCMSOperations.cpp src/share/vm/gc/g1/dirtyCardQueue.cpp src/share/vm/gc/g1/dirtyCardQueue.hpp src/share/vm/gc/g1/g1AllocRegion.cpp src/share/vm/gc/g1/g1BlockOffsetTable.cpp src/share/vm/gc/g1/g1BlockOffsetTable.hpp src/share/vm/gc/g1/g1BlockOffsetTable.inline.hpp src/share/vm/gc/g1/g1CollectedHeap.cpp src/share/vm/gc/g1/g1CollectedHeap.hpp src/share/vm/gc/g1/g1CollectedHeap_ext.cpp src/share/vm/gc/g1/g1CollectorPolicy.hpp src/share/vm/gc/g1/g1ParScanThreadState.hpp src/share/vm/gc/g1/g1RemSet.cpp src/share/vm/gc/g1/g1RemSet.hpp src/share/vm/gc/g1/g1StringDedupQueue.cpp src/share/vm/gc/g1/heapRegion.cpp src/share/vm/gc/g1/heapRegion.hpp src/share/vm/gc/g1/heapRegion.inline.hpp src/share/vm/gc/g1/heapRegionRemSet.cpp src/share/vm/gc/g1/heapRegionRemSet.hpp src/share/vm/gc/g1/heapRegionSet.cpp src/share/vm/gc/g1/vmStructs_g1.hpp src/share/vm/gc/parallel/gcTaskThread.cpp src/share/vm/gc/parallel/parallelScavengeHeap.cpp src/share/vm/gc/parallel/psMarkSweep.cpp src/share/vm/gc/parallel/psOldGen.cpp src/share/vm/gc/parallel/psParallelCompact.cpp src/share/vm/gc/parallel/psScavenge.cpp src/share/vm/gc/serial/defNewGeneration.cpp src/share/vm/gc/serial/defNewGeneration.hpp src/share/vm/gc/serial/markSweep.cpp src/share/vm/gc/shared/ageTable.cpp src/share/vm/gc/shared/blockOffsetTable.cpp src/share/vm/gc/shared/blockOffsetTable.hpp src/share/vm/gc/shared/collectedHeap.cpp src/share/vm/gc/shared/collectorPolicy.cpp src/share/vm/gc/shared/gcLocker.cpp src/share/vm/gc/shared/gcLocker.hpp src/share/vm/gc/shared/genCollectedHeap.cpp src/share/vm/gc/shared/referenceProcessor.cpp src/share/vm/gc/shared/referenceProcessor.hpp src/share/vm/gc/shared/space.cpp src/share/vm/gc/shared/space.hpp src/share/vm/gc/shared/specialized_oop_closures.hpp src/share/vm/gc/shared/vmGCOperations.cpp src/share/vm/gc/shared/workgroup.cpp src/share/vm/interpreter/abstractInterpreter.cpp src/share/vm/interpreter/abstractInterpreter.hpp src/share/vm/interpreter/bytecodeInterpreter.cpp src/share/vm/interpreter/interpreter.cpp src/share/vm/interpreter/interpreterRuntime.cpp src/share/vm/interpreter/linkResolver.cpp src/share/vm/interpreter/linkResolver.hpp src/share/vm/interpreter/rewriter.cpp src/share/vm/interpreter/templateInterpreter.cpp src/share/vm/interpreter/templateInterpreter.hpp src/share/vm/interpreter/templateInterpreterGenerator.hpp src/share/vm/jvmci/jvmciCompilerToVM.cpp src/share/vm/jvmci/jvmciJavaClasses.hpp src/share/vm/jvmci/jvmciRuntime.cpp src/share/vm/memory/referenceType.hpp src/share/vm/memory/universe.cpp src/share/vm/memory/universe.hpp src/share/vm/oops/arrayOop.hpp src/share/vm/oops/constantPool.cpp src/share/vm/oops/constantPool.hpp src/share/vm/oops/instanceKlass.cpp src/share/vm/oops/klassVtable.cpp src/share/vm/oops/method.cpp src/share/vm/oops/method.hpp src/share/vm/oops/methodData.cpp src/share/vm/oops/objArrayOop.hpp src/share/vm/oops/oop.hpp src/share/vm/oops/oop.inline.hpp src/share/vm/oops/typeArrayKlass.cpp src/share/vm/oops/typeArrayOop.cpp src/share/vm/oops/typeArrayOop.hpp src/share/vm/opto/cfgnode.cpp src/share/vm/opto/loopTransform.cpp src/share/vm/opto/loopnode.cpp src/share/vm/opto/loopnode.hpp src/share/vm/opto/macro.cpp src/share/vm/opto/runtime.cpp src/share/vm/opto/subnode.cpp src/share/vm/prims/jni.cpp src/share/vm/prims/jvmtiEnv.cpp src/share/vm/prims/jvmtiEnvBase.cpp src/share/vm/prims/jvmtiExport.cpp src/share/vm/prims/jvmtiRedefineClasses.cpp src/share/vm/prims/jvmtiTagMap.cpp src/share/vm/prims/methodHandles.cpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/arguments.hpp src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp src/share/vm/runtime/deoptimization.cpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/interfaceSupport.hpp src/share/vm/runtime/javaCalls.cpp src/share/vm/runtime/objectMonitor.cpp src/share/vm/runtime/os.hpp src/share/vm/runtime/safepoint.cpp src/share/vm/runtime/sharedRuntime.cpp src/share/vm/runtime/synchronizer.cpp src/share/vm/runtime/thread.cpp src/share/vm/runtime/thread.hpp src/share/vm/runtime/vmStructs.cpp src/share/vm/runtime/vm_version.cpp src/share/vm/runtime/vm_version.hpp src/share/vm/services/heapDumper.cpp src/share/vm/services/memoryService.cpp src/share/vm/services/threadService.cpp src/share/vm/services/virtualMemoryTracker.cpp src/share/vm/trace/traceEventClasses.xsl src/share/vm/trace/traceStream.hpp src/share/vm/utilities/exceptions.cpp src/share/vm/utilities/exceptions.hpp src/share/vm/utilities/globalDefinitions.cpp src/share/vm/utilities/globalDefinitions.hpp src/share/vm/utilities/globalDefinitions_gcc.hpp src/share/vm/utilities/hashtable.cpp src/share/vm/utilities/quickSort.cpp src/share/vm/utilities/vmError.cpp test/Makefile test/TEST.groups test/gc/6581734/Test6581734.java test/gc/6845368/bigobj.java test/gc/7072527/TestFullGCCount.java
diffstat 372 files changed, 78619 insertions(+), 72894 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Feb 03 12:09:12 2016 +0100
+++ b/.hgtags	Thu Feb 04 09:20:28 2016 +0100
@@ -504,3 +504,5 @@
 f008e8cc10d5b3212fb22d58c96fa01d38654f19 jdk-9+99
 bdb0acafc63c42e84d9d8195bf2e2b25ee9c3306 jdk-9+100
 9f45d3d57d6948cf526fbc2e2891a9a74ac6941a jdk-9+101
+d5239fc1b69749ae50793c61b899fcdacf3df857 jdk-9+102
+c5f55130b1b69510d9a6f4a3105b58e21cd7ffe1 jdk-9+103
--- a/make/lib/Lib-jdk.hotspot.agent.gmk	Wed Feb 03 12:09:12 2016 +0100
+++ b/make/lib/Lib-jdk.hotspot.agent.gmk	Thu Feb 04 09:20:28 2016 +0100
@@ -110,7 +110,6 @@
     LIBS := $(SA_LIBS), \
     MAPFILE := $(SA_MAPFILE), \
     OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libsa, \
-    DEBUG_SYMBOLS := true, \
     STRIP_SYMBOLS := true, \
 ))
 
--- a/make/solaris/makefiles/sparcWorks.make	Wed Feb 03 12:09:12 2016 +0100
+++ b/make/solaris/makefiles/sparcWorks.make	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -48,9 +48,9 @@
 $(shell $(CC) -V 2>&1 | sed -n 's/^.*[ ,\t]C[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
 
 # Pick which compiler is validated
-# Validated compiler for JDK9 is SS12.3 (5.12)
-VALIDATED_COMPILER_REVS   := 5.12
-VALIDATED_CC_COMPILER_REVS := 5.12
+# Validated compiler for JDK9 is SS12.4 (5.13)
+VALIDATED_COMPILER_REVS   := 5.13
+VALIDATED_CC_COMPILER_REVS := 5.13
 
 # Warning messages about not using the above validated versions
 ENFORCE_COMPILER_REV${ENFORCE_COMPILER_REV} := $(strip ${VALIDATED_COMPILER_REVS})
--- a/src/cpu/aarch64/vm/aarch64.ad	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/aarch64/vm/aarch64.ad	Thu Feb 04 09:20:28 2016 +0100
@@ -577,7 +577,7 @@
     R26
  /* R27, */                     // heapbase
  /* R28, */                     // thread
-    R29,                        // fp
+ /* R29, */                     // fp
  /* R30, */                     // lr
  /* R31 */                      // sp
 );
@@ -646,7 +646,7 @@
     R26, R26_H,
  /* R27, R27_H, */              // heapbase
  /* R28, R28_H, */              // thread
-    R29, R29_H,                 // fp
+ /* R29, R29_H, */              // fp
  /* R30, R30_H, */              // lr
  /* R31, R31_H */               // sp
 );
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "interpreter/interpreter.hpp"
+#include "oops/constMethod.hpp"
+#include "oops/method.hpp"
+#include "runtime/frame.inline.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/macros.hpp"
+
+
+int AbstractInterpreter::BasicType_as_index(BasicType type) {
+  int i = 0;
+  switch (type) {
+    case T_BOOLEAN: i = 0; break;
+    case T_CHAR   : i = 1; break;
+    case T_BYTE   : i = 2; break;
+    case T_SHORT  : i = 3; break;
+    case T_INT    : i = 4; break;
+    case T_LONG   : i = 5; break;
+    case T_VOID   : i = 6; break;
+    case T_FLOAT  : i = 7; break;
+    case T_DOUBLE : i = 8; break;
+    case T_OBJECT : i = 9; break;
+    case T_ARRAY  : i = 9; break;
+    default       : ShouldNotReachHere();
+  }
+  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
+         "index out of bounds");
+  return i;
+}
+
+// These should never be compiled since the interpreter will prefer
+// the compiled version to the intrinsic version.
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  switch (method_kind(m)) {
+    case Interpreter::java_lang_math_sin     : // fall thru
+    case Interpreter::java_lang_math_cos     : // fall thru
+    case Interpreter::java_lang_math_tan     : // fall thru
+    case Interpreter::java_lang_math_abs     : // fall thru
+    case Interpreter::java_lang_math_log     : // fall thru
+    case Interpreter::java_lang_math_log10   : // fall thru
+    case Interpreter::java_lang_math_sqrt    : // fall thru
+    case Interpreter::java_lang_math_pow     : // fall thru
+    case Interpreter::java_lang_math_exp     :
+      return false;
+    default:
+      return true;
+  }
+}
+
+// How much stack a method activation needs in words.
+int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
+  const int entry_size = frame::interpreter_frame_monitor_size();
+
+  // total overhead size: entry_size + (saved rfp thru expr stack
+  // bottom).  be sure to change this if you add/subtract anything
+  // to/from the overhead area
+  const int overhead_size =
+    -(frame::interpreter_frame_initial_sp_offset) + entry_size;
+
+  const int stub_code = frame::entry_frame_after_call_words;
+  const int method_stack = (method->max_locals() + method->max_stack()) *
+                           Interpreter::stackElementWords;
+  return (overhead_size + method_stack + stub_code);
+}
+
+// asm based interpreter deoptimization helpers
+int AbstractInterpreter::size_activation(int max_stack,
+                                         int temps,
+                                         int extra_args,
+                                         int monitors,
+                                         int callee_params,
+                                         int callee_locals,
+                                         bool is_top_frame) {
+  // Note: This calculation must exactly parallel the frame setup
+  // in TemplateInterpreterGenerator::generate_method_entry.
+
+  // fixed size of an interpreter frame:
+  int overhead = frame::sender_sp_offset -
+                 frame::interpreter_frame_initial_sp_offset;
+  // Our locals were accounted for by the caller (or last_frame_adjust
+  // on the transistion) Since the callee parameters already account
+  // for the callee's params we only need to account for the extra
+  // locals.
+  int size = overhead +
+         (callee_locals - callee_params)*Interpreter::stackElementWords +
+         monitors * frame::interpreter_frame_monitor_size() +
+         temps* Interpreter::stackElementWords + extra_args;
+
+  // On AArch64 we always keep the stack pointer 16-aligned, so we
+  // must round up here.
+  size = round_to(size, 2);
+
+  return size;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+                                            int tempcount,
+                                            int popframe_extra_args,
+                                            int moncount,
+                                            int caller_actual_parameters,
+                                            int callee_param_count,
+                                            int callee_locals,
+                                            frame* caller,
+                                            frame* interpreter_frame,
+                                            bool is_top_frame,
+                                            bool is_bottom_frame) {
+  // The frame interpreter_frame is guaranteed to be the right size,
+  // as determined by a previous call to the size_activation() method.
+  // It is also guaranteed to be walkable even though it is in a
+  // skeletal state
+
+  int max_locals = method->max_locals() * Interpreter::stackElementWords;
+  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
+    Interpreter::stackElementWords;
+
+#ifdef ASSERT
+  assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
+#endif
+
+  interpreter_frame->interpreter_frame_set_method(method);
+  // NOTE the difference in using sender_sp and
+  // interpreter_frame_sender_sp interpreter_frame_sender_sp is
+  // the original sp of the caller (the unextended_sp) and
+  // sender_sp is fp+8/16 (32bit/64bit) XXX
+  intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
+
+#ifdef ASSERT
+  if (caller->is_interpreted_frame()) {
+    assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
+  }
+#endif
+
+  interpreter_frame->interpreter_frame_set_locals(locals);
+  BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
+  BasicObjectLock* monbot = montop - moncount;
+  interpreter_frame->interpreter_frame_set_monitor_end(monbot);
+
+  // Set last_sp
+  intptr_t*  esp = (intptr_t*) monbot -
+    tempcount*Interpreter::stackElementWords -
+    popframe_extra_args;
+  interpreter_frame->interpreter_frame_set_last_sp(esp);
+
+  // All frames but the initial (oldest) interpreter frame we fill in have
+  // a value for sender_sp that allows walking the stack but isn't
+  // truly correct. Correct the value here.
+  if (extra_locals != 0 &&
+      interpreter_frame->sender_sp() ==
+      interpreter_frame->interpreter_frame_sender_sp()) {
+    interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
+                                                       extra_locals);
+  }
+  *interpreter_frame->interpreter_frame_cache_addr() =
+    method->constants()->cache();
+}
--- a/src/cpu/aarch64/vm/interpreter_aarch64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,261 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
-#include "interpreter/bytecodeHistogram.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/interp_masm.hpp"
-#include "interpreter/templateInterpreterGenerator.hpp"
-#include "interpreter/templateTable.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "prims/methodHandles.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/timer.hpp"
-#include "runtime/vframeArray.hpp"
-#include "utilities/debug.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-
-#define __ _masm->
-
-
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  address entry = __ pc();
-
-  __ andr(esp, esp, -16);
-  __ mov(c_rarg3, esp);
-  // rmethod
-  // rlocals
-  // c_rarg3: first stack arg - wordSize
-
-  // adjust sp
-  __ sub(sp, c_rarg3, 18 * wordSize);
-  __ str(lr, Address(__ pre(sp, -2 * wordSize)));
-  __ call_VM(noreg,
-             CAST_FROM_FN_PTR(address,
-                              InterpreterRuntime::slow_signature_handler),
-             rmethod, rlocals, c_rarg3);
-
-  // r0: result handler
-
-  // Stack layout:
-  // rsp: return address           <- sp
-  //      1 garbage
-  //      8 integer args (if static first is unused)
-  //      1 float/double identifiers
-  //      8 double args
-  //        stack args              <- esp
-  //        garbage
-  //        expression stack bottom
-  //        bcp (NULL)
-  //        ...
-
-  // Restore LR
-  __ ldr(lr, Address(__ post(sp, 2 * wordSize)));
-
-  // Do FP first so we can use c_rarg3 as temp
-  __ ldrw(c_rarg3, Address(sp, 9 * wordSize)); // float/double identifiers
-
-  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
-    const FloatRegister r = as_FloatRegister(i);
-
-    Label d, done;
-
-    __ tbnz(c_rarg3, i, d);
-    __ ldrs(r, Address(sp, (10 + i) * wordSize));
-    __ b(done);
-    __ bind(d);
-    __ ldrd(r, Address(sp, (10 + i) * wordSize));
-    __ bind(done);
-  }
-
-  // c_rarg0 contains the result from the call of
-  // InterpreterRuntime::slow_signature_handler so we don't touch it
-  // here.  It will be loaded with the JNIEnv* later.
-  __ ldr(c_rarg1, Address(sp, 1 * wordSize));
-  for (int i = c_rarg2->encoding(); i <= c_rarg7->encoding(); i += 2) {
-    Register rm = as_Register(i), rn = as_Register(i+1);
-    __ ldp(rm, rn, Address(sp, i * wordSize));
-  }
-
-  __ add(sp, sp, 18 * wordSize);
-  __ ret(lr);
-
-  return entry;
-}
-
-
-//
-// Various method entries
-//
-
-address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
-  // rmethod: Method*
-  // r13: sender sp
-  // esp: args
-
-  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
-
-  // These don't need a safepoint check because they aren't virtually
-  // callable. We won't enter these intrinsics from compiled code.
-  // If in the future we added an intrinsic which was virtually callable
-  // we'd have to worry about how to safepoint so that this code is used.
-
-  // mathematical functions inlined by compiler
-  // (interpreter must provide identical implementation
-  // in order to avoid monotonicity bugs when switching
-  // from interpreter to compiler in the middle of some
-  // computation)
-  //
-  // stack:
-  //        [ arg ] <-- esp
-  //        [ arg ]
-  // retaddr in lr
-
-  address entry_point = NULL;
-  Register continuation = lr;
-  switch (kind) {
-  case Interpreter::java_lang_math_abs:
-    entry_point = __ pc();
-    __ ldrd(v0, Address(esp));
-    __ fabsd(v0, v0);
-    __ mov(sp, r13); // Restore caller's SP
-    break;
-  case Interpreter::java_lang_math_sqrt:
-    entry_point = __ pc();
-    __ ldrd(v0, Address(esp));
-    __ fsqrtd(v0, v0);
-    __ mov(sp, r13);
-    break;
-  case Interpreter::java_lang_math_sin :
-  case Interpreter::java_lang_math_cos :
-  case Interpreter::java_lang_math_tan :
-  case Interpreter::java_lang_math_log :
-  case Interpreter::java_lang_math_log10 :
-  case Interpreter::java_lang_math_exp :
-    entry_point = __ pc();
-    __ ldrd(v0, Address(esp));
-    __ mov(sp, r13);
-    __ mov(r19, lr);
-    continuation = r19;  // The first callee-saved register
-    generate_transcendental_entry(kind, 1);
-    break;
-  case Interpreter::java_lang_math_pow :
-    entry_point = __ pc();
-    __ mov(r19, lr);
-    continuation = r19;
-    __ ldrd(v0, Address(esp, 2 * Interpreter::stackElementSize));
-    __ ldrd(v1, Address(esp));
-    __ mov(sp, r13);
-    generate_transcendental_entry(kind, 2);
-    break;
-  default:
-    ;
-  }
-  if (entry_point) {
-    __ br(continuation);
-  }
-
-  return entry_point;
-}
-
-  // double trigonometrics and transcendentals
-  // static jdouble dsin(jdouble x);
-  // static jdouble dcos(jdouble x);
-  // static jdouble dtan(jdouble x);
-  // static jdouble dlog(jdouble x);
-  // static jdouble dlog10(jdouble x);
-  // static jdouble dexp(jdouble x);
-  // static jdouble dpow(jdouble x, jdouble y);
-
-void TemplateInterpreterGenerator::generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs) {
-  address fn;
-  switch (kind) {
-  case Interpreter::java_lang_math_sin :
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
-    break;
-  case Interpreter::java_lang_math_cos :
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
-    break;
-  case Interpreter::java_lang_math_tan :
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
-    break;
-  case Interpreter::java_lang_math_log :
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
-    break;
-  case Interpreter::java_lang_math_log10 :
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
-    break;
-  case Interpreter::java_lang_math_exp :
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
-    break;
-  case Interpreter::java_lang_math_pow :
-    fpargs = 2;
-    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
-    break;
-  default:
-    ShouldNotReachHere();
-    fn = NULL;  // unreachable
-  }
-  const int gpargs = 0, rtype = 3;
-  __ mov(rscratch1, fn);
-  __ blrt(rscratch1, gpargs, fpargs, rtype);
-}
-
-// Abstract method entry
-// Attempt to execute abstract method. Throw exception
-address TemplateInterpreterGenerator::generate_abstract_entry(void) {
-  // rmethod: Method*
-  // r13: sender SP
-
-  address entry_point = __ pc();
-
-  // abstract method entry
-
-  //  pop return address, reset last_sp to NULL
-  __ empty_expression_stack();
-  __ restore_bcp();      // bcp must be correct for exception handler   (was destroyed)
-  __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
-
-  // throw exception
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address,
-                             InterpreterRuntime::throw_AbstractMethodError));
-  // the call_VM checks for exception, so we should never return here.
-  __ should_not_reach_here();
-
-  return entry_point;
-}
--- a/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1090,7 +1090,7 @@
 }
 
 
-// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// 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
 // forced.  Save down any oops in registers and describe them in an
 // OopMap.
@@ -1272,14 +1272,14 @@
 // GetPrimtiveArrayCritical and disallow the use of any other JNI
 // functions.  The wrapper is expected to unpack the arguments before
 // passing them to the callee and perform checks before and after the
-// native call to ensure that they GC_locker
+// native call to ensure that they GCLocker
 // lock_critical/unlock_critical semantics are followed.  Some other
 // parts of JNI setup are skipped like the tear down of the JNI handle
 // block and the check for pending exceptions it's impossible for them
 // to be thrown.
 //
 // They are roughly structured like this:
-//    if (GC_locker::needs_gc())
+//    if (GCLocker::needs_gc())
 //      SharedRuntime::block_for_jni_critical();
 //    tranistion to thread_in_native
 //    unpack arrray arguments and call native entry point
--- a/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -962,7 +962,7 @@
       __ lea(d, Address(d, count, Address::lsl(exact_log2(-step))));
     }
 
-    Label done, tail;
+    Label tail;
 
     __ cmp(count, 16/granularity);
     __ br(Assembler::LO, tail);
@@ -987,7 +987,8 @@
       }
       // rscratch2 is the byte adjustment needed to align s.
       __ cbz(rscratch2, aligned);
-      __ lsr(rscratch2, rscratch2, exact_log2(granularity));
+      int shift = exact_log2(granularity);
+      if (shift)  __ lsr(rscratch2, rscratch2, shift);
       __ sub(count, count, rscratch2);
 
 #if 0
--- a/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -57,6 +57,13 @@
 #include "../../../../../../simulator/simulator.hpp"
 #endif
 
+// Size of interpreter code.  Increase if too small.  Interpreter will
+// fail with a guarantee ("not enough space for interpreter generation");
+// if too small.
+// Run with +PrintInterpreter to get the VM to print out the size.
+// Max size with JVMTI
+int TemplateInterpreter::InterpreterCodeSize = 200 * 1024;
+
 #define __ _masm->
 
 //-----------------------------------------------------------------------------
@@ -65,6 +72,213 @@
 
 //-----------------------------------------------------------------------------
 
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+  address entry = __ pc();
+
+  __ andr(esp, esp, -16);
+  __ mov(c_rarg3, esp);
+  // rmethod
+  // rlocals
+  // c_rarg3: first stack arg - wordSize
+
+  // adjust sp
+  __ sub(sp, c_rarg3, 18 * wordSize);
+  __ str(lr, Address(__ pre(sp, -2 * wordSize)));
+  __ call_VM(noreg,
+             CAST_FROM_FN_PTR(address,
+                              InterpreterRuntime::slow_signature_handler),
+             rmethod, rlocals, c_rarg3);
+
+  // r0: result handler
+
+  // Stack layout:
+  // rsp: return address           <- sp
+  //      1 garbage
+  //      8 integer args (if static first is unused)
+  //      1 float/double identifiers
+  //      8 double args
+  //        stack args              <- esp
+  //        garbage
+  //        expression stack bottom
+  //        bcp (NULL)
+  //        ...
+
+  // Restore LR
+  __ ldr(lr, Address(__ post(sp, 2 * wordSize)));
+
+  // Do FP first so we can use c_rarg3 as temp
+  __ ldrw(c_rarg3, Address(sp, 9 * wordSize)); // float/double identifiers
+
+  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
+    const FloatRegister r = as_FloatRegister(i);
+
+    Label d, done;
+
+    __ tbnz(c_rarg3, i, d);
+    __ ldrs(r, Address(sp, (10 + i) * wordSize));
+    __ b(done);
+    __ bind(d);
+    __ ldrd(r, Address(sp, (10 + i) * wordSize));
+    __ bind(done);
+  }
+
+  // c_rarg0 contains the result from the call of
+  // InterpreterRuntime::slow_signature_handler so we don't touch it
+  // here.  It will be loaded with the JNIEnv* later.
+  __ ldr(c_rarg1, Address(sp, 1 * wordSize));
+  for (int i = c_rarg2->encoding(); i <= c_rarg7->encoding(); i += 2) {
+    Register rm = as_Register(i), rn = as_Register(i+1);
+    __ ldp(rm, rn, Address(sp, i * wordSize));
+  }
+
+  __ add(sp, sp, 18 * wordSize);
+  __ ret(lr);
+
+  return entry;
+}
+
+
+//
+// Various method entries
+//
+
+address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
+  // rmethod: Method*
+  // r13: sender sp
+  // esp: args
+
+  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
+
+  // These don't need a safepoint check because they aren't virtually
+  // callable. We won't enter these intrinsics from compiled code.
+  // If in the future we added an intrinsic which was virtually callable
+  // we'd have to worry about how to safepoint so that this code is used.
+
+  // mathematical functions inlined by compiler
+  // (interpreter must provide identical implementation
+  // in order to avoid monotonicity bugs when switching
+  // from interpreter to compiler in the middle of some
+  // computation)
+  //
+  // stack:
+  //        [ arg ] <-- esp
+  //        [ arg ]
+  // retaddr in lr
+
+  address entry_point = NULL;
+  Register continuation = lr;
+  switch (kind) {
+  case Interpreter::java_lang_math_abs:
+    entry_point = __ pc();
+    __ ldrd(v0, Address(esp));
+    __ fabsd(v0, v0);
+    __ mov(sp, r13); // Restore caller's SP
+    break;
+  case Interpreter::java_lang_math_sqrt:
+    entry_point = __ pc();
+    __ ldrd(v0, Address(esp));
+    __ fsqrtd(v0, v0);
+    __ mov(sp, r13);
+    break;
+  case Interpreter::java_lang_math_sin :
+  case Interpreter::java_lang_math_cos :
+  case Interpreter::java_lang_math_tan :
+  case Interpreter::java_lang_math_log :
+  case Interpreter::java_lang_math_log10 :
+  case Interpreter::java_lang_math_exp :
+    entry_point = __ pc();
+    __ ldrd(v0, Address(esp));
+    __ mov(sp, r13);
+    __ mov(r19, lr);
+    continuation = r19;  // The first callee-saved register
+    generate_transcendental_entry(kind, 1);
+    break;
+  case Interpreter::java_lang_math_pow :
+    entry_point = __ pc();
+    __ mov(r19, lr);
+    continuation = r19;
+    __ ldrd(v0, Address(esp, 2 * Interpreter::stackElementSize));
+    __ ldrd(v1, Address(esp));
+    __ mov(sp, r13);
+    generate_transcendental_entry(kind, 2);
+    break;
+  default:
+    ;
+  }
+  if (entry_point) {
+    __ br(continuation);
+  }
+
+  return entry_point;
+}
+
+  // double trigonometrics and transcendentals
+  // static jdouble dsin(jdouble x);
+  // static jdouble dcos(jdouble x);
+  // static jdouble dtan(jdouble x);
+  // static jdouble dlog(jdouble x);
+  // static jdouble dlog10(jdouble x);
+  // static jdouble dexp(jdouble x);
+  // static jdouble dpow(jdouble x, jdouble y);
+
+void TemplateInterpreterGenerator::generate_transcendental_entry(AbstractInterpreter::MethodKind kind, int fpargs) {
+  address fn;
+  switch (kind) {
+  case Interpreter::java_lang_math_sin :
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
+    break;
+  case Interpreter::java_lang_math_cos :
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
+    break;
+  case Interpreter::java_lang_math_tan :
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
+    break;
+  case Interpreter::java_lang_math_log :
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
+    break;
+  case Interpreter::java_lang_math_log10 :
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
+    break;
+  case Interpreter::java_lang_math_exp :
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
+    break;
+  case Interpreter::java_lang_math_pow :
+    fpargs = 2;
+    fn = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
+    break;
+  default:
+    ShouldNotReachHere();
+    fn = NULL;  // unreachable
+  }
+  const int gpargs = 0, rtype = 3;
+  __ mov(rscratch1, fn);
+  __ blrt(rscratch1, gpargs, fpargs, rtype);
+}
+
+// Abstract method entry
+// Attempt to execute abstract method. Throw exception
+address TemplateInterpreterGenerator::generate_abstract_entry(void) {
+  // rmethod: Method*
+  // r13: sender SP
+
+  address entry_point = __ pc();
+
+  // abstract method entry
+
+  //  pop return address, reset last_sp to NULL
+  __ empty_expression_stack();
+  __ restore_bcp();      // bcp must be correct for exception handler   (was destroyed)
+  __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
+
+  // throw exception
+  __ call_VM(noreg, CAST_FROM_FN_PTR(address,
+                             InterpreterRuntime::throw_AbstractMethodError));
+  // the call_VM checks for exception, so we should never return here.
+  __ should_not_reach_here();
+
+  return entry_point;
+}
+
 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
   address entry = __ pc();
 
--- a/src/cpu/aarch64/vm/templateInterpreter_aarch64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, Red Hat Inc. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "interpreter/interpreter.hpp"
-#include "oops/constMethod.hpp"
-#include "oops/method.hpp"
-#include "runtime/frame.inline.hpp"
-#include "utilities/debug.hpp"
-#include "utilities/macros.hpp"
-
-// Size of interpreter code.  Increase if too small.  Interpreter will
-// fail with a guarantee ("not enough space for interpreter generation");
-// if too small.
-// Run with +PrintInterpreter to get the VM to print out the size.
-// Max size with JVMTI
-int TemplateInterpreter::InterpreterCodeSize = 200 * 1024;
-
-int AbstractInterpreter::BasicType_as_index(BasicType type) {
-  int i = 0;
-  switch (type) {
-    case T_BOOLEAN: i = 0; break;
-    case T_CHAR   : i = 1; break;
-    case T_BYTE   : i = 2; break;
-    case T_SHORT  : i = 3; break;
-    case T_INT    : i = 4; break;
-    case T_LONG   : i = 5; break;
-    case T_VOID   : i = 6; break;
-    case T_FLOAT  : i = 7; break;
-    case T_DOUBLE : i = 8; break;
-    case T_OBJECT : i = 9; break;
-    case T_ARRAY  : i = 9; break;
-    default       : ShouldNotReachHere();
-  }
-  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
-         "index out of bounds");
-  return i;
-}
-
-// These should never be compiled since the interpreter will prefer
-// the compiled version to the intrinsic version.
-bool AbstractInterpreter::can_be_compiled(methodHandle m) {
-  switch (method_kind(m)) {
-    case Interpreter::java_lang_math_sin     : // fall thru
-    case Interpreter::java_lang_math_cos     : // fall thru
-    case Interpreter::java_lang_math_tan     : // fall thru
-    case Interpreter::java_lang_math_abs     : // fall thru
-    case Interpreter::java_lang_math_log     : // fall thru
-    case Interpreter::java_lang_math_log10   : // fall thru
-    case Interpreter::java_lang_math_sqrt    : // fall thru
-    case Interpreter::java_lang_math_pow     : // fall thru
-    case Interpreter::java_lang_math_exp     :
-      return false;
-    default:
-      return true;
-  }
-}
-
-// How much stack a method activation needs in words.
-int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
-  const int entry_size = frame::interpreter_frame_monitor_size();
-
-  // total overhead size: entry_size + (saved rfp thru expr stack
-  // bottom).  be sure to change this if you add/subtract anything
-  // to/from the overhead area
-  const int overhead_size =
-    -(frame::interpreter_frame_initial_sp_offset) + entry_size;
-
-  const int stub_code = frame::entry_frame_after_call_words;
-  const int method_stack = (method->max_locals() + method->max_stack()) *
-                           Interpreter::stackElementWords;
-  return (overhead_size + method_stack + stub_code);
-}
-
-// asm based interpreter deoptimization helpers
-int AbstractInterpreter::size_activation(int max_stack,
-                                         int temps,
-                                         int extra_args,
-                                         int monitors,
-                                         int callee_params,
-                                         int callee_locals,
-                                         bool is_top_frame) {
-  // Note: This calculation must exactly parallel the frame setup
-  // in TemplateInterpreterGenerator::generate_method_entry.
-
-  // fixed size of an interpreter frame:
-  int overhead = frame::sender_sp_offset -
-                 frame::interpreter_frame_initial_sp_offset;
-  // Our locals were accounted for by the caller (or last_frame_adjust
-  // on the transistion) Since the callee parameters already account
-  // for the callee's params we only need to account for the extra
-  // locals.
-  int size = overhead +
-         (callee_locals - callee_params)*Interpreter::stackElementWords +
-         monitors * frame::interpreter_frame_monitor_size() +
-         temps* Interpreter::stackElementWords + extra_args;
-
-  // On AArch64 we always keep the stack pointer 16-aligned, so we
-  // must round up here.
-  size = round_to(size, 2);
-
-  return size;
-}
-
-void AbstractInterpreter::layout_activation(Method* method,
-                                            int tempcount,
-                                            int popframe_extra_args,
-                                            int moncount,
-                                            int caller_actual_parameters,
-                                            int callee_param_count,
-                                            int callee_locals,
-                                            frame* caller,
-                                            frame* interpreter_frame,
-                                            bool is_top_frame,
-                                            bool is_bottom_frame) {
-  // The frame interpreter_frame is guaranteed to be the right size,
-  // as determined by a previous call to the size_activation() method.
-  // It is also guaranteed to be walkable even though it is in a
-  // skeletal state
-
-  int max_locals = method->max_locals() * Interpreter::stackElementWords;
-  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
-    Interpreter::stackElementWords;
-
-#ifdef ASSERT
-  assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
-#endif
-
-  interpreter_frame->interpreter_frame_set_method(method);
-  // NOTE the difference in using sender_sp and
-  // interpreter_frame_sender_sp interpreter_frame_sender_sp is
-  // the original sp of the caller (the unextended_sp) and
-  // sender_sp is fp+8/16 (32bit/64bit) XXX
-  intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
-
-#ifdef ASSERT
-  if (caller->is_interpreted_frame()) {
-    assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
-  }
-#endif
-
-  interpreter_frame->interpreter_frame_set_locals(locals);
-  BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
-  BasicObjectLock* monbot = montop - moncount;
-  interpreter_frame->interpreter_frame_set_monitor_end(monbot);
-
-  // Set last_sp
-  intptr_t*  esp = (intptr_t*) monbot -
-    tempcount*Interpreter::stackElementWords -
-    popframe_extra_args;
-  interpreter_frame->interpreter_frame_set_last_sp(esp);
-
-  // All frames but the initial (oldest) interpreter frame we fill in have
-  // a value for sender_sp that allows walking the stack but isn't
-  // truly correct. Correct the value here.
-  if (extra_locals != 0 &&
-      interpreter_frame->sender_sp() ==
-      interpreter_frame->interpreter_frame_sender_sp()) {
-    interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
-                                                       extra_locals);
-  }
-  *interpreter_frame->interpreter_frame_cache_addr() =
-    method->constants()->cache();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "interpreter/interpreter.hpp"
+#include "oops/constMethod.hpp"
+#include "oops/method.hpp"
+#include "runtime/frame.inline.hpp"
+#include "utilities/debug.hpp"
+#include "utilities/macros.hpp"
+
+int AbstractInterpreter::BasicType_as_index(BasicType type) {
+  int i = 0;
+  switch (type) {
+    case T_BOOLEAN: i = 0; break;
+    case T_CHAR   : i = 1; break;
+    case T_BYTE   : i = 2; break;
+    case T_SHORT  : i = 3; break;
+    case T_INT    : i = 4; break;
+    case T_LONG   : i = 5; break;
+    case T_VOID   : i = 6; break;
+    case T_FLOAT  : i = 7; break;
+    case T_DOUBLE : i = 8; break;
+    case T_OBJECT : i = 9; break;
+    case T_ARRAY  : i = 9; break;
+    default       : ShouldNotReachHere();
+  }
+  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
+  return i;
+}
+
+// Support abs and sqrt like in compiler.
+// For others we can use a normal (native) entry.
+bool AbstractInterpreter::math_entry_available(AbstractInterpreter::MethodKind kind) {
+  if (!InlineIntrinsics) return false;
+
+  return ((kind==Interpreter::java_lang_math_sqrt && VM_Version::has_fsqrt()) ||
+          (kind==Interpreter::java_lang_math_abs));
+}
+
+// These should never be compiled since the interpreter will prefer
+// the compiled version to the intrinsic version.
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  return !math_entry_available(method_kind(m));
+}
+
+// How much stack a method activation needs in stack slots.
+// We must calc this exactly like in generate_fixed_frame.
+// Note: This returns the conservative size assuming maximum alignment.
+int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
+  const int max_alignment_size = 2;
+  const int abi_scratch = frame::abi_reg_args_size;
+  return method->max_locals() + method->max_stack() +
+         frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
+}
+
+// Returns number of stackElementWords needed for the interpreter frame with the
+// given sections.
+// This overestimates the stack by one slot in case of alignments.
+int AbstractInterpreter::size_activation(int max_stack,
+                                         int temps,
+                                         int extra_args,
+                                         int monitors,
+                                         int callee_params,
+                                         int callee_locals,
+                                         bool is_top_frame) {
+  // Note: This calculation must exactly parallel the frame setup
+  // in TemplateInterpreterGenerator::generate_fixed_frame.
+  assert(Interpreter::stackElementWords == 1, "sanity");
+  const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;
+  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
+                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
+  const int size =
+    max_stack                                                +
+    (callee_locals - callee_params)                          +
+    monitors * frame::interpreter_frame_monitor_size()       +
+    max_alignment_space                                      +
+    abi_scratch                                              +
+    frame::ijava_state_size / Interpreter::stackElementSize;
+
+  // Fixed size of an interpreter frame, align to 16-byte.
+  return (size & -2);
+}
+
+// Fills a sceletal interpreter frame generated during deoptimizations.
+//
+// Parameters:
+//
+// interpreter_frame != NULL:
+//   set up the method, locals, and monitors.
+//   The frame interpreter_frame, if not NULL, is guaranteed to be the
+//   right size, as determined by a previous call to this method.
+//   It is also guaranteed to be walkable even though it is in a skeletal state
+//
+// is_top_frame == true:
+//   We're processing the *oldest* interpreter frame!
+//
+// pop_frame_extra_args:
+//   If this is != 0 we are returning to a deoptimized frame by popping
+//   off the callee frame. We want to re-execute the call that called the
+//   callee interpreted, but since the return to the interpreter would pop
+//   the arguments off advance the esp by dummy popframe_extra_args slots.
+//   Popping off those will establish the stack layout as it was before the call.
+//
+void AbstractInterpreter::layout_activation(Method* method,
+                                            int tempcount,
+                                            int popframe_extra_args,
+                                            int moncount,
+                                            int caller_actual_parameters,
+                                            int callee_param_count,
+                                            int callee_locals_count,
+                                            frame* caller,
+                                            frame* interpreter_frame,
+                                            bool is_top_frame,
+                                            bool is_bottom_frame) {
+
+  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
+                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
+
+  intptr_t* locals_base  = (caller->is_interpreted_frame()) ?
+    caller->interpreter_frame_esp() + caller_actual_parameters :
+    caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize);
+
+  intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize;
+  intptr_t* monitor      = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
+  intptr_t* esp_base     = monitor - 1;
+  intptr_t* esp          = esp_base - tempcount - popframe_extra_args;
+  intptr_t* sp           = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
+  intptr_t* sender_sp    = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
+  intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
+
+  interpreter_frame->interpreter_frame_set_method(method);
+  interpreter_frame->interpreter_frame_set_locals(locals_base);
+  interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
+  interpreter_frame->interpreter_frame_set_esp(esp);
+  interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
+  interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
+  if (!is_bottom_frame) {
+    interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
+  }
+}
--- a/src/cpu/ppc/vm/interpreter_ppc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,555 +0,0 @@
-/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/macroAssembler.inline.hpp"
-#include "interpreter/bytecodeHistogram.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/interp_masm.hpp"
-#include "interpreter/templateInterpreterGenerator.hpp"
-#include "interpreter/templateTable.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "prims/methodHandles.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/timer.hpp"
-#include "runtime/vframeArray.hpp"
-#include "utilities/debug.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-
-#define __ _masm->
-
-#ifdef PRODUCT
-#define BLOCK_COMMENT(str) // nothing
-#else
-#define BLOCK_COMMENT(str) __ block_comment(str)
-#endif
-
-#define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
-
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  // Slow_signature handler that respects the PPC C calling conventions.
-  //
-  // We get called by the native entry code with our output register
-  // area == 8. First we call InterpreterRuntime::get_result_handler
-  // to copy the pointer to the signature string temporarily to the
-  // first C-argument and to return the result_handler in
-  // R3_RET. Since native_entry will copy the jni-pointer to the
-  // first C-argument slot later on, it is OK to occupy this slot
-  // temporarilly. Then we copy the argument list on the java
-  // expression stack into native varargs format on the native stack
-  // and load arguments into argument registers. Integer arguments in
-  // the varargs vector will be sign-extended to 8 bytes.
-  //
-  // On entry:
-  //   R3_ARG1        - intptr_t*     Address of java argument list in memory.
-  //   R15_prev_state - BytecodeInterpreter* Address of interpreter state for
-  //     this method
-  //   R19_method
-  //
-  // On exit (just before return instruction):
-  //   R3_RET            - contains the address of the result_handler.
-  //   R4_ARG2           - is not updated for static methods and contains "this" otherwise.
-  //   R5_ARG3-R10_ARG8: - When the (i-2)th Java argument is not of type float or double,
-  //                       ARGi contains this argument. Otherwise, ARGi is not updated.
-  //   F1_ARG1-F13_ARG13 - contain the first 13 arguments of type float or double.
-
-  const int LogSizeOfTwoInstructions = 3;
-
-  // FIXME: use Argument:: GL: Argument names different numbers!
-  const int max_fp_register_arguments  = 13;
-  const int max_int_register_arguments = 6;  // first 2 are reserved
-
-  const Register arg_java       = R21_tmp1;
-  const Register arg_c          = R22_tmp2;
-  const Register signature      = R23_tmp3;  // is string
-  const Register sig_byte       = R24_tmp4;
-  const Register fpcnt          = R25_tmp5;
-  const Register argcnt         = R26_tmp6;
-  const Register intSlot        = R27_tmp7;
-  const Register target_sp      = R28_tmp8;
-  const FloatRegister floatSlot = F0;
-
-  address entry = __ function_entry();
-
-  __ save_LR_CR(R0);
-  __ save_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
-  // We use target_sp for storing arguments in the C frame.
-  __ mr(target_sp, R1_SP);
-  __ push_frame_reg_args_nonvolatiles(0, R11_scratch1);
-
-  __ mr(arg_java, R3_ARG1);
-
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_signature), R16_thread, R19_method);
-
-  // Signature is in R3_RET. Signature is callee saved.
-  __ mr(signature, R3_RET);
-
-  // Get the result handler.
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_result_handler), R16_thread, R19_method);
-
-  {
-    Label L;
-    // test if static
-    // _access_flags._flags must be at offset 0.
-    // TODO PPC port: requires change in shared code.
-    //assert(in_bytes(AccessFlags::flags_offset()) == 0,
-    //       "MethodDesc._access_flags == MethodDesc._access_flags._flags");
-    // _access_flags must be a 32 bit value.
-    assert(sizeof(AccessFlags) == 4, "wrong size");
-    __ lwa(R11_scratch1/*access_flags*/, method_(access_flags));
-    // testbit with condition register.
-    __ testbitdi(CCR0, R0, R11_scratch1/*access_flags*/, JVM_ACC_STATIC_BIT);
-    __ btrue(CCR0, L);
-    // For non-static functions, pass "this" in R4_ARG2 and copy it
-    // to 2nd C-arg slot.
-    // We need to box the Java object here, so we use arg_java
-    // (address of current Java stack slot) as argument and don't
-    // dereference it as in case of ints, floats, etc.
-    __ mr(R4_ARG2, arg_java);
-    __ addi(arg_java, arg_java, -BytesPerWord);
-    __ std(R4_ARG2, _abi(carg_2), target_sp);
-    __ bind(L);
-  }
-
-  // Will be incremented directly after loop_start. argcnt=0
-  // corresponds to 3rd C argument.
-  __ li(argcnt, -1);
-  // arg_c points to 3rd C argument
-  __ addi(arg_c, target_sp, _abi(carg_3));
-  // no floating-point args parsed so far
-  __ li(fpcnt, 0);
-
-  Label move_intSlot_to_ARG, move_floatSlot_to_FARG;
-  Label loop_start, loop_end;
-  Label do_int, do_long, do_float, do_double, do_dontreachhere, do_object, do_array, do_boxed;
-
-  // signature points to '(' at entry
-#ifdef ASSERT
-  __ lbz(sig_byte, 0, signature);
-  __ cmplwi(CCR0, sig_byte, '(');
-  __ bne(CCR0, do_dontreachhere);
-#endif
-
-  __ bind(loop_start);
-
-  __ addi(argcnt, argcnt, 1);
-  __ lbzu(sig_byte, 1, signature);
-
-  __ cmplwi(CCR0, sig_byte, ')'); // end of signature
-  __ beq(CCR0, loop_end);
-
-  __ cmplwi(CCR0, sig_byte, 'B'); // byte
-  __ beq(CCR0, do_int);
-
-  __ cmplwi(CCR0, sig_byte, 'C'); // char
-  __ beq(CCR0, do_int);
-
-  __ cmplwi(CCR0, sig_byte, 'D'); // double
-  __ beq(CCR0, do_double);
-
-  __ cmplwi(CCR0, sig_byte, 'F'); // float
-  __ beq(CCR0, do_float);
-
-  __ cmplwi(CCR0, sig_byte, 'I'); // int
-  __ beq(CCR0, do_int);
-
-  __ cmplwi(CCR0, sig_byte, 'J'); // long
-  __ beq(CCR0, do_long);
-
-  __ cmplwi(CCR0, sig_byte, 'S'); // short
-  __ beq(CCR0, do_int);
-
-  __ cmplwi(CCR0, sig_byte, 'Z'); // boolean
-  __ beq(CCR0, do_int);
-
-  __ cmplwi(CCR0, sig_byte, 'L'); // object
-  __ beq(CCR0, do_object);
-
-  __ cmplwi(CCR0, sig_byte, '['); // array
-  __ beq(CCR0, do_array);
-
-  //  __ cmplwi(CCR0, sig_byte, 'V'); // void cannot appear since we do not parse the return type
-  //  __ beq(CCR0, do_void);
-
-  __ bind(do_dontreachhere);
-
-  __ unimplemented("ShouldNotReachHere in slow_signature_handler", 120);
-
-  __ bind(do_array);
-
-  {
-    Label start_skip, end_skip;
-
-    __ bind(start_skip);
-    __ lbzu(sig_byte, 1, signature);
-    __ cmplwi(CCR0, sig_byte, '[');
-    __ beq(CCR0, start_skip); // skip further brackets
-    __ cmplwi(CCR0, sig_byte, '9');
-    __ bgt(CCR0, end_skip);   // no optional size
-    __ cmplwi(CCR0, sig_byte, '0');
-    __ bge(CCR0, start_skip); // skip optional size
-    __ bind(end_skip);
-
-    __ cmplwi(CCR0, sig_byte, 'L');
-    __ beq(CCR0, do_object);  // for arrays of objects, the name of the object must be skipped
-    __ b(do_boxed);          // otherwise, go directly to do_boxed
-  }
-
-  __ bind(do_object);
-  {
-    Label L;
-    __ bind(L);
-    __ lbzu(sig_byte, 1, signature);
-    __ cmplwi(CCR0, sig_byte, ';');
-    __ bne(CCR0, L);
-   }
-  // Need to box the Java object here, so we use arg_java (address of
-  // current Java stack slot) as argument and don't dereference it as
-  // in case of ints, floats, etc.
-  Label do_null;
-  __ bind(do_boxed);
-  __ ld(R0,0, arg_java);
-  __ cmpdi(CCR0, R0, 0);
-  __ li(intSlot,0);
-  __ beq(CCR0, do_null);
-  __ mr(intSlot, arg_java);
-  __ bind(do_null);
-  __ std(intSlot, 0, arg_c);
-  __ addi(arg_java, arg_java, -BytesPerWord);
-  __ addi(arg_c, arg_c, BytesPerWord);
-  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
-  __ blt(CCR0, move_intSlot_to_ARG);
-  __ b(loop_start);
-
-  __ bind(do_int);
-  __ lwa(intSlot, 0, arg_java);
-  __ std(intSlot, 0, arg_c);
-  __ addi(arg_java, arg_java, -BytesPerWord);
-  __ addi(arg_c, arg_c, BytesPerWord);
-  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
-  __ blt(CCR0, move_intSlot_to_ARG);
-  __ b(loop_start);
-
-  __ bind(do_long);
-  __ ld(intSlot, -BytesPerWord, arg_java);
-  __ std(intSlot, 0, arg_c);
-  __ addi(arg_java, arg_java, - 2 * BytesPerWord);
-  __ addi(arg_c, arg_c, BytesPerWord);
-  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
-  __ blt(CCR0, move_intSlot_to_ARG);
-  __ b(loop_start);
-
-  __ bind(do_float);
-  __ lfs(floatSlot, 0, arg_java);
-#if defined(LINUX)
-  // Linux uses ELF ABI. Both original ELF and ELFv2 ABIs have float
-  // in the least significant word of an argument slot.
-#if defined(VM_LITTLE_ENDIAN)
-  __ stfs(floatSlot, 0, arg_c);
-#else
-  __ stfs(floatSlot, 4, arg_c);
-#endif
-#elif defined(AIX)
-  // Although AIX runs on big endian CPU, float is in most significant
-  // word of an argument slot.
-  __ stfs(floatSlot, 0, arg_c);
-#else
-#error "unknown OS"
-#endif
-  __ addi(arg_java, arg_java, -BytesPerWord);
-  __ addi(arg_c, arg_c, BytesPerWord);
-  __ cmplwi(CCR0, fpcnt, max_fp_register_arguments);
-  __ blt(CCR0, move_floatSlot_to_FARG);
-  __ b(loop_start);
-
-  __ bind(do_double);
-  __ lfd(floatSlot, - BytesPerWord, arg_java);
-  __ stfd(floatSlot, 0, arg_c);
-  __ addi(arg_java, arg_java, - 2 * BytesPerWord);
-  __ addi(arg_c, arg_c, BytesPerWord);
-  __ cmplwi(CCR0, fpcnt, max_fp_register_arguments);
-  __ blt(CCR0, move_floatSlot_to_FARG);
-  __ b(loop_start);
-
-  __ bind(loop_end);
-
-  __ pop_frame();
-  __ restore_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
-  __ restore_LR_CR(R0);
-
-  __ blr();
-
-  Label move_int_arg, move_float_arg;
-  __ bind(move_int_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions)
-  __ mr(R5_ARG3, intSlot);  __ b(loop_start);
-  __ mr(R6_ARG4, intSlot);  __ b(loop_start);
-  __ mr(R7_ARG5, intSlot);  __ b(loop_start);
-  __ mr(R8_ARG6, intSlot);  __ b(loop_start);
-  __ mr(R9_ARG7, intSlot);  __ b(loop_start);
-  __ mr(R10_ARG8, intSlot); __ b(loop_start);
-
-  __ bind(move_float_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions)
-  __ fmr(F1_ARG1, floatSlot);   __ b(loop_start);
-  __ fmr(F2_ARG2, floatSlot);   __ b(loop_start);
-  __ fmr(F3_ARG3, floatSlot);   __ b(loop_start);
-  __ fmr(F4_ARG4, floatSlot);   __ b(loop_start);
-  __ fmr(F5_ARG5, floatSlot);   __ b(loop_start);
-  __ fmr(F6_ARG6, floatSlot);   __ b(loop_start);
-  __ fmr(F7_ARG7, floatSlot);   __ b(loop_start);
-  __ fmr(F8_ARG8, floatSlot);   __ b(loop_start);
-  __ fmr(F9_ARG9, floatSlot);   __ b(loop_start);
-  __ fmr(F10_ARG10, floatSlot); __ b(loop_start);
-  __ fmr(F11_ARG11, floatSlot); __ b(loop_start);
-  __ fmr(F12_ARG12, floatSlot); __ b(loop_start);
-  __ fmr(F13_ARG13, floatSlot); __ b(loop_start);
-
-  __ bind(move_intSlot_to_ARG);
-  __ sldi(R0, argcnt, LogSizeOfTwoInstructions);
-  __ load_const(R11_scratch1, move_int_arg); // Label must be bound here.
-  __ add(R11_scratch1, R0, R11_scratch1);
-  __ mtctr(R11_scratch1/*branch_target*/);
-  __ bctr();
-  __ bind(move_floatSlot_to_FARG);
-  __ sldi(R0, fpcnt, LogSizeOfTwoInstructions);
-  __ addi(fpcnt, fpcnt, 1);
-  __ load_const(R11_scratch1, move_float_arg); // Label must be bound here.
-  __ add(R11_scratch1, R0, R11_scratch1);
-  __ mtctr(R11_scratch1/*branch_target*/);
-  __ bctr();
-
-  return entry;
-}
-
-address AbstractInterpreterGenerator::generate_result_handler_for(BasicType type) {
-  //
-  // Registers alive
-  //   R3_RET
-  //   LR
-  //
-  // Registers updated
-  //   R3_RET
-  //
-
-  Label done;
-  address entry = __ pc();
-
-  switch (type) {
-  case T_BOOLEAN:
-    // convert !=0 to 1
-    __ neg(R0, R3_RET);
-    __ orr(R0, R3_RET, R0);
-    __ srwi(R3_RET, R0, 31);
-    break;
-  case T_BYTE:
-     // sign extend 8 bits
-     __ extsb(R3_RET, R3_RET);
-     break;
-  case T_CHAR:
-     // zero extend 16 bits
-     __ clrldi(R3_RET, R3_RET, 48);
-     break;
-  case T_SHORT:
-     // sign extend 16 bits
-     __ extsh(R3_RET, R3_RET);
-     break;
-  case T_INT:
-     // sign extend 32 bits
-     __ extsw(R3_RET, R3_RET);
-     break;
-  case T_LONG:
-     break;
-  case T_OBJECT:
-    // unbox result if not null
-    __ cmpdi(CCR0, R3_RET, 0);
-    __ beq(CCR0, done);
-    __ ld(R3_RET, 0, R3_RET);
-    __ verify_oop(R3_RET);
-    break;
-  case T_FLOAT:
-     break;
-  case T_DOUBLE:
-     break;
-  case T_VOID:
-     break;
-  default: ShouldNotReachHere();
-  }
-
-  __ BIND(done);
-  __ blr();
-
-  return entry;
-}
-
-// Abstract method entry.
-//
-address TemplateInterpreterGenerator::generate_abstract_entry(void) {
-  address entry = __ pc();
-
-  //
-  // Registers alive
-  //   R16_thread     - JavaThread*
-  //   R19_method     - callee's method (method to be invoked)
-  //   R1_SP          - SP prepared such that caller's outgoing args are near top
-  //   LR             - return address to caller
-  //
-  // Stack layout at this point:
-  //
-  //   0       [TOP_IJAVA_FRAME_ABI]         <-- R1_SP
-  //           alignment (optional)
-  //           [outgoing Java arguments]
-  //           ...
-  //   PARENT  [PARENT_IJAVA_FRAME_ABI]
-  //            ...
-  //
-
-  // Can't use call_VM here because we have not set up a new
-  // interpreter state. Make the call to the vm and make it look like
-  // our caller set up the JavaFrameAnchor.
-  __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
-
-  // Push a new C frame and save LR.
-  __ save_LR_CR(R0);
-  __ push_frame_reg_args(0, R11_scratch1);
-
-  // This is not a leaf but we have a JavaFrameAnchor now and we will
-  // check (create) exceptions afterward so this is ok.
-  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError),
-                  R16_thread);
-
-  // Pop the C frame and restore LR.
-  __ pop_frame();
-  __ restore_LR_CR(R0);
-
-  // Reset JavaFrameAnchor from call_VM_leaf above.
-  __ reset_last_Java_frame();
-
-  // We don't know our caller, so jump to the general forward exception stub,
-  // which will also pop our full frame off. Satisfy the interface of
-  // SharedRuntime::generate_forward_exception()
-  __ load_const_optimized(R11_scratch1, StubRoutines::forward_exception_entry(), R0);
-  __ mtctr(R11_scratch1);
-  __ bctr();
-
-  return entry;
-}
-
-// Interpreter intrinsic for WeakReference.get().
-// 1. Don't push a full blown frame and go on dispatching, but fetch the value
-//    into R8 and return quickly
-// 2. If G1 is active we *must* execute this intrinsic for corrrectness:
-//    It contains a GC barrier which puts the reference into the satb buffer
-//    to indicate that someone holds a strong reference to the object the
-//    weak ref points to!
-address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
-  // Code: _aload_0, _getfield, _areturn
-  // parameter size = 1
-  //
-  // The code that gets generated by this routine is split into 2 parts:
-  //    1. the "intrinsified" code for G1 (or any SATB based GC),
-  //    2. the slow path - which is an expansion of the regular method entry.
-  //
-  // Notes:
-  // * In the G1 code we do not check whether we need to block for
-  //   a safepoint. If G1 is enabled then we must execute the specialized
-  //   code for Reference.get (except when the Reference object is null)
-  //   so that we can log the value in the referent field with an SATB
-  //   update buffer.
-  //   If the code for the getfield template is modified so that the
-  //   G1 pre-barrier code is executed when the current method is
-  //   Reference.get() then going through the normal method entry
-  //   will be fine.
-  // * The G1 code can, however, check the receiver object (the instance
-  //   of java.lang.Reference) and jump to the slow path if null. If the
-  //   Reference object is null then we obviously cannot fetch the referent
-  //   and so we don't need to call the G1 pre-barrier. Thus we can use the
-  //   regular method entry code to generate the NPE.
-  //
-
-  if (UseG1GC) {
-    address entry = __ pc();
-
-    const int referent_offset = java_lang_ref_Reference::referent_offset;
-    guarantee(referent_offset > 0, "referent offset not initialized");
-
-    Label slow_path;
-
-    // Debugging not possible, so can't use __ skip_if_jvmti_mode(slow_path, GR31_SCRATCH);
-
-    // In the G1 code we don't check if we need to reach a safepoint. We
-    // continue and the thread will safepoint at the next bytecode dispatch.
-
-    // If the receiver is null then it is OK to jump to the slow path.
-    __ ld(R3_RET, Interpreter::stackElementSize, R15_esp); // get receiver
-
-    // Check if receiver == NULL and go the slow path.
-    __ cmpdi(CCR0, R3_RET, 0);
-    __ beq(CCR0, slow_path);
-
-    // Load the value of the referent field.
-    __ load_heap_oop(R3_RET, referent_offset, R3_RET);
-
-    // Generate the G1 pre-barrier code to log the value of
-    // the referent field in an SATB buffer. Note with
-    // these parameters the pre-barrier does not generate
-    // the load of the previous value.
-
-    // Restore caller sp for c2i case.
-#ifdef ASSERT
-      __ ld(R9_ARG7, 0, R1_SP);
-      __ ld(R10_ARG8, 0, R21_sender_SP);
-      __ cmpd(CCR0, R9_ARG7, R10_ARG8);
-      __ asm_assert_eq("backlink", 0x544);
-#endif // ASSERT
-    __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
-
-    __ g1_write_barrier_pre(noreg,         // obj
-                            noreg,         // offset
-                            R3_RET,        // pre_val
-                            R11_scratch1,  // tmp
-                            R12_scratch2,  // tmp
-                            true);         // needs_frame
-
-    __ blr();
-
-    // Generate regular method entry.
-    __ bind(slow_path);
-    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R11_scratch1);
-    return entry;
-  }
-
-  return NULL;
-}
--- a/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/ppc/vm/sharedRuntime_ppc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1477,7 +1477,7 @@
   }
 }
 
-// Check GC_locker::needs_gc and enter the runtime if it's true. This
+// 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
 // forced. Save down any oops in registers and describe them in an
 // OopMap.
@@ -1489,9 +1489,9 @@
                                                VMRegPair* in_regs,
                                                BasicType* in_sig_bt,
                                                Register tmp_reg ) {
-  __ block_comment("check GC_locker::needs_gc");
+  __ block_comment("check GCLocker::needs_gc");
   Label cont;
-  __ lbz(tmp_reg, (RegisterOrConstant)(intptr_t)GC_locker::needs_gc_address());
+  __ lbz(tmp_reg, (RegisterOrConstant)(intptr_t)GCLocker::needs_gc_address());
   __ cmplwi(CCR0, tmp_reg, 0);
   __ beq(CCR0, cont);
 
@@ -1690,14 +1690,14 @@
 // GetPrimtiveArrayCritical and disallow the use of any other JNI
 // functions.  The wrapper is expected to unpack the arguments before
 // passing them to the callee and perform checks before and after the
-// native call to ensure that they GC_locker
+// native call to ensure that they GCLocker
 // lock_critical/unlock_critical semantics are followed.  Some other
 // parts of JNI setup are skipped like the tear down of the JNI handle
 // block and the check for pending exceptions it's impossible for them
 // to be thrown.
 //
 // They are roughly structured like this:
-//   if (GC_locker::needs_gc())
+//   if (GCLocker::needs_gc())
 //     SharedRuntime::block_for_jni_critical();
 //   tranistion to thread_in_native
 //   unpack arrray arguments and call native entry point
--- a/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -51,6 +51,13 @@
 #undef __
 #define __ _masm->
 
+// Size of interpreter code.  Increase if too small.  Interpreter will
+// fail with a guarantee ("not enough space for interpreter generation");
+// if too small.
+// Run with +PrintInterpreter to get the VM to print out the size.
+// Max size with JVMTI
+int TemplateInterpreter::InterpreterCodeSize = 230*K;
+
 #ifdef PRODUCT
 #define BLOCK_COMMENT(str) /* nothing */
 #else
@@ -61,6 +68,500 @@
 
 //-----------------------------------------------------------------------------
 
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+  // Slow_signature handler that respects the PPC C calling conventions.
+  //
+  // We get called by the native entry code with our output register
+  // area == 8. First we call InterpreterRuntime::get_result_handler
+  // to copy the pointer to the signature string temporarily to the
+  // first C-argument and to return the result_handler in
+  // R3_RET. Since native_entry will copy the jni-pointer to the
+  // first C-argument slot later on, it is OK to occupy this slot
+  // temporarilly. Then we copy the argument list on the java
+  // expression stack into native varargs format on the native stack
+  // and load arguments into argument registers. Integer arguments in
+  // the varargs vector will be sign-extended to 8 bytes.
+  //
+  // On entry:
+  //   R3_ARG1        - intptr_t*     Address of java argument list in memory.
+  //   R15_prev_state - BytecodeInterpreter* Address of interpreter state for
+  //     this method
+  //   R19_method
+  //
+  // On exit (just before return instruction):
+  //   R3_RET            - contains the address of the result_handler.
+  //   R4_ARG2           - is not updated for static methods and contains "this" otherwise.
+  //   R5_ARG3-R10_ARG8: - When the (i-2)th Java argument is not of type float or double,
+  //                       ARGi contains this argument. Otherwise, ARGi is not updated.
+  //   F1_ARG1-F13_ARG13 - contain the first 13 arguments of type float or double.
+
+  const int LogSizeOfTwoInstructions = 3;
+
+  // FIXME: use Argument:: GL: Argument names different numbers!
+  const int max_fp_register_arguments  = 13;
+  const int max_int_register_arguments = 6;  // first 2 are reserved
+
+  const Register arg_java       = R21_tmp1;
+  const Register arg_c          = R22_tmp2;
+  const Register signature      = R23_tmp3;  // is string
+  const Register sig_byte       = R24_tmp4;
+  const Register fpcnt          = R25_tmp5;
+  const Register argcnt         = R26_tmp6;
+  const Register intSlot        = R27_tmp7;
+  const Register target_sp      = R28_tmp8;
+  const FloatRegister floatSlot = F0;
+
+  address entry = __ function_entry();
+
+  __ save_LR_CR(R0);
+  __ save_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
+  // We use target_sp for storing arguments in the C frame.
+  __ mr(target_sp, R1_SP);
+  __ push_frame_reg_args_nonvolatiles(0, R11_scratch1);
+
+  __ mr(arg_java, R3_ARG1);
+
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_signature), R16_thread, R19_method);
+
+  // Signature is in R3_RET. Signature is callee saved.
+  __ mr(signature, R3_RET);
+
+  // Get the result handler.
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::get_result_handler), R16_thread, R19_method);
+
+  {
+    Label L;
+    // test if static
+    // _access_flags._flags must be at offset 0.
+    // TODO PPC port: requires change in shared code.
+    //assert(in_bytes(AccessFlags::flags_offset()) == 0,
+    //       "MethodDesc._access_flags == MethodDesc._access_flags._flags");
+    // _access_flags must be a 32 bit value.
+    assert(sizeof(AccessFlags) == 4, "wrong size");
+    __ lwa(R11_scratch1/*access_flags*/, method_(access_flags));
+    // testbit with condition register.
+    __ testbitdi(CCR0, R0, R11_scratch1/*access_flags*/, JVM_ACC_STATIC_BIT);
+    __ btrue(CCR0, L);
+    // For non-static functions, pass "this" in R4_ARG2 and copy it
+    // to 2nd C-arg slot.
+    // We need to box the Java object here, so we use arg_java
+    // (address of current Java stack slot) as argument and don't
+    // dereference it as in case of ints, floats, etc.
+    __ mr(R4_ARG2, arg_java);
+    __ addi(arg_java, arg_java, -BytesPerWord);
+    __ std(R4_ARG2, _abi(carg_2), target_sp);
+    __ bind(L);
+  }
+
+  // Will be incremented directly after loop_start. argcnt=0
+  // corresponds to 3rd C argument.
+  __ li(argcnt, -1);
+  // arg_c points to 3rd C argument
+  __ addi(arg_c, target_sp, _abi(carg_3));
+  // no floating-point args parsed so far
+  __ li(fpcnt, 0);
+
+  Label move_intSlot_to_ARG, move_floatSlot_to_FARG;
+  Label loop_start, loop_end;
+  Label do_int, do_long, do_float, do_double, do_dontreachhere, do_object, do_array, do_boxed;
+
+  // signature points to '(' at entry
+#ifdef ASSERT
+  __ lbz(sig_byte, 0, signature);
+  __ cmplwi(CCR0, sig_byte, '(');
+  __ bne(CCR0, do_dontreachhere);
+#endif
+
+  __ bind(loop_start);
+
+  __ addi(argcnt, argcnt, 1);
+  __ lbzu(sig_byte, 1, signature);
+
+  __ cmplwi(CCR0, sig_byte, ')'); // end of signature
+  __ beq(CCR0, loop_end);
+
+  __ cmplwi(CCR0, sig_byte, 'B'); // byte
+  __ beq(CCR0, do_int);
+
+  __ cmplwi(CCR0, sig_byte, 'C'); // char
+  __ beq(CCR0, do_int);
+
+  __ cmplwi(CCR0, sig_byte, 'D'); // double
+  __ beq(CCR0, do_double);
+
+  __ cmplwi(CCR0, sig_byte, 'F'); // float
+  __ beq(CCR0, do_float);
+
+  __ cmplwi(CCR0, sig_byte, 'I'); // int
+  __ beq(CCR0, do_int);
+
+  __ cmplwi(CCR0, sig_byte, 'J'); // long
+  __ beq(CCR0, do_long);
+
+  __ cmplwi(CCR0, sig_byte, 'S'); // short
+  __ beq(CCR0, do_int);
+
+  __ cmplwi(CCR0, sig_byte, 'Z'); // boolean
+  __ beq(CCR0, do_int);
+
+  __ cmplwi(CCR0, sig_byte, 'L'); // object
+  __ beq(CCR0, do_object);
+
+  __ cmplwi(CCR0, sig_byte, '['); // array
+  __ beq(CCR0, do_array);
+
+  //  __ cmplwi(CCR0, sig_byte, 'V'); // void cannot appear since we do not parse the return type
+  //  __ beq(CCR0, do_void);
+
+  __ bind(do_dontreachhere);
+
+  __ unimplemented("ShouldNotReachHere in slow_signature_handler", 120);
+
+  __ bind(do_array);
+
+  {
+    Label start_skip, end_skip;
+
+    __ bind(start_skip);
+    __ lbzu(sig_byte, 1, signature);
+    __ cmplwi(CCR0, sig_byte, '[');
+    __ beq(CCR0, start_skip); // skip further brackets
+    __ cmplwi(CCR0, sig_byte, '9');
+    __ bgt(CCR0, end_skip);   // no optional size
+    __ cmplwi(CCR0, sig_byte, '0');
+    __ bge(CCR0, start_skip); // skip optional size
+    __ bind(end_skip);
+
+    __ cmplwi(CCR0, sig_byte, 'L');
+    __ beq(CCR0, do_object);  // for arrays of objects, the name of the object must be skipped
+    __ b(do_boxed);          // otherwise, go directly to do_boxed
+  }
+
+  __ bind(do_object);
+  {
+    Label L;
+    __ bind(L);
+    __ lbzu(sig_byte, 1, signature);
+    __ cmplwi(CCR0, sig_byte, ';');
+    __ bne(CCR0, L);
+   }
+  // Need to box the Java object here, so we use arg_java (address of
+  // current Java stack slot) as argument and don't dereference it as
+  // in case of ints, floats, etc.
+  Label do_null;
+  __ bind(do_boxed);
+  __ ld(R0,0, arg_java);
+  __ cmpdi(CCR0, R0, 0);
+  __ li(intSlot,0);
+  __ beq(CCR0, do_null);
+  __ mr(intSlot, arg_java);
+  __ bind(do_null);
+  __ std(intSlot, 0, arg_c);
+  __ addi(arg_java, arg_java, -BytesPerWord);
+  __ addi(arg_c, arg_c, BytesPerWord);
+  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
+  __ blt(CCR0, move_intSlot_to_ARG);
+  __ b(loop_start);
+
+  __ bind(do_int);
+  __ lwa(intSlot, 0, arg_java);
+  __ std(intSlot, 0, arg_c);
+  __ addi(arg_java, arg_java, -BytesPerWord);
+  __ addi(arg_c, arg_c, BytesPerWord);
+  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
+  __ blt(CCR0, move_intSlot_to_ARG);
+  __ b(loop_start);
+
+  __ bind(do_long);
+  __ ld(intSlot, -BytesPerWord, arg_java);
+  __ std(intSlot, 0, arg_c);
+  __ addi(arg_java, arg_java, - 2 * BytesPerWord);
+  __ addi(arg_c, arg_c, BytesPerWord);
+  __ cmplwi(CCR0, argcnt, max_int_register_arguments);
+  __ blt(CCR0, move_intSlot_to_ARG);
+  __ b(loop_start);
+
+  __ bind(do_float);
+  __ lfs(floatSlot, 0, arg_java);
+#if defined(LINUX)
+  // Linux uses ELF ABI. Both original ELF and ELFv2 ABIs have float
+  // in the least significant word of an argument slot.
+#if defined(VM_LITTLE_ENDIAN)
+  __ stfs(floatSlot, 0, arg_c);
+#else
+  __ stfs(floatSlot, 4, arg_c);
+#endif
+#elif defined(AIX)
+  // Although AIX runs on big endian CPU, float is in most significant
+  // word of an argument slot.
+  __ stfs(floatSlot, 0, arg_c);
+#else
+#error "unknown OS"
+#endif
+  __ addi(arg_java, arg_java, -BytesPerWord);
+  __ addi(arg_c, arg_c, BytesPerWord);
+  __ cmplwi(CCR0, fpcnt, max_fp_register_arguments);
+  __ blt(CCR0, move_floatSlot_to_FARG);
+  __ b(loop_start);
+
+  __ bind(do_double);
+  __ lfd(floatSlot, - BytesPerWord, arg_java);
+  __ stfd(floatSlot, 0, arg_c);
+  __ addi(arg_java, arg_java, - 2 * BytesPerWord);
+  __ addi(arg_c, arg_c, BytesPerWord);
+  __ cmplwi(CCR0, fpcnt, max_fp_register_arguments);
+  __ blt(CCR0, move_floatSlot_to_FARG);
+  __ b(loop_start);
+
+  __ bind(loop_end);
+
+  __ pop_frame();
+  __ restore_nonvolatile_gprs(R1_SP, _spill_nonvolatiles_neg(r14));
+  __ restore_LR_CR(R0);
+
+  __ blr();
+
+  Label move_int_arg, move_float_arg;
+  __ bind(move_int_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions)
+  __ mr(R5_ARG3, intSlot);  __ b(loop_start);
+  __ mr(R6_ARG4, intSlot);  __ b(loop_start);
+  __ mr(R7_ARG5, intSlot);  __ b(loop_start);
+  __ mr(R8_ARG6, intSlot);  __ b(loop_start);
+  __ mr(R9_ARG7, intSlot);  __ b(loop_start);
+  __ mr(R10_ARG8, intSlot); __ b(loop_start);
+
+  __ bind(move_float_arg); // each case must consist of 2 instructions (otherwise adapt LogSizeOfTwoInstructions)
+  __ fmr(F1_ARG1, floatSlot);   __ b(loop_start);
+  __ fmr(F2_ARG2, floatSlot);   __ b(loop_start);
+  __ fmr(F3_ARG3, floatSlot);   __ b(loop_start);
+  __ fmr(F4_ARG4, floatSlot);   __ b(loop_start);
+  __ fmr(F5_ARG5, floatSlot);   __ b(loop_start);
+  __ fmr(F6_ARG6, floatSlot);   __ b(loop_start);
+  __ fmr(F7_ARG7, floatSlot);   __ b(loop_start);
+  __ fmr(F8_ARG8, floatSlot);   __ b(loop_start);
+  __ fmr(F9_ARG9, floatSlot);   __ b(loop_start);
+  __ fmr(F10_ARG10, floatSlot); __ b(loop_start);
+  __ fmr(F11_ARG11, floatSlot); __ b(loop_start);
+  __ fmr(F12_ARG12, floatSlot); __ b(loop_start);
+  __ fmr(F13_ARG13, floatSlot); __ b(loop_start);
+
+  __ bind(move_intSlot_to_ARG);
+  __ sldi(R0, argcnt, LogSizeOfTwoInstructions);
+  __ load_const(R11_scratch1, move_int_arg); // Label must be bound here.
+  __ add(R11_scratch1, R0, R11_scratch1);
+  __ mtctr(R11_scratch1/*branch_target*/);
+  __ bctr();
+  __ bind(move_floatSlot_to_FARG);
+  __ sldi(R0, fpcnt, LogSizeOfTwoInstructions);
+  __ addi(fpcnt, fpcnt, 1);
+  __ load_const(R11_scratch1, move_float_arg); // Label must be bound here.
+  __ add(R11_scratch1, R0, R11_scratch1);
+  __ mtctr(R11_scratch1/*branch_target*/);
+  __ bctr();
+
+  return entry;
+}
+
+address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type) {
+  //
+  // Registers alive
+  //   R3_RET
+  //   LR
+  //
+  // Registers updated
+  //   R3_RET
+  //
+
+  Label done;
+  address entry = __ pc();
+
+  switch (type) {
+  case T_BOOLEAN:
+    // convert !=0 to 1
+    __ neg(R0, R3_RET);
+    __ orr(R0, R3_RET, R0);
+    __ srwi(R3_RET, R0, 31);
+    break;
+  case T_BYTE:
+     // sign extend 8 bits
+     __ extsb(R3_RET, R3_RET);
+     break;
+  case T_CHAR:
+     // zero extend 16 bits
+     __ clrldi(R3_RET, R3_RET, 48);
+     break;
+  case T_SHORT:
+     // sign extend 16 bits
+     __ extsh(R3_RET, R3_RET);
+     break;
+  case T_INT:
+     // sign extend 32 bits
+     __ extsw(R3_RET, R3_RET);
+     break;
+  case T_LONG:
+     break;
+  case T_OBJECT:
+    // unbox result if not null
+    __ cmpdi(CCR0, R3_RET, 0);
+    __ beq(CCR0, done);
+    __ ld(R3_RET, 0, R3_RET);
+    __ verify_oop(R3_RET);
+    break;
+  case T_FLOAT:
+     break;
+  case T_DOUBLE:
+     break;
+  case T_VOID:
+     break;
+  default: ShouldNotReachHere();
+  }
+
+  BIND(done);
+  __ blr();
+
+  return entry;
+}
+
+// Abstract method entry.
+//
+address TemplateInterpreterGenerator::generate_abstract_entry(void) {
+  address entry = __ pc();
+
+  //
+  // Registers alive
+  //   R16_thread     - JavaThread*
+  //   R19_method     - callee's method (method to be invoked)
+  //   R1_SP          - SP prepared such that caller's outgoing args are near top
+  //   LR             - return address to caller
+  //
+  // Stack layout at this point:
+  //
+  //   0       [TOP_IJAVA_FRAME_ABI]         <-- R1_SP
+  //           alignment (optional)
+  //           [outgoing Java arguments]
+  //           ...
+  //   PARENT  [PARENT_IJAVA_FRAME_ABI]
+  //            ...
+  //
+
+  // Can't use call_VM here because we have not set up a new
+  // interpreter state. Make the call to the vm and make it look like
+  // our caller set up the JavaFrameAnchor.
+  __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R12_scratch2/*tmp*/);
+
+  // Push a new C frame and save LR.
+  __ save_LR_CR(R0);
+  __ push_frame_reg_args(0, R11_scratch1);
+
+  // This is not a leaf but we have a JavaFrameAnchor now and we will
+  // check (create) exceptions afterward so this is ok.
+  __ call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError),
+                  R16_thread);
+
+  // Pop the C frame and restore LR.
+  __ pop_frame();
+  __ restore_LR_CR(R0);
+
+  // Reset JavaFrameAnchor from call_VM_leaf above.
+  __ reset_last_Java_frame();
+
+  // We don't know our caller, so jump to the general forward exception stub,
+  // which will also pop our full frame off. Satisfy the interface of
+  // SharedRuntime::generate_forward_exception()
+  __ load_const_optimized(R11_scratch1, StubRoutines::forward_exception_entry(), R0);
+  __ mtctr(R11_scratch1);
+  __ bctr();
+
+  return entry;
+}
+
+// Interpreter intrinsic for WeakReference.get().
+// 1. Don't push a full blown frame and go on dispatching, but fetch the value
+//    into R8 and return quickly
+// 2. If G1 is active we *must* execute this intrinsic for corrrectness:
+//    It contains a GC barrier which puts the reference into the satb buffer
+//    to indicate that someone holds a strong reference to the object the
+//    weak ref points to!
+address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
+  // Code: _aload_0, _getfield, _areturn
+  // parameter size = 1
+  //
+  // The code that gets generated by this routine is split into 2 parts:
+  //    1. the "intrinsified" code for G1 (or any SATB based GC),
+  //    2. the slow path - which is an expansion of the regular method entry.
+  //
+  // Notes:
+  // * In the G1 code we do not check whether we need to block for
+  //   a safepoint. If G1 is enabled then we must execute the specialized
+  //   code for Reference.get (except when the Reference object is null)
+  //   so that we can log the value in the referent field with an SATB
+  //   update buffer.
+  //   If the code for the getfield template is modified so that the
+  //   G1 pre-barrier code is executed when the current method is
+  //   Reference.get() then going through the normal method entry
+  //   will be fine.
+  // * The G1 code can, however, check the receiver object (the instance
+  //   of java.lang.Reference) and jump to the slow path if null. If the
+  //   Reference object is null then we obviously cannot fetch the referent
+  //   and so we don't need to call the G1 pre-barrier. Thus we can use the
+  //   regular method entry code to generate the NPE.
+  //
+
+  if (UseG1GC) {
+    address entry = __ pc();
+
+    const int referent_offset = java_lang_ref_Reference::referent_offset;
+    guarantee(referent_offset > 0, "referent offset not initialized");
+
+    Label slow_path;
+
+    // Debugging not possible, so can't use __ skip_if_jvmti_mode(slow_path, GR31_SCRATCH);
+
+    // In the G1 code we don't check if we need to reach a safepoint. We
+    // continue and the thread will safepoint at the next bytecode dispatch.
+
+    // If the receiver is null then it is OK to jump to the slow path.
+    __ ld(R3_RET, Interpreter::stackElementSize, R15_esp); // get receiver
+
+    // Check if receiver == NULL and go the slow path.
+    __ cmpdi(CCR0, R3_RET, 0);
+    __ beq(CCR0, slow_path);
+
+    // Load the value of the referent field.
+    __ load_heap_oop(R3_RET, referent_offset, R3_RET);
+
+    // Generate the G1 pre-barrier code to log the value of
+    // the referent field in an SATB buffer. Note with
+    // these parameters the pre-barrier does not generate
+    // the load of the previous value.
+
+    // Restore caller sp for c2i case.
+#ifdef ASSERT
+      __ ld(R9_ARG7, 0, R1_SP);
+      __ ld(R10_ARG8, 0, R21_sender_SP);
+      __ cmpd(CCR0, R9_ARG7, R10_ARG8);
+      __ asm_assert_eq("backlink", 0x544);
+#endif // ASSERT
+    __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started.
+
+    __ g1_write_barrier_pre(noreg,         // obj
+                            noreg,         // offset
+                            R3_RET,        // pre_val
+                            R11_scratch1,  // tmp
+                            R12_scratch2,  // tmp
+                            true);         // needs_frame
+
+    __ blr();
+
+    // Generate regular method entry.
+    __ bind(slow_path);
+    __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals), R11_scratch1);
+    return entry;
+  }
+
+  return NULL;
+}
+
 // Actually we should never reach here since we do stack overflow checks before pushing any frame.
 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
   address entry = __ pc();
@@ -222,12 +723,6 @@
   return entry;
 }
 
-// A result handler converts the native result into java format.
-// Use the shared code between c++ and template interpreter.
-address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type) {
-  return AbstractInterpreterGenerator::generate_result_handler_for(type);
-}
-
 address TemplateInterpreterGenerator::generate_safept_entry_for(TosState state, address runtime_entry) {
   address entry = __ pc();
 
@@ -602,7 +1097,7 @@
 // End of helpers
 
 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
-  if (!TemplateInterpreter::math_entry_available(kind)) {
+  if (!Interpreter::math_entry_available(kind)) {
     NOT_PRODUCT(__ should_not_reach_here();)
     return NULL;
   }
--- a/src/cpu/ppc/vm/templateInterpreter_ppc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015 SAP SE. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "interpreter/interpreter.hpp"
-#include "oops/constMethod.hpp"
-#include "oops/method.hpp"
-#include "runtime/frame.inline.hpp"
-#include "utilities/debug.hpp"
-#include "utilities/macros.hpp"
-
-// Size of interpreter code.  Increase if too small.  Interpreter will
-// fail with a guarantee ("not enough space for interpreter generation");
-// if too small.
-// Run with +PrintInterpreter to get the VM to print out the size.
-// Max size with JVMTI
-int TemplateInterpreter::InterpreterCodeSize = 230*K;
-
-int AbstractInterpreter::BasicType_as_index(BasicType type) {
-  int i = 0;
-  switch (type) {
-    case T_BOOLEAN: i = 0; break;
-    case T_CHAR   : i = 1; break;
-    case T_BYTE   : i = 2; break;
-    case T_SHORT  : i = 3; break;
-    case T_INT    : i = 4; break;
-    case T_LONG   : i = 5; break;
-    case T_VOID   : i = 6; break;
-    case T_FLOAT  : i = 7; break;
-    case T_DOUBLE : i = 8; break;
-    case T_OBJECT : i = 9; break;
-    case T_ARRAY  : i = 9; break;
-    default       : ShouldNotReachHere();
-  }
-  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
-  return i;
-}
-
-// These should never be compiled since the interpreter will prefer
-// the compiled version to the intrinsic version.
-bool AbstractInterpreter::can_be_compiled(methodHandle m) {
-  return !TemplateInterpreter::math_entry_available(method_kind(m));
-}
-
-// How much stack a method activation needs in stack slots.
-// We must calc this exactly like in generate_fixed_frame.
-// Note: This returns the conservative size assuming maximum alignment.
-int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
-  const int max_alignment_size = 2;
-  const int abi_scratch = frame::abi_reg_args_size;
-  return method->max_locals() + method->max_stack() +
-         frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
-}
-
-// Returns number of stackElementWords needed for the interpreter frame with the
-// given sections.
-// This overestimates the stack by one slot in case of alignments.
-int AbstractInterpreter::size_activation(int max_stack,
-                                         int temps,
-                                         int extra_args,
-                                         int monitors,
-                                         int callee_params,
-                                         int callee_locals,
-                                         bool is_top_frame) {
-  // Note: This calculation must exactly parallel the frame setup
-  // in TemplateInterpreterGenerator::generate_fixed_frame.
-  assert(Interpreter::stackElementWords == 1, "sanity");
-  const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;
-  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
-                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
-  const int size =
-    max_stack                                                +
-    (callee_locals - callee_params)                          +
-    monitors * frame::interpreter_frame_monitor_size()       +
-    max_alignment_space                                      +
-    abi_scratch                                              +
-    frame::ijava_state_size / Interpreter::stackElementSize;
-
-  // Fixed size of an interpreter frame, align to 16-byte.
-  return (size & -2);
-}
-
-// Fills a sceletal interpreter frame generated during deoptimizations.
-//
-// Parameters:
-//
-// interpreter_frame != NULL:
-//   set up the method, locals, and monitors.
-//   The frame interpreter_frame, if not NULL, is guaranteed to be the
-//   right size, as determined by a previous call to this method.
-//   It is also guaranteed to be walkable even though it is in a skeletal state
-//
-// is_top_frame == true:
-//   We're processing the *oldest* interpreter frame!
-//
-// pop_frame_extra_args:
-//   If this is != 0 we are returning to a deoptimized frame by popping
-//   off the callee frame. We want to re-execute the call that called the
-//   callee interpreted, but since the return to the interpreter would pop
-//   the arguments off advance the esp by dummy popframe_extra_args slots.
-//   Popping off those will establish the stack layout as it was before the call.
-//
-void AbstractInterpreter::layout_activation(Method* method,
-                                            int tempcount,
-                                            int popframe_extra_args,
-                                            int moncount,
-                                            int caller_actual_parameters,
-                                            int callee_param_count,
-                                            int callee_locals_count,
-                                            frame* caller,
-                                            frame* interpreter_frame,
-                                            bool is_top_frame,
-                                            bool is_bottom_frame) {
-
-  const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
-                                         (frame::abi_minframe_size / Interpreter::stackElementSize);
-
-  intptr_t* locals_base  = (caller->is_interpreted_frame()) ?
-    caller->interpreter_frame_esp() + caller_actual_parameters :
-    caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize);
-
-  intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize;
-  intptr_t* monitor      = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
-  intptr_t* esp_base     = monitor - 1;
-  intptr_t* esp          = esp_base - tempcount - popframe_extra_args;
-  intptr_t* sp           = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
-  intptr_t* sender_sp    = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
-  intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
-
-  interpreter_frame->interpreter_frame_set_method(method);
-  interpreter_frame->interpreter_frame_set_locals(locals_base);
-  interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
-  interpreter_frame->interpreter_frame_set_esp(esp);
-  interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
-  interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
-  if (!is_bottom_frame) {
-    interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
-  }
-}
-
-// Support abs and sqrt like in compiler.
-// For others we can use a normal (native) entry.
-
-bool TemplateInterpreter::math_entry_available(AbstractInterpreter::MethodKind kind) {
-  if (!InlineIntrinsics) return false;
-
-  return ((kind==Interpreter::java_lang_math_sqrt && VM_Version::has_fsqrt()) ||
-          (kind==Interpreter::java_lang_math_abs));
-}
-
-
--- a/src/cpu/ppc/vm/templateInterpreter_ppc.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013, 2015 SAP SE. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef CPU_PPC_VM_TEMPLATEINTERPRETER_PPC_HPP
-#define CPU_PPC_VM_TEMPLATEINTERPRETER_PPC_HPP
-
- protected:
-
-  // Size of interpreter code. Increase if too small.  Interpreter will
-  // fail with a guarantee ("not enough space for interpreter generation");
-  // if too small.
-  // Run with +PrintInterpreter to get the VM to print out the size.
-  // Max size with JVMTI
-  const static int InterpreterCodeSize = 230*K;
-
- public:
-  // Support abs and sqrt like in compiler.
-  // For others we can use a normal (native) entry.
-  static bool math_entry_available(AbstractInterpreter::MethodKind kind);
-#endif // CPU_PPC_VM_TEMPLATEINTERPRETER_PPC_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -0,0 +1,304 @@
+/*
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "interpreter/interpreter.hpp"
+#include "oops/constMethod.hpp"
+#include "oops/method.hpp"
+#include "runtime/arguments.hpp"
+#include "runtime/frame.inline.hpp"
+#include "runtime/synchronizer.hpp"
+#include "utilities/macros.hpp"
+
+
+int AbstractInterpreter::BasicType_as_index(BasicType type) {
+  int i = 0;
+  switch (type) {
+    case T_BOOLEAN: i = 0; break;
+    case T_CHAR   : i = 1; break;
+    case T_BYTE   : i = 2; break;
+    case T_SHORT  : i = 3; break;
+    case T_INT    : i = 4; break;
+    case T_LONG   : i = 5; break;
+    case T_VOID   : i = 6; break;
+    case T_FLOAT  : i = 7; break;
+    case T_DOUBLE : i = 8; break;
+    case T_OBJECT : i = 9; break;
+    case T_ARRAY  : i = 9; break;
+    default       : ShouldNotReachHere();
+  }
+  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
+  return i;
+}
+
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  // No special entry points that preclude compilation
+  return true;
+}
+
+static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
+
+  // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
+  // expression stack, the callee will have callee_extra_locals (so we can account for
+  // frame extension) and monitor_size for monitors. Basically we need to calculate
+  // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
+  //
+  //
+  // The big complicating thing here is that we must ensure that the stack stays properly
+  // aligned. This would be even uglier if monitor size wasn't modulo what the stack
+  // needs to be aligned for). We are given that the sp (fp) is already aligned by
+  // the caller so we must ensure that it is properly aligned for our callee.
+  //
+  const int rounded_vm_local_words =
+       round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
+  // callee_locals and max_stack are counts, not the size in frame.
+  const int locals_size =
+       round_to(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong);
+  const int max_stack_words = max_stack * Interpreter::stackElementWords;
+  return (round_to((max_stack_words
+                   + rounded_vm_local_words
+                   + frame::memory_parameter_word_sp_offset), WordsPerLong)
+                   // already rounded
+                   + locals_size + monitor_size);
+}
+
+// How much stack a method top interpreter activation needs in words.
+int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
+
+  // See call_stub code
+  int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
+                                 WordsPerLong);    // 7 + register save area
+
+  // Save space for one monitor to get into the interpreted method in case
+  // the method is synchronized
+  int monitor_size    = method->is_synchronized() ?
+                                1*frame::interpreter_frame_monitor_size() : 0;
+  return size_activation_helper(method->max_locals(), method->max_stack(),
+                                monitor_size) + call_stub_size;
+}
+
+int AbstractInterpreter::size_activation(int max_stack,
+                                         int temps,
+                                         int extra_args,
+                                         int monitors,
+                                         int callee_params,
+                                         int callee_locals,
+                                         bool is_top_frame) {
+  // Note: This calculation must exactly parallel the frame setup
+  // in TemplateInterpreterGenerator::generate_fixed_frame.
+
+  int monitor_size           = monitors * frame::interpreter_frame_monitor_size();
+
+  assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
+
+  //
+  // Note: if you look closely this appears to be doing something much different
+  // than generate_fixed_frame. What is happening is this. On sparc we have to do
+  // this dance with interpreter_sp_adjustment because the window save area would
+  // appear just below the bottom (tos) of the caller's java expression stack. Because
+  // the interpreter want to have the locals completely contiguous generate_fixed_frame
+  // will adjust the caller's sp for the "extra locals" (max_locals - parameter_size).
+  // Now in generate_fixed_frame the extension of the caller's sp happens in the callee.
+  // In this code the opposite occurs the caller adjusts it's own stack base on the callee.
+  // This is mostly ok but it does cause a problem when we get to the initial frame (the oldest)
+  // because the oldest frame would have adjust its callers frame and yet that frame
+  // already exists and isn't part of this array of frames we are unpacking. So at first
+  // glance this would seem to mess up that frame. However Deoptimization::fetch_unroll_info_helper()
+  // will after it calculates all of the frame's on_stack_size()'s will then figure out the
+  // amount to adjust the caller of the initial (oldest) frame and the calculation will all
+  // add up. It does seem like it simpler to account for the adjustment here (and remove the
+  // callee... parameters here). However this would mean that this routine would have to take
+  // the caller frame as input so we could adjust its sp (and set it's interpreter_sp_adjustment)
+  // and run the calling loop in the reverse order. This would also would appear to mean making
+  // this code aware of what the interactions are when that initial caller fram was an osr or
+  // other adapter frame. deoptimization is complicated enough and  hard enough to debug that
+  // there is no sense in messing working code.
+  //
+
+  int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong);
+  assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align");
+
+  int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size);
+
+  return raw_frame_size;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+                                            int tempcount,
+                                            int popframe_extra_args,
+                                            int moncount,
+                                            int caller_actual_parameters,
+                                            int callee_param_count,
+                                            int callee_local_count,
+                                            frame* caller,
+                                            frame* interpreter_frame,
+                                            bool is_top_frame,
+                                            bool is_bottom_frame) {
+  // Set up the following variables:
+  //   - Lmethod
+  //   - Llocals
+  //   - Lmonitors (to the indicated number of monitors)
+  //   - Lesp (to the indicated number of temps)
+  // The frame caller on entry is a description of the caller of the
+  // frame we are about to layout. We are guaranteed that we will be
+  // able to fill in a new interpreter frame as its callee (i.e. the
+  // stack space is allocated and the amount was determined by an
+  // earlier call to the size_activation() method).  On return caller
+  // while describe the interpreter frame we just layed out.
+
+  // The skeleton frame must already look like an interpreter frame
+  // even if not fully filled out.
+  assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
+
+  int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
+  int monitor_size           = moncount * frame::interpreter_frame_monitor_size();
+  assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
+
+  intptr_t* fp = interpreter_frame->fp();
+
+  JavaThread* thread = JavaThread::current();
+  RegisterMap map(thread, false);
+  // More verification that skeleton frame is properly walkable
+  assert(fp == caller->sp(), "fp must match");
+
+  intptr_t* montop     = fp - rounded_vm_local_words;
+
+  // preallocate monitors (cf. __ add_monitor_to_stack)
+  intptr_t* monitors = montop - monitor_size;
+
+  // preallocate stack space
+  intptr_t*  esp = monitors - 1 -
+    (tempcount * Interpreter::stackElementWords) -
+    popframe_extra_args;
+
+  int local_words = method->max_locals() * Interpreter::stackElementWords;
+  NEEDS_CLEANUP;
+  intptr_t* locals;
+  if (caller->is_interpreted_frame()) {
+    // Can force the locals area to end up properly overlapping the top of the expression stack.
+    intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
+    // Note that this computation means we replace size_of_parameters() values from the caller
+    // interpreter frame's expression stack with our argument locals
+    int parm_words  = caller_actual_parameters * Interpreter::stackElementWords;
+    locals = Lesp_ptr + parm_words;
+    int delta = local_words - parm_words;
+    int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
+    *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
+    if (!is_bottom_frame) {
+      // Llast_SP is set below for the current frame to SP (with the
+      // extra space for the callee's locals). Here we adjust
+      // Llast_SP for the caller's frame, removing the extra space
+      // for the current method's locals.
+      *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
+    } else {
+      assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
+    }
+  } else {
+    assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
+    // Don't have Lesp available; lay out locals block in the caller
+    // adjacent to the register window save area.
+    //
+    // Compiled frames do not allocate a varargs area which is why this if
+    // statement is needed.
+    //
+    if (caller->is_compiled_frame()) {
+      locals = fp + frame::register_save_words + local_words - 1;
+    } else {
+      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
+    }
+    if (!caller->is_entry_frame()) {
+      // Caller wants his own SP back
+      int caller_frame_size = caller->cb()->frame_size();
+      *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
+    }
+  }
+  if (TraceDeoptimization) {
+    if (caller->is_entry_frame()) {
+      // make sure I5_savedSP and the entry frames notion of saved SP
+      // agree.  This assertion duplicate a check in entry frame code
+      // but catches the failure earlier.
+      assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
+             "would change callers SP");
+    }
+    if (caller->is_entry_frame()) {
+      tty->print("entry ");
+    }
+    if (caller->is_compiled_frame()) {
+      tty->print("compiled ");
+      if (caller->is_deoptimized_frame()) {
+        tty->print("(deopt) ");
+      }
+    }
+    if (caller->is_interpreted_frame()) {
+      tty->print("interpreted ");
+    }
+    tty->print_cr("caller fp=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, p2i(caller->fp()), p2i(caller->sp()));
+    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(caller->sp()), p2i(caller->sp() + 16));
+    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(caller->fp()), p2i(caller->fp() + 16));
+    tty->print_cr("interpreter fp=" INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->fp()), p2i(interpreter_frame->sp()));
+    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->sp()), p2i(interpreter_frame->sp() + 16));
+    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->fp()), p2i(interpreter_frame->fp() + 16));
+    tty->print_cr("Llocals = " INTPTR_FORMAT, p2i(locals));
+    tty->print_cr("Lesp = " INTPTR_FORMAT, p2i(esp));
+    tty->print_cr("Lmonitors = " INTPTR_FORMAT, p2i(monitors));
+  }
+
+  if (method->max_locals() > 0) {
+    assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
+    assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
+    assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
+    assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
+  }
+#ifdef _LP64
+  assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
+#endif
+
+  *interpreter_frame->register_addr(Lmethod)     = (intptr_t) method;
+  *interpreter_frame->register_addr(Llocals)     = (intptr_t) locals;
+  *interpreter_frame->register_addr(Lmonitors)   = (intptr_t) monitors;
+  *interpreter_frame->register_addr(Lesp)        = (intptr_t) esp;
+  // Llast_SP will be same as SP as there is no adapter space
+  *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
+  *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
+#ifdef FAST_DISPATCH
+  *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
+#endif
+
+
+#ifdef ASSERT
+  BasicObjectLock* mp = (BasicObjectLock*)monitors;
+
+  assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
+  assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
+  assert(interpreter_frame->interpreter_frame_monitor_end()   == mp, "monitor_end matches");
+  assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
+  assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
+
+  // check bounds
+  intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
+  intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
+  assert(lo < monitors && montop <= hi, "monitors in bounds");
+  assert(lo <= esp && esp < monitors, "esp in bounds");
+#endif // ASSERT
+}
--- a/src/cpu/sparc/vm/interpreter_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
-#include "interpreter/bytecodeHistogram.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/interp_masm.hpp"
-#include "interpreter/templateInterpreterGenerator.hpp"
-#include "interpreter/templateTable.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "prims/methodHandles.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/timer.hpp"
-#include "runtime/vframeArray.hpp"
-#include "utilities/debug.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-
-
-
-// Generation of Interpreter
-//
-// The TemplateInterpreterGenerator generates the interpreter into Interpreter::_code.
-
-
-#define __ _masm->
-
-
-//----------------------------------------------------------------------------------------------------
-
-#ifndef _LP64
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  address entry = __ pc();
-  Argument argv(0, true);
-
-  // We are in the jni transition frame. Save the last_java_frame corresponding to the
-  // outer interpreter frame
-  //
-  __ set_last_Java_frame(FP, noreg);
-  // make sure the interpreter frame we've pushed has a valid return pc
-  __ mov(O7, I7);
-  __ mov(Lmethod, G3_scratch);
-  __ mov(Llocals, G4_scratch);
-  __ save_frame(0);
-  __ mov(G2_thread, L7_thread_cache);
-  __ add(argv.address_in_frame(), O3);
-  __ mov(G2_thread, O0);
-  __ mov(G3_scratch, O1);
-  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
-  __ delayed()->mov(G4_scratch, O2);
-  __ mov(L7_thread_cache, G2_thread);
-  __ reset_last_Java_frame();
-
-  // load the register arguments (the C code packed them as varargs)
-  for (Argument ldarg = argv.successor(); ldarg.is_register(); ldarg = ldarg.successor()) {
-      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
-  }
-  __ ret();
-  __ delayed()->
-     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
-  return entry;
-}
-
-
-#else
-// LP64 passes floating point arguments in F1, F3, F5, etc. instead of
-// O0, O1, O2 etc..
-// Doubles are passed in D0, D2, D4
-// We store the signature of the first 16 arguments in the first argument
-// slot because it will be overwritten prior to calling the native
-// function, with the pointer to the JNIEnv.
-// If LP64 there can be up to 16 floating point arguments in registers
-// or 6 integer registers.
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-
-  enum {
-    non_float  = 0,
-    float_sig  = 1,
-    double_sig = 2,
-    sig_mask   = 3
-  };
-
-  address entry = __ pc();
-  Argument argv(0, true);
-
-  // We are in the jni transition frame. Save the last_java_frame corresponding to the
-  // outer interpreter frame
-  //
-  __ set_last_Java_frame(FP, noreg);
-  // make sure the interpreter frame we've pushed has a valid return pc
-  __ mov(O7, I7);
-  __ mov(Lmethod, G3_scratch);
-  __ mov(Llocals, G4_scratch);
-  __ save_frame(0);
-  __ mov(G2_thread, L7_thread_cache);
-  __ add(argv.address_in_frame(), O3);
-  __ mov(G2_thread, O0);
-  __ mov(G3_scratch, O1);
-  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
-  __ delayed()->mov(G4_scratch, O2);
-  __ mov(L7_thread_cache, G2_thread);
-  __ reset_last_Java_frame();
-
-
-  // load the register arguments (the C code packed them as varargs)
-  Address Sig = argv.address_in_frame();        // Argument 0 holds the signature
-  __ ld_ptr( Sig, G3_scratch );                   // Get register argument signature word into G3_scratch
-  __ mov( G3_scratch, G4_scratch);
-  __ srl( G4_scratch, 2, G4_scratch);             // Skip Arg 0
-  Label done;
-  for (Argument ldarg = argv.successor(); ldarg.is_float_register(); ldarg = ldarg.successor()) {
-    Label NonFloatArg;
-    Label LoadFloatArg;
-    Label LoadDoubleArg;
-    Label NextArg;
-    Address a = ldarg.address_in_frame();
-    __ andcc(G4_scratch, sig_mask, G3_scratch);
-    __ br(Assembler::zero, false, Assembler::pt, NonFloatArg);
-    __ delayed()->nop();
-
-    __ cmp(G3_scratch, float_sig );
-    __ br(Assembler::equal, false, Assembler::pt, LoadFloatArg);
-    __ delayed()->nop();
-
-    __ cmp(G3_scratch, double_sig );
-    __ br(Assembler::equal, false, Assembler::pt, LoadDoubleArg);
-    __ delayed()->nop();
-
-    __ bind(NonFloatArg);
-    // There are only 6 integer register arguments!
-    if ( ldarg.is_register() )
-      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
-    else {
-    // Optimization, see if there are any more args and get out prior to checking
-    // all 16 float registers.  My guess is that this is rare.
-    // If is_register is false, then we are done the first six integer args.
-      __ br_null_short(G4_scratch, Assembler::pt, done);
-    }
-    __ ba(NextArg);
-    __ delayed()->srl( G4_scratch, 2, G4_scratch );
-
-    __ bind(LoadFloatArg);
-    __ ldf( FloatRegisterImpl::S, a, ldarg.as_float_register(), 4);
-    __ ba(NextArg);
-    __ delayed()->srl( G4_scratch, 2, G4_scratch );
-
-    __ bind(LoadDoubleArg);
-    __ ldf( FloatRegisterImpl::D, a, ldarg.as_double_register() );
-    __ ba(NextArg);
-    __ delayed()->srl( G4_scratch, 2, G4_scratch );
-
-    __ bind(NextArg);
-
-  }
-
-  __ bind(done);
-  __ ret();
-  __ delayed()->
-     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
-  return entry;
-}
-#endif
-
-void TemplateInterpreterGenerator::generate_counter_overflow(Label& Lcontinue) {
-
-  // Generate code to initiate compilation on the counter overflow.
-
-  // InterpreterRuntime::frequency_counter_overflow takes two arguments,
-  // the first indicates if the counter overflow occurs at a backwards branch (NULL bcp)
-  // and the second is only used when the first is true.  We pass zero for both.
-  // The call returns the address of the verified entry point for the method or NULL
-  // if the compilation did not complete (either went background or bailed out).
-  __ set((int)false, O2);
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), O2, O2, true);
-  // returns verified_entry_point or NULL
-  // we ignore it in any case
-  __ ba_short(Lcontinue);
-
-}
-
-
-// End of helpers
-
-// Various method entries
-
-// Abstract method entry
-// Attempt to execute abstract method. Throw exception
-//
-address TemplateInterpreterGenerator::generate_abstract_entry(void) {
-  address entry = __ pc();
-  // abstract method entry
-  // throw exception
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
-  // the call_VM checks for exception, so we should never return here.
-  __ should_not_reach_here();
-  return entry;
-
-}
--- a/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/sparc/vm/macroAssembler_sparc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3386,10 +3386,20 @@
   // Retain tlab and allocate object in shared space if
   // the amount free in the tlab is too large to discard.
   cmp(t1, t2);
+
   brx(Assembler::lessEqual, false, Assembler::pt, discard_tlab);
-
   // increment waste limit to prevent getting stuck on this slow path
-  delayed()->add(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment(), t2);
+  if (Assembler::is_simm13(ThreadLocalAllocBuffer::refill_waste_limit_increment())) {
+    delayed()->add(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment(), t2);
+  } else {
+    delayed()->nop();
+    // set64 does not use the temp register if the given constant is 32 bit. So
+    // we can just use any register; using G0 results in ignoring of the upper 32 bit
+    // of that value.
+    set64(ThreadLocalAllocBuffer::refill_waste_limit_increment(), t3, G0);
+    add(t2, t3, t2);
+  }
+
   st_ptr(t2, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
   if (TLABStats) {
     // increment number of slow_allocations
--- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1748,7 +1748,7 @@
 }
 
 
-// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// 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
 // forced.  Save down any oops in registers and describe them in an
 // OopMap.
@@ -1759,9 +1759,9 @@
                                                OopMapSet* oop_maps,
                                                VMRegPair* in_regs,
                                                BasicType* in_sig_bt) {
-  __ block_comment("check GC_locker::needs_gc");
+  __ block_comment("check GCLocker::needs_gc");
   Label cont;
-  AddressLiteral sync_state(GC_locker::needs_gc_address());
+  AddressLiteral sync_state(GCLocker::needs_gc_address());
   __ load_bool_contents(sync_state, G3_scratch);
   __ cmp_zero_and_br(Assembler::equal, G3_scratch, cont);
   __ delayed()->nop();
@@ -1936,14 +1936,14 @@
 // GetPrimtiveArrayCritical and disallow the use of any other JNI
 // functions.  The wrapper is expected to unpack the arguments before
 // passing them to the callee and perform checks before and after the
-// native call to ensure that they GC_locker
+// native call to ensure that they GCLocker
 // lock_critical/unlock_critical semantics are followed.  Some other
 // parts of JNI setup are skipped like the tear down of the JNI handle
 // block and the check for pending exceptions it's impossible for them
 // to be thrown.
 //
 // They are roughly structured like this:
-//    if (GC_locker::needs_gc())
+//    if (GCLocker::needs_gc())
 //      SharedRuntime::block_for_jni_critical();
 //    tranistion to thread_in_native
 //    unpack arrray arguments and call native entry point
--- a/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,18 @@
 #endif
 #undef FAST_DISPATCH
 
+// Size of interpreter code.  Increase if too small.  Interpreter will
+// fail with a guarantee ("not enough space for interpreter generation");
+// if too small.
+// Run with +PrintInterpreter to get the VM to print out the size.
+// Max size with JVMTI
+#ifdef _LP64
+  // The sethi() instruction generates lots more instructions when shell
+  // stack limit is unlimited, so that's why this is much bigger.
+int TemplateInterpreter::InterpreterCodeSize = 260 * K;
+#else
+int TemplateInterpreter::InterpreterCodeSize = 230 * K;
+#endif
 
 // Generation of Interpreter
 //
@@ -63,6 +75,174 @@
 
 //----------------------------------------------------------------------------------------------------
 
+#ifndef _LP64
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+  address entry = __ pc();
+  Argument argv(0, true);
+
+  // We are in the jni transition frame. Save the last_java_frame corresponding to the
+  // outer interpreter frame
+  //
+  __ set_last_Java_frame(FP, noreg);
+  // make sure the interpreter frame we've pushed has a valid return pc
+  __ mov(O7, I7);
+  __ mov(Lmethod, G3_scratch);
+  __ mov(Llocals, G4_scratch);
+  __ save_frame(0);
+  __ mov(G2_thread, L7_thread_cache);
+  __ add(argv.address_in_frame(), O3);
+  __ mov(G2_thread, O0);
+  __ mov(G3_scratch, O1);
+  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
+  __ delayed()->mov(G4_scratch, O2);
+  __ mov(L7_thread_cache, G2_thread);
+  __ reset_last_Java_frame();
+
+  // load the register arguments (the C code packed them as varargs)
+  for (Argument ldarg = argv.successor(); ldarg.is_register(); ldarg = ldarg.successor()) {
+      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
+  }
+  __ ret();
+  __ delayed()->
+     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
+  return entry;
+}
+
+
+#else
+// LP64 passes floating point arguments in F1, F3, F5, etc. instead of
+// O0, O1, O2 etc..
+// Doubles are passed in D0, D2, D4
+// We store the signature of the first 16 arguments in the first argument
+// slot because it will be overwritten prior to calling the native
+// function, with the pointer to the JNIEnv.
+// If LP64 there can be up to 16 floating point arguments in registers
+// or 6 integer registers.
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+
+  enum {
+    non_float  = 0,
+    float_sig  = 1,
+    double_sig = 2,
+    sig_mask   = 3
+  };
+
+  address entry = __ pc();
+  Argument argv(0, true);
+
+  // We are in the jni transition frame. Save the last_java_frame corresponding to the
+  // outer interpreter frame
+  //
+  __ set_last_Java_frame(FP, noreg);
+  // make sure the interpreter frame we've pushed has a valid return pc
+  __ mov(O7, I7);
+  __ mov(Lmethod, G3_scratch);
+  __ mov(Llocals, G4_scratch);
+  __ save_frame(0);
+  __ mov(G2_thread, L7_thread_cache);
+  __ add(argv.address_in_frame(), O3);
+  __ mov(G2_thread, O0);
+  __ mov(G3_scratch, O1);
+  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
+  __ delayed()->mov(G4_scratch, O2);
+  __ mov(L7_thread_cache, G2_thread);
+  __ reset_last_Java_frame();
+
+
+  // load the register arguments (the C code packed them as varargs)
+  Address Sig = argv.address_in_frame();        // Argument 0 holds the signature
+  __ ld_ptr( Sig, G3_scratch );                   // Get register argument signature word into G3_scratch
+  __ mov( G3_scratch, G4_scratch);
+  __ srl( G4_scratch, 2, G4_scratch);             // Skip Arg 0
+  Label done;
+  for (Argument ldarg = argv.successor(); ldarg.is_float_register(); ldarg = ldarg.successor()) {
+    Label NonFloatArg;
+    Label LoadFloatArg;
+    Label LoadDoubleArg;
+    Label NextArg;
+    Address a = ldarg.address_in_frame();
+    __ andcc(G4_scratch, sig_mask, G3_scratch);
+    __ br(Assembler::zero, false, Assembler::pt, NonFloatArg);
+    __ delayed()->nop();
+
+    __ cmp(G3_scratch, float_sig );
+    __ br(Assembler::equal, false, Assembler::pt, LoadFloatArg);
+    __ delayed()->nop();
+
+    __ cmp(G3_scratch, double_sig );
+    __ br(Assembler::equal, false, Assembler::pt, LoadDoubleArg);
+    __ delayed()->nop();
+
+    __ bind(NonFloatArg);
+    // There are only 6 integer register arguments!
+    if ( ldarg.is_register() )
+      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
+    else {
+    // Optimization, see if there are any more args and get out prior to checking
+    // all 16 float registers.  My guess is that this is rare.
+    // If is_register is false, then we are done the first six integer args.
+      __ br_null_short(G4_scratch, Assembler::pt, done);
+    }
+    __ ba(NextArg);
+    __ delayed()->srl( G4_scratch, 2, G4_scratch );
+
+    __ bind(LoadFloatArg);
+    __ ldf( FloatRegisterImpl::S, a, ldarg.as_float_register(), 4);
+    __ ba(NextArg);
+    __ delayed()->srl( G4_scratch, 2, G4_scratch );
+
+    __ bind(LoadDoubleArg);
+    __ ldf( FloatRegisterImpl::D, a, ldarg.as_double_register() );
+    __ ba(NextArg);
+    __ delayed()->srl( G4_scratch, 2, G4_scratch );
+
+    __ bind(NextArg);
+
+  }
+
+  __ bind(done);
+  __ ret();
+  __ delayed()->
+     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
+  return entry;
+}
+#endif
+
+void TemplateInterpreterGenerator::generate_counter_overflow(Label& Lcontinue) {
+
+  // Generate code to initiate compilation on the counter overflow.
+
+  // InterpreterRuntime::frequency_counter_overflow takes two arguments,
+  // the first indicates if the counter overflow occurs at a backwards branch (NULL bcp)
+  // and the second is only used when the first is true.  We pass zero for both.
+  // The call returns the address of the verified entry point for the method or NULL
+  // if the compilation did not complete (either went background or bailed out).
+  __ set((int)false, O2);
+  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), O2, O2, true);
+  // returns verified_entry_point or NULL
+  // we ignore it in any case
+  __ ba_short(Lcontinue);
+
+}
+
+
+// End of helpers
+
+// Various method entries
+
+// Abstract method entry
+// Attempt to execute abstract method. Throw exception
+//
+address TemplateInterpreterGenerator::generate_abstract_entry(void) {
+  address entry = __ pc();
+  // abstract method entry
+  // throw exception
+  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
+  // the call_VM checks for exception, so we should never return here.
+  __ should_not_reach_here();
+  return entry;
+
+}
 
 void TemplateInterpreterGenerator::save_native_result(void) {
   // result potentially in O0/O1: save it across calls
@@ -911,6 +1091,31 @@
 address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
   return NULL;
 }
+
+// TODO: rather than touching all pages, check against stack_overflow_limit and bang yellow page to
+// generate exception
+void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
+  // Quick & dirty stack overflow checking: bang the stack & handle trap.
+  // Note that we do the banging after the frame is setup, since the exception
+  // handling code expects to find a valid interpreter frame on the stack.
+  // Doing the banging earlier fails if the caller frame is not an interpreter
+  // frame.
+  // (Also, the exception throwing code expects to unlock any synchronized
+  // method receiever, so do the banging after locking the receiver.)
+
+  // Bang each page in the shadow zone. We can't assume it's been done for
+  // an interpreter frame with greater than a page of locals, so each page
+  // needs to be checked.  Only true for non-native.
+  if (UseStackBanging) {
+    const int page_size = os::vm_page_size();
+    const int n_shadow_pages = ((int)JavaThread::stack_shadow_zone_size()) / page_size;
+    const int start_page = native_call ? n_shadow_pages : 1;
+    for (int pages = start_page; pages <= n_shadow_pages; pages++) {
+      __ bang_stack_with_offset(pages*page_size);
+    }
+  }
+}
+
 //
 // Interpreter stub for calling a native method. (asm interpreter)
 // This sets up a somewhat different looking stack for calling the native method
--- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,316 +0,0 @@
-/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "interpreter/interpreter.hpp"
-#include "oops/constMethod.hpp"
-#include "oops/method.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/synchronizer.hpp"
-#include "utilities/macros.hpp"
-
-// Size of interpreter code.  Increase if too small.  Interpreter will
-// fail with a guarantee ("not enough space for interpreter generation");
-// if too small.
-// Run with +PrintInterpreter to get the VM to print out the size.
-// Max size with JVMTI
-#ifdef _LP64
-  // The sethi() instruction generates lots more instructions when shell
-  // stack limit is unlimited, so that's why this is much bigger.
-int TemplateInterpreter::InterpreterCodeSize = 260 * K;
-#else
-int TemplateInterpreter::InterpreterCodeSize = 230 * K;
-#endif
-
-int AbstractInterpreter::BasicType_as_index(BasicType type) {
-  int i = 0;
-  switch (type) {
-    case T_BOOLEAN: i = 0; break;
-    case T_CHAR   : i = 1; break;
-    case T_BYTE   : i = 2; break;
-    case T_SHORT  : i = 3; break;
-    case T_INT    : i = 4; break;
-    case T_LONG   : i = 5; break;
-    case T_VOID   : i = 6; break;
-    case T_FLOAT  : i = 7; break;
-    case T_DOUBLE : i = 8; break;
-    case T_OBJECT : i = 9; break;
-    case T_ARRAY  : i = 9; break;
-    default       : ShouldNotReachHere();
-  }
-  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
-  return i;
-}
-
-bool AbstractInterpreter::can_be_compiled(methodHandle m) {
-  // No special entry points that preclude compilation
-  return true;
-}
-
-static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
-
-  // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
-  // expression stack, the callee will have callee_extra_locals (so we can account for
-  // frame extension) and monitor_size for monitors. Basically we need to calculate
-  // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
-  //
-  //
-  // The big complicating thing here is that we must ensure that the stack stays properly
-  // aligned. This would be even uglier if monitor size wasn't modulo what the stack
-  // needs to be aligned for). We are given that the sp (fp) is already aligned by
-  // the caller so we must ensure that it is properly aligned for our callee.
-  //
-  const int rounded_vm_local_words =
-       round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
-  // callee_locals and max_stack are counts, not the size in frame.
-  const int locals_size =
-       round_to(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong);
-  const int max_stack_words = max_stack * Interpreter::stackElementWords;
-  return (round_to((max_stack_words
-                   + rounded_vm_local_words
-                   + frame::memory_parameter_word_sp_offset), WordsPerLong)
-                   // already rounded
-                   + locals_size + monitor_size);
-}
-
-// How much stack a method top interpreter activation needs in words.
-int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
-
-  // See call_stub code
-  int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
-                                 WordsPerLong);    // 7 + register save area
-
-  // Save space for one monitor to get into the interpreted method in case
-  // the method is synchronized
-  int monitor_size    = method->is_synchronized() ?
-                                1*frame::interpreter_frame_monitor_size() : 0;
-  return size_activation_helper(method->max_locals(), method->max_stack(),
-                                monitor_size) + call_stub_size;
-}
-
-int AbstractInterpreter::size_activation(int max_stack,
-                                         int temps,
-                                         int extra_args,
-                                         int monitors,
-                                         int callee_params,
-                                         int callee_locals,
-                                         bool is_top_frame) {
-  // Note: This calculation must exactly parallel the frame setup
-  // in TemplateInterpreterGenerator::generate_fixed_frame.
-
-  int monitor_size           = monitors * frame::interpreter_frame_monitor_size();
-
-  assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
-
-  //
-  // Note: if you look closely this appears to be doing something much different
-  // than generate_fixed_frame. What is happening is this. On sparc we have to do
-  // this dance with interpreter_sp_adjustment because the window save area would
-  // appear just below the bottom (tos) of the caller's java expression stack. Because
-  // the interpreter want to have the locals completely contiguous generate_fixed_frame
-  // will adjust the caller's sp for the "extra locals" (max_locals - parameter_size).
-  // Now in generate_fixed_frame the extension of the caller's sp happens in the callee.
-  // In this code the opposite occurs the caller adjusts it's own stack base on the callee.
-  // This is mostly ok but it does cause a problem when we get to the initial frame (the oldest)
-  // because the oldest frame would have adjust its callers frame and yet that frame
-  // already exists and isn't part of this array of frames we are unpacking. So at first
-  // glance this would seem to mess up that frame. However Deoptimization::fetch_unroll_info_helper()
-  // will after it calculates all of the frame's on_stack_size()'s will then figure out the
-  // amount to adjust the caller of the initial (oldest) frame and the calculation will all
-  // add up. It does seem like it simpler to account for the adjustment here (and remove the
-  // callee... parameters here). However this would mean that this routine would have to take
-  // the caller frame as input so we could adjust its sp (and set it's interpreter_sp_adjustment)
-  // and run the calling loop in the reverse order. This would also would appear to mean making
-  // this code aware of what the interactions are when that initial caller fram was an osr or
-  // other adapter frame. deoptimization is complicated enough and  hard enough to debug that
-  // there is no sense in messing working code.
-  //
-
-  int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong);
-  assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align");
-
-  int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size);
-
-  return raw_frame_size;
-}
-
-void AbstractInterpreter::layout_activation(Method* method,
-                                            int tempcount,
-                                            int popframe_extra_args,
-                                            int moncount,
-                                            int caller_actual_parameters,
-                                            int callee_param_count,
-                                            int callee_local_count,
-                                            frame* caller,
-                                            frame* interpreter_frame,
-                                            bool is_top_frame,
-                                            bool is_bottom_frame) {
-  // Set up the following variables:
-  //   - Lmethod
-  //   - Llocals
-  //   - Lmonitors (to the indicated number of monitors)
-  //   - Lesp (to the indicated number of temps)
-  // The frame caller on entry is a description of the caller of the
-  // frame we are about to layout. We are guaranteed that we will be
-  // able to fill in a new interpreter frame as its callee (i.e. the
-  // stack space is allocated and the amount was determined by an
-  // earlier call to the size_activation() method).  On return caller
-  // while describe the interpreter frame we just layed out.
-
-  // The skeleton frame must already look like an interpreter frame
-  // even if not fully filled out.
-  assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
-
-  int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
-  int monitor_size           = moncount * frame::interpreter_frame_monitor_size();
-  assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
-
-  intptr_t* fp = interpreter_frame->fp();
-
-  JavaThread* thread = JavaThread::current();
-  RegisterMap map(thread, false);
-  // More verification that skeleton frame is properly walkable
-  assert(fp == caller->sp(), "fp must match");
-
-  intptr_t* montop     = fp - rounded_vm_local_words;
-
-  // preallocate monitors (cf. __ add_monitor_to_stack)
-  intptr_t* monitors = montop - monitor_size;
-
-  // preallocate stack space
-  intptr_t*  esp = monitors - 1 -
-    (tempcount * Interpreter::stackElementWords) -
-    popframe_extra_args;
-
-  int local_words = method->max_locals() * Interpreter::stackElementWords;
-  NEEDS_CLEANUP;
-  intptr_t* locals;
-  if (caller->is_interpreted_frame()) {
-    // Can force the locals area to end up properly overlapping the top of the expression stack.
-    intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
-    // Note that this computation means we replace size_of_parameters() values from the caller
-    // interpreter frame's expression stack with our argument locals
-    int parm_words  = caller_actual_parameters * Interpreter::stackElementWords;
-    locals = Lesp_ptr + parm_words;
-    int delta = local_words - parm_words;
-    int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
-    *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
-    if (!is_bottom_frame) {
-      // Llast_SP is set below for the current frame to SP (with the
-      // extra space for the callee's locals). Here we adjust
-      // Llast_SP for the caller's frame, removing the extra space
-      // for the current method's locals.
-      *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
-    } else {
-      assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
-    }
-  } else {
-    assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
-    // Don't have Lesp available; lay out locals block in the caller
-    // adjacent to the register window save area.
-    //
-    // Compiled frames do not allocate a varargs area which is why this if
-    // statement is needed.
-    //
-    if (caller->is_compiled_frame()) {
-      locals = fp + frame::register_save_words + local_words - 1;
-    } else {
-      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
-    }
-    if (!caller->is_entry_frame()) {
-      // Caller wants his own SP back
-      int caller_frame_size = caller->cb()->frame_size();
-      *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
-    }
-  }
-  if (TraceDeoptimization) {
-    if (caller->is_entry_frame()) {
-      // make sure I5_savedSP and the entry frames notion of saved SP
-      // agree.  This assertion duplicate a check in entry frame code
-      // but catches the failure earlier.
-      assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
-             "would change callers SP");
-    }
-    if (caller->is_entry_frame()) {
-      tty->print("entry ");
-    }
-    if (caller->is_compiled_frame()) {
-      tty->print("compiled ");
-      if (caller->is_deoptimized_frame()) {
-        tty->print("(deopt) ");
-      }
-    }
-    if (caller->is_interpreted_frame()) {
-      tty->print("interpreted ");
-    }
-    tty->print_cr("caller fp=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, p2i(caller->fp()), p2i(caller->sp()));
-    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(caller->sp()), p2i(caller->sp() + 16));
-    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(caller->fp()), p2i(caller->fp() + 16));
-    tty->print_cr("interpreter fp=" INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->fp()), p2i(interpreter_frame->sp()));
-    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->sp()), p2i(interpreter_frame->sp() + 16));
-    tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->fp()), p2i(interpreter_frame->fp() + 16));
-    tty->print_cr("Llocals = " INTPTR_FORMAT, p2i(locals));
-    tty->print_cr("Lesp = " INTPTR_FORMAT, p2i(esp));
-    tty->print_cr("Lmonitors = " INTPTR_FORMAT, p2i(monitors));
-  }
-
-  if (method->max_locals() > 0) {
-    assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
-    assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
-    assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
-    assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
-  }
-#ifdef _LP64
-  assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
-#endif
-
-  *interpreter_frame->register_addr(Lmethod)     = (intptr_t) method;
-  *interpreter_frame->register_addr(Llocals)     = (intptr_t) locals;
-  *interpreter_frame->register_addr(Lmonitors)   = (intptr_t) monitors;
-  *interpreter_frame->register_addr(Lesp)        = (intptr_t) esp;
-  // Llast_SP will be same as SP as there is no adapter space
-  *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
-  *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
-#ifdef FAST_DISPATCH
-  *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
-#endif
-
-
-#ifdef ASSERT
-  BasicObjectLock* mp = (BasicObjectLock*)monitors;
-
-  assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
-  assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
-  assert(interpreter_frame->interpreter_frame_monitor_end()   == mp, "monitor_end matches");
-  assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
-  assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
-
-  // check bounds
-  intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
-  intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
-  assert(lo < monitors && montop <= hi, "monitors in bounds");
-  assert(lo <= esp && esp < monitors, "esp in bounds");
-#endif // ASSERT
-}
--- a/src/cpu/sparc/vm/templateTable_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/sparc/vm/templateTable_sparc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3356,7 +3356,15 @@
       __ cmp_and_brx_short(RtlabWasteLimitValue, RfreeValue, Assembler::greaterEqualUnsigned, Assembler::pt, slow_case); // tlab waste is small
 
       // increment waste limit to prevent getting stuck on this slow path
-      __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue);
+      if (Assembler::is_simm13(ThreadLocalAllocBuffer::refill_waste_limit_increment())) {
+        __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue);
+      } else {
+        // set64 does not use the temp register if the given constant is 32 bit. So
+        // we can just use any register; using G0 results in ignoring of the upper 32 bit
+        // of that value.
+        __ set64(ThreadLocalAllocBuffer::refill_waste_limit_increment(), G4_scratch, G0);
+        __ add(RtlabWasteLimitValue, G4_scratch, RtlabWasteLimitValue);
+      }
       __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
     } else {
       // No allocation in the shared eden.
--- a/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/sparc/vm/vm_version_sparc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -45,13 +45,6 @@
   if( cache_line_size > AllocatePrefetchStepSize )
     AllocatePrefetchStepSize = cache_line_size;
 
-  assert(AllocatePrefetchLines > 0, "invalid value");
-  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
-    AllocatePrefetchLines = 3;
-  assert(AllocateInstancePrefetchLines > 0, "invalid value");
-  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
-    AllocateInstancePrefetchLines = 1;
-
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/x86/vm/abstractInterpreter_x86.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "ci/ciMethod.hpp"
+#include "interpreter/interpreter.hpp"
+#include "runtime/frame.inline.hpp"
+
+
+// asm based interpreter deoptimization helpers
+int AbstractInterpreter::size_activation(int max_stack,
+                                         int temps,
+                                         int extra_args,
+                                         int monitors,
+                                         int callee_params,
+                                         int callee_locals,
+                                         bool is_top_frame) {
+  // Note: This calculation must exactly parallel the frame setup
+  // in TemplateInterpreterGenerator::generate_fixed_frame.
+
+  // fixed size of an interpreter frame:
+  int overhead = frame::sender_sp_offset -
+                 frame::interpreter_frame_initial_sp_offset;
+  // Our locals were accounted for by the caller (or last_frame_adjust
+  // on the transistion) Since the callee parameters already account
+  // for the callee's params we only need to account for the extra
+  // locals.
+  int size = overhead +
+         (callee_locals - callee_params)*Interpreter::stackElementWords +
+         monitors * frame::interpreter_frame_monitor_size() +
+         temps* Interpreter::stackElementWords + extra_args;
+
+  return size;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+                                            int tempcount,
+                                            int popframe_extra_args,
+                                            int moncount,
+                                            int caller_actual_parameters,
+                                            int callee_param_count,
+                                            int callee_locals,
+                                            frame* caller,
+                                            frame* interpreter_frame,
+                                            bool is_top_frame,
+                                            bool is_bottom_frame) {
+  // The frame interpreter_frame is guaranteed to be the right size,
+  // as determined by a previous call to the size_activation() method.
+  // It is also guaranteed to be walkable even though it is in a
+  // skeletal state
+
+  int max_locals = method->max_locals() * Interpreter::stackElementWords;
+  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
+    Interpreter::stackElementWords;
+
+#ifdef ASSERT
+  assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
+#endif
+
+  interpreter_frame->interpreter_frame_set_method(method);
+  // NOTE the difference in using sender_sp and
+  // interpreter_frame_sender_sp interpreter_frame_sender_sp is
+  // the original sp of the caller (the unextended_sp) and
+  // sender_sp is fp+8/16 (32bit/64bit) XXX
+  intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
+
+#ifdef ASSERT
+  if (caller->is_interpreted_frame()) {
+    assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
+  }
+#endif
+
+  interpreter_frame->interpreter_frame_set_locals(locals);
+  BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
+  BasicObjectLock* monbot = montop - moncount;
+  interpreter_frame->interpreter_frame_set_monitor_end(monbot);
+
+  // Set last_sp
+  intptr_t*  esp = (intptr_t*) monbot -
+    tempcount*Interpreter::stackElementWords -
+    popframe_extra_args;
+  interpreter_frame->interpreter_frame_set_last_sp(esp);
+
+  // All frames but the initial (oldest) interpreter frame we fill in have
+  // a value for sender_sp that allows walking the stack but isn't
+  // truly correct. Correct the value here.
+  if (extra_locals != 0 &&
+      interpreter_frame->sender_sp() ==
+      interpreter_frame->interpreter_frame_sender_sp()) {
+    interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
+                                                       extra_locals);
+  }
+  *interpreter_frame->interpreter_frame_cache_addr() =
+    method->constants()->cache();
+}
+
+#ifndef _LP64
+int AbstractInterpreter::BasicType_as_index(BasicType type) {
+  int i = 0;
+  switch (type) {
+    case T_BOOLEAN: i = 0; break;
+    case T_CHAR   : i = 1; break;
+    case T_BYTE   : i = 2; break;
+    case T_SHORT  : i = 3; break;
+    case T_INT    : // fall through
+    case T_LONG   : // fall through
+    case T_VOID   : i = 4; break;
+    case T_FLOAT  : i = 5; break;  // have to treat float and double separately for SSE
+    case T_DOUBLE : i = 6; break;
+    case T_OBJECT : // fall through
+    case T_ARRAY  : i = 7; break;
+    default       : ShouldNotReachHere();
+  }
+  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
+  return i;
+}
+#else
+int AbstractInterpreter::BasicType_as_index(BasicType type) {
+  int i = 0;
+  switch (type) {
+    case T_BOOLEAN: i = 0; break;
+    case T_CHAR   : i = 1; break;
+    case T_BYTE   : i = 2; break;
+    case T_SHORT  : i = 3; break;
+    case T_INT    : i = 4; break;
+    case T_LONG   : i = 5; break;
+    case T_VOID   : i = 6; break;
+    case T_FLOAT  : i = 7; break;
+    case T_DOUBLE : i = 8; break;
+    case T_OBJECT : i = 9; break;
+    case T_ARRAY  : i = 9; break;
+    default       : ShouldNotReachHere();
+  }
+  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
+         "index out of bounds");
+  return i;
+}
+#endif // _LP64
+
+// These should never be compiled since the interpreter will prefer
+// the compiled version to the intrinsic version.
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  switch (method_kind(m)) {
+    case Interpreter::java_lang_math_sin     : // fall thru
+    case Interpreter::java_lang_math_cos     : // fall thru
+    case Interpreter::java_lang_math_tan     : // fall thru
+    case Interpreter::java_lang_math_abs     : // fall thru
+    case Interpreter::java_lang_math_log     : // fall thru
+    case Interpreter::java_lang_math_log10   : // fall thru
+    case Interpreter::java_lang_math_sqrt    : // fall thru
+    case Interpreter::java_lang_math_pow     : // fall thru
+    case Interpreter::java_lang_math_exp     :
+      return false;
+    default:
+      return true;
+  }
+}
+
+// How much stack a method activation needs in words.
+int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
+  const int entry_size = frame::interpreter_frame_monitor_size();
+
+  // total overhead size: entry_size + (saved rbp thru expr stack
+  // bottom).  be sure to change this if you add/subtract anything
+  // to/from the overhead area
+  const int overhead_size =
+    -(frame::interpreter_frame_initial_sp_offset) + entry_size;
+
+#ifndef _LP64
+  const int stub_code = 4;  // see generate_call_stub
+#else
+  const int stub_code = frame::entry_frame_after_call_words;
+#endif
+
+  const int method_stack = (method->max_locals() + method->max_stack()) *
+                           Interpreter::stackElementWords;
+  return (overhead_size + method_stack + stub_code);
+}
--- a/src/cpu/x86/vm/interpreterGenerator_x86.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/interp_masm.hpp"
-#include "interpreter/templateInterpreterGenerator.hpp"
-
-#define __ _masm->
-
-// Abstract method entry
-// Attempt to execute abstract method. Throw exception
-address TemplateInterpreterGenerator::generate_abstract_entry(void) {
-
-  address entry_point = __ pc();
-
-  // abstract method entry
-
-  //  pop return address, reset last_sp to NULL
-  __ empty_expression_stack();
-  __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
-  __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
-
-  // throw exception
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
-  // the call_VM checks for exception, so we should never return here.
-  __ should_not_reach_here();
-
-  return entry_point;
-}
--- a/src/cpu/x86/vm/interpreter_x86_32.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
-#include "interpreter/bytecodeHistogram.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/interp_masm.hpp"
-#include "interpreter/templateInterpreterGenerator.hpp"
-#include "interpreter/templateTable.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "prims/methodHandles.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/timer.hpp"
-#include "runtime/vframeArray.hpp"
-#include "utilities/debug.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-
-#define __ _masm->
-
-//------------------------------------------------------------------------------------------------------------------------
-
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  address entry = __ pc();
-  // rbx,: method
-  // rcx: temporary
-  // rdi: pointer to locals
-  // rsp: end of copied parameters area
-  __ mov(rcx, rsp);
-  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
-  __ ret(0);
-  return entry;
-}
-
-
-address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
-
-  // rbx,: Method*
-  // rcx: scratrch
-  // rsi: sender sp
-
-  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
-
-  address entry_point = __ pc();
-
-  // These don't need a safepoint check because they aren't virtually
-  // callable. We won't enter these intrinsics from compiled code.
-  // If in the future we added an intrinsic which was virtually callable
-  // we'd have to worry about how to safepoint so that this code is used.
-
-  // mathematical functions inlined by compiler
-  // (interpreter must provide identical implementation
-  // in order to avoid monotonicity bugs when switching
-  // from interpreter to compiler in the middle of some
-  // computation)
-  //
-  // stack: [ ret adr ] <-- rsp
-  //        [ lo(arg) ]
-  //        [ hi(arg) ]
-  //
-
-  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
-  //       native methods. Interpreter::method_kind(...) does a check for
-  //       native methods first before checking for intrinsic methods and
-  //       thus will never select this entry point. Make sure it is not
-  //       called accidentally since the SharedRuntime entry points will
-  //       not work for JDK 1.2.
-  //
-  // We no longer need to check for JDK 1.2 since it's EOL'ed.
-  // The following check existed in pre 1.6 implementation,
-  //    if (Universe::is_jdk12x_version()) {
-  //      __ should_not_reach_here();
-  //    }
-  // Universe::is_jdk12x_version() always returns false since
-  // the JDK version is not yet determined when this method is called.
-  // This method is called during interpreter_init() whereas
-  // JDK version is only determined when universe2_init() is called.
-
-  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
-  //       java methods.  Interpreter::method_kind(...) will select
-  //       this entry point for the corresponding methods in JDK 1.3.
-  // get argument
-  __ fld_d(Address(rsp, 1*wordSize));
-  switch (kind) {
-    case Interpreter::java_lang_math_sin :
-        __ subptr(rsp, 2 * wordSize);
-        __ fstp_d(Address(rsp, 0));
-        if (VM_Version::supports_sse2() && StubRoutines::dsin() != NULL) {
-          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
-        } else {
-          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin)));
-        }
-        __ addptr(rsp, 2 * wordSize);
-        break;
-    case Interpreter::java_lang_math_cos :
-        __ subptr(rsp, 2 * wordSize);
-        __ fstp_d(Address(rsp, 0));
-        if (VM_Version::supports_sse2() && StubRoutines::dcos() != NULL) {
-          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
-        } else {
-          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos)));
-        }
-        __ addptr(rsp, 2 * wordSize);
-        break;
-    case Interpreter::java_lang_math_tan :
-        __ trigfunc('t');
-        break;
-    case Interpreter::java_lang_math_sqrt:
-        __ fsqrt();
-        break;
-    case Interpreter::java_lang_math_abs:
-        __ fabs();
-        break;
-    case Interpreter::java_lang_math_log:
-        __ subptr(rsp, 2 * wordSize);
-        __ fstp_d(Address(rsp, 0));
-        if (VM_Version::supports_sse2()) {
-          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
-        } else {
-          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
-        }
-        __ addptr(rsp, 2 * wordSize);
-        break;
-    case Interpreter::java_lang_math_log10:
-        __ flog10();
-        // Store to stack to convert 80bit precision back to 64bits
-        __ push_fTOS();
-        __ pop_fTOS();
-        break;
-    case Interpreter::java_lang_math_pow:
-      __ fld_d(Address(rsp, 3*wordSize)); // second argument
-      __ subptr(rsp, 4 * wordSize);
-      __ fstp_d(Address(rsp, 0));
-      __ fstp_d(Address(rsp, 2 * wordSize));
-      if (VM_Version::supports_sse2()) {
-        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
-      } else {
-        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
-      }
-      __ addptr(rsp, 4 * wordSize);
-      break;
-    case Interpreter::java_lang_math_exp:
-      __ subptr(rsp, 2*wordSize);
-      __ fstp_d(Address(rsp, 0));
-      if (VM_Version::supports_sse2()) {
-        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
-      } else {
-        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
-      }
-      __ addptr(rsp, 2*wordSize);
-    break;
-    default                              :
-        ShouldNotReachHere();
-  }
-
-  // return double result in xmm0 for interpreter and compilers.
-  if (UseSSE >= 2) {
-    __ subptr(rsp, 2*wordSize);
-    __ fstp_d(Address(rsp, 0));
-    __ movdbl(xmm0, Address(rsp, 0));
-    __ addptr(rsp, 2*wordSize);
-  }
-
-  // done, result in FPU ST(0) or XMM0
-  __ pop(rdi);                               // get return address
-  __ mov(rsp, rsi);                          // set sp to sender sp
-  __ jmp(rdi);
-
-  return entry_point;
-}
--- a/src/cpu/x86/vm/interpreter_x86_64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/macroAssembler.hpp"
-#include "interpreter/bytecodeHistogram.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/interp_masm.hpp"
-#include "interpreter/templateInterpreterGenerator.hpp"
-#include "interpreter/templateTable.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "prims/methodHandles.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/timer.hpp"
-#include "runtime/vframeArray.hpp"
-#include "utilities/debug.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-
-#define __ _masm->
-
-#ifdef _WIN64
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  address entry = __ pc();
-
-  // rbx: method
-  // r14: pointer to locals
-  // c_rarg3: first stack arg - wordSize
-  __ mov(c_rarg3, rsp);
-  // adjust rsp
-  __ subptr(rsp, 4 * wordSize);
-  __ call_VM(noreg,
-             CAST_FROM_FN_PTR(address,
-                              InterpreterRuntime::slow_signature_handler),
-             rbx, r14, c_rarg3);
-
-  // rax: result handler
-
-  // Stack layout:
-  // rsp: 3 integer or float args (if static first is unused)
-  //      1 float/double identifiers
-  //        return address
-  //        stack args
-  //        garbage
-  //        expression stack bottom
-  //        bcp (NULL)
-  //        ...
-
-  // Do FP first so we can use c_rarg3 as temp
-  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
-
-  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
-    XMMRegister floatreg = as_XMMRegister(i+1);
-    Label isfloatordouble, isdouble, next;
-
-    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
-    __ jcc(Assembler::notZero, isfloatordouble);
-
-    // Do Int register here
-    switch ( i ) {
-      case 0:
-        __ movl(rscratch1, Address(rbx, Method::access_flags_offset()));
-        __ testl(rscratch1, JVM_ACC_STATIC);
-        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
-        break;
-      case 1:
-        __ movptr(c_rarg2, Address(rsp, wordSize));
-        break;
-      case 2:
-        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
-        break;
-      default:
-        break;
-    }
-
-    __ jmp (next);
-
-    __ bind(isfloatordouble);
-    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
-    __ jcc(Assembler::notZero, isdouble);
-
-// Do Float Here
-    __ movflt(floatreg, Address(rsp, i * wordSize));
-    __ jmp(next);
-
-// Do Double here
-    __ bind(isdouble);
-    __ movdbl(floatreg, Address(rsp, i * wordSize));
-
-    __ bind(next);
-  }
-
-
-  // restore rsp
-  __ addptr(rsp, 4 * wordSize);
-
-  __ ret(0);
-
-  return entry;
-}
-#else
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  address entry = __ pc();
-
-  // rbx: method
-  // r14: pointer to locals
-  // c_rarg3: first stack arg - wordSize
-  __ mov(c_rarg3, rsp);
-  // adjust rsp
-  __ subptr(rsp, 14 * wordSize);
-  __ call_VM(noreg,
-             CAST_FROM_FN_PTR(address,
-                              InterpreterRuntime::slow_signature_handler),
-             rbx, r14, c_rarg3);
-
-  // rax: result handler
-
-  // Stack layout:
-  // rsp: 5 integer args (if static first is unused)
-  //      1 float/double identifiers
-  //      8 double args
-  //        return address
-  //        stack args
-  //        garbage
-  //        expression stack bottom
-  //        bcp (NULL)
-  //        ...
-
-  // Do FP first so we can use c_rarg3 as temp
-  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
-
-  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
-    const XMMRegister r = as_XMMRegister(i);
-
-    Label d, done;
-
-    __ testl(c_rarg3, 1 << i);
-    __ jcc(Assembler::notZero, d);
-    __ movflt(r, Address(rsp, (6 + i) * wordSize));
-    __ jmp(done);
-    __ bind(d);
-    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
-    __ bind(done);
-  }
-
-  // Now handle integrals.  Only do c_rarg1 if not static.
-  __ movl(c_rarg3, Address(rbx, Method::access_flags_offset()));
-  __ testl(c_rarg3, JVM_ACC_STATIC);
-  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
-
-  __ movptr(c_rarg2, Address(rsp, wordSize));
-  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
-  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
-  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
-
-  // restore rsp
-  __ addptr(rsp, 14 * wordSize);
-
-  __ ret(0);
-
-  return entry;
-}
-#endif
-
-
-//
-// Various method entries
-//
-
-address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
-
-  // rbx,: Method*
-  // rcx: scratrch
-  // r13: sender sp
-
-  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
-
-  address entry_point = __ pc();
-
-  // These don't need a safepoint check because they aren't virtually
-  // callable. We won't enter these intrinsics from compiled code.
-  // If in the future we added an intrinsic which was virtually callable
-  // we'd have to worry about how to safepoint so that this code is used.
-
-  // mathematical functions inlined by compiler
-  // (interpreter must provide identical implementation
-  // in order to avoid monotonicity bugs when switching
-  // from interpreter to compiler in the middle of some
-  // computation)
-  //
-  // stack: [ ret adr ] <-- rsp
-  //        [ lo(arg) ]
-  //        [ hi(arg) ]
-  //
-
-  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
-  //       native methods. Interpreter::method_kind(...) does a check for
-  //       native methods first before checking for intrinsic methods and
-  //       thus will never select this entry point. Make sure it is not
-  //       called accidentally since the SharedRuntime entry points will
-  //       not work for JDK 1.2.
-  //
-  // We no longer need to check for JDK 1.2 since it's EOL'ed.
-  // The following check existed in pre 1.6 implementation,
-  //    if (Universe::is_jdk12x_version()) {
-  //      __ should_not_reach_here();
-  //    }
-  // Universe::is_jdk12x_version() always returns false since
-  // the JDK version is not yet determined when this method is called.
-  // This method is called during interpreter_init() whereas
-  // JDK version is only determined when universe2_init() is called.
-
-  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
-  //       java methods.  Interpreter::method_kind(...) will select
-  //       this entry point for the corresponding methods in JDK 1.3.
-  // get argument
-
-  if (kind == Interpreter::java_lang_math_sqrt) {
-    __ sqrtsd(xmm0, Address(rsp, wordSize));
-  } else if (kind == Interpreter::java_lang_math_exp) {
-    __ movdbl(xmm0, Address(rsp, wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
-  } else if (kind == Interpreter::java_lang_math_log) {
-    __ movdbl(xmm0, Address(rsp, wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
-  } else if (kind == Interpreter::java_lang_math_pow) {
-    __ movdbl(xmm1, Address(rsp, wordSize));
-    __ movdbl(xmm0, Address(rsp, 3 * wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
-  } else if (kind == Interpreter::java_lang_math_sin && StubRoutines::dsin() != NULL) {
-    __ movdbl(xmm0, Address(rsp, wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin())));
-  } else if (kind == Interpreter::java_lang_math_cos && StubRoutines::dcos() != NULL) {
-    __ movdbl(xmm0, Address(rsp, wordSize));
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos())));
-  } else {
-    __ fld_d(Address(rsp, wordSize));
-    switch (kind) {
-      case Interpreter::java_lang_math_sin :
-          __ trigfunc('s');
-          break;
-      case Interpreter::java_lang_math_cos :
-          __ trigfunc('c');
-          break;
-      case Interpreter::java_lang_math_tan :
-          __ trigfunc('t');
-          break;
-      case Interpreter::java_lang_math_abs:
-          __ fabs();
-          break;
-      case Interpreter::java_lang_math_log10:
-          __ flog10();
-          break;
-      default                              :
-          ShouldNotReachHere();
-    }
-
-    // return double result in xmm0 for interpreter and compilers.
-    __ subptr(rsp, 2*wordSize);
-    // Round to 64bit precision
-    __ fstp_d(Address(rsp, 0));
-    __ movdbl(xmm0, Address(rsp, 0));
-    __ addptr(rsp, 2*wordSize);
-  }
-
-
-  __ pop(rax);
-  __ mov(rsp, r13);
-  __ jmp(rax);
-
-  return entry_point;
-}
--- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -114,15 +114,20 @@
 
 OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words,
                                            int* total_frame_words, bool verify_fpu, bool save_vectors) {
-  int vect_words = 0;
   int num_xmm_regs = XMMRegisterImpl::number_of_registers;
+  int ymm_bytes = num_xmm_regs * 16;
+  int zmm_bytes = num_xmm_regs * 32;
 #ifdef COMPILER2
   if (save_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
-    // Save upper half of ZMM/YMM registers :
-    vect_words = 8 * 16 / wordSize;
-    additional_frame_words += vect_words;
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
+    // Save upper half of YMM registers
+    int vect_bytes = ymm_bytes;
+    if (UseAVX > 2) {
+      // Save upper half of ZMM registers as well
+      vect_bytes += zmm_bytes;
+    }
+    additional_frame_words += vect_bytes / wordSize;
   }
 #else
   assert(!save_vectors, "vectors are generated only by C2");
@@ -185,13 +190,14 @@
 
   off = xmm0_off;
   delta = xmm1_off - off;
-  if(UseSSE == 1) {           // Save the XMM state
+  if(UseSSE == 1) {
+    // Save the XMM state
     for (int n = 0; n < num_xmm_regs; n++) {
       __ movflt(Address(rsp, off*wordSize), as_XMMRegister(n));
       off += delta;
     }
   } else if(UseSSE >= 2) {
-    // Save whole 128bit (16 bytes) XMM regiters
+    // Save whole 128bit (16 bytes) XMM registers
     for (int n = 0; n < num_xmm_regs; n++) {
       __ movdqu(Address(rsp, off*wordSize), as_XMMRegister(n));
       off += delta;
@@ -199,13 +205,14 @@
   }
 
   if (save_vectors) {
-    assert(vect_words*wordSize == 128, "");
-    __ subptr(rsp, 128); // Save upper half of YMM registes
+    __ subptr(rsp, ymm_bytes);
+    // Save upper half of YMM registers
     for (int n = 0; n < num_xmm_regs; n++) {
       __ vextractf128h(Address(rsp, n*16), as_XMMRegister(n));
     }
     if (UseAVX > 2) {
-      __ subptr(rsp, 256); // Save upper half of ZMM registes
+      __ subptr(rsp, zmm_bytes);
+      // Save upper half of ZMM registers
       for (int n = 0; n < num_xmm_regs; n++) {
         __ vextractf64x4h(Address(rsp, n*32), as_XMMRegister(n), 1);
       }
@@ -255,48 +262,57 @@
 
 void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_vectors) {
   int num_xmm_regs = XMMRegisterImpl::number_of_registers;
+  int ymm_bytes = num_xmm_regs * 16;
+  int zmm_bytes = num_xmm_regs * 32;
   // Recover XMM & FPU state
   int additional_frame_bytes = 0;
 #ifdef COMPILER2
   if (restore_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
-    additional_frame_bytes = 128;
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
+    // Save upper half of YMM registers
+    additional_frame_bytes = ymm_bytes;
+    if (UseAVX > 2) {
+      // Save upper half of ZMM registers as well
+      additional_frame_bytes += zmm_bytes;
+    }
   }
 #else
   assert(!restore_vectors, "vectors are generated only by C2");
 #endif
 
+  int off = xmm0_off;
+  int delta = xmm1_off - off;
+
+  if (UseSSE == 1) {
+    // Restore XMM registers
+    assert(additional_frame_bytes == 0, "");
+    for (int n = 0; n < num_xmm_regs; n++) {
+      __ movflt(as_XMMRegister(n), Address(rsp, off*wordSize));
+      off += delta;
+    }
+  } else if (UseSSE >= 2) {
+    // Restore whole 128bit (16 bytes) XMM registers. Do this before restoring YMM and
+    // ZMM because the movdqu instruction zeros the upper part of the XMM register.
+    for (int n = 0; n < num_xmm_regs; n++) {
+      __ movdqu(as_XMMRegister(n), Address(rsp, off*wordSize+additional_frame_bytes));
+      off += delta;
+    }
+  }
+
   if (restore_vectors) {
-    assert(additional_frame_bytes == 128, "");
     if (UseAVX > 2) {
       // Restore upper half of ZMM registers.
       for (int n = 0; n < num_xmm_regs; n++) {
         __ vinsertf64x4h(as_XMMRegister(n), Address(rsp, n*32), 1);
       }
-      __ addptr(rsp, additional_frame_bytes*2); // Save upper half of ZMM registes
+      __ addptr(rsp, zmm_bytes);
     }
-    // Restore upper half of YMM registes.
+    // Restore upper half of YMM registers.
     for (int n = 0; n < num_xmm_regs; n++) {
       __ vinsertf128h(as_XMMRegister(n), Address(rsp, n*16));
     }
-    __ addptr(rsp, additional_frame_bytes); // Save upper half of YMM registes
-  }
-
-  int off = xmm0_off;
-  int delta = xmm1_off - off;
-
-  if (UseSSE == 1) {
-    for (int n = 0; n < num_xmm_regs; n++) {
-      __ movflt(as_XMMRegister(n), Address(rsp, off*wordSize));
-      off += delta;
-    }
-  } else if (UseSSE >= 2) {
-    // additional_frame_bytes only populated for the restore_vector case, else it is 0
-    for (int n = 0; n < num_xmm_regs; n++) {
-      __ movdqu(as_XMMRegister(n), Address(rsp, off*wordSize+additional_frame_bytes));
-      off += delta;
-    }
+    __ addptr(rsp, ymm_bytes);
   }
 
   __ pop_FPU_state();
@@ -306,7 +322,6 @@
   __ popa();
   // Get the rbp, described implicitly by the frame sender code (no oopMap)
   __ pop(rbp);
-
 }
 
 void RegisterSaver::restore_result_registers(MacroAssembler* masm) {
@@ -1271,7 +1286,7 @@
   }
 }
 
-// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// 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
 // forced.  Save down any oops in registers and describe them in an
 // OopMap.
@@ -1284,9 +1299,9 @@
                                                OopMapSet* oop_maps,
                                                VMRegPair* in_regs,
                                                BasicType* in_sig_bt) {
-  __ block_comment("check GC_locker::needs_gc");
+  __ block_comment("check GCLocker::needs_gc");
   Label cont;
-  __ cmp8(ExternalAddress((address)GC_locker::needs_gc_address()), false);
+  __ cmp8(ExternalAddress((address)GCLocker::needs_gc_address()), false);
   __ jcc(Assembler::equal, cont);
 
   // Save down any incoming oops and call into the runtime to halt for a GC
@@ -1469,14 +1484,14 @@
 // GetPrimtiveArrayCritical and disallow the use of any other JNI
 // functions.  The wrapper is expected to unpack the arguments before
 // passing them to the callee and perform checks before and after the
-// native call to ensure that they GC_locker
+// native call to ensure that they GCLocker
 // lock_critical/unlock_critical semantics are followed.  Some other
 // parts of JNI setup are skipped like the tear down of the JNI handle
 // block and the check for pending exceptions it's impossible for them
 // to be thrown.
 //
 // They are roughly structured like this:
-//    if (GC_locker::needs_gc())
+//    if (GCLocker::needs_gc())
 //      SharedRuntime::block_for_jni_critical();
 //    tranistion to thread_in_native
 //    unpack arrray arguments and call native entry point
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,8 +150,8 @@
   }
 #if defined(COMPILER2) || INCLUDE_JVMCI
   if (save_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
   }
 #else
   assert(!save_vectors, "vectors are generated only by C2 and JVMCI");
@@ -176,18 +176,18 @@
 
   // push cpu state handles this on EVEX enabled targets
   if (save_vectors) {
-    // Save upper half of YMM registes(0..15)
+    // Save upper half of YMM registers(0..15)
     int base_addr = XSAVE_AREA_YMM_BEGIN;
     for (int n = 0; n < 16; n++) {
       __ vextractf128h(Address(rsp, base_addr+n*16), as_XMMRegister(n));
     }
     if (VM_Version::supports_evex()) {
-      // Save upper half of ZMM registes(0..15)
+      // Save upper half of ZMM registers(0..15)
       base_addr = XSAVE_AREA_ZMM_BEGIN;
       for (int n = 0; n < 16; n++) {
         __ vextractf64x4h(Address(rsp, base_addr+n*32), as_XMMRegister(n), 1);
       }
-      // Save full ZMM registes(16..num_xmm_regs)
+      // Save full ZMM registers(16..num_xmm_regs)
       base_addr = XSAVE_AREA_UPPERBANK;
       off = 0;
       int vector_len = Assembler::AVX_512bit;
@@ -321,8 +321,8 @@
 
 #if defined(COMPILER2) || INCLUDE_JVMCI
   if (restore_vectors) {
-    assert(UseAVX > 0, "512bit vectors are supported only with EVEX");
-    assert(MaxVectorSize == 64, "only 512bit vectors are supported now");
+    assert(UseAVX > 0, "up to 512bit vectors are supported with EVEX");
+    assert(MaxVectorSize <= 64, "up to 512bit vectors are supported now");
   }
 #else
   assert(!restore_vectors, "vectors are generated only by C2");
@@ -330,18 +330,18 @@
 
   // On EVEX enabled targets everything is handled in pop fpu state
   if (restore_vectors) {
-    // Restore upper half of YMM registes (0..15)
+    // Restore upper half of YMM registers (0..15)
     int base_addr = XSAVE_AREA_YMM_BEGIN;
     for (int n = 0; n < 16; n++) {
       __ vinsertf128h(as_XMMRegister(n), Address(rsp,  base_addr+n*16));
     }
     if (VM_Version::supports_evex()) {
-      // Restore upper half of ZMM registes (0..15)
+      // Restore upper half of ZMM registers (0..15)
       base_addr = XSAVE_AREA_ZMM_BEGIN;
       for (int n = 0; n < 16; n++) {
         __ vinsertf64x4h(as_XMMRegister(n), Address(rsp, base_addr+n*32), 1);
       }
-      // Restore full ZMM registes(16..num_xmm_regs)
+      // Restore full ZMM registers(16..num_xmm_regs)
       base_addr = XSAVE_AREA_UPPERBANK;
       int vector_len = Assembler::AVX_512bit;
       int off = 0;
@@ -351,7 +351,7 @@
     }
   } else {
     if (VM_Version::supports_evex()) {
-      // Restore upper bank of ZMM registes(16..31) for double/float usage
+      // Restore upper bank of ZMM registers(16..31) for double/float usage
       int base_addr = XSAVE_AREA_UPPERBANK;
       int off = 0;
       for (int n = 16; n < num_xmm_regs; n++) {
@@ -1416,7 +1416,7 @@
 }
 
 
-// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// 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
 // forced.  Save down any oops in registers and describe them in an
 // OopMap.
@@ -1428,9 +1428,9 @@
                                                OopMapSet* oop_maps,
                                                VMRegPair* in_regs,
                                                BasicType* in_sig_bt) {
-  __ block_comment("check GC_locker::needs_gc");
+  __ block_comment("check GCLocker::needs_gc");
   Label cont;
-  __ cmp8(ExternalAddress((address)GC_locker::needs_gc_address()), false);
+  __ cmp8(ExternalAddress((address)GCLocker::needs_gc_address()), false);
   __ jcc(Assembler::equal, cont);
 
   // Save down any incoming oops and call into the runtime to halt for a GC
@@ -1795,14 +1795,14 @@
 // GetPrimtiveArrayCritical and disallow the use of any other JNI
 // functions.  The wrapper is expected to unpack the arguments before
 // passing them to the callee and perform checks before and after the
-// native call to ensure that they GC_locker
+// native call to ensure that they GCLocker
 // lock_critical/unlock_critical semantics are followed.  Some other
 // parts of JNI setup are skipped like the tear down of the JNI handle
 // block and the check for pending exceptions it's impossible for them
 // to be thrown.
 //
 // They are roughly structured like this:
-//    if (GC_locker::needs_gc())
+//    if (GCLocker::needs_gc())
 //      SharedRuntime::block_for_jni_critical();
 //    tranistion to thread_in_native
 //    unpack arrray arguments and call native entry point
--- a/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,17 @@
 
 #define __ _masm->
 
+// Size of interpreter code.  Increase if too small.  Interpreter will
+// fail with a guarantee ("not enough space for interpreter generation");
+// if too small.
+// Run with +PrintInterpreter to get the VM to print out the size.
+// Max size with JVMTI
+#ifdef AMD64
+int TemplateInterpreter::InterpreterCodeSize = 256 * 1024;
+#else
+int TemplateInterpreter::InterpreterCodeSize = 224 * 1024;
+#endif // AMD64
+
 // Global Register Names
 static const Register rbcp     = LP64_ONLY(r13) NOT_LP64(rsi);
 static const Register rlocals  = LP64_ONLY(r14) NOT_LP64(rdi);
@@ -57,6 +68,7 @@
 const int bcp_offset    = frame::interpreter_frame_bcp_offset    * wordSize;
 const int locals_offset = frame::interpreter_frame_locals_offset * wordSize;
 
+
 //-----------------------------------------------------------------------------
 
 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
@@ -778,6 +790,30 @@
   return NULL;
 }
 
+// TODO: rather than touching all pages, check against stack_overflow_limit and bang yellow page to
+// generate exception.  Windows might need this to map the shadow pages though.
+void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
+  // Quick & dirty stack overflow checking: bang the stack & handle trap.
+  // Note that we do the banging after the frame is setup, since the exception
+  // handling code expects to find a valid interpreter frame on the stack.
+  // Doing the banging earlier fails if the caller frame is not an interpreter
+  // frame.
+  // (Also, the exception throwing code expects to unlock any synchronized
+  // method receiever, so do the banging after locking the receiver.)
+
+  // Bang each page in the shadow zone. We can't assume it's been done for
+  // an interpreter frame with greater than a page of locals, so each page
+  // needs to be checked.  Only true for non-native.
+  if (UseStackBanging) {
+    const int page_size = os::vm_page_size();
+    const int n_shadow_pages = ((int)JavaThread::stack_shadow_zone_size()) / page_size;
+    const int start_page = native_call ? n_shadow_pages : 1;
+    for (int pages = start_page; pages <= n_shadow_pages; pages++) {
+      __ bang_stack_with_offset(pages*page_size);
+    }
+  }
+}
+
 // Interpreter stub for calling a native method. (asm interpreter)
 // This sets up a somewhat different looking stack for calling the
 // native method than the typical interpreter frame setup.
@@ -1304,6 +1340,27 @@
   return entry_point;
 }
 
+// Abstract method entry
+// Attempt to execute abstract method. Throw exception
+address TemplateInterpreterGenerator::generate_abstract_entry(void) {
+
+  address entry_point = __ pc();
+
+  // abstract method entry
+
+  //  pop return address, reset last_sp to NULL
+  __ empty_expression_stack();
+  __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
+  __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
+
+  // throw exception
+  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
+  // the call_VM checks for exception, so we should never return here.
+  __ should_not_reach_here();
+
+  return entry_point;
+}
+
 //
 // Generic interpreted method entry to (asm) interpreter
 //
--- a/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,26 @@
 #include "asm/macroAssembler.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
+#include "interpreter/interpreterRuntime.hpp"
 #include "interpreter/templateInterpreterGenerator.hpp"
 #include "runtime/arguments.hpp"
+#include "runtime/sharedRuntime.hpp"
 
 #define __ _masm->
 
 
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+  address entry = __ pc();
+  // rbx,: method
+  // rcx: temporary
+  // rdi: pointer to locals
+  // rsp: end of copied parameters area
+  __ mov(rcx, rsp);
+  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
+  __ ret(0);
+  return entry;
+}
+
 /**
  * Method entry for static native methods:
  *   int java.util.zip.CRC32.update(int crc, int b)
@@ -301,3 +315,105 @@
 
   return NULL;
 }
+
+address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
+
+  // rbx,: Method*
+  // rcx: scratrch
+  // rsi: sender sp
+
+  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
+
+  address entry_point = __ pc();
+
+  // These don't need a safepoint check because they aren't virtually
+  // callable. We won't enter these intrinsics from compiled code.
+  // If in the future we added an intrinsic which was virtually callable
+  // we'd have to worry about how to safepoint so that this code is used.
+
+  // mathematical functions inlined by compiler
+  // (interpreter must provide identical implementation
+  // in order to avoid monotonicity bugs when switching
+  // from interpreter to compiler in the middle of some
+  // computation)
+  //
+  // stack: [ ret adr ] <-- rsp
+  //        [ lo(arg) ]
+  //        [ hi(arg) ]
+  //
+
+  __ fld_d(Address(rsp, 1*wordSize));
+  switch (kind) {
+    case Interpreter::java_lang_math_sin :
+        __ trigfunc('s');
+        break;
+    case Interpreter::java_lang_math_cos :
+        __ trigfunc('c');
+        break;
+    case Interpreter::java_lang_math_tan :
+        __ trigfunc('t');
+        break;
+    case Interpreter::java_lang_math_sqrt:
+        __ fsqrt();
+        break;
+    case Interpreter::java_lang_math_abs:
+        __ fabs();
+        break;
+    case Interpreter::java_lang_math_log:
+        __ subptr(rsp, 2 * wordSize);
+        __ fstp_d(Address(rsp, 0));
+        if (VM_Version::supports_sse2()) {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
+        }
+        else {
+          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
+        }
+        __ addptr(rsp, 2 * wordSize);
+        break;
+    case Interpreter::java_lang_math_log10:
+        __ flog10();
+        // Store to stack to convert 80bit precision back to 64bits
+        __ push_fTOS();
+        __ pop_fTOS();
+        break;
+    case Interpreter::java_lang_math_pow:
+      __ fld_d(Address(rsp, 3*wordSize)); // second argument
+      __ subptr(rsp, 4 * wordSize);
+      __ fstp_d(Address(rsp, 0));
+      __ fstp_d(Address(rsp, 2 * wordSize));
+      if (VM_Version::supports_sse2()) {
+        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
+      } else {
+        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow)));
+      }
+      __ addptr(rsp, 4 * wordSize);
+      break;
+    case Interpreter::java_lang_math_exp:
+      __ subptr(rsp, 2*wordSize);
+      __ fstp_d(Address(rsp, 0));
+      if (VM_Version::supports_sse2()) {
+        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
+      } else {
+        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
+      }
+      __ addptr(rsp, 2*wordSize);
+    break;
+    default                              :
+        ShouldNotReachHere();
+  }
+
+  // return double result in xmm0 for interpreter and compilers.
+  if (UseSSE >= 2) {
+    __ subptr(rsp, 2*wordSize);
+    __ fstp_d(Address(rsp, 0));
+    __ movdbl(xmm0, Address(rsp, 0));
+    __ addptr(rsp, 2*wordSize);
+  }
+
+  // done, result in FPU ST(0) or XMM0
+  __ pop(rdi);                               // get return address
+  __ mov(rsp, rsi);                          // set sp to sender sp
+  __ jmp(rdi);
+
+  return entry_point;
+}
--- a/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,11 +26,155 @@
 #include "asm/macroAssembler.hpp"
 #include "interpreter/interp_masm.hpp"
 #include "interpreter/interpreter.hpp"
+#include "interpreter/interpreterRuntime.hpp"
 #include "interpreter/templateInterpreterGenerator.hpp"
 #include "runtime/arguments.hpp"
 
 #define __ _masm->
 
+#ifdef _WIN64
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+  address entry = __ pc();
+
+  // rbx: method
+  // r14: pointer to locals
+  // c_rarg3: first stack arg - wordSize
+  __ mov(c_rarg3, rsp);
+  // adjust rsp
+  __ subptr(rsp, 4 * wordSize);
+  __ call_VM(noreg,
+             CAST_FROM_FN_PTR(address,
+                              InterpreterRuntime::slow_signature_handler),
+             rbx, r14, c_rarg3);
+
+  // rax: result handler
+
+  // Stack layout:
+  // rsp: 3 integer or float args (if static first is unused)
+  //      1 float/double identifiers
+  //        return address
+  //        stack args
+  //        garbage
+  //        expression stack bottom
+  //        bcp (NULL)
+  //        ...
+
+  // Do FP first so we can use c_rarg3 as temp
+  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers
+
+  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
+    XMMRegister floatreg = as_XMMRegister(i+1);
+    Label isfloatordouble, isdouble, next;
+
+    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
+    __ jcc(Assembler::notZero, isfloatordouble);
+
+    // Do Int register here
+    switch ( i ) {
+      case 0:
+        __ movl(rscratch1, Address(rbx, Method::access_flags_offset()));
+        __ testl(rscratch1, JVM_ACC_STATIC);
+        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
+        break;
+      case 1:
+        __ movptr(c_rarg2, Address(rsp, wordSize));
+        break;
+      case 2:
+        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
+        break;
+      default:
+        break;
+    }
+
+    __ jmp (next);
+
+    __ bind(isfloatordouble);
+    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
+    __ jcc(Assembler::notZero, isdouble);
+
+// Do Float Here
+    __ movflt(floatreg, Address(rsp, i * wordSize));
+    __ jmp(next);
+
+// Do Double here
+    __ bind(isdouble);
+    __ movdbl(floatreg, Address(rsp, i * wordSize));
+
+    __ bind(next);
+  }
+
+
+  // restore rsp
+  __ addptr(rsp, 4 * wordSize);
+
+  __ ret(0);
+
+  return entry;
+}
+#else
+address TemplateInterpreterGenerator::generate_slow_signature_handler() {
+  address entry = __ pc();
+
+  // rbx: method
+  // r14: pointer to locals
+  // c_rarg3: first stack arg - wordSize
+  __ mov(c_rarg3, rsp);
+  // adjust rsp
+  __ subptr(rsp, 14 * wordSize);
+  __ call_VM(noreg,
+             CAST_FROM_FN_PTR(address,
+                              InterpreterRuntime::slow_signature_handler),
+             rbx, r14, c_rarg3);
+
+  // rax: result handler
+
+  // Stack layout:
+  // rsp: 5 integer args (if static first is unused)
+  //      1 float/double identifiers
+  //      8 double args
+  //        return address
+  //        stack args
+  //        garbage
+  //        expression stack bottom
+  //        bcp (NULL)
+  //        ...
+
+  // Do FP first so we can use c_rarg3 as temp
+  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers
+
+  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
+    const XMMRegister r = as_XMMRegister(i);
+
+    Label d, done;
+
+    __ testl(c_rarg3, 1 << i);
+    __ jcc(Assembler::notZero, d);
+    __ movflt(r, Address(rsp, (6 + i) * wordSize));
+    __ jmp(done);
+    __ bind(d);
+    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
+    __ bind(done);
+  }
+
+  // Now handle integrals.  Only do c_rarg1 if not static.
+  __ movl(c_rarg3, Address(rbx, Method::access_flags_offset()));
+  __ testl(c_rarg3, JVM_ACC_STATIC);
+  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
+
+  __ movptr(c_rarg2, Address(rsp, wordSize));
+  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
+  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
+  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));
+
+  // restore rsp
+  __ addptr(rsp, 14 * wordSize);
+
+  __ ret(0);
+
+  return entry;
+}
+#endif  // __WIN64
+
 /**
  * Method entry for static native methods:
  *   int java.util.zip.CRC32.update(int crc, int b)
@@ -193,3 +337,84 @@
 
   return NULL;
 }
+
+//
+// Various method entries
+//
+
+address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
+
+  // rbx,: Method*
+  // rcx: scratrch
+  // r13: sender sp
+
+  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
+
+  address entry_point = __ pc();
+
+  // These don't need a safepoint check because they aren't virtually
+  // callable. We won't enter these intrinsics from compiled code.
+  // If in the future we added an intrinsic which was virtually callable
+  // we'd have to worry about how to safepoint so that this code is used.
+
+  // mathematical functions inlined by compiler
+  // (interpreter must provide identical implementation
+  // in order to avoid monotonicity bugs when switching
+  // from interpreter to compiler in the middle of some
+  // computation)
+  //
+  // stack: [ ret adr ] <-- rsp
+  //        [ lo(arg) ]
+  //        [ hi(arg) ]
+  //
+
+
+  if (kind == Interpreter::java_lang_math_sqrt) {
+    __ sqrtsd(xmm0, Address(rsp, wordSize));
+  } else if (kind == Interpreter::java_lang_math_exp) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
+  } else if (kind == Interpreter::java_lang_math_log) {
+    __ movdbl(xmm0, Address(rsp, wordSize));
+    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
+  } else if (kind == Interpreter::java_lang_math_pow) {
+    __ movdbl(xmm1, Address(rsp, wordSize));
+    __ movdbl(xmm0, Address(rsp, 3 * wordSize));
+    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow())));
+  } else {
+    __ fld_d(Address(rsp, wordSize));
+    switch (kind) {
+      case Interpreter::java_lang_math_sin :
+          __ trigfunc('s');
+          break;
+      case Interpreter::java_lang_math_cos :
+          __ trigfunc('c');
+          break;
+      case Interpreter::java_lang_math_tan :
+          __ trigfunc('t');
+          break;
+      case Interpreter::java_lang_math_abs:
+          __ fabs();
+          break;
+      case Interpreter::java_lang_math_log10:
+          __ flog10();
+          break;
+      default                              :
+          ShouldNotReachHere();
+    }
+
+    // return double result in xmm0 for interpreter and compilers.
+    __ subptr(rsp, 2*wordSize);
+    // Round to 64bit precision
+    __ fstp_d(Address(rsp, 0));
+    __ movdbl(xmm0, Address(rsp, 0));
+    __ addptr(rsp, 2*wordSize);
+  }
+
+
+  __ pop(rax);
+  __ mov(rsp, r13);
+  __ jmp(rax);
+
+  return entry_point;
+}
--- a/src/cpu/x86/vm/templateInterpreter_x86.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "ci/ciMethod.hpp"
-#include "interpreter/interpreter.hpp"
-#include "runtime/frame.inline.hpp"
-
-// Size of interpreter code.  Increase if too small.  Interpreter will
-// fail with a guarantee ("not enough space for interpreter generation");
-// if too small.
-// Run with +PrintInterpreter to get the VM to print out the size.
-// Max size with JVMTI
-#ifdef AMD64
-int TemplateInterpreter::InterpreterCodeSize = 256 * 1024;
-#else
-int TemplateInterpreter::InterpreterCodeSize = 224 * 1024;
-#endif // AMD64
-
-// asm based interpreter deoptimization helpers
-int AbstractInterpreter::size_activation(int max_stack,
-                                         int temps,
-                                         int extra_args,
-                                         int monitors,
-                                         int callee_params,
-                                         int callee_locals,
-                                         bool is_top_frame) {
-  // Note: This calculation must exactly parallel the frame setup
-  // in TemplateInterpreterGenerator::generate_fixed_frame.
-
-  // fixed size of an interpreter frame:
-  int overhead = frame::sender_sp_offset -
-                 frame::interpreter_frame_initial_sp_offset;
-  // Our locals were accounted for by the caller (or last_frame_adjust
-  // on the transistion) Since the callee parameters already account
-  // for the callee's params we only need to account for the extra
-  // locals.
-  int size = overhead +
-         (callee_locals - callee_params)*Interpreter::stackElementWords +
-         monitors * frame::interpreter_frame_monitor_size() +
-         temps* Interpreter::stackElementWords + extra_args;
-
-  return size;
-}
-
-void AbstractInterpreter::layout_activation(Method* method,
-                                            int tempcount,
-                                            int popframe_extra_args,
-                                            int moncount,
-                                            int caller_actual_parameters,
-                                            int callee_param_count,
-                                            int callee_locals,
-                                            frame* caller,
-                                            frame* interpreter_frame,
-                                            bool is_top_frame,
-                                            bool is_bottom_frame) {
-  // The frame interpreter_frame is guaranteed to be the right size,
-  // as determined by a previous call to the size_activation() method.
-  // It is also guaranteed to be walkable even though it is in a
-  // skeletal state
-
-  int max_locals = method->max_locals() * Interpreter::stackElementWords;
-  int extra_locals = (method->max_locals() - method->size_of_parameters()) *
-    Interpreter::stackElementWords;
-
-#ifdef ASSERT
-  assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
-#endif
-
-  interpreter_frame->interpreter_frame_set_method(method);
-  // NOTE the difference in using sender_sp and
-  // interpreter_frame_sender_sp interpreter_frame_sender_sp is
-  // the original sp of the caller (the unextended_sp) and
-  // sender_sp is fp+8/16 (32bit/64bit) XXX
-  intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
-
-#ifdef ASSERT
-  if (caller->is_interpreted_frame()) {
-    assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
-  }
-#endif
-
-  interpreter_frame->interpreter_frame_set_locals(locals);
-  BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
-  BasicObjectLock* monbot = montop - moncount;
-  interpreter_frame->interpreter_frame_set_monitor_end(monbot);
-
-  // Set last_sp
-  intptr_t*  esp = (intptr_t*) monbot -
-    tempcount*Interpreter::stackElementWords -
-    popframe_extra_args;
-  interpreter_frame->interpreter_frame_set_last_sp(esp);
-
-  // All frames but the initial (oldest) interpreter frame we fill in have
-  // a value for sender_sp that allows walking the stack but isn't
-  // truly correct. Correct the value here.
-  if (extra_locals != 0 &&
-      interpreter_frame->sender_sp() ==
-      interpreter_frame->interpreter_frame_sender_sp()) {
-    interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
-                                                       extra_locals);
-  }
-  *interpreter_frame->interpreter_frame_cache_addr() =
-    method->constants()->cache();
-}
-
-#ifndef _LP64
-int AbstractInterpreter::BasicType_as_index(BasicType type) {
-  int i = 0;
-  switch (type) {
-    case T_BOOLEAN: i = 0; break;
-    case T_CHAR   : i = 1; break;
-    case T_BYTE   : i = 2; break;
-    case T_SHORT  : i = 3; break;
-    case T_INT    : // fall through
-    case T_LONG   : // fall through
-    case T_VOID   : i = 4; break;
-    case T_FLOAT  : i = 5; break;  // have to treat float and double separately for SSE
-    case T_DOUBLE : i = 6; break;
-    case T_OBJECT : // fall through
-    case T_ARRAY  : i = 7; break;
-    default       : ShouldNotReachHere();
-  }
-  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers, "index out of bounds");
-  return i;
-}
-#else
-int AbstractInterpreter::BasicType_as_index(BasicType type) {
-  int i = 0;
-  switch (type) {
-    case T_BOOLEAN: i = 0; break;
-    case T_CHAR   : i = 1; break;
-    case T_BYTE   : i = 2; break;
-    case T_SHORT  : i = 3; break;
-    case T_INT    : i = 4; break;
-    case T_LONG   : i = 5; break;
-    case T_VOID   : i = 6; break;
-    case T_FLOAT  : i = 7; break;
-    case T_DOUBLE : i = 8; break;
-    case T_OBJECT : i = 9; break;
-    case T_ARRAY  : i = 9; break;
-    default       : ShouldNotReachHere();
-  }
-  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
-         "index out of bounds");
-  return i;
-}
-#endif // _LP64
-
-// These should never be compiled since the interpreter will prefer
-// the compiled version to the intrinsic version.
-bool AbstractInterpreter::can_be_compiled(methodHandle m) {
-  switch (method_kind(m)) {
-    case Interpreter::java_lang_math_sin     : // fall thru
-    case Interpreter::java_lang_math_cos     : // fall thru
-    case Interpreter::java_lang_math_tan     : // fall thru
-    case Interpreter::java_lang_math_abs     : // fall thru
-    case Interpreter::java_lang_math_log     : // fall thru
-    case Interpreter::java_lang_math_log10   : // fall thru
-    case Interpreter::java_lang_math_sqrt    : // fall thru
-    case Interpreter::java_lang_math_pow     : // fall thru
-    case Interpreter::java_lang_math_exp     :
-      return false;
-    default:
-      return true;
-  }
-}
-
-// How much stack a method activation needs in words.
-int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
-  const int entry_size = frame::interpreter_frame_monitor_size();
-
-  // total overhead size: entry_size + (saved rbp thru expr stack
-  // bottom).  be sure to change this if you add/subtract anything
-  // to/from the overhead area
-  const int overhead_size =
-    -(frame::interpreter_frame_initial_sp_offset) + entry_size;
-
-#ifndef _LP64
-  const int stub_code = 4;  // see generate_call_stub
-#else
-  const int stub_code = frame::entry_frame_after_call_words;
-#endif
-
-  const int method_stack = (method->max_locals() + method->max_stack()) *
-                           Interpreter::stackElementWords;
-  return (overhead_size + method_stack + stub_code);
-}
--- a/src/cpu/x86/vm/vm_version_x86.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/x86/vm/vm_version_x86.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1163,13 +1163,6 @@
   if( cache_line_size > AllocatePrefetchStepSize )
     AllocatePrefetchStepSize = cache_line_size;
 
-  assert(AllocatePrefetchLines > 0, "invalid value");
-  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
-    AllocatePrefetchLines = 3;
-  assert(AllocateInstancePrefetchLines > 0, "invalid value");
-  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
-    AllocateInstancePrefetchLines = 1;
-
   AllocatePrefetchDistance = allocate_prefetch_distance();
   AllocatePrefetchStyle    = allocate_prefetch_style();
 
@@ -1183,7 +1176,9 @@
     }
     if (supports_sse4_2() && supports_ht()) { // Nehalem based cpus
       AllocatePrefetchDistance = 192;
-      AllocatePrefetchLines = 4;
+      if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) {
+        FLAG_SET_DEFAULT(AllocatePrefetchLines, 4);
+      }
     }
 #ifdef COMPILER2
     if (supports_sse4_2()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/zero/vm/abstractInterpreter_zero.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "interpreter/bytecodeInterpreter.hpp"
+#include "interpreter/cppInterpreter.hpp"
+#include "runtime/frame.inline.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+bool AbstractInterpreter::can_be_compiled(methodHandle m) {
+  return true;
+}
+
+int AbstractInterpreter::BasicType_as_index(BasicType type) {
+  int i = 0;
+  switch (type) {
+    case T_BOOLEAN: i = 0; break;
+    case T_CHAR   : i = 1; break;
+    case T_BYTE   : i = 2; break;
+    case T_SHORT  : i = 3; break;
+    case T_INT    : i = 4; break;
+    case T_LONG   : i = 5; break;
+    case T_VOID   : i = 6; break;
+    case T_FLOAT  : i = 7; break;
+    case T_DOUBLE : i = 8; break;
+    case T_OBJECT : i = 9; break;
+    case T_ARRAY  : i = 9; break;
+    default       : ShouldNotReachHere();
+  }
+  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
+         "index out of bounds");
+  return i;
+}
+
+// Deoptimization helpers
+
+int AbstractInterpreter::size_activation(int       max_stack,
+                                         int       tempcount,
+                                         int       extra_args,
+                                         int       moncount,
+                                         int       callee_param_count,
+                                         int       callee_locals,
+                                         bool      is_top_frame) {
+  int header_words        = InterpreterFrame::header_words;
+  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
+  int stack_words         = is_top_frame ? max_stack : tempcount;
+  int callee_extra_locals = callee_locals - callee_param_count;
+
+  return header_words + monitor_words + stack_words + callee_extra_locals;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+                                            int       tempcount,
+                                            int       popframe_extra_args,
+                                            int       moncount,
+                                            int       caller_actual_parameters,
+                                            int       callee_param_count,
+                                            int       callee_locals,
+                                            frame*    caller,
+                                            frame*    interpreter_frame,
+                                            bool      is_top_frame,
+                                            bool      is_bottom_frame) {
+  assert(popframe_extra_args == 0, "what to do?");
+  assert(!is_top_frame || (!callee_locals && !callee_param_count),
+         "top frame should have no caller");
+
+  // This code must exactly match what InterpreterFrame::build
+  // does (the full InterpreterFrame::build, that is, not the
+  // one that creates empty frames for the deoptimizer).
+  //
+  // interpreter_frame will be filled in.  It's size is determined by
+  // a previous call to the size_activation() method,
+  //
+  // Note that tempcount is the current size of the expression
+  // stack.  For top most frames we will allocate a full sized
+  // expression stack and not the trimmed version that non-top
+  // frames have.
+
+  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
+  intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
+  interpreterState istate = interpreter_frame->get_interpreterState();
+  intptr_t *monitor_base  = (intptr_t*) istate;
+  intptr_t *stack_base    = monitor_base - monitor_words;
+  intptr_t *stack         = stack_base - tempcount - 1;
+
+  BytecodeInterpreter::layout_interpreterState(istate,
+                                               caller,
+                                               NULL,
+                                               method,
+                                               locals,
+                                               stack,
+                                               stack_base,
+                                               monitor_base,
+                                               NULL,
+                                               is_top_frame);
+}
+
+// Helper for (runtime) stack overflow checks
+
+int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
+  return 0;
+}
--- a/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2008 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -25,7 +25,6 @@
 
 #include "precompiled.hpp"
 #include "asm/assembler.hpp"
-#include "interp_masm_zero.hpp"
 #include "interpreter/bytecodeInterpreter.hpp"
 #include "interpreter/bytecodeInterpreter.inline.hpp"
 #include "interpreter/interpreter.hpp"
@@ -33,8 +32,6 @@
 #include "oops/methodData.hpp"
 #include "oops/method.hpp"
 #include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
 #include "runtime/deoptimization.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/sharedRuntime.hpp"
@@ -68,4 +65,40 @@
   return NULL;
 }
 
+void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
+                                                  frame*    caller,
+                                                  frame*    current,
+                                                  Method* method,
+                                                  intptr_t* locals,
+                                                  intptr_t* stack,
+                                                  intptr_t* stack_base,
+                                                  intptr_t* monitor_base,
+                                                  intptr_t* frame_bottom,
+                                                  bool      is_top_frame) {
+  istate->set_locals(locals);
+  istate->set_method(method);
+  istate->set_self_link(istate);
+  istate->set_prev_link(NULL);
+  // thread will be set by a hacky repurposing of frame::patch_pc()
+  // bcp will be set by vframeArrayElement::unpack_on_stack()
+  istate->set_constants(method->constants()->cache());
+  istate->set_msg(BytecodeInterpreter::method_resume);
+  istate->set_bcp_advance(0);
+  istate->set_oop_temp(NULL);
+  istate->set_mdx(NULL);
+  if (caller->is_interpreted_frame()) {
+    interpreterState prev = caller->get_interpreterState();
+    prev->set_callee(method);
+    if (*prev->bcp() == Bytecodes::_invokeinterface)
+      prev->set_bcp_advance(5);
+    else
+      prev->set_bcp_advance(3);
+  }
+  istate->set_callee(NULL);
+  istate->set_monitor_base((BasicObjectLock *) monitor_base);
+  istate->set_stack_base(stack_base);
+  istate->set_stack(stack);
+  istate->set_stack_limit(stack_base - method->max_stack() - 1);
+}
+
 #endif // CC_INTERP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cpu/zero/vm/cppInterpreterGenerator_zero.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "asm/assembler.hpp"
+#include "interpreter/bytecodeHistogram.hpp"
+#include "interpreter/cppInterpreterGenerator.hpp"
+#include "interpreter/interpreterRuntime.hpp"
+#include "oops/method.hpp"
+#include "runtime/arguments.hpp"
+#include "interpreter/cppInterpreter.hpp"
+
+address CppInterpreterGenerator::generate_slow_signature_handler() {
+  _masm->advance(1);
+  return (address) InterpreterRuntime::slow_signature_handler;
+}
+
+address CppInterpreterGenerator::generate_math_entry(
+    AbstractInterpreter::MethodKind kind) {
+  if (!InlineIntrinsics)
+    return NULL;
+
+  Unimplemented();
+  return NULL;
+}
+
+address CppInterpreterGenerator::generate_abstract_entry() {
+  return generate_entry((address) ShouldNotCallThisEntry());
+}
+
+address CppInterpreterGenerator::generate_empty_entry() {
+  if (!UseFastEmptyMethods)
+    return NULL;
+
+  return generate_entry((address) CppInterpreter::empty_entry);
+}
+
+address CppInterpreterGenerator::generate_accessor_entry() {
+  if (!UseFastAccessorMethods)
+    return NULL;
+
+  return generate_entry((address) CppInterpreter::accessor_entry);
+}
+
+address CppInterpreterGenerator::generate_Reference_get_entry(void) {
+#if INCLUDE_ALL_GCS
+  if (UseG1GC) {
+    // We need to generate have a routine that generates code to:
+    //   * load the value in the referent field
+    //   * passes that value to the pre-barrier.
+    //
+    // In the case of G1 this will record the value of the
+    // referent in an SATB buffer if marking is active.
+    // This will cause concurrent marking to mark the referent
+    // field as live.
+    Unimplemented();
+  }
+#endif // INCLUDE_ALL_GCS
+
+  // If G1 is not enabled then attempt to go through the normal entry point
+  // Reference.get could be instrumented by jvmti
+  return NULL;
+}
+
+address CppInterpreterGenerator::generate_native_entry(bool synchronized) {
+  return generate_entry((address) CppInterpreter::native_entry);
+}
+
+address CppInterpreterGenerator::generate_normal_entry(bool synchronized) {
+  return generate_entry((address) CppInterpreter::normal_entry);
+}
--- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -747,92 +747,6 @@
   return (InterpreterFrame *) fp;
 }
 
-int AbstractInterpreter::BasicType_as_index(BasicType type) {
-  int i = 0;
-  switch (type) {
-    case T_BOOLEAN: i = 0; break;
-    case T_CHAR   : i = 1; break;
-    case T_BYTE   : i = 2; break;
-    case T_SHORT  : i = 3; break;
-    case T_INT    : i = 4; break;
-    case T_LONG   : i = 5; break;
-    case T_VOID   : i = 6; break;
-    case T_FLOAT  : i = 7; break;
-    case T_DOUBLE : i = 8; break;
-    case T_OBJECT : i = 9; break;
-    case T_ARRAY  : i = 9; break;
-    default       : ShouldNotReachHere();
-  }
-  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
-         "index out of bounds");
-  return i;
-}
-
-BasicType CppInterpreter::result_type_of(Method* method) {
-  BasicType t;
-  switch (method->result_index()) {
-    case 0 : t = T_BOOLEAN; break;
-    case 1 : t = T_CHAR;    break;
-    case 2 : t = T_BYTE;    break;
-    case 3 : t = T_SHORT;   break;
-    case 4 : t = T_INT;     break;
-    case 5 : t = T_LONG;    break;
-    case 6 : t = T_VOID;    break;
-    case 7 : t = T_FLOAT;   break;
-    case 8 : t = T_DOUBLE;  break;
-    case 9 : t = T_OBJECT;  break;
-    default: ShouldNotReachHere();
-  }
-  assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
-         "out of step with AbstractInterpreter::BasicType_as_index");
-  return t;
-}
-
-address CppInterpreterGenerator::generate_empty_entry() {
-  if (!UseFastEmptyMethods)
-    return NULL;
-
-  return generate_entry((address) CppInterpreter::empty_entry);
-}
-
-address CppInterpreterGenerator::generate_accessor_entry() {
-  if (!UseFastAccessorMethods)
-    return NULL;
-
-  return generate_entry((address) CppInterpreter::accessor_entry);
-}
-
-address CppInterpreterGenerator::generate_Reference_get_entry(void) {
-#if INCLUDE_ALL_GCS
-  if (UseG1GC) {
-    // We need to generate have a routine that generates code to:
-    //   * load the value in the referent field
-    //   * passes that value to the pre-barrier.
-    //
-    // In the case of G1 this will record the value of the
-    // referent in an SATB buffer if marking is active.
-    // This will cause concurrent marking to mark the referent
-    // field as live.
-    Unimplemented();
-  }
-#endif // INCLUDE_ALL_GCS
-
-  // If G1 is not enabled then attempt to go through the normal entry point
-  // Reference.get could be instrumented by jvmti
-  return NULL;
-}
-
-address CppInterpreterGenerator::generate_native_entry(bool synchronized) {
-  return generate_entry((address) CppInterpreter::native_entry);
-}
-
-address CppInterpreterGenerator::generate_normal_entry(bool synchronized) {
-  return generate_entry((address) CppInterpreter::normal_entry);
-}
-
-
-// Deoptimization helpers
-
 InterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
   ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
 
@@ -858,101 +772,24 @@
   return (InterpreterFrame *) fp;
 }
 
-int AbstractInterpreter::size_activation(int       max_stack,
-                                         int       tempcount,
-                                         int       extra_args,
-                                         int       moncount,
-                                         int       callee_param_count,
-                                         int       callee_locals,
-                                         bool      is_top_frame) {
-  int header_words        = InterpreterFrame::header_words;
-  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
-  int stack_words         = is_top_frame ? max_stack : tempcount;
-  int callee_extra_locals = callee_locals - callee_param_count;
-
-  return header_words + monitor_words + stack_words + callee_extra_locals;
-}
-
-void AbstractInterpreter::layout_activation(Method* method,
-                                            int       tempcount,
-                                            int       popframe_extra_args,
-                                            int       moncount,
-                                            int       caller_actual_parameters,
-                                            int       callee_param_count,
-                                            int       callee_locals,
-                                            frame*    caller,
-                                            frame*    interpreter_frame,
-                                            bool      is_top_frame,
-                                            bool      is_bottom_frame) {
-  assert(popframe_extra_args == 0, "what to do?");
-  assert(!is_top_frame || (!callee_locals && !callee_param_count),
-         "top frame should have no caller");
-
-  // This code must exactly match what InterpreterFrame::build
-  // does (the full InterpreterFrame::build, that is, not the
-  // one that creates empty frames for the deoptimizer).
-  //
-  // interpreter_frame will be filled in.  It's size is determined by
-  // a previous call to the size_activation() method,
-  //
-  // Note that tempcount is the current size of the expression
-  // stack.  For top most frames we will allocate a full sized
-  // expression stack and not the trimmed version that non-top
-  // frames have.
-
-  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
-  intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
-  interpreterState istate = interpreter_frame->get_interpreterState();
-  intptr_t *monitor_base  = (intptr_t*) istate;
-  intptr_t *stack_base    = monitor_base - monitor_words;
-  intptr_t *stack         = stack_base - tempcount - 1;
-
-  BytecodeInterpreter::layout_interpreterState(istate,
-                                               caller,
-                                               NULL,
-                                               method,
-                                               locals,
-                                               stack,
-                                               stack_base,
-                                               monitor_base,
-                                               NULL,
-                                               is_top_frame);
-}
-
-void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
-                                                  frame*    caller,
-                                                  frame*    current,
-                                                  Method* method,
-                                                  intptr_t* locals,
-                                                  intptr_t* stack,
-                                                  intptr_t* stack_base,
-                                                  intptr_t* monitor_base,
-                                                  intptr_t* frame_bottom,
-                                                  bool      is_top_frame) {
-  istate->set_locals(locals);
-  istate->set_method(method);
-  istate->set_self_link(istate);
-  istate->set_prev_link(NULL);
-  // thread will be set by a hacky repurposing of frame::patch_pc()
-  // bcp will be set by vframeArrayElement::unpack_on_stack()
-  istate->set_constants(method->constants()->cache());
-  istate->set_msg(BytecodeInterpreter::method_resume);
-  istate->set_bcp_advance(0);
-  istate->set_oop_temp(NULL);
-  istate->set_mdx(NULL);
-  if (caller->is_interpreted_frame()) {
-    interpreterState prev = caller->get_interpreterState();
-    prev->set_callee(method);
-    if (*prev->bcp() == Bytecodes::_invokeinterface)
-      prev->set_bcp_advance(5);
-    else
-      prev->set_bcp_advance(3);
+BasicType CppInterpreter::result_type_of(Method* method) {
+  BasicType t;
+  switch (method->result_index()) {
+    case 0 : t = T_BOOLEAN; break;
+    case 1 : t = T_CHAR;    break;
+    case 2 : t = T_BYTE;    break;
+    case 3 : t = T_SHORT;   break;
+    case 4 : t = T_INT;     break;
+    case 5 : t = T_LONG;    break;
+    case 6 : t = T_VOID;    break;
+    case 7 : t = T_FLOAT;   break;
+    case 8 : t = T_DOUBLE;  break;
+    case 9 : t = T_OBJECT;  break;
+    default: ShouldNotReachHere();
   }
-  istate->set_callee(NULL);
-  istate->set_monitor_base((BasicObjectLock *) monitor_base);
-  istate->set_stack_base(stack_base);
-  istate->set_stack(stack);
-  istate->set_stack_limit(stack_base - method->max_stack() - 1);
+  assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
+         "out of step with AbstractInterpreter::BasicType_as_index");
+  return t;
 }
 
 address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
@@ -964,12 +801,6 @@
   return NULL;
 }
 
-// Helper for (runtime) stack overflow checks
-
-int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
-  return 0;
-}
-
 // Helper for figuring out if frames are interpreter frames
 
 bool CppInterpreter::contains(address pc) {
--- a/src/cpu/zero/vm/interp_masm_zero.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2009 Red Hat, Inc.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "interp_masm_zero.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/markOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiRedefineClassesTrace.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "runtime/basicLock.hpp"
-#include "runtime/biasedLocking.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/thread.inline.hpp"
-
-// This file is intentionally empty
--- a/src/cpu/zero/vm/interpreter_zero.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/assembler.hpp"
-#include "interpreter/bytecodeHistogram.hpp"
-#include "interpreter/cppInterpreterGenerator.hpp"
-#include "interpreter/interpreter.hpp"
-#include "interpreter/interpreterRuntime.hpp"
-#include "interpreter/templateTable.hpp"
-#include "oops/arrayOop.hpp"
-#include "oops/methodData.hpp"
-#include "oops/method.hpp"
-#include "oops/oop.inline.hpp"
-#include "prims/jvmtiExport.hpp"
-#include "prims/jvmtiThreadState.hpp"
-#include "prims/methodHandles.hpp"
-#include "runtime/arguments.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "runtime/stubRoutines.hpp"
-#include "runtime/synchronizer.hpp"
-#include "runtime/timer.hpp"
-#include "runtime/vframeArray.hpp"
-#include "utilities/debug.hpp"
-#ifdef COMPILER1
-#include "c1/c1_Runtime1.hpp"
-#endif
-#ifdef CC_INTERP
-#include "interpreter/cppInterpreter.hpp"
-#endif
-
-address AbstractInterpreterGenerator::generate_slow_signature_handler() {
-  _masm->advance(1);
-  return (address) InterpreterRuntime::slow_signature_handler;
-}
-
-address CppInterpreterGenerator::generate_math_entry(
-    AbstractInterpreter::MethodKind kind) {
-  if (!InlineIntrinsics)
-    return NULL;
-
-  Unimplemented();
-  return NULL;
-}
-
-address CppInterpreterGenerator::generate_abstract_entry() {
-  return generate_entry((address) ShouldNotCallThisEntry());
-}
-
-bool AbstractInterpreter::can_be_compiled(methodHandle m) {
-  return true;
-}
--- a/src/cpu/zero/vm/register_definitions_zero.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2009 Red Hat, Inc.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "asm/assembler.hpp"
-#include "asm/register.hpp"
-#include "interp_masm_zero.hpp"
-#include "register_zero.hpp"
-
-// This file is intentionally empty
--- a/src/cpu/zero/vm/stack_zero.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/zero/vm/stack_zero.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -25,9 +25,16 @@
 
 #include "precompiled.hpp"
 #include "interpreter/interpreterRuntime.hpp"
+#include "runtime/thread.hpp"
 #include "stack_zero.hpp"
 #include "stack_zero.inline.hpp"
 
+// Inlined causes circular inclusion with thread.hpp
+ZeroStack::ZeroStack()
+    : _base(NULL), _top(NULL), _sp(NULL) {
+    _shadow_pages_size = JavaThread::stack_shadow_zone_size();
+  }
+
 int ZeroStack::suggest_size(Thread *thread) const {
   assert(needs_setup(), "already set up");
   int abi_available = abi_stack_available(thread);
--- a/src/cpu/zero/vm/stack_zero.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/zero/vm/stack_zero.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -38,10 +38,7 @@
   int _shadow_pages_size; // how much ABI stack must we keep free?
 
  public:
-  ZeroStack()
-    : _base(NULL), _top(NULL), _sp(NULL) {
-    _shadow_pages_size = JavaThread::stack_shadow_zone_size();
-  }
+  ZeroStack();
 
   bool needs_setup() const {
     return _base == NULL;
--- a/src/cpu/zero/vm/stack_zero.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/cpu/zero/vm/stack_zero.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -49,11 +49,10 @@
 // value can be negative.
 inline int ZeroStack::abi_stack_available(Thread *thread) const {
   guarantee(Thread::current() == thread, "should run in the same thread");
-  assert(thread->stack_size() -
-         (thread->stack_base() - (address) &stack_used +
-          JavaThread::stack_guard_zone_size() + JavaThread::stack_shadow_zone_size()) ==
-         (address)&stack_used - thread->stack_overflow_limit(), "sanity");
-  return (address)&stack_used - stack_overflow_limit();
+  int stack_used = thread->stack_base() - (address) &stack_used
+    + (JavaThread::stack_guard_zone_size() + JavaThread::stack_shadow_zone_size());
+  int stack_free = thread->stack_size() - stack_used;
+  return stack_free;
 }
 
 #endif // CPU_ZERO_VM_STACK_ZERO_INLINE_HPP
--- a/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c	Thu Feb 04 09:20:28 2016 +0100
@@ -171,6 +171,7 @@
 
    if (strlen(libname) >= sizeof(newlib->name)) {
      print_debug("libname %s too long\n", libname);
+     free(newlib);
      return NULL;
    }
    strcpy(newlib->name, libname);
--- a/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c	Thu Feb 04 09:20:28 2016 +0100
@@ -217,6 +217,7 @@
 
   if (strlen(libname) >= sizeof(newlib->name)) {
     print_debug("libname %s too long\n", libname);
+    free(newlib);
     return NULL;
   }
   strcpy(newlib->name, libname);
--- a/src/os/aix/vm/decoder_aix.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/aix/vm/decoder_aix.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -36,13 +36,15 @@
 
   virtual bool can_decode_C_frame_in_vm() const { return true; }
 
-  virtual bool demangle(const char* symbol, char* buf, int buflen) { return false; } // demangled by getFuncName
+  virtual bool demangle(const char* symbol, char* buf, int buflen) { return false; } // use AixSymbols::get_function_name to demangle
 
   virtual bool decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) {
-    return (::getFuncName((codeptr_t)addr, buf, buflen, offset, 0, 0, 0, demangle) == 0);
+    return AixSymbols::get_function_name(addr, buf, buflen, offset, 0, demangle);
   }
   virtual bool decode(address addr, char *buf, int buflen, int* offset, const void *base) {
     ShouldNotReachHere();
     return false;
   }
+
 };
+
--- a/src/os/aix/vm/misc_aix.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/aix/vm/misc_aix.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -41,7 +41,6 @@
     fputc('\n', stderr); fflush(stderr); \
   } \
 }
-#define ERRBYE(s) { trcVerbose(s); return -1; }
 
 #define assert0(b) assert((b), "")
 #define guarantee0(b) guarantee((b), "")
--- a/src/os/aix/vm/os_aix.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/aix/vm/os_aix.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -130,61 +130,10 @@
 #define ERROR_MP_VMGETINFO_FAILED                    102
 #define ERROR_MP_VMGETINFO_CLAIMS_NO_SUPPORT_FOR_64K 103
 
-// The semantics in this file are thus that codeptr_t is a *real code ptr*.
-// This means that any function taking codeptr_t as arguments will assume
-// a real codeptr and won't handle function descriptors (eg getFuncName),
-// whereas functions taking address as args will deal with function
-// descriptors (eg os::dll_address_to_library_name).
-typedef unsigned int* codeptr_t;
-
-// Typedefs for stackslots, stack pointers, pointers to op codes.
-typedef unsigned long stackslot_t;
-typedef stackslot_t* stackptr_t;
-
 // Query dimensions of the stack of the calling thread.
 static bool query_stack_dimensions(address* p_stack_base, size_t* p_stack_size);
 static address resolve_function_descriptor_to_code_pointer(address p);
 
-// Function to check a given stack pointer against given stack limits.
-inline bool is_valid_stackpointer(stackptr_t sp, stackptr_t stack_base, size_t stack_size) {
-  if (((uintptr_t)sp) & 0x7) {
-    return false;
-  }
-  if (sp > stack_base) {
-    return false;
-  }
-  if (sp < (stackptr_t) ((address)stack_base - stack_size)) {
-    return false;
-  }
-  return true;
-}
-
-// Returns true if function is a valid codepointer.
-inline bool is_valid_codepointer(codeptr_t p) {
-  if (!p) {
-    return false;
-  }
-  if (((uintptr_t)p) & 0x3) {
-    return false;
-  }
-  if (LoadedLibraries::find_for_text_address(p, NULL) == NULL) {
-    return false;
-  }
-  return true;
-}
-
-// Macro to check a given stack pointer against given stack limits and to die if test fails.
-#define CHECK_STACK_PTR(sp, stack_base, stack_size) { \
-    guarantee(is_valid_stackpointer((stackptr_t)(sp), (stackptr_t)(stack_base), stack_size), "Stack Pointer Invalid"); \
-}
-
-// Macro to check the current stack pointer against given stacklimits.
-#define CHECK_CURRENT_STACK_PTR(stack_base, stack_size) { \
-  address sp; \
-  sp = os::current_stack_pointer(); \
-  CHECK_STACK_PTR(sp, stack_base, stack_size); \
-}
-
 static void vmembk_print_on(outputStream* os);
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -859,9 +808,6 @@
     trcVerbose("Thread " UINT64_FORMAT ": stack not in data segment.", (uint64_t) pthread_id);
   }
 
-  // Do some sanity checks.
-  CHECK_CURRENT_STACK_PTR(thread->stack_base(), thread->stack_size());
-
   // Try to randomize the cache line index of hot stack frames.
   // This helps when threads of the same stack traces evict each other's
   // cache lines. The threads can be either from the same JVM instance, or
@@ -1028,9 +974,6 @@
   // initialize floating point control register
   os::Aix::init_thread_fpu_state();
 
-  // some sanity checks
-  CHECK_CURRENT_STACK_PTR(thread->stack_base(), thread->stack_size());
-
   // Initial thread state is RUNNABLE
   osthread->set_state(RUNNABLE);
 
@@ -1382,32 +1325,7 @@
     return false;
   }
 
-  // Go through Decoder::decode to call getFuncName which reads the name from the traceback table.
-  return Decoder::decode(addr, buf, buflen, offset, demangle);
-}
-
-static int getModuleName(codeptr_t pc,                    // [in] program counter
-                         char* p_name, size_t namelen,    // [out] optional: function name
-                         char* p_errmsg, size_t errmsglen // [out] optional: user provided buffer for error messages
-                         ) {
-
-  if (p_name && namelen > 0) {
-    *p_name = '\0';
-  }
-  if (p_errmsg && errmsglen > 0) {
-    *p_errmsg = '\0';
-  }
-
-  if (p_name && namelen > 0) {
-    loaded_module_t lm;
-    if (LoadedLibraries::find_for_text_address(pc, &lm) != NULL) {
-      strncpy(p_name, lm.shortname, namelen);
-      p_name[namelen - 1] = '\0';
-    }
-    return 0;
-  }
-
-  return -1;
+  return AixSymbols::get_function_name(addr, buf, buflen, offset, NULL, demangle);
 }
 
 bool os::dll_address_to_library_name(address addr, char* buf,
@@ -1425,10 +1343,7 @@
     return false;
   }
 
-  if (::getModuleName((codeptr_t) addr, buf, buflen, 0, 0) == 0) {
-    return true;
-  }
-  return false;
+  return AixSymbols::get_module_name(addr, buf, buflen);
 }
 
 // Loads .dll/.so and in case of error it checks if .dll/.so was built
@@ -3827,7 +3742,7 @@
   loaded_module_t lm;
   if (LoadedLibraries::find_for_text_address(addr, &lm) != NULL ||
       LoadedLibraries::find_for_data_address(addr, &lm) != NULL) {
-    st->print("%s", lm.path);
+    st->print_cr("%s", lm.path);
     return true;
   }
 
--- a/src/os/aix/vm/os_aix.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/aix/vm/os_aix.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -65,7 +65,7 @@
 }
 
 // Bang the shadow pages if they need to be touched to be mapped.
-inline void os::bang_stack_shadow_pages() {
+inline void os::map_stack_shadow_pages() {
 }
 
 inline void os::dll_unload(void *lib) {
--- a/src/os/aix/vm/porting_aix.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/aix/vm/porting_aix.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -23,30 +23,35 @@
  */
 
 #include "asm/assembler.hpp"
+#include "compiler/disassembler.hpp"
 #include "loadlib_aix.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
-// For CritSect
 #include "misc_aix.hpp"
 #include "porting_aix.hpp"
 #include "runtime/os.hpp"
+#include "runtime/thread.hpp"
 #include "utilities/debug.hpp"
 
 #include <demangle.h>
 #include <sys/debug.h>
+#include <ucontext.h>
 
 //////////////////////////////////
 // Provide implementation for dladdr based on LoadedLibraries pool and
-// traceback table scan (see getFuncName).
+// traceback table scan
 
 // Search traceback table in stack,
 // return procedure name from trace back table.
 #define MAX_FUNC_SEARCH_LEN 0x10000
-// Any PC below this value is considered toast.
-#define MINIMUM_VALUE_FOR_PC ((unsigned int*)0x1024)
 
 #define PTRDIFF_BYTES(p1,p2) (((ptrdiff_t)p1) - ((ptrdiff_t)p2))
 
+// Typedefs for stackslots, stack pointers, pointers to op codes.
+typedef unsigned long stackslot_t;
+typedef stackslot_t* stackptr_t;
+typedef unsigned int* codeptr_t;
+
 // Unfortunately, the interface of dladdr makes the implementator
 // responsible for maintaining memory for function name/library
 // name. I guess this is because most OS's keep those values as part
@@ -91,15 +96,12 @@
 
 static fixed_strings dladdr_fixed_strings;
 
-// Given a code pointer, returns the function name and the displacement.
-// Function looks for the traceback table at the end of the function.
-extern "C" int getFuncName(
-    codeptr_t pc,                    // [in] program counter
+bool AixSymbols::get_function_name (
+    address pc0,                     // [in] program counter
     char* p_name, size_t namelen,    // [out] optional: function name ("" if not available)
     int* p_displacement,             // [out] optional: displacement (-1 if not available)
     const struct tbtable** p_tb,     // [out] optional: ptr to traceback table to get further
                                      //                 information (NULL if not available)
-    char* p_errmsg, size_t errmsglen,// [out] optional: user provided buffer for error messages
     bool demangle                    // [in] whether to demangle the name
   ) {
   struct tbtable* tb = 0;
@@ -109,9 +111,6 @@
   if (p_name && namelen > 0) {
     *p_name = '\0';
   }
-  if (p_errmsg && errmsglen > 0) {
-    *p_errmsg = '\0';
-  }
   if (p_displacement) {
     *p_displacement = -1;
   }
@@ -119,9 +118,12 @@
     *p_tb = NULL;
   }
 
+  codeptr_t pc = (codeptr_t)pc0;
+
   // weed out obvious bogus states
-  if (pc < MINIMUM_VALUE_FOR_PC) {
-    ERRBYE("invalid program counter");
+  if (pc < (codeptr_t)0x1000) {
+    trcVerbose("invalid program counter");
+    return false;
   }
 
   // We see random but frequent crashes in this function since some months mainly on shutdown
@@ -130,7 +132,8 @@
   // As the pc cannot be trusted to be anything sensible lets make all reads via SafeFetch. Also
   // bail if this is not a text address right now.
   if (!LoadedLibraries::find_for_text_address(pc, NULL)) {
-    ERRBYE("not a text address");
+    trcVerbose("not a text address");
+    return false;
   }
 
   // .. (Note that is_readable_pointer returns true if safefetch stubs are not there yet;
@@ -138,10 +141,11 @@
   // error files than not having a callstack.)
 #define CHECK_POINTER_READABLE(p) \
   if (!MiscUtils::is_readable_pointer(p)) { \
-    ERRBYE("pc not readable"); \
+    trcVerbose("pc not readable"); \
+    return false; \
   }
 
-  codeptr_t pc2 = pc;
+  codeptr_t pc2 = (codeptr_t) pc;
 
   // Make sure the pointer is word aligned.
   pc2 = (codeptr_t) align_ptr_up((char*)pc2, 4);
@@ -154,7 +158,8 @@
     pc2++;
   }
   if (*pc2 != 0) {
-    ERRBYE("no traceback table found");
+    trcVerbose("no traceback table found");
+    return false;
   }
   //
   // Set up addressability to the traceback table
@@ -166,7 +171,8 @@
   if (tb->tb.lang >= 0xf && tb->tb.lang <= 0xfb) {
     // Language specifiers, go from 0 (C) to 14 (Objective C).
     // According to spec, 0xf-0xfa reserved, 0xfb-0xff reserved for ibm.
-    ERRBYE("no traceback table found");
+    trcVerbose("no traceback table found");
+    return false;
   }
 
   // Existence of fields in the tbtable extension are contingent upon
@@ -188,7 +194,8 @@
 
     // Weed out the cases where we did find the wrong traceback table.
     if (pc < start_of_procedure) {
-      ERRBYE("no traceback table found");
+      trcVerbose("no traceback table found");
+      return false;
     }
 
     // return the displacement
@@ -218,23 +225,19 @@
   if (p_name && namelen > 0) {
     if (tb->tb.name_present) {
       // Copy name from text because it may not be zero terminated.
-      // 256 is good enough for most cases; do not use large buffers here.
-      char buf[256];
-      const short l = MIN2<short>(*((short*)pc2), sizeof(buf) - 1);
+      const short l = MIN2<short>(*((short*)pc2), namelen - 1);
       // Be very careful.
       int i = 0; char* const p = (char*)pc2 + sizeof(short);
       while (i < l && MiscUtils::is_readable_pointer(p + i)) {
-        buf[i] = p[i];
+        p_name[i] = p[i];
         i++;
       }
-      buf[i] = '\0';
-
-      p_name[0] = '\0';
+      p_name[i] = '\0';
 
       // If it is a C++ name, try and demangle it using the Demangle interface (see demangle.h).
       if (demangle) {
         char* rest;
-        Name* const name = Demangle(buf, rest);
+        Name* const name = Demangle(p_name, rest);
         if (name) {
           const char* const demangled_name = name->Text();
           if (demangled_name) {
@@ -244,24 +247,35 @@
           delete name;
         }
       }
-
-      // Fallback: if demangling did not work, just provide the unmangled name.
-      if (p_name[0] == '\0') {
-        strncpy(p_name, buf, namelen-1);
-        p_name[namelen-1] = '\0';
-      }
-
     } else {
       strncpy(p_name, "<nameless function>", namelen-1);
       p_name[namelen-1] = '\0';
     }
   }
+
   // Return traceback table, if user wants it.
   if (p_tb) {
     (*p_tb) = tb;
   }
 
-  return 0;
+  return true;
+
+}
+
+bool AixSymbols::get_module_name(address pc,
+                         char* p_name, size_t namelen) {
+
+  if (p_name && namelen > 0) {
+    p_name[0] = '\0';
+    loaded_module_t lm;
+    if (LoadedLibraries::find_for_text_address(pc, &lm) != NULL) {
+      strncpy(p_name, lm.shortname, namelen);
+      p_name[namelen - 1] = '\0';
+      return true;
+    }
+  }
+
+  return false;
 }
 
 // Special implementation of dladdr for Aix based on LoadedLibraries
@@ -341,8 +355,8 @@
       char funcname[256] = "";
       int displacement = 0;
 
-      if (getFuncName((codeptr_t) p, funcname, sizeof(funcname), &displacement,
-                      NULL, NULL, 0, false) == 0) {
+      if (AixSymbols::get_function_name(p, funcname, sizeof(funcname),
+                      &displacement, NULL, true)) {
         if (funcname[0] != '\0') {
           const char* const interned = dladdr_fixed_strings.intern(funcname);
           info->dli_sname = interned;
@@ -385,3 +399,414 @@
   return rc; // error: return 0 [sic]
 
 }
+
+/////////////////////////////////////////////////////////////////////////////
+// Native callstack dumping
+
+// Print the traceback table for one stack frame.
+static void print_tbtable (outputStream* st, const struct tbtable* p_tb) {
+
+  if (p_tb == NULL) {
+    st->print("<null>");
+    return;
+  }
+
+  switch(p_tb->tb.lang) {
+    case TB_C: st->print("C"); break;
+    case TB_FORTRAN: st->print("FORTRAN"); break;
+    case TB_PASCAL: st->print("PASCAL"); break;
+    case TB_ADA: st->print("ADA"); break;
+    case TB_PL1: st->print("PL1"); break;
+    case TB_BASIC: st->print("BASIC"); break;
+    case TB_LISP: st->print("LISP"); break;
+    case TB_COBOL: st->print("COBOL"); break;
+    case TB_MODULA2: st->print("MODULA2"); break;
+    case TB_CPLUSPLUS: st->print("C++"); break;
+    case TB_RPG: st->print("RPG"); break;
+    case TB_PL8: st->print("PL8"); break;
+    case TB_ASM: st->print("ASM"); break;
+    case TB_HPJ: st->print("HPJ"); break;
+    default: st->print("unknown");
+  }
+  st->print(" ");
+
+  if (p_tb->tb.globallink) {
+    st->print("globallink ");
+  }
+  if (p_tb->tb.is_eprol) {
+    st->print("eprol ");
+  }
+  if (p_tb->tb.int_proc) {
+    st->print("int_proc ");
+  }
+  if (p_tb->tb.tocless) {
+    st->print("tocless ");
+  }
+  if (p_tb->tb.fp_present) {
+    st->print("fp_present ");
+  }
+  if (p_tb->tb.int_hndl) {
+    st->print("interrupt_handler ");
+  }
+  if (p_tb->tb.uses_alloca) {
+    st->print("uses_alloca ");
+  }
+  if (p_tb->tb.saves_cr) {
+    st->print("saves_cr ");
+  }
+  if (p_tb->tb.saves_lr) {
+    st->print("saves_lr ");
+  }
+  if (p_tb->tb.stores_bc) {
+    st->print("stores_bc ");
+  }
+  if (p_tb->tb.fixup) {
+    st->print("fixup ");
+  }
+  if (p_tb->tb.fpr_saved > 0) {
+    st->print("fpr_saved:%d ", p_tb->tb.fpr_saved);
+  }
+  if (p_tb->tb.gpr_saved > 0) {
+    st->print("gpr_saved:%d ", p_tb->tb.gpr_saved);
+  }
+  if (p_tb->tb.fixedparms > 0) {
+    st->print("fixedparms:%d ", p_tb->tb.fixedparms);
+  }
+  if (p_tb->tb.floatparms > 0) {
+    st->print("floatparms:%d ", p_tb->tb.floatparms);
+  }
+  if (p_tb->tb.parmsonstk > 0) {
+    st->print("parmsonstk:%d", p_tb->tb.parmsonstk);
+  }
+}
+
+// Print information for pc (module, function, displacement, traceback table)
+// on one line.
+static void print_info_for_pc (outputStream* st, codeptr_t pc, char* buf,
+                               size_t buf_size, bool demangle) {
+  const struct tbtable* tb = NULL;
+  int displacement = -1;
+
+  if (!MiscUtils::is_readable_pointer(pc)) {
+    st->print("(invalid)");
+    return;
+  }
+
+  if (AixSymbols::get_module_name((address)pc, buf, buf_size)) {
+    st->print("%s", buf);
+  } else {
+    st->print("(unknown module)");
+  }
+  st->print("::");
+  if (AixSymbols::get_function_name((address)pc, buf, buf_size,
+                                     &displacement, &tb, demangle)) {
+    st->print("%s", buf);
+  } else {
+    st->print("(unknown function)");
+  }
+  if (displacement == -1) {
+    st->print("+?");
+  } else {
+    st->print("+0x%x", displacement);
+  }
+  if (tb) {
+    st->fill_to(64);
+    st->print("  (");
+    print_tbtable(st, tb);
+    st->print(")");
+  }
+}
+
+static void print_stackframe(outputStream* st, stackptr_t sp, char* buf,
+                             size_t buf_size, bool demangle) {
+
+  stackptr_t sp2 = sp;
+
+  // skip backchain
+
+  sp2++;
+
+  // skip crsave
+
+  sp2++;
+
+  // retrieve lrsave. That is the only info I need to get the function/displacement
+
+  codeptr_t lrsave = (codeptr_t) *(sp2);
+  st->print (PTR64_FORMAT " - " PTR64_FORMAT " ", sp2, lrsave);
+
+  if (lrsave != NULL) {
+    print_info_for_pc(st, lrsave, buf, buf_size, demangle);
+  }
+
+}
+
+// Function to check a given stack pointer against given stack limits.
+static bool is_valid_stackpointer(stackptr_t sp, stackptr_t stack_base, size_t stack_size) {
+  if (((uintptr_t)sp) & 0x7) {
+    return false;
+  }
+  if (sp > stack_base) {
+    return false;
+  }
+  if (sp < (stackptr_t) ((address)stack_base - stack_size)) {
+    return false;
+  }
+  return true;
+}
+
+// Returns true if function is a valid codepointer.
+static bool is_valid_codepointer(codeptr_t p) {
+  if (!p) {
+    return false;
+  }
+  if (((uintptr_t)p) & 0x3) {
+    return false;
+  }
+  if (LoadedLibraries::find_for_text_address(p, NULL) == NULL) {
+    return false;
+  }
+  return true;
+}
+
+// Function tries to guess if the given combination of stack pointer, stack base
+// and stack size is a valid stack frame.
+static bool is_valid_frame (stackptr_t p, stackptr_t stack_base, size_t stack_size) {
+
+  if (!is_valid_stackpointer(p, stack_base, stack_size)) {
+    return false;
+  }
+
+  // First check - the occurrence of a valid backchain pointer up the stack, followed by a
+  // valid codeptr, counts as a good candidate.
+  stackptr_t sp2 = (stackptr_t) *p;
+  if (is_valid_stackpointer(sp2, stack_base, stack_size) && // found a valid stack pointer in the stack...
+     ((sp2 - p) > 6) &&  // ... pointing upwards and not into my frame...
+     is_valid_codepointer((codeptr_t)(*(sp2 + 2)))) // ... followed by a code pointer after two slots...
+  {
+    return true;
+  }
+
+  return false;
+}
+
+// Try to relocate a stack back chain in a given stack.
+// Used in callstack dumping, when the backchain is broken by an overwriter
+static stackptr_t try_find_backchain (stackptr_t last_known_good_frame,
+                                      stackptr_t stack_base, size_t stack_size)
+{
+  if (!is_valid_stackpointer(last_known_good_frame, stack_base, stack_size)) {
+    return NULL;
+  }
+
+  stackptr_t sp = last_known_good_frame;
+
+  sp += 6; // Omit next fixed frame slots.
+  while (sp < stack_base) {
+    if (is_valid_frame(sp, stack_base, stack_size)) {
+      return sp;
+    }
+    sp ++;
+  }
+
+  return NULL;
+}
+
+static void decode_instructions_at_pc(const char* header,
+                                      codeptr_t pc, int num_before,
+                                      int num_after, outputStream* st) {
+  // TODO: PPC port Disassembler::decode(pc, 16, 16, st);
+}
+
+
+void AixNativeCallstack::print_callstack_for_context(outputStream* st, const ucontext_t* context,
+                                                     bool demangle, char* buf, size_t buf_size) {
+
+#define MAX_CALLSTACK_DEPTH 50
+
+  unsigned long* sp;
+  unsigned long* sp_last;
+  int frame;
+
+  // To print the first frame, use the current value of iar:
+  // current entry indicated by iar (the current pc)
+  codeptr_t cur_iar = 0;
+  stackptr_t cur_sp = 0;
+  codeptr_t cur_rtoc = 0;
+  codeptr_t cur_lr = 0;
+
+  const ucontext_t* uc = (const ucontext_t*) context;
+
+  // fallback: use the current context
+  ucontext_t local_context;
+  if (!uc) {
+    if (getcontext(&local_context) == 0) {
+      uc = &local_context;
+    } else {
+      st->print_cr("No context given and getcontext failed. ");
+      return;
+    }
+  }
+
+  cur_iar = (codeptr_t)uc->uc_mcontext.jmp_context.iar;
+  cur_sp = (stackptr_t)uc->uc_mcontext.jmp_context.gpr[1];
+  cur_rtoc = (codeptr_t)uc->uc_mcontext.jmp_context.gpr[2];
+  cur_lr = (codeptr_t)uc->uc_mcontext.jmp_context.lr;
+
+  // syntax used here:
+  //  n   --------------   <-- stack_base,   stack_to
+  //  n-1 |            |
+  //  ... | older      |
+  //  ... |   frames   | |
+  //      |            | | stack grows downward
+  //  ... | younger    | |
+  //  ... |   frames   | V
+  //      |            |
+  //      |------------|   <-- cur_sp, current stack ptr
+  //      |            |
+  //      |  unsused   |
+  //      |    stack   |
+  //      |            |
+  //      .            .
+  //      .            .
+  //      .            .
+  //      .            .
+  //      |            |
+  //   0  --------------   <-- stack_from
+  //
+
+  // Retrieve current stack base, size from the current thread. If there is none,
+  // retrieve it from the OS.
+  stackptr_t stack_base = NULL;
+  size_t stack_size = NULL;
+  Thread* const thread = Thread::current_or_null_safe();
+  if (thread) {
+    stack_base = (stackptr_t) thread->stack_base();
+    stack_size = thread->stack_size();
+  } else {
+    stack_base = (stackptr_t) os::current_stack_base();
+    stack_size = os::current_stack_size();
+  }
+
+  st->print_cr("------ current frame:");
+  st->print("iar:  " PTR64_FORMAT " ", p2i(cur_iar));
+  print_info_for_pc(st, cur_iar, buf, buf_size, demangle);
+  st->cr();
+
+  if (cur_iar && MiscUtils::is_readable_pointer(cur_iar)) {
+    decode_instructions_at_pc(
+      "Decoded instructions at iar:",
+      cur_iar, 32, 16, st);
+  }
+
+  // Print out lr too, which may be interesting if we did jump to some bogus location;
+  // in those cases the new frame is not built up yet and the caller location is only
+  // preserved via lr register.
+  st->print("lr:   " PTR64_FORMAT " ", p2i(cur_lr));
+  print_info_for_pc(st, cur_lr, buf, buf_size, demangle);
+  st->cr();
+
+  if (cur_lr && MiscUtils::is_readable_pointer(cur_lr)) {
+    decode_instructions_at_pc(
+      "Decoded instructions at lr:",
+      cur_lr, 32, 16, st);
+  }
+
+  // Check and print sp.
+  st->print("sp:   " PTR64_FORMAT " ", p2i(cur_sp));
+  if (!is_valid_stackpointer(cur_sp, stack_base, stack_size)) {
+    st->print("(invalid) ");
+    goto cleanup;
+  } else {
+    st->print("(base - 0x%X) ", PTRDIFF_BYTES(stack_base, cur_sp));
+  }
+  st->cr();
+
+  // Check and print rtoc.
+  st->print("rtoc: "  PTR64_FORMAT " ", p2i(cur_rtoc));
+  if (cur_rtoc == NULL || cur_rtoc == (codeptr_t)-1 ||
+      !MiscUtils::is_readable_pointer(cur_rtoc)) {
+    st->print("(invalid)");
+  } else if (((uintptr_t)cur_rtoc) & 0x7) {
+    st->print("(unaligned)");
+  }
+  st->cr();
+
+  st->print_cr("|---stackaddr----|   |----lrsave------|:   <function name>");
+
+  ///
+  // Walk callstack.
+  //
+  // (if no context was given, use the current stack)
+  sp = (unsigned long*)(*(unsigned long*)cur_sp); // Stack pointer
+  sp_last = cur_sp;
+
+  frame = 0;
+
+  while (frame < MAX_CALLSTACK_DEPTH) {
+
+    // Check sp.
+    bool retry = false;
+    if (sp == NULL) {
+      // The backchain pointer was NULL. This normally means the end of the chain. But the
+      // stack might be corrupted, and it may be worth looking for the stack chain.
+      if (is_valid_stackpointer(sp_last, stack_base, stack_size) && (stack_base - 0x10) > sp_last) {
+        // If we are not within <guess> 0x10 stackslots of the stack base, we assume that this
+        // is indeed not the end of the chain but that the stack was corrupted. So lets try to
+        // find the end of the chain.
+        st->print_cr("*** back chain pointer is NULL - end of stack or broken backchain ? ***");
+        retry = true;
+      } else {
+        st->print_cr("*** end of backchain ***");
+        goto end_walk_callstack;
+      }
+    } else if (!is_valid_stackpointer(sp, stack_base, stack_size)) {
+      st->print_cr("*** stack pointer invalid - backchain corrupted (" PTR_FORMAT ") ***", p2i(sp));
+      retry = true;
+    } else if (sp < sp_last) {
+      st->print_cr("invalid stack pointer: " PTR_FORMAT " (not monotone raising)", p2i(sp));
+      retry = true;
+    }
+
+    // If backchain is broken, try to recover, by manually scanning the stack for a pattern
+    // which looks like a valid stack.
+    if (retry) {
+      st->print_cr("trying to recover and find backchain...");
+      sp = try_find_backchain(sp_last, stack_base, stack_size);
+      if (sp) {
+        st->print_cr("found something which looks like a backchain at " PTR64_FORMAT ", after 0x%x bytes... ",
+            p2i(sp), PTRDIFF_BYTES(sp, sp_last));
+      } else {
+        st->print_cr("did not find a backchain, giving up.");
+        goto end_walk_callstack;
+      }
+    }
+
+    // Print stackframe.
+    print_stackframe(st, sp, buf, buf_size, demangle);
+    st->cr();
+    frame ++;
+
+    // Next stack frame and link area.
+    sp_last = sp;
+    sp = (unsigned long*)(*sp);
+  }
+
+  // Prevent endless loops in case of invalid callstacks.
+  if (frame == MAX_CALLSTACK_DEPTH) {
+    st->print_cr("...(stopping after %d frames.", MAX_CALLSTACK_DEPTH);
+  }
+
+end_walk_callstack:
+
+  st->print_cr("-----------------------");
+
+cleanup:
+
+  return;
+
+}
+
+
+
+
--- a/src/os/aix/vm/porting_aix.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/aix/vm/porting_aix.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -61,24 +61,37 @@
 #endif
 int dladdr(void *addr, Dl_info *info);
 
-typedef unsigned int* codeptr_t;
-
 struct tbtable;
 
-// helper function - given a program counter, tries to locate the traceback table and
-// returns info from it (like, most importantly, function name, displacement of the
-// pc inside the function, and the traceback table itself.
-#ifdef __cplusplus
-extern "C"
-#endif
-int getFuncName(
-      codeptr_t pc,                    // [in] program counter
-      char* p_name, size_t namelen,    // [out] optional: user provided buffer for the function name
-      int* p_displacement,             // [out] optional: displacement
-      const struct tbtable** p_tb,     // [out] optional: ptr to traceback table to get further information
-      char* p_errmsg, size_t errmsglen, // [out] optional: user provided buffer for error messages
-      bool demangle                    // [in] whether to demangle the name
-    );
+class AixSymbols {
+ public:
+
+  // Given a program counter, tries to locate the traceback table and returns info from
+  // it - e.g. function name, displacement of the pc inside the function, and the traceback
+  // table itself.
+  static bool get_function_name (
+    address pc,                      // [in] program counter
+    char* p_name, size_t namelen,    // [out] optional: user provided buffer for the function name
+    int* p_displacement,             // [out] optional: displacement
+    const struct tbtable** p_tb,     // [out] optional: ptr to traceback table to get further information
+    bool demangle                    // [in] whether to demangle the name
+  );
+
+  // Given a program counter, returns the name of the module (library and module) the pc points to
+  static bool get_module_name (
+    address pc,                      // [in] program counter
+    char* p_name, size_t namelen     // [out] module name
+  );
+
+};
+
+class AixNativeCallstack {
+ public:
+  static void print_callstack_for_context(outputStream* st, const ucontext_t* uc,
+                                          bool demangle,
+                                          char* buf, size_t buf_size);
+};
+
 
 #endif // OS_AIX_VM_PORTING_AIX_HPP
 
--- a/src/os/bsd/vm/os_bsd.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/bsd/vm/os_bsd.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -3481,7 +3481,7 @@
   os::Bsd::min_stack_allowed = MAX2(os::Bsd::min_stack_allowed,
                                     JavaThread::stack_guard_zone_size() +
                                     JavaThread::stack_shadow_zone_size() +
-                                    2*BytesPerWord COMPILER2_PRESENT(+1) * Bsd::page_size());
+                                    (2*BytesPerWord COMPILER2_PRESENT(+1)) * Bsd::page_size());
 
   size_t threadStackSizeInBytes = ThreadStackSize * K;
   if (threadStackSizeInBytes != 0 &&
--- a/src/os/bsd/vm/os_bsd.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/bsd/vm/os_bsd.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
 
 
 // Bang the shadow pages if they need to be touched to be mapped.
-inline void os::bang_stack_shadow_pages() {
+inline void os::map_stack_shadow_pages() {
 }
 
 inline void os::dll_unload(void *lib) {
--- a/src/os/linux/vm/os_linux.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/linux/vm/os_linux.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@
 
 
 // Bang the shadow pages if they need to be touched to be mapped.
-inline void os::bang_stack_shadow_pages() {
+inline void os::map_stack_shadow_pages() {
 }
 
 inline void os::dll_unload(void *lib) {
--- a/src/os/solaris/vm/os_solaris.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/solaris/vm/os_solaris.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -819,19 +819,19 @@
 void os::Solaris::hotspot_sigmask(Thread* thread) {
   //Save caller's signal mask
   sigset_t sigmask;
-  thr_sigsetmask(SIG_SETMASK, NULL, &sigmask);
+  pthread_sigmask(SIG_SETMASK, NULL, &sigmask);
   OSThread *osthread = thread->osthread();
   osthread->set_caller_sigmask(sigmask);
 
-  thr_sigsetmask(SIG_UNBLOCK, os::Solaris::unblocked_signals(), NULL);
+  pthread_sigmask(SIG_UNBLOCK, os::Solaris::unblocked_signals(), NULL);
   if (!ReduceSignalUsage) {
     if (thread->is_VM_thread()) {
       // Only the VM thread handles BREAK_SIGNAL ...
-      thr_sigsetmask(SIG_UNBLOCK, vm_signals(), NULL);
+      pthread_sigmask(SIG_UNBLOCK, vm_signals(), NULL);
     } else {
       // ... all other threads block BREAK_SIGNAL
       assert(!sigismember(vm_signals(), SIGINT), "SIGINT should not be blocked");
-      thr_sigsetmask(SIG_BLOCK, vm_signals(), NULL);
+      pthread_sigmask(SIG_BLOCK, vm_signals(), NULL);
     }
   }
 }
@@ -1188,7 +1188,7 @@
   if (Thread::current()->osthread() == osthread) {
     // Restore caller's signal mask
     sigset_t sigmask = osthread->caller_sigmask();
-    thr_sigsetmask(SIG_SETMASK, &sigmask, NULL);
+    pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
   }
   delete osthread;
 }
@@ -3561,7 +3561,7 @@
       sigset_t suspend_set;  // signals for sigsuspend()
 
       // get current set of blocked signals and unblock resume signal
-      thr_sigsetmask(SIG_BLOCK, NULL, &suspend_set);
+      pthread_sigmask(SIG_BLOCK, NULL, &suspend_set);
       sigdelset(&suspend_set, os::Solaris::SIGasync());
 
       sr_semaphore.signal();
@@ -3838,7 +3838,7 @@
 
     // try to honor the signal mask
     sigset_t oset;
-    thr_sigsetmask(SIG_SETMASK, &(actp->sa_mask), &oset);
+    pthread_sigmask(SIG_SETMASK, &(actp->sa_mask), &oset);
 
     // call into the chained handler
     if (siginfo_flag_set) {
@@ -3848,7 +3848,7 @@
     }
 
     // restore the signal mask
-    thr_sigsetmask(SIG_SETMASK, &oset, 0);
+    pthread_sigmask(SIG_SETMASK, &oset, 0);
   }
   // Tell jvm's signal handler the signal is taken care of.
   return true;
@@ -4415,7 +4415,7 @@
   os::Solaris::min_stack_allowed = MAX2(os::Solaris::min_stack_allowed,
                                         JavaThread::stack_guard_zone_size() +
                                         JavaThread::stack_shadow_zone_size() +
-                                        2*BytesPerWord COMPILER2_PRESENT(+1) * page_size);
+                                        (2*BytesPerWord COMPILER2_PRESENT(+1)) * page_size);
 
   size_t threadStackSizeInBytes = ThreadStackSize * K;
   if (threadStackSizeInBytes != 0 &&
@@ -5492,7 +5492,7 @@
   // (This allows a debugger to break into the running thread.)
   sigset_t oldsigs;
   sigset_t* allowdebug_blocked = os::Solaris::allowdebug_blocked_signals();
-  thr_sigsetmask(SIG_BLOCK, allowdebug_blocked, &oldsigs);
+  pthread_sigmask(SIG_BLOCK, allowdebug_blocked, &oldsigs);
 #endif
 
   OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
@@ -5519,7 +5519,7 @@
                 status, "cond_timedwait");
 
 #ifdef ASSERT
-  thr_sigsetmask(SIG_SETMASK, &oldsigs, NULL);
+  pthread_sigmask(SIG_SETMASK, &oldsigs, NULL);
 #endif
   _counter = 0;
   status = os::Solaris::mutex_unlock(_mutex);
@@ -5667,8 +5667,6 @@
 
 size_t os::write(int fd, const void *buf, unsigned int nBytes) {
   size_t res;
-  assert(((JavaThread*)Thread::current())->thread_state() == _thread_in_native,
-         "Assumed _thread_in_native");
   RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
   return res;
 }
--- a/src/os/solaris/vm/os_solaris.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/solaris/vm/os_solaris.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@
 
 
 // Bang the shadow pages if they need to be touched to be mapped.
-inline void os::bang_stack_shadow_pages() {
+inline void os::map_stack_shadow_pages() {
 }
 inline void os::dll_unload(void *lib) { ::dlclose(lib); }
 
--- a/src/os/windows/vm/os_windows.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/windows/vm/os_windows.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -3318,6 +3318,35 @@
   return os::uncommit_memory(addr, size);
 }
 
+static bool protect_pages_individually(char* addr, size_t bytes, unsigned int p, DWORD *old_status) {
+  uint count = 0;
+  bool ret = false;
+  size_t bytes_remaining = bytes;
+  char * next_protect_addr = addr;
+
+  // Use VirtualQuery() to get the chunk size.
+  while (bytes_remaining) {
+    MEMORY_BASIC_INFORMATION alloc_info;
+    if (VirtualQuery(next_protect_addr, &alloc_info, sizeof(alloc_info)) == 0) {
+      return false;
+    }
+
+    size_t bytes_to_protect = MIN2(bytes_remaining, (size_t)alloc_info.RegionSize);
+    // We used different API at allocate_pages_individually() based on UseNUMAInterleaving,
+    // but we don't distinguish here as both cases are protected by same API.
+    ret = VirtualProtect(next_protect_addr, bytes_to_protect, p, old_status) != 0;
+    warning("Failed protecting pages individually for chunk #%u", count);
+    if (!ret) {
+      return false;
+    }
+
+    bytes_remaining -= bytes_to_protect;
+    next_protect_addr += bytes_to_protect;
+    count++;
+  }
+  return ret;
+}
+
 // Set protections specified
 bool os::protect_memory(char* addr, size_t bytes, ProtType prot,
                         bool is_committed) {
@@ -3345,7 +3374,25 @@
   // Pages in the region become guard pages. Any attempt to access a guard page
   // causes the system to raise a STATUS_GUARD_PAGE exception and turn off
   // the guard page status. Guard pages thus act as a one-time access alarm.
-  return VirtualProtect(addr, bytes, p, &old_status) != 0;
+  bool ret;
+  if (UseNUMAInterleaving) {
+    // If UseNUMAInterleaving is enabled, the pages may have been allocated a chunk at a time,
+    // so we must protect the chunks individually.
+    ret = protect_pages_individually(addr, bytes, p, &old_status);
+  } else {
+    ret = VirtualProtect(addr, bytes, p, &old_status) != 0;
+  }
+#ifdef ASSERT
+  if (!ret) {
+    int err = os::get_last_error();
+    char buf[256];
+    size_t buf_len = os::lasterror(buf, sizeof(buf));
+    warning("INFO: os::protect_memory(" PTR_FORMAT ", " SIZE_FORMAT
+          ") failed; error='%s' (DOS error/errno=%d)", addr, bytes,
+          buf_len != 0 ? buf : "<no_error_string>", err);
+  }
+#endif
+  return ret;
 }
 
 bool os::guard_memory(char* addr, size_t bytes) {
@@ -3768,6 +3815,7 @@
   return NULL;
 }
 
+#define MAXIMUM_THREADS_TO_KEEP (16 * MAXIMUM_WAIT_OBJECTS)
 #define EXIT_TIMEOUT 300000 /* 5 minutes */
 
 static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) {
@@ -3786,7 +3834,7 @@
     // _endthreadex().
     // Should be large enough to avoid blocking the exiting thread due to lack of
     // a free slot.
-    static HANDLE handles[MAXIMUM_WAIT_OBJECTS];
+    static HANDLE handles[MAXIMUM_THREADS_TO_KEEP];
     static int handle_count = 0;
 
     static INIT_ONCE init_once_crit_sect = INIT_ONCE_STATIC_INIT;
@@ -3800,6 +3848,11 @@
     if (!InitOnceExecuteOnce(&init_once_crit_sect, init_crit_sect_call, &crit_sect, NULL)) {
       warning("crit_sect initialization failed in %s: %d\n", __FILE__, __LINE__);
     } else if (OrderAccess::load_acquire(&process_exiting) == 0) {
+      if (what != EPT_THREAD) {
+        // Atomically set process_exiting before the critical section
+        // to increase the visibility between racing threads.
+        Atomic::cmpxchg((jint)GetCurrentThreadId(), &process_exiting, 0);
+      }
       EnterCriticalSection(&crit_sect);
 
       if (what == EPT_THREAD && OrderAccess::load_acquire(&process_exiting) == 0) {
@@ -3820,14 +3873,14 @@
 
         // If there's no free slot in the array of the kept handles, we'll have to
         // wait until at least one thread completes exiting.
-        if ((handle_count = j) == MAXIMUM_WAIT_OBJECTS) {
+        if ((handle_count = j) == MAXIMUM_THREADS_TO_KEEP) {
           // Raise the priority of the oldest exiting thread to increase its chances
           // to complete sooner.
           SetThreadPriority(handles[0], THREAD_PRIORITY_ABOVE_NORMAL);
           res = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, handles, FALSE, EXIT_TIMEOUT);
           if (res >= WAIT_OBJECT_0 && res < (WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS)) {
             i = (res - WAIT_OBJECT_0);
-            handle_count = MAXIMUM_WAIT_OBJECTS - 1;
+            handle_count = MAXIMUM_THREADS_TO_KEEP - 1;
             for (; i < handle_count; ++i) {
               handles[i] = handles[i + 1];
             }
@@ -3836,7 +3889,7 @@
                     (res == WAIT_FAILED ? "failed" : "timed out"),
                     GetLastError(), __FILE__, __LINE__);
             // Don't keep handles, if we failed waiting for them.
-            for (i = 0; i < MAXIMUM_WAIT_OBJECTS; ++i) {
+            for (i = 0; i < MAXIMUM_THREADS_TO_KEEP; ++i) {
               CloseHandle(handles[i]);
             }
             handle_count = 0;
@@ -3857,42 +3910,59 @@
         // The current exiting thread has stored its handle in the array, and now
         // should leave the critical section before calling _endthreadex().
 
-      } else if (what != EPT_THREAD) {
-        if (handle_count > 0) {
-          // Before ending the process, make sure all the threads that had called
-          // _endthreadex() completed.
-
-          // Set the priority level of the current thread to the same value as
-          // the priority level of exiting threads.
-          // This is to ensure it will be given a fair chance to execute if
-          // the timeout expires.
-          hthr = GetCurrentThread();
-          SetThreadPriority(hthr, THREAD_PRIORITY_ABOVE_NORMAL);
-          for (i = 0; i < handle_count; ++i) {
-            SetThreadPriority(handles[i], THREAD_PRIORITY_ABOVE_NORMAL);
+      } else if (what != EPT_THREAD && handle_count > 0) {
+        jlong start_time, finish_time, timeout_left;
+        // Before ending the process, make sure all the threads that had called
+        // _endthreadex() completed.
+
+        // Set the priority level of the current thread to the same value as
+        // the priority level of exiting threads.
+        // This is to ensure it will be given a fair chance to execute if
+        // the timeout expires.
+        hthr = GetCurrentThread();
+        SetThreadPriority(hthr, THREAD_PRIORITY_ABOVE_NORMAL);
+        start_time = os::javaTimeNanos();
+        finish_time = start_time + ((jlong)EXIT_TIMEOUT * 1000000L);
+        for (i = 0; ; ) {
+          int portion_count = handle_count - i;
+          if (portion_count > MAXIMUM_WAIT_OBJECTS) {
+            portion_count = MAXIMUM_WAIT_OBJECTS;
           }
-          res = WaitForMultipleObjects(handle_count, handles, TRUE, EXIT_TIMEOUT);
+          for (j = 0; j < portion_count; ++j) {
+            SetThreadPriority(handles[i + j], THREAD_PRIORITY_ABOVE_NORMAL);
+          }
+          timeout_left = (finish_time - start_time) / 1000000L;
+          if (timeout_left < 0) {
+            timeout_left = 0;
+          }
+          res = WaitForMultipleObjects(portion_count, handles + i, TRUE, timeout_left);
           if (res == WAIT_FAILED || res == WAIT_TIMEOUT) {
             warning("WaitForMultipleObjects %s (%u) in %s: %d\n",
                     (res == WAIT_FAILED ? "failed" : "timed out"),
                     GetLastError(), __FILE__, __LINE__);
+            // Reset portion_count so we close the remaining
+            // handles due to this error.
+            portion_count = handle_count - i;
           }
-          for (i = 0; i < handle_count; ++i) {
-            CloseHandle(handles[i]);
+          for (j = 0; j < portion_count; ++j) {
+            CloseHandle(handles[i + j]);
           }
-          handle_count = 0;
+          if ((i += portion_count) >= handle_count) {
+            break;
+          }
+          start_time = os::javaTimeNanos();
         }
-
-        OrderAccess::release_store(&process_exiting, 1);
+        handle_count = 0;
       }
 
       LeaveCriticalSection(&crit_sect);
     }
 
-    if (what == EPT_THREAD) {
-      while (OrderAccess::load_acquire(&process_exiting) != 0) {
-        // Some other thread is about to call exit(), so we
-        // don't let the current thread proceed to _endthreadex()
+    if (OrderAccess::load_acquire(&process_exiting) != 0 &&
+        process_exiting != (jint)GetCurrentThreadId()) {
+      // Some other thread is about to call exit(), so we
+      // don't let the current thread proceed to exit() or _endthreadex()
+      while (true) {
         SuspendThread(GetCurrentThread());
         // Avoid busy-wait loop, if SuspendThread() failed.
         Sleep(EXIT_TIMEOUT);
--- a/src/os/windows/vm/os_windows.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os/windows/vm/os_windows.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
 }
 
 // Bang the shadow pages if they need to be touched to be mapped.
-inline void os::bang_stack_shadow_pages() {
+inline void os::map_stack_shadow_pages() {
   // Write to each page of our new frame to force OS mapping.
   // If we decrement stack pointer more than one page
   // the OS may not map an intervening page into our space
--- a/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -40,6 +40,7 @@
 #include "prims/jniFastGetField.hpp"
 #include "prims/jvm.h"
 #include "prims/jvm_misc.hpp"
+#include "porting_aix.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/extendedPC.hpp"
 #include "runtime/frame.inline.hpp"
@@ -579,3 +580,9 @@
   return 0;
 }
 
+bool os::platform_print_native_stack(outputStream* st, void* context, char *buf, int buf_size) {
+  AixNativeCallstack::print_callstack_for_context(st, (const ucontext_t*)context, true, buf, (size_t) buf_size);
+  return true;
+}
+
+
--- a/src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/os_cpu/aix_ppc/vm/os_aix_ppc.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -32,4 +32,8 @@
   // Note: Currently only used in 64 bit Windows implementations
   static bool register_code_area(char *low, char *high) { return true; }
 
+#define PLATFORM_PRINT_NATIVE_STACK 1
+static bool platform_print_native_stack(outputStream* st, void* context,
+                                        char *buf, int buf_size);
+
 #endif // OS_CPU_AIX_PPC_VM_OS_AIX_PPC_HPP
--- a/src/share/vm/asm/codeBuffer.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/asm/codeBuffer.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -535,7 +535,7 @@
 }
 
 void CodeBuffer::finalize_oop_references(const methodHandle& mh) {
-  No_Safepoint_Verifier nsv;
+  NoSafepointVerifier nsv;
 
   GrowableArray<oop> oops;
 
--- a/src/share/vm/c1/c1_Runtime1.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -554,12 +554,11 @@
     // tracing
     if (log_is_enabled(Info, exceptions)) {
       ResourceMark rm;
-      log_info(exceptions)("Exception <%s> (" INTPTR_FORMAT
-                           ") thrown in compiled method <%s> at PC " INTPTR_FORMAT
-                           " for thread " INTPTR_FORMAT,
-                           exception->print_value_string(),
-                           p2i((address)exception()),
-                           nm->method()->print_value_string(), p2i(pc), p2i(thread));
+      stringStream tempst;
+      tempst.print("compiled method <%s>\n"
+                   " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
+                   nm->method()->print_value_string(), p2i(pc), p2i(thread));
+      Exceptions::log_exception(exception, tempst);
     }
     // for AbortVMOnException flag
     Exceptions::debug_check_abort(exception);
--- a/src/share/vm/ci/ciEnv.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/ci/ciEnv.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -969,7 +969,7 @@
     // and invalidating our dependencies until we install this method.
     // No safepoints are allowed. Otherwise, class redefinition can occur in between.
     MutexLocker ml(Compile_lock);
-    No_Safepoint_Verifier nsv;
+    NoSafepointVerifier nsv;
 
     // Change in Jvmti state may invalidate compilation.
     if (!failing() && jvmti_state_changed()) {
--- a/src/share/vm/ci/ciField.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/ci/ciField.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -72,7 +72,7 @@
 
   assert(ciObjectFactory::is_initialized(), "not a shared field");
 
-  assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constan-pool");
+  assert(klass->get_instanceKlass()->is_linked(), "must be linked before using its constant-pool");
 
   constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants());
 
@@ -106,10 +106,31 @@
   // even though we may not need to.
   int holder_index = cpool->klass_ref_index_at(index);
   bool holder_is_accessible;
-  ciInstanceKlass* declared_holder =
-    ciEnv::current(thread)->get_klass_by_index(cpool, holder_index,
-                                               holder_is_accessible,
-                                               klass)->as_instance_klass();
+
+  ciKlass* generic_declared_holder = ciEnv::current(thread)->get_klass_by_index(cpool, holder_index,
+                                                                                holder_is_accessible,
+                                                                                klass);
+
+  if (generic_declared_holder->is_array_klass()) {
+    // If the declared holder of the field is an array class, assume that
+    // the canonical holder of that field is java.lang.Object. Arrays
+    // do not have fields; java.lang.Object is the only supertype of an
+    // array type that can declare fields and is therefore the canonical
+    // holder of the array type.
+    //
+    // Furthermore, the compilers assume that java.lang.Object does not
+    // have any fields. Therefore, the field is not looked up. Instead,
+    // the method returns partial information that will trigger special
+    // handling in ciField::will_link and will result in a
+    // java.lang.NoSuchFieldError exception being thrown by the compiled
+    // code (the expected behavior in this case).
+    _holder = ciEnv::current(thread)->Object_klass();
+    _offset = -1;
+    _is_constant = false;
+    return;
+  }
+
+  ciInstanceKlass* declared_holder = generic_declared_holder->as_instance_klass();
 
   // The declared holder of this field may not have been loaded.
   // Bail out with partial field information.
--- a/src/share/vm/ci/ciInstance.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/ci/ciInstance.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 
 protected:
   ciInstance(instanceHandle h_i) : ciObject(h_i) {
-    assert(h_i()->is_instance(), "wrong type");
+    assert(h_i()->is_instance_noinline(), "wrong type");
   }
 
   ciInstance(ciKlass* klass) : ciObject(klass) {}
--- a/src/share/vm/ci/ciTypeFlow.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/ci/ciTypeFlow.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -2930,7 +2930,7 @@
   }
 
   // Dominated[i] is true if block i is dominated by dom_block
-  int num_blocks = _methodBlocks->num_blocks();
+  int num_blocks = block_count();
   bool* dominated = NEW_RESOURCE_ARRAY(bool, num_blocks);
   for (int i = 0; i < num_blocks; ++i) {
     dominated[i] = true;
--- a/src/share/vm/classfile/altHashing.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/altHashing.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -300,4 +300,8 @@
   testMurmur3_32_ByteArray();
   testEquivalentHashes();
 }
+
+void AltHashing_test() {
+  AltHashing::test_alt_hash();
+}
 #endif // PRODUCT
--- a/src/share/vm/classfile/classFileParser.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/classFileParser.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -863,7 +863,7 @@
     initialize_hashtable(interface_names);
     bool dup = false;
     {
-      debug_only(No_Safepoint_Verifier nsv;)
+      debug_only(NoSafepointVerifier nsv;)
       for (index = 0; index < itfs_len; index++) {
         const Klass* const k = _local_interfaces->at(index);
         const Symbol* const name = InstanceKlass::cast(k)->name();
@@ -1620,7 +1620,7 @@
     initialize_hashtable(names_and_sigs);
     bool dup = false;
     {
-      debug_only(No_Safepoint_Verifier nsv;)
+      debug_only(NoSafepointVerifier nsv;)
       for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) {
         const Symbol* const name = fs.name();
         const Symbol* const sig = fs.signature();
@@ -2885,7 +2885,7 @@
       initialize_hashtable(names_and_sigs);
       bool dup = false;
       {
-        debug_only(No_Safepoint_Verifier nsv;)
+        debug_only(NoSafepointVerifier nsv;)
         for (int i = 0; i < length; i++) {
           const Method* const m = _methods->at(i);
           // If no duplicates, add name/signature in hashtable names_and_sigs.
--- a/src/share/vm/classfile/classLoader.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/classLoader.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
 #include "memory/universe.inline.hpp"
 #include "oops/instanceKlass.hpp"
 #include "oops/instanceRefKlass.hpp"
+#include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/symbol.hpp"
 #include "prims/jvm_misc.hpp"
--- a/src/share/vm/classfile/classLoaderData.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/classLoaderData.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -574,9 +574,9 @@
   // actual ClassLoaderData object.
   ClassLoaderData::Dependencies dependencies(CHECK_NULL);
 
-  No_Safepoint_Verifier no_safepoints; // we mustn't GC until we've installed the
-                                       // ClassLoaderData in the graph since the CLD
-                                       // contains unhandled oops
+  NoSafepointVerifier no_safepoints; // we mustn't GC until we've installed the
+                                     // ClassLoaderData in the graph since the CLD
+                                     // contains unhandled oops
 
   ClassLoaderData* cld = new ClassLoaderData(loader, is_anonymous, dependencies);
 
--- a/src/share/vm/classfile/classLoaderData.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/classLoaderData.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -275,9 +275,7 @@
   // Used to make sure that this CLD is not unloaded.
   void set_keep_alive(bool value) { _keep_alive = value; }
 
-  unsigned int identity_hash() const {
-    return _class_loader == NULL ? 0 : _class_loader->identity_hash();
-  }
+  inline unsigned int identity_hash() const;
 
   // Used when tracing from klasses.
   void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim);
--- a/src/share/vm/classfile/classLoaderData.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/classLoaderData.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,11 @@
 
 #include "classfile/classLoaderData.hpp"
 #include "classfile/javaClasses.hpp"
+#include "oops/oop.inline.hpp"
+
+unsigned int ClassLoaderData::identity_hash() const {
+  return _class_loader == NULL ? 0 : _class_loader->identity_hash();
+}
 
 inline ClassLoaderData* ClassLoaderData::class_loader_data_or_null(oop loader) {
   if (loader == NULL) {
--- a/src/share/vm/classfile/dictionary.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/dictionary.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/classLoaderData.inline.hpp"
 #include "classfile/sharedClassUtil.hpp"
 #include "classfile/dictionary.hpp"
 #include "classfile/systemDictionary.hpp"
@@ -500,6 +501,15 @@
   }
 }
 
+
+unsigned int ProtectionDomainCacheTable::compute_hash(oop protection_domain) {
+  return (unsigned int)(protection_domain->identity_hash());
+}
+
+int ProtectionDomainCacheTable::index_for(oop protection_domain) {
+  return hash_to_index(compute_hash(protection_domain));
+}
+
 ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
   : Hashtable<oop, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
 {
--- a/src/share/vm/classfile/dictionary.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/dictionary.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -196,14 +196,9 @@
     return entry;
   }
 
-  static unsigned int compute_hash(oop protection_domain) {
-    return (unsigned int)(protection_domain->identity_hash());
-  }
+  static unsigned int compute_hash(oop protection_domain);
 
-  int index_for(oop protection_domain) {
-    return hash_to_index(compute_hash(protection_domain));
-  }
-
+  int index_for(oop protection_domain);
   ProtectionDomainCacheEntry* add_entry(int index, unsigned int hash, oop protection_domain);
   ProtectionDomainCacheEntry* find_entry(int index, oop protection_domain);
 
--- a/src/share/vm/classfile/javaAssertions.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/javaAssertions.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 #include "classfile/vmSymbols.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/oopFactory.hpp"
+#include "oops/objArrayOop.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/handles.inline.hpp"
 
--- a/src/share/vm/classfile/javaClasses.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/javaClasses.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1524,7 +1524,7 @@
   objArrayOop     _mirrors;
   typeArrayOop    _cprefs; // needed to insulate method name against redefinition
   int             _index;
-  No_Safepoint_Verifier _nsv;
+  NoSafepointVerifier _nsv;
 
  public:
 
@@ -1583,7 +1583,7 @@
 
   void expand(TRAPS) {
     objArrayHandle old_head(THREAD, _head);
-    Pause_No_Safepoint_Verifier pnsv(&_nsv);
+    PauseNoSafepointVerifier pnsv(&_nsv);
 
     objArrayOop head = oopFactory::new_objectArray(trace_size, CHECK);
     objArrayHandle new_head(THREAD, head);
--- a/src/share/vm/classfile/javaClasses.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/javaClasses.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,12 +60,7 @@
 
   static Handle basic_create(int length, bool byte_arr, TRAPS);
 
-  static void set_coder(oop string, jbyte coder) {
-    assert(initialized, "Must be initialized");
-    if (coder_offset > 0) {
-      string->byte_field_put(coder_offset, coder);
-    }
-  }
+  static inline void set_coder(oop string, jbyte coder);
 
  public:
 
@@ -110,55 +105,15 @@
     return coder_offset;
   }
 
-  static void set_value_raw(oop string, typeArrayOop buffer) {
-    assert(initialized, "Must be initialized");
-    string->obj_field_put_raw(value_offset, buffer);
-  }
-  static void set_value(oop string, typeArrayOop buffer) {
-    assert(initialized && (value_offset > 0), "Must be initialized");
-    string->obj_field_put(value_offset, (oop)buffer);
-  }
-  static void set_hash(oop string, unsigned int hash) {
-    assert(initialized && (hash_offset > 0), "Must be initialized");
-    string->int_field_put(hash_offset, hash);
-  }
+  static inline void set_value_raw(oop string, typeArrayOop buffer);
+  static inline void set_value(oop string, typeArrayOop buffer);
+  static inline void set_hash(oop string, unsigned int hash);
 
   // Accessors
-  static typeArrayOop value(oop java_string) {
-    assert(initialized && (value_offset > 0), "Must be initialized");
-    assert(is_instance(java_string), "must be java_string");
-    return (typeArrayOop) java_string->obj_field(value_offset);
-  }
-  static unsigned int hash(oop java_string) {
-    assert(initialized && (hash_offset > 0), "Must be initialized");
-    assert(is_instance(java_string), "must be java_string");
-    return java_string->int_field(hash_offset);
-  }
-  static bool is_latin1(oop java_string) {
-    assert(initialized, "Must be initialized");
-    assert(is_instance(java_string), "must be java_string");
-    if (coder_offset > 0) {
-      jbyte coder = java_string->byte_field(coder_offset);
-      assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
-      return coder == CODER_LATIN1;
-    } else {
-      return false;
-    }
-  }
-  static int length(oop java_string) {
-    assert(initialized, "Must be initialized");
-    assert(is_instance(java_string), "must be java_string");
-    typeArrayOop value_array = ((typeArrayOop)java_string->obj_field(value_offset));
-    if (value_array == NULL) {
-     return 0;
-    }
-    int arr_length = value_array->length();
-    if (!is_latin1(java_string)) {
-      assert((arr_length & 1) == 0, "should be even for UTF16 string");
-      arr_length >>= 1; // convert number of bytes to number of elements
-    }
-    return arr_length;
-  }
+  static inline typeArrayOop value(oop java_string);
+  static inline unsigned int hash(oop java_string);
+  static inline bool is_latin1(oop java_string);
+  static inline int length(oop java_string);
   static int utf8_length(oop java_string);
 
   // String converters
@@ -219,7 +174,7 @@
 
   // Testers
   static bool is_instance(oop obj);
-  static bool is_instance_inlined(oop obj);
+  static inline bool is_instance_inlined(oop obj);
 
   // Debugging
   static void print(oop java_string, outputStream* st);
@@ -911,42 +866,19 @@
   static int number_of_fake_oop_fields;
 
   // Accessors
-  static oop referent(oop ref) {
-    return ref->obj_field(referent_offset);
-  }
-  static void set_referent(oop ref, oop value) {
-    ref->obj_field_put(referent_offset, value);
-  }
-  static void set_referent_raw(oop ref, oop value) {
-    ref->obj_field_put_raw(referent_offset, value);
-  }
-  static HeapWord* referent_addr(oop ref) {
-    return ref->obj_field_addr<HeapWord>(referent_offset);
-  }
-  static oop next(oop ref) {
-    return ref->obj_field(next_offset);
-  }
-  static void set_next(oop ref, oop value) {
-    ref->obj_field_put(next_offset, value);
-  }
-  static void set_next_raw(oop ref, oop value) {
-    ref->obj_field_put_raw(next_offset, value);
-  }
-  static HeapWord* next_addr(oop ref) {
-    return ref->obj_field_addr<HeapWord>(next_offset);
-  }
-  static oop discovered(oop ref) {
-    return ref->obj_field(discovered_offset);
-  }
-  static void set_discovered(oop ref, oop value) {
-    ref->obj_field_put(discovered_offset, value);
-  }
-  static void set_discovered_raw(oop ref, oop value) {
-    ref->obj_field_put_raw(discovered_offset, value);
-  }
-  static HeapWord* discovered_addr(oop ref) {
-    return ref->obj_field_addr<HeapWord>(discovered_offset);
-  }
+  static inline oop referent(oop ref);
+  static inline void set_referent(oop ref, oop value);
+  static inline void set_referent_raw(oop ref, oop value);
+  static inline HeapWord* referent_addr(oop ref);
+  static inline oop next(oop ref);
+  static inline void set_next(oop ref, oop value);
+  static inline void set_next_raw(oop ref, oop value);
+  static inline HeapWord* next_addr(oop ref);
+  static inline oop discovered(oop ref);
+  static inline void set_discovered(oop ref, oop value);
+  static inline void set_discovered_raw(oop ref, oop value);
+  static inline HeapWord* discovered_addr(oop ref);
+
   // Accessors for statics
   static oop  pending_list_lock();
   static oop  pending_list();
--- a/src/share/vm/classfile/javaClasses.inline.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/javaClasses.inline.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,105 @@
 #include "oops/oop.inline.hpp"
 #include "oops/oopsHierarchy.hpp"
 
+void java_lang_String::set_coder(oop string, jbyte coder) {
+  assert(initialized, "Must be initialized");
+  if (coder_offset > 0) {
+    string->byte_field_put(coder_offset, coder);
+  }
+}
+
+void java_lang_String::set_value_raw(oop string, typeArrayOop buffer) {
+  assert(initialized, "Must be initialized");
+  string->obj_field_put_raw(value_offset, buffer);
+}
+void java_lang_String::set_value(oop string, typeArrayOop buffer) {
+  assert(initialized && (value_offset > 0), "Must be initialized");
+  string->obj_field_put(value_offset, (oop)buffer);
+}
+void java_lang_String::set_hash(oop string, unsigned int hash) {
+  assert(initialized && (hash_offset > 0), "Must be initialized");
+  string->int_field_put(hash_offset, hash);
+}
+
+// Accessors
+typeArrayOop java_lang_String::value(oop java_string) {
+  assert(initialized && (value_offset > 0), "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  return (typeArrayOop) java_string->obj_field(value_offset);
+}
+unsigned int java_lang_String::hash(oop java_string) {
+  assert(initialized && (hash_offset > 0), "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  return java_string->int_field(hash_offset);
+}
+bool java_lang_String::is_latin1(oop java_string) {
+  assert(initialized, "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  if (coder_offset > 0) {
+    jbyte coder = java_string->byte_field(coder_offset);
+    assert(CompactStrings || coder == CODER_UTF16, "Must be UTF16 without CompactStrings");
+    return coder == CODER_LATIN1;
+  } else {
+    return false;
+  }
+}
+int java_lang_String::length(oop java_string) {
+  assert(initialized, "Must be initialized");
+  assert(is_instance(java_string), "must be java_string");
+  typeArrayOop value_array = ((typeArrayOop)java_string->obj_field(value_offset));
+  if (value_array == NULL) {
+    return 0;
+  }
+  int arr_length = value_array->length();
+  if (!is_latin1(java_string)) {
+    assert((arr_length & 1) == 0, "should be even for UTF16 string");
+    arr_length >>= 1; // convert number of bytes to number of elements
+  }
+  return arr_length;
+}
+
+bool java_lang_String::is_instance_inlined(oop obj) {
+  return obj != NULL && obj->klass() == SystemDictionary::String_klass();
+}
+
+// Accessors
+oop java_lang_ref_Reference::referent(oop ref) {
+  return ref->obj_field(referent_offset);
+}
+void java_lang_ref_Reference::set_referent(oop ref, oop value) {
+  ref->obj_field_put(referent_offset, value);
+}
+void java_lang_ref_Reference::set_referent_raw(oop ref, oop value) {
+  ref->obj_field_put_raw(referent_offset, value);
+}
+HeapWord* java_lang_ref_Reference::referent_addr(oop ref) {
+  return ref->obj_field_addr<HeapWord>(referent_offset);
+}
+oop java_lang_ref_Reference::next(oop ref) {
+  return ref->obj_field(next_offset);
+}
+void java_lang_ref_Reference::set_next(oop ref, oop value) {
+  ref->obj_field_put(next_offset, value);
+}
+void java_lang_ref_Reference::set_next_raw(oop ref, oop value) {
+  ref->obj_field_put_raw(next_offset, value);
+}
+HeapWord* java_lang_ref_Reference::next_addr(oop ref) {
+  return ref->obj_field_addr<HeapWord>(next_offset);
+}
+oop java_lang_ref_Reference::discovered(oop ref) {
+  return ref->obj_field(discovered_offset);
+}
+void java_lang_ref_Reference::set_discovered(oop ref, oop value) {
+  ref->obj_field_put(discovered_offset, value);
+}
+void java_lang_ref_Reference::set_discovered_raw(oop ref, oop value) {
+  ref->obj_field_put_raw(discovered_offset, value);
+}
+HeapWord* java_lang_ref_Reference::discovered_addr(oop ref) {
+  return ref->obj_field_addr<HeapWord>(discovered_offset);
+}
+
 inline void java_lang_invoke_CallSite::set_target_volatile(oop site, oop target) {
   site->obj_field_put_volatile(_target_offset, target);
 }
@@ -41,10 +140,6 @@
   site->obj_field_put(_target_offset, target);
 }
 
-inline bool java_lang_String::is_instance_inlined(oop obj) {
-  return obj != NULL && obj->klass() == SystemDictionary::String_klass();
-}
-
 inline bool java_lang_invoke_CallSite::is_instance(oop obj) {
   return obj != NULL && is_subclass(obj->klass());
 }
@@ -73,6 +168,9 @@
   return obj != NULL && is_subclass(obj->klass());
 }
 
+
+
+
 inline int Backtrace::merge_bci_and_version(int bci, int version) {
   // only store u2 for version, checking for overflow.
   if (version > USHRT_MAX || version < 0) version = USHRT_MAX;
--- a/src/share/vm/classfile/stringTable.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/stringTable.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 #include "precompiled.hpp"
 #include "classfile/altHashing.hpp"
 #include "classfile/compactHashtable.inline.hpp"
-#include "classfile/javaClasses.hpp"
+#include "classfile/javaClasses.inline.hpp"
 #include "classfile/stringTable.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "gc/shared/collectedHeap.inline.hpp"
@@ -136,7 +136,7 @@
   assert(java_lang_String::equals(string(), name, len),
          "string must be properly initialized");
   // Cannot hit a safepoint in this function because the "this" pointer can move.
-  No_Safepoint_Verifier nsv;
+  NoSafepointVerifier nsv;
 
   // Check if the symbol table has been rehashed, if so, need to recalculate
   // the hash value and index before second lookup.
--- a/src/share/vm/classfile/symbolTable.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/symbolTable.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -264,7 +264,7 @@
   unsigned int hashValue;
   char* name;
   {
-    debug_only(No_Safepoint_Verifier nsv;)
+    debug_only(NoSafepointVerifier nsv;)
 
     name = (char*)sym->base() + begin;
     len = end - begin;
@@ -288,7 +288,7 @@
     buffer[i] = name[i];
   }
   // Make sure there is no safepoint in the code above since name can't move.
-  // We can't include the code in No_Safepoint_Verifier because of the
+  // We can't include the code in NoSafepointVerifier because of the
   // ResourceMark.
 
   // Grab SymbolTable_lock first.
@@ -405,7 +405,7 @@
   }
 
   // Cannot hit a safepoint in this function because the "this" pointer can move.
-  No_Safepoint_Verifier nsv;
+  NoSafepointVerifier nsv;
 
   // Check if the symbol table has been rehashed, if so, need to recalculate
   // the hash value and index.
@@ -454,7 +454,7 @@
   }
 
   // Cannot hit a safepoint in this function because the "this" pointer can move.
-  No_Safepoint_Verifier nsv;
+  NoSafepointVerifier nsv;
 
   for (int i=0; i<names_count; i++) {
     // Check if the symbol table has been rehashed, if so, need to recalculate
@@ -667,3 +667,53 @@
     return 0;
   }
 }
+
+#ifndef PRODUCT
+// Internal test of TempNewSymbol
+void Test_TempNewSymbol() {
+  // Assert messages assume these symbols are unique, and the refcounts start at
+  // one, but code does not rely on this.
+  Thread* THREAD = Thread::current();
+  Symbol* abc = SymbolTable::new_symbol("abc", CATCH);
+  int abccount = abc->refcount();
+  TempNewSymbol ss = abc;
+  assert(ss->refcount() == abccount, "only one abc");
+  assert(ss->refcount() == abc->refcount(), "should match TempNewSymbol");
+
+  Symbol* efg = SymbolTable::new_symbol("efg", CATCH);
+  Symbol* hij = SymbolTable::new_symbol("hij", CATCH);
+  int efgcount = efg->refcount();
+  int hijcount = hij->refcount();
+
+  TempNewSymbol s1 = efg;
+  TempNewSymbol s2 = hij;
+  assert(s1->refcount() == efgcount, "one efg");
+  assert(s2->refcount() == hijcount, "one hij");
+
+  // Assignment operator
+  s1 = s2;
+  assert(hij->refcount() == hijcount + 1, "should be two hij");
+  assert(efg->refcount() == efgcount - 1, "should be no efg");
+
+  s1 = ss;  // s1 is abc
+  assert(s1->refcount() == abccount + 1, "should be two abc (s1 and ss)");
+  assert(hij->refcount() == hijcount, "should only have one hij now (s2)");
+
+  s1 = s1; // self assignment
+  assert(s1->refcount() == abccount + 1, "should still be two abc (s1 and ss)");
+
+  TempNewSymbol s3;
+  Symbol* klm = SymbolTable::new_symbol("klm", CATCH);
+  int klmcount = klm->refcount();
+  s3 = klm;   // assignment
+  assert(s3->refcount() == klmcount, "only one klm now");
+
+  Symbol* xyz = SymbolTable::new_symbol("xyz", CATCH);
+  int xyzcount = xyz->refcount();
+  { // inner scope
+     TempNewSymbol s_inner = xyz;
+  }
+  assert(xyz->refcount() == (xyzcount - 1),
+         "Should have been decremented by dtor in inner scope");
+}
+#endif // PRODUCT
--- a/src/share/vm/classfile/symbolTable.hpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/symbolTable.hpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,8 +42,17 @@
 class BoolObjectClosure;
 class outputStream;
 
-// Class to hold a newly created or referenced Symbol* temporarily in scope.
-// new_symbol() and lookup() will create a Symbol* if not already in the
+// TempNewSymbol acts as a handle class in a handle/body idiom and is
+// responsible for proper resource management of the body (which is a Symbol*).
+// The body is resource managed by a reference counting scheme.
+// TempNewSymbol can therefore be used to properly hold a newly created or referenced
+// Symbol* temporarily in scope.
+//
+// Routines in SymbolTable will initialize the reference count of a Symbol* before
+// it becomes "managed" by TempNewSymbol instances. As a handle class, TempNewSymbol
+// needs to maintain proper reference counting in context of copy semantics.
+//
+// In SymbolTable, new_symbol() and lookup() will create a Symbol* if not already in the
 // symbol table and add to the symbol's reference count.
 // probe() and lookup_only() will increment the refcount if symbol is found.
 class TempNewSymbol : public StackObj {
@@ -51,25 +60,38 @@
 
  public:
   TempNewSymbol() : _temp(NULL) {}
-  // Creating or looking up a symbol increments the symbol's reference count
+
+  // Conversion from a Symbol* to a TempNewSymbol.
+  // Does not increment the current reference count.
   TempNewSymbol(Symbol *s) : _temp(s) {}
 
-  // Operator= increments reference count.
-  void operator=(const TempNewSymbol &s) {
-    //clear();  //FIXME
-    _temp = s._temp;
-    if (_temp !=NULL) _temp->increment_refcount();
+  // Copy constructor increments reference count.
+  TempNewSymbol(const TempNewSymbol& rhs) : _temp(rhs._temp) {
+    if (_temp != NULL) {
+      _temp->increment_refcount();
+    }
   }
 
-  // Decrement reference counter so it can go away if it's unique
-  void clear() { if (_temp != NULL)  _temp->decrement_refcount();  _temp = NULL; }
+  // Assignment operator uses a c++ trick called copy and swap idiom.
+  // rhs is passed by value so within the scope of this method it is a copy.
+  // At method exit it contains the former value of _temp, triggering the correct refcount
+  // decrement upon destruction.
+  void operator=(TempNewSymbol rhs) {
+    Symbol* tmp = rhs._temp;
+    rhs._temp = _temp;
+    _temp = tmp;
+  }
 
-  ~TempNewSymbol() { clear(); }
+  // Decrement reference counter so it can go away if it's unused
+  ~TempNewSymbol() {
+    if (_temp != NULL) {
+      _temp->decrement_refcount();
+    }
+  }
 
-  // Operators so they can be used like Symbols
+  // Symbol* conversion operators
   Symbol* operator -> () const                   { return _temp; }
   bool    operator == (Symbol* o) const          { return _temp == o; }
-  // Sneaky conversion function
   operator Symbol*()                             { return _temp; }
 };
 
--- a/src/share/vm/classfile/systemDictionary.cpp	Wed Feb 03 12:09:12 2016 +0100
+++ b/src/share/vm/classfile/systemDictionary.cpp	Thu Feb 04 09:20:28 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -475,11 +475,11 @@
       // Note that we have an entry, and entries can be deleted only during GC,
       // so we cannot allow GC to occur while we're holding this entry.
 
-      // We're using a No_Safepoint_Verifier to catch any place where we
+      // We're using a NoSafepointVerifier to catch any place where we
       // might potentially do a GC at all.
       // Dictionary::do_unloading() asserts that classes in SD are only
       // unloaded at a safepoint. Anonymous classes are not in SD.
-      No_Safepoint_Verifier nosafepoint;
+      NoSafepointVerifier nosafepoint;
       dictionary()->add_protection_domain(d_index, d_hash, klass, loader_data,
                                           protection_domain, THREAD);
     }
@@ -908,11 +908,11 @@
     MutexLocker mu(SystemDictionary_lock, THREAD);
     // Note that we have an entry, and entries can be deleted only during GC,
     // so we cannot allow GC to occur while we're holding this entry.
-    // We're using a No_Safepoint_Verifier to catch any place where we
+    // We're using a NoSafepointVerifier to catch any place where we
     // might potentially do a GC at all.
     // Dictionary::do_unloading() asserts that classes in SD are only
     // unloaded at a safepoint. Anonymous classes are not in SD.
-    No_Safepoint_Verifier nosafepoint;
+    NoSafepointVerifier nosafepoint;
     if (dictionary()->is_valid_protection_domain(d_index, d_hash, name,
                                                  loader_data,
                                                  protection_domain)) {
@@ -961,11 +961,11 @@
   {
     // Note that we have an entry, and entries can be deleted only during GC,
     // so we cannot allow GC to occur while we're holding this entry.
-    // We're using a No_Safepoint_Verifier to catch any place where we
+    // We're using a NoSafepointVerifier to catch any place where we
     // might potentially do a GC at all.
     // Dictionary::do_unloading() asserts that classes in SD are only
     // unloaded at a safepoint. Anonymous classes are not in SD.
-    No_Safepoint_Verifier nosafepoint;
+    NoSafepointVerifier nosafepoint;
     return dictionary()->find(d_index, d_hash, class_name, loader_data,
                               protection_domain, THREAD);
   }
@@ -1974,12 +1974,11 @@
   InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
   InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
 
-  initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Cleaner_klass), scan, CHECK);
+  initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
   InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
   InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
   InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
   InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
-  InstanceKlass::cast(WK_KLASS(Cleaner_klass))->set_reference_type(REF_CLEANER);
 
   // JSR 292 classes
   WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
@@ -2211,7 +2210,7 @@
   MutexLocker mu_s(SystemDictionary_lock, THREAD);
 
   // Better never do a GC while we're holding these oops
-  No_Safepoint_Verifier nosafepoint;
+  NoSafepointVerifier nosafepoint;
 
   Klass* klass1 = find_class(d_index1, d_hash1, constraint_name, loader_data1);
   Klass* klass2 = find_class(d_index2, d_hash2, constrai