Fix of hang during Intel JIT profiling

Committed on behalf of Kirill Uhanov

llvm-svn: 164736
This commit is contained in:
Andrew Kaylor 2012-09-26 23:43:56 +00:00
parent 76b65ea942
commit c091ea33f0
2 changed files with 10 additions and 12 deletions

View File

@ -37,13 +37,13 @@ namespace {
class IntelJITEventListener : public JITEventListener {
typedef DenseMap<void*, unsigned int> MethodIDMap;
IntelJITEventsWrapper& Wrapper;
OwningPtr<IntelJITEventsWrapper> Wrapper;
MethodIDMap MethodIDs;
FilenameCache Filenames;
public:
IntelJITEventListener(IntelJITEventsWrapper& libraryWrapper)
: Wrapper(libraryWrapper) {
IntelJITEventListener(IntelJITEventsWrapper* libraryWrapper) {
Wrapper.reset(libraryWrapper);
}
~IntelJITEventListener() {
@ -94,7 +94,7 @@ static iJIT_Method_Load FunctionDescToIntelJITFormat(
void IntelJITEventListener::NotifyFunctionEmitted(
const Function &F, void *FnStart, size_t FnSize,
const EmittedFunctionDetails &Details) {
iJIT_Method_Load FunctionMessage = FunctionDescToIntelJITFormat(Wrapper,
iJIT_Method_Load FunctionMessage = FunctionDescToIntelJITFormat(*Wrapper,
F.getName().data(),
reinterpret_cast<uint64_t>(FnStart),
FnSize);
@ -151,7 +151,7 @@ void IntelJITEventListener::NotifyFunctionEmitted(
FunctionMessage.line_number_table = 0;
}
Wrapper.iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
Wrapper->iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
&FunctionMessage);
MethodIDs[FnStart] = FunctionMessage.method_id;
}
@ -159,7 +159,7 @@ void IntelJITEventListener::NotifyFunctionEmitted(
void IntelJITEventListener::NotifyFreeingMachineCode(void *FnStart) {
MethodIDMap::iterator I = MethodIDs.find(FnStart);
if (I != MethodIDs.end()) {
Wrapper.iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_UNLOAD_START, &I->second);
Wrapper->iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_UNLOAD_START, &I->second);
MethodIDs.erase(I);
}
}
@ -168,15 +168,13 @@ void IntelJITEventListener::NotifyFreeingMachineCode(void *FnStart) {
namespace llvm {
JITEventListener *JITEventListener::createIntelJITEventListener() {
static OwningPtr<IntelJITEventsWrapper> JITProfilingWrapper(
new IntelJITEventsWrapper);
return new IntelJITEventListener(*JITProfilingWrapper);
return new IntelJITEventListener(new IntelJITEventsWrapper);
}
// for testing
JITEventListener *JITEventListener::createIntelJITEventListener(
IntelJITEventsWrapper* TestImpl) {
return new IntelJITEventListener(*TestImpl);
return new IntelJITEventListener(TestImpl);
}
} // namespace llvm

View File

@ -80,7 +80,7 @@ public:
EXPECT_TRUE(0 != MockWrapper);
Listener.reset(JITEventListener::createIntelJITEventListener(
MockWrapper.get()));
MockWrapper.take()));
EXPECT_TRUE(0 != Listener);
EE->RegisterJITEventListener(Listener.get());
}