Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
prsadhuk committed Feb 11, 2020
2 parents 0b3cf5e + a59e8a7 commit 5f44b6c
Show file tree
Hide file tree
Showing 115 changed files with 3,465 additions and 1,104 deletions.
1 change: 1 addition & 0 deletions .hgtags
Expand Up @@ -618,3 +618,4 @@ a96bc204e3b31ddbf909b20088964112f052927e jdk-14+34
c7d4f2849dbfb755fc5860b362a4044ea0c9e082 jdk-15+8
4a87bb7ebfd7f6a25ec59a5982fe3607242777f8 jdk-14+35
62b5bfef8d618e08e6f3a56cf1fb0e67e89e9cc2 jdk-15+9
bc54620a3848c26cff9766e5e2a6e5ddab98ed18 jdk-14+36
1 change: 1 addition & 0 deletions make/GenerateLinkOptData.gmk
Expand Up @@ -75,6 +75,7 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR)
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.raw \
-Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \
-Duser.language=en -Duser.country=US \
--module-path $(SUPPORT_OUTPUTDIR)/classlist.jar \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.HelloClasslist \
2> $(LINK_OPT_DIR)/stderr > $(JLI_TRACE_FILE) \
Expand Down
44 changes: 38 additions & 6 deletions make/jdk/src/classes/build/tools/classlist/HelloClasslist.java
Expand Up @@ -31,6 +31,9 @@
*/
package build.tools.classlist;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.net.InetAddress;
import java.nio.file.FileSystems;
import java.time.LocalDateTime;
Expand All @@ -55,19 +58,20 @@ public class HelloClasslist {

private static final Logger LOGGER = Logger.getLogger("Hello");

public static void main(String ... args) {
public static void main(String ... args) throws Throwable {

FileSystems.getDefault();

List<String> strings = Arrays.asList("Hello", "World!", "From: ",
InetAddress.getLoopbackAddress().toString());
InetAddress.getLoopbackAddress().toString());

String helloWorld = strings.parallelStream()
.map(s -> s.toLowerCase(Locale.ROOT))
.collect(joining(","));
.map(s -> s.toLowerCase(Locale.ROOT))
.collect(joining(","));

Stream.of(helloWorld.split(","))
.forEach(System.out::println);
Stream.of(helloWorld.split("([,x-z]{1,3})([\\s]*)"))
.map(String::toString)
.forEach(System.out::println);

// Common concatenation patterns
String SS = String.valueOf(args.length) + String.valueOf(args.length);
Expand All @@ -83,6 +87,10 @@ public static void main(String ... args) {
String SCSCS = String.valueOf(args.length) + "string" + String.valueOf(args.length) + "string" + String.valueOf(args.length);
String CI = "string" + args.length;
String IC = args.length + "string";
String SI = String.valueOf(args.length) + args.length;
String IS = args.length + String.valueOf(args.length);
String CIS = "string" + args.length + String.valueOf(args.length);
String CSCI = "string" + String.valueOf(args.length) + "string" + args.length;
String CIC = "string" + args.length + "string";
String CICI = "string" + args.length + "string" + args.length;
String CJ = "string" + System.currentTimeMillis();
Expand All @@ -99,7 +107,31 @@ public static void main(String ... args) {
DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.ROOT)
.format(new Date()));

// A selection of trivial and relatively common MH operations
invoke(MethodHandles.identity(double.class), 1.0);
invoke(MethodHandles.identity(int.class), 1);
invoke(MethodHandles.identity(String.class), "x");

invoke(handle("staticMethod_V", MethodType.methodType(void.class)));

LOGGER.log(Level.FINE, "New Date: " + newDate + " - old: " + oldDate);
}

public static void staticMethod_V() {}

private static MethodHandle handle(String name, MethodType type) throws Throwable {
return MethodHandles.lookup().findStatic(HelloClasslist.class, name, type);
}

private static Object invoke(MethodHandle mh, Object ... args) throws Throwable {
try {
for (Object o : args) {
mh = MethodHandles.insertArguments(mh, 0, o);
}
return mh.invoke();
} catch (Throwable t) {
LOGGER.warning("Failed to find, link and/or invoke " + mh.toString() + ": " + t.getMessage());
throw t;
}
}
}
13 changes: 8 additions & 5 deletions src/hotspot/cpu/x86/vm_version_x86.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
Expand Down Expand Up @@ -672,11 +672,14 @@ void VM_Version::get_processor_features() {
}
}
if (FLAG_IS_DEFAULT(UseAVX)) {
FLAG_SET_DEFAULT(UseAVX, use_avx_limit);
if (is_intel_family_core() && _model == CPU_MODEL_SKYLAKE && _stepping < 5) {
FLAG_SET_DEFAULT(UseAVX, 2); //Set UseAVX=2 for Skylake
// Don't use AVX-512 on older Skylakes unless explicitly requested.
if (use_avx_limit > 2 && is_intel_skylake() && _stepping < 5) {
FLAG_SET_DEFAULT(UseAVX, 2);
} else {
FLAG_SET_DEFAULT(UseAVX, use_avx_limit);
}
} else if (UseAVX > use_avx_limit) {
}
if (UseAVX > use_avx_limit) {
warning("UseAVX=%d is not supported on this CPU, setting it to UseAVX=%d", (int) UseAVX, use_avx_limit);
FLAG_SET_DEFAULT(UseAVX, use_avx_limit);
} else if (UseAVX < 0) {
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/cpu/x86/vm_version_x86.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
Expand Down Expand Up @@ -868,6 +868,9 @@ enum Extended_Family {
static bool is_intel_family_core() { return is_intel() &&
extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }

static bool is_intel_skylake() { return is_intel_family_core() &&
extended_cpu_model() == CPU_MODEL_SKYLAKE; }

static bool is_intel_tsc_synched_at_init() {
if (is_intel_family_core()) {
uint32_t ext_model = extended_cpu_model();
Expand Down
27 changes: 22 additions & 5 deletions src/hotspot/os/bsd/osThread_bsd.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
Expand Down Expand Up @@ -36,11 +36,12 @@ void OSThread::pd_initialize() {
#else
_thread_id = NULL;
#endif
_unique_thread_id = 0;
_pthread_id = NULL;
_siginfo = NULL;
_ucontext = NULL;
_expanding_stack = 0;
_alt_sig_stack = NULL;
_siginfo = NULL;
_ucontext = NULL;
_expanding_stack = 0;
_alt_sig_stack = NULL;

sigemptyset(&_caller_sigmask);

Expand All @@ -49,6 +50,22 @@ void OSThread::pd_initialize() {
assert(_startThread_lock !=NULL, "check");
}

// Additional thread_id used to correlate threads in SA
void OSThread::set_unique_thread_id() {
#ifdef __APPLE__
thread_identifier_info_data_t m_ident_info;
mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;

mach_port_t mach_thread_port = mach_thread_self();
guarantee(mach_thread_port != 0, "just checking");
thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO,
(thread_info_t) &m_ident_info, &count);
mach_port_deallocate(mach_task_self(), mach_thread_port);

_unique_thread_id = m_ident_info.thread_id;
#endif
}

void OSThread::pd_destroy() {
delete _startThread_lock;
}
6 changes: 2 additions & 4 deletions src/hotspot/os/bsd/osThread_bsd.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
Expand Down Expand Up @@ -82,9 +82,7 @@
_pthread_id = tid;
}

void set_unique_thread_id(uint64_t id) {
_unique_thread_id = id;
}
void set_unique_thread_id();

// ***************************************************************
// suspension support.
Expand Down
42 changes: 14 additions & 28 deletions src/hotspot/os/bsd/os_bsd.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
Expand Down Expand Up @@ -634,19 +634,6 @@ extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFu
objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL;
#endif

#ifdef __APPLE__
static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) {
// Additional thread_id used to correlate threads in SA
thread_identifier_info_data_t m_ident_info;
mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;

thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO,
(thread_info_t) &m_ident_info, &count);

return m_ident_info.thread_id;
}
#endif

// Thread start routine for all newly created threads
static void *thread_native_entry(Thread *thread) {

Expand All @@ -672,10 +659,10 @@ static void *thread_native_entry(Thread *thread) {
os::current_thread_id(), (uintx) pthread_self());

#ifdef __APPLE__
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id());
guarantee(unique_thread_id != 0, "unique thread id was not found");
osthread->set_unique_thread_id(unique_thread_id);
// Store unique OS X thread id used by SA
osthread->set_unique_thread_id();
#endif

// initialize signal mask for this thread
os::Bsd::hotspot_sigmask(thread);

Expand Down Expand Up @@ -823,12 +810,12 @@ bool os::create_attached_thread(JavaThread* thread) {

osthread->set_thread_id(os::Bsd::gettid());

// Store pthread info into the OSThread
#ifdef __APPLE__
uint64_t unique_thread_id = locate_unique_thread_id(osthread->thread_id());
guarantee(unique_thread_id != 0, "just checking");
osthread->set_unique_thread_id(unique_thread_id);
// Store unique OS X thread id used by SA
osthread->set_unique_thread_id();
#endif

// Store pthread info into the OSThread
osthread->set_pthread_id(::pthread_self());

// initialize floating point control register
Expand Down Expand Up @@ -1100,12 +1087,11 @@ void os::die() {
pid_t os::Bsd::gettid() {
int retval = -1;

#ifdef __APPLE__ //XNU kernel
// despite the fact mach port is actually not a thread id use it
// instead of syscall(SYS_thread_selfid) as it certainly fits to u4
retval = ::pthread_mach_thread_np(::pthread_self());
guarantee(retval != 0, "just checking");
return retval;
#ifdef __APPLE__ // XNU kernel
mach_port_t port = mach_thread_self();
guarantee(MACH_PORT_VALID(port), "just checking");
mach_port_deallocate(mach_task_self(), port);
return (pid_t)port;

#else
#ifdef __FreeBSD__
Expand All @@ -1128,7 +1114,7 @@ pid_t os::Bsd::gettid() {

intx os::current_thread_id() {
#ifdef __APPLE__
return (intx)::pthread_mach_thread_np(::pthread_self());
return (intx)os::Bsd::gettid();
#else
return (intx)::pthread_self();
#endif
Expand Down
36 changes: 21 additions & 15 deletions src/hotspot/share/ci/ciInstanceKlass.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
Expand Down Expand Up @@ -213,14 +213,19 @@ ciInstanceKlass* ciInstanceKlass::get_canonical_holder(int offset) {
}

ciInstanceKlass* self = this;
for (;;) {
assert(self->is_loaded(), "must be loaded to have size");
ciInstanceKlass* super = self->super();
if (super == NULL || super->nof_nonstatic_fields() == 0 ||
!super->contains_field_offset(offset)) {
return self;
} else {
self = super; // return super->get_canonical_holder(offset)
assert(self->is_loaded(), "must be loaded to access field info");
ciField* field = self->get_field_by_offset(offset, false);
if (field != NULL) {
return field->holder();
} else {
for (;;) {
assert(self->is_loaded(), "must be loaded to have size");
ciInstanceKlass* super = self->super();
if (super == NULL || super->nof_nonstatic_fields() == 0) {
return self;
} else {
self = super; // return super->get_canonical_holder(offset)
}
}
}
}
Expand Down Expand Up @@ -391,6 +396,13 @@ bool ciInstanceKlass::has_finalizable_subclass() {
return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
}

// ------------------------------------------------------------------
// ciInstanceKlass::contains_field_offset
bool ciInstanceKlass::contains_field_offset(int offset) {
VM_ENTRY_MARK;
return get_instanceKlass()->contains_field_offset(offset);
}

// ------------------------------------------------------------------
// ciInstanceKlass::get_field_by_offset
ciField* ciInstanceKlass::get_field_by_offset(int field_offset, bool is_static) {
Expand Down Expand Up @@ -457,15 +469,9 @@ int ciInstanceKlass::compute_nonstatic_fields() {
ciInstanceKlass* super = this->super();
GrowableArray<ciField*>* super_fields = NULL;
if (super != NULL && super->has_nonstatic_fields()) {
int super_fsize = super->nonstatic_field_size() * heapOopSize;
int super_flen = super->nof_nonstatic_fields();
super_fields = super->_nonstatic_fields;
assert(super_flen == 0 || super_fields != NULL, "first get nof_fields");
// See if I am no larger than my super; if so, I can use his fields.
if (fsize == super_fsize) {
_nonstatic_fields = super_fields;
return super_fields->length();
}
}

GrowableArray<ciField*>* fields = NULL;
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/ci/ciInstanceKlass.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
Expand Down Expand Up @@ -225,9 +225,7 @@ class ciInstanceKlass : public ciKlass {
ciInstanceKlass* unique_concrete_subklass();
bool has_finalizable_subclass();

bool contains_field_offset(int offset) {
return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
}
bool contains_field_offset(int offset);

// Get the instance of java.lang.Class corresponding to
// this klass. This instance is used for locking of
Expand Down

0 comments on commit 5f44b6c

Please sign in to comment.