llvm.org GIT mirror llvm / 44aebe8
Fix of hang during Intel JIT profiling Committed on behalf of Kirill Uhanov git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164736 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Kaylor 8 years ago
2 changed file(s) with 10 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3636 class IntelJITEventListener : public JITEventListener {
3737 typedef DenseMap MethodIDMap;
3838
39 IntelJITEventsWrapper& Wrapper;
39 OwningPtr Wrapper;
4040 MethodIDMap MethodIDs;
4141 FilenameCache Filenames;
4242
4343 public:
44 IntelJITEventListener(IntelJITEventsWrapper& libraryWrapper)
45 : Wrapper(libraryWrapper) {
44 IntelJITEventListener(IntelJITEventsWrapper* libraryWrapper) {
45 Wrapper.reset(libraryWrapper);
4646 }
4747
4848 ~IntelJITEventListener() {
9393 void IntelJITEventListener::NotifyFunctionEmitted(
9494 const Function &F, void *FnStart, size_t FnSize,
9595 const EmittedFunctionDetails &Details) {
96 iJIT_Method_Load FunctionMessage = FunctionDescToIntelJITFormat(Wrapper,
96 iJIT_Method_Load FunctionMessage = FunctionDescToIntelJITFormat(*Wrapper,
9797 F.getName().data(),
9898 reinterpret_cast(FnStart),
9999 FnSize);
150150 FunctionMessage.line_number_table = 0;
151151 }
152152
153 Wrapper.iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
154 &FunctionMessage);
153 Wrapper->iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED,
154 &FunctionMessage);
155155 MethodIDs[FnStart] = FunctionMessage.method_id;
156156 }
157157
158158 void IntelJITEventListener::NotifyFreeingMachineCode(void *FnStart) {
159159 MethodIDMap::iterator I = MethodIDs.find(FnStart);
160160 if (I != MethodIDs.end()) {
161 Wrapper.iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_UNLOAD_START, &I->second);
161 Wrapper->iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_UNLOAD_START, &I->second);
162162 MethodIDs.erase(I);
163163 }
164164 }
167167
168168 namespace llvm {
169169 JITEventListener *JITEventListener::createIntelJITEventListener() {
170 static OwningPtr JITProfilingWrapper(
171 new IntelJITEventsWrapper);
172 return new IntelJITEventListener(*JITProfilingWrapper);
170 return new IntelJITEventListener(new IntelJITEventsWrapper);
173171 }
174172
175173 // for testing
176174 JITEventListener *JITEventListener::createIntelJITEventListener(
177175 IntelJITEventsWrapper* TestImpl) {
178 return new IntelJITEventListener(*TestImpl);
176 return new IntelJITEventListener(TestImpl);
179177 }
180178
181179 } // namespace llvm
7979 EXPECT_TRUE(0 != MockWrapper);
8080
8181 Listener.reset(JITEventListener::createIntelJITEventListener(
82 MockWrapper.get()));
82 MockWrapper.take()));
8383 EXPECT_TRUE(0 != Listener);
8484 EE->RegisterJITEventListener(Listener.get());
8585 }