/hg/release/icedtea7-forest-2.6/hotspot: 9 new changesets
andrew at icedtea.classpath.org
andrew at icedtea.classpath.org
Thu Oct 27 05:05:37 UTC 2016
changeset 4cfc65368ce4 in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=4cfc65368ce4
author: andrew
date: Tue Oct 25 04:22:24 2016 +0100
8078628, PR3151: Zero build fails with pre-compiled headers disabled
changeset 8657f5b23db3 in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=8657f5b23db3
author: mikael
date: Wed Oct 26 05:30:06 2016 +0100
8141491, PR3160, G592292: Unaligned memory access in Bits.c
Summary: Introduce alignment-safe Copy::conjoint_swap and j.i.m.Unsafe.copySwapMemory
Reviewed-by: jrose, dholmes, psandoz
changeset 0e9399a0c43d in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=0e9399a0c43d
author: sspitsyn
date: Wed Oct 26 08:28:18 2016 +0100
8076579, PR3162: Popping a stack frame after exception breakpoint sets last method param to exception
Summary: Null the InterpreterRuntime::member_name_arg_or_null return value when it is necessary
Reviewed-by: jbachorik, coleenp, twisti
changeset 228a2db07c72 in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=228a2db07c72
author: hseigel
date: Thu Mar 19 08:55:50 2015 -0400
8075118, PR3162: JVM stuck in infinite loop during verification
Summary: keep a list of handlers to prevent the same handler from being scanned repeatedly.
Reviewed-by: dlong, dholmes
changeset 39f402503b12 in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=39f402503b12
author: poonam
date: Fri Oct 30 08:29:19 2015 -0700
8140249, PR3162: JVM Crashing During startUp If Flight Recording is enabled
Reviewed-by: dholmes
Contributed-by: Shafi Ahmad <shafi.s.ahmad at oracle.com>
changeset f5731ee4cfbd in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=f5731ee4cfbd
author: kevinw
date: Fri Jan 08 05:28:21 2016 -0800
8144483, PR3162: One long Safepoint pause directly after each GC log rotation
Reviewed-by: dholmes
Contributed-by: cheleswer.sahu at oracle.com
changeset 2f48c9cd3e1b in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=2f48c9cd3e1b
author: dbuck
date: Sun Sep 06 05:02:06 2015 -0700
8135002, PR3162: Fix or remove broken links in objectMonitor.cpp comments
Summary: Updated comments to refer to relevant patents.
Reviewed-by: dcubed
changeset 854132273cf4 in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=854132273cf4
author: aph
date: Thu Oct 06 15:11:35 2016 +0000
8167200, PR3204: AArch64: Broken stack pointer adjustment in interpreter
Summary: Always adjust SP unconditionally
Reviewed-by: dlong, kbarrett
changeset 0771982261c9 in /hg/release/icedtea7-forest-2.6/hotspot
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot?cmd=changeset;node=0771982261c9
author: aph
date: Wed Oct 26 05:40:47 2016 +0100
8157306, PR3209: Random infrequent null pointer exceptions in javac
Reviewed-by: kvn
diffstat:
src/cpu/aarch64/vm/templateTable_aarch64.cpp | 10 +-
src/cpu/x86/vm/vm_version_x86.hpp | 2 +-
src/cpu/zero/vm/entry_zero.hpp | 4 +-
src/cpu/zero/vm/methodHandles_zero.hpp | 6 +-
src/cpu/zero/vm/nativeInst_zero.cpp | 3 +-
src/os/solaris/vm/os_solaris.cpp | 4 +-
src/share/vm/classfile/verifier.cpp | 16 +-
src/share/vm/classfile/verifier.hpp | 5 +-
src/share/vm/interpreter/cppInterpreterGenerator.hpp | 5 +
src/share/vm/interpreter/interpreterRuntime.cpp | 2 +
src/share/vm/opto/lcm.cpp | 7 +-
src/share/vm/prims/methodHandles.hpp | 5 +
src/share/vm/prims/unsafe.cpp | 31 +++
src/share/vm/runtime/interfaceSupport.hpp | 18 +-
src/share/vm/runtime/objectMonitor.cpp | 8 +-
src/share/vm/utilities/copy.cpp | 171 ++++++++++++++++++-
src/share/vm/utilities/copy.hpp | 12 +-
test/runtime/handlerInTry/HandlerInTry.jasm | 115 ++++++++++++
test/runtime/handlerInTry/IsolatedHandlerInTry.jasm | 124 +++++++++++++
test/runtime/handlerInTry/LoadHandlerInTry.java | 86 +++++++++
20 files changed, 609 insertions(+), 25 deletions(-)
diffs (truncated from 920 to 500 lines):
diff -r f3c6a07c0b6c -r 0771982261c9 src/cpu/aarch64/vm/templateTable_aarch64.cpp
--- a/src/cpu/aarch64/vm/templateTable_aarch64.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/cpu/aarch64/vm/templateTable_aarch64.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -3779,19 +3779,15 @@
// allocate one if there's no free slot
{
- Label entry, loop, no_adjust;
+ Label entry, loop;
// 1. compute new pointers // rsp: old expression stack top
__ ldr(c_rarg1, monitor_block_bot); // c_rarg1: old expression stack bottom
- __ sub(esp, esp, entry_size); // move expression stack top
+ __ sub(esp, esp, entry_size); // move expression stack top
__ sub(c_rarg1, c_rarg1, entry_size); // move expression stack bottom
__ mov(c_rarg3, esp); // set start value for copy loop
__ str(c_rarg1, monitor_block_bot); // set new monitor block bottom
- __ cmp(sp, c_rarg3); // Check if we need to move sp
- __ br(Assembler::LO, no_adjust); // to allow more stack space
- // for our new esp
- __ sub(sp, sp, 2 * wordSize);
- __ bind(no_adjust);
+ __ sub(sp, sp, entry_size); // make room for the monitor
__ b(entry);
// 2. move expression stack contents
diff -r f3c6a07c0b6c -r 0771982261c9 src/cpu/x86/vm/vm_version_x86.hpp
--- a/src/cpu/x86/vm/vm_version_x86.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/cpu/x86/vm/vm_version_x86.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -521,7 +521,7 @@
result = _cpuid_info.std_cpuid1_ebx.bits.threads_per_cpu /
cores_per_cpu();
}
- return result;
+ return (result == 0 ? 1 : result);
}
static intx prefetch_data_size() {
diff -r f3c6a07c0b6c -r 0771982261c9 src/cpu/zero/vm/entry_zero.hpp
--- a/src/cpu/zero/vm/entry_zero.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/cpu/zero/vm/entry_zero.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2008, 2009, 2010 Red Hat, Inc.
+ * Copyright 2016 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
@@ -26,6 +26,8 @@
#ifndef CPU_ZERO_VM_ENTRY_ZERO_HPP
#define CPU_ZERO_VM_ENTRY_ZERO_HPP
+#include "interpreter/cppInterpreter.hpp"
+
class ZeroEntry {
public:
ZeroEntry() {
diff -r f3c6a07c0b6c -r 0771982261c9 src/cpu/zero/vm/methodHandles_zero.hpp
--- a/src/cpu/zero/vm/methodHandles_zero.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/cpu/zero/vm/methodHandles_zero.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2013, Red Hat, Inc.
+ * Copyright (c) 2011, 2016, 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
@@ -23,6 +23,8 @@
*
*/
+#ifndef CPU_ZERO_VM_METHODHANDLES_ZERO_HPP
+#define CPU_ZERO_VM_METHODHANDLES_ZERO_HPP
// Adapters
static unsigned int adapter_code_size() {
@@ -39,3 +41,5 @@
static int method_handle_entry_linkToVirtual(methodOop method, intptr_t UNUSED, TRAPS);
static int method_handle_entry_linkToInterface(methodOop method, intptr_t UNUSED, TRAPS);
static int method_handle_entry_invalid(methodOop method, intptr_t UNUSED, TRAPS);
+
+#endif // CPU_ZERO_VM_METHODHANDLES_ZERO_HPP
diff -r f3c6a07c0b6c -r 0771982261c9 src/cpu/zero/vm/nativeInst_zero.cpp
--- a/src/cpu/zero/vm/nativeInst_zero.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/cpu/zero/vm/nativeInst_zero.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2008 Red Hat, Inc.
+ * Copyright 2016 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
@@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "assembler_zero.inline.hpp"
+#include "entry_zero.hpp"
#include "memory/resourceArea.hpp"
#include "nativeInst_zero.hpp"
#include "oops/oop.inline.hpp"
diff -r f3c6a07c0b6c -r 0771982261c9 src/os/solaris/vm/os_solaris.cpp
--- a/src/os/solaris/vm/os_solaris.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/os/solaris/vm/os_solaris.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -2327,7 +2327,9 @@
st->print(", physical " UINT64_FORMAT "k", os::physical_memory()>>10);
st->print("(" UINT64_FORMAT "k free)", os::available_memory() >> 10);
st->cr();
- (void) check_addr0(st);
+ if (VMError::fatal_error_in_progress()) {
+ (void) check_addr0(st);
+ }
}
// Taken from /usr/include/sys/machsig.h Supposed to be architecture specific
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/classfile/verifier.cpp
--- a/src/share/vm/classfile/verifier.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/classfile/verifier.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -2243,14 +2243,20 @@
}
// Look at the method's handlers. If the bci is in the handler's try block
-// then check if the handler_pc is already on the stack. If not, push it.
+// then check if the handler_pc is already on the stack. If not, push it
+// unless the handler has already been scanned.
void ClassVerifier::push_handlers(ExceptionTable* exhandlers,
+ GrowableArray<u4>* handler_list,
GrowableArray<u4>* handler_stack,
u4 bci) {
int exlength = exhandlers->length();
for(int x = 0; x < exlength; x++) {
if (bci >= exhandlers->start_pc(x) && bci < exhandlers->end_pc(x)) {
- handler_stack->append_if_missing(exhandlers->handler_pc(x));
+ u4 exhandler_pc = exhandlers->handler_pc(x);
+ if (!handler_list->contains(exhandler_pc)) {
+ handler_stack->append_if_missing(exhandler_pc);
+ handler_list->append(exhandler_pc);
+ }
}
}
}
@@ -2268,6 +2274,10 @@
GrowableArray<u4>* bci_stack = new GrowableArray<u4>(30);
// Create stack for handlers for try blocks containing this handler.
GrowableArray<u4>* handler_stack = new GrowableArray<u4>(30);
+ // Create list of handlers that have been pushed onto the handler_stack
+ // so that handlers embedded inside of their own TRY blocks only get
+ // scanned once.
+ GrowableArray<u4>* handler_list = new GrowableArray<u4>(30);
// Create list of visited branch opcodes (goto* and if*).
GrowableArray<u4>* visited_branches = new GrowableArray<u4>(30);
ExceptionTable exhandlers(_method());
@@ -2286,7 +2296,7 @@
// If the bytecode is in a TRY block, push its handlers so they
// will get parsed.
- push_handlers(&exhandlers, handler_stack, bci);
+ push_handlers(&exhandlers, handler_list, handler_stack, bci);
switch (opcode) {
case Bytecodes::_if_icmpeq:
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/classfile/verifier.hpp
--- a/src/share/vm/classfile/verifier.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/classfile/verifier.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -303,9 +303,10 @@
bool* this_uninit, constantPoolHandle cp, StackMapTable* stackmap_table,
TRAPS);
- // Used by ends_in_athrow() to push all handlers that contain bci onto
- // the handler_stack, if the handler is not already on the stack.
+ // Used by ends_in_athrow() to push all handlers that contain bci onto the
+ // handler_stack, if the handler has not already been pushed on the stack.
void push_handlers(ExceptionTable* exhandlers,
+ GrowableArray<u4>* handler_list,
GrowableArray<u4>* handler_stack,
u4 bci);
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/interpreter/cppInterpreterGenerator.hpp
--- a/src/share/vm/interpreter/cppInterpreterGenerator.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/interpreter/cppInterpreterGenerator.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2016 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
@@ -28,6 +29,10 @@
// This file contains the platform-independent parts
// of the template interpreter generator.
+#ifdef TARGET_ARCH_zero
+#include "entry_zero.hpp"
+#endif
+
#ifdef CC_INTERP
class CppInterpreterGenerator: public AbstractInterpreterGenerator {
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/interpreter/interpreterRuntime.cpp
--- a/src/share/vm/interpreter/interpreterRuntime.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/interpreter/interpreterRuntime.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -1272,5 +1272,7 @@
if (MethodHandles::has_member_arg(cname, mname)) {
oop member_name = java_lang_invoke_DirectMethodHandle::member((oop)dmh);
thread->set_vm_result(member_name);
+ } else {
+ thread->set_vm_result(NULL);
}
IRT_END
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/opto/lcm.cpp
--- a/src/share/vm/opto/lcm.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/opto/lcm.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -1068,11 +1068,14 @@
Block *sb = _succs[i];
// Clone the entire area; ignoring the edge fixup for now.
for( uint j = end; j > beg; j-- ) {
- // It is safe here to clone a node with anti_dependence
- // since clones dominate on each path.
Node *clone = _nodes[j-1]->clone();
sb->_nodes.insert( 1, clone );
bbs.map(clone->_idx,sb);
+#ifdef AARCH64
+ if (clone->needs_anti_dependence_check()) {
+ insert_anti_dependences(sb, clone);
+ }
+#endif
}
}
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/prims/methodHandles.hpp
--- a/src/share/vm/prims/methodHandles.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/prims/methodHandles.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2016 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
@@ -31,6 +32,10 @@
#include "runtime/globals.hpp"
#include "runtime/interfaceSupport.hpp"
+#ifdef TARGET_ARCH_zero
+#include "entry_zero.hpp"
+#endif
+
class MacroAssembler;
class Label;
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/prims/unsafe.cpp
--- a/src/share/vm/prims/unsafe.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/prims/unsafe.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -703,6 +703,36 @@
Copy::conjoint_memory_atomic(src, dst, sz);
UNSAFE_END
+// This function is a leaf since if the source and destination are both in native memory
+// the copy may potentially be very large, and we don't want to disable GC if we can avoid it.
+// If either source or destination (or both) are on the heap, the function will enter VM using
+// JVM_ENTRY_FROM_LEAF
+JVM_LEAF(void, Unsafe_CopySwapMemory0(JNIEnv *env, jobject unsafe, jobject srcObj, jlong srcOffset, jobject dstObj, jlong dstOffset, jlong size, jlong elemSize)) {
+ UnsafeWrapper("Unsafe_CopySwapMemory0");
+
+ size_t sz = (size_t)size;
+ size_t esz = (size_t)elemSize;
+
+ if (srcObj == NULL && dstObj == NULL) {
+ // Both src & dst are in native memory
+ address src = (address)srcOffset;
+ address dst = (address)dstOffset;
+
+ Copy::conjoint_swap(src, dst, sz, esz);
+ } else {
+ // At least one of src/dst are on heap, transition to VM to access raw pointers
+
+ JVM_ENTRY_FROM_LEAF(env, void, Unsafe_CopySwapMemory0) {
+ oop srcp = JNIHandles::resolve(srcObj);
+ oop dstp = JNIHandles::resolve(dstObj);
+
+ address src = (address)index_oop_from_field_offset_long(srcp, srcOffset);
+ address dst = (address)index_oop_from_field_offset_long(dstp, dstOffset);
+
+ Copy::conjoint_swap(src, dst, sz, esz);
+ } JVM_END
+ }
+} JVM_END
////// Random queries
@@ -1611,6 +1641,7 @@
JNINativeMethod memcopy_methods[] = {
{CC"copyMemory", CC"("OBJ"J"OBJ"JJ)V", FN_PTR(Unsafe_CopyMemory2)},
+ {CC"copySwapMemory0", CC "(" OBJ "J" OBJ "JJJ)V", FN_PTR(Unsafe_CopySwapMemory0)},
{CC"setMemory", CC"("OBJ"JJB)V", FN_PTR(Unsafe_SetMemory2)}
};
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/runtime/interfaceSupport.hpp
--- a/src/share/vm/runtime/interfaceSupport.hpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/runtime/interfaceSupport.hpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2011, 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
@@ -445,6 +445,14 @@
os::verify_stack_alignment(); \
/* begin of body */
+#define VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread) \
+ TRACE_CALL(result_type, header) \
+ debug_only(ResetNoHandleMark __rnhm;) \
+ HandleMarkCleaner __hm(thread); \
+ Thread* THREAD = thread; \
+ os::verify_stack_alignment(); \
+ /* begin of body */
+
// ENTRY routines may lock, GC and throw exceptions
@@ -616,6 +624,14 @@
VM_LEAF_BASE(result_type, header)
+#define JVM_ENTRY_FROM_LEAF(env, result_type, header) \
+ { { \
+ JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
+ ThreadInVMfromNative __tiv(thread); \
+ debug_only(VMNativeEntryWrapper __vew;) \
+ VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread)
+
+
#define JVM_END } }
#endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/runtime/objectMonitor.cpp
--- a/src/share/vm/runtime/objectMonitor.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/runtime/objectMonitor.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -224,7 +224,8 @@
//
// * The monitor entry list operations avoid locks, but strictly speaking
// they're not lock-free. Enter is lock-free, exit is not.
-// See http://j2se.east/~dice/PERSIST/040825-LockFreeQueues.html
+// For a description of 'Methods and apparatus providing non-blocking access
+// to a resource,' see U.S. Pat. No. 7844973.
//
// * The cxq can have multiple concurrent "pushers" but only one concurrent
// detaching thread. This mechanism is immune from the ABA corruption.
@@ -2007,7 +2008,8 @@
// (duration) or we can fix the count at approximately the duration of
// a context switch and vary the frequency. Of course we could also
// vary both satisfying K == Frequency * Duration, where K is adaptive by monitor.
-// See http://j2se.east/~dice/PERSIST/040824-AdaptiveSpinning.html.
+// For a description of 'Adaptive spin-then-block mutual exclusion in
+// multi-threaded processing,' see U.S. Pat. No. 8046758.
//
// This implementation varies the duration "D", where D varies with
// the success rate of recent spin attempts. (D is capped at approximately
diff -r f3c6a07c0b6c -r 0771982261c9 src/share/vm/utilities/copy.cpp
--- a/src/share/vm/utilities/copy.cpp Fri Jul 29 06:30:14 2016 +0100
+++ b/src/share/vm/utilities/copy.cpp Wed Oct 26 05:40:47 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -53,6 +53,175 @@
}
}
+class CopySwap : AllStatic {
+public:
+ /**
+ * Copy and byte swap elements
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ * @param elem_size size of the elements to copy-swap
+ */
+ static void conjoint_swap(address src, address dst, size_t byte_count, size_t elem_size) {
+ assert(src != NULL, err_msg("address must not be NULL"));
+ assert(dst != NULL, err_msg("address must not be NULL"));
+ assert(elem_size == 2 || elem_size == 4 || elem_size == 8,
+ err_msg("incorrect element size: " SIZE_FORMAT, elem_size));
+ assert(is_size_aligned(byte_count, elem_size),
+ err_msg("byte_count " SIZE_FORMAT " must be multiple of element size " SIZE_FORMAT, byte_count, elem_size));
+
+ address src_end = src + byte_count;
+
+ if (dst <= src || dst >= src_end) {
+ do_conjoint_swap<RIGHT>(src, dst, byte_count, elem_size);
+ } else {
+ do_conjoint_swap<LEFT>(src, dst, byte_count, elem_size);
+ }
+ }
+
+private:
+ /**
+ * Byte swap a 16-bit value
+ */
+ static uint16_t byte_swap(uint16_t x) {
+ return (x << 8) | (x >> 8);
+ }
+
+ /**
+ * Byte swap a 32-bit value
+ */
+ static uint32_t byte_swap(uint32_t x) {
+ uint16_t lo = (uint16_t)x;
+ uint16_t hi = (uint16_t)(x >> 16);
+
+ return ((uint32_t)byte_swap(lo) << 16) | (uint32_t)byte_swap(hi);
+ }
+
+ /**
+ * Byte swap a 64-bit value
+ */
+ static uint64_t byte_swap(uint64_t x) {
+ uint32_t lo = (uint32_t)x;
+ uint32_t hi = (uint32_t)(x >> 32);
+
+ return ((uint64_t)byte_swap(lo) << 32) | (uint64_t)byte_swap(hi);
+ }
+
+ enum CopyDirection {
+ RIGHT, // lower -> higher address
+ LEFT // higher -> lower address
+ };
+
+ /**
+ * Copy and byte swap elements
+ *
+ * <T> - type of element to copy
+ * <D> - copy direction
+ * <is_src_aligned> - true if src argument is aligned to element size
+ * <is_dst_aligned> - true if dst argument is aligned to element size
+ *
+ * @param src address of source
+ * @param dst address of destination
+ * @param byte_count number of bytes to copy
+ */
+ template <typename T, CopyDirection D, bool is_src_aligned, bool is_dst_aligned>
+ static void do_conjoint_swap(address src, address dst, size_t byte_count) {
+ address cur_src, cur_dst;
+
+ switch (D) {
+ case RIGHT:
+ cur_src = src;
+ cur_dst = dst;
+ break;
+ case LEFT:
+ cur_src = src + byte_count - sizeof(T);
+ cur_dst = dst + byte_count - sizeof(T);
+ break;
+ }
+
+ for (size_t i = 0; i < byte_count / sizeof(T); i++) {
+ T tmp;
+
+ if (is_src_aligned) {
+ tmp = *(T*)cur_src;
+ } else {
+ memcpy(&tmp, cur_src, sizeof(T));
+ }
+
+ tmp = byte_swap(tmp);
+
+ if (is_dst_aligned) {
+ *(T*)cur_dst = tmp;
+ } else {
+ memcpy(cur_dst, &tmp, sizeof(T));
+ }
+
+ switch (D) {
+ case RIGHT:
+ cur_src += sizeof(T);
+ cur_dst += sizeof(T);
+ break;
+ case LEFT:
+ cur_src -= sizeof(T);
+ cur_dst -= sizeof(T);
+ break;
+ }
+ }
+ }
More information about the distro-pkg-dev
mailing list