Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -1552,7 +1552,7 @@ void LIR_Assembler::emit_opNullFreeArrayCheck(LIR_OpNullFreeArrayCheck* op) {
__ br(Assembler::NE, test_mark_word);
__ load_prototype_header(tmp, op->array()->as_register());
__ bind(test_mark_word);
__ tst(tmp, markWord::null_free_array_bit_in_place);
__ tst(tmp, markWord::null_free_array_mask_in_place);
}

void LIR_Assembler::emit_opSubstitutabilityCheck(LIR_OpSubstitutabilityCheck* op) {
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2434,20 +2434,20 @@ void MacroAssembler::test_oop_prototype_bit(Register oop, Register temp_reg, int
}

void MacroAssembler::test_flat_array_oop(Register oop, Register temp_reg, Label& is_flat_array) {
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_bit_in_place, true, is_flat_array);
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_mask_in_place, true, is_flat_array);
}

void MacroAssembler::test_non_flat_array_oop(Register oop, Register temp_reg,
Label&is_non_flat_array) {
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_bit_in_place, false, is_non_flat_array);
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_mask_in_place, false, is_non_flat_array);
}

void MacroAssembler::test_null_free_array_oop(Register oop, Register temp_reg, Label& is_null_free_array) {
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_bit_in_place, true, is_null_free_array);
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_mask_in_place, true, is_null_free_array);
}

void MacroAssembler::test_non_null_free_array_oop(Register oop, Register temp_reg, Label&is_non_null_free_array) {
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_bit_in_place, false, is_non_null_free_array);
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_mask_in_place, false, is_non_null_free_array);
}

void MacroAssembler::test_flat_array_layout(Register lh, Label& is_flat_array) {
Expand Down Expand Up @@ -7988,7 +7988,7 @@ void MacroAssembler::fast_lock(Register basic_lock, Register obj, Register t1, R
assert(oopDesc::mark_offset_in_bytes() == 0, "required to avoid lea");
orr(mark, mark, markWord::unlocked_value);
// Mask inline_type bit such that we go to the slow path if object is an inline type
andr(mark, mark, ~((int) markWord::inline_type_bit_in_place));
andr(mark, mark, ~((int) markWord::inline_type_mask_in_place));

eor(t, mark, markWord::unlocked_value);
cmpxchg(/*addr*/ obj, /*expected*/ mark, /*new*/ t, Assembler::xword,
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2026, 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 @@ -1588,7 +1588,7 @@ void LIR_Assembler::emit_opNullFreeArrayCheck(LIR_OpNullFreeArrayCheck* op) {
__ jccb(Assembler::notZero, test_mark_word);
__ load_prototype_header(tmp, op->array()->as_register(), rscratch1);
__ bind(test_mark_word);
__ testl(tmp, markWord::null_free_array_bit_in_place);
__ testl(tmp, markWord::null_free_array_mask_in_place);
}

void LIR_Assembler::emit_opSubstitutabilityCheck(LIR_OpSubstitutabilityCheck* op) {
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2438,7 +2438,7 @@ void MacroAssembler::test_oop_prototype_bit(Register oop, Register temp_reg, int
void MacroAssembler::test_flat_array_oop(Register oop, Register temp_reg,
Label& is_flat_array) {
#ifdef _LP64
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_bit_in_place, true, is_flat_array);
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_mask_in_place, true, is_flat_array);
#else
load_klass(temp_reg, oop, noreg);
movl(temp_reg, Address(temp_reg, Klass::layout_helper_offset()));
Expand All @@ -2449,7 +2449,7 @@ void MacroAssembler::test_flat_array_oop(Register oop, Register temp_reg,
void MacroAssembler::test_non_flat_array_oop(Register oop, Register temp_reg,
Label& is_non_flat_array) {
#ifdef _LP64
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_bit_in_place, false, is_non_flat_array);
test_oop_prototype_bit(oop, temp_reg, markWord::flat_array_mask_in_place, false, is_non_flat_array);
#else
load_klass(temp_reg, oop, noreg);
movl(temp_reg, Address(temp_reg, Klass::layout_helper_offset()));
Expand All @@ -2459,15 +2459,15 @@ void MacroAssembler::test_non_flat_array_oop(Register oop, Register temp_reg,

void MacroAssembler::test_null_free_array_oop(Register oop, Register temp_reg, Label&is_null_free_array) {
#ifdef _LP64
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_bit_in_place, true, is_null_free_array);
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_mask_in_place, true, is_null_free_array);
#else
Unimplemented();
#endif
}

void MacroAssembler::test_non_null_free_array_oop(Register oop, Register temp_reg, Label&is_non_null_free_array) {
#ifdef _LP64
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_bit_in_place, false, is_non_null_free_array);
test_oop_prototype_bit(oop, temp_reg, markWord::null_free_array_mask_in_place, false, is_non_null_free_array);
#else
Unimplemented();
#endif
Expand Down Expand Up @@ -10716,7 +10716,7 @@ void MacroAssembler::fast_lock(Register basic_lock, Register obj, Register reg_r
andptr(tmp, ~(int32_t)markWord::unlocked_value);
orptr(reg_rax, markWord::unlocked_value);
// Mask inline_type bit such that we go to the slow path if object is an inline type
andptr(reg_rax, ~((int) markWord::inline_type_bit_in_place));
andptr(reg_rax, ~((int) markWord::inline_type_mask_in_place));

lock(); cmpxchgptr(tmp, Address(obj, oopDesc::mark_offset_in_bytes()));
jcc(Assembler::notEqual, slow);
Expand Down
57 changes: 30 additions & 27 deletions src/hotspot/share/oops/markWord.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, 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 @@ -117,7 +117,7 @@ class markWord {
// Conversion
uintptr_t value() const { return _value; }

// Constants, in least significant bit order
// Bit field widths, in least significant bit order
static const int lock_bits = 2;
static const int self_fwd_bits = 1;
// instance state
Expand All @@ -130,6 +130,7 @@ class markWord {
static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - inline_type_bits - larval_bits - flat_array_bits - null_free_array_bits - self_fwd_bits;
static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;

// Bit field shifts, in least significant bit order
static const int lock_shift = 0;
static const int self_fwd_shift = lock_shift + lock_bits;
static const int age_shift = self_fwd_shift + self_fwd_bits;
Expand All @@ -139,28 +140,30 @@ class markWord {
static const int larval_shift = flat_array_shift + flat_array_bits;
static const int hash_shift = larval_shift + larval_bits;

// Bit field masks
static const uintptr_t lock_mask = right_n_bits(lock_bits);
static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
static const uintptr_t self_fwd_mask = right_n_bits(self_fwd_bits);
static const uintptr_t self_fwd_mask_in_place = self_fwd_mask << self_fwd_shift;
static const uintptr_t inline_type_bit_in_place = right_n_bits(inline_type_bits) << inline_type_shift;
static const uintptr_t inline_type_mask_in_place = inline_type_bit_in_place + lock_mask;
static const uintptr_t null_free_array_mask = right_n_bits(null_free_array_bits);
static const uintptr_t null_free_array_mask_in_place = (null_free_array_mask << null_free_array_shift) | lock_mask_in_place;
static const uintptr_t null_free_array_bit_in_place = (right_n_bits(null_free_array_bits) << null_free_array_shift);
static const uintptr_t flat_array_mask = right_n_bits(flat_array_bits);
static const uintptr_t flat_array_mask_in_place = (flat_array_mask << flat_array_shift) | null_free_array_mask_in_place | lock_mask_in_place;
static const uintptr_t flat_array_bit_in_place = right_n_bits(flat_array_bits) << flat_array_shift;
static const uintptr_t age_mask = right_n_bits(age_bits);
static const uintptr_t age_mask_in_place = age_mask << age_shift;

static const uintptr_t inline_type_mask = right_n_bits(inline_type_bits);
static const uintptr_t inline_type_mask_in_place = inline_type_mask << inline_type_shift;
static const uintptr_t null_free_array_mask = right_n_bits(null_free_array_bits);
static const uintptr_t null_free_array_mask_in_place = null_free_array_mask << null_free_array_shift;
static const uintptr_t flat_array_mask = right_n_bits(flat_array_bits);
static const uintptr_t flat_array_mask_in_place = flat_array_mask << flat_array_shift;
static const uintptr_t larval_mask = right_n_bits(larval_bits);
static const uintptr_t larval_mask_in_place = (larval_mask << larval_shift) | inline_type_mask_in_place;
static const uintptr_t larval_bit_in_place = right_n_bits(larval_bits) << larval_shift;

static const uintptr_t larval_mask_in_place = larval_mask << larval_shift;
static const uintptr_t hash_mask = right_n_bits(hash_bits);
static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;

// Derived masks
static const uintptr_t inline_type_pattern_mask = inline_type_mask_in_place | lock_mask_in_place;
static const uintptr_t null_free_array_pattern_mask = null_free_array_mask_in_place | lock_mask_in_place;
static const uintptr_t flat_array_pattern_mask = flat_array_mask_in_place | null_free_array_pattern_mask;
static const uintptr_t larval_pattern_mask = larval_mask_in_place | inline_type_pattern_mask;

#ifdef _LP64
// Used only with compact headers:
// We store the (narrow) Klass* in the bits 43 to 64.
Expand All @@ -180,12 +183,12 @@ class markWord {
static const uintptr_t monitor_value = 2;
static const uintptr_t marked_value = 3;

static const uintptr_t inline_type_pattern = inline_type_bit_in_place | unlocked_value;
static const uintptr_t null_free_array_pattern = null_free_array_bit_in_place | unlocked_value;
static const uintptr_t null_free_flat_array_pattern = flat_array_bit_in_place | null_free_array_pattern;
static const uintptr_t nullable_flat_array_pattern = flat_array_bit_in_place | unlocked_value;
static const uintptr_t inline_type_pattern = inline_type_mask_in_place | unlocked_value;
static const uintptr_t null_free_array_pattern = null_free_array_mask_in_place | unlocked_value;
static const uintptr_t null_free_flat_array_pattern = flat_array_mask_in_place | null_free_array_pattern;
static const uintptr_t nullable_flat_array_pattern = flat_array_mask_in_place | unlocked_value;

static const uintptr_t larval_pattern = larval_bit_in_place | inline_type_pattern;
static const uintptr_t larval_pattern = larval_mask_in_place | inline_type_pattern;

static const uintptr_t no_hash = 0 ; // no hash value assigned
static const uintptr_t no_hash_in_place = (uintptr_t)no_hash << hash_shift;
Expand All @@ -197,7 +200,7 @@ class markWord {
static markWord zero() { return markWord(uintptr_t(0)); }

bool is_inline_type() const {
return (mask_bits(value(), inline_type_mask_in_place) == inline_type_pattern);
return (mask_bits(value(), inline_type_pattern_mask) == inline_type_pattern);
}

// lock accessors (note that these assume lock_shift == 0)
Expand All @@ -214,7 +217,7 @@ class markWord {
// is unlocked and not an inline type (which cannot be involved in locking, displacement or inflation)
// i.e. test both lock bits and the inline type bit together
bool is_neutral() const { // Not locked, or marked - a "clean" neutral state
return (mask_bits(value(), inline_type_mask_in_place) == unlocked_value);
return (mask_bits(value(), inline_type_pattern_mask) == unlocked_value);
}

bool is_forwarded() const {
Expand Down Expand Up @@ -293,27 +296,27 @@ class markWord {

// private buffered value operations
markWord enter_larval_state() const {
return markWord(value() | larval_bit_in_place);
return markWord(value() | larval_mask_in_place);
}
markWord exit_larval_state() const {
return markWord(value() & ~larval_bit_in_place);
return markWord(value() & ~larval_mask_in_place);
}
bool is_larval_state() const {
return (mask_bits(value(), larval_mask_in_place) == larval_pattern);
return (mask_bits(value(), larval_pattern_mask) == larval_pattern);
}

bool is_flat_array() const {
#ifdef _LP64 // 64 bit encodings only
return (mask_bits(value(), flat_array_mask_in_place) == null_free_flat_array_pattern)
|| (mask_bits(value(), flat_array_mask_in_place) == nullable_flat_array_pattern);
return (mask_bits(value(), flat_array_pattern_mask) == null_free_flat_array_pattern)
|| (mask_bits(value(), flat_array_pattern_mask) == nullable_flat_array_pattern);
#else
return false;
#endif
}

bool is_null_free_array() const {
#ifdef _LP64 // 64 bit encodings only
return (mask_bits(value(), null_free_array_mask_in_place) == null_free_array_pattern);
return (mask_bits(value(), null_free_array_pattern_mask) == null_free_array_pattern);
#else
return false;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/callnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ Node* AllocateNode::make_ideal_mark(PhaseGVN* phase, Node* control, Node* mem) {
if (Arguments::is_valhalla_enabled()) {
mark_node = phase->transform(mark_node);
// Avoid returning a constant (old node) here because this method is used by LoadNode::Ideal
mark_node = new OrXNode(mark_node, phase->MakeConX(_larval ? markWord::larval_bit_in_place : 0));
mark_node = new OrXNode(mark_node, phase->MakeConX(_larval ? markWord::larval_mask_in_place : 0));
}
return mark_node;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/graphKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3910,7 +3910,7 @@ Node* GraphKit::flat_array_test(Node* array_or_klass, bool flat) {
}

Node* GraphKit::null_free_array_test(Node* array, bool null_free) {
return mark_word_test(array, markWord::null_free_array_bit_in_place, null_free);
return mark_word_test(array, markWord::null_free_array_mask_in_place, null_free);
}

Node* GraphKit::null_free_atomic_array_test(Node* array, ciInlineKlass* vk) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,7 @@ void PhaseMacroExpand::expand_subtypecheck_node(SubTypeCheckNode *check) {
// // One array is locked, load prototype header from the klass
// mark = array1.klass.proto | array2.klass.proto | ...
// }
// if ((mark & markWord::flat_array_bit_in_place) == 0) {
// if ((mark & markWord::flat_array_mask_in_place) == 0) {
// ...
// }
void PhaseMacroExpand::expand_flatarraycheck_node(FlatArrayCheckNode* check) {
Expand Down Expand Up @@ -3013,7 +3013,7 @@ void PhaseMacroExpand::expand_flatarraycheck_node(FlatArrayCheckNode* check) {
mark_phi->init_req(2, proto);

// Check if flat array bits are set
Node* mask = MakeConX(markWord::flat_array_bit_in_place);
Node* mask = MakeConX(markWord::flat_array_mask_in_place);
Node* masked = _igvn.transform(new AndXNode(_igvn.transform(mark_phi), mask));
cmp = _igvn.transform(new CmpXNode(masked, MakeConX(0)));
Node* is_not_flat = _igvn.transform(new BoolNode(cmp, BoolTest::eq));
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/opto/macroArrayCopy.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2026, 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 @@ -328,11 +328,11 @@ Node* PhaseMacroExpand::mark_word_test(Node** ctrl, Node* obj, MergeMemNode* mem
}

Node* PhaseMacroExpand::generate_flat_array_guard(Node** ctrl, Node* array, MergeMemNode* mem, RegionNode* region) {
return mark_word_test(ctrl, array, mem, markWord::flat_array_bit_in_place, region);
return mark_word_test(ctrl, array, mem, markWord::flat_array_mask_in_place, region);
}

Node* PhaseMacroExpand::generate_null_free_array_guard(Node** ctrl, Node* array, MergeMemNode* mem, RegionNode* region) {
return mark_word_test(ctrl, array, mem, markWord::null_free_array_bit_in_place, region);
return mark_word_test(ctrl, array, mem, markWord::null_free_array_mask_in_place, region);
}

void PhaseMacroExpand::finish_arraycopy_call(Node* call, Node** ctrl, MergeMemNode** mem, const TypePtr* adr_type) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/mulnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,15 +895,15 @@ Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
set_req_X(1, phase->longcon(0), phase);
return this;
}
} else if (mask == markWord::null_free_array_bit_in_place) {
} else if (mask == markWord::null_free_array_mask_in_place) {
if (adr_t1->is_null_free()) {
set_req_X(1, in(2), phase);
return this;
} else if (adr_t1->is_not_null_free()) {
set_req_X(1, phase->longcon(0), phase);
return this;
}
} else if (mask == markWord::flat_array_bit_in_place) {
} else if (mask == markWord::flat_array_mask_in_place) {
if (adr_t1->is_flat()) {
set_req_X(1, in(2), phase);
return this;
Expand Down