Skip to content

Commit 918a3ae

Browse files
author
duke
committedApr 11, 2022
Automatic merge of jdk:master into master
2 parents 8236171 + 0c04bf8 commit 918a3ae

File tree

10 files changed

+29
-207
lines changed

10 files changed

+29
-207
lines changed
 

‎src/hotspot/share/ci/ciInstanceKlass.cpp

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
2828
#include "ci/ciInstanceKlass.hpp"
2929
#include "ci/ciUtilities.inline.hpp"
3030
#include "classfile/javaClasses.hpp"
31-
#include "classfile/systemDictionary.hpp"
3231
#include "classfile/vmClasses.hpp"
3332
#include "memory/allocation.hpp"
3433
#include "memory/allocation.inline.hpp"
@@ -281,31 +280,6 @@ bool ciInstanceKlass::is_boxed_value_offset(int offset) const {
281280
(offset == java_lang_boxing_object::value_offset(bt));
282281
}
283282

284-
static bool is_klass_initialized(Symbol* klass_name) {
285-
VM_ENTRY_MARK;
286-
InstanceKlass* ik = SystemDictionary::find_instance_klass(klass_name, Handle(), Handle());
287-
return ik != nullptr && ik->is_initialized();
288-
}
289-
290-
bool ciInstanceKlass::is_box_cache_valid() const {
291-
BasicType box_type = box_klass_type();
292-
293-
if (box_type != T_OBJECT) {
294-
switch(box_type) {
295-
case T_INT: return is_klass_initialized(java_lang_Integer_IntegerCache::symbol());
296-
case T_CHAR: return is_klass_initialized(java_lang_Character_CharacterCache::symbol());
297-
case T_SHORT: return is_klass_initialized(java_lang_Short_ShortCache::symbol());
298-
case T_BYTE: return is_klass_initialized(java_lang_Byte_ByteCache::symbol());
299-
case T_LONG: return is_klass_initialized(java_lang_Long_LongCache::symbol());
300-
case T_BOOLEAN:
301-
case T_FLOAT:
302-
case T_DOUBLE: return true;
303-
default:;
304-
}
305-
}
306-
return false;
307-
}
308-
309283
// ------------------------------------------------------------------
310284
// ciInstanceKlass::is_in_package
311285
//

‎src/hotspot/share/ci/ciInstanceKlass.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -265,7 +265,6 @@ class ciInstanceKlass : public ciKlass {
265265
BasicType box_klass_type() const;
266266
bool is_box_klass() const;
267267
bool is_boxed_value_offset(int offset) const;
268-
bool is_box_cache_valid() const;
269268

270269
// Is this klass in the given package?
271270
bool is_in_package(const char* packagename) {

‎src/hotspot/share/opto/callGenerator.cpp

+5-76
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -582,62 +582,6 @@ void LateInlineVirtualCallGenerator::do_late_inline() {
582582
CallGenerator::do_late_inline_helper();
583583
}
584584

585-
static bool has_non_debug_usages(Node* n) {
586-
for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
587-
Node* m = n->fast_out(i);
588-
if (!m->is_SafePoint()
589-
|| (m->is_Call() && m->as_Call()->has_non_debug_use(n))) {
590-
return true;
591-
}
592-
}
593-
return false;
594-
}
595-
596-
static bool is_box_cache_valid(CallNode* call) {
597-
ciInstanceKlass* klass = call->as_CallStaticJava()->method()->holder();
598-
return klass->is_box_cache_valid();
599-
}
600-
601-
// delay box in runtime, treat box as a scalarized object
602-
static void scalarize_debug_usages(CallNode* call, Node* resproj) {
603-
GraphKit kit(call->jvms());
604-
PhaseGVN& gvn = kit.gvn();
605-
606-
ProjNode* res = resproj->as_Proj();
607-
ciInstanceKlass* klass = call->as_CallStaticJava()->method()->holder();
608-
int n_fields = klass->nof_nonstatic_fields();
609-
assert(n_fields == 1, "the klass must be an auto-boxing klass");
610-
611-
for (DUIterator_Last imin, i = res->last_outs(imin); i >= imin;) {
612-
SafePointNode* sfpt = res->last_out(i)->as_SafePoint();
613-
uint first_ind = sfpt->req() - sfpt->jvms()->scloff();
614-
Node* sobj = new SafePointScalarObjectNode(gvn.type(res)->isa_oopptr(),
615-
#ifdef ASSERT
616-
call,
617-
#endif // ASSERT
618-
first_ind, n_fields, true);
619-
sobj->init_req(0, kit.root());
620-
sfpt->add_req(call->in(TypeFunc::Parms));
621-
sobj = gvn.transform(sobj);
622-
JVMState* jvms = sfpt->jvms();
623-
jvms->set_endoff(sfpt->req());
624-
int start = jvms->debug_start();
625-
int end = jvms->debug_end();
626-
int num_edges = sfpt->replace_edges_in_range(res, sobj, start, end, &gvn);
627-
i -= num_edges;
628-
}
629-
630-
assert(res->outcnt() == 0, "the box must have no use after replace");
631-
632-
#ifndef PRODUCT
633-
if (PrintEliminateAllocations) {
634-
tty->print("++++ Eliminated: %d ", call->_idx);
635-
call->as_CallStaticJava()->method()->print_short_name(tty);
636-
tty->cr();
637-
}
638-
#endif
639-
}
640-
641585
void CallGenerator::do_late_inline_helper() {
642586
assert(is_late_inline(), "only late inline allowed");
643587

@@ -687,24 +631,11 @@ void CallGenerator::do_late_inline_helper() {
687631
C->remove_macro_node(call);
688632
}
689633

690-
bool result_not_used = false;
691-
692-
if (is_pure_call()) {
693-
// Disabled due to JDK-8276112
694-
if (false && is_boxing_late_inline() && callprojs.resproj != nullptr) {
695-
// replace box node to scalar node only in case it is directly referenced by debug info
696-
assert(call->as_CallStaticJava()->is_boxing_method(), "sanity");
697-
if (!has_non_debug_usages(callprojs.resproj) && is_box_cache_valid(call)) {
698-
scalarize_debug_usages(call, callprojs.resproj);
699-
}
700-
}
634+
// The call is marked as pure (no important side effects), but result isn't used.
635+
// It's safe to remove the call.
636+
bool result_not_used = (callprojs.resproj == NULL || callprojs.resproj->outcnt() == 0);
701637

702-
// The call is marked as pure (no important side effects), but result isn't used.
703-
// It's safe to remove the call.
704-
result_not_used = (callprojs.resproj == NULL || callprojs.resproj->outcnt() == 0);
705-
}
706-
707-
if (result_not_used) {
638+
if (is_pure_call() && result_not_used) {
708639
GraphKit kit(call->jvms());
709640
kit.replace_call(call, C->top(), true);
710641
} else {
@@ -832,8 +763,6 @@ class LateInlineBoxingCallGenerator : public LateInlineCallGenerator {
832763
return new_jvms;
833764
}
834765

835-
virtual bool is_boxing_late_inline() const { return true; }
836-
837766
virtual CallGenerator* with_call_node(CallNode* call) {
838767
LateInlineBoxingCallGenerator* cg = new LateInlineBoxingCallGenerator(method(), _inline_cg);
839768
cg->set_call_node(call->as_CallStaticJava());

‎src/hotspot/share/opto/callGenerator.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,6 @@ class CallGenerator : public ResourceObj {
7474
virtual bool is_late_inline() const { return false; }
7575
// same but for method handle calls
7676
virtual bool is_mh_late_inline() const { return false; }
77-
virtual bool is_boxing_late_inline() const { return false; }
7877
virtual bool is_string_late_inline() const { return false; }
7978
virtual bool is_virtual_late_inline() const { return false; }
8079

‎src/hotspot/share/opto/callnode.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -1567,20 +1567,17 @@ SafePointScalarObjectNode::SafePointScalarObjectNode(const TypeOopPtr* tp,
15671567
Node* alloc,
15681568
#endif
15691569
uint first_index,
1570-
uint n_fields,
1571-
bool is_auto_box) :
1570+
uint n_fields) :
15721571
TypeNode(tp, 1), // 1 control input -- seems required. Get from root.
15731572
_first_index(first_index),
1574-
_n_fields(n_fields),
1575-
_is_auto_box(is_auto_box)
1573+
_n_fields(n_fields)
15761574
#ifdef ASSERT
15771575
, _alloc(alloc)
15781576
#endif
15791577
{
15801578
#ifdef ASSERT
15811579
if (!alloc->is_Allocate()
1582-
&& !(alloc->Opcode() == Op_VectorBox)
1583-
&& (!alloc->is_CallStaticJava() || !alloc->as_CallStaticJava()->is_boxing_method())) {
1580+
&& !(alloc->Opcode() == Op_VectorBox)) {
15841581
alloc->dump();
15851582
assert(false, "unexpected call node");
15861583
}

‎src/hotspot/share/opto/callnode.hpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -512,7 +512,6 @@ class SafePointScalarObjectNode: public TypeNode {
512512
// states of the scalarized object fields are collected.
513513
// It is relative to the last (youngest) jvms->_scloff.
514514
uint _n_fields; // Number of non-static fields of the scalarized object.
515-
bool _is_auto_box; // True if the scalarized object is an auto box.
516515
DEBUG_ONLY(Node* _alloc;)
517516

518517
virtual uint hash() const ; // { return NO_HASH; }
@@ -525,7 +524,7 @@ class SafePointScalarObjectNode: public TypeNode {
525524
#ifdef ASSERT
526525
Node* alloc,
527526
#endif
528-
uint first_index, uint n_fields, bool is_auto_box = false);
527+
uint first_index, uint n_fields);
529528
virtual int Opcode() const;
530529
virtual uint ideal_reg() const;
531530
virtual const RegMask &in_RegMask(uint) const;
@@ -538,7 +537,6 @@ class SafePointScalarObjectNode: public TypeNode {
538537
}
539538
uint n_fields() const { return _n_fields; }
540539

541-
bool is_auto_box() const { return _is_auto_box; }
542540
#ifdef ASSERT
543541
Node* alloc() const { return _alloc; }
544542
#endif

‎src/hotspot/share/opto/output.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,8 @@ void PhaseOutput::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local,
819819
ciKlass* cik = t->is_oopptr()->klass();
820820
assert(cik->is_instance_klass() ||
821821
cik->is_array_klass(), "Not supported allocation.");
822-
ScopeValue* klass_sv = new ConstantOopWriteValue(cik->java_mirror()->constant_encoding());
823-
sv = spobj->is_auto_box() ? new AutoBoxObjectValue(spobj->_idx, klass_sv)
824-
: new ObjectValue(spobj->_idx, klass_sv);
822+
sv = new ObjectValue(spobj->_idx,
823+
new ConstantOopWriteValue(cik->java_mirror()->constant_encoding()));
825824
set_sv_for_object_node(objs, sv);
826825

827826
uint first_ind = spobj->first_index(sfpt->jvms());
@@ -1093,9 +1092,8 @@ void PhaseOutput::Process_OopMap_Node(MachNode *mach, int current_offset) {
10931092
ciKlass* cik = t->is_oopptr()->klass();
10941093
assert(cik->is_instance_klass() ||
10951094
cik->is_array_klass(), "Not supported allocation.");
1096-
ScopeValue* klass_sv = new ConstantOopWriteValue(cik->java_mirror()->constant_encoding());
1097-
ObjectValue* sv = spobj->is_auto_box() ? new AutoBoxObjectValue(spobj->_idx, klass_sv)
1098-
: new ObjectValue(spobj->_idx, klass_sv);
1095+
ObjectValue* sv = new ObjectValue(spobj->_idx,
1096+
new ConstantOopWriteValue(cik->java_mirror()->constant_encoding()));
10991097
PhaseOutput::set_sv_for_object_node(objs, sv);
11001098

11011099
uint first_ind = spobj->first_index(youngest_jvms);

‎src/hotspot/share/runtime/deoptimization.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -926,7 +926,7 @@ void Deoptimization::deoptimize_all_marked(nmethod* nmethod_only) {
926926
Deoptimization::DeoptAction Deoptimization::_unloaded_action
927927
= Deoptimization::Action_reinterpret;
928928

929-
#if COMPILER2_OR_JVMCI
929+
#if INCLUDE_JVMCI
930930
template<typename CacheType>
931931
class BoxCacheBase : public CHeapObj<mtCompiler> {
932932
protected:
@@ -1054,7 +1054,9 @@ oop Deoptimization::get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMa
10541054
}
10551055
return NULL;
10561056
}
1057+
#endif // INCLUDE_JVMCI
10571058

1059+
#if COMPILER2_OR_JVMCI
10581060
bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, TRAPS) {
10591061
Handle pending_exception(THREAD, thread->pending_exception());
10601062
const char* exception_file = thread->exception_file();
@@ -1071,14 +1073,17 @@ bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap*
10711073
oop obj = NULL;
10721074

10731075
if (k->is_instance_klass()) {
1074-
if (sv->is_auto_box()) {
1076+
#if INCLUDE_JVMCI
1077+
CompiledMethod* cm = fr->cb()->as_compiled_method_or_null();
1078+
if (cm->is_compiled_by_jvmci() && sv->is_auto_box()) {
10751079
AutoBoxObjectValue* abv = (AutoBoxObjectValue*) sv;
10761080
obj = get_cached_box(abv, fr, reg_map, THREAD);
10771081
if (obj != NULL) {
10781082
// Set the flag to indicate the box came from a cache, so that we can skip the field reassignment for it.
10791083
abv->set_cached(true);
10801084
}
10811085
}
1086+
#endif // INCLUDE_JVMCI
10821087

10831088
InstanceKlass* ik = InstanceKlass::cast(k);
10841089
if (obj == NULL) {
@@ -1425,10 +1430,12 @@ void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableAr
14251430
continue;
14261431
}
14271432

1433+
#if INCLUDE_JVMCI
14281434
// Don't reassign fields of boxes that came from a cache. Caches may be in CDS.
14291435
if (sv->is_auto_box() && ((AutoBoxObjectValue*) sv)->is_cached()) {
14301436
continue;
14311437
}
1438+
#endif // INCLUDE_JVMCI
14321439
#ifdef COMPILER2
14331440
if (EnableVectorSupport && VectorSupport::is_vector(k)) {
14341441
assert(sv->field_size() == 1, "%s not a vector", k->name()->as_C_string());

‎src/hotspot/share/runtime/deoptimization.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -160,9 +160,8 @@ class Deoptimization : AllStatic {
160160

161161
#if INCLUDE_JVMCI
162162
static address deoptimize_for_missing_exception_handler(CompiledMethod* cm);
163-
#endif
164-
165163
static oop get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMap* reg_map, TRAPS);
164+
#endif
166165

167166
private:
168167
// Does the actual work for deoptimizing a single frame

‎test/hotspot/jtreg/compiler/eliminateAutobox/TestEliminateBoxInDebugInfo.java

-78
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.