--- a/hotspot/make/aix/makefiles/mapfile-vers-debug Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/aix/makefiles/mapfile-vers-debug Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -132,6 +132,7 @@
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
JVM_GetMethodTypeAnnotations;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/make/aix/makefiles/mapfile-vers-product Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/aix/makefiles/mapfile-vers-product Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -130,6 +130,7 @@
JVM_GetMethodIxNameUTF;
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -130,6 +130,7 @@
_JVM_GetMethodIxSignatureUTF
_JVM_GetMethodParameters
_JVM_GetMethodTypeAnnotations
+ _JVM_GetNanoTimeAdjustment
_JVM_GetPrimitiveArrayElement
_JVM_GetProtectionDomain
_JVM_GetStackAccessControlContext
--- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -130,6 +130,7 @@
_JVM_GetMethodIxSignatureUTF
_JVM_GetMethodParameters
_JVM_GetMethodTypeAnnotations
+ _JVM_GetNanoTimeAdjustment
_JVM_GetPrimitiveArrayElement
_JVM_GetProtectionDomain
_JVM_GetStackAccessControlContext
--- a/hotspot/make/bsd/makefiles/mapfile-vers-debug Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-debug Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -132,6 +132,7 @@
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
JVM_GetMethodTypeAnnotations;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/make/bsd/makefiles/mapfile-vers-product Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/bsd/makefiles/mapfile-vers-product Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -132,6 +132,7 @@
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
JVM_GetMethodTypeAnnotations;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/make/linux/makefiles/build_vm_def.sh Thu Feb 05 11:43:29 2015 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-# If we're cross compiling use that path for nm
-if [ "$CROSS_COMPILE_ARCH" != "" ]; then
-NM=$ALT_COMPILER_PATH/nm
-else
-NM=nm
-fi
-
-$NM --defined-only $* \
- | awk '{
- if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";"
- if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";"
- if ($3 ~ /^_ZN9Arguments17SharedArchivePathE$/) print "\t" $3 ";"
- }' \
- | sort -u
--- a/hotspot/make/linux/makefiles/mapfile-vers-debug Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/linux/makefiles/mapfile-vers-debug Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -132,6 +132,7 @@
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
JVM_GetMethodTypeAnnotations;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/make/linux/makefiles/mapfile-vers-product Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/linux/makefiles/mapfile-vers-product Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 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
@@ -132,6 +132,7 @@
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
JVM_GetMethodTypeAnnotations;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/make/linux/makefiles/vm.make Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/linux/makefiles/vm.make Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 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
@@ -239,8 +239,14 @@
rm -f $@
cat $^ > $@
+VMDEF_PAT = ^_ZTV
+VMDEF_PAT := ^gHotSpotVM|$(VMDEF_PAT)
+VMDEF_PAT := ^UseSharedSpaces$$|$(VMDEF_PAT)
+VMDEF_PAT := ^_ZN9Arguments17SharedArchivePathE$$|$(VMDEF_PAT)
+
vm.def: $(Res_Files) $(Obj_Files)
- sh $(GAMMADIR)/make/linux/makefiles/build_vm_def.sh *.o > $@
+ $(QUIETLY) $(NM) --defined-only $(Obj_Files) | sort -k3 -u | \
+ awk '$$3 ~ /$(VMDEF_PAT)/ { print "\t" $$3 ";" }' > $@
mapfile_ext:
rm -f $@
--- a/hotspot/make/solaris/makefiles/mapfile-vers Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/make/solaris/makefiles/mapfile-vers Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 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
@@ -132,6 +132,7 @@
JVM_GetMethodIxSignatureUTF;
JVM_GetMethodParameters;
JVM_GetMethodTypeAnnotations;
+ JVM_GetNanoTimeAdjustment;
JVM_GetPrimitiveArrayElement;
JVM_GetProtectionDomain;
JVM_GetStackAccessControlContext;
--- a/hotspot/src/cpu/sparc/vm/sparc.ad Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
//
-// Copyright (c) 1998, 2013, 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
@@ -2996,7 +2996,7 @@
%}
enc_class enc_String_Equals(o0RegP str1, o1RegP str2, g3RegI cnt, notemp_iRegI result) %{
- Label Lword_loop, Lpost_word, Lchar, Lchar_loop, Ldone;
+ Label Lchar, Lchar_loop, Ldone;
MacroAssembler _masm(&cbuf);
Register str1_reg = reg_to_register_object($str1$$reg);
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -6194,7 +6194,7 @@
ShortBranchVerifier sbv(this);
assert(UseSSE42Intrinsics, "SSE4.2 is required");
- // This method uses pcmpestri inxtruction with bound registers
+ // This method uses pcmpestri instruction with bound registers
// inputs:
// xmm - substring
// rax - substring length (elements count)
@@ -6355,7 +6355,7 @@
//
assert(int_cnt2 == -1 || (0 < int_cnt2 && int_cnt2 < 8), "should be != 0");
- // This method uses pcmpestri inxtruction with bound registers
+ // This method uses pcmpestri instruction with bound registers
// inputs:
// xmm - substring
// rax - substring length (elements count)
@@ -6644,7 +6644,6 @@
// start from first character again because it has aligned address.
int stride2 = 16;
int adr_stride = stride << scale;
- int adr_stride2 = stride2 << scale;
assert(result == rax && cnt2 == rdx && cnt1 == rcx, "pcmpestri");
// rax and rdx are used by pcmpestri as elements counters
@@ -6743,7 +6742,7 @@
// inputs:
// vec1- substring
// rax - negative string length (elements count)
- // mem - scaned string
+ // mem - scanned string
// rdx - string length (elements count)
// pcmpmask - cmp mode: 11000 (string compare with negated result)
// + 00 (unsigned bytes) or + 01 (unsigned shorts)
--- a/hotspot/src/os/aix/vm/os_aix.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/os/aix/vm/os_aix.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2014 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -1115,6 +1115,15 @@
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
}
+void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
+ timeval time;
+ int status = gettimeofday(&time, NULL);
+ assert(status != -1, "aix error at gettimeofday()");
+ seconds = jlong(time.tv_sec);
+ nanos = jlong(time.tv_usec) * 1000;
+}
+
+
// We need to manually declare mread_real_time,
// because IBM didn't provide a prototype in time.h.
// (they probably only ever tested in C, not C++)
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -984,6 +984,14 @@
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
}
+void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
+ timeval time;
+ int status = gettimeofday(&time, NULL);
+ assert(status != -1, "bsd error");
+ seconds = jlong(time.tv_sec);
+ nanos = jlong(time.tv_usec) * 1000;
+}
+
#ifndef __APPLE__
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC (1)
--- a/hotspot/src/os/linux/vm/os_linux.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -1322,6 +1322,15 @@
return jlong(time.tv_sec) * 1000 + jlong(time.tv_usec / 1000);
}
+void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
+ timeval time;
+ int status = gettimeofday(&time, NULL);
+ assert(status != -1, "linux error");
+ seconds = jlong(time.tv_sec);
+ nanos = jlong(time.tv_usec) * 1000;
+}
+
+
#ifndef CLOCK_MONOTONIC
#define CLOCK_MONOTONIC (1)
#endif
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -1475,6 +1475,16 @@
return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000;
}
+void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
+ timeval t;
+ if (gettimeofday(&t, NULL) == -1) {
+ fatal(err_msg("os::javaTimeSystemUTC: gettimeofday (%s)", strerror(errno)));
+ }
+ seconds = jlong(t.tv_sec);
+ nanos = jlong(t.tv_usec) * 1000;
+}
+
+
jlong os::javaTimeNanos() {
return (jlong)getTimeNanos();
}
--- a/hotspot/src/os/windows/vm/os_windows.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -839,6 +839,12 @@
return (a - offset()) / 10000;
}
+// Returns time ticks in (10th of micro seconds)
+jlong windows_to_time_ticks(FILETIME wt) {
+ jlong a = jlong_from(wt.dwHighDateTime, wt.dwLowDateTime);
+ return (a - offset());
+}
+
FILETIME java_to_windows_time(jlong l) {
jlong a = (l * 10000) + offset();
FILETIME result;
@@ -874,6 +880,15 @@
}
}
+void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) {
+ FILETIME wt;
+ GetSystemTimeAsFileTime(&wt);
+ jlong ticks = windows_to_time_ticks(wt); // 10th of micros
+ jlong secs = jlong(ticks / 10000000); // 10000 * 1000
+ seconds = secs;
+ nanos = jlong(ticks - (secs*10000000)) * 100;
+}
+
jlong os::javaTimeNanos() {
if (!win32::_has_performance_count) {
return javaTimeMillis() * NANOSECS_PER_MILLISEC; // the best we can do.
@@ -1693,7 +1708,7 @@
}
break;
- case 6004:
+ case 10000:
if (is_workstation) {
st->print("10");
} else {
--- a/hotspot/src/share/vm/classfile/verifier.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/classfile/verifier.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1950,7 +1950,7 @@
InstanceKlass* target_instance = InstanceKlass::cast(target_class);
fieldDescriptor fd;
if (is_method) {
- Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::normal);
+ Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::find_overpass);
if (m != NULL && m->is_protected()) {
if (!this_class->is_same_class_package(m->method_holder())) {
return true;
@@ -2496,7 +2496,7 @@
Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method(
vmSymbols::object_initializer_name(),
cp->signature_ref_at(bcs->get_index_u2()),
- Klass::normal);
+ Klass::find_overpass);
// Do nothing if method is not found. Let resolution detect the error.
if (m != NULL) {
instanceKlassHandle mh(THREAD, m->method_holder());
--- a/hotspot/src/share/vm/code/codeCache.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/code/codeCache.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -199,15 +199,10 @@
}
guarantee(NonProfiledCodeHeapSize + ProfiledCodeHeapSize + NonNMethodCodeHeapSize <= ReservedCodeCacheSize, "Size check");
- // Align reserved sizes of CodeHeaps
- size_t non_method_size = ReservedCodeSpace::allocation_align_size_up(NonNMethodCodeHeapSize);
- size_t profiled_size = ReservedCodeSpace::allocation_align_size_up(ProfiledCodeHeapSize);
- size_t non_profiled_size = ReservedCodeSpace::allocation_align_size_up(NonProfiledCodeHeapSize);
-
- // Compute initial sizes of CodeHeaps
- size_t init_non_method_size = MIN2(InitialCodeCacheSize, non_method_size);
- size_t init_profiled_size = MIN2(InitialCodeCacheSize, profiled_size);
- size_t init_non_profiled_size = MIN2(InitialCodeCacheSize, non_profiled_size);
+ // Align CodeHeaps
+ size_t alignment = heap_alignment();
+ size_t non_method_size = align_size_up(NonNMethodCodeHeapSize, alignment);
+ size_t profiled_size = align_size_down(ProfiledCodeHeapSize, alignment);
// Reserve one continuous chunk of memory for CodeHeaps and split it into
// parts for the individual heaps. The memory layout looks like this:
@@ -216,18 +211,27 @@
// Profiled nmethods
// Non-nmethods
// ---------- low ------------
- ReservedCodeSpace rs = reserve_heap_memory(non_profiled_size + profiled_size + non_method_size);
+ ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize);
ReservedSpace non_method_space = rs.first_part(non_method_size);
ReservedSpace rest = rs.last_part(non_method_size);
ReservedSpace profiled_space = rest.first_part(profiled_size);
ReservedSpace non_profiled_space = rest.last_part(profiled_size);
// Non-nmethods (stubs, adapters, ...)
- add_heap(non_method_space, "CodeHeap 'non-nmethods'", init_non_method_size, CodeBlobType::NonNMethod);
+ add_heap(non_method_space, "CodeHeap 'non-nmethods'", CodeBlobType::NonNMethod);
// Tier 2 and tier 3 (profiled) methods
- add_heap(profiled_space, "CodeHeap 'profiled nmethods'", init_profiled_size, CodeBlobType::MethodProfiled);
+ add_heap(profiled_space, "CodeHeap 'profiled nmethods'", CodeBlobType::MethodProfiled);
// Tier 1 and tier 4 (non-profiled) methods and native methods
- add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", init_non_profiled_size, CodeBlobType::MethodNonProfiled);
+ add_heap(non_profiled_space, "CodeHeap 'non-profiled nmethods'", CodeBlobType::MethodNonProfiled);
+}
+
+size_t CodeCache::heap_alignment() {
+ // If large page support is enabled, align code heaps according to large
+ // page size to make sure that code cache is covered by large pages.
+ const size_t page_size = os::can_execute_large_page_memory() ?
+ os::page_size_for_region_unaligned(ReservedCodeCacheSize, 8) :
+ os::vm_page_size();
+ return MAX2(page_size, (size_t) os::vm_allocation_granularity());
}
ReservedCodeSpace CodeCache::reserve_heap_memory(size_t size) {
@@ -284,7 +288,7 @@
return NULL;
}
-void CodeCache::add_heap(ReservedSpace rs, const char* name, size_t size_initial, int code_blob_type) {
+void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type) {
// Check if heap is needed
if (!heap_available(code_blob_type)) {
return;
@@ -295,8 +299,8 @@
_heaps->append(heap);
// Reserve Space
+ size_t size_initial = MIN2(InitialCodeCacheSize, rs.size());
size_initial = round_to(size_initial, os::vm_page_size());
-
if (!heap->reserve(rs, size_initial, CodeCacheSegmentSize)) {
vm_exit_during_initialization("Could not reserve enough space for code cache");
}
@@ -840,7 +844,7 @@
} else {
// Use a single code heap
ReservedCodeSpace rs = reserve_heap_memory(ReservedCodeCacheSize);
- add_heap(rs, "CodeCache", InitialCodeCacheSize, CodeBlobType::All);
+ add_heap(rs, "CodeCache", CodeBlobType::All);
}
// Initialize ICache flush mechanism
--- a/hotspot/src/share/vm/code/codeCache.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/code/codeCache.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -98,12 +98,13 @@
// CodeHeap management
static void initialize_heaps(); // Initializes the CodeHeaps
// Creates a new heap with the given name and size, containing CodeBlobs of the given type
- static void add_heap(ReservedSpace rs, const char* name, size_t size_initial, int code_blob_type);
+ static void add_heap(ReservedSpace rs, const char* name, int code_blob_type);
static CodeHeap* get_code_heap(const CodeBlob* cb); // Returns the CodeHeap for the given CodeBlob
static CodeHeap* get_code_heap(int code_blob_type); // Returns the CodeHeap for the given CodeBlobType
// Returns the name of the VM option to set the size of the corresponding CodeHeap
static const char* get_code_heap_flag_name(int code_blob_type);
static bool heap_available(int code_blob_type); // Returns true if an own CodeHeap for the given CodeBlobType is available
+ static size_t heap_alignment(); // Returns the alignment of the CodeHeaps in bytes
static ReservedCodeSpace reserve_heap_memory(size_t size); // Reserves one continuous chunk of memory for the CodeHeaps
// Iteration
--- a/hotspot/src/share/vm/compiler/compilerOracle.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -553,7 +553,8 @@
int match = MethodMatcher::Exact;
while (name[0] == '*') {
match |= MethodMatcher::Suffix;
- strcpy(name, name + 1);
+ // Copy remaining string plus NUL to the beginning
+ memmove(name, name + 1, strlen(name + 1) + 1);
}
if (strcmp(name, "*") == 0) return MethodMatcher::Any;
@@ -689,6 +690,13 @@
return NULL;
}
+int skip_whitespace(char* line) {
+ // Skip any leading spaces
+ int whitespace_read = 0;
+ sscanf(line, "%*[ \t]%n", &whitespace_read);
+ return whitespace_read;
+}
+
void CompilerOracle::parse_from_line(char* line) {
if (line[0] == '\0') return;
if (line[0] == '#') return;
@@ -755,15 +763,9 @@
line += bytes_read;
- // Skip any leading spaces before signature
- int whitespace_read = 0;
- sscanf(line, "%*[ \t]%n", &whitespace_read);
- if (whitespace_read > 0) {
- line += whitespace_read;
- }
-
// there might be a signature following the method.
// signatures always begin with ( so match that by hand
+ line += skip_whitespace(line);
if (1 == sscanf(line, "(%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
sig[0] = '(';
line += bytes_read;
@@ -786,7 +788,9 @@
//
// For future extensions: extend scan_flag_and_value()
char option[256]; // stores flag for Type (1) and type of Type (2)
- while (sscanf(line, "%*[ \t]%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
+
+ line += skip_whitespace(line);
+ while (sscanf(line, "%255[a-zA-Z0-9]%n", option, &bytes_read) == 1) {
if (match != NULL && !_quiet) {
// Print out the last match added
ttyLocker ttyl;
@@ -816,6 +820,7 @@
// Type (1) option
match = add_option_string(c_name, c_match, m_name, m_match, signature, option, true);
}
+ line += skip_whitespace(line);
} // while(
} else {
match = add_predicate(command, c_name, c_match, m_name, m_match, signature);
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -289,11 +289,11 @@
// returns first instance method
// Looks up method in classes, then looks up local default methods
void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
- Method* result_oop = klass->uncached_lookup_method(name, signature, Klass::normal);
+ Method* result_oop = klass->uncached_lookup_method(name, signature, Klass::find_overpass);
result = methodHandle(THREAD, result_oop);
while (!result.is_null() && result->is_static() && result->method_holder()->super() != NULL) {
KlassHandle super_klass = KlassHandle(THREAD, result->method_holder()->super());
- result = methodHandle(THREAD, super_klass->uncached_lookup_method(name, signature, Klass::normal));
+ result = methodHandle(THREAD, super_klass->uncached_lookup_method(name, signature, Klass::find_overpass));
}
if (klass->oop_is_array()) {
@@ -320,7 +320,8 @@
// First check in default method array
if (!resolved_method->is_abstract() &&
(InstanceKlass::cast(klass())->default_methods() != NULL)) {
- int index = InstanceKlass::find_method_index(InstanceKlass::cast(klass())->default_methods(), name, signature, false, false);
+ int index = InstanceKlass::find_method_index(InstanceKlass::cast(klass())->default_methods(),
+ name, signature, Klass::find_overpass, Klass::find_static);
if (index >= 0 ) {
vtable_index = InstanceKlass::cast(klass())->default_vtable_indices()->at(index);
}
--- a/hotspot/src/share/vm/memory/universe.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/memory/universe.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -115,6 +115,7 @@
LatestMethodCache* Universe::_finalizer_register_cache = NULL;
LatestMethodCache* Universe::_loader_addClass_cache = NULL;
LatestMethodCache* Universe::_pd_implies_cache = NULL;
+LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
oop Universe::_out_of_memory_error_java_heap = NULL;
oop Universe::_out_of_memory_error_metaspace = NULL;
oop Universe::_out_of_memory_error_class_metaspace = NULL;
@@ -130,7 +131,6 @@
oop Universe::_vm_exception = NULL;
oop Universe::_allocation_context_notification_obj = NULL;
-Method* Universe::_throw_illegal_access_error = NULL;
Array<int>* Universe::_the_empty_int_array = NULL;
Array<u2>* Universe::_the_empty_short_array = NULL;
Array<Klass*>* Universe::_the_empty_klass_array = NULL;
@@ -236,6 +236,7 @@
_finalizer_register_cache->serialize(f);
_loader_addClass_cache->serialize(f);
_pd_implies_cache->serialize(f);
+ _throw_illegal_access_error_cache->serialize(f);
}
void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
@@ -664,6 +665,7 @@
Universe::_finalizer_register_cache = new LatestMethodCache();
Universe::_loader_addClass_cache = new LatestMethodCache();
Universe::_pd_implies_cache = new LatestMethodCache();
+ Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
if (UseSharedSpaces) {
// Read the data structures supporting the shared spaces (shared
@@ -1016,7 +1018,8 @@
tty->print_cr("Unable to link/verify Unsafe.throwIllegalAccessError method");
return false; // initialization failed (cannot throw exception yet)
}
- Universe::_throw_illegal_access_error = m;
+ Universe::_throw_illegal_access_error_cache->init(
+ SystemDictionary::misc_Unsafe_klass(), m);
// Setup method for registering loaded classes in class loader vector
InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->link_class(CHECK_false);
@@ -1042,7 +1045,7 @@
return false; // initialization failed
}
Universe::_pd_implies_cache->init(
- SystemDictionary::ProtectionDomain_klass(), m);;
+ SystemDictionary::ProtectionDomain_klass(), m);
}
// This needs to be done before the first scavenge/gc, since
--- a/hotspot/src/share/vm/memory/universe.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/memory/universe.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -148,8 +148,7 @@
static LatestMethodCache* _finalizer_register_cache; // static method for registering finalizable objects
static LatestMethodCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector
static LatestMethodCache* _pd_implies_cache; // method for checking protection domain attributes
-
- static Method* _throw_illegal_access_error;
+ static LatestMethodCache* _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError() method
// preallocated error objects (no backtrace)
static oop _out_of_memory_error_java_heap;
@@ -305,6 +304,7 @@
static Method* loader_addClass_method() { return _loader_addClass_cache->get_method(); }
static Method* protection_domain_implies_method() { return _pd_implies_cache->get_method(); }
+ static Method* throw_illegal_access_error() { return _throw_illegal_access_error_cache->get_method(); }
static oop null_ptr_exception_instance() { return _null_ptr_exception_instance; }
static oop arithmetic_exception_instance() { return _arithmetic_exception_instance; }
@@ -314,8 +314,6 @@
static inline oop allocation_context_notification_obj();
static inline void set_allocation_context_notification_obj(oop obj);
- static Method* throw_illegal_access_error() { return _throw_illegal_access_error; }
-
static Array<int>* the_empty_int_array() { return _the_empty_int_array; }
static Array<u2>* the_empty_short_array() { return _the_empty_short_array; }
static Array<Method*>* the_empty_method_array() { return _the_empty_method_array; }
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -71,10 +71,13 @@
return super()->find_field(name, sig, fd);
}
-Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
+Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const {
// There are no methods in an array klass but the super class (Object) has some
assert(super(), "super klass must be present");
- return super()->uncached_lookup_method(name, signature, mode);
+ // Always ignore overpass methods in superclasses, although technically the
+ // super klass of an array, (j.l.Object) should not have
+ // any overpass methods present.
+ return super()->uncached_lookup_method(name, signature, Klass::skip_overpass);
}
ArrayKlass::ArrayKlass(Symbol* name) {
--- a/hotspot/src/share/vm/oops/arrayKlass.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/arrayKlass.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -82,7 +82,7 @@
Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
// Lookup operations
- Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
+ Method* uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const;
// Casting from Klass*
static ArrayKlass* cast(Klass* k) {
--- a/hotspot/src/share/vm/oops/constantPool.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/constantPool.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -493,12 +493,7 @@
}
char* ConstantPool::string_at_noresolve(int which) {
- Symbol* s = unresolved_string_at(which);
- if (s == NULL) {
- return (char*)"<pseudo-string>";
- } else {
- return unresolved_string_at(which)->as_C_string();
- }
+ return unresolved_string_at(which)->as_C_string();
}
BasicType ConstantPool::basic_type_for_signature_at(int which) {
@@ -1828,7 +1823,7 @@
// explicitly, because it may require scavenging.
int obj_index = cp_to_object_index(index);
pseudo_string_at_put(index, obj_index, patch());
- DEBUG_ONLY(cp_patches->at_put(index, Handle());)
+ DEBUG_ONLY(cp_patches->at_put(index, Handle());)
}
}
#ifdef ASSERT
--- a/hotspot/src/share/vm/oops/constantPool.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/constantPool.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -48,17 +48,21 @@
class CPSlot VALUE_OBJ_CLASS_SPEC {
intptr_t _ptr;
public:
+ enum TagBits { _resolved_value = 0, _symbol_bit = 1, _pseudo_bit = 2, _symbol_mask = 3 };
+
CPSlot(intptr_t ptr): _ptr(ptr) {}
CPSlot(Klass* ptr): _ptr((intptr_t)ptr) {}
- CPSlot(Symbol* ptr): _ptr((intptr_t)ptr | 1) {}
+ CPSlot(Symbol* ptr): _ptr((intptr_t)ptr | _symbol_bit) {}
+ CPSlot(Symbol* ptr, int tag_bits): _ptr((intptr_t)ptr | tag_bits) {}
intptr_t value() { return _ptr; }
- bool is_resolved() { return (_ptr & 1) == 0; }
- bool is_unresolved() { return (_ptr & 1) == 1; }
+ bool is_resolved() { return (_ptr & _symbol_bit ) == _resolved_value; }
+ bool is_unresolved() { return (_ptr & _symbol_bit ) != _resolved_value; }
+ bool is_pseudo_string() { return (_ptr & _symbol_mask) == _symbol_bit + _pseudo_bit; }
Symbol* get_symbol() {
assert(is_unresolved(), "bad call");
- return (Symbol*)(_ptr & ~1);
+ return (Symbol*)(_ptr & ~_symbol_mask);
}
Klass* get_klass() {
assert(is_resolved(), "bad call");
@@ -261,7 +265,7 @@
void unresolved_string_at_put(int which, Symbol* s) {
release_tag_at_put(which, JVM_CONSTANT_String);
- *symbol_at_addr(which) = s;
+ slot_at_put(which, CPSlot(s, CPSlot::_symbol_bit));
}
void int_at_put(int which, jint i) {
@@ -405,20 +409,18 @@
// use pseudo-strings to link themselves to related metaobjects.
bool is_pseudo_string_at(int which) {
- // A pseudo string is a string that doesn't have a symbol in the cpSlot
- return unresolved_string_at(which) == NULL;
+ assert(tag_at(which).is_string(), "Corrupted constant pool");
+ return slot_at(which).is_pseudo_string();
}
oop pseudo_string_at(int which, int obj_index) {
- assert(tag_at(which).is_string(), "Corrupted constant pool");
- assert(unresolved_string_at(which) == NULL, "shouldn't have symbol");
+ assert(is_pseudo_string_at(which), "must be a pseudo-string");
oop s = resolved_references()->obj_at(obj_index);
return s;
}
oop pseudo_string_at(int which) {
- assert(tag_at(which).is_string(), "Corrupted constant pool");
- assert(unresolved_string_at(which) == NULL, "shouldn't have symbol");
+ assert(is_pseudo_string_at(which), "must be a pseudo-string");
int obj_index = cp_to_object_index(which);
oop s = resolved_references()->obj_at(obj_index);
return s;
@@ -426,7 +428,8 @@
void pseudo_string_at_put(int which, int obj_index, oop x) {
assert(tag_at(which).is_string(), "Corrupted constant pool");
- unresolved_string_at_put(which, NULL); // indicates patched string
+ Symbol* sym = unresolved_string_at(which);
+ slot_at_put(which, CPSlot(sym, (CPSlot::_symbol_bit | CPSlot::_pseudo_bit)));
string_at_put(which, obj_index, x); // this works just fine
}
@@ -443,15 +446,14 @@
Symbol* unresolved_string_at(int which) {
assert(tag_at(which).is_string(), "Corrupted constant pool");
- Symbol* s = *symbol_at_addr(which);
- return s;
+ Symbol* sym = slot_at(which).get_symbol();
+ return sym;
}
// Returns an UTF8 for a CONSTANT_String entry at a given index.
// UTF8 char* representation was chosen to avoid conversion of
// java_lang_Strings at resolved entries into Symbol*s
// or vice versa.
- // Caller is responsible for checking for pseudo-strings.
char* string_at_noresolve(int which);
jint name_and_type_at(int which) {
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -1416,18 +1416,21 @@
// find_method looks up the name/signature in the local methods array
Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const {
- return find_method_impl(name, signature, false);
+ return find_method_impl(name, signature, find_overpass, find_static);
}
-Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const {
- return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass, false);
+Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature,
+ OverpassLookupMode overpass_mode, StaticLookupMode static_mode) const {
+ return InstanceKlass::find_method_impl(methods(), name, signature, overpass_mode, static_mode);
}
// find_instance_method looks up the name/signature in the local methods array
// and skips over static methods
Method* InstanceKlass::find_instance_method(
Array<Method*>* methods, Symbol* name, Symbol* signature) {
- Method* meth = InstanceKlass::find_method_impl(methods, name, signature, false, true);
+ Method* meth = InstanceKlass::find_method_impl(methods, name, signature,
+ find_overpass, skip_static);
+ assert(((meth == NULL) || !meth->is_static()), "find_instance_method should have skipped statics");
return meth;
}
@@ -1440,12 +1443,12 @@
// find_method looks up the name/signature in the local methods array
Method* InstanceKlass::find_method(
Array<Method*>* methods, Symbol* name, Symbol* signature) {
- return InstanceKlass::find_method_impl(methods, name, signature, false, false);
+ return InstanceKlass::find_method_impl(methods, name, signature, find_overpass, find_static);
}
Method* InstanceKlass::find_method_impl(
- Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static) {
- int hit = find_method_index(methods, name, signature, skipping_overpass, skipping_static);
+ Array<Method*>* methods, Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode, StaticLookupMode static_mode) {
+ int hit = find_method_index(methods, name, signature, overpass_mode, static_mode);
return hit >= 0 ? methods->at(hit): NULL;
}
@@ -1463,7 +1466,9 @@
// is important during method resolution to prefer a static method, for example,
// over an overpass method.
int InstanceKlass::find_method_index(
- Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static) {
+ Array<Method*>* methods, Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode, StaticLookupMode static_mode) {
+ bool skipping_overpass = (overpass_mode == skip_overpass);
+ bool skipping_static = (static_mode == skip_static);
int hit = binary_search(methods, name);
if (hit != -1) {
Method* m = methods->at(hit);
@@ -1489,7 +1494,7 @@
}
// not found
#ifdef ASSERT
- int index = skipping_overpass || skipping_static ? -1 : linear_search(methods, name, signature);
+ int index = (skipping_overpass || skipping_static) ? -1 : linear_search(methods, name, signature);
assert(index == -1, err_msg("binary search should have found entry %d", index));
#endif
}
@@ -1515,16 +1520,16 @@
// uncached_lookup_method searches both the local class methods array and all
// superclasses methods arrays, skipping any overpass methods in superclasses.
-Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
- MethodLookupMode lookup_mode = mode;
+Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const {
+ OverpassLookupMode overpass_local_mode = overpass_mode;
Klass* klass = const_cast<InstanceKlass*>(this);
while (klass != NULL) {
- Method* method = InstanceKlass::cast(klass)->find_method_impl(name, signature, (lookup_mode == skip_overpass));
+ Method* method = InstanceKlass::cast(klass)->find_method_impl(name, signature, overpass_local_mode, find_static);
if (method != NULL) {
return method;
}
klass = InstanceKlass::cast(klass)->super();
- lookup_mode = skip_overpass; // Always ignore overpass methods in superclasses
+ overpass_local_mode = skip_overpass; // Always ignore overpass methods in superclasses
}
return NULL;
}
@@ -1554,7 +1559,7 @@
}
// Look up interfaces
if (m == NULL) {
- m = lookup_method_in_all_interfaces(name, signature, normal);
+ m = lookup_method_in_all_interfaces(name, signature, find_defaults);
}
return m;
}
@@ -1564,7 +1569,7 @@
// They should only be found in the initial InterfaceMethodRef
Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
Symbol* signature,
- MethodLookupMode mode) const {
+ DefaultsLookupMode defaults_mode) const {
Array<Klass*>* all_ifs = transitive_interfaces();
int num_ifs = all_ifs->length();
InstanceKlass *ik = NULL;
@@ -1572,7 +1577,7 @@
ik = InstanceKlass::cast(all_ifs->at(i));
Method* m = ik->lookup_method(name, signature);
if (m != NULL && m->is_public() && !m->is_static() &&
- ((mode != skip_defaults) || !m->is_default_method())) {
+ ((defaults_mode != skip_defaults) || !m->is_default_method())) {
return m;
}
}
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -499,14 +499,15 @@
static bool method_matches(Method* m, Symbol* signature, bool skipping_overpass, bool skipping_static);
// find a local method index in default_methods (returns -1 if not found)
- static int find_method_index(Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static);
+ static int find_method_index(Array<Method*>* methods, Symbol* name, Symbol* signature,
+ OverpassLookupMode overpass_mode, StaticLookupMode static_mode);
// lookup operation (returns NULL if not found)
- Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
+ Method* uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const;
// lookup a method in all the interfaces that this class implements
// (returns NULL if not found)
- Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
+ Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const;
// lookup a method in local defaults then in all interfaces
// (returns NULL if not found)
@@ -1058,8 +1059,10 @@
Klass* array_klass_impl(bool or_null, TRAPS);
// find a local method (returns NULL if not found)
- Method* find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const;
- static Method* find_method_impl(Array<Method*>* methods, Symbol* name, Symbol* signature, bool skipping_overpass, bool skipping_static);
+ Method* find_method_impl(Symbol* name, Symbol* signature,
+ OverpassLookupMode overpass_mode, StaticLookupMode static_mode) const;
+ static Method* find_method_impl(Array<Method*>* methods, Symbol* name, Symbol* signature,
+ OverpassLookupMode overpass_mode, StaticLookupMode static_mode);
// Free CHeap allocated fields.
void release_C_heap_structures();
--- a/hotspot/src/share/vm/oops/klass.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/klass.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -140,7 +140,7 @@
return NULL;
}
-Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
+Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const {
#ifdef ASSERT
tty->print_cr("Error: uncached_lookup_method called on a klass oop."
" Likely error: reflection method does not correctly"
--- a/hotspot/src/share/vm/oops/klass.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/klass.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -164,7 +164,9 @@
void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
public:
- enum MethodLookupMode { normal, skip_overpass, skip_defaults };
+ enum DefaultsLookupMode { find_defaults, skip_defaults };
+ enum OverpassLookupMode { find_overpass, skip_overpass };
+ enum StaticLookupMode { find_static, skip_static };
bool is_klass() const volatile { return true; }
@@ -413,10 +415,10 @@
// lookup operation for MethodLookupCache
friend class MethodLookupCache;
virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;
- virtual Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
+ virtual Method* uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const;
public:
Method* lookup_method(Symbol* name, Symbol* signature) const {
- return uncached_lookup_method(name, signature, normal);
+ return uncached_lookup_method(name, signature, find_overpass);
}
// array class with specific rank
--- a/hotspot/src/share/vm/oops/klassVtable.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -649,7 +649,7 @@
// this check for all access permissions.
InstanceKlass *sk = InstanceKlass::cast(super);
if (sk->has_miranda_methods()) {
- if (sk->lookup_method_in_all_interfaces(name, signature, Klass::normal) != NULL) {
+ if (sk->lookup_method_in_all_interfaces(name, signature, Klass::find_defaults) != NULL) {
return false; // found a matching miranda; we do not need a new entry
}
}
@@ -725,7 +725,7 @@
&& mo->method_holder() != NULL
&& mo->method_holder()->super() != NULL)
{
- mo = mo->method_holder()->super()->uncached_lookup_method(name, signature, Klass::normal);
+ mo = mo->method_holder()->super()->uncached_lookup_method(name, signature, Klass::find_overpass);
}
if (mo == NULL || mo->access_flags().is_private() ) {
// super class hierarchy does not implement it or protection is different
@@ -770,7 +770,7 @@
if (is_miranda(im, class_methods, default_methods, super)) { // is it a miranda at all?
InstanceKlass *sk = InstanceKlass::cast(super);
// check if it is a duplicate of a super's miranda
- if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::normal) == NULL) {
+ if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::find_defaults) == NULL) {
new_mirandas->append(im);
}
if (all_mirandas != NULL) {
--- a/hotspot/src/share/vm/opto/library_call.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/opto/library_call.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -1351,7 +1351,6 @@
Node* cache = __ ConI(cache_i);
Node* md2 = __ ConI(md2_i);
Node* lastChar = __ ConI(target_array->char_at(target_length - 1));
- Node* targetCount = __ ConI(target_length);
Node* targetCountLess1 = __ ConI(target_length - 1);
Node* targetOffset = __ ConI(targetOffset_i);
Node* sourceEnd = __ SubI(__ AddI(sourceOffset, sourceCount), targetCountLess1);
@@ -1408,8 +1407,6 @@
Node* arg = argument(1);
Node* result;
- // Disable the use of pcmpestri until it can be guaranteed that
- // the load doesn't cross into the uncommited space.
if (Matcher::has_match_rule(Op_StrIndexOf) &&
UseSSE42Intrinsics) {
// Generate SSE4.2 version of indexOf
@@ -1421,9 +1418,6 @@
return true;
}
- ciInstanceKlass* str_klass = env()->String_klass();
- const TypeOopPtr* string_type = TypeOopPtr::make_from_klass(str_klass);
-
// Make the merge point
RegionNode* result_rgn = new RegionNode(4);
Node* result_phi = new PhiNode(result_rgn, TypeInt::INT);
--- a/hotspot/src/share/vm/opto/output.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/opto/output.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -2475,7 +2475,7 @@
if( iop == Op_Con ) continue; // Do not schedule Top
if( iop == Op_Node && // Do not schedule PhiNodes, ProjNodes
mach->pipeline() == MachNode::pipeline_class() &&
- !n->is_SpillCopy() ) // Breakpoints, Prolog, etc
+ !n->is_SpillCopy() && !n->is_MachMerge() ) // Breakpoints, Prolog, etc
continue;
break; // Funny loop structure to be sure...
}
--- a/hotspot/src/share/vm/opto/postaloc.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/opto/postaloc.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -428,6 +428,7 @@
// Insert the merge node into the block before the first use.
uint use_index = block->find_node(reg2defuse.at(reg).first_use());
block->insert_node(merge, use_index++);
+ _cfg.map_node_to_block(merge, block);
// Let the allocator know about the new node, use the same lrg
_lrg_map.extend(merge->_idx, lrg);
--- a/hotspot/src/share/vm/prims/jvm.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/prims/jvm.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -300,6 +300,48 @@
return os::javaTimeNanos();
JVM_END
+// The function below is actually exposed by sun.misc.VM and not
+// java.lang.System, but we choose to keep it here so that it stays next
+// to JVM_CurrentTimeMillis and JVM_NanoTime
+
+const jlong MAX_DIFF_SECS = 0x0100000000LL; // 2^32
+const jlong MIN_DIFF_SECS = -MAX_DIFF_SECS; // -2^32
+
+JVM_LEAF(jlong, JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs))
+ JVMWrapper("JVM_GetNanoTimeAdjustment");
+ jlong seconds;
+ jlong nanos;
+
+ os::javaTimeSystemUTC(seconds, nanos);
+
+ // We're going to verify that the result can fit in a long.
+ // For that we need the difference in seconds between 'seconds'
+ // and 'offset_secs' to be such that:
+ // |seconds - offset_secs| < (2^63/10^9)
+ // We're going to approximate 10^9 ~< 2^30 (1000^3 ~< 1024^3)
+ // which makes |seconds - offset_secs| < 2^33
+ // and we will prefer +/- 2^32 as the maximum acceptable diff
+ // as 2^32 has a more natural feel than 2^33...
+ //
+ // So if |seconds - offset_secs| >= 2^32 - we return a special
+ // sentinel value (-1) which the caller should take as an
+ // exception value indicating that the offset given to us is
+ // too far from range of the current time - leading to too big
+ // a nano adjustment. The caller is expected to recover by
+ // computing a more accurate offset and calling this method
+ // again. (For the record 2^32 secs is ~136 years, so that
+ // should rarely happen)
+ //
+ jlong diff = seconds - offset_secs;
+ if (diff >= MAX_DIFF_SECS || diff <= MIN_DIFF_SECS) {
+ return -1; // sentinel value: the offset is too far off the target
+ }
+
+ // return the adjustment. If you compute a time by adding
+ // this number of nanoseconds along with the number of seconds
+ // in the offset you should get the current UTC time.
+ return (diff * (jlong)1000000000) + nanos;
+JVM_END
JVM_ENTRY(void, JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
jobject dst, jint dst_pos, jint length))
@@ -1167,7 +1209,7 @@
Method* m_oop = object->klass()->uncached_lookup_method(
vmSymbols::run_method_name(),
vmSymbols::void_object_signature(),
- Klass::normal);
+ Klass::find_overpass);
methodHandle m (THREAD, m_oop);
if (m.is_null() || !m->is_method() || !m()->is_public() || m()->is_static()) {
THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method");
--- a/hotspot/src/share/vm/prims/jvm.h Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/prims/jvm.h Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -131,6 +131,9 @@
JNIEXPORT jlong JNICALL
JVM_NanoTime(JNIEnv *env, jclass ignored);
+JNIEXPORT jlong JNICALL
+JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
+
JNIEXPORT void JNICALL
JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
jobject dst, jint dst_pos, jint length);
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -3376,7 +3376,9 @@
// not yet in the vtable, because the vtable setup is in progress.
// This must be done after we adjust the default_methods and
// default_vtable_indices for methods already in the vtable.
+ // If redefining Unsafe, walk all the vtables looking for entries.
if (ik->vtable_length() > 0 && (_the_class_oop->is_interface()
+ || _the_class_oop == SystemDictionary::misc_Unsafe_klass()
|| ik->is_subtype_of(_the_class_oop))) {
// ik->vtable() creates a wrapper object; rm cleans it up
ResourceMark rm(_thread);
@@ -3396,7 +3398,9 @@
// interface, then we have to call adjust_method_entries() for
// every InstanceKlass that has an itable since there isn't a
// subclass relationship between an interface and an InstanceKlass.
+ // If redefining Unsafe, walk all the itables looking for entries.
if (ik->itable_length() > 0 && (_the_class_oop->is_interface()
+ || _the_class_oop == SystemDictionary::misc_Unsafe_klass()
|| ik->is_subclass_of(_the_class_oop))) {
// ik->itable() creates a wrapper object; rm cleans it up
ResourceMark rm(_thread);
--- a/hotspot/src/share/vm/prims/methodComparator.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/prims/methodComparator.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -405,6 +405,8 @@
if (strcmp(_old_cp->string_at_noresolve(cpi_old),
_new_cp->string_at_noresolve(cpi_new)) != 0)
return false;
+ if (_old_cp->is_pseudo_string_at(cpi_old) || _new_cp->is_pseudo_string_at(cpi_new))
+ return (_old_cp->is_pseudo_string_at(cpi_old) == _new_cp->is_pseudo_string_at(cpi_new));
} else if (tag_old.is_klass() || tag_old.is_unresolved_klass()) {
// tag_old should be klass - 4881222
if (! (tag_new.is_unresolved_klass() || tag_new.is_klass()))
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -393,7 +393,7 @@
// Find method and invoke standard lookup
methodHandle method (THREAD,
- klass->uncached_lookup_method(m_name, s_name, Klass::normal));
+ klass->uncached_lookup_method(m_name, s_name, Klass::find_overpass));
address result = lookup(method, in_base_library, CATCH);
assert(in_base_library, "must be in basic library");
guarantee(result != NULL, "must be non NULL");
--- a/hotspot/src/share/vm/runtime/arguments.cpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Thu Feb 05 15:44:19 2015 -0800
@@ -1127,7 +1127,7 @@
#endif
intx Arguments::scaled_compile_threshold(intx threshold, double scale) {
- if (scale == 1.0 || scale < 0.0) {
+ if (scale == 1.0 || scale <= 0.0) {
return threshold;
} else {
return (intx)(threshold * scale);
@@ -1143,7 +1143,7 @@
// Check value to avoid calculating log2 of 0.
if (scale == 0.0) {
- return 1;
+ return freq_log;
}
intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale);
@@ -3479,8 +3479,10 @@
set_mode_flags(_int);
}
- if ((TieredCompilation && CompileThresholdScaling == 0)
- || (!TieredCompilation && scaled_compile_threshold(CompileThreshold) == 0)) {
+ // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
+ // but like -Xint, leave compilation thresholds unaffected.
+ // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
+ if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
set_mode_flags(_int);
}
--- a/hotspot/src/share/vm/runtime/os.hpp Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/src/share/vm/runtime/os.hpp Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -173,10 +173,10 @@
static jlong javaTimeMillis();
static jlong javaTimeNanos();
static void javaTimeNanos_info(jvmtiTimerInfo *info_ptr);
+ static void javaTimeSystemUTC(jlong &seconds, jlong &nanos);
static void run_periodic_checks();
static bool supports_monotonic_clock();
-
// Returns the elapsed time in seconds since the vm started.
static double elapsedTime();
--- a/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java Thu Feb 05 15:44:19 2015 -0800
@@ -87,6 +87,13 @@
{
"-XX:-TieredCompilation",
"-XX:+PrintFlagsFinal",
+ "-XX:CompileThreshold=1000",
+ "-XX:CompileThresholdScaling=0.0",
+ "-version"
+ },
+ {
+ "-XX:-TieredCompilation",
+ "-XX:+PrintFlagsFinal",
"-XX:CompileThreshold=0",
"-XX:CompileThresholdScaling=0.75",
"-version"
@@ -108,6 +115,11 @@
"double CompileThresholdScaling := 0.750000 {product}"
},
{
+ "intx CompileThreshold := 1000 {pd product}",
+ "double CompileThresholdScaling := 0.000000 {product}",
+ "interpreted mode"
+ },
+ {
"intx CompileThreshold := 0 {pd product}",
"double CompileThresholdScaling := 0.750000 {product}",
"interpreted mode"
@@ -295,21 +307,21 @@
"double CompileThresholdScaling := 2.000000 {product}"
},
{
- "intx Tier0BackedgeNotifyFreqLog := 0 {product}",
- "intx Tier0InvokeNotifyFreqLog := 0 {product}",
- "intx Tier23InlineeNotifyFreqLog := 0 {product}",
- "intx Tier2BackedgeNotifyFreqLog := 0 {product}",
- "intx Tier2InvokeNotifyFreqLog := 0 {product}",
- "intx Tier3BackEdgeThreshold := 0 {product}",
- "intx Tier3BackedgeNotifyFreqLog := 0 {product}",
- "intx Tier3CompileThreshold := 0 {product}",
- "intx Tier3InvocationThreshold := 0 {product}",
- "intx Tier3InvokeNotifyFreqLog := 0 {product}",
- "intx Tier3MinInvocationThreshold := 0 {product}",
- "intx Tier4BackEdgeThreshold := 0 {product}",
- "intx Tier4CompileThreshold := 0 {product}",
- "intx Tier4InvocationThreshold := 0 {product}",
- "intx Tier4MinInvocationThreshold := 0 {product}",
+ "intx Tier0BackedgeNotifyFreqLog := 10 {product}",
+ "intx Tier0InvokeNotifyFreqLog := 7 {product}",
+ "intx Tier23InlineeNotifyFreqLog := 20 {product}",
+ "intx Tier2BackedgeNotifyFreqLog := 14 {product}",
+ "intx Tier2InvokeNotifyFreqLog := 11 {product}",
+ "intx Tier3BackEdgeThreshold := 60000 {product}",
+ "intx Tier3BackedgeNotifyFreqLog := 13 {product}",
+ "intx Tier3CompileThreshold := 2000 {product}",
+ "intx Tier3InvocationThreshold := 200 {product}",
+ "intx Tier3InvokeNotifyFreqLog := 10 {product}",
+ "intx Tier3MinInvocationThreshold := 100 {product}",
+ "intx Tier4BackEdgeThreshold := 40000 {product}",
+ "intx Tier4CompileThreshold := 15000 {product}",
+ "intx Tier4InvocationThreshold := 5000 {product}",
+ "intx Tier4MinInvocationThreshold := 600 {product}",
"double CompileThresholdScaling := 0.000000 {product}",
"interpreted mode"
}
--- a/hotspot/test/compiler/codecache/cli/printcodecache/PrintCodeCacheRunner.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/codecache/cli/printcodecache/PrintCodeCacheRunner.java Thu Feb 05 15:44:19 2015 -0800
@@ -82,6 +82,9 @@
ExitCode.OK,
testCaseDescription.getTestOptions(options,
CommandLineOptionTest.prepareBooleanFlag(
- "PrintCodeCache", printCodeCache)));
+ "PrintCodeCache", printCodeCache),
+ // Do not use large pages to avoid large page
+ // alignment of code heaps affecting their size.
+ "-XX:-UseLargePages"));
}
}
--- a/hotspot/test/compiler/codecache/stress/CodeCacheStressRunner.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/codecache/stress/CodeCacheStressRunner.java Thu Feb 05 15:44:19 2015 -0800
@@ -36,7 +36,7 @@
try {
// adjust timeout and substract vm init and exit time
long timeout = Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT);
- timeout *= 0.9;
+ timeout *= 0.8;
new TimeLimitedRunner(timeout, 2.0d, this::test).call();
} catch (Exception e) {
throw new Error("Exception occurred during test execution", e);
--- a/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Thu Feb 05 15:44:19 2015 -0800
@@ -77,7 +77,7 @@
}
public OverloadCompileQueueTest() {
- Helper.startInfiniteLoopThread(this::lockUnlock);
+ Helper.startInfiniteLoopThread(this::lockUnlock, 100L);
}
@Override
@@ -99,8 +99,9 @@
private void lockUnlock() {
try {
+ int sleep = Helper.RNG.nextInt(MAX_SLEEP);
Helper.WHITE_BOX.lockCompilation();
- Thread.sleep(Helper.RNG.nextInt(MAX_SLEEP));
+ Thread.sleep(sleep);
} catch (InterruptedException e) {
throw new Error("TESTBUG: lockUnlocker thread was unexpectedly interrupted", e);
} finally {
--- a/hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java Thu Feb 05 15:44:19 2015 -0800
@@ -26,7 +26,6 @@
* @bug 8042235
* @summary redefining method used by multiple MethodHandles crashes VM
* @compile -XDignore.symbol.file RedefineMethodUsedByMultipleMethodHandles.java
- * @ignore 7076820
* @run main RedefineMethodUsedByMultipleMethodHandles
*/
--- a/hotspot/test/compiler/oracle/CheckCompileCommandOption.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/oracle/CheckCompileCommandOption.java Thu Feb 05 15:44:19 2015 -0800
@@ -21,12 +21,15 @@
* questions.
*/
+import java.io.PrintWriter;
+import java.io.File;
+
import com.oracle.java.testlibrary.*;
/*
* @test CheckCompileCommandOption
- * @bug 8055286 8056964 8059847
- * @summary "Checks parsing of -XX:+CompileCommand=option"
+ * @bug 8055286 8056964 8059847 8069035
+ * @summary "Checks parsing of -XX:CompileCommand=option"
* @library /testlibrary
* @run main CheckCompileCommandOption
*/
@@ -45,38 +48,69 @@
// have the the following types: intx, uintx, bool, ccstr,
// ccstrlist, and double.
+ private static final String[][] FILE_ARGUMENTS = {
+ {
+ "-XX:CompileCommandFile=" + new File(System.getProperty("test.src", "."), "command1.txt"),
+ "-version"
+ },
+ {
+ "-XX:CompileCommandFile=" + new File(System.getProperty("test.src", "."), "command2.txt"),
+ "-version"
+ }
+ };
+
+ private static final String[][] FILE_EXPECTED_OUTPUT = {
+ {
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption1 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption2 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption3 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption4 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption5 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption6 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption7 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption8 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption9 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption10 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption11 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption12 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption13 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption14 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption15 = true",
+ "CompileCommand: option com/oracle/Test.test(I) bool MyBoolOption16 = true"
+ },
+ {
+ "CompileCommand: option Test.test const char* MyListOption = '_foo _bar'",
+ "CompileCommand: option Test.test const char* MyStrOption = '_foo'",
+ "CompileCommand: option Test.test bool MyBoolOption = false",
+ "CompileCommand: option Test.test intx MyIntxOption = -1",
+ "CompileCommand: option Test.test uintx MyUintxOption = 1",
+ "CompileCommand: option Test.test bool MyFlag = true",
+ "CompileCommand: option Test.test double MyDoubleOption = 1.123000"
+ }
+ };
+
private static final String[][] TYPE_1_ARGUMENTS = {
{
"-XX:CompileCommand=option,com/oracle/Test.test,MyBoolOption1",
"-XX:CompileCommand=option,com/oracle/Test,test,MyBoolOption2",
"-XX:CompileCommand=option,com.oracle.Test::test,MyBoolOption3",
"-XX:CompileCommand=option,com/oracle/Test::test,MyBoolOption4",
- "-version"
- },
- {
- "-XX:CompileCommand=option,com/oracle/Test.test,MyBoolOption1,MyBoolOption2",
- "-version"
- },
- {
- "-XX:CompileCommand=option,com/oracle/Test,test,MyBoolOption1,MyBoolOption2",
+ "-XX:CompileCommand=option,com/oracle/Test.test,MyBoolOption5,MyBoolOption6",
+ "-XX:CompileCommand=option,com/oracle/Test,test,MyBoolOption7,MyBoolOption8",
"-version"
}
};
private static final String[][] TYPE_1_EXPECTED_OUTPUTS = {
{
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption1 = true",
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption2 = true",
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption3 = true",
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption4 = true"
- },
- {
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption1 = true",
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption2 = true",
- },
- {
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption1 = true",
- "CompilerOracle: option com/oracle/Test.test bool MyBoolOption2 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption1 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption2 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption3 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption4 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption5 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption6 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption7 = true",
+ "CompileCommand: option com/oracle/Test.test bool MyBoolOption8 = true"
}
};
@@ -88,38 +122,28 @@
"-XX:CompileCommand=option,Test::test,intx,MyIntxOption,-1",
"-XX:CompileCommand=option,Test::test,uintx,MyUintxOption,1",
"-XX:CompileCommand=option,Test::test,MyFlag",
- "-XX:CompileCommand=option,Test::test,double,MyDoubleOption,1.123",
- "-version"
- },
- {
- "-XX:CompileCommand=option,Test.test,double,MyDoubleOption,1.123",
- "-version"
- },
- {
- "-XX:CompileCommand=option,Test::test,bool,MyBoolOption,false,intx,MyIntxOption,-1,uintx,MyUintxOption,1,MyFlag,double,MyDoubleOption,1.123",
+ "-XX:CompileCommand=option,Test::test,double,MyDoubleOption1,1.123",
+ "-XX:CompileCommand=option,Test.test,double,MyDoubleOption2,1.123",
+ "-XX:CompileCommand=option,Test::test,bool,MyBoolOptionX,false,intx,MyIntxOptionX,-1,uintx,MyUintxOptionX,1,MyFlagX,double,MyDoubleOptionX,1.123",
"-version"
}
};
private static final String[][] TYPE_2_EXPECTED_OUTPUTS = {
{
- "CompilerOracle: option Test.test const char* MyListOption = '_foo _bar'",
- "CompilerOracle: option Test.test const char* MyStrOption = '_foo'",
- "CompilerOracle: option Test.test bool MyBoolOption = false",
- "CompilerOracle: option Test.test intx MyIntxOption = -1",
- "CompilerOracle: option Test.test uintx MyUintxOption = 1",
- "CompilerOracle: option Test.test bool MyFlag = true",
- "CompilerOracle: option Test.test double MyDoubleOption = 1.123000"
- },
- {
- "CompilerOracle: option Test.test double MyDoubleOption = 1.123000"
- },
- {
- "CompilerOracle: option Test.test bool MyBoolOption = false",
- "CompilerOracle: option Test.test intx MyIntxOption = -1",
- "CompilerOracle: option Test.test uintx MyUintxOption = 1",
- "CompilerOracle: option Test.test bool MyFlag = true",
- "CompilerOracle: option Test.test double MyDoubleOption = 1.123000",
+ "CompileCommand: option Test.test const char* MyListOption = '_foo _bar'",
+ "CompileCommand: option Test.test const char* MyStrOption = '_foo'",
+ "CompileCommand: option Test.test bool MyBoolOption = false",
+ "CompileCommand: option Test.test intx MyIntxOption = -1",
+ "CompileCommand: option Test.test uintx MyUintxOption = 1",
+ "CompileCommand: option Test.test bool MyFlag = true",
+ "CompileCommand: option Test.test double MyDoubleOption1 = 1.123000",
+ "CompileCommand: option Test.test double MyDoubleOption2 = 1.123000",
+ "CompileCommand: option Test.test bool MyBoolOptionX = false",
+ "CompileCommand: option Test.test intx MyIntxOptionX = -1",
+ "CompileCommand: option Test.test uintx MyUintxOptionX = 1",
+ "CompileCommand: option Test.test bool MyFlagX = true",
+ "CompileCommand: option Test.test double MyDoubleOptionX = 1.123000",
}
};
@@ -172,7 +196,7 @@
out.shouldContain(expected_output);
}
- out.shouldNotContain("CompileCommand: unrecognized line");
+ out.shouldNotContain("CompileCommand: An error occured during parsing");
out.shouldHaveExitValue(0);
}
@@ -183,7 +207,7 @@
pb = ProcessTools.createJavaProcessBuilder(arguments);
out = new OutputAnalyzer(pb.start());
- out.shouldContain("CompileCommand: unrecognized line");
+ out.shouldContain("CompileCommand: An error occured during parsing");
out.shouldHaveExitValue(0);
}
@@ -212,5 +236,10 @@
for (String[] arguments: TYPE_2_INVALID_ARGUMENTS) {
verifyInvalidOption(arguments);
}
+
+ // Check if commands in command file are parsed correctly
+ for (int i = 0; i < FILE_ARGUMENTS.length; i++) {
+ verifyValidOption(FILE_ARGUMENTS[i], FILE_EXPECTED_OUTPUT[i]);
+ }
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/oracle/TestCompileCommand.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 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.
+ */
+
+import java.io.PrintWriter;
+import java.io.File;
+
+import com.oracle.java.testlibrary.*;
+
+/*
+ * @test TestCompileCommand
+ * @bug 8069389
+ * @summary "Regression tests of -XX:CompileCommand"
+ * @library /testlibrary
+ * @run main TestCompileCommand
+ */
+
+public class TestCompileCommand {
+
+ private static final String[][] ARGUMENTS = {
+ {
+ "-XX:CompileCommand=print,*01234567890123456789012345678901234567890123456789,*0123456789012345678901234567890123456789",
+ "-version"
+ }
+ };
+
+ private static final String[][] OUTPUTS = {
+ {
+ "print *01234567890123456789012345678901234567890123456789.*0123456789012345678901234567890123456789"
+ }
+ };
+
+ private static void verifyValidOption(String[] arguments, String[] expected_outputs) throws Exception {
+ ProcessBuilder pb;
+ OutputAnalyzer out;
+
+ pb = ProcessTools.createJavaProcessBuilder(arguments);
+ out = new OutputAnalyzer(pb.start());
+
+ for (String expected_output : expected_outputs) {
+ out.shouldContain(expected_output);
+ }
+
+ out.shouldNotContain("CompileCommand: An error occured during parsing");
+ out.shouldHaveExitValue(0);
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ if (ARGUMENTS.length != OUTPUTS.length) {
+ throw new RuntimeException("Test is set up incorrectly: length of arguments and expected outputs for type (1) options does not match.");
+ }
+
+ // Check if type (1) options are parsed correctly
+ for (int i = 0; i < ARGUMENTS.length; i++) {
+ verifyValidOption(ARGUMENTS[i], OUTPUTS[i]);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/oracle/command1.txt Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,12 @@
+option,com/oracle/Test.test,MyBoolOption1
+option,com/oracle/Test,test,MyBoolOption2
+option,com.oracle.Test::test,MyBoolOption3
+option,com/oracle/Test::test,MyBoolOption4
+option,com/oracle/Test.test,MyBoolOption5,MyBoolOption6
+option,com/oracle/Test,test,MyBoolOption7,MyBoolOption8
+option,com/oracle/Test.test(I),MyBoolOption9
+option,com/oracle/Test,test,(I),MyBoolOption10
+option,com.oracle.Test::test(I),MyBoolOption11
+option,com/oracle/Test::test(I),MyBoolOption12
+option,com/oracle/Test.test(I),MyBoolOption13,MyBoolOption14
+option,com/oracle/Test,test(I),MyBoolOption15,MyBoolOption16
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/oracle/command2.txt Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,7 @@
+option,Test::test,ccstrlist,MyListOption,_foo,_bar
+option,Test::test,ccstr,MyStrOption,_foo
+option,Test::test,bool,MyBoolOption,false
+option,Test::test,intx,MyIntxOption,-1
+option,Test::test,uintx,MyUintxOption,1
+option,Test::test,MyFlag
+option,Test::test,double,MyDoubleOption,1.123
--- a/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java Thu Feb 05 15:44:19 2015 -0800
@@ -28,7 +28,6 @@
* @bug 8038636
* @library /testlibrary
* @build Agent
- * @ignore 7076820
* @run main ClassFileInstaller Agent
* @run main Launcher
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:ReservedCodeCacheSize=3M Agent
--- a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java Thu Feb 05 15:44:19 2015 -0800
@@ -28,7 +28,6 @@
* @bug 8040237
* @library /testlibrary
* @build Agent Test A B
- * @ignore 7076820
* @run main ClassFileInstaller Agent
* @run main Launcher
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:ReservedCodeCacheSize=3M Agent
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Thu Feb 05 15:44:19 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -119,13 +119,13 @@
return new String[] { getMethodWithLockName() };
}
- public void lock(booleab forceAbort) {
+ public void lock(boolean forceAbort) {
synchronized(monitor) {
if (forceAbort) {
// We're calling native method in order to force
// abort. It's done by explicit xabort call emitted
// in SharedRuntime::generate_native_wrapper.
- // If an actuall JNI call will be replaced by
+ // If an actual JNI call will be replaced by
// intrinsic - we'll be in trouble, since xabort
// will be no longer called and test may fail.
UNSAFE.addressSize();
--- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java Thu Feb 05 15:44:19 2015 -0800
@@ -34,7 +34,6 @@
/*
* @test
* @bug 8059624 8064669
- * @ignore 8066998
* @library /testlibrary /../../test/lib
* @build ForceNMethodSweepTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -42,7 +41,7 @@
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
* -XX:-TieredCompilation -XX:+WhiteBoxAPI
* -XX:CompileCommand=compileonly,SimpleTestCase$Helper::*
- * ForceNMethodSweepTest
+ * -XX:-BackgroundCompilation ForceNMethodSweepTest
* @summary testing of WB::forceNMethodSweep
*/
public class ForceNMethodSweepTest extends CompilerWhiteBoxTest {
--- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java Thu Feb 05 11:43:29 2015 -0800
+++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java Thu Feb 05 15:44:19 2015 -0800
@@ -41,6 +41,10 @@
// Compressed Class Space is only available on 64-bit JVMs
return;
}
+ if (!Platform.shouldSAAttach()) {
+ System.out.println("SA attach not expected to work - test skipped.");
+ return;
+ }
String pid = Integer.toString(ProcessTools.getProcessId());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/AllocateInstance.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies the behaviour of Unsafe.allocateInstance
+ * @library /testlibrary
+ * @run main AllocateInstance
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class AllocateInstance {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+
+ // allocateInstance() should not result in a call to the constructor
+ TestClass tc = (TestClass)unsafe.allocateInstance(TestClass.class);
+ assertFalse(tc.calledConstructor);
+
+ // allocateInstance() on an abstract class should result in an InstantiationException
+ try {
+ AbstractClass ac = (AbstractClass)unsafe.allocateInstance(AbstractClass.class);
+ throw new RuntimeException("Did not get expected InstantiationException");
+ } catch (InstantiationException e) {
+ // Expected
+ }
+ }
+
+ class TestClass {
+ public boolean calledConstructor = false;
+
+ public TestClass() {
+ calledConstructor = true;
+ }
+ }
+
+ abstract class AbstractClass {
+ public AbstractClass() {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/AllocateMemory.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies behaviour of Unsafe.allocateMemory
+ * @library /testlibrary
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=20m AllocateMemory
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class AllocateMemory {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+
+ // Allocate a byte, write to the location and read back the value
+ long address = unsafe.allocateMemory(1);
+ assertNotEquals(address, 0L);
+
+ unsafe.putByte(address, Byte.MAX_VALUE);
+ assertEquals(Byte.MAX_VALUE, unsafe.getByte(address));
+ unsafe.freeMemory(address);
+
+ // Call to allocateMemory() with a negative value should result in an IllegalArgumentException
+ try {
+ address = unsafe.allocateMemory(-1);
+ throw new RuntimeException("Did not get expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ // Expected
+ assertNotEquals(address, 0L);
+ }
+
+ // allocateMemory() should throw an OutOfMemoryError when the underlying malloc fails,
+ // we test this by limiting the malloc using -XX:MallocMaxTestWords
+ try {
+ address = unsafe.allocateMemory(20 * 1024 * 1024 * 8);
+ } catch (OutOfMemoryError e) {
+ // Expected
+ return;
+ }
+ throw new RuntimeException("Did not get expected OutOfMemoryError");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/CopyMemory.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies behaviour of Unsafe.copyMemory
+ * @library /testlibrary
+ * @run main CopyMemory
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class CopyMemory {
+ final static int LENGTH = 8;
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ long src = unsafe.allocateMemory(LENGTH);
+ long dst = unsafe.allocateMemory(LENGTH);
+ assertNotEquals(src, 0L);
+ assertNotEquals(dst, 0L);
+
+ // call copyMemory() with different lengths and verify the contents of
+ // the destination array
+ for (int i = 0; i < LENGTH; i++) {
+ unsafe.putByte(src + i, (byte)i);
+ unsafe.copyMemory(src, dst, i);
+ for (int j = 0; j < i; j++) {
+ assertEquals(unsafe.getByte(src + j), unsafe.getByte(src + j));
+ }
+ }
+ unsafe.freeMemory(src);
+ unsafe.freeMemory(dst);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/DefineClass.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies the behaviour of Unsafe.defineClass
+ * @library /testlibrary
+ * @run main DefineClass
+ */
+
+import java.security.ProtectionDomain;
+import java.io.InputStream;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class DefineClass {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ TestClassLoader classloader = new TestClassLoader();
+ ProtectionDomain pd = new ProtectionDomain(null, null);
+
+ byte klassbuf[] = InMemoryJavaCompiler.compile("TestClass", "class TestClass { }");
+
+ // Invalid class data
+ try {
+ unsafe.defineClass(null, klassbuf, 4, klassbuf.length - 4, classloader, pd);
+ throw new RuntimeException("defineClass did not throw expected ClassFormatError");
+ } catch (ClassFormatError e) {
+ // Expected
+ }
+
+ // Negative offset
+ try {
+ unsafe.defineClass(null, klassbuf, -1, klassbuf.length, classloader, pd);
+ throw new RuntimeException("defineClass did not throw expected IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Expected
+ }
+
+ // Negative length
+ try {
+ unsafe.defineClass(null, klassbuf, 0, -1, classloader, pd);
+ throw new RuntimeException("defineClass did not throw expected IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Expected
+ }
+
+ // Offset greater than klassbuf.length
+ try {
+ unsafe.defineClass(null, klassbuf, klassbuf.length + 1, klassbuf.length, classloader, pd);
+ throw new RuntimeException("defineClass did not throw expected IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Expected
+ }
+
+ // Length greater than klassbuf.length
+ try {
+ unsafe.defineClass(null, klassbuf, 0, klassbuf.length + 1, classloader, pd);
+ throw new RuntimeException("defineClass did not throw expected IndexOutOfBoundsException");
+ } catch (IndexOutOfBoundsException e) {
+ // Expected
+ }
+
+ Class klass = unsafe.defineClass(null, klassbuf, 0, klassbuf.length, classloader, pd);
+ assertEquals(klass.getClassLoader(), classloader);
+ assertEquals(klass.getProtectionDomain(), pd);
+ }
+
+ private static class TestClassLoader extends ClassLoader {
+ public TestClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+
+ public TestClassLoader() {
+ super();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/FieldOffset.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies the behaviour of Unsafe.fieldOffset
+ * @library /testlibrary
+ * @run main FieldOffset
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import java.lang.reflect.*;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class FieldOffset {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Field fields[] = Test.class.getDeclaredFields();
+
+ for (int i = 0; i < fields.length; i++) {
+ int offset = unsafe.fieldOffset(fields[i]);
+ // Ensure we got a valid offset value back
+ assertNotEquals(offset, unsafe.INVALID_FIELD_OFFSET);
+
+ // Make sure the field offset is unique
+ for (int j = 0; j < i; j++) {
+ assertNotEquals(offset, unsafe.fieldOffset(fields[j]));
+ }
+ }
+ }
+
+ class Test {
+ boolean booleanField;
+ byte byteField;
+ char charField;
+ double doubleField;
+ float floatField;
+ int intField;
+ long longField;
+ Object objectField;
+ short shortField;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetField.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies behaviour of Unsafe.getField
+ * @library /testlibrary
+ * @run main GetField
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import java.lang.reflect.*;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetField {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ // Unsafe.INVALID_FIELD_OFFSET is a static final int field,
+ // make sure getField returns the correct field
+ Field field = Unsafe.class.getField("INVALID_FIELD_OFFSET");
+ assertNotEquals(field.getModifiers() & Modifier.FINAL, 0);
+ assertNotEquals(field.getModifiers() & Modifier.STATIC, 0);
+ assertEquals(field.getType(), int.class);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutAddress.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * Verify behaviour of Unsafe.get/putAddress and Unsafe.addressSize
+ * @library /testlibrary
+ * @run main GetPutAddress
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutAddress {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ int addressSize = unsafe.addressSize();
+ // Ensure the size returned from Unsafe.addressSize is correct
+ assertEquals(unsafe.addressSize(), Platform.is32bit() ? 4 : 8);
+
+ // Write the address, read it back and make sure it's the same value
+ long address = unsafe.allocateMemory(addressSize);
+ unsafe.putAddress(address, address);
+ long readAddress = unsafe.getAddress(address);
+ if (addressSize == 4) {
+ readAddress &= 0x00000000FFFFFFFFL;
+ }
+ assertEquals(address, readAddress);
+ unsafe.freeMemory(address);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutBoolean.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putBoolean
+ * @library /testlibrary
+ * @run main GetPutBoolean
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutBoolean {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("b1");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals(false, unsafe.getBoolean(t, offset));
+ unsafe.putBoolean(t, offset, true);
+ assertEquals(true, unsafe.getBoolean(t, offset));
+
+ boolean arrayBoolean[] = { true, false, false, true };
+ int scale = unsafe.arrayIndexScale(arrayBoolean.getClass());
+ offset = unsafe.arrayBaseOffset(arrayBoolean.getClass());
+ for (int i = 0; i < arrayBoolean.length; i++) {
+ assertEquals(unsafe.getBoolean(arrayBoolean, offset), arrayBoolean[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public boolean b1 = false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutByte.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putByte
+ * @library /testlibrary
+ * @run main GetPutByte
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutByte {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("b");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals((byte)0, unsafe.getByte(t, offset));
+ unsafe.putByte(t, offset, (byte)1);
+ assertEquals((byte)1, unsafe.getByte(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putByte(address, (byte)2);
+ assertEquals((byte)2, unsafe.getByte(address));
+ unsafe.freeMemory(address);
+
+ byte arrayByte[] = { -1, 0, 1, 2 };
+ int scale = unsafe.arrayIndexScale(arrayByte.getClass());
+ offset = unsafe.arrayBaseOffset(arrayByte.getClass());
+ for (int i = 0; i < arrayByte.length; i++) {
+ assertEquals(unsafe.getByte(arrayByte, offset), arrayByte[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public byte b = 0;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutChar.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putChar
+ * @library /testlibrary
+ * @run main GetPutChar
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutChar {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("c");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals('\u0000', unsafe.getChar(t, offset));
+ unsafe.putChar(t, offset, '\u0001');
+ assertEquals('\u0001', unsafe.getChar(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putChar(address, '\u0002');
+ assertEquals('\u0002', unsafe.getChar(address));
+ unsafe.freeMemory(address);
+
+ char arrayChar[] = { '\uabcd', '\u00ff', '\uff00', };
+ int scale = unsafe.arrayIndexScale(arrayChar.getClass());
+ offset = unsafe.arrayBaseOffset(arrayChar.getClass());
+ for (int i = 0; i < arrayChar.length; i++) {
+ assertEquals(unsafe.getChar(arrayChar, offset), arrayChar[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public char c = '\u0000';
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutDouble.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putDouble
+ * @library /testlibrary
+ * @run main GetPutDouble
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutDouble {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("d");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals(-1.0, unsafe.getDouble(t, offset));
+ unsafe.putDouble(t, offset, 0.0);
+ assertEquals(0.0, unsafe.getDouble(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putDouble(address, 1.0);
+ assertEquals(1.0, unsafe.getDouble(address));
+ unsafe.freeMemory(address);
+
+ double arrayDouble[] = { -1.0, 0.0, 1.0, 2.0 };
+ int scale = unsafe.arrayIndexScale(arrayDouble.getClass());
+ offset = unsafe.arrayBaseOffset(arrayDouble.getClass());
+ for (int i = 0; i < arrayDouble.length; i++) {
+ assertEquals(unsafe.getDouble(arrayDouble, offset), arrayDouble[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public double d = -1.0;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutFloat.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putFloat
+ * @library /testlibrary
+ * @run main GetPutFloat
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutFloat {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("f");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals(-1.0f, unsafe.getFloat(t, offset));
+ unsafe.putFloat(t, offset, 0.0f);
+ assertEquals(0.0f, unsafe.getFloat(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putFloat(address, 1.0f);
+ assertEquals(1.0f, unsafe.getFloat(address));
+ unsafe.freeMemory(address);
+
+ float arrayFloat[] = { -1.0f, 0.0f, 1.0f, 2.0f };
+ int scale = unsafe.arrayIndexScale(arrayFloat.getClass());
+ offset = unsafe.arrayBaseOffset(arrayFloat.getClass());
+ for (int i = 0; i < arrayFloat.length; i++) {
+ assertEquals(unsafe.getFloat(arrayFloat, offset), arrayFloat[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public float f = -1.0f;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutInt.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @library /testlibrary
+ * @run main GetPutInt
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutInt {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("i");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals(-1, unsafe.getInt(t, offset));
+ unsafe.putInt(t, offset, 0);
+ assertEquals(0, unsafe.getInt(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putInt(address, 1);
+ assertEquals(1, unsafe.getInt(address));
+ unsafe.freeMemory(address);
+
+ int arrayInt[] = { -1, 0, 1, 2 };
+ int scale = unsafe.arrayIndexScale(arrayInt.getClass());
+ offset = unsafe.arrayBaseOffset(arrayInt.getClass());
+ for (int i = 0; i < arrayInt.length; i++) {
+ assertEquals(unsafe.getInt(arrayInt, offset), arrayInt[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public int i = -1;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutLong.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putLong
+ * @library /testlibrary
+ * @run main GetPutLong
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutLong {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("l");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals(-1L, unsafe.getLong(t, offset));
+ unsafe.putLong(t, offset, 0L);
+ assertEquals(0L, unsafe.getLong(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putLong(address, 1L);
+ assertEquals(1L, unsafe.getLong(address));
+ unsafe.freeMemory(address);
+
+ long arrayLong[] = { -1, 0, 1, 2 };
+ int scale = unsafe.arrayIndexScale(arrayLong.getClass());
+ offset = unsafe.arrayBaseOffset(arrayLong.getClass());
+ for (int i = 0; i < arrayLong.length; i++) {
+ assertEquals(unsafe.getLong(arrayLong, offset), arrayLong[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public long l = -1L;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutObject.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putObject
+ * @library /testlibrary
+ * @run main GetPutObject
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutObject {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Object o = new Object();
+ Field field = Test.class.getField("o");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals(t.o, unsafe.getObject(t, offset));
+
+ unsafe.putObject(t, offset, o);
+ assertEquals(o, unsafe.getObject(t, offset));
+
+ Object arrayObject[] = { unsafe, null, new Object() };
+ int scale = unsafe.arrayIndexScale(arrayObject.getClass());
+ offset = unsafe.arrayBaseOffset(arrayObject.getClass());
+ for (int i = 0; i < arrayObject.length; i++) {
+ assertEquals(unsafe.getObject(arrayObject, offset), arrayObject[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public Object o = new Object();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetPutShort.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify behaviour of Unsafe.get/putShort
+ * @library /testlibrary
+ * @run main GetPutShort
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetPutShort {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ Test t = new Test();
+ Field field = Test.class.getField("s");
+
+ int offset = unsafe.fieldOffset(field);
+ assertEquals((short)-1, unsafe.getShort(t, offset));
+ unsafe.putShort(t, offset, (short)0);
+ assertEquals((short)0, unsafe.getShort(t, offset));
+
+ long address = unsafe.allocateMemory(8);
+ unsafe.putShort(address, (short)1);
+ assertEquals((short)1, unsafe.getShort(address));
+ unsafe.freeMemory(address);
+
+ short arrayShort[] = { -1, 0, 1, 2 };
+ int scale = unsafe.arrayIndexScale(arrayShort.getClass());
+ offset = unsafe.arrayBaseOffset(arrayShort.getClass());
+ for (int i = 0; i < arrayShort.length; i++) {
+ assertEquals(unsafe.getShort(arrayShort, offset), arrayShort[i]);
+ offset += scale;
+ }
+ }
+
+ static class Test {
+ public short s = -1;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/GetUnsafe.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies that getUnsafe() actually throws SecurityException when unsafeAccess is prohibited.
+ * @library /testlibrary
+ * @run main GetUnsafe
+ */
+
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class GetUnsafe {
+ public static void main(String args[]) throws Exception {
+ try {
+ Unsafe unsafe = Unsafe.getUnsafe();
+ } catch (SecurityException e) {
+ // Expected
+ return;
+ }
+ throw new RuntimeException("Did not get expected SecurityException");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/PageSize.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Make sure pageSize() returns a value that is a power of two
+ * @library /testlibrary
+ * @run main PageSize
+ */
+
+import java.lang.reflect.Field;
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class PageSize {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ int pageSize = unsafe.pageSize();
+
+ for (int n = 1; n != 0; n <<= 1) {
+ if (pageSize == n) {
+ return;
+ }
+ }
+ throw new RuntimeException("Expected pagesize to be a power of two, actual pagesize:" + pageSize);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/SetMemory.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verifies that setMemory works correctly
+ * @library /testlibrary
+ * @run main SetMemory
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class SetMemory {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ long address = unsafe.allocateMemory(1);
+ assertNotEquals(address, 0L);
+ unsafe.setMemory(address, 1, (byte)17);
+ assertEquals((byte)17, unsafe.getByte(address));
+ unsafe.freeMemory(address);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Unsafe/ThrowException.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 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.
+ */
+
+/*
+ * @test
+ * @summary Verify that throwException() can throw an exception
+ * @library /testlibrary
+ * @run main ThrowException
+ */
+
+import com.oracle.java.testlibrary.*;
+import sun.misc.Unsafe;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class ThrowException {
+ public static void main(String args[]) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ try {
+ unsafe.throwException(new TestException());
+ } catch (Throwable t) {
+ if (t instanceof TestException) {
+ return;
+ }
+ throw t;
+ }
+ throw new RuntimeException("Did not throw expected TestException");
+ }
+ static class TestException extends Exception {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java Thu Feb 05 15:44:19 2015 -0800
@@ -0,0 +1,138 @@
+
+/*
+ * Copyright (c) 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.
+ */
+
+/**
+ * @test
+ * @bug 8008678
+ * @summary JSR 292: constant pool reconstitution must support pseudo strings
+ * @library /testlibrary
+ * @compile -XDignore.symbol.file TestLambdaFormRetransformation.java
+ * @run main TestLambdaFormRetransformation
+ */
+
+import java.io.IOException;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
+import java.lang.instrument.UnmodifiableClassException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.ProtectionDomain;
+import java.util.Arrays;
+
+import com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+
+public class TestLambdaFormRetransformation {
+ private static String MANIFEST = String.format("Manifest-Version: 1.0\n" +
+ "Premain-Class: %s\n" +
+ "Can-Retransform-Classes: true\n",
+ Agent.class.getName());
+
+ private static String CP = System.getProperty("test.classes");
+
+ public static void main(String args[]) throws Throwable {
+ Path agent = TestLambdaFormRetransformation.buildAgent();
+ OutputAnalyzer oa = ProcessTools.executeTestJvm("-javaagent:" +
+ agent.toAbsolutePath().toString(), "-version");
+ oa.shouldHaveExitValue(ExitCode.OK.value);
+ }
+
+ private static Path buildAgent() throws IOException {
+ Path manifest = TestLambdaFormRetransformation.createManifest();
+ Path jar = Files.createTempFile(Paths.get("."), null, ".jar");
+
+ String[] args = new String[] {
+ "-cfm",
+ jar.toAbsolutePath().toString(),
+ manifest.toAbsolutePath().toString(),
+ "-C",
+ TestLambdaFormRetransformation.CP,
+ Agent.class.getName() + ".class"
+ };
+
+ sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
+
+ if (!jarTool.run(args)) {
+ throw new Error("jar failed: args=" + Arrays.toString(args));
+ }
+ return jar;
+ }
+
+ private static Path createManifest() throws IOException {
+ Path manifest = Files.createTempFile(Paths.get("."), null, ".mf");
+ byte[] manifestBytes = TestLambdaFormRetransformation.MANIFEST.getBytes();
+ Files.write(manifest, manifestBytes);
+ return manifest;
+ }
+}
+
+class Agent implements ClassFileTransformer {
+ private static Runnable lambda = () -> {
+ System.out.println("I'll crash you!");
+ };
+
+ public static void premain(String args, Instrumentation instrumentation) {
+ if (!instrumentation.isRetransformClassesSupported()) {
+ System.out.println("Class retransformation is not supported.");
+ return;
+ }
+ System.out.println("Calling lambda to ensure that lambda forms were created");
+
+ Agent.lambda.run();
+
+ System.out.println("Registering class file transformer");
+
+ instrumentation.addTransformer(new Agent());
+
+ for (Class c : instrumentation.getAllLoadedClasses()) {
+ if (c.getName().contains("LambdaForm") &&
+ instrumentation.isModifiableClass(c)) {
+ System.out.format("We've found a modifiable lambda form: %s%n", c.getName());
+ try {
+ instrumentation.retransformClasses(c);
+ } catch (UnmodifiableClassException e) {
+ throw new AssertionError("Modification of modifiable class " +
+ "caused UnmodifiableClassException", e);
+ }
+ }
+ }
+ }
+
+ public static void main(String args[]) {
+ }
+
+ @Override
+ public byte[] transform(ClassLoader loader,
+ String className,
+ Class<?> classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer
+ ) throws IllegalClassFormatException {
+ System.out.println("Transforming " + className);
+ return classfileBuffer.clone();
+ }
+}