Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make java/lang/Class available in AOT #2082

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions runtime/compiler/compile/J9Compilation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -38,6 +38,7 @@
#include "control/Options_inlines.hpp"
#include "control/Recompilation.hpp"
#include "control/RecompilationInfo.hpp"
#include "env/j9method.h"
#include "env/TRMemory.hpp"
#include "env/VMJ9.h"
#include "env/VMAccessCriticalSection.hpp"
Expand Down Expand Up @@ -175,6 +176,9 @@ J9::Compilation::Compilation(
_ReferenceClassPointer = fe->getClassFromSignature("Ljava/lang/ref/Reference;", 25, compilee);
_JITHelpersClassPointer = fe->getClassFromSignature("Lcom/ibm/jit/JITHelpers;", 24, compilee);

_aotClassClassPointer = NULL;
_aotClassClassPointerInitialized = false;

_aotGuardPatchSites = new (m->trHeapMemory()) TR::list<TR_AOTGuardSite*>(getTypedAllocator<TR_AOTGuardSite*>(self()->allocator()));

_aotClassInfo = new (m->trHeapMemory()) TR::list<TR::AOTClassInfo*>(getTypedAllocator<TR::AOTClassInfo*>(self()->allocator()));
Expand Down Expand Up @@ -1144,9 +1148,36 @@ J9::Compilation::addAsMonitorAuto(TR::SymbolReference* symRef, bool dontAddIfDLT
}

TR_OpaqueClassBlock *
J9::Compilation::getClassClassPointer()
J9::Compilation::getClassClassPointer(bool isVettedForAOT)
{
return _ObjectClassPointer ? self()->fe()->getClassClassPointer(_ObjectClassPointer) : 0;
if (!isVettedForAOT)
return _ObjectClassPointer ? self()->fe()->getClassClassPointer(_ObjectClassPointer) : 0;

if (_aotClassClassPointerInitialized)
return _aotClassClassPointer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be nit-picky, but do we need _aotClassClassPointerInitialized? Isn't it sufficient to know that if _aotClassClassPointer is NULL it hasn't been initialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be unavailable even though we set isVettedForAOT=true


_aotClassClassPointerInitialized = true;

bool jlObjectVettedForAOT = true;
TR_OpaqueClassBlock *jlObject = self()->fej9()->getClassFromSignature(
"Ljava/lang/Object;",
18,
self()->getCurrentMethod(),
jlObjectVettedForAOT);

if (jlObject == NULL)
return NULL;

TR_OpaqueClassBlock *jlClass = self()->fe()->getClassClassPointer(jlObject);
if (jlClass == NULL)
return NULL;

TR_ResolvedJ9Method *method = (TR_ResolvedJ9Method*)self()->getCurrentMethod();
if (!method->validateArbitraryClass(self(), (J9Class*)jlClass))
return NULL;

_aotClassClassPointer = jlClass;
return jlClass;
}

/*
Expand Down
7 changes: 5 additions & 2 deletions runtime/compiler/compile/J9Compilation.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -258,7 +258,7 @@ class OMR_EXTENSIBLE Compilation : public OMR::CompilationConnector
TR_OpaqueClassBlock *getSystemClassPointer() { return _SystemClassPointer; }
TR_OpaqueClassBlock *getReferenceClassPointer() { return _ReferenceClassPointer; }
TR_OpaqueClassBlock *getJITHelpersClassPointer() { return _JITHelpersClassPointer; }
TR_OpaqueClassBlock *getClassClassPointer();
TR_OpaqueClassBlock *getClassClassPointer(bool isVettedForAOT = false);

// Monitors
TR_Array<List<TR::RegisterMappedSymbol> * > & getMonitorAutos() { return _monitorAutos; }
Expand Down Expand Up @@ -343,6 +343,9 @@ class OMR_EXTENSIBLE Compilation : public OMR::CompilationConnector
TR_OpaqueClassBlock *_ReferenceClassPointer;
TR_OpaqueClassBlock *_JITHelpersClassPointer;

TR_OpaqueClassBlock *_aotClassClassPointer;
bool _aotClassClassPointerInitialized;

TR_Array<List<TR::RegisterMappedSymbol> *> _monitorAutos;
TR::list<TR::SymbolReference*> _monitorAutoSymRefsInCompiledMethod;

Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ TR_J9InlinerPolicy::createUnsafePutWithOffset(TR::ResolvedMethodSymbol *calleeSy
traceMsg(comp(),"Setting node %p as an unsafe static wrtbar\n",indirectAccessTreeTop->getNode());
indirectAccessTreeTop->getNode()->setIsUnsafeStaticWrtBar(true);
}
TR_OpaqueClassBlock *javaLangClass = comp()->fe()->getClassFromSignature("Ljava/lang/Class;",17, comp()->getCurrentMethod(),true);
TR_OpaqueClassBlock *javaLangClass = comp()->getClassClassPointer(/* isVettedForAOT = */ true);
// If we are not able to get javaLangClass it is still inefficient to put direct Access far
// So in that case we will generate lowTagCmpTest to branch to indirect access if true
bool needNotLowTagged = javaLangClass != NULL || conversionNeeded ;
Expand Down