Skip to content

Commit

Permalink
Merge pull request #2082 from jdmpapin/aot-get-class-class-pointer
Browse files Browse the repository at this point in the history
Make java/lang/Class available in AOT
  • Loading branch information
andrewcraik authored Jun 12, 2018
2 parents ee0b791 + 119b787 commit d3d7dc3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
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;

_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

0 comments on commit d3d7dc3

Please sign in to comment.