Skip to content

Instantly share code, notes, and snippets.

View JohnTortugo's full-sized avatar
🎯
Focusing

Cesar Soares JohnTortugo

🎯
Focusing
View GitHub Profile
@JohnTortugo
JohnTortugo / debug.txt
Created June 5, 2023 19:26
Samples of PrintDebugInfo
Compiled method (c2) 504 48 TestObjectClone::test (37 bytes)
total in heap [0x00007f4ba915d110,0x00007f4ba915d568] = 1112
relocation [0x00007f4ba915d280,0x00007f4ba915d2a8] = 40
main code [0x00007f4ba915d2c0,0x00007f4ba915d3d0] = 272
stub code [0x00007f4ba915d3d0,0x00007f4ba915d3e8] = 24
oops [0x00007f4ba915d3e8,0x00007f4ba915d3f8] = 16
metadata [0x00007f4ba915d3f8,0x00007f4ba915d410] = 24
scopes data [0x00007f4ba915d410,0x00007f4ba915d4b0] = 160
scopes pcs [0x00007f4ba915d4b0,0x00007f4ba915d560] = 176
dependencies [0x00007f4ba915d560,0x00007f4ba915d568] = 8

HotSpot Escape Analysis and Scalar Replacement Status

Introduction

Escape Analysis (EA) is a compiler analysis to answer the following questions for a given object O, method M, and thread T.

  • Escapes(O, M): Does object O outlive the execution of method M? This may happen for instance if a reference to O is assigned to a global variable.
  • Escapes(O, T): Does object O escape the current execution thread? This may happen for instance if a reference to O is copied to another thread.

Answers to these questions enable a compiler to perform a few highly effective optimizations, for instance, Stack Allocation (SA), Lock Elision (LE), and Scalar Replacement of Aggregates (SRA). Note that,

/*
* Copyright (c) 2021, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or