Skip to content

Commit 40f847e

Browse files
committed
8227745: Enable Escape Analysis for Better Performance in the Presence of JVMTI Agents
8233915: JVMTI FollowReferences: Java Heap Leak not found because of C2 Scalar Replacement Reviewed-by: mdoerr, goetz, sspitsyn, kvn
1 parent f167a71 commit 40f847e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5744
-218
lines changed

src/hotspot/share/c1/c1_IR.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2020, 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
@@ -244,7 +244,11 @@ class IRScopeDebugInfo: public CompilationResourceObj {
244244
bool reexecute = topmost ? should_reexecute() : false;
245245
bool return_oop = false; // This flag will be ignored since it used only for C2 with escape analysis.
246246
bool rethrow_exception = false;
247-
recorder->describe_scope(pc_offset, methodHandle(), scope()->method(), bci(), reexecute, rethrow_exception, is_method_handle_invoke, return_oop, locvals, expvals, monvals);
247+
bool has_ea_local_in_scope = false;
248+
bool arg_escape = false;
249+
recorder->describe_scope(pc_offset, methodHandle(), scope()->method(), bci(),
250+
reexecute, rethrow_exception, is_method_handle_invoke, return_oop,
251+
has_ea_local_in_scope, arg_escape, locvals, expvals, monvals);
248252
}
249253
};
250254

src/hotspot/share/ci/ciEnv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ bool ciEnv::cache_jvmti_state() {
242242
_jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions();
243243
_jvmti_can_pop_frame = JvmtiExport::can_pop_frame();
244244
_jvmti_can_get_owned_monitor_info = JvmtiExport::can_get_owned_monitor_info();
245+
_jvmti_can_walk_any_space = JvmtiExport::can_walk_any_space();
245246
return _task != NULL && _task->method()->is_old();
246247
}
247248

@@ -271,6 +272,10 @@ bool ciEnv::jvmti_state_changed() const {
271272
JvmtiExport::can_get_owned_monitor_info()) {
272273
return true;
273274
}
275+
if (!_jvmti_can_walk_any_space &&
276+
JvmtiExport::can_walk_any_space()) {
277+
return true;
278+
}
274279

275280
return false;
276281
}

src/hotspot/share/ci/ciEnv.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ciEnv : StackObj {
7474
bool _jvmti_can_post_on_exceptions;
7575
bool _jvmti_can_pop_frame;
7676
bool _jvmti_can_get_owned_monitor_info; // includes can_get_owned_monitor_stack_depth_info
77+
bool _jvmti_can_walk_any_space;
7778

7879
// Cache DTrace flags
7980
bool _dtrace_extended_probes;
@@ -349,6 +350,7 @@ class ciEnv : StackObj {
349350
bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint; }
350351
bool jvmti_can_post_on_exceptions() const { return _jvmti_can_post_on_exceptions; }
351352
bool jvmti_can_get_owned_monitor_info() const { return _jvmti_can_get_owned_monitor_info; }
353+
bool jvmti_can_walk_any_space() const { return _jvmti_can_walk_any_space; }
352354

353355
// Cache DTrace flags
354356
void cache_dtrace_flags();

src/hotspot/share/code/compiledMethod.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2020, 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
@@ -293,17 +293,13 @@ void CompiledMethod::verify_oop_relocations() {
293293
ScopeDesc* CompiledMethod::scope_desc_at(address pc) {
294294
PcDesc* pd = pc_desc_at(pc);
295295
guarantee(pd != NULL, "scope must be present");
296-
return new ScopeDesc(this, pd->scope_decode_offset(),
297-
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
298-
pd->return_oop());
296+
return new ScopeDesc(this, pd);
299297
}
300298

301299
ScopeDesc* CompiledMethod::scope_desc_near(address pc) {
302300
PcDesc* pd = pc_desc_near(pc);
303301
guarantee(pd != NULL, "scope must be present");
304-
return new ScopeDesc(this, pd->scope_decode_offset(),
305-
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
306-
pd->return_oop());
302+
return new ScopeDesc(this, pd);
307303
}
308304

309305
address CompiledMethod::oops_reloc_begin() const {

src/hotspot/share/code/debugInfoRec.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ void DebugInformationRecorder::describe_scope(int pc_offset,
288288
bool rethrow_exception,
289289
bool is_method_handle_invoke,
290290
bool return_oop,
291+
bool has_ea_local_in_scope,
292+
bool arg_escape,
291293
DebugToken* locals,
292294
DebugToken* expressions,
293295
DebugToken* monitors) {
@@ -304,6 +306,8 @@ void DebugInformationRecorder::describe_scope(int pc_offset,
304306
last_pd->set_rethrow_exception(rethrow_exception);
305307
last_pd->set_is_method_handle_invoke(is_method_handle_invoke);
306308
last_pd->set_return_oop(return_oop);
309+
last_pd->set_has_ea_local_in_scope(has_ea_local_in_scope);
310+
last_pd->set_arg_escape(arg_escape);
307311

308312
// serialize sender stream offest
309313
stream()->write_int(sender_stream_offset);

src/hotspot/share/code/debugInfoRec.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2020, 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
@@ -105,6 +105,8 @@ class DebugInformationRecorder: public ResourceObj {
105105
bool rethrow_exception = false,
106106
bool is_method_handle_invoke = false,
107107
bool return_oop = false,
108+
bool has_ea_local_in_scope = false,
109+
bool arg_escape = false,
108110
DebugToken* locals = NULL,
109111
DebugToken* expressions = NULL,
110112
DebugToken* monitors = NULL);

src/hotspot/share/code/nmethod.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,9 +2419,7 @@ void nmethod::verify_interrupt_point(address call_site) {
24192419

24202420
PcDesc* pd = pc_desc_at(nativeCall_at(call_site)->return_address());
24212421
assert(pd != NULL, "PcDesc must exist");
2422-
for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
2423-
pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(),
2424-
pd->return_oop());
2422+
for (ScopeDesc* sd = new ScopeDesc(this, pd);
24252423
!sd->is_top(); sd = sd->sender()) {
24262424
sd->verify();
24272425
}
@@ -3056,9 +3054,7 @@ const char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
30563054
ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
30573055
PcDesc* p = pc_desc_near(begin+1);
30583056
if (p != NULL && p->real_pc(this) <= end) {
3059-
return new ScopeDesc(this, p->scope_decode_offset(),
3060-
p->obj_decode_offset(), p->should_reexecute(), p->rethrow_exception(),
3061-
p->return_oop());
3057+
return new ScopeDesc(this, p);
30623058
}
30633059
return NULL;
30643060
}

src/hotspot/share/code/pcDesc.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2020, 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
@@ -42,7 +42,9 @@ class PcDesc {
4242
PCDESC_reexecute = 1 << 0,
4343
PCDESC_is_method_handle_invoke = 1 << 1,
4444
PCDESC_return_oop = 1 << 2,
45-
PCDESC_rethrow_exception = 1 << 3
45+
PCDESC_rethrow_exception = 1 << 3,
46+
PCDESC_has_ea_local_in_scope = 1 << 4,
47+
PCDESC_arg_escape = 1 << 5
4648
};
4749

4850
int _flags;
@@ -89,6 +91,16 @@ class PcDesc {
8991
bool return_oop() const { return (_flags & PCDESC_return_oop) != 0; }
9092
void set_return_oop(bool z) { set_flag(PCDESC_return_oop, z); }
9193

94+
// Indicates if there are objects in scope that, based on escape analysis, are local to the
95+
// compiled method or local to the current thread, i.e. NoEscape or ArgEscape
96+
bool has_ea_local_in_scope() const { return (_flags & PCDESC_has_ea_local_in_scope) != 0; }
97+
void set_has_ea_local_in_scope(bool z) { set_flag(PCDESC_has_ea_local_in_scope, z); }
98+
99+
// Indicates if this pc descriptor is at a call site where objects that do not escape the
100+
// current thread are passed as arguments.
101+
bool arg_escape() const { return (_flags & PCDESC_arg_escape) != 0; }
102+
void set_arg_escape(bool z) { set_flag(PCDESC_arg_escape, z); }
103+
92104
// Returns the real pc
93105
address real_pc(const CompiledMethod* code) const;
94106

src/hotspot/share/code/scopeDesc.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,16 @@
3131
#include "oops/oop.inline.hpp"
3232
#include "runtime/handles.inline.hpp"
3333

34-
ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) {
34+
ScopeDesc::ScopeDesc(const CompiledMethod* code, PcDesc* pd, bool ignore_objects) {
35+
int obj_decode_offset = ignore_objects ? DebugInformationRecorder::serialized_null : pd->obj_decode_offset();
3536
_code = code;
36-
_decode_offset = decode_offset;
37+
_decode_offset = pd->scope_decode_offset();
3738
_objects = decode_object_values(obj_decode_offset);
38-
_reexecute = reexecute;
39-
_rethrow_exception = rethrow_exception;
40-
_return_oop = return_oop;
41-
decode_body();
42-
}
43-
44-
ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) {
45-
_code = code;
46-
_decode_offset = decode_offset;
47-
_objects = decode_object_values(DebugInformationRecorder::serialized_null);
48-
_reexecute = reexecute;
49-
_rethrow_exception = rethrow_exception;
50-
_return_oop = return_oop;
39+
_reexecute = pd->should_reexecute();
40+
_rethrow_exception = pd->rethrow_exception();
41+
_return_oop = pd->return_oop();
42+
_has_ea_local_in_scope = ignore_objects ? false : pd->has_ea_local_in_scope();
43+
_arg_escape = ignore_objects ? false : pd->arg_escape();
5144
decode_body();
5245
}
5346

@@ -59,6 +52,8 @@ void ScopeDesc::initialize(const ScopeDesc* parent, int decode_offset) {
5952
_reexecute = false; //reexecute only applies to the first scope
6053
_rethrow_exception = false;
6154
_return_oop = false;
55+
_has_ea_local_in_scope = parent->has_ea_local_in_scope();
56+
_arg_escape = false;
6257
decode_body();
6358
}
6459

src/hotspot/share/code/scopeDesc.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2020, 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
@@ -60,12 +60,7 @@ class SimpleScopeDesc : public StackObj {
6060
class ScopeDesc : public ResourceObj {
6161
public:
6262
// Constructor
63-
ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop);
64-
65-
// Calls above, giving default value of "serialized_null" to the
66-
// "obj_decode_offset" argument. (We don't use a default argument to
67-
// avoid a .hpp-.hpp dependency.)
68-
ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop);
63+
ScopeDesc(const CompiledMethod* code, PcDesc* pd, bool ignore_objects = false);
6964

7065
// Direct access to scope
7166
ScopeDesc* at_offset(int decode_offset) { return new ScopeDesc(this, decode_offset); }
@@ -76,6 +71,10 @@ class ScopeDesc : public ResourceObj {
7671
bool should_reexecute() const { return _reexecute; }
7772
bool rethrow_exception() const { return _rethrow_exception; }
7873
bool return_oop() const { return _return_oop; }
74+
// Returns true if one or more NoEscape or ArgEscape objects exist in
75+
// any of the scopes at compiled pc.
76+
bool has_ea_local_in_scope() const { return _has_ea_local_in_scope; }
77+
bool arg_escape() const { return _arg_escape; }
7978

8079
GrowableArray<ScopeValue*>* locals();
8180
GrowableArray<ScopeValue*>* expressions();
@@ -105,6 +104,9 @@ class ScopeDesc : public ResourceObj {
105104
bool _reexecute;
106105
bool _rethrow_exception;
107106
bool _return_oop;
107+
bool _has_ea_local_in_scope; // One or more NoEscape or ArgEscape objects exist in
108+
// any of the scopes at compiled pc.
109+
bool _arg_escape; // Compiled Java call in youngest scope passes ArgEscape
108110

109111
// Decoding offsets
110112
int _decode_offset;

0 commit comments

Comments
 (0)