Merge
This commit is contained in:
commit
e9af52deeb
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxNameUTF;
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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
|
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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 @@ mapfile_reorder : mapfile $(REORDERFILE)
|
||||
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 $@
|
||||
|
@ -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 @@ SUNWprivate_1.1 {
|
||||
JVM_GetMethodIxSignatureUTF;
|
||||
JVM_GetMethodParameters;
|
||||
JVM_GetMethodTypeAnnotations;
|
||||
JVM_GetNanoTimeAdjustment;
|
||||
JVM_GetPrimitiveArrayElement;
|
||||
JVM_GetProtectionDomain;
|
||||
JVM_GetStackAccessControlContext;
|
||||
|
@ -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 Fast_Unlock(iRegP oop, iRegP box, o7RegP scratch, iRegP scratch2) %{
|
||||
%}
|
||||
|
||||
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);
|
||||
|
@ -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 @@ void MacroAssembler::string_indexofC8(Register str1, Register str2,
|
||||
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 @@ void MacroAssembler::string_indexof(Register str1, Register str2,
|
||||
//
|
||||
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 @@ void MacroAssembler::string_compare(Register str1, Register str2,
|
||||
// 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 @@ void MacroAssembler::string_compare(Register str1, Register str2,
|
||||
// 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)
|
||||
|
@ -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 @@ jlong os::javaTimeMillis() {
|
||||
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++)
|
||||
|
@ -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 @@ jlong os::javaTimeMillis() {
|
||||
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)
|
||||
|
@ -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 @@ jlong os::javaTimeMillis() {
|
||||
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
|
||||
|
@ -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 @@ jlong os::javaTimeMillis() {
|
||||
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();
|
||||
}
|
||||
|
@ -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 @@ jlong windows_to_java_time(FILETIME wt) {
|
||||
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 @@ jlong os::javaTimeMillis() {
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ void os::win32::print_windows_version(outputStream* st) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 6004:
|
||||
case 10000:
|
||||
if (is_workstation) {
|
||||
st->print("10");
|
||||
} else {
|
||||
|
@ -1950,7 +1950,7 @@ bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
|
||||
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 @@ void ClassVerifier::verify_invoke_init(
|
||||
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());
|
||||
|
@ -199,15 +199,10 @@ void CodeCache::initialize_heaps() {
|
||||
}
|
||||
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 @@ void CodeCache::initialize_heaps() {
|
||||
// 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 @@ const char* CodeCache::get_code_heap_flag_name(int code_blob_type) {
|
||||
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 @@ void CodeCache::add_heap(ReservedSpace rs, const char* name, size_t size_initial
|
||||
_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 @@ void CodeCache::initialize() {
|
||||
} 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
|
||||
|
@ -98,12 +98,13 @@ class CodeCache : AllStatic {
|
||||
// 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
|
||||
|
@ -553,7 +553,8 @@ static MethodMatcher::Mode check_mode(char name[], const char*& error_msg) {
|
||||
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 @@ static MethodMatcher* scan_flag_and_value(const char* type, const char* line, in
|
||||
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 @@ void CompilerOracle::parse_from_line(char* line) {
|
||||
|
||||
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 @@ void CompilerOracle::parse_from_line(char* line) {
|
||||
//
|
||||
// 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 @@ void CompilerOracle::parse_from_line(char* line) {
|
||||
// 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);
|
||||
|
@ -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 @@ void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle kl
|
||||
// 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 @@ int LinkResolver::vtable_index_of_interface_method(KlassHandle klass,
|
||||
// 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);
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ oop Universe::_the_min_jint_string = NULL;
|
||||
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::_virtual_machine_error_instance = NULL;
|
||||
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 @@ void Universe::serialize(SerializeClosure* f, bool do_all) {
|
||||
_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 @@ jint universe_init() {
|
||||
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 @@ bool universe_post_init() {
|
||||
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 @@ bool universe_post_init() {
|
||||
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
|
||||
|
@ -148,8 +148,7 @@ class Universe: AllStatic {
|
||||
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 @@ class Universe: AllStatic {
|
||||
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 @@ class Universe: AllStatic {
|
||||
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; }
|
||||
|
@ -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 @@ Klass* ArrayKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) co
|
||||
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) {
|
||||
|
@ -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 @@ class ArrayKlass: public Klass {
|
||||
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) {
|
||||
|
@ -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 @@ Symbol* ConstantPool::uncached_klass_ref_at_noresolve(int which) {
|
||||
}
|
||||
|
||||
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 @@ void ConstantPool::patch_resolved_references(GrowableArray<Handle>* cp_patches)
|
||||
// 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
|
||||
|
@ -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 SymbolHashMap;
|
||||
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 @@ class ConstantPool : public Metadata {
|
||||
|
||||
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 @@ class ConstantPool : public Metadata {
|
||||
// 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 @@ class ConstantPool : public Metadata {
|
||||
|
||||
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 @@ class ConstantPool : public Metadata {
|
||||
|
||||
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) {
|
||||
|
@ -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 @@ static int binary_search(Array<Method*>* methods, Symbol* name) {
|
||||
|
||||
// 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 @@ Method* InstanceKlass::find_instance_method(Symbol* name, Symbol* signature) {
|
||||
// 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 @@ bool InstanceKlass::method_matches(Method* m, Symbol* signature, bool skipping_o
|
||||
// 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 @@ int InstanceKlass::find_method_index(
|
||||
}
|
||||
// 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 @@ int InstanceKlass::find_method_by_name(
|
||||
|
||||
// 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 @@ Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
|
||||
}
|
||||
// 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 @@ Method* InstanceKlass::lookup_method_in_ordered_interfaces(Symbol* name,
|
||||
// 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 @@ Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ class InstanceKlass: public Klass {
|
||||
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 @@ private:
|
||||
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();
|
||||
|
@ -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 @@ Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
|
||||
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"
|
||||
|
@ -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 @@ protected:
|
||||
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 @@ protected:
|
||||
// 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
|
||||
|
@ -649,7 +649,7 @@ bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
|
||||
// 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 @@ bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
|
||||
&& 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 @@ void klassVtable::add_new_mirandas_to_lists(
|
||||
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) {
|
||||
|
@ -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* LibraryCallKit::string_indexOf(Node* string_object, ciTypeArray* target_ar
|
||||
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 @@ bool LibraryCallKit::inline_string_indexOf() {
|
||||
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 @@ bool LibraryCallKit::inline_string_indexOf() {
|
||||
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);
|
||||
|
@ -2475,7 +2475,7 @@ void Scheduling::DoScheduling() {
|
||||
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...
|
||||
}
|
||||
|
@ -428,6 +428,7 @@ int PhaseChaitin::possibly_merge_multidef(Node *n, uint k, Block *block, RegToDe
|
||||
// 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);
|
||||
|
@ -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 @@ JVM_LEAF(jlong, JVM_NanoTime(JNIEnv *env, jclass ignored))
|
||||
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 = 0x0100000000; // 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 @@ JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, job
|
||||
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");
|
||||
|
@ -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 @@ JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored);
|
||||
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);
|
||||
|
@ -3376,7 +3376,9 @@ void VM_RedefineClasses::AdjustCpoolCacheAndVtable::do_klass(Klass* k) {
|
||||
// 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 @@ void VM_RedefineClasses::AdjustCpoolCacheAndVtable::do_klass(Klass* k) {
|
||||
// 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);
|
||||
|
@ -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 @@ bool MethodComparator::pool_constants_same(int cpi_old, int cpi_new) {
|
||||
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()))
|
||||
|
@ -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 @@ address NativeLookup::base_library_lookup(const char* class_name, const char* me
|
||||
|
||||
// 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");
|
||||
|
@ -1127,7 +1127,7 @@ static void no_shared_spaces(const char* message) {
|
||||
#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 @@ intx Arguments::scaled_freq_log(intx freq_log, double scale) {
|
||||
|
||||
// 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 @@ jint Arguments::finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_req
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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 @@ class os: AllStatic {
|
||||
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();
|
||||
|
||||
|
@ -84,6 +84,13 @@ public class CheckCompileThresholdScaling {
|
||||
"-XX:CompileThresholdScaling=0.75",
|
||||
"-version"
|
||||
},
|
||||
{
|
||||
"-XX:-TieredCompilation",
|
||||
"-XX:+PrintFlagsFinal",
|
||||
"-XX:CompileThreshold=1000",
|
||||
"-XX:CompileThresholdScaling=0.0",
|
||||
"-version"
|
||||
},
|
||||
{
|
||||
"-XX:-TieredCompilation",
|
||||
"-XX:+PrintFlagsFinal",
|
||||
@ -107,6 +114,11 @@ public class CheckCompileThresholdScaling {
|
||||
"intx CompileThreshold := 750 {pd product}",
|
||||
"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}",
|
||||
@ -295,21 +307,21 @@ public class CheckCompileThresholdScaling {
|
||||
"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"
|
||||
}
|
||||
|
@ -82,6 +82,9 @@ public class PrintCodeCacheRunner implements CodeCacheCLITestCase.Runner {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class CodeCacheStressRunner {
|
||||
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);
|
||||
|
@ -77,7 +77,7 @@ public class OverloadCompileQueueTest implements Runnable {
|
||||
}
|
||||
|
||||
public OverloadCompileQueueTest() {
|
||||
Helper.startInfiniteLoopThread(this::lockUnlock);
|
||||
Helper.startInfiniteLoopThread(this::lockUnlock, 100L);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -99,8 +99,9 @@ public class OverloadCompileQueueTest implements Runnable {
|
||||
|
||||
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 {
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
|
@ -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 @@ public class CheckCompileCommandOption {
|
||||
// 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 @@ public class CheckCompileCommandOption {
|
||||
"-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 @@ public class CheckCompileCommandOption {
|
||||
out.shouldContain(expected_output);
|
||||
}
|
||||
|
||||
out.shouldNotContain("CompileCommand: unrecognized line");
|
||||
out.shouldNotContain("CompileCommand: An error occured during parsing");
|
||||
out.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
@ -183,7 +207,7 @@ public class CheckCompileCommandOption {
|
||||
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 @@ public class CheckCompileCommandOption {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
78
hotspot/test/compiler/oracle/TestCompileCommand.java
Normal file
78
hotspot/test/compiler/oracle/TestCompileCommand.java
Normal file
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
12
hotspot/test/compiler/oracle/command1.txt
Normal file
12
hotspot/test/compiler/oracle/command1.txt
Normal file
@ -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
|
7
hotspot/test/compiler/oracle/command2.txt
Normal file
7
hotspot/test/compiler/oracle/command2.txt
Normal file
@ -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
|
@ -28,7 +28,6 @@ import com.oracle.java.testlibrary.*;
|
||||
* @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
|
||||
|
@ -28,7 +28,6 @@ import com.oracle.java.testlibrary.*;
|
||||
* @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
|
||||
|
@ -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 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
|
||||
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();
|
||||
|
@ -34,7 +34,6 @@ import com.oracle.java.testlibrary.InfiniteLoop;
|
||||
/*
|
||||
* @test
|
||||
* @bug 8059624 8064669
|
||||
* @ignore 8066998
|
||||
* @library /testlibrary /../../test/lib
|
||||
* @build ForceNMethodSweepTest
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
@ -42,7 +41,7 @@ import com.oracle.java.testlibrary.InfiniteLoop;
|
||||
* @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 {
|
||||
|
@ -41,6 +41,10 @@ public class CompressedClassSpaceSizeInJmapHeap {
|
||||
// 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());
|
||||
|
||||
|
63
hotspot/test/runtime/Unsafe/AllocateInstance.java
Normal file
63
hotspot/test/runtime/Unsafe/AllocateInstance.java
Normal file
@ -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() {}
|
||||
}
|
||||
}
|
66
hotspot/test/runtime/Unsafe/AllocateMemory.java
Normal file
66
hotspot/test/runtime/Unsafe/AllocateMemory.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
56
hotspot/test/runtime/Unsafe/CopyMemory.java
Normal file
56
hotspot/test/runtime/Unsafe/CopyMemory.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
99
hotspot/test/runtime/Unsafe/DefineClass.java
Normal file
99
hotspot/test/runtime/Unsafe/DefineClass.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
65
hotspot/test/runtime/Unsafe/FieldOffset.java
Normal file
65
hotspot/test/runtime/Unsafe/FieldOffset.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
46
hotspot/test/runtime/Unsafe/GetField.java
Normal file
46
hotspot/test/runtime/Unsafe/GetField.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
52
hotspot/test/runtime/Unsafe/GetPutAddress.java
Normal file
52
hotspot/test/runtime/Unsafe/GetPutAddress.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
59
hotspot/test/runtime/Unsafe/GetPutBoolean.java
Normal file
59
hotspot/test/runtime/Unsafe/GetPutBoolean.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
64
hotspot/test/runtime/Unsafe/GetPutByte.java
Normal file
64
hotspot/test/runtime/Unsafe/GetPutByte.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
64
hotspot/test/runtime/Unsafe/GetPutChar.java
Normal file
64
hotspot/test/runtime/Unsafe/GetPutChar.java
Normal file
@ -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';
|
||||
}
|
||||
}
|
64
hotspot/test/runtime/Unsafe/GetPutDouble.java
Normal file
64
hotspot/test/runtime/Unsafe/GetPutDouble.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
64
hotspot/test/runtime/Unsafe/GetPutFloat.java
Normal file
64
hotspot/test/runtime/Unsafe/GetPutFloat.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
63
hotspot/test/runtime/Unsafe/GetPutInt.java
Normal file
63
hotspot/test/runtime/Unsafe/GetPutInt.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
64
hotspot/test/runtime/Unsafe/GetPutLong.java
Normal file
64
hotspot/test/runtime/Unsafe/GetPutLong.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
61
hotspot/test/runtime/Unsafe/GetPutObject.java
Normal file
61
hotspot/test/runtime/Unsafe/GetPutObject.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
64
hotspot/test/runtime/Unsafe/GetPutShort.java
Normal file
64
hotspot/test/runtime/Unsafe/GetPutShort.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
44
hotspot/test/runtime/Unsafe/GetUnsafe.java
Normal file
44
hotspot/test/runtime/Unsafe/GetUnsafe.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
48
hotspot/test/runtime/Unsafe/PageSize.java
Normal file
48
hotspot/test/runtime/Unsafe/PageSize.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
44
hotspot/test/runtime/Unsafe/SetMemory.java
Normal file
44
hotspot/test/runtime/Unsafe/SetMemory.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
49
hotspot/test/runtime/Unsafe/ThrowException.java
Normal file
49
hotspot/test/runtime/Unsafe/ThrowException.java
Normal file
@ -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 {}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user