1 Star 0 Fork 27

Alex Gao/openjdk-17

forked from src-openEuler/openjdk-17 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Add-JBooster-Lazy-AOT-module.patch 155.38 KB
一键复制 编辑 原始数据 按行查看 历史
Benshuai5D 提交于 2024-10-16 23:06 . IAXNDZ:update to 17.0.13
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161
---
make/autoconf/jvm-features.m4 | 2 +
make/data/hotspot-symbols/symbols-unix | 3 +-
make/modules/jdk.jbooster/Launcher.gmk | 25 ++-
src/hotspot/share/aot/aotCodeHeap.cpp | 27 ++--
src/hotspot/share/aot/aotCodeHeap.hpp | 6 +-
src/hotspot/share/aot/aotLoader.cpp | 22 ++-
src/hotspot/share/aot/aotLoader.hpp | 2 +-
src/hotspot/share/gc/parallel/psScavenge.cpp | 1 +
src/hotspot/share/include/jvm.h | 6 +
src/hotspot/share/interpreter/rewriter.cpp | 15 +-
src/hotspot/share/interpreter/rewriter.hpp | 6 +-
.../jbooster/client/clientDataManager.cpp | 16 +-
.../jbooster/client/clientDataManager.hpp | 6 +-
.../share/jbooster/jClientArguments.cpp | 4 +
.../share/jbooster/jClientArguments.hpp | 1 +
src/hotspot/share/jbooster/jClientVMFlags.hpp | 2 +
.../share/jbooster/jbooster_globals.hpp | 2 +-
src/hotspot/share/jbooster/lazyAot.cpp | 117 ++++++++------
src/hotspot/share/jbooster/lazyAot.hpp | 32 ++--
.../share/jbooster/net/serialization.cpp | 16 ++
.../jbooster/server/serverDataManager.cpp | 5 +-
.../jbooster/server/serverDataManager.hpp | 3 +
.../jbooster/server/serverMessageHandler.cpp | 8 +-
.../jbooster/server/serverMessageHandler.hpp | 1 +
src/hotspot/share/oops/compressedOops.cpp | 46 ++++--
src/hotspot/share/oops/instanceKlass.hpp | 2 +-
src/hotspot/share/oops/method.cpp | 9 +-
src/hotspot/share/oops/methodData.cpp | 2 +-
src/hotspot/share/prims/jvm.cpp | 11 +-
.../share/prims/jvmtiRedefineClasses.cpp | 2 +-
.../share/lib/security/default.policy | 35 +++++
.../tools/jaotc/binformat/elf/ElfSection.java | 34 +++-
.../src/jdk/tools/jaotc/AOTBackend.java | 13 +-
.../jdk/tools/jaotc/AOTCompilationTask.java | 4 +
.../src/jdk/tools/jaotc/AOTCompiledClass.java | 58 ++++++-
.../src/jdk/tools/jaotc/AOTCompiler.java | 147 +++++++++++++++++-
.../src/jdk/tools/jaotc/Collector.java | 18 ++-
.../src/jdk/tools/jaotc/CompilationSpec.java | 9 ++
.../jdk/tools/jaotc/CompiledMethodInfo.java | 13 ++
.../src/jdk/tools/jaotc/DataBuilder.java | 5 +-
.../jdk/tools/jaotc/DataPatchProcessor.java | 17 +-
.../src/jdk/tools/jaotc/Main.java | 118 ++++++++++++--
.../src/jdk/tools/jaotc/MetadataBuilder.java | 6 +
.../src/jdk/tools/jaotc/Options.java | 19 +++
...JBoosterHotSpotAOTInvokeDynamicPlugin.java | 46 ++++++
src/jdk.aot/share/classes/module-info.java | 4 +
.../sun/jvm/hotspot/oops/InstanceKlass.java | 9 +-
.../classes/jdk/vm/ci/aarch64/AArch64.java | 8 +
.../share/classes/jdk/vm/ci/amd64/AMD64.java | 8 +
.../DirectHotSpotObjectConstantImpl.java | 16 ++
.../ci/hotspot/HotSpotConstantPoolObject.java | 2 +-
.../vm/ci/hotspot/HotSpotJVMCIRuntime.java | 4 +-
.../vm/ci/hotspot/HotSpotProfilingInfo.java | 16 +-
.../HotSpotResolvedJavaMethodImpl.java | 31 +++-
.../share/classes/module-info.java | 4 +-
.../graalvm/compiler/code/DataSection.java | 13 +-
.../hotspot/aarch64/AArch64HotSpotMove.java | 8 +-
.../AArch64HotSpotStrategySwitchOp.java | 11 +-
.../hotspot/amd64/AMD64HotSpotMove.java | 7 +-
.../hotspot/test/CheckGraalIntrinsics.java | 1 -
.../hotspot/AOTGraalHotSpotVMConfig.java | 7 +-
.../meta/DefaultHotSpotLoweringProvider.java | 4 +-
.../graalvm/compiler/java/BytecodeParser.java | 4 +-
.../graalvm/compiler/nodes/InliningLog.java | 7 +-
.../common/inlining/walker/InliningData.java | 20 ++-
.../share/classes/jdk/jbooster/JBooster.java | 13 +-
.../share/classes/module-info.java | 3 +-
.../share/native/libjbooster/JBooster.c | 6 +
.../jtreg/compiler/aot/TestAotPrint.java | 63 ++++++++
.../compiler/aot/TestAotWithRetransform.java | 143 +++++++++++++++++
.../jdk/internal/jimage/JImageOpenTest.java | 2 +-
.../modules/etc/JdkQualifiedExportTest.java | 1 +
test/jdk/tools/launcher/HelpFlagsTest.java | 2 +-
test/jdk/tools/launcher/VersionCheck.java | 2 -
74 files changed, 1166 insertions(+), 195 deletions(-)
create mode 100644 src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/jbooster/JBoosterHotSpotAOTInvokeDynamicPlugin.java
create mode 100644 test/hotspot/jtreg/compiler/aot/TestAotPrint.java
create mode 100644 test/hotspot/jtreg/compiler/aot/TestAotWithRetransform.java
diff --git a/make/autoconf/jvm-features.m4 b/make/autoconf/jvm-features.m4
index 6e81c84d9..6f8341432 100644
--- a/make/autoconf/jvm-features.m4
+++ b/make/autoconf/jvm-features.m4
@@ -332,6 +332,8 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_JBOOSTER],
AC_MSG_CHECKING([if platform is supported by JBOOSTER])
if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
AC_MSG_RESULT([yes])
+ elif test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
+ AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
AVAILABLE=false
diff --git a/make/data/hotspot-symbols/symbols-unix b/make/data/hotspot-symbols/symbols-unix
index d731017ab..63e5a6946 100644
--- a/make/data/hotspot-symbols/symbols-unix
+++ b/make/data/hotspot-symbols/symbols-unix
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2016, 2023, 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
@@ -211,4 +211,5 @@ JVM_SetBootLoaderUnnamedModule
JVM_JBoosterInitVM
JVM_JBoosterHandleConnection
JVM_JBoosterPrintStoredClientData
+JVM_JBoosterGetMetaspaceMethodData
JVM_JBoosterStartupNativeCallback
diff --git a/make/modules/jdk.jbooster/Launcher.gmk b/make/modules/jdk.jbooster/Launcher.gmk
index 1b03ec55e..550ade0f4 100644
--- a/make/modules/jdk.jbooster/Launcher.gmk
+++ b/make/modules/jdk.jbooster/Launcher.gmk
@@ -26,9 +26,26 @@
include LauncherCommon.gmk
$(eval $(call SetupBuildLauncher, jbooster, \
- MAIN_CLASS := jdk.jbooster.Main, \
- JAVA_ARGS := \
- -XX:+UnlockExperimentalVMOptions \
- -XX:+AsJBooster \
+ MAIN_CLASS := jdk.jbooster.JBooster, \
+ EXTRA_JAVA_ARGS := -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ , \
+ JAVA_ARGS := -XX:+UnlockExperimentalVMOptions -XX:+UseAOT -XX:+AsJBooster \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=$(call CommaList, jdk.internal.vm.compiler jdk.aot) \
+ -XX:+CalculateClassFingerprint \
+ -Dgraal.UseExceptionProbability=false \
+ -Dgraal.RemoveNeverExecutedCode=false \
+ -Djvmci.Compiler=graal \
+ --add-modules ALL-DEFAULT \
, \
))
diff --git a/src/hotspot/share/aot/aotCodeHeap.cpp b/src/hotspot/share/aot/aotCodeHeap.cpp
index 153ef67bb..efe12ac74 100644
--- a/src/hotspot/share/aot/aotCodeHeap.cpp
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp
@@ -57,6 +57,7 @@
#include "utilities/sizes.hpp"
bool AOTLib::_narrow_oop_shift_initialized = false;
+bool AOTLib::_narrow_klass_shift_initialized = false;
int AOTLib::_narrow_oop_shift = 0;
int AOTLib::_narrow_klass_shift = 0;
@@ -197,15 +198,18 @@ void AOTLib::verify_config() {
if (UseCompressedOops && _valid) {
if (!_narrow_oop_shift_initialized) {
_narrow_oop_shift = _config->_narrowOopShift;
- if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
- _narrow_klass_shift = _config->_narrowKlassShift;
- }
_narrow_oop_shift_initialized = true;
} else {
verify_flag(_config->_narrowOopShift, _narrow_oop_shift, "aot_config->_narrowOopShift");
- if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
- verify_flag(_config->_narrowKlassShift, _narrow_klass_shift, "aot_config->_narrowKlassShift");
- }
+ }
+ }
+
+ if (UseCompressedClassPointers && _valid) {
+ if (!_narrow_klass_shift_initialized) {
+ _narrow_klass_shift = _config->_narrowKlassShift;
+ _narrow_klass_shift_initialized = true;
+ } else {
+ verify_flag(_config->_narrowKlassShift, _narrow_klass_shift, "aot_config->_narrowKlassShift");
}
}
}
@@ -618,7 +622,7 @@ void AOTCodeHeap::print_statistics() {
}
#endif
-Method* AOTCodeHeap::find_method(Klass* klass, TRAPS, const char* method_name) {
+Method* AOTCodeHeap::find_method(Klass* klass, Thread* THREAD, const char* method_name) {
int method_name_len = Bytes::get_Java_u2((address)method_name);
method_name += 2;
const char* signature_name = method_name + method_name_len;
@@ -656,11 +660,6 @@ Method* AOTCodeHeap::find_method(Klass* klass, TRAPS, const char* method_name) {
memcpy(&meta_name[klass_len + 1], method_name, method_name_len);
memcpy(&meta_name[klass_len + 1 + method_name_len], signature_name, signature_name_len);
meta_name[klass_len + 1 + method_name_len + signature_name_len] = '\0';
- Handle exception = Exceptions::new_exception(THREAD, vmSymbols::java_lang_NoSuchMethodError(), meta_name);
- java_lang_Throwable::print(exception(), tty);
- tty->cr();
- java_lang_Throwable::print_stack_trace(exception, tty);
- tty->cr();
fatal("Failed to find method '%s'", meta_name);
}
NOT_PRODUCT( aot_methods_found++; )
@@ -771,14 +770,14 @@ void AOTCodeHeap::sweep_method(AOTCompiledMethod *aot) {
}
-bool AOTCodeHeap::load_klass_data(InstanceKlass* ik, TRAPS) {
+bool AOTCodeHeap::load_klass_data(InstanceKlass* ik, Thread* THREAD) {
ResourceMark rm;
NOT_PRODUCT( klasses_seen++; )
// AOT does not support custom class loaders.
ClassLoaderData* cld = ik->class_loader_data();
- if (!cld->is_builtin_class_loader_data()) {
+ if (!cld->is_builtin_class_loader_data() JBOOSTER_ONLY(&& !UseJBooster)) {
log_trace(aot, class, load)("skip class %s for custom classloader %s (%p) tid=" INTPTR_FORMAT,
ik->internal_name(), cld->loader_name(), cld, p2i(THREAD));
return false;
diff --git a/src/hotspot/share/aot/aotCodeHeap.hpp b/src/hotspot/share/aot/aotCodeHeap.hpp
index 40c187ec7..357ce9fb7 100644
--- a/src/hotspot/share/aot/aotCodeHeap.hpp
+++ b/src/hotspot/share/aot/aotCodeHeap.hpp
@@ -112,6 +112,7 @@ typedef struct {
class AOTLib : public CHeapObj<mtCode> {
static bool _narrow_oop_shift_initialized;
+ static bool _narrow_klass_shift_initialized;
static int _narrow_oop_shift;
static int _narrow_klass_shift;
@@ -130,6 +131,7 @@ public:
static int narrow_oop_shift() { return _narrow_oop_shift; }
static int narrow_klass_shift() { return _narrow_klass_shift; }
static bool narrow_oop_shift_initialized() { return _narrow_oop_shift_initialized; }
+ static bool narrow_klass_shift_initialized() { return _narrow_klass_shift_initialized; }
bool is_valid() const {
return _valid;
@@ -235,7 +237,7 @@ public:
virtual void* next(void *p) const;
AOTKlassData* find_klass(InstanceKlass* ik);
- bool load_klass_data(InstanceKlass* ik, TRAPS);
+ bool load_klass_data(InstanceKlass* ik, Thread* THREAD);
Klass* get_klass_from_got(const char* klass_name, int klass_len, const Method* method);
bool is_dependent_method(Klass* dependee, AOTCompiledMethod* aot);
@@ -273,7 +275,7 @@ public:
return NULL;
}
- static Method* find_method(Klass* klass, TRAPS, const char* method_name);
+ static Method* find_method(Klass* klass, Thread* THREAD, const char* method_name);
void cleanup_inline_caches();
diff --git a/src/hotspot/share/aot/aotLoader.cpp b/src/hotspot/share/aot/aotLoader.cpp
index 4e12ee95a..f8e89e634 100644
--- a/src/hotspot/share/aot/aotLoader.cpp
+++ b/src/hotspot/share/aot/aotLoader.cpp
@@ -47,7 +47,7 @@ GrowableArray<AOTLib*>* AOTLoader::_libraries = new(ResourceObj::C_HEAP, mtCode)
// Iterate over all AOT Libraries
#define FOR_ALL_AOT_LIBRARIES(lib) for (GrowableArrayIterator<AOTLib*> lib = libraries()->begin(); lib != libraries()->end(); ++lib)
-void AOTLoader::load_for_klass(InstanceKlass* ik, TRAPS) {
+void AOTLoader::load_for_klass(InstanceKlass* ik, Thread* THREAD) {
if (ik->is_hidden()) {
// don't even bother
return;
@@ -155,6 +155,7 @@ void AOTLoader::initialize() {
if (AOTLibrary != NULL) {
const int len = (int)strlen(AOTLibrary);
char* cp = NEW_C_HEAP_ARRAY(char, len+1, mtCode);
+ char* cp_start = cp;
memcpy(cp, AOTLibrary, len);
cp[len] = '\0';
char* end = cp + len;
@@ -165,6 +166,7 @@ void AOTLoader::initialize() {
cp++;
load_library(name, true);
}
+ FREE_C_HEAP_ARRAY(char, cp_start);
}
// Load well-know AOT libraries from Java installation directory.
@@ -191,11 +193,11 @@ void AOTLoader::universe_init() {
FOR_ALL_AOT_LIBRARIES(lib) {
(*lib)->verify_flag((*lib)->config()->_narrowOopShift, oop_shift, "CompressedOops::shift");
}
- if (UseCompressedClassPointers) { // It is set only if UseCompressedOops is set
- int klass_shift = CompressedKlassPointers::shift();
- FOR_ALL_AOT_LIBRARIES(lib) {
- (*lib)->verify_flag((*lib)->config()->_narrowKlassShift, klass_shift, "CompressedKlassPointers::shift");
- }
+ }
+ if (UseCompressedClassPointers && AOTLib::narrow_klass_shift_initialized()) {
+ int klass_shift = CompressedKlassPointers::shift();
+ FOR_ALL_AOT_LIBRARIES(lib) {
+ (*lib)->verify_flag((*lib)->config()->_narrowKlassShift, klass_shift, "CompressedKlassPointers::shift");
}
}
// Create heaps for all valid libraries
@@ -239,11 +241,15 @@ void AOTLoader::set_narrow_oop_shift() {
void AOTLoader::set_narrow_klass_shift() {
// This method is called from Metaspace::set_narrow_klass_base_and_shift().
if (UseAOT && libraries_count() > 0 &&
- UseCompressedOops && AOTLib::narrow_oop_shift_initialized() &&
- UseCompressedClassPointers) {
+ UseCompressedClassPointers && AOTLib::narrow_klass_shift_initialized()) {
+#ifdef AARCH64
+ // the shift in aarch64 cannot be altered, just check it
+ guarantee(CompressedKlassPointers::shift() == AOTLib::narrow_klass_shift(), "sanity");
+#else
if (CompressedKlassPointers::shift() == 0) {
CompressedKlassPointers::set_shift(AOTLib::narrow_klass_shift());
}
+#endif
}
}
diff --git a/src/hotspot/share/aot/aotLoader.hpp b/src/hotspot/share/aot/aotLoader.hpp
index cf03ea087..6273c3fe3 100644
--- a/src/hotspot/share/aot/aotLoader.hpp
+++ b/src/hotspot/share/aot/aotLoader.hpp
@@ -59,7 +59,7 @@ public:
static void universe_init() NOT_AOT_RETURN;
static void set_narrow_oop_shift() NOT_AOT_RETURN;
static void set_narrow_klass_shift() NOT_AOT_RETURN;
- static void load_for_klass(InstanceKlass* ik, TRAPS) NOT_AOT_RETURN;
+ static void load_for_klass(InstanceKlass* ik, Thread* THREAD) NOT_AOT_RETURN;
static uint64_t get_saved_fingerprint(InstanceKlass* ik) NOT_AOT({ return 0; });
static void oops_do(OopClosure* f) NOT_AOT_RETURN;
static void metadata_do(MetadataClosure* f) NOT_AOT_RETURN;
diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp
index 98ec438ad..98ab42022 100644
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp
@@ -91,6 +91,7 @@ static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_i
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id);
+ PSScavengeRootsClosure roots_closure(pm);
PSPromoteRootsClosure roots_to_old_closure(pm);
switch (root_type) {
diff --git a/src/hotspot/share/include/jvm.h b/src/hotspot/share/include/jvm.h
index 49c932aec..0f6fba8ba 100644
--- a/src/hotspot/share/include/jvm.h
+++ b/src/hotspot/share/include/jvm.h
@@ -1119,6 +1119,12 @@ JVM_JBoosterHandleConnection(JNIEnv *env, jint connection_fd);
JNIEXPORT void JNICALL
JVM_JBoosterPrintStoredClientData(JNIEnv *env, jboolean print_all);
+/**
+ * Get metaspaceMethodData.
+ */
+JNIEXPORT long JNICALL
+JVM_JBoosterGetMetaspaceMethodData(JNIEnv *env, jint session_id, jlong metaspace_method);
+
/**
* Callback of startup signal.
*/
diff --git a/src/hotspot/share/interpreter/rewriter.cpp b/src/hotspot/share/interpreter/rewriter.cpp
index 080735ba4..3908e43bd 100644
--- a/src/hotspot/share/interpreter/rewriter.cpp
+++ b/src/hotspot/share/interpreter/rewriter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2023, 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
@@ -168,14 +168,14 @@ void Rewriter::rewrite_Object_init(const methodHandle& method, TRAPS) {
// Rewrite a classfile-order CP index into a native-order CPC index.
-void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse) {
+void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse, Method* current_method) {
address p = bcp + offset;
if (!reverse) {
int cp_index = Bytes::get_Java_u2(p);
int cache_index = cp_entry_to_cp_cache(cp_index);
Bytes::put_native_u2(p, cache_index);
if (!_method_handle_invokers.is_empty())
- maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse);
+ maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse, current_method);
} else {
int cache_index = Bytes::get_native_u2(p);
int pool_index = cp_cache_entry_pool_index(cache_index);
@@ -209,7 +209,7 @@ void Rewriter::rewrite_invokespecial(address bcp, int offset, bool reverse, bool
// Adjust the invocation bytecode for a signature-polymorphic method (MethodHandle.invoke, etc.)
-void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse) {
+void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse, Method* current_method) {
if (!reverse) {
if ((*opc) == (u1)Bytecodes::_invokevirtual ||
// allow invokespecial as an alias, although it would be very odd:
@@ -242,6 +242,11 @@ void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_i
// to transmit the call site's intended call type.
if (status > 0) {
(*opc) = (u1)Bytecodes::_invokehandle;
+#if INCLUDE_JBOOSTER
+ if (!_klass->is_hidden() && current_method != nullptr) {
+ current_method->set_rewrite_invokehandle(true);
+ }
+#endif // INCLUDE_JBOOSTER
}
}
} else {
@@ -472,7 +477,7 @@ void Rewriter::scan_method(Thread* thread, Method* method, bool reverse, bool* i
case Bytecodes::_invokestatic :
case Bytecodes::_invokeinterface:
case Bytecodes::_invokehandle : // if reverse=true
- rewrite_member_reference(bcp, prefix_length+1, reverse);
+ rewrite_member_reference(bcp, prefix_length+1, reverse, method);
break;
case Bytecodes::_invokedynamic:
rewrite_invokedynamic(bcp, prefix_length+1, reverse);
diff --git a/src/hotspot/share/interpreter/rewriter.hpp b/src/hotspot/share/interpreter/rewriter.hpp
index 928e15ac1..2de251ce2 100644
--- a/src/hotspot/share/interpreter/rewriter.hpp
+++ b/src/hotspot/share/interpreter/rewriter.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2023, 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
@@ -186,8 +186,8 @@ class Rewriter: public StackObj {
void make_constant_pool_cache(TRAPS);
void scan_method(Thread* thread, Method* m, bool reverse, bool* invokespecial_error);
void rewrite_Object_init(const methodHandle& m, TRAPS);
- void rewrite_member_reference(address bcp, int offset, bool reverse);
- void maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse);
+ void rewrite_member_reference(address bcp, int offset, bool reverse, Method* current_method = nullptr);
+ void maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse, Method* current_method = nullptr);
void rewrite_invokedynamic(address bcp, int offset, bool reverse);
void maybe_rewrite_ldc(address bcp, int offset, bool is_wide, bool reverse);
void rewrite_invokespecial(address bcp, int offset, bool reverse, bool* invokespecial_error);
diff --git a/src/hotspot/share/jbooster/client/clientDataManager.cpp b/src/hotspot/share/jbooster/client/clientDataManager.cpp
index 6326b6e8d..1e4c8f2b5 100644
--- a/src/hotspot/share/jbooster/client/clientDataManager.cpp
+++ b/src/hotspot/share/jbooster/client/clientDataManager.cpp
@@ -44,10 +44,12 @@ ClientDataManager::ClientDataManager() {
_allow_aot = false;
_allow_cds = false;
_allow_clr = false;
+ _allow_pgo = false;
_using_aot = false;
_using_cds = false;
_using_clr = false;
+ _using_pgo = false;
_cache_clr_path = nullptr;
_cache_cds_path = nullptr;
@@ -110,7 +112,8 @@ void ClientDataManager::init_const() {
_program_args->hash());
_cache_clr_path = JBoosterManager::calc_cache_path(_cache_dir_path, _program_str_id, "clr.log");
_cache_cds_path = JBoosterManager::calc_cache_path(_cache_dir_path, _program_str_id, "cds.jsa");
- _cache_aot_path = JBoosterManager::calc_cache_path(_cache_dir_path, _program_str_id, "aot.so");
+ const char* aot_path_suffix = _allow_pgo ? "aot-pgo.so" : "aot.so";
+ _cache_aot_path = JBoosterManager::calc_cache_path(_cache_dir_path, _program_str_id, aot_path_suffix);
}
void ClientDataManager::init_client_duty() {
@@ -142,11 +145,22 @@ jint ClientDataManager::init_cds_options() {
jint ClientDataManager::init_aot_options() {
if (!is_aot_allowed()) return JNI_OK;
+ if (FLAG_SET_CMDLINE(UseAOT, true) != JVMFlag::SUCCESS) {
+ return JNI_EINVAL;
+ }
+ if (is_aot_being_used()) {
+ if (FLAG_SET_CMDLINE(AOTLibrary, cache_aot_path()) != JVMFlag::SUCCESS) {
+ return JNI_EINVAL;
+ }
+ }
return JNI_OK;
}
jint ClientDataManager::init_pgo_options() {
if (!is_pgo_allowed()) return JNI_OK;
+ if (FLAG_SET_CMDLINE(TypeProfileWidth, 8) != JVMFlag::SUCCESS) {
+ return JNI_EINVAL;
+ }
return JNI_OK;
}
diff --git a/src/hotspot/share/jbooster/client/clientDataManager.hpp b/src/hotspot/share/jbooster/client/clientDataManager.hpp
index 0a778a07e..07be0dc2a 100644
--- a/src/hotspot/share/jbooster/client/clientDataManager.hpp
+++ b/src/hotspot/share/jbooster/client/clientDataManager.hpp
@@ -42,10 +42,12 @@ class ClientDataManager: public CHeapObj<mtJBooster> {
bool _allow_clr;
bool _allow_cds;
bool _allow_aot;
+ bool _allow_pgo;
bool _using_clr;
bool _using_cds;
bool _using_aot;
+ bool _using_pgo;
const char* _cache_clr_path;
const char* _cache_cds_path;
@@ -103,16 +105,18 @@ public:
bool is_clr_allowed() { return _allow_clr; }
bool is_cds_allowed() { return _allow_cds; }
bool is_aot_allowed() { return _allow_aot; }
+ bool is_pgo_allowed() { return _allow_pgo; }
bool is_clr_being_used() { return _using_clr; }
bool is_cds_being_used() { return _using_cds; }
bool is_aot_being_used() { return _using_aot; }
+ bool is_pgo_being_used() { return _using_pgo; }
// <cache_dir>/client/cache-<parogram_str_id>-clr.log
const char* cache_clr_path() { return _cache_clr_path; }
// <cache_dir>/client/cache-<parogram_str_id>-cds.jsa
const char* cache_cds_path() { return _cache_cds_path; }
- // <cache_dir>/client/cache-<parogram_str_id>-aot.so
+ // <cache_dir>/client/cache-<parogram_str_id>-aot[-pgo].so
const char* cache_aot_path() { return _cache_aot_path; }
uint32_t session_id() { return _session_id; }
diff --git a/src/hotspot/share/jbooster/jClientArguments.cpp b/src/hotspot/share/jbooster/jClientArguments.cpp
index 2c32b6482..1ae91674f 100644
--- a/src/hotspot/share/jbooster/jClientArguments.cpp
+++ b/src/hotspot/share/jbooster/jClientArguments.cpp
@@ -212,6 +212,7 @@ void JClientArguments::init_for_client() {
_jbooster_allow_clr = ClientDataManager::get().is_clr_allowed();
_jbooster_allow_cds = ClientDataManager::get().is_cds_allowed();
_jbooster_allow_aot = ClientDataManager::get().is_aot_allowed();
+ _jbooster_allow_pgo = ClientDataManager::get().is_pgo_allowed();
_related_flags = new JClientVMFlags(true);
_hash = calc_hash();
@@ -234,6 +235,7 @@ uint32_t JClientArguments::calc_hash() {
result = calc_new_hash(result, primitive_hash(_jbooster_allow_clr));
result = calc_new_hash(result, primitive_hash(_jbooster_allow_cds));
result = calc_new_hash(result, primitive_hash(_jbooster_allow_aot));
+ result = calc_new_hash(result, primitive_hash(_jbooster_allow_pgo));
result = calc_new_hash(result, _related_flags->hash(_jbooster_allow_clr, _jbooster_allow_cds, _jbooster_allow_aot));
return result;
@@ -309,6 +311,7 @@ int JClientArguments::serialize(MessageBuffer& buf) const {
JB_RETURN(buf.serialize_no_meta(_jbooster_allow_clr));
JB_RETURN(buf.serialize_no_meta(_jbooster_allow_cds));
JB_RETURN(buf.serialize_no_meta(_jbooster_allow_aot));
+ JB_RETURN(buf.serialize_no_meta(_jbooster_allow_pgo));
JB_RETURN(buf.serialize_with_meta(_related_flags));
JB_RETURN(buf.serialize_no_meta(_hash));
@@ -351,6 +354,7 @@ int JClientArguments::deserialize(MessageBuffer& buf) {
JB_RETURN(buf.deserialize_ref_no_meta(_jbooster_allow_clr));
JB_RETURN(buf.deserialize_ref_no_meta(_jbooster_allow_cds));
JB_RETURN(buf.deserialize_ref_no_meta(_jbooster_allow_aot));
+ JB_RETURN(buf.deserialize_ref_no_meta(_jbooster_allow_pgo));
_related_flags = new JClientVMFlags(false);
JB_RETURN(buf.deserialize_with_meta(_related_flags));
diff --git a/src/hotspot/share/jbooster/jClientArguments.hpp b/src/hotspot/share/jbooster/jClientArguments.hpp
index e3574db02..7a0db1738 100644
--- a/src/hotspot/share/jbooster/jClientArguments.hpp
+++ b/src/hotspot/share/jbooster/jClientArguments.hpp
@@ -67,6 +67,7 @@ private:
bool _jbooster_allow_clr;
bool _jbooster_allow_cds;
bool _jbooster_allow_aot;
+ bool _jbooster_allow_pgo;
JClientVMFlags* _related_flags;
// ========================= end =========================
diff --git a/src/hotspot/share/jbooster/jClientVMFlags.hpp b/src/hotspot/share/jbooster/jClientVMFlags.hpp
index 3cdbc59cf..71da58934 100644
--- a/src/hotspot/share/jbooster/jClientVMFlags.hpp
+++ b/src/hotspot/share/jbooster/jClientVMFlags.hpp
@@ -56,6 +56,8 @@
f(intx, MaxVectorSize ) \
f(bool, UseTLAB ) \
f(bool, UseG1GC ) \
+ f(bool, BytecodeVerificationLocal ) \
+ f(bool, BytecodeVerificationRemote ) \
#define JCLIENT_VM_FLAGS(f) \
JCLIENT_CDS_VM_FLAGS(f) \
diff --git a/src/hotspot/share/jbooster/jbooster_globals.hpp b/src/hotspot/share/jbooster/jbooster_globals.hpp
index 45aa00db5..e9ba39e2d 100644
--- a/src/hotspot/share/jbooster/jbooster_globals.hpp
+++ b/src/hotspot/share/jbooster/jbooster_globals.hpp
@@ -83,7 +83,7 @@
range(0, 4) \
\
product(ccstr, UseBoostPackages, "all", DIAGNOSTIC, \
- "\"all\" means \"aot+cds+clr\".") \
+ "\"all\" means \"aot+cds+clr+pgo\".") \
\
product(bool, JBoosterClientStrictMatch, false, DIAGNOSTIC, \
"Be strict when matching the client data.") \
diff --git a/src/hotspot/share/jbooster/lazyAot.cpp b/src/hotspot/share/jbooster/lazyAot.cpp
index ca79f1816..91c570328 100644
--- a/src/hotspot/share/jbooster/lazyAot.cpp
+++ b/src/hotspot/share/jbooster/lazyAot.cpp
@@ -31,7 +31,7 @@
#include "jbooster/lazyAot.hpp"
#include "jbooster/server/serverDataManager.hpp"
#include "jbooster/utilities/debugUtils.hpp"
-#include "jbooster/utilities/ptrHashSet.inline.hpp"
+#include "jbooster/utilities/scalarHashMap.inline.hpp"
#include "memory/resourceArea.inline.hpp"
#include "oops/instanceKlass.inline.hpp"
#include "oops/method.inline.hpp"
@@ -48,6 +48,22 @@ enum {
INITIALIZED_KLASSES
};
+ClassLoaderKeepAliveMark::~ClassLoaderKeepAliveMark() {
+ for (GrowableArrayIterator<OopHandle> iter = _handles.begin(); iter != _handles.end(); ++iter) {
+ (*iter).release(Universe::vm_global());
+ }
+}
+
+void ClassLoaderKeepAliveMark::add(ClassLoaderData* cld){
+ _handles.append(OopHandle(Universe::vm_global(), cld->holder_phantom()));
+}
+
+void ClassLoaderKeepAliveMark::add_all(GrowableArray<ClassLoaderData*>* clds){
+ for (GrowableArrayIterator<ClassLoaderData*> iter = clds->begin(); iter != clds->end(); ++iter) {
+ add(*iter);
+ }
+}
+
InstanceKlass* LazyAOT::get_klass_from_class_tag(const constantPoolHandle& cp,
int index,
Handle loader,
@@ -65,12 +81,14 @@ InstanceKlass* LazyAOT::get_klass_from_class_tag(const constantPoolHandle& cp,
Symbol* name = cp->symbol_at(name_index);
klass = SystemDictionary::resolve_or_fail(name, loader, Handle(), true, THREAD);
if (HAS_PENDING_EXCEPTION) {
- log_trace(jbooster, compilation)("Class in constant pool not found: "
- "class=\"%s\", loader=\"%s\", holder=\"%s\"",
- name->as_C_string(),
- ClassLoaderData::class_loader_data_or_null(loader())
- ->loader_name(),
- cp->pool_holder()->internal_name());
+ if (PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())) return nullptr;
+ LogTarget(Trace, jbooster, compilation) lt;
+ if (lt.is_enabled()) {
+ lt.print("Class in constant pool not found: class=\"%s\", loader=\"%s\", holder=\"%s\"",
+ name->as_C_string(),
+ ClassLoaderData::class_loader_data_or_null(loader())->loader_name(),
+ cp->pool_holder()->internal_name());
+ }
CLEAR_PENDING_EXCEPTION;
return nullptr;
}
@@ -107,13 +125,16 @@ void LazyAOT::get_klasses_from_name_and_type_tag(const constantPoolHandle& cp,
: SignatureStream::CachedOrNull;
Klass* klass = ss.as_klass(loader, Handle(), mode, THREAD);
if (HAS_PENDING_EXCEPTION) {
- ResourceMark rm;
- log_trace(jbooster, compilation)("Class in constant pool not found: "
- "method=\"%s\", loader=\"%s\", holder=\"%s\"",
- sym->as_C_string(),
- ClassLoaderData::class_loader_data_or_null(loader())
- ->loader_name(),
- cp->pool_holder()->internal_name());
+ if (PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())) return;
+ LogTarget(Trace, jbooster, compilation) lt;
+ if (lt.is_enabled()) {
+ ResourceMark rm;
+ lt.print("Class in constant pool not found: method=\"%s\", loader=\"%s\", holder=\"%s\"",
+ sym->as_C_string(),
+ ClassLoaderData::class_loader_data_or_null(loader())
+ ->loader_name(),
+ cp->pool_holder()->internal_name());
+ }
CLEAR_PENDING_EXCEPTION;
continue;
}
@@ -128,24 +149,24 @@ void LazyAOT::get_klasses_from_name_and_type_tag(const constantPoolHandle& cp,
}
void LazyAOT::collect_klasses_by_inheritance(GrowableArray<InstanceKlass*>* dst,
- PtrHashSet<InstanceKlass*>* vis,
+ ScalarHashSet<InstanceKlass*>* vis,
InstanceKlass* ik,
TRAPS) {
if (!vis->add(ik)) return;
InstanceKlass* super = ik->java_super();
if (super != nullptr) {
- collect_klasses_by_inheritance(dst, vis, super, THREAD);
+ collect_klasses_by_inheritance(dst, vis, super, CHECK);
}
Array<InstanceKlass*>* interfaces = ik->local_interfaces();
for (int i = 0; i < interfaces->length(); ++i) {
InstanceKlass* interface = interfaces->at(i);
- collect_klasses_by_inheritance(dst, vis, interface, THREAD);
+ collect_klasses_by_inheritance(dst, vis, interface, CHECK);
}
dst->append(ik);
}
void LazyAOT::collect_klasses_in_constant_pool(GrowableArray<InstanceKlass*>* dst,
- PtrHashSet<InstanceKlass*>* vis,
+ ScalarHashSet<InstanceKlass*>* vis,
InstanceKlass* ik,
int which_klasses,
TRAPS) {
@@ -154,31 +175,31 @@ void LazyAOT::collect_klasses_in_constant_pool(GrowableArray<InstanceKlass*>* ds
for (int i = 0; i < cp->length(); ++i) {
constantTag tag = cp->tag_at(i);
if (tag.is_unresolved_klass() || tag.is_klass()) {
- InstanceKlass* next = get_klass_from_class_tag(cp, i, class_loader, which_klasses, THREAD);
+ InstanceKlass* next = get_klass_from_class_tag(cp, i, class_loader, which_klasses, CHECK);
if (next != nullptr) { // next is null when it is not a InstanceKlass
- collect_klasses_by_inheritance(dst, vis, next, THREAD);
+ collect_klasses_by_inheritance(dst, vis, next, CHECK);
}
} else if (tag.is_name_and_type()) {
GrowableArray<InstanceKlass*> next_list;
- get_klasses_from_name_and_type_tag(cp, i, class_loader, next_list, which_klasses, THREAD);
+ get_klasses_from_name_and_type_tag(cp, i, class_loader, next_list, which_klasses, CHECK);
for (GrowableArrayIterator<InstanceKlass*> iter = next_list.begin();
iter != next_list.end();
++iter) {
- collect_klasses_by_inheritance(dst, vis, *iter, THREAD);
+ collect_klasses_by_inheritance(dst, vis, *iter, CHECK);
}
}
}
}
void LazyAOT::collect_klasses_in_constant_pool(GrowableArray<InstanceKlass*>* dst,
- PtrHashSet<InstanceKlass*>* vis,
+ ScalarHashSet<InstanceKlass*>* vis,
TRAPS) {
int last_len = 0;
for (int lvl = _compilation_related_klasses_layers; lvl > 0; --lvl) {
int len = dst->length();
for (int i = last_len; i < len; ++i) {
ThreadInVMfromNative tiv(THREAD);
- collect_klasses_in_constant_pool(dst, vis, dst->at(i), ALL_KLASSES, THREAD);
+ collect_klasses_in_constant_pool(dst, vis, dst->at(i), ALL_KLASSES, CHECK);
}
last_len = len;
}
@@ -186,10 +207,10 @@ void LazyAOT::collect_klasses_in_constant_pool(GrowableArray<InstanceKlass*>* ds
void LazyAOT::collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_ik,
GrowableArray<ArrayKlass*>* dst_ak,
- PtrHashSet<InstanceKlass*>* ik_vis,
+ ScalarHashSet<InstanceKlass*>* ik_vis,
TRAPS) {
int last_len = 0;
- PtrHashSet<ArrayKlass*> ak_vis;
+ ScalarHashSet<ArrayKlass*> ak_vis;
for (int lvl = _compilation_related_klasses_layers; lvl > 0; --lvl) {
int len = dst_ik->length();
for (int i = last_len; i < len; ++i) {
@@ -198,7 +219,7 @@ void LazyAOT::collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_
MethodData* method_data = methods->at(j)->method_data();
if (method_data != nullptr) {
collect_klasses_in_method_data(dst_ik, dst_ak, ik_vis, &ak_vis,
- method_data, ALL_KLASSES, THREAD);
+ method_data, ALL_KLASSES, CHECK);
}
}
}
@@ -208,8 +229,8 @@ void LazyAOT::collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_
void LazyAOT::collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_ik,
GrowableArray<ArrayKlass*>* dst_ak,
- PtrHashSet<InstanceKlass*>* ik_vis,
- PtrHashSet<ArrayKlass*>* ak_vis,
+ ScalarHashSet<InstanceKlass*>* ik_vis,
+ ScalarHashSet<ArrayKlass*>* ak_vis,
MethodData* method_data,
int which_klasses,
TRAPS) {
@@ -225,7 +246,7 @@ void LazyAOT::collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_
if (which_klasses == INITIALIZED_KLASSES && !(*iter)->is_initialized()) {
continue;
}
- collect_klasses_by_inheritance(dst_ik, ik_vis, *iter, THREAD);
+ collect_klasses_by_inheritance(dst_ik, ik_vis, *iter, CHECK);
}
for (GrowableArrayIterator<ArrayKlass*> iter = ak_array.begin();
iter != ak_array.end();
@@ -237,26 +258,25 @@ void LazyAOT::collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_
}
}
-bool LazyAOT::sort_klasses_by_inheritance(GrowableArray<InstanceKlass*>* dst_ik,
+void LazyAOT::sort_klasses_by_inheritance(GrowableArray<InstanceKlass*>* dst_ik,
GrowableArray<ArrayKlass*>* dst_ak,
GrowableArray<InstanceKlass*>* src,
bool reverse_scan_src,
TRAPS) {
- PtrHashSet<InstanceKlass*> visited;
+ ScalarHashSet<InstanceKlass*> visited;
if (reverse_scan_src) {
for (int i = src->length() - 1; i >= 0; --i) {
- collect_klasses_by_inheritance(dst_ik, &visited, src->at(i), THREAD);
+ collect_klasses_by_inheritance(dst_ik, &visited, src->at(i), CHECK);
}
} else {
for (GrowableArrayIterator<InstanceKlass*> iter = src->begin();
iter != src->end();
++iter) {
- collect_klasses_by_inheritance(dst_ik, &visited, *iter, THREAD);
+ collect_klasses_by_inheritance(dst_ik, &visited, *iter, CHECK);
}
}
- collect_klasses_in_constant_pool(dst_ik, &visited, THREAD);
- collect_klasses_in_method_data(dst_ik, dst_ak, &visited, THREAD);
- return true;
+ collect_klasses_in_constant_pool(dst_ik, &visited, CHECK);
+ collect_klasses_in_method_data(dst_ik, dst_ak, &visited, CHECK);
}
bool LazyAOT::can_be_compiled(const methodHandle& mh) {
@@ -280,17 +300,17 @@ bool LazyAOT::can_be_compiled(InstanceKlass* ik, bool check_cld) {
}
bool LazyAOT::can_be_compiled(ClassLoaderData* cld) {
- oop loader_oop = cld->class_loader();
+ Handle loader_h(JavaThread::current(), cld->class_loader());
// Skip the bootstrap loaders used by LambdaForm.
// Each LambdaForm has its own bootstrap class loader.
// @see ClassLoaderData::is_boot_class_loader_data()
if (cld->is_the_null_class_loader_data()) return true;
- if (loader_oop == nullptr) return false;
+ if (loader_h.is_null()) return false;
// Skip klasses like GeneratedMethodAccessor, GeneratedConstructorAccessor
// and GeneratedSerializationConstructorAccessor.
- if (loader_oop->is_a(vmClasses::reflect_DelegatingClassLoader_klass())) {
+ if (loader_h->is_a(vmClasses::reflect_DelegatingClassLoader_klass())) {
return false;
}
@@ -372,7 +392,7 @@ private:
BOOL_TO_STR(LazyAOT::can_be_compiled(cld)));
tty->print_cr(" -");
}
- if (LazyAOT::can_be_compiled(cld)) {
+ if (!cld->has_class_mirror_holder() && LazyAOT::can_be_compiled(cld)) {
if (_loaders != nullptr) _loaders->append(cld);
KlassGetAllInstanceKlassesClosure cl(_klasses, _methods_to_compile, _methods_not_compile);
cld->classes_do(&cl);
@@ -393,7 +413,8 @@ public:
void do_cld(ClassLoaderData* cld) override { for_each(cld); }
};
-void LazyAOT::collect_all_klasses_to_compile(GrowableArray<ClassLoaderData*>* all_loaders,
+void LazyAOT::collect_all_klasses_to_compile(ClassLoaderKeepAliveMark& clka,
+ GrowableArray<ClassLoaderData*>* all_loaders,
GrowableArray<InstanceKlass*>* klasses_to_compile,
GrowableArray<Method*>* methods_to_compile,
GrowableArray<Method*>* methods_not_compile,
@@ -406,11 +427,12 @@ void LazyAOT::collect_all_klasses_to_compile(GrowableArray<ClassLoaderData*>* al
CLDGetAllInstanceKlassesClosure cl(all_loaders, klasses_to_compile, methods_to_compile, methods_not_compile);
ThreadInVMfromNative tivm(THREAD);
MutexLocker ml(THREAD, ClassLoaderDataGraph_lock);
- ClassLoaderDataGraph::cld_do(&cl);
+ ClassLoaderDataGraph::loaded_cld_do(&cl);
+ clka.add_all(all_loaders);
}
TraceTime tt("Sort klasses", TRACETIME_LOG(Info, jbooster, aot));
sort_klasses_by_inheritance(all_sorted_klasses, array_klasses, klasses_to_compile,
- /* reverse_scan_src */ true, CATCH);
+ /* reverse_scan_src */ true, CHECK);
}
log_info(jbooster, compilation)("Klasses to send: %d", all_sorted_klasses->length());
log_info(jbooster, compilation)("Klasses to compile: %d", klasses_to_compile->length());
@@ -443,7 +465,6 @@ static Handle add_klasses_to_java_hash_set(GrowableArray<InstanceKlass*>* klasse
vmSymbols::object_boolean_signature(),
Handle(THREAD, (*iter)->java_mirror()),
CHECK_NH);
- guarantee((bool)result.get_jboolean() == true, "sanity");
}
return hash_set_h;
}
@@ -467,7 +488,6 @@ static Handle add_methods_names_to_java_hash_set(GrowableArray<Method*>* methods
vmSymbols::add_method_name(),
vmSymbols::object_boolean_signature(),
s_h, CHECK_NH);
- guarantee((bool)result.get_jboolean() == true, "sanity");
}
return hash_set_h;
}
@@ -475,6 +495,7 @@ static Handle add_methods_names_to_java_hash_set(GrowableArray<Method*>* methods
bool LazyAOT::compile_classes_by_graal(int session_id,
const char* file_path,
GrowableArray<InstanceKlass*>* klasses,
+ bool use_pgo,
TRAPS) {
DebugUtils::assert_thread_in_vm();
@@ -504,6 +525,7 @@ bool LazyAOT::compile_methods_by_graal(int session_id,
GrowableArray<InstanceKlass*>* klasses,
GrowableArray<Method*>* methods_to_compile,
GrowableArray<Method*>* methods_not_compile,
+ bool use_pgo,
TRAPS) {
DebugUtils::assert_thread_in_vm();
@@ -526,9 +548,10 @@ bool LazyAOT::compile_methods_by_graal(int session_id,
java_args.push_oop(klass_set_h);
java_args.push_oop(method_name_set_h);
java_args.push_oop(not_method_name_set_h);
+ java_args.push_int(use_pgo);
TempNewSymbol compile_methods_name = SymbolTable::new_symbol("compileMethods");
- TempNewSymbol compile_methods_signature = SymbolTable::new_symbol("(ILjava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;)Z");
+ TempNewSymbol compile_methods_signature = SymbolTable::new_symbol("(ILjava/lang/String;Ljava/util/Set;Ljava/util/Set;Ljava/util/Set;Z)Z");
JavaCalls::call_static(&result, ServerDataManager::get().main_klass(),
compile_methods_name,
compile_methods_signature,
diff --git a/src/hotspot/share/jbooster/lazyAot.hpp b/src/hotspot/share/jbooster/lazyAot.hpp
index f9adc6596..1d2a49351 100644
--- a/src/hotspot/share/jbooster/lazyAot.hpp
+++ b/src/hotspot/share/jbooster/lazyAot.hpp
@@ -24,7 +24,7 @@
#ifndef SHARE_JBOOSTER_LAZYAOT_HPP
#define SHARE_JBOOSTER_LAZYAOT_HPP
-#include "jbooster/utilities/ptrHashSet.hpp"
+#include "jbooster/utilities/scalarHashMap.hpp"
#include "memory/allocation.hpp"
#include "runtime/handles.hpp"
#include "runtime/thread.hpp"
@@ -36,6 +36,17 @@ template <class T> class GrowableArray;
class InstanceKlass;
class Method;
class MethodData;
+class OopHandle;
+
+class ClassLoaderKeepAliveMark: public StackObj {
+ GrowableArray<OopHandle> _handles;
+
+public:
+ ~ClassLoaderKeepAliveMark();
+
+ void add(ClassLoaderData* cld);
+ void add_all(GrowableArray<ClassLoaderData*>* clds);
+};
class LazyAOT: public AllStatic {
private:
@@ -55,29 +66,29 @@ private:
TRAPS);
static void collect_klasses_by_inheritance(GrowableArray<InstanceKlass*>* dst,
- PtrHashSet<InstanceKlass*>* vis,
+ ScalarHashSet<InstanceKlass*>* vis,
InstanceKlass* ik,
TRAPS);
static void collect_klasses_in_constant_pool(GrowableArray<InstanceKlass*>* dst,
- PtrHashSet<InstanceKlass*>* vis,
+ ScalarHashSet<InstanceKlass*>* vis,
InstanceKlass* ik,
int which_klasses,
TRAPS);
static void collect_klasses_in_constant_pool(GrowableArray<InstanceKlass*>* dst,
- PtrHashSet<InstanceKlass*>* vis,
+ ScalarHashSet<InstanceKlass*>* vis,
TRAPS);
static void collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_ik,
GrowableArray<ArrayKlass*>* dst_ak,
- PtrHashSet<InstanceKlass*>* ik_vis,
+ ScalarHashSet<InstanceKlass*>* ik_vis,
TRAPS);
static void collect_klasses_in_method_data(GrowableArray<InstanceKlass*>* dst_ik,
GrowableArray<ArrayKlass*>* dst_ak,
- PtrHashSet<InstanceKlass*>* ik_vis,
- PtrHashSet<ArrayKlass*>* ak_vis,
+ ScalarHashSet<InstanceKlass*>* ik_vis,
+ ScalarHashSet<ArrayKlass*>* ak_vis,
MethodData* method_data,
int which_klasses,
TRAPS);
- static bool sort_klasses_by_inheritance(GrowableArray<InstanceKlass*>* dst_ik,
+ static void sort_klasses_by_inheritance(GrowableArray<InstanceKlass*>* dst_ik,
GrowableArray<ArrayKlass*>* dst_ak,
GrowableArray<InstanceKlass*>* src,
bool reverse_scan_src,
@@ -88,7 +99,8 @@ public:
static bool can_be_compiled(InstanceKlass* ik, bool check_cld = true);
static bool can_be_compiled(ClassLoaderData* cld);
- static void collect_all_klasses_to_compile(GrowableArray<ClassLoaderData*>* all_loaders,
+ static void collect_all_klasses_to_compile(ClassLoaderKeepAliveMark& clka,
+ GrowableArray<ClassLoaderData*>* all_loaders,
GrowableArray<InstanceKlass*>* klasses_to_compile,
GrowableArray<Method*>* methods_to_compile,
GrowableArray<Method*>* methods_not_compile,
@@ -99,12 +111,14 @@ public:
static bool compile_classes_by_graal(int session_id,
const char* file_path,
GrowableArray<InstanceKlass*>* klasses,
+ bool use_pgo,
TRAPS);
static bool compile_methods_by_graal(int session_id,
const char* file_path,
GrowableArray<InstanceKlass*>* klasses,
GrowableArray<Method*>* methods_to_compile,
GrowableArray<Method*>* methods_not_compile,
+ bool use_pgo,
TRAPS);
};
diff --git a/src/hotspot/share/jbooster/net/serialization.cpp b/src/hotspot/share/jbooster/net/serialization.cpp
index b0db65e68..d95edd7df 100644
--- a/src/hotspot/share/jbooster/net/serialization.cpp
+++ b/src/hotspot/share/jbooster/net/serialization.cpp
@@ -136,6 +136,12 @@ int SerializationImpl<InstanceKlass>::serialize(MessageBuffer& buf, const Instan
}
MemoryWrapper mw((void*) cf_buf, cf_size);
JB_RETURN(buf.serialize_no_meta(mw));
+
+ if (should_send_class_file) {
+ // fingerprint of ClassFileStream
+ InstanceKlass* ik = const_cast<InstanceKlass*>(&arg);
+ JB_RETURN(buf.serialize_no_meta(ik->get_stored_fingerprint()));
+ }
}
return 0;
@@ -269,6 +275,16 @@ int SerializationImpl<InstanceKlass>::deserialize_ptr(MessageBuffer& buf, Instan
session_data->add_klass_address((address) client_klass, (address) res, THREAD);
arg_ptr = res;
}
+
+ if (!mw.is_null()) {
+ // fingerprint of ClassFileStream
+ uint64_t fingerprint;
+ JB_RETURN(buf.deserialize_ref_no_meta(fingerprint));
+ if (res != nullptr) {
+ // force to set the fingerprint that from client
+ res->store_fingerprint(fingerprint);
+ }
+ }
return 0;
}
diff --git a/src/hotspot/share/jbooster/server/serverDataManager.cpp b/src/hotspot/share/jbooster/server/serverDataManager.cpp
index b4a11dc5c..33d6faf4c 100644
--- a/src/hotspot/share/jbooster/server/serverDataManager.cpp
+++ b/src/hotspot/share/jbooster/server/serverDataManager.cpp
@@ -279,12 +279,15 @@ JClientProgramData::JClientProgramData(uint32_t program_id, JClientArguments* pr
bool allow_clr = _program_args->jbooster_allow_clr();
bool allow_cds = _program_args->jbooster_allow_cds();
bool allow_aot = _program_args->jbooster_allow_aot();
+ bool allow_pgo = _program_args->jbooster_allow_pgo();
const char* clr_path = JBoosterManager::calc_cache_path(sd, _program_str_id, "clr.log");
const char* cds_path = JBoosterManager::calc_cache_path(sd, _program_str_id, "cds.jsa");
- const char* aot_path = JBoosterManager::calc_cache_path(sd, _program_str_id, "aot.so");
+ const char* aot_path_suffix = allow_pgo ? "aot-pgo.so" : "aot.so";
+ const char* aot_path = JBoosterManager::calc_cache_path(sd, _program_str_id, aot_path_suffix);
clr_cache_state().init(allow_clr, clr_path);
cds_cache_state().init(allow_cds, cds_path);
aot_cache_state().init(allow_aot, aot_path);
+ _using_pgo = allow_pgo;
}
JClientProgramData::~JClientProgramData() {
diff --git a/src/hotspot/share/jbooster/server/serverDataManager.hpp b/src/hotspot/share/jbooster/server/serverDataManager.hpp
index 22b416cd9..9181acd10 100644
--- a/src/hotspot/share/jbooster/server/serverDataManager.hpp
+++ b/src/hotspot/share/jbooster/server/serverDataManager.hpp
@@ -191,6 +191,8 @@ private:
JClientCacheState _cds_cache_state;
JClientCacheState _aot_cache_state;
+ bool _using_pgo; // use pgo if or not, as boost level 4
+
NONCOPYABLE(JClientProgramData);
public:
@@ -211,6 +213,7 @@ public:
JClientCacheState& clr_cache_state() { return _clr_cache_state; }
JClientCacheState& cds_cache_state() { return _cds_cache_state; }
JClientCacheState& aot_cache_state() { return _aot_cache_state; }
+ bool using_pgo() { return _using_pgo; }
};
/**
diff --git a/src/hotspot/share/jbooster/server/serverMessageHandler.cpp b/src/hotspot/share/jbooster/server/serverMessageHandler.cpp
index 9e66b6d4c..a92d1c6a4 100644
--- a/src/hotspot/share/jbooster/server/serverMessageHandler.cpp
+++ b/src/hotspot/share/jbooster/server/serverMessageHandler.cpp
@@ -321,8 +321,10 @@ int ServerMessageHandler::handle_lazy_aot_compilation_task(TRAPS) {
JB_THROW(request_missing_class_loaders(THREAD));
JB_THROW(request_missing_klasses(THREAD));
JB_THROW(request_methods_to_compile(&klasses_to_compile, &methods_to_compile, THREAD));
- JB_THROW(request_methods_not_compile(&methods_not_compile, THREAD));
- JB_THROW(request_method_data(THREAD));
+ if (pd->using_pgo()) {
+ JB_THROW(request_methods_not_compile(&methods_not_compile, THREAD));
+ JB_THROW(request_method_data(THREAD));
+ }
JB_THROW(ss().send_request(MessageType::EndOfCurrentPhase));
}
} JB_TRY_END JB_CATCH_REST() {
@@ -336,6 +338,7 @@ int ServerMessageHandler::handle_lazy_aot_compilation_task(TRAPS) {
JB_RETURN(try_to_compile_lazy_aot(&klasses_to_compile,
&methods_to_compile,
&methods_not_compile,
+ pd->using_pgo(),
THREAD));
} else { // not compile in current thread
if (aot_cache_state.is_being_generated()) {
@@ -356,6 +359,7 @@ int ServerMessageHandler::handle_lazy_aot_compilation_task(TRAPS) {
int ServerMessageHandler::try_to_compile_lazy_aot(GrowableArray<InstanceKlass*>* klasses_to_compile,
GrowableArray<Method*>* methods_to_compile,
GrowableArray<Method*>* methods_not_compile,
+ bool use_pgo,
TRAPS) {
JClientProgramData* pd = ss().session_data()->program_data();
JClientCacheState& aot_cache_state = pd->aot_cache_state();
diff --git a/src/hotspot/share/jbooster/server/serverMessageHandler.hpp b/src/hotspot/share/jbooster/server/serverMessageHandler.hpp
index 6d510c6ca..26926dd41 100644
--- a/src/hotspot/share/jbooster/server/serverMessageHandler.hpp
+++ b/src/hotspot/share/jbooster/server/serverMessageHandler.hpp
@@ -59,6 +59,7 @@ private:
int try_to_compile_lazy_aot(GrowableArray<InstanceKlass*>* klasses_to_compile,
GrowableArray<Method*>* methods_to_compile,
GrowableArray<Method*>* methods_not_compile,
+ bool use_pgo,
TRAPS);
public:
ServerMessageHandler(ServerStream* server_stream);
diff --git a/src/hotspot/share/oops/compressedOops.cpp b/src/hotspot/share/oops/compressedOops.cpp
index 03dbf5966..a9ee02efc 100644
--- a/src/hotspot/share/oops/compressedOops.cpp
+++ b/src/hotspot/share/oops/compressedOops.cpp
@@ -243,25 +243,39 @@ void CompressedKlassPointers::initialize(address addr, size_t len) {
range = 4 * G;
} else {
+#if defined(AARCH64) && INCLUDE_AOT
+ if (UseAOT && AOTLoader::libraries_count() > 0) {
+ constexpr uint64_t unscaled_max = nth_bit(32);
+ assert(len <= unscaled_max, "Klass range larger than 32 bits?");
- // Otherwise we attempt to use a zero base if the range fits in lower 32G.
- if (end <= (address)KlassEncodingMetaspaceMax) {
- base = 0;
- } else {
- base = addr;
- }
-
- // Highest offset a Klass* can ever have in relation to base.
- range = end - base;
-
- // We may not even need a shift if the range fits into 32bit:
- const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1);
- if (range < UnscaledClassSpaceMax) {
+ // Shift is always 0 on aarch64(AOT enabled).
shift = 0;
- } else {
- shift = LogKlassAlignmentInBytes;
- }
+ // On aarch64(AOT enabled), we don't bother with zero-based encoding (base=0 shift>0).
+ base = (end <= (address)unscaled_max) ? nullptr : addr;
+
+ range = end - base;
+ } else
+#endif // defined(AARCH64) && INCLUDE_AOT
+ {
+ // Otherwise we attempt to use a zero base if the range fits in lower 32G.
+ if (end <= (address)KlassEncodingMetaspaceMax) {
+ base = 0;
+ } else {
+ base = addr;
+ }
+
+ // Highest offset a Klass* can ever have in relation to base.
+ range = end - base;
+
+ // We may not even need a shift if the range fits into 32bit:
+ const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1);
+ if (range < UnscaledClassSpaceMax) {
+ shift = 0;
+ } else {
+ shift = LogKlassAlignmentInBytes;
+ }
+ }
}
set_base(base);
diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp
index 047b81a0c..9d798972e 100644
--- a/src/hotspot/share/oops/instanceKlass.hpp
+++ b/src/hotspot/share/oops/instanceKlass.hpp
@@ -1072,7 +1072,7 @@ public:
nonstatic_oop_map_size +
(is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
(has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0) +
- AOT_ONLY(sizeof(u1)) NOT_AOT(0));
+ AOT_ONLY((int)align_up(sizeof(u1),wordSize)/wordSize) NOT_AOT(0));
}
int size() const { return size(vtable_length(),
diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp
index fa3a2f2db..c52a7e1e6 100644
--- a/src/hotspot/share/oops/method.cpp
+++ b/src/hotspot/share/oops/method.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, 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
@@ -104,6 +104,9 @@ Method::Method(ConstMethod* xconst, AccessFlags access_flags) {
set_hidden(false);
set_dont_inline(false);
set_has_injected_profile(false);
+#if INCLUDE_JBOOSTER
+ set_rewrite_invokehandle(false);
+#endif
set_method_data(NULL);
clear_method_counters();
set_vtable_index(Method::garbage_vtable_index);
@@ -1170,6 +1173,10 @@ void Method::unlink_method() {
_from_compiled_entry = NULL;
_from_interpreted_entry = NULL;
+#if INCLUDE_AOT
+ _aot_code = NULL;
+#endif
+
if (is_native()) {
*native_function_addr() = NULL;
set_signature_handler(NULL);
diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp
index 266c48a5e..58432f1eb 100644
--- a/src/hotspot/share/oops/methodData.cpp
+++ b/src/hotspot/share/oops/methodData.cpp
@@ -1975,7 +1975,7 @@ MethodData* MethodData::create_instance_for_jbooster(Method* method, int size, c
// memcpy
int start = in_bytes(byte_offset_of(MethodData, _method)) + sizeof(res->_method);
- memcpy((void*) (((char*) res) + start), mem + start, size);
+ memcpy((void*) (((char*) res) + start), mem + start, size - start);
// restore
memcpy((void*) &res->_extra_data_lock, lock_bak, sizeof(res->_extra_data_lock));
diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp
index 8ceca7cd3..0d501e494 100644
--- a/src/hotspot/share/prims/jvm.cpp
+++ b/src/hotspot/share/prims/jvm.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2023, 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
@@ -3882,6 +3882,15 @@ JVM_ENTRY(void, JVM_JBoosterPrintStoredClientData(JNIEnv *env, jboolean print_al
#endif // INCLUDE_JBOOSTER
JVM_END
+JVM_ENTRY(jlong, JVM_JBoosterGetMetaspaceMethodData(JNIEnv *env, jint session_id, jlong metaspace_method))
+#if INCLUDE_JBOOSTER
+ TempJClientSessionData session_data = ServerDataManager::get().get_session(session_id, THREAD);
+ return (jlong) session_data->method_data_address((address) metaspace_method, THREAD);
+#else
+ return 0;
+#endif // INCLUDE_JBOOSTER
+JVM_END
+
JVM_ENTRY(void, JVM_JBoosterStartupNativeCallback(JNIEnv *env))
#if INCLUDE_JBOOSTER
if (!UseJBooster) return;
diff --git a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp
index c4c03ab8d..1c52bb06a 100644
--- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp
+++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp
@@ -4432,7 +4432,7 @@ void VM_RedefineClasses::redefine_single_class(Thread* current, jclass the_jclas
if (!the_class->should_be_initialized()) {
// Class was already initialized, so AOT has only seen the original version.
// We need to let AOT look at it again.
- AOTLoader::load_for_klass(the_class, current->as_Java_thread());
+ AOTLoader::load_for_klass(the_class, current);
}
#endif
diff --git a/src/java.base/share/lib/security/default.policy b/src/java.base/share/lib/security/default.policy
index 1c58b7797..06f0307f1 100644
--- a/src/java.base/share/lib/security/default.policy
+++ b/src/java.base/share/lib/security/default.policy
@@ -110,6 +110,41 @@ grant codeBase "jrt:/jdk.accessibility" {
permission java.lang.RuntimePermission "accessClassInPackage.sun.awt";
};
+grant codeBase "jrt:/jdk.aot" {
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.api.directives";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.api.runtime";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.api.replacements";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.asm.amd64";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.asm.aarch64";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.bytecode";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.code";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.core";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.core.common";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.core.target";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.debug";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.graph";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot.meta";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot.replacements";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot.stubs";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.hotspot.word";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.java";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.lir.asm";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.lir.phases";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.nodes";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.nodes.graphbuilderconf";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.options";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.phases";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.phases.tiers";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.printer";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.runtime";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.replacements";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.serviceprovider";
+ permission java.lang.RuntimePermission "accessClassInPackage.org.graalvm.compiler.word";
+ permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.vm.compiler.word";
+ permission java.lang.RuntimePermission "accessClassInPackage.jdk.vm.ci.jbooster";
+};
+
grant codeBase "jrt:/jdk.charsets" {
permission java.util.PropertyPermission "os.name", "read";
permission java.lang.RuntimePermission "charsetProvider";
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSection.java b/src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSection.java
index 7e0168a85..8b72dad28 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSection.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/elf/ElfSection.java
@@ -31,8 +31,9 @@ import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Rel;
import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Rela;
import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Shdr;
import jdk.tools.jaotc.binformat.elf.Elf.Elf64_Sym;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
-final class ElfSection {
+public final class ElfSection {
private final String name;
private final ByteBuffer section;
private final byte[] data;
@@ -53,6 +54,17 @@ final class ElfSection {
ElfSection(String sectName, byte[] sectData, int sectFlags, int sectType,
boolean hasRelocations, int align, int sectIndex) {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ StringBuilder sectNameTab;
+ int shStrTabNrOfBytes;
+ if (ctx != null) {
+ sectNameTab = ctx.getElfSectionSectNameTab();
+ shStrTabNrOfBytes = ctx.getElfSectionShStrTabNrOfBytes().get();
+ } else {
+ sectNameTab = ElfSection.sectNameTab;
+ shStrTabNrOfBytes = ElfSection.shStrTabNrOfBytes;
+ }
+
section = ElfByteBuffer.allocate(Elf64_Shdr.totalsize);
name = sectName;
// Return all 0's for NULL section
@@ -62,6 +74,12 @@ final class ElfSection {
data = null;
hasrelocations = false;
sectionIndex = 0;
+
+ if (ctx != null) {
+ ctx.getElfSectionShStrTabNrOfBytes().set(shStrTabNrOfBytes);
+ } else {
+ ElfSection.shStrTabNrOfBytes = shStrTabNrOfBytes;
+ }
return;
}
@@ -103,6 +121,12 @@ final class ElfSection {
hasrelocations = hasRelocations;
sectionIndex = sectIndex;
+
+ if (ctx != null) {
+ ctx.getElfSectionShStrTabNrOfBytes().set(shStrTabNrOfBytes);
+ } else {
+ ElfSection.shStrTabNrOfBytes = shStrTabNrOfBytes;
+ }
}
String getName() {
@@ -154,4 +178,12 @@ final class ElfSection {
return sectionIndex;
}
+ public static void guaranteeStaticNotUsed() {
+ if (sectNameTab.length() != 0) {
+ throw new IllegalStateException("Static sectNameTab should be empty for JBooster!");
+ }
+ if (shStrTabNrOfBytes != 0) {
+ throw new IllegalStateException("Static shStrTabNrOfBytes should be 0 for JBooster!");
+ }
+ }
}
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java
index 45ad9a594..eec021d5d 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java
@@ -50,6 +50,7 @@ import org.graalvm.compiler.phases.tiers.Suites;
import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
import jdk.vm.ci.meta.DefaultProfilingInfo;
import jdk.vm.ci.meta.ProfilingInfo;
@@ -116,7 +117,9 @@ final class AOTBackend {
@SuppressWarnings("try")
private StructuredGraph buildStructuredGraph(ResolvedJavaMethod javaMethod, DebugContext debug) {
try (DebugContext.Scope s = debug.scope("AOTParseMethod")) {
- StructuredGraph graph = new StructuredGraph.Builder(graalOptions, debug).method(javaMethod).useProfilingInfo(false).build();
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ boolean useProfilingInfo = ctx != null ? ctx.usePGO() : false;
+ StructuredGraph graph = new StructuredGraph.Builder(graalOptions, debug).method(javaMethod).useProfilingInfo(useProfilingInfo).build();
graphBuilderSuite.apply(graph, highTierContext);
return graph;
} catch (Throwable e) {
@@ -128,7 +131,13 @@ final class AOTBackend {
@SuppressWarnings("try")
private CompilationResult compileGraph(ResolvedJavaMethod resolvedMethod, StructuredGraph graph, DebugContext debug) {
try (DebugContext.Scope s = debug.scope("AOTCompileMethod")) {
- ProfilingInfo profilingInfo = DefaultProfilingInfo.get(TriState.FALSE);
+ ProfilingInfo profilingInfo;
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (ctx != null && ctx.usePGO()) {
+ profilingInfo = resolvedMethod.getProfilingInfo(true, true);
+ } else {
+ profilingInfo = DefaultProfilingInfo.get(TriState.FALSE);
+ }
final boolean isImmutablePIC = true;
CompilationIdentifier id = new CompilationIdentifier() {
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompilationTask.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompilationTask.java
index b3a72f981..b5f391ec1 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompilationTask.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompilationTask.java
@@ -160,6 +160,10 @@ final class AOTCompilationTask implements Runnable, Comparable<Object> {
return JVMCICompiler.INVOCATION_ENTRY_BCI;
}
+ Main getMain() {
+ return main;
+ }
+
ResolvedJavaMethod getMethod() {
return method;
}
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
index 416d332fc..0e33d5f02 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiledClass.java
@@ -38,6 +38,7 @@ import jdk.tools.jaotc.binformat.Symbol.Binding;
import jdk.tools.jaotc.binformat.Symbol.Kind;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.ResolvedJavaField;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
@@ -82,6 +83,13 @@ final class AOTCompiledClass {
private String[] getMetaspaceNames() {
String name = metadataName;
+ AOTDynamicTypeStore dynoStore;
+ if (JBoosterCompilationContext.get() != null) {
+ dynoStore = (AOTDynamicTypeStore) JBoosterCompilationContext.get()
+ .getAOTCompiledClassAOTDynamicTypeStore();
+ } else {
+ dynoStore = AOTCompiledClass.dynoStore;
+ }
Set<Location> locs = dynoStore.getDynamicClassLocationsForType(type);
if (locs == null) {
return new String[]{name};
@@ -263,6 +271,9 @@ final class AOTCompiledClass {
* Get the number of all AOT classes.
*/
static int getClassesCount() {
+ if (JBoosterCompilationContext.get() != null) {
+ return JBoosterCompilationContext.get().getAOTCompiledClassClassesCount().get();
+ }
return classesCount;
}
@@ -322,7 +333,19 @@ final class AOTCompiledClass {
static synchronized AOTKlassData addAOTKlassData(BinaryContainer binaryContainer, HotSpotResolvedObjectType type) {
AOTKlassData data = getAOTKlassData(type);
if (data == null) {
- data = new AOTKlassData(binaryContainer, type, classesCount++);
+ int cnt;
+ HashMap<String, AOTKlassData> klassData;
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (ctx != null) {
+ cnt = ctx.getAOTCompiledClassClassesCount().getAndIncrement();
+ @SuppressWarnings({"unchecked"})
+ HashMap<String, AOTKlassData> kd = (HashMap<String, AOTKlassData>) ctx.getAOTCompiledClassKlassData();
+ klassData = kd;
+ } else {
+ cnt = classesCount++;
+ klassData = AOTCompiledClass.klassData;
+ }
+ data = new AOTKlassData(binaryContainer, type, cnt);
klassData.put(type.getName(), data);
}
return data;
@@ -330,6 +353,15 @@ final class AOTCompiledClass {
static synchronized AOTKlassData getAOTKlassData(HotSpotResolvedObjectType type) {
String name = type.getName();
+ HashMap<String, AOTKlassData> klassData;
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (ctx != null) {
+ @SuppressWarnings({"unchecked"})
+ HashMap<String, AOTKlassData> kd = (HashMap<String, AOTKlassData>) ctx.getAOTCompiledClassKlassData();
+ klassData = kd;
+ } else {
+ klassData = AOTCompiledClass.klassData;
+ }
AOTKlassData data = klassData.get(name);
if (data != null) {
HotSpotResolvedObjectType oldType = data.getType();
@@ -417,6 +449,19 @@ final class AOTCompiledClass {
}
static void putAOTKlassData(BinaryContainer binaryContainer) {
+ AOTDynamicTypeStore dynoStore;
+ HashMap<String, AOTKlassData> klassData;
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (ctx != null) {
+ dynoStore = (AOTDynamicTypeStore) ctx.getAOTCompiledClassAOTDynamicTypeStore();
+ @SuppressWarnings({"unchecked"})
+ HashMap<String, AOTKlassData> kd = (HashMap<String, AOTKlassData>) ctx.getAOTCompiledClassKlassData();
+ klassData = kd;
+ } else {
+ dynoStore = AOTCompiledClass.dynoStore;
+ klassData = AOTCompiledClass.klassData;
+ }
+
// record dynamic types
Set<HotSpotResolvedObjectType> dynoTypes = dynoStore.getDynamicTypes();
if (dynoTypes != null) {
@@ -468,4 +513,15 @@ final class AOTCompiledClass {
this.methods = null;
}
+ public static void guaranteeStaticNotUsed() {
+ if (dynoStore != null) {
+ throw new IllegalStateException("Static dynoStore should be null for JBooster!");
+ }
+ if (classesCount != 0) {
+ throw new IllegalStateException("Static classesCount should be 0 for JBooster!");
+ }
+ if (!klassData.isEmpty()) {
+ throw new IllegalStateException("Static klassData should be empty for JBooster!");
+ }
+ }
}
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiler.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiler.java
index 4bf9047a4..680bccb26 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiler.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTCompiler.java
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.graalvm.compiler.options.OptionValues;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.ResolvedJavaMethod;
final class AOTCompiler {
@@ -50,7 +51,7 @@ final class AOTCompiler {
/**
* Compile queue.
*/
- private class CompileQueue extends ThreadPoolExecutor {
+ private static class CompileQueue extends ThreadPoolExecutor {
/**
* Time of the start of this queue.
@@ -67,21 +68,59 @@ final class AOTCompiler {
*/
private final AtomicInteger failedMethodCount = new AtomicInteger();
+ /**
+ * The printer to use.
+ */
+ private final LogPrinter printer;
+
/**
* Create a compile queue with the given number of threads.
*/
- CompileQueue(final int threads) {
+ CompileQueue(LogPrinter printer, final int threads) {
super(threads, threads, 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<>());
+ this.printer = printer;
startTime = System.currentTimeMillis();
}
+ @Override
+ protected void beforeExecute(Thread t, Runnable r) {
+ AOTCompilationTask task = (AOTCompilationTask) r;
+
+ JBoosterCompilationContext ctx = task.getMain().getJBoosterCompilationContext();
+ if (ctx != null) {
+ // Every run() is executed in a new thread in the thread pool.
+ // - Some code of JAOTC use global static variables, which makes it impossible to process
+ // multiple AOTCompilationTasks in parallel.
+ // - Some code of VM.CI should be patched by JBooster, but it's difficult to pass the ctx
+ // through method calls.
+ // So we use the thread-local JBoosterCompilationContext for each thread. And different
+ // threads can share the same ctx.
+ JBoosterCompilationContext.set(ctx);
+ }
+ }
+
@Override
protected void afterExecute(Runnable r, Throwable t) {
AOTCompilationTask task = (AOTCompilationTask) r;
+
+ AtomicInteger successfulMethodCount;
+ AtomicInteger failedMethodCount;
+ JBoosterCompilationContext ctx = task.getMain().getJBoosterCompilationContext();
+ if (ctx != null) {
+ successfulMethodCount = ctx.getCompileQueueSuccessfulMethodCount();
+ failedMethodCount = ctx.getCompileQueueFailedMethodCount();
+
+ ctx.getAOTCompilerRemainingTaskCount().countDown();
+ JBoosterCompilationContext.set(null);
+ } else {
+ successfulMethodCount = this.successfulMethodCount;
+ failedMethodCount = this.failedMethodCount;
+ }
+
if (task.getResult() != null) {
final int count = successfulMethodCount.incrementAndGet();
if (count % 100 == 0) {
- main.printer.printInfo(".");
+ printer.printInfo(".");
}
CompiledMethodInfo result = task.getResult();
if (result != null) {
@@ -89,21 +128,33 @@ final class AOTCompiler {
}
} else {
failedMethodCount.incrementAndGet();
- main.printer.printlnVerbose("");
+ printer.printlnVerbose("");
ResolvedJavaMethod method = task.getMethod();
- main.printer.printlnVerbose(" failed " + method.getName() + method.getSignature().toMethodDescriptor());
+ printer.printlnVerbose(" failed " + method.getName() + method.getSignature().toMethodDescriptor());
}
}
@Override
protected void terminated() {
+ if (jboosterGlobalCompileQueue != null) {
+ printer.printlnInfo("JBooster global AOT compilation queue terminated.");
+ return;
+ }
final long endTime = System.currentTimeMillis();
final int success = successfulMethodCount.get();
final int failed = failedMethodCount.get();
- main.printer.printlnInfo("");
- main.printer.printlnInfo(success + " methods compiled, " + failed + " methods failed (" + (endTime - startTime) + " ms)");
+ printer.printlnInfo("");
+ printer.printlnInfo(success + " methods compiled, " + failed + " methods failed (" + (endTime - startTime) + " ms)");
}
+ public void guaranteeStaticNotUsed() {
+ if (successfulMethodCount.get() != 0) {
+ throw new IllegalStateException("Static successfulMethodCount should be 0 for JBooster!");
+ }
+ if (failedMethodCount.get() != 0) {
+ throw new IllegalStateException("Static failedMethodCount should be 0 for JBooster!");
+ }
+ }
}
/**
@@ -115,7 +166,7 @@ final class AOTCompiler {
AOTCompiler(Main main, OptionValues graalOptions, AOTBackend aotBackend, final int threads) {
this.main = main;
this.graalOptions = graalOptions;
- this.compileQueue = new CompileQueue(threads);
+ this.compileQueue = new CompileQueue(main.printer, threads);
this.backend = aotBackend;
}
@@ -166,4 +217,84 @@ final class AOTCompiler {
LogPrinter.writeLog(message + " " + methodName);
}
+ private static CompileQueue jboosterGlobalCompileQueue = null;
+
+ static ThreadPoolExecutor getJBoosterGlobalCompileQueue() {
+ return jboosterGlobalCompileQueue;
+ }
+
+ /**
+ * Compile classes by the jboosterGlobalCompileQueue. So different classes
+ * set can use the same thread pool.
+ */
+ static List<AOTCompiledClass> compileClassesInJBooster(
+ Main main, OptionValues options, AOTBackend backend, List<AOTCompiledClass> classes)
+ throws InterruptedException {
+ main.printer.printlnInfo("Compiling with " + jboosterGlobalCompileQueue.getCorePoolSize() + " threads");
+ main.printer.printInfo("."); // Compilation progress indication.
+
+ final long startTime = System.currentTimeMillis();
+
+ JBoosterCompilationContext ctx = main.getJBoosterCompilationContext();
+ List<AOTCompilationTask> tasks = getMethodCompilationTasks(main, options, backend, classes);
+ ctx.setAOTCompilerTotalTaskCount(tasks.size());
+ enqueueMethods(main, tasks);
+
+ ctx.getAOTCompilerRemainingTaskCount().await();
+
+ final long endTime = System.currentTimeMillis();
+ final int success = ctx.getCompileQueueSuccessfulMethodCount().get();
+ final int failed = ctx.getCompileQueueFailedMethodCount().get();
+ main.printer.printlnInfo("");
+ main.printer.printlnInfo(success + " methods compiled, " + failed + " methods failed (" + (endTime - startTime) + " ms)");
+ jboosterGlobalCompileQueue.guaranteeStaticNotUsed();
+
+ List<AOTCompiledClass> compiledClasses = new ArrayList<>();
+ for (AOTCompiledClass compiledClass : classes) {
+ if (compiledClass.hasCompiledMethods()) {
+ compiledClasses.add(compiledClass);
+ }
+ }
+ return compiledClasses;
+ }
+
+ static void initJBoosterGlobalCompileQueue() {
+ if (jboosterGlobalCompileQueue != null) {
+ throw new InternalError("Init twice?");
+ }
+
+ int globalThreads = Integer.max(Runtime.getRuntime().availableProcessors() - 4, 1);
+ Main commonMain = new Main();
+ commonMain.options.info = true;
+ commonMain.options.verbose = false;
+ commonMain.options.debug = false;
+ jboosterGlobalCompileQueue = new CompileQueue(commonMain.printer, globalThreads);
+ }
+
+ private static List<AOTCompilationTask> getMethodCompilationTasks(Main main, OptionValues options,
+ AOTBackend backend, List<AOTCompiledClass> classes) {
+ List<AOTCompilationTask> list = new ArrayList<>();
+ for (AOTCompiledClass aotClass : classes) {
+ for (ResolvedJavaMethod method : aotClass.getMethods()) {
+ AOTCompilationTask task = new AOTCompilationTask(main, options, aotClass, method, backend);
+ list.add(task);
+ }
+ }
+ return list;
+ }
+
+ private static void enqueueMethods(Main main, List<AOTCompilationTask> tasks) throws InterruptedException {
+ for (AOTCompilationTask task : tasks) {
+ try {
+ jboosterGlobalCompileQueue.execute(task);
+ } catch (RejectedExecutionException e) {
+ main.getJBoosterCompilationContext().getAOTCompilerRemainingTaskCount().countDown();
+ if (jboosterGlobalCompileQueue.isShutdown()) {
+ throw new InterruptedException();
+ } else {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
}
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java
index bd127b308..8c2083f4e 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Collector.java
@@ -54,7 +54,15 @@ final class Collector {
}
Set<Class<?>> collectClassesToCompile() {
- Set<Class<?>> classesToCompile = new HashSet<>();
+ Set<Class<?>> classesToCompile;
+ if (main.options.getClassesToCompile() != null) {
+ if (main.options.files.isEmpty()) {
+ return main.options.getClassesToCompile();
+ }
+ classesToCompile = main.options.getClassesToCompile();
+ } else {
+ classesToCompile = new HashSet<>();
+ }
FileSupport fileSupport = new FileSupport();
ClassSearch lookup = new ClassSearch();
lookup.addProvider(new ModuleSourceProvider());
@@ -104,11 +112,11 @@ final class Collector {
*
* @return array list of AOT classes which have compiled methods.
*/
- List<AOTCompiledClass> collectMethodsToCompile(Set<Class<?>> classesToCompile, MetaAccessProvider metaAccess) {
+ List<AOTCompiledClass> collectMethodsToCompile(Set<Class<?>> classesToCompile, Set<String> methodsToCompile, Set<String> methodsNotToCompile, MetaAccessProvider metaAccess) {
int total = 0;
int count = 0;
List<AOTCompiledClass> classes = new ArrayList<>();
- CompilationSpec compilationRestrictions = collectSpecifiedMethods();
+ CompilationSpec compilationRestrictions = collectSpecifiedMethods(methodsToCompile, methodsNotToCompile);
for (Class<?> c : classesToCompile) {
ResolvedJavaType resolvedJavaType = metaAccess.lookupJavaType(c);
@@ -160,8 +168,8 @@ final class Collector {
* If a file with compilation limitations is specified using flag --compile-commands, read the
* file's contents and collect the restrictions.
*/
- private CompilationSpec collectSpecifiedMethods() {
- CompilationSpec compilationRestrictions = new CompilationSpec();
+ private CompilationSpec collectSpecifiedMethods(Set<String> methodsToCompile, Set<String> methodsNotToCompile) {
+ CompilationSpec compilationRestrictions = new CompilationSpec((HashSet<String>) methodsToCompile, (HashSet<String>) methodsNotToCompile);
String methodListFileName = main.options.methodList;
if (methodListFileName != null && !methodListFileName.equals("")) {
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompilationSpec.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompilationSpec.java
index 19662c52b..17ea7fd58 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompilationSpec.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompilationSpec.java
@@ -48,6 +48,15 @@ final class CompilationSpec {
private HashSet<String> excludeStrings = new HashSet<>();
private HashSet<Pattern> excludePatterns = new HashSet<>();
+ CompilationSpec(HashSet<String> compileOnlyStrings, HashSet<String> excludeStrings) {
+ if (compileOnlyStrings != null) {
+ this.compileOnlyStrings = compileOnlyStrings;
+ }
+ if (excludeStrings != null) {
+ this.excludeStrings = excludeStrings;
+ }
+ }
+
/**
* Add a {@code compileOnly} directive to the compile-only list.
*
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompiledMethodInfo.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompiledMethodInfo.java
index 49db6afbb..6da934117 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompiledMethodInfo.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/CompiledMethodInfo.java
@@ -38,6 +38,7 @@ import jdk.tools.jaotc.binformat.ReadOnlyDataContainer;
import jdk.vm.ci.code.site.Call;
import jdk.vm.ci.hotspot.HotSpotCompiledCode;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
final class CompiledMethodInfo {
@@ -243,10 +244,16 @@ final class CompiledMethodInfo {
}
static int getMethodsCount() {
+ if (JBoosterCompilationContext.get() != null) {
+ return JBoosterCompilationContext.get().getCompiledMethodInfoMethodsCount().get();
+ }
return methodsCount.get();
}
static int getNextCodeId() {
+ if (JBoosterCompilationContext.get() != null) {
+ return JBoosterCompilationContext.get().getCompiledMethodInfoMethodsCount().getAndIncrement();
+ }
return methodsCount.getAndIncrement();
}
@@ -338,4 +345,10 @@ final class CompiledMethodInfo {
this.compilationResult = null;
this.methodInfo = null;
}
+
+ public static void guaranteeStaticNotUsed() {
+ if (methodsCount.get() != 0) {
+ throw new IllegalStateException("Static methodsCount should be 0 for JBooster!");
+ }
+ }
}
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java
index 949124ffe..1a6de8758 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java
@@ -58,12 +58,15 @@ final class DataBuilder {
private static final HashMap<Long, String> vmAddresses = new HashMap<>();
+ static {
+ fillVMAddresses(HotSpotJVMCIRuntime.runtime().getConfigStore());
+ }
+
DataBuilder(Main main, HotSpotHostBackend backend, List<AOTCompiledClass> classes, BinaryContainer binaryContainer) {
this.main = main;
this.backend = backend;
this.classes = classes;
this.binaryContainer = binaryContainer;
- fillVMAddresses(HotSpotJVMCIRuntime.runtime().getConfigStore());
}
/**
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataPatchProcessor.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataPatchProcessor.java
index c6b141b1f..1055294ac 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataPatchProcessor.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataPatchProcessor.java
@@ -148,15 +148,24 @@ final class DataPatchProcessor {
int alignment = data.getAlignment();
byte[] value = new byte[size];
ByteBuffer buffer = ByteBuffer.wrap(value).order(ByteOrder.nativeOrder());
- DataSection.emit(buffer, data, (p, c) -> {
+ final String[] targetSymbol = {""};
+ DataSection.emit(buffer, data, (position, constant) -> {
+ assert constant instanceof HotSpotMetaspaceConstant : "unknown type:" + constant;
+ HotSpotMetaspaceConstant metaspaceConstant = (HotSpotMetaspaceConstant) constant;
+ HotSpotResolvedObjectType type = metaspaceConstant.asResolvedJavaType();
+ assert type != null : "unexpected null type";
+ methodInfo.addDependentKlassData(binaryContainer, type);
+ targetSymbol[0] = "got." + AOTCompiledClass.metadataName(type);
});
- String targetSymbol = "data.M" + methodInfo.getCodeId() + "." + dataOffset;
- Symbol relocationSymbol = binaryContainer.getSymbol(targetSymbol);
+ if ("".equals(targetSymbol[0])) {
+ targetSymbol[0] = "data.M" + methodInfo.getCodeId() + "." + dataOffset;
+ }
+ Symbol relocationSymbol = binaryContainer.getSymbol(targetSymbol[0]);
if (relocationSymbol == null) {
int symSize = Math.max(8, size);
int symAlig = Math.max(8, alignment);
int offsetInConstantDataSection = binaryContainer.addConstantData(value, symAlig);
- relocationSymbol = binaryContainer.getConstantDataContainer().createSymbol(offsetInConstantDataSection, Kind.OBJECT, Binding.LOCAL, symSize, targetSymbol);
+ relocationSymbol = binaryContainer.getConstantDataContainer().createSymbol(offsetInConstantDataSection, Kind.OBJECT, Binding.LOCAL, symSize, targetSymbol[0]);
}
Relocation reloc = new Relocation(relocOffset, RelocType.METASPACE_GOT_REFERENCE, 0, binaryContainer.getCodeContainer(), relocationSymbol);
binaryContainer.addRelocation(reloc);
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java
index bb9bc1667..7e44c0cdb 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java
@@ -29,6 +29,7 @@ import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC;
import static org.graalvm.compiler.core.common.GraalOptions.ImmutableCode;
import static org.graalvm.compiler.hotspot.meta.HotSpotAOTProfilingPlugin.Options.TieredAOT;
+import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
@@ -40,6 +41,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Stream;
import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
@@ -68,6 +70,9 @@ import org.graalvm.compiler.runtime.RuntimeProvider;
import jdk.tools.jaotc.Options.Option;
import jdk.tools.jaotc.binformat.BinaryContainer;
+import jdk.tools.jaotc.binformat.elf.ElfSection;
+import jdk.tools.jaotc.jbooster.JBoosterHotSpotAOTInvokeDynamicPlugin;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.runtime.JVMCI;
@@ -79,6 +84,8 @@ public final class Main {
LogPrinter printer;
GraalFilters filters;
+ private final JBoosterCompilationContext jboosterContext;
+
private static final int EXIT_OK = 0; // No errors.
private static final int EXIT_CMDERR = 2; // Bad command-line arguments and/or switches.
private static final int EXIT_ABNORMAL = 4; // Terminated abnormally.
@@ -93,6 +100,81 @@ public final class Main {
System.exit(exitCode);
}
+ public static void initForJBooster() {
+ AOTCompiler.initJBoosterGlobalCompileQueue();
+ }
+
+ public static ThreadPoolExecutor getJBoosterGlobalCompileQueue() {
+ return AOTCompiler.getJBoosterGlobalCompileQueue();
+ }
+
+ public Main() {
+ this(null);
+ }
+
+ public Main(JBoosterCompilationContext jboosterContext) {
+ this.jboosterContext = jboosterContext;
+ log = new PrintWriter(System.out);
+ printer = new LogPrinter(this, log);
+ }
+
+ public JBoosterCompilationContext getJBoosterCompilationContext() {
+ return jboosterContext;
+ }
+
+ /**
+ * This method is for JBooster.
+ * Compile all specified methods to one lib.
+ * This method can only be invoked once for each Main instance.
+ */
+ @SuppressWarnings("try")
+ public boolean compileForJBooster() {
+ JBoosterCompilationContext.set(jboosterContext);
+
+ options.asJBooster = true;
+ options.outputName = jboosterContext.getFilePath();
+ options.classesToCompile = jboosterContext.getClassesToCompile();
+ options.methodsToCompile = jboosterContext.getMethodsToCompile();
+ options.methodsNotToCompile = jboosterContext.getMethodsNotToCompile();
+ options.dynamicInvokeSupported = true;
+
+ options.info = true;
+ options.verbose = false;
+ options.debug = false;
+
+ options.tiered = false;
+ options.ignoreClassLoadingErrors = true;
+
+ try (Timer t = new Timer(this, "Total time of compilation")) {
+ File compiledFile = new File(options.outputName);
+ if (compiledFile.isFile()) {
+ compiledFile.delete();
+ }
+
+ if (run()) {
+ return true;
+ } else {
+ if (compiledFile.isFile()) {
+ compiledFile.delete();
+ }
+ return false;
+ }
+ } catch (InterruptedException e) {
+ printer.printlnInfo("Compilation interrupted.");
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ log.flush();
+ JBoosterCompilationContext.set(null);
+
+ // Make sure the static fields are not used.
+ CompiledMethodInfo.guaranteeStaticNotUsed();
+ AOTCompiledClass.guaranteeStaticNotUsed();
+ ElfSection.guaranteeStaticNotUsed();
+ }
+ return false;
+ }
+
/**
* Expands '@file' in command line arguments by replacing '@file' with the content of 'file'
* parsed by StringTokenizer. '@' character can be quoted as '@@'.
@@ -194,7 +276,7 @@ public final class Main {
List<AOTCompiledClass> classes;
try (Timer t = new Timer(this, "")) {
- classes = collector.collectMethodsToCompile(classesToCompile, metaAccess);
+ classes = collector.collectMethodsToCompile(classesToCompile, options.methodsToCompile, options.methodsNotToCompile, metaAccess);
}
// Free memory!
@@ -205,23 +287,39 @@ public final class Main {
}
AOTDynamicTypeStore dynoStore = new AOTDynamicTypeStore();
- AOTCompiledClass.setDynamicTypeStore(dynoStore);
+ if (!options.isAsJBooster()) {
+ AOTCompiledClass.setDynamicTypeStore(dynoStore);
+ } else {
+ jboosterContext.setAotCompiledClassAOTDynamicTypeStore(dynoStore);
+ }
// AOTBackend aotBackend = new AOTBackend(this, graalOptions, backend, new
// HotSpotInvokeDynamicPlugin(dynoStore));
// Temporary workaround until JDK-8223533 is fixed.
// Disable invokedynamic support.
- var indyPlugin = new HotSpotInvokeDynamicPlugin(dynoStore) {
- @Override
- public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
- return false;
- }
- };
+ HotSpotInvokeDynamicPlugin indyPlugin;
+ if (options.isDynamicInvokeSupported()) {
+ printer.printlnInfo("Using JBoosterHotSpotAOTInvokeDynamicPlugin.");
+ indyPlugin = new JBoosterHotSpotAOTInvokeDynamicPlugin(dynoStore);
+ } else {
+ indyPlugin = new HotSpotInvokeDynamicPlugin(dynoStore) {
+ @Override
+ public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
+ return false;
+ }
+ };
+ }
AOTBackend aotBackend = new AOTBackend(this, graalOptions, backend, indyPlugin);
SnippetReflectionProvider snippetReflection = aotBackend.getProviders().getSnippetReflection();
- AOTCompiler compiler = new AOTCompiler(this, graalOptions, aotBackend, options.threads);
- classes = compiler.compileClasses(classes);
+ AOTCompiler compiler;
+ if (!options.isAsJBooster()) {
+ compiler = new AOTCompiler(this, graalOptions, aotBackend, options.threads);
+ classes = compiler.compileClasses(classes);
+ } else {
+ compiler = null;
+ classes = AOTCompiler.compileClassesInJBooster(this, graalOptions, aotBackend, classes);
+ }
PhaseSuite<HighTierContext> graphBuilderSuite = aotBackend.getGraphBuilderSuite();
ListIterator<BasePhase<? super HighTierContext>> iterator = graphBuilderSuite.findPhase(GraphBuilderPhase.class);
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java
index 817f6a2e2..b03d93b68 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/MetadataBuilder.java
@@ -198,6 +198,12 @@ final class MetadataBuilder {
for (int index = 0; index < metaDataEntries.length; index++) {
Object ref = metaDataEntries[index];
+
+ // types that brought by agentlib should be added in here
+ if (methodInfo.getDependentKlassData(getType(ref)) == null) {
+ methodInfo.addDependentKlassData(binaryContainer, getType(ref));
+ }
+
String name = metadataName(ref);
// Create GOT cells for klasses referenced in metadata
addMetadataEntry(binaryContainer, name);
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java
index e5dcda118..517edc1df 100644
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java
@@ -29,6 +29,7 @@ import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
import jdk.tools.jaotc.collect.ClassSearch;
import jdk.tools.jaotc.collect.ClassSource;
@@ -65,6 +66,24 @@ final class Options {
boolean compileWithAssertions;
boolean tiered;
+ boolean asJBooster = false;
+ Set<Class<?>> classesToCompile = null;
+ Set<String> methodsToCompile = null;
+ Set<String> methodsNotToCompile = null;
+ boolean dynamicInvokeSupported = false;
+
+ public boolean isAsJBooster() {
+ return asJBooster;
+ }
+
+ public Set<Class<?>> getClassesToCompile() {
+ return classesToCompile;
+ }
+
+ public boolean isDynamicInvokeSupported() {
+ return isAsJBooster() && dynamicInvokeSupported;
+ }
+
private String defaultOutputName() {
osName = System.getProperty("os.name");
String name = "unnamed.";
diff --git a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/jbooster/JBoosterHotSpotAOTInvokeDynamicPlugin.java b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/jbooster/JBoosterHotSpotAOTInvokeDynamicPlugin.java
new file mode 100644
index 000000000..5c616458b
--- /dev/null
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/jbooster/JBoosterHotSpotAOTInvokeDynamicPlugin.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2023, Huawei Technologies Co., Ltd. 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
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.tools.jaotc.jbooster;
+
+import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+import org.graalvm.compiler.bytecode.Bytecodes;
+import org.graalvm.compiler.hotspot.meta.HotSpotInvokeDynamicPlugin;
+import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
+
+/**
+ * JBoosterHotSpotAOTInvokeDynamicPlugin
+ */
+public class JBoosterHotSpotAOTInvokeDynamicPlugin extends HotSpotInvokeDynamicPlugin {
+ public JBoosterHotSpotAOTInvokeDynamicPlugin(DynamicTypeStore dynoStore) {
+ super(dynoStore);
+ }
+
+ @Override
+ public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int opcode) {
+ // Support ConstantCallSite of invokedynamic only.
+ if (opcode != Bytecodes.INVOKEDYNAMIC) return false;
+ HotSpotResolvedJavaMethod target = (HotSpotResolvedJavaMethod) builder.getCode().getConstantPool().lookupMethod(index, opcode);
+ return "linkToTargetMethod".equals(target.getName());
+ }
+}
diff --git a/src/jdk.aot/share/classes/module-info.java b/src/jdk.aot/share/classes/module-info.java
index f6341b8ae..ca6edae24 100644
--- a/src/jdk.aot/share/classes/module-info.java
+++ b/src/jdk.aot/share/classes/module-info.java
@@ -34,4 +34,8 @@ module jdk.aot {
requires jdk.internal.vm.ci;
requires jdk.internal.vm.compiler;
requires jdk.management;
+
+ exports jdk.tools.jaotc to jdk.jbooster;
+ exports jdk.tools.jaotc.collect to jdk.jbooster;
+ exports jdk.tools.jaotc.collect.module to jdk.jbooster;
}
diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
index f2e998c56..268cedc41 100644
--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
@@ -74,7 +74,6 @@ public class InstanceKlass extends Klass {
private static int MISC_HAS_NONSTATIC_CONCRETE_METHODS;
private static int MISC_DECLARES_NONSTATIC_CONCRETE_METHODS;
private static int MISC_HAS_BEEN_REDEFINED;
- private static int MISC_HAS_PASSED_FINGERPRINT_CHECK;
private static int MISC_IS_SCRATCH_CLASS;
private static int MISC_IS_SHARED_BOOT_CLASS;
private static int MISC_IS_SHARED_PLATFORM_CLASS;
@@ -132,7 +131,6 @@ public class InstanceKlass extends Klass {
MISC_HAS_NONSTATIC_CONCRETE_METHODS = db.lookupIntConstant("InstanceKlass::_misc_has_nonstatic_concrete_methods").intValue();
MISC_DECLARES_NONSTATIC_CONCRETE_METHODS = db.lookupIntConstant("InstanceKlass::_misc_declares_nonstatic_concrete_methods").intValue();
MISC_HAS_BEEN_REDEFINED = db.lookupIntConstant("InstanceKlass::_misc_has_been_redefined").intValue();
- MISC_HAS_PASSED_FINGERPRINT_CHECK = db.lookupIntConstant("InstanceKlass::_misc_has_passed_fingerprint_check").intValue();
MISC_IS_SCRATCH_CLASS = db.lookupIntConstant("InstanceKlass::_misc_is_scratch_class").intValue();
MISC_IS_SHARED_BOOT_CLASS = db.lookupIntConstant("InstanceKlass::_misc_is_shared_boot_class").intValue();
MISC_IS_SHARED_PLATFORM_CLASS = db.lookupIntConstant("InstanceKlass::_misc_is_shared_platform_class").intValue();
@@ -288,6 +286,10 @@ public class InstanceKlass extends Klass {
size += 8; // uint64_t
}
+ if (VM.getVM().hasAOT()) {
+ size += 1; // u1 aot_flags
+ }
+
return alignSize(size);
}
@@ -303,6 +305,9 @@ public class InstanceKlass extends Klass {
if (vm.getCommandLineBooleanFlag("DumpSharedSpaces")) {
return true;
}
+ if (vm.getCommandLineBooleanFlag("CalculateClassFingerprint")) {
+ return true;
+ }
return false;
}
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java
index c2a7fa2b5..d65b9b272 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java
@@ -30,6 +30,7 @@ import jdk.vm.ci.code.CPUFeatureName;
import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.Register.RegisterCategory;
import jdk.vm.ci.code.RegisterArray;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.PlatformKind;
@@ -206,10 +207,17 @@ public class AArch64 extends Architecture {
@Override
public EnumSet<CPUFeature> getFeatures() {
+ if (JBoosterCompilationContext.get() != null) {
+ // [AArch64]can't get features from client now, just return empty set
+ return EnumSet.noneOf(CPUFeature.class);
+ }
return features;
}
public EnumSet<Flag> getFlags() {
+ if (JBoosterCompilationContext.get() != null) {
+ return EnumSet.noneOf(Flag.class);
+ }
return flags;
}
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java
index 3fc5b6e79..b01824af3 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java
@@ -35,6 +35,7 @@ import jdk.vm.ci.code.CPUFeatureName;
import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.Register.RegisterCategory;
import jdk.vm.ci.code.RegisterArray;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.PlatformKind;
@@ -253,10 +254,17 @@ public class AMD64 extends Architecture {
@Override
public EnumSet<CPUFeature> getFeatures() {
+ if (JBoosterCompilationContext.get() != null) {
+ // [AMD64]can't get features from client now, just return empty set
+ return EnumSet.noneOf(CPUFeature.class);
+ }
return features;
}
public EnumSet<Flag> getFlags() {
+ if (JBoosterCompilationContext.get() != null) {
+ return EnumSet.noneOf(Flag.class);
+ }
return flags;
}
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java
index cc553a39f..df87221da 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java
@@ -45,10 +45,26 @@ final class DirectHotSpotObjectConstantImpl extends HotSpotObjectConstantImpl {
super(compressed);
assert object != null;
this.object = object;
+ this.holderType = null;
+ this.cpi = -1;
+ }
+
+ static JavaConstant forObject(HotSpotResolvedObjectType type, int cpi, JavaConstant object) {
+ return new DirectHotSpotObjectConstantImpl(type, cpi, object);
+ }
+
+ private DirectHotSpotObjectConstantImpl(HotSpotResolvedObjectType type, int cpi, JavaConstant constant) {
+ super(((DirectHotSpotObjectConstantImpl) constant).compressed);
+ this.object = ((DirectHotSpotObjectConstantImpl) constant).object;
+ this.holderType = type;
+ this.cpi = cpi;
}
final Object object;
+ private final HotSpotResolvedObjectType holderType;
+ private final int cpi;
+
@Override
public JavaConstant compress() {
assert !compressed;
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPoolObject.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPoolObject.java
index ce82af7e5..eaf2bcc9b 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPoolObject.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPoolObject.java
@@ -32,7 +32,7 @@ import jdk.vm.ci.meta.JavaKind;
public final class HotSpotConstantPoolObject implements JavaConstant {
public static JavaConstant forObject(HotSpotResolvedObjectType type, int cpi, JavaConstant object) {
- return new HotSpotConstantPoolObject(type, cpi, object);
+ return DirectHotSpotObjectConstantImpl.forObject(type, cpi, object);
}
private final JavaConstant constant;
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
index 079dacefd..74be52e13 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2023, 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
@@ -301,7 +301,7 @@ public final class HotSpotJVMCIRuntime implements JVMCIRuntime {
"Enables tracing of profiling info when read by JVMCI.",
"Empty value: trace all methods",
"Non-empty value: trace methods whose fully qualified name contains the value."),
- UseProfilingInformation(Boolean.class, true, "");
+ UseProfilingInformation(Boolean.class, true, "Use ProfilingInformation for compiler");
// @formatter:on
/**
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java
index dec8c0e89..28e46e64e 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2023, 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
@@ -22,6 +22,7 @@
*/
package jdk.vm.ci.hotspot;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.DeoptimizationReason;
import jdk.vm.ci.meta.JavaMethodProfile;
import jdk.vm.ci.meta.JavaTypeProfile;
@@ -50,7 +51,12 @@ final class HotSpotProfilingInfo implements ProfilingInfo {
}
this.includeNormal = includeNormal;
this.includeOSR = includeOSR;
- this.isMature = methodData.isProfileMature();
+ if (methodData.isProfileMature()) {
+ this.isMature = true;
+ } else {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ this.isMature = ctx != null && ctx.usePGO();
+ }
hintPosition = 0;
hintBCI = -1;
}
@@ -110,7 +116,11 @@ final class HotSpotProfilingInfo implements ProfilingInfo {
@Override
public TriState getExceptionSeen(int bci) {
- findBCI(bci, true);
+ if (JBoosterCompilationContext.get() != null) {
+ findBCI(bci, false);
+ } else {
+ findBCI(bci, true);
+ }
return dataAccessor.getExceptionSeen(methodData, position);
}
diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
index fc370ba75..fb281f98d 100644
--- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
+++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2023, 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
@@ -38,6 +38,7 @@ import java.lang.reflect.Type;
import jdk.vm.ci.common.JVMCIError;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.ConstantPool;
import jdk.vm.ci.meta.DefaultProfilingInfo;
@@ -472,26 +473,40 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
@Override
public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) {
ProfilingInfo info;
-
- if (Option.UseProfilingInformation.getBoolean() && methodData == null) {
- long metaspaceMethodData = UNSAFE.getAddress(getMetaspaceMethod() + config().methodDataOffset);
+ HotSpotMethodData currentMethodData = null;
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (ctx == null || !ctx.usePGO()) {
+ currentMethodData = methodData;
+ }
+
+ if (Option.UseProfilingInformation.getBoolean() && (ctx != null && ctx.usePGO() || methodData == null)) {
+ long metaspaceMethodData = 0L;
+ if (ctx == null) {
+ metaspaceMethodData = UNSAFE.getAddress(getMetaspaceMethod() + config().methodDataOffset);
+ } else if (ctx.usePGO()) {
+ // force to get MethodData everytime when use JBooster
+ metaspaceMethodData = JBoosterCompilationContext.get().getMetaspaceMethodData(getMetaspaceMethod());
+ }
if (metaspaceMethodData != 0) {
- methodData = new HotSpotMethodData(metaspaceMethodData, this);
+ currentMethodData = new HotSpotMethodData(metaspaceMethodData, this);
+ if (ctx == null) {
+ methodData = currentMethodData;
+ }
String methodDataFilter = Option.TraceMethodDataFilter.getString();
if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) {
- String line = methodData.toString() + System.lineSeparator();
+ String line = currentMethodData.toString() + System.lineSeparator();
byte[] lineBytes = line.getBytes();
HotSpotJVMCIRuntime.runtime().writeDebugOutput(lineBytes, 0, lineBytes.length, true, true);
}
}
}
- if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) {
+ if (currentMethodData == null || (!currentMethodData.hasNormalData() && !currentMethodData.hasExtraData())) {
// Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in
// case of a deoptimization.
info = DefaultProfilingInfo.get(TriState.FALSE);
} else {
- info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR);
+ info = new HotSpotProfilingInfo(currentMethodData, this, includeNormal, includeOSR);
}
return info;
}
diff --git a/src/jdk.internal.vm.ci/share/classes/module-info.java b/src/jdk.internal.vm.ci/share/classes/module-info.java
index 9f9122cf8..111ad997f 100644
--- a/src/jdk.internal.vm.ci/share/classes/module-info.java
+++ b/src/jdk.internal.vm.ci/share/classes/module-info.java
@@ -32,8 +32,8 @@ module jdk.internal.vm.ci {
jdk.internal.vm.compiler.management;
exports jdk.vm.ci.meta to jdk.internal.vm.compiler;
exports jdk.vm.ci.code to jdk.internal.vm.compiler;
- exports jdk.vm.ci.hotspot to jdk.internal.vm.compiler;
- exports jdk.vm.ci.jbooster to jdk.jbooster, jdk.internal.vm.compiler;
+ exports jdk.vm.ci.hotspot to jdk.internal.vm.compiler, jdk.jbooster;
+ exports jdk.vm.ci.jbooster to jdk.aot, jdk.jbooster, jdk.internal.vm.compiler;
uses jdk.vm.ci.services.JVMCIServiceLocator;
uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.code/src/org/graalvm/compiler/code/DataSection.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.code/src/org/graalvm/compiler/code/DataSection.java
index 0d99acf0f..a20fd5b9b 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.code/src/org/graalvm/compiler/code/DataSection.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.code/src/org/graalvm/compiler/code/DataSection.java
@@ -47,6 +47,17 @@ public final class DataSection implements Iterable<Data> {
}
public abstract static class Data {
+ public static final int MIN_ALIGNMENT;
+ static {
+ String archStr = System.getProperty("os.arch").toLowerCase();
+ if ("aarch64".equals(archStr)) {
+ // AArch64 Relocations are 4-aligned
+ // see relocInfo_aarch64.hpp -> offset_unit
+ MIN_ALIGNMENT = 4;
+ } else {
+ MIN_ALIGNMENT = 1;
+ }
+ }
private int alignment;
private final int size;
@@ -54,7 +65,7 @@ public final class DataSection implements Iterable<Data> {
private DataSectionReference ref;
protected Data(int alignment, int size) {
- this.alignment = alignment;
+ this.alignment = lcm(alignment, MIN_ALIGNMENT);
this.size = size;
// initialized in DataSection.insertData(Data)
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotMove.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotMove.java
index c9b7bc9bc..b78ae697d 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotMove.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotMove.java
@@ -71,7 +71,13 @@ public class AArch64HotSpotMove {
// masm.forceMov(asRegister(result), 0);
masm.movNarrowAddress(asRegister(result), 0);
} else {
- masm.movNativeAddress(asRegister(result), 0);
+ Register resultRegister = asRegister(result);
+ if (crb.compilationResult.isImmutablePIC()) {
+ masm.addressOf(resultRegister);
+ masm.ldr(64, resultRegister, AArch64Address.createBaseRegisterOnlyAddress(resultRegister));
+ } else {
+ masm.movNativeAddress(resultRegister, 0);
+ }
}
}
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotStrategySwitchOp.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotStrategySwitchOp.java
index 447a48b60..92c68ddac 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotStrategySwitchOp.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotStrategySwitchOp.java
@@ -28,6 +28,7 @@ import static jdk.vm.ci.code.ValueUtil.asRegister;
import java.util.function.Function;
+import org.graalvm.compiler.asm.aarch64.AArch64Address;
import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler;
import org.graalvm.compiler.core.common.calc.Condition;
@@ -71,8 +72,14 @@ final class AArch64HotSpotStrategySwitchOp extends AArch64ControlFlow.StrategySw
throw GraalError.unimplemented();
} else {
crb.recordInlineDataInCode(meta);
- masm.movNativeAddress(asRegister(scratch), 0x0000_DEAD_DEAD_DEADL);
- masm.cmp(64, keyRegister, asRegister(scratch));
+ Register scratchRegister = asRegister(scratch);
+ if (crb.compilationResult.isImmutablePIC()) {
+ masm.addressOf(scratchRegister);
+ masm.ldr(64, scratchRegister, AArch64Address.createBaseRegisterOnlyAddress(scratchRegister));
+ } else {
+ masm.movNativeAddress(scratchRegister, 0x0000_DEAD_DEAD_DEADL);
+ }
+ masm.cmp(64, keyRegister, scratchRegister);
}
} else {
super.emitComparison(c);
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotMove.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotMove.java
index e839243be..0c1be69d8 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotMove.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotMove.java
@@ -44,6 +44,7 @@ import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
import jdk.vm.ci.code.Register;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
import jdk.vm.ci.hotspot.HotSpotObjectConstant;
import jdk.vm.ci.meta.AllocatableValue;
@@ -65,7 +66,8 @@ public class AMD64HotSpotMove {
@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
- if (GeneratePIC.getValue(crb.getOptions())) {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (GeneratePIC.getValue(crb.getOptions()) && (ctx == null || !ctx.usePGO())) {
throw GraalError.shouldNotReachHere("Object constant load should not be happening directly");
}
boolean compressed = input.isCompressed();
@@ -142,7 +144,8 @@ public class AMD64HotSpotMove {
@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
- if (GeneratePIC.getValue(crb.getOptions())) {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (GeneratePIC.getValue(crb.getOptions()) && (ctx == null || !ctx.usePGO())) {
throw GraalError.shouldNotReachHere("Metaspace constant load should not be happening directly");
}
boolean compressed = input.isCompressed();
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java
index d5b23edd1..c580616eb 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java
@@ -471,7 +471,6 @@ public class CheckGraalIntrinsics extends GraalTest {
if (!(arch instanceof AMD64)) {
// Can we implement these on non-AMD64 platforms? C2 seems to.
add(toBeInvestigated,
- "com/sun/crypto/provider/CounterMode.implCrypt([BII[BI)I",
"java/lang/String.compareTo(Ljava/lang/String;)I",
"java/lang/StringLatin1.indexOf([B[B)I",
"java/lang/StringLatin1.inflate([BI[BII)V",
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/AOTGraalHotSpotVMConfig.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/AOTGraalHotSpotVMConfig.java
index 2305d5eb5..ffc883c12 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/AOTGraalHotSpotVMConfig.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/AOTGraalHotSpotVMConfig.java
@@ -41,8 +41,13 @@ public class AOTGraalHotSpotVMConfig extends GraalHotSpotVMConfig {
// always equal to alignment to avoid emitting zero-shift AOT code.
CompressEncoding vmOopEncoding = super.getOopEncoding();
aotOopEncoding = new CompressEncoding(vmOopEncoding.getBase(), logMinObjAlignment());
+
+ // For compressed klass, there is always zero-shift in aarch64
CompressEncoding vmKlassEncoding = super.getKlassEncoding();
- aotKlassEncoding = new CompressEncoding(vmKlassEncoding.getBase(), logKlassAlignment);
+ String archStr = System.getProperty("os.arch").toLowerCase();
+ int zeroShift = 0;
+ aotKlassEncoding = new CompressEncoding(vmKlassEncoding.getBase(), "aarch64".equals(archStr) ? zeroShift : logKlassAlignment);
+
assert check();
reportErrors();
}
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java
index 423c2f95e..6199d921b 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java
@@ -178,6 +178,7 @@ import jdk.vm.ci.hotspot.HotSpotCallingConventionType;
import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField;
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
import jdk.vm.ci.meta.JavaType;
@@ -526,7 +527,8 @@ public abstract class DefaultHotSpotLoweringProvider extends DefaultJavaLowering
LoweredCallTargetNode loweredCallTarget = null;
OptionValues options = graph.getOptions();
- if (InlineVTableStubs.getValue(options) && callTarget.invokeKind().isIndirect() && (AlwaysInlineVTableStubs.getValue(options) || invoke.isPolymorphic())) {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if ((ctx == null || !ctx.usePGO()) && InlineVTableStubs.getValue(options) && callTarget.invokeKind().isIndirect() && (AlwaysInlineVTableStubs.getValue(options) || invoke.isPolymorphic())) {
HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) callTarget.targetMethod();
ResolvedJavaType receiverType = invoke.getReceiverType();
if (hsMethod.isInVirtualMethodTable(receiverType)) {
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java
index 6b8e63229..e429e43e8 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java
@@ -444,6 +444,7 @@ import jdk.vm.ci.code.BailoutException;
import jdk.vm.ci.code.BytecodeFrame;
import jdk.vm.ci.code.CodeUtil;
import jdk.vm.ci.code.site.InfopointReason;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.ConstantPool;
import jdk.vm.ci.meta.ConstantReflectionProvider;
@@ -4432,7 +4433,8 @@ public class BytecodeParser implements GraphBuilderContext {
}
private JavaTypeProfile getProfileForTypeCheck(TypeReference type) {
- if (parsingIntrinsic() || profilingInfo == null || !optimisticOpts.useTypeCheckHints(getOptions()) || type.isExact()) {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if ((ctx != null && ctx.usePGO()) || parsingIntrinsic() || profilingInfo == null || !optimisticOpts.useTypeCheckHints(getOptions()) || type.isExact()) {
return null;
} else {
return profilingInfo.getTypeProfile(bci());
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/InliningLog.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/InliningLog.java
index bda34e6a7..40b1ac3b8 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/InliningLog.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/InliningLog.java
@@ -171,10 +171,15 @@ public class InliningLog {
if (!enabled) {
return;
}
- assert leaves.containsKey(invoke);
+ if (!leaves.containsKey(invoke)) {
+ trackNewCallsite(invoke);
+ }
assert (!positive && replacements == null && calleeLog == null) || (positive && replacements != null && calleeLog != null) ||
(positive && replacements == null && calleeLog == null);
Callsite callsite = leaves.get(invoke);
+ if (callsite == null) {
+ return;
+ }
callsite.target = callsite.invoke.getTargetMethod();
Decision decision = new Decision(positive, String.format(reason, args), phase, invoke.getTargetMethod());
callsite.decisions.add(decision);
diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java
index 9d24764a6..d2f7b99cc 100644
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/inlining/walker/InliningData.java
@@ -70,6 +70,7 @@ import org.graalvm.compiler.phases.common.inlining.policy.InliningPolicy;
import org.graalvm.compiler.phases.tiers.HighTierContext;
import jdk.vm.ci.code.BailoutException;
+import jdk.vm.ci.jbooster.JBoosterCompilationContext;
import jdk.vm.ci.meta.Assumptions.AssumptionResult;
import jdk.vm.ci.meta.JavaTypeProfile;
import jdk.vm.ci.meta.ResolvedJavaMethod;
@@ -152,7 +153,7 @@ public class InliningData {
return "it is a non-intrinsic native method";
} else if (method.isAbstract()) {
return "it is an abstract method";
- } else if (!method.getDeclaringClass().isInitialized()) {
+ } else if (!method.getDeclaringClass().isInitialized() && (JBoosterCompilationContext.get() == null || !JBoosterCompilationContext.get().usePGO())) {
return "the method's class is not initialized";
} else if (!method.canBeInlined()) {
return "it is marked non-inlinable";
@@ -193,6 +194,16 @@ public class InliningData {
MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
ResolvedJavaMethod targetMethod = callTarget.targetMethod();
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if (ctx != null && ctx.usePGO()) {
+ String methodName = targetMethod.getDeclaringClass().toClassName() + "." + targetMethod.getName() + targetMethod.getSignature().toMethodDescriptor();
+ if (JBoosterCompilationContext.get().isInlineExcluded(methodName)) {
+ InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "can not inline invokehandle calls");
+ invoke.asNode().graph().getInliningLog().addDecision(invoke, false, "InliningPhase", null, null, "can not inline invokehandle calls");
+ return null;
+ }
+ }
+
InvokeKind invokeKind = callTarget.invokeKind();
if (invokeKind == CallTargetNode.InvokeKind.Special || invokeKind == CallTargetNode.InvokeKind.Static || targetMethod.canBeStaticallyBound()) {
return getExactInlineInfo(invoke, targetMethod);
@@ -271,7 +282,8 @@ public class InliningData {
double notRecordedTypeProbability = typeProfile.getNotRecordedProbability();
final OptimisticOptimizations optimisticOpts = context.getOptimisticOptimizations();
OptionValues options = invoke.asNode().getOptions();
- if (ptypes.length == 1 && notRecordedTypeProbability == 0) {
+ JBoosterCompilationContext ctx = JBoosterCompilationContext.get();
+ if ((ctx == null || !ctx.usePGO()) && ptypes.length == 1 && notRecordedTypeProbability == 0) {
if (!optimisticOpts.inlineMonomorphicCalls(options)) {
InliningUtil.traceNotInlinedMethod(invoke, inliningDepth(), targetMethod, "inlining monomorphic calls is disabled");
invoke.asNode().graph().getInliningLog().addDecision(invoke, false, "InliningPhase", null, null, "inlining monomorphic calls is disabled");
@@ -385,6 +397,10 @@ public class InliningData {
return null;
}
}
+ if (ctx != null && ctx.usePGO() && notRecordedTypeProbability == 0) {
+ // always inline with megamorphic, never deopt
+ notRecordedTypeProbability = 0.01D;
+ }
return new MultiTypeGuardInlineInfo(invoke, concreteMethods, usedTypes, typesToConcretes, notRecordedTypeProbability);
}
}
diff --git a/src/jdk.jbooster/share/classes/jdk/jbooster/JBooster.java b/src/jdk.jbooster/share/classes/jdk/jbooster/JBooster.java
index 49cdbb28a..642fbafa6 100644
--- a/src/jdk.jbooster/share/classes/jdk/jbooster/JBooster.java
+++ b/src/jdk.jbooster/share/classes/jdk/jbooster/JBooster.java
@@ -29,8 +29,7 @@ import java.util.Set;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
-import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option;
+import jdk.tools.jaotc.Main;
import sun.misc.Signal;
import sun.misc.SignalHandler;
@@ -175,22 +174,24 @@ public final class JBooster {
/**
* This method is invoked only in C++.
*/
- private static boolean compileClasses(int sessionId, String filePath, Set<Class<?>> classes) {
- return compileMethods(sessionId, filePath, classes, null, null);
+ private static boolean compileClasses(int sessionId, String filePath, Set<Class<?>> classes, boolean usePGO) {
+ return compileMethods(sessionId, filePath, classes, null, null, usePGO);
}
/**
* This method is invoked only in C++.
*/
private static boolean compileMethods(int sessionId, String filePath, Set<Class<?>> classes,
- Set<String> methodsToCompile, Set<String> methodsNotToCompile) {
+ Set<String> methodsToCompile, Set<String> methodsNotToCompile, boolean usePGO) {
LOGGER.log(INFO, "Compilation task received: classes_to_compile={0}, methods_to_compile={1}, methods_not_compile={2}, session_id={3}.",
classes.size(),
(methodsToCompile == null ? "all" : String.valueOf(methodsToCompile.size())),
(methodsNotToCompile == null ? "none" : String.valueOf(methodsNotToCompile.size())),
sessionId);
try {
- // [JBOOSTER TODO] jaotc logic
+ JBoosterCompilationContextImpl ctx = new JBoosterCompilationContextImpl(
+ sessionId, filePath, classes, methodsToCompile, methodsNotToCompile, usePGO);
+ return new Main(ctx).compileForJBooster();
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/jdk.jbooster/share/classes/module-info.java b/src/jdk.jbooster/share/classes/module-info.java
index 5a7c685b5..648eb9641 100644
--- a/src/jdk.jbooster/share/classes/module-info.java
+++ b/src/jdk.jbooster/share/classes/module-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2023, Huawei Technologies Co., Ltd. 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
@@ -28,6 +28,7 @@
* @since 9
*/
module jdk.jbooster {
+ requires jdk.aot;
requires jdk.internal.vm.ci;
requires jdk.unsupported;
requires java.logging;
diff --git a/src/jdk.jbooster/share/native/libjbooster/JBooster.c b/src/jdk.jbooster/share/native/libjbooster/JBooster.c
index 385e8780b..664c761ff 100644
--- a/src/jdk.jbooster/share/native/libjbooster/JBooster.c
+++ b/src/jdk.jbooster/share/native/libjbooster/JBooster.c
@@ -43,3 +43,9 @@ Java_jdk_jbooster_JBooster_printStoredClientData(JNIEnv * env, jclass unused, jb
{
JVM_JBoosterPrintStoredClientData(env, print_all);
}
+
+JNIEXPORT long JNICALL
+Java_jdk_jbooster_JBoosterCompilationContextImpl_getMetaspaceMethodData(JNIEnv * env, jclass unused, jint session_id, jlong metaspace_method)
+{
+ return JVM_JBoosterGetMetaspaceMethodData(env, session_id, metaspace_method);
+}
diff --git a/test/hotspot/jtreg/compiler/aot/TestAotPrint.java b/test/hotspot/jtreg/compiler/aot/TestAotPrint.java
new file mode 100644
index 000000000..12d966e1b
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/aot/TestAotPrint.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2024, Huawei Technologies Co., Ltd. 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
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @requires vm.aot
+ * @library /test/lib /testlibrary /
+ * @build compiler.aot.TestAotPrint
+ * jdk.test.whitebox.WhiteBox
+ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
+ * @run driver compiler.aot.AotCompiler -libname libAotString.so
+ * -class java.lang.String
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseAOT
+ * -XX:AOTLibrary=./libAotString.so -XX:+PrintCompilation
+ * -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
+ * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ * -XX:+PrintAOT compiler.aot.TestAotPrint
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseAOT
+ * -XX:AOTLibrary=./libAotString.so -XX:+PrintCompilation
+ * -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
+ * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
+ * -XX:+PrintAOT compiler.aot.TestAotPrint true
+ */
+
+package compiler.aot;
+
+import compiler.aot.HelloWorldPrinter;
+import jdk.test.lib.cli.CommandLineOptionTest;
+import jdk.test.lib.process.ExitCode;
+import jdk.test.whitebox.WhiteBox;
+
+public class TestAotPrint {
+ private static final WhiteBox WB = WhiteBox.getWhiteBox();
+
+ public static void main(String[] args) throws Throwable {
+ boolean preserve_static_stubs = false;
+ if (args.length > 0 && "true".equals(args[0])) {
+ preserve_static_stubs = true;
+ }
+ HelloWorldPrinter.print();
+ WB.clearInlineCaches(preserve_static_stubs);
+ }
+}
diff --git a/test/hotspot/jtreg/compiler/aot/TestAotWithRetransform.java b/test/hotspot/jtreg/compiler/aot/TestAotWithRetransform.java
new file mode 100644
index 000000000..295f52579
--- /dev/null
+++ b/test/hotspot/jtreg/compiler/aot/TestAotWithRetransform.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2024, Huawei Technologies Co., Ltd. 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
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @requires vm.aot
+ * @library /test/lib /testlibrary /
+ * @build compiler.aot.TestAotWithRetransform
+ * compiler.aot.AotCompiler
+ * @run driver compiler.aot.AotCompiler -libname libTestAotWithRetransform.so
+ * -class compiler.aot.HelloWorldPrinter
+ * -compile compiler.aot.HelloWorldPrinter.print()V
+ * @run driver jdk.test.lib.util.JavaAgentBuilder
+ * compiler.aot.TestAotWithRetransform TestAotWithRetransform.jar
+ * @run driver compiler.aot.TestAotWithRetransform
+ */
+
+package compiler.aot;
+
+import compiler.aot.HelloWorldPrinter;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.List;
+import jdk.test.lib.cli.CommandLineOptionTest;
+import jdk.test.lib.process.ExitCode;
+
+public class TestAotWithRetransform {
+ private final static String LIB_NAME = "libTestAotWithRetransform.so";
+ private final static String JAR_NAME = "TestAotWithRetransform.jar";
+ private final static String CLASS_NAME = "compiler/aot/HelloWorldPrinter";
+ private final static String UPDATED_MESSAGE = "Hello earth";
+
+ private final static String[] UNEXPECTED_MESSAGES = new String[] {
+ HelloWorldPrinter.CLINIT_MESSAGE,
+ HelloWorldPrinter.MESSAGE,
+ CLASS_NAME
+ };
+
+ private final static String[] EXPECTED_MESSAGES = new String[] {
+ LIB_NAME,
+ UPDATED_MESSAGE
+ };
+
+ public static class Bytes {
+ public final static byte[] WORLD = Bytes.asBytes("world");
+ public final static byte[] EARTH = Bytes.asBytes("earth");
+
+ public static byte[] asBytes(String string) {
+ byte[] result = new byte[string.length()];
+ for (int i = 0; i < string.length(); i++) {
+ result[i] = (byte)string.charAt(i);
+ }
+ return result;
+ }
+
+ public static byte[] replaceAll(byte[] input, byte[] target, byte[] replacement) {
+ List<Byte> result = new ArrayList<>();
+ for (int i = 0; i < input.length; i++) {
+ if (hasTarget(input, i, target)) {
+ for (int j = 0; j < replacement.length; j++) {
+ result.add(replacement[j]);
+ }
+ i += target.length - 1;
+ } else {
+ result.add(input[i]);
+ }
+ }
+ byte[] resultArray = new byte[result.size()];
+ for (int i = 0; i < resultArray.length; i++) {
+ resultArray[i] = result.get(i);
+ }
+ return resultArray;
+ }
+
+ private static boolean hasTarget(byte[] input, int start, byte[] target) {
+ for (int i = 0; i < target.length; i++) {
+ if (start + i == input.length) {
+ return false;
+ }
+ if (input[start + i] != target[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ public static class TestClassFileTransformer implements ClassFileTransformer {
+ public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
+ if (CLASS_NAME.equals(className)) {
+ return Bytes.replaceAll(classfileBuffer, Bytes.WORLD, Bytes.EARTH);
+ }
+ return classfileBuffer;
+ }
+ }
+
+ // Called when agent is loaded at startup
+ public static void premain(String agentArgs, Instrumentation instrumentation) throws Exception {
+ // don't init HelloWorldPrinter here, just Load in advance
+ HelloWorldPrinter.class.getName();
+ instrumentation.addTransformer(new TestClassFileTransformer(), true);
+ // retransform HelloWorldPrinter
+ instrumentation.retransformClasses(HelloWorldPrinter.class);
+ }
+
+ public static void main(String[] args) throws Throwable {
+ try {
+ boolean addTestVMOptions = true;
+ CommandLineOptionTest.verifyJVMStartup(EXPECTED_MESSAGES,
+ UNEXPECTED_MESSAGES, "Unexpected exit code",
+ "Unexpected output", ExitCode.OK, addTestVMOptions,
+ "-XX:+UnlockExperimentalVMOptions", "-XX:+UseAOT", "-XX:+PrintAOT",
+ "-XX:AOTLibrary=./" + LIB_NAME,
+ "-javaagent:./" + JAR_NAME,
+ HelloWorldPrinter.class.getName());
+ } catch (Throwable t) {
+ throw new Error("Problems executing test " + t, t);
+ }
+ }
+}
diff --git a/test/jdk/jdk/internal/jimage/JImageOpenTest.java b/test/jdk/jdk/internal/jimage/JImageOpenTest.java
index 5dd304db1..769902cb0 100644
--- a/test/jdk/jdk/internal/jimage/JImageOpenTest.java
+++ b/test/jdk/jdk/internal/jimage/JImageOpenTest.java
@@ -33,7 +33,7 @@ import java.util.stream.Stream;
/*
* @test
* @summary Test to see if thread interrupt handling interferes with other threads.
- * @run main/othervm -Djdk.image.map.all=false JImageOpenTest
+ * @run main/othervm --add-exports jdk.internal.vm.ci/jdk.vm.ci.code.site=jdk.internal.vm.compiler -Djdk.image.map.all=false JImageOpenTest
*/
public class JImageOpenTest {
private static final int NTHREADS = 10;
diff --git a/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java b/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java
index 4718e10e8..a64b0efd1 100644
--- a/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java
+++ b/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java
@@ -72,6 +72,7 @@ public class JdkQualifiedExportTest {
Set.of("jdk.internal.vm.ci/jdk.vm.ci.services",
"jdk.internal.vm.ci/jdk.vm.ci.runtime",
"jdk.internal.vm.ci/jdk.vm.ci.hotspot",
+ "jdk.internal.vm.ci/jdk.vm.ci.jbooster",
"jdk.internal.vm.ci/jdk.vm.ci.meta",
"jdk.internal.vm.ci/jdk.vm.ci.code",
"java.base/jdk.internal.javac");
diff --git a/test/jdk/tools/launcher/HelpFlagsTest.java b/test/jdk/tools/launcher/HelpFlagsTest.java
index f7a4acd0c..7e7cf47f9 100644
--- a/test/jdk/tools/launcher/HelpFlagsTest.java
+++ b/test/jdk/tools/launcher/HelpFlagsTest.java
@@ -130,7 +130,7 @@ public class HelpFlagsTest extends TestHelper {
new ToolHelpSpec("javadoc", 1, 1, 1, 0, 1, 1, 1), // -?, -h, --help -help, Documents -help
new ToolHelpSpec("javap", 1, 1, 1, 0, 1, 1, 2), // -?, -h, --help -help, Documents -help
new ToolHelpSpec("javaw", 1, 1, 1, 0, 1, 1, 1), // -?, -h, --help -help, Documents -help, win only
- new ToolHelpSpec("jbooster", 0, 0, 0, 0, 0, 0, 1), // none.
+ new ToolHelpSpec("jbooster", 1, 1, 1, 0, 1, 1, 1), // -?, -h, --help -help, Documents -help
new ToolHelpSpec("jcmd", 1, 1, 1, 0, 1, 0, 1), // -?, -h, --help, -help accepted but not documented.
new ToolHelpSpec("jdb", 1, 1, 1, 0, 1, 1, 0), // -?, -h, --help -help, Documents -help
new ToolHelpSpec("jdeprscan", 1, 1, 1, 0, 0, 0, 1), // -?, -h, --help
diff --git a/test/jdk/tools/launcher/VersionCheck.java b/test/jdk/tools/launcher/VersionCheck.java
index 1fd5dd99a..48ec0890f 100644
--- a/test/jdk/tools/launcher/VersionCheck.java
+++ b/test/jdk/tools/launcher/VersionCheck.java
@@ -54,10 +54,8 @@ public class VersionCheck extends TestHelper {
"jaccessinspector-32",
"jaccesswalker",
"jaccesswalker-32",
- "jaotc",
"javaw",
"javaws",
- "jbooster",
"jcontrol",
"jmc",
"jmc.ini",
--
2.19.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gaoxiang90/openjdk-17.git
git@gitee.com:gaoxiang90/openjdk-17.git
gaoxiang90
openjdk-17
openjdk-17
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385