Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Sep 10, 2024
2 parents d496ab5 + 64a79d8 commit 58103fe
Show file tree
Hide file tree
Showing 139 changed files with 3,007 additions and 2,481 deletions.
50 changes: 26 additions & 24 deletions make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, 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 @@ -364,33 +364,35 @@ int parseYear(String year, int defaultYear) {
}

Month parseMonth(String mon) {
switch (mon) {
case "Jan": return Month.JANUARY;
case "Feb": return Month.FEBRUARY;
case "Mar": return Month.MARCH;
case "Apr": return Month.APRIL;
case "May": return Month.MAY;
case "Jun": return Month.JUNE;
case "Jul": return Month.JULY;
case "Aug": return Month.AUGUST;
case "Sep": return Month.SEPTEMBER;
case "Oct": return Month.OCTOBER;
case "Nov": return Month.NOVEMBER;
case "Dec": return Month.DECEMBER;
}
int len = mon.length();

if (mon.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY;
if (mon.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY;
if (mon.regionMatches(true, 0, "March", 0, len)) return Month.MARCH;
if (mon.regionMatches(true, 0, "April", 0, len)) return Month.APRIL;
if (mon.regionMatches(true, 0, "May", 0, len)) return Month.MAY;
if (mon.regionMatches(true, 0, "June", 0, len)) return Month.JUNE;
if (mon.regionMatches(true, 0, "July", 0, len)) return Month.JULY;
if (mon.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST;
if (mon.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER;
if (mon.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER;
if (mon.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER;
if (mon.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER;

throw new IllegalArgumentException("Unknown month: " + mon);
}

DayOfWeek parseDayOfWeek(String dow) {
switch (dow) {
case "Mon": return DayOfWeek.MONDAY;
case "Tue": return DayOfWeek.TUESDAY;
case "Wed": return DayOfWeek.WEDNESDAY;
case "Thu": return DayOfWeek.THURSDAY;
case "Fri": return DayOfWeek.FRIDAY;
case "Sat": return DayOfWeek.SATURDAY;
case "Sun": return DayOfWeek.SUNDAY;
}
int len = dow.length();

if (dow.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY;
if (dow.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY;
if (dow.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY;
if (dow.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY;
if (dow.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY;
if (dow.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY;
if (dow.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY;

throw new IllegalArgumentException("Unknown day-of-week: " + dow);
}

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/classfile/classFileParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ class ClassFileParser {

bool is_hidden() const { return _is_hidden; }
bool is_interface() const { return _access_flags.is_interface(); }
bool is_abstract() const { return _access_flags.is_abstract(); }

ClassLoaderData* loader_data() const { return _loader_data; }
const Symbol* class_name() const { return _class_name; }
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/interpreter/bytecodeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ int ExceptionMessageBuilder::do_instruction(int bci) {
}
}

constantTag tag = cp->tag_at(cp_index);
constantTag tag = cp->constant_tag_at(cp_index);
if (tag.is_klass() || tag.is_unresolved_klass() ||
tag.is_method() || tag.is_interface_method() ||
tag.is_field() || tag.is_string()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, 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 @@ -30,7 +30,6 @@
#include "jfr/support/jfrThreadLocal.hpp"
#include "jfr/utilities/jfrEpochQueue.inline.hpp"
#include "jfr/utilities/jfrTypes.hpp"
#include "memory/metaspace.hpp"
#include "oops/compressedKlass.inline.hpp"
#include "utilities/macros.hpp"

Expand Down Expand Up @@ -75,13 +74,14 @@ static size_t element_size(bool compressed) {
return compressed ? NARROW_ELEMENT_SIZE : ELEMENT_SIZE;
}

static bool can_compress_element(traceid id) {
return Metaspace::using_class_space() && id < uncompressed_threshold;
static bool can_compress_element(const Klass* klass) {
return CompressedKlassPointers::is_in_encoding_range(klass) &&
JfrTraceId::load_raw(klass) < uncompressed_threshold;
}

static size_t element_size(const Klass* klass) {
assert(klass != nullptr, "invariant");
return element_size(can_compress_element(JfrTraceId::load_raw(klass)));
return element_size(can_compress_element(klass));
}

static bool is_unloaded(traceid id, bool previous_epoch) {
Expand Down Expand Up @@ -137,7 +137,8 @@ static inline void store_traceid(JfrEpochQueueNarrowKlassElement* element, trace
}

static void store_compressed_element(traceid id, const Klass* klass, u1* pos) {
assert(can_compress_element(id), "invariant");
assert(can_compress_element(klass), "invariant");
assert(id == JfrTraceId::load_raw(klass), "invariant");
JfrEpochQueueNarrowKlassElement* const element = new (pos) JfrEpochQueueNarrowKlassElement();
store_traceid(element, id);
element->compressed_klass = encode(klass);
Expand All @@ -153,7 +154,7 @@ static void store_element(const Klass* klass, u1* pos) {
assert(pos != nullptr, "invariant");
assert(klass != nullptr, "invariant");
const traceid id = JfrTraceId::load_raw(klass);
if (can_compress_element(id)) {
if (can_compress_element(klass)) {
store_compressed_element(id, klass, pos);
return;
}
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/share/memory/allocation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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 @@ -75,14 +75,16 @@ void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
size_t word_size,
MetaspaceObj::Type type, TRAPS) throw() {
// Klass has its own operator new
return Metaspace::allocate(loader_data, word_size, type, THREAD);
assert(type != ClassType, "class has its own operator new");
return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false, THREAD);
}

void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
size_t word_size,
MetaspaceObj::Type type) throw() {
assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread");
return Metaspace::allocate(loader_data, word_size, type);
assert(type != ClassType, "class has its own operator new");
return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false);
}

bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/memory/metaspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ size_t Metaspace::max_allocation_word_size() {
// is suitable for calling from non-Java threads.
// Callers are responsible for checking null.
MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type) {
MetaspaceObj::Type type, bool use_class_space) {
assert(word_size <= Metaspace::max_allocation_word_size(),
"allocation size too large (" SIZE_FORMAT ")", word_size);

Expand All @@ -840,7 +840,7 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
// Deal with concurrent unloading failed allocation starvation
MetaspaceCriticalAllocation::block_if_concurrent_purge();

MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
MetadataType mdtype = use_class_space ? ClassType : NonClassType;

// Try to allocate metadata.
MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
Expand All @@ -856,18 +856,18 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
}

MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type, TRAPS) {
MetaspaceObj::Type type, bool use_class_space, TRAPS) {

if (HAS_PENDING_EXCEPTION) {
assert(false, "Should not allocate with exception pending");
return nullptr; // caller does a CHECK_NULL too
}
assert(!THREAD->owns_locks(), "allocating metaspace while holding mutex");

MetaWord* result = allocate(loader_data, word_size, type);
MetaWord* result = allocate(loader_data, word_size, type, use_class_space);

if (result == nullptr) {
MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
MetadataType mdtype = use_class_space ? ClassType : NonClassType;
tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype);

// Allocation failed.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/memory/metaspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ class Metaspace : public AllStatic {
static size_t max_allocation_word_size();

static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type, TRAPS);
MetaspaceObj::Type type, bool use_class_space, TRAPS);

// Non-TRAPS version of allocate which can be called by a non-Java thread, that returns
// null on failure.
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceObj::Type type);
MetaspaceObj::Type type, bool use_class_space);

// Returns true if the pointer points into class space, non-class metaspace, or the
// metadata portion of the CDS archive.
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/oops/annotations.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, 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 @@ -89,7 +89,6 @@ class Annotations: public MetaspaceObj {
// Turn metadata annotations into a Java heap object (oop)
static typeArrayOop make_java_array(AnnotationArray* annotations, TRAPS);

bool is_klass() const { return false; }
void metaspace_pointers_do(MetaspaceClosure* it);
MetaspaceObj::Type type() const { return AnnotationsType; }

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/array.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, 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 @@ -34,7 +34,7 @@ template <typename T>
inline void* Array<T>::operator new(size_t size, ClassLoaderData* loader_data, int length, TRAPS) throw() {
size_t word_size = Array::size(length);
return (void*) Metaspace::allocate(loader_data, word_size,
MetaspaceObj::array_type(sizeof(T)), THREAD);
MetaspaceObj::array_type(sizeof(T)), false, THREAD);
}

#endif // SHARE_OOPS_ARRAY_INLINE_HPP
4 changes: 4 additions & 0 deletions src/hotspot/share/oops/arrayKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"

void* ArrayKlass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, true, THREAD);
}

ArrayKlass::ArrayKlass() {
assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for CDS");
}
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/oops/arrayKlass.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, 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 @@ -49,6 +49,8 @@ class ArrayKlass: public Klass {
ArrayKlass(Symbol* name, KlassKind kind);
ArrayKlass();

void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();

public:
// Testing operation
DEBUG_ONLY(bool is_array_klass_slow() const { return true; })
Expand Down
14 changes: 13 additions & 1 deletion src/hotspot/share/oops/compressedKlass.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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 @@ -107,6 +107,18 @@ class CompressedKlassPointers : public AllStatic {

static inline narrowKlass encode_not_null(Klass* v);
static inline narrowKlass encode(Klass* v);

// Returns whether the pointer is in the memory region used for encoding compressed
// class pointers. This includes CDS.

// encoding encoding
// base end (base+range)
// |-----------------------------------------------------------------------|
// |----CDS---| |--------------------class space---------------------------|

static inline bool is_in_encoding_range(const void* p) {
return p >= _base && p < (_base + _range);
}
};

#endif // SHARE_OOPS_COMPRESSEDKLASS_HPP
3 changes: 1 addition & 2 deletions src/hotspot/share/oops/constMethod.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2024, 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 @@ -470,7 +470,6 @@ class ConstMethod : public MetaspaceObj {

// Deallocation for RedefineClasses
void deallocate_contents(ClassLoaderData* loader_data);
bool is_klass() const { return false; }
DEBUG_ONLY(bool on_stack() { return false; })

void metaspace_pointers_do(MetaspaceClosure* it);
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/oops/cpCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ class ConstantPoolCache: public MetaspaceObj {
// RedefineClasses support
DEBUG_ONLY(bool on_stack() { return false; })
void deallocate_contents(ClassLoaderData* data);
bool is_klass() const { return false; }
void record_gc_epoch();
uint64_t gc_epoch() { return _gc_epoch; }

Expand Down
16 changes: 11 additions & 5 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ const char* InstanceKlass::nest_host_error() {
}
}

void* InstanceKlass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size,
bool use_class_space, TRAPS) throw() {
return Metaspace::allocate(loader_data, word_size, ClassType, use_class_space, THREAD);
}

InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) {
const int size = InstanceKlass::size(parser.vtable_size(),
parser.itable_size(),
Expand All @@ -449,23 +454,24 @@ InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& par
assert(loader_data != nullptr, "invariant");

InstanceKlass* ik;
const bool use_class_space = !parser.is_interface() && !parser.is_abstract();

// Allocation
if (parser.is_instance_ref_klass()) {
// java.lang.ref.Reference
ik = new (loader_data, size, THREAD) InstanceRefKlass(parser);
ik = new (loader_data, size, use_class_space, THREAD) InstanceRefKlass(parser);
} else if (class_name == vmSymbols::java_lang_Class()) {
// mirror - java.lang.Class
ik = new (loader_data, size, THREAD) InstanceMirrorKlass(parser);
ik = new (loader_data, size, use_class_space, THREAD) InstanceMirrorKlass(parser);
} else if (is_stack_chunk_class(class_name, loader_data)) {
// stack chunk
ik = new (loader_data, size, THREAD) InstanceStackChunkKlass(parser);
ik = new (loader_data, size, use_class_space, THREAD) InstanceStackChunkKlass(parser);
} else if (is_class_loader(class_name, parser)) {
// class loader - java.lang.ClassLoader
ik = new (loader_data, size, THREAD) InstanceClassLoaderKlass(parser);
ik = new (loader_data, size, use_class_space, THREAD) InstanceClassLoaderKlass(parser);
} else {
// normal
ik = new (loader_data, size, THREAD) InstanceKlass(parser);
ik = new (loader_data, size, use_class_space, THREAD) InstanceKlass(parser);
}

// Check for pending exception before adding to the loader data and incrementing
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/oops/instanceKlass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef SHARE_OOPS_INSTANCEKLASS_HPP
#define SHARE_OOPS_INSTANCEKLASS_HPP

#include "memory/allocation.hpp"
#include "memory/referenceType.hpp"
#include "oops/annotations.hpp"
#include "oops/constMethod.hpp"
Expand Down Expand Up @@ -144,6 +145,8 @@ class InstanceKlass: public Klass {
protected:
InstanceKlass(const ClassFileParser& parser, KlassKind kind = Kind, ReferenceType reference_type = REF_NONE);

void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, bool use_class_space, TRAPS) throw();

public:
InstanceKlass();

Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/oops/klass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signatur
return nullptr;
}

void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
}

Klass::Klass() : _kind(UnknownKlassKind) {
assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
}
Expand Down
Loading

0 comments on commit 58103fe

Please sign in to comment.