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 Jan 2, 2024
2 parents 43ec8d5 + a5cf421 commit 221b69b
Show file tree
Hide file tree
Showing 19 changed files with 339 additions and 91 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/javaClasses.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 @@ -1343,7 +1343,7 @@ const char* java_lang_Class::as_external_name(oop java_class) {

Klass* java_lang_Class::array_klass_acquire(oop java_class) {
Klass* k = ((Klass*)java_class->metadata_field_acquire(_array_klass_offset));
assert(k == nullptr || k->is_klass() && k->is_array_klass(), "should be array klass");
assert(k == nullptr || (k->is_klass() && k->is_array_klass()), "should be array klass");
return k;
}

Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class PCMarkAndPushClosure: public OopClosure {
public:
PCMarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { }

template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
template <typename T> void do_oop_work(T* p) { _compaction_manager->mark_and_push(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
};

class PCIterateMarkAndPushClosure: public ClaimMetadataVisitingOopIterateClosure {
Expand All @@ -60,9 +60,9 @@ class PCIterateMarkAndPushClosure: public ClaimMetadataVisitingOopIterateClosure
ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_stw_fullgc_mark, rp),
_compaction_manager(cm) { }

template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
template <typename T> void do_oop_work(T* p) { _compaction_manager->mark_and_push(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
};

inline bool ParCompactionManager::steal(int queue_num, oop& t) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ class PCAdjustPointerClosure: public BasicOopIterateClosure {
public:
PCAdjustPointerClosure(ParCompactionManager* cm) : _cm(cm) {
}
template <typename T> void do_oop_nv(T* p) { PSParallelCompact::adjust_pointer(p, _cm); }
virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
template <typename T> void do_oop_work(T* p) { PSParallelCompact::adjust_pointer(p, _cm); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual void do_oop(narrowOop* p) { do_oop_work(p); }

virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
private:
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ class PSPushContentsClosure: public BasicOopIterateClosure {
public:
PSPushContentsClosure(PSPromotionManager* pm) : BasicOopIterateClosure(PSScavenge::reference_processor()), _pm(pm) {}

template <typename T> void do_oop_nv(T* p) {
template <typename T> void do_oop_work(T* p) {
if (PSScavenge::should_scavenge(p)) {
_pm->claim_or_forward_depth(p);
}
}

virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
virtual void do_oop(oop* p) { do_oop_work(p); }
virtual void do_oop(narrowOop* p) { do_oop_work(p); }
};

//
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/x/xHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void XHeap::mark_start() {
// Enter mark phase
XGlobalPhase = XPhaseMark;

// Reset marking information and mark roots
// Reset marking information
_mark.start();

// Update statistics
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/z/zGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ void ZGenerationYoung::mark_start() {
// Enter mark phase
set_phase(Phase::Mark);

// Reset marking information and mark roots
// Reset marking information
_mark.start();

// Flip remembered set bits
Expand Down Expand Up @@ -1213,7 +1213,7 @@ void ZGenerationOld::mark_start() {
// Enter mark phase
set_phase(Phase::Mark);

// Reset marking information and mark roots
// Reset marking information
_mark.start();

// Update statistics
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/interpreter/bytecodes.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 @@ -536,7 +536,7 @@ jchar Bytecodes::compute_flags(const char* format, jchar more_flags) {
}
guarantee(has_size == 0 || // no field yet
this_size == has_size || // same size
this_size < has_size && *fp == '\0', // last field can be short
(this_size < has_size && *fp == '\0'), // last field can be short
"mixed field sizes in format");
has_size = this_size;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/constantPool.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 @@ -539,7 +539,7 @@ class ConstantPool : public Metadata {
int offset = build_int_from_shorts(operands->at(n+0),
operands->at(n+1));
// The offset itself must point into the second part of the array.
assert(offset == 0 || offset >= second_part && offset <= operands->length(), "oob (3)");
assert(offset == 0 || (offset >= second_part && offset <= operands->length()), "oob (3)");
return offset;
}
static void operand_offset_at_put(Array<u2>* operands, int bsms_attribute_index, int offset) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/method.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 @@ -326,7 +326,7 @@ int Method::bci_from(address bcp) const {
}
// Do not have a ResourceMark here because AsyncGetCallTrace stack walking code
// may call this after interrupting a nested ResourceMark.
assert(is_native() && bcp == code_base() || contains(bcp) || VMError::is_error_reported(),
assert((is_native() && bcp == code_base()) || contains(bcp) || VMError::is_error_reported(),
"bcp doesn't belong to this method. bcp: " PTR_FORMAT, p2i(bcp));

return int(bcp - code_base());
Expand Down Expand Up @@ -360,7 +360,7 @@ address Method::bcp_from(int bci) const {
assert((is_native() && bci == 0) || (!is_native() && 0 <= bci && bci < code_size()),
"illegal bci: %d for %s method", bci, is_native() ? "native" : "non-native");
address bcp = code_base() + bci;
assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method");
assert((is_native() && bcp == code_base()) || contains(bcp), "bcp doesn't belong to this method");
return bcp;
}

Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/utilities/utf8.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 @@ -341,10 +341,10 @@ bool UTF8::is_legal_utf8(const unsigned char* buffer, int length,
// For an unsigned char v,
// (v | v - 1) is < 128 (highest bit 0) for 0 < v < 128;
// (v | v - 1) is >= 128 (highest bit 1) for v == 0 or v >= 128.
unsigned char res = b0 | b0 - 1 |
b1 | b1 - 1 |
b2 | b2 - 1 |
b3 | b3 - 1;
unsigned char res = b0 | (b0 - 1) |
b1 | (b1 - 1) |
b2 | (b2 - 1) |
b3 | (b3 - 1);
if (res >= 128) break;
i += 4;
}
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/util/IdentityHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void init(int initCapacity) {
}

/**
* Constructs a new identity hash map containing the keys-value mappings
* Constructs a new identity hash map containing the key-value mappings
* in the specified map.
*
* @param m the map whose mappings are to be placed into this map
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 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 @@ -189,45 +189,73 @@ public BootstrapMethodEntryImpl bootstrapMethodEntry(int index) {
return bsmEntries().get(index);
}

private static IllegalArgumentException outOfBoundsError(IndexOutOfBoundsException cause) {
return new IllegalArgumentException("Reading beyond classfile bounds", cause);
}

@Override
public int readU1(int p) {
return buffer[p] & 0xFF;
try {
return buffer[p] & 0xFF;
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
public int readU2(int p) {
int b1 = buffer[p] & 0xFF;
int b2 = buffer[p + 1] & 0xFF;
return (b1 << 8) + b2;
try {
int b1 = buffer[p] & 0xFF;
int b2 = buffer[p + 1] & 0xFF;
return (b1 << 8) + b2;
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
public int readS1(int p) {
return buffer[p];
try {
return buffer[p];
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
public int readS2(int p) {
int b1 = buffer[p];
int b2 = buffer[p + 1] & 0xFF;
return (b1 << 8) + b2;
try {
int b1 = buffer[p];
int b2 = buffer[p + 1] & 0xFF;
return (b1 << 8) + b2;
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
public int readInt(int p) {
int ch1 = buffer[p] & 0xFF;
int ch2 = buffer[p + 1] & 0xFF;
int ch3 = buffer[p + 2] & 0xFF;
int ch4 = buffer[p + 3] & 0xFF;
return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4;
try {
int ch1 = buffer[p] & 0xFF;
int ch2 = buffer[p + 1] & 0xFF;
int ch3 = buffer[p + 2] & 0xFF;
int ch4 = buffer[p + 3] & 0xFF;
return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4;
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
public long readLong(int p) {
return ((long) buffer[p + 0] << 56) + ((long) (buffer[p + 1] & 255) << 48) +
((long) (buffer[p + 2] & 255) << 40) + ((long) (buffer[p + 3] & 255) << 32) +
((long) (buffer[p + 4] & 255) << 24) + ((buffer[p + 5] & 255) << 16) + ((buffer[p + 6] & 255) << 8) +
(buffer[p + 7] & 255);
try {
return ((long) buffer[p + 0] << 56) + ((long) (buffer[p + 1] & 255) << 48) +
((long) (buffer[p + 2] & 255) << 40) + ((long) (buffer[p + 3] & 255) << 32) +
((long) (buffer[p + 4] & 255) << 24) + ((buffer[p + 5] & 255) << 16) + ((buffer[p + 6] & 255) << 8) +
(buffer[p + 7] & 255);
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
Expand All @@ -242,12 +270,20 @@ public double readDouble(int p) {

@Override
public byte[] readBytes(int p, int len) {
return Arrays.copyOfRange(buffer, p, p + len);
try {
return Arrays.copyOfRange(buffer, p, p + len);
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

@Override
public void copyBytesTo(BufWriter buf, int p, int len) {
buf.writeBytes(buffer, p, len);
try {
buf.writeBytes(buffer, p, len);
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}

BootstrapMethodsAttribute bootstrapMethodsAttribute() {
Expand Down Expand Up @@ -446,8 +482,12 @@ public boolean compare(BufWriter bufWriter,
int bufWriterOffset,
int classReaderOffset,
int length) {
return Arrays.equals(((BufWriterImpl) bufWriter).elems,
bufWriterOffset, bufWriterOffset + length,
buffer, classReaderOffset, classReaderOffset + length);
try {
return Arrays.equals(((BufWriterImpl) bufWriter).elems,
bufWriterOffset, bufWriterOffset + length,
buffer, classReaderOffset, classReaderOffset + length);
} catch (IndexOutOfBoundsException e) {
throw outOfBoundsError(e);
}
}
}
Loading

0 comments on commit 221b69b

Please sign in to comment.