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 / gist:95e95ca4855854c658ea7374c63dd456
Created April 16, 2025 23:02
Patched nmethod::purge to print JVMCI method names
void nmethod::purge(bool free_code_cache_data, bool unregister_nmethod) {
assert(!free_code_cache_data, "must only call not freeing code cache data");
MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag);
// completely deallocate this method
const char* name = method()->name()->as_C_string();
const char* is_jvmci = "";
const char* is_osr = is_osr_method() ? "osr" : "";
const size_t code_cache_free_space = CodeCache::unallocated_capacity(CodeCache::get_code_blob_type(this))/1024;
@JohnTortugo
JohnTortugo / setup.sh
Created April 16, 2025 04:57
Setup & Build OpenJDK on Ubuntu
#!/bin/bash
sudo apt install -y alsa-lib-devel cups-devel fontconfig-devel
sudo apt install -y libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel
sudo apt install -y autoconf git make
sudo apt groupinstall -y "Development Tools"
sudo mkdir /wf/
sudo chgrp -R ec2-user /wf/
sudo chown -R ec2-user /wf/
@JohnTortugo
JohnTortugo / gist:80b55c549dc2484537cf25d02e8478b6
Created April 9, 2025 04:05
Compile & Run Java Test using WhiteBox & TestLib
/wf/tortugo-master/build/linux-x86_64-server-fastdebug/jdk/bin/javac -cp build/linux-x86_64-server-fastdebug/support/test/lib/test-lib.jar:/wf/tortugo-master/build/linux-x86_64-server-fastdebug/support/test/lib/wb_classes/ TestMethodEvictionAndProfiling.java
/wf/tortugo-master/build/linux-x86_64-server-fastdebug/jdk/bin/java \
-Xbootclasspath/a:/wf/tortugo-master/build/linux-x86_64-server-fastdebug/support/test/lib/wb_classes/ \
-cp .:/wf/tortugo-master/build/linux-x86_64-server-fastdebug/support/test/lib/test-lib.jar \
-XX:+UnlockDiagnosticVMOptions \
-XX:+WhiteBoxAPI \
-Xbatch \
-XX:+SegmentedCodeCache \
-XX:+UseG1GC \
@JohnTortugo
JohnTortugo / gist:87d5df2db4a96a9bc2a2b25f4d7fdb58
Last active April 14, 2025 22:36
Setup to build OpenJDK on Amazon Linux2
#!/bin/bash
sudo yum install -y alsa-lib-devel cups-devel fontconfig-devel
sudo yum install -y libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel
sudo yum install -y autoconf git make
sudo yum groupinstall -y "Development Tools"
sudo mkdir /wf/
sudo chgrp -R ec2-user /wf/
sudo chown -R ec2-user /wf/
src/hotspot/cpu/aarch64/assembler_aarch64.hpp:186: unsigned &get_insn() { return insn; }
src/hotspot/cpu/aarch64/assembler_aarch64.hpp:3001: void sshll2(FloatRegister Vd, SIMD_Arrangement Ta, FloatRegister Vn, SIMD_Arrangement Tb, int shift) {
src/hotspot/cpu/aarch64/assembler_aarch64.hpp:3006: void sxtl(FloatRegister Vd, SIMD_Arrangement Ta, FloatRegister Vn, SIMD_Arrangement Tb) {
src/hotspot/cpu/aarch64/assembler_aarch64.hpp:3047: void uqxtn(FloatRegister Vd, SIMD_Arrangement Tb, FloatRegister Vn, SIMD_Arrangement Ta) {
src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp:230: inline void moviw(Register Rd, unsigned imm) { orrw(Rd, zr, imm); }
src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp:246: inline void bfxilw(Register Rd, Register Rn, unsigned lsb, unsigned width) {
src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp:253: inline void sbfizw(Register Rd, Register Rn, unsigned lsb, unsigned width) {
src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp:260: inline void sbfxw(Register Rd, Registe
@only 169 156 273 260 258 204 203 251 200 190 99 97 53 42 40 39 27
@only 158 207 202 44 39
0 Root === 0 113 125 136 147 173 271 272 [[ 0 1 3 23 24 25 47 186 185 181 161 142 87 108 115 120 131 275 ]]
1 Con === 0 [[ ]] #top
3 Start === 3 0 [[ 3 5 6 7 8 9 10 11 ]] #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address, 5:int, 6:int}
23 ConI === 0 [[ 190 27 27 143 157 132 121 121 101 183 190 143 143 132 132 121 ]] #int:0
24 ConP === 0 [[ 27 190 ]] #precise TestIncorrectRemat$MyClass: 0x00007ffff04f1578:Constant:exact * Klass:precise TestIncorrectRemat$MyClass: 0x00007ffff04f1578:Constant:exact *
25 ConL === 0 [[ 27 190 ]] #long:16
47 ConI === 0 [[ 251 90 ]] #int:42
@JohnTortugo
JohnTortugo / gist:5efef342fa2b5b712abeed461f9dbec8
Created July 20, 2023 00:33
Investigate RAM issue on Big-endians
diff --git a/src/hotspot/share/code/debugInfo.cpp b/src/hotspot/share/code/debugInfo.cpp
index 55d12448deb..404df71a4a6 100644
--- a/src/hotspot/share/code/debugInfo.cpp
+++ b/src/hotspot/share/code/debugInfo.cpp
@@ -243,7 +243,10 @@ void ObjectValue::print_fields_on(outputStream* st) const {
ObjectValue* ObjectMergeValue::select(frame& fr, RegisterMap& reg_map) {
StackValue* sv_selector = StackValue::create_stack_value(&fr, &reg_map, _selector);
jint selector = sv_selector->get_int();
-
+ tty->print_cr("_selector is location: %d",_selector->is_location());
@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