Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: src/IceGlobalContext.cpp

Issue 1867473002: Subzero: Fix -timing-focus . (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===// 1 //===- subzero/src/IceGlobalContext.cpp - Global context defs -------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (!BuildDefs::timers()) 880 if (!BuildDefs::timers())
881 return 0; 881 return 0;
882 auto Timers = getTimers(); 882 auto Timers = getTimers();
883 TimerStackIdT NewID = Timers->size(); 883 TimerStackIdT NewID = Timers->size();
884 Timers->push_back(TimerStack(Name)); 884 Timers->push_back(TimerStack(Name));
885 return NewID; 885 return NewID;
886 } 886 }
887 887
888 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID, 888 TimerIdT GlobalContext::getTimerID(TimerStackIdT StackID,
889 const std::string &Name) { 889 const std::string &Name) {
890 auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers; 890 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
891 assert(StackID < Timers->size()); 891 assert(StackID < Timers->size());
892 return Timers->at(StackID).getTimerID(Name); 892 return Timers->at(StackID).getTimerID(Name);
893 } 893 }
894 894
895 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) { 895 void GlobalContext::pushTimer(TimerIdT ID, TimerStackIdT StackID) {
896 auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers; 896 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
897 assert(StackID < Timers->size()); 897 assert(StackID < Timers->size());
898 Timers->at(StackID).push(ID); 898 Timers->at(StackID).push(ID);
899 } 899 }
900 900
901 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) { 901 void GlobalContext::popTimer(TimerIdT ID, TimerStackIdT StackID) {
902 auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers; 902 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
903 assert(StackID < Timers->size()); 903 assert(StackID < Timers->size());
904 Timers->at(StackID).pop(ID); 904 Timers->at(StackID).pop(ID);
905 } 905 }
906 906
907 void GlobalContext::resetTimer(TimerStackIdT StackID) { 907 void GlobalContext::resetTimer(TimerStackIdT StackID) {
908 auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers; 908 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
909 assert(StackID < Timers->size()); 909 assert(StackID < Timers->size());
910 Timers->at(StackID).reset(); 910 Timers->at(StackID).reset();
911 } 911 }
912 912
913 std::string GlobalContext::getTimerName(TimerStackIdT StackID) {
914 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
915 assert(StackID < Timers->size());
916 return Timers->at(StackID).getName();
917 }
918
913 void GlobalContext::setTimerName(TimerStackIdT StackID, 919 void GlobalContext::setTimerName(TimerStackIdT StackID,
914 const std::string &NewName) { 920 const std::string &NewName) {
915 auto Timers = &ICE_TLS_GET_FIELD(TLS)->Timers; 921 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
916 assert(StackID < Timers->size()); 922 assert(StackID < Timers->size());
917 Timers->at(StackID).setName(NewName); 923 Timers->at(StackID).setName(NewName);
918 } 924 }
919 925
920 // Note: optQueueBlockingPush and optQueueBlockingPop use unique_ptr at the 926 // Note: optQueueBlockingPush and optQueueBlockingPop use unique_ptr at the
921 // interface to take and transfer ownership, but they internally store the raw 927 // interface to take and transfer ownership, but they internally store the raw
922 // Cfg pointer in the work queue. This allows e.g. future queue optimizations 928 // Cfg pointer in the work queue. This allows e.g. future queue optimizations
923 // such as the use of atomics to modify queue elements. 929 // such as the use of atomics to modify queue elements.
924 void GlobalContext::optQueueBlockingPush(std::unique_ptr<OptWorkItem> Item) { 930 void GlobalContext::optQueueBlockingPush(std::unique_ptr<OptWorkItem> Item) {
925 assert(Item); 931 assert(Item);
(...skipping 29 matching lines...) Expand all
955 void GlobalContext::dumpStats(const Cfg *Func) { 961 void GlobalContext::dumpStats(const Cfg *Func) {
956 if (!getFlags().getDumpStats()) 962 if (!getFlags().getDumpStats())
957 return; 963 return;
958 if (Func == nullptr) { 964 if (Func == nullptr) {
959 getStatsCumulative()->dump(Func, this); 965 getStatsCumulative()->dump(Func, this);
960 } else { 966 } else {
961 ICE_TLS_GET_FIELD(TLS)->StatsFunction.dump(Func, this); 967 ICE_TLS_GET_FIELD(TLS)->StatsFunction.dump(Func, this);
962 } 968 }
963 } 969 }
964 970
965 void GlobalContext::mergeTimersFromTLS() {
966 getTimers()->mergeFrom(ICE_TLS_GET_FIELD(TLS)->Timers);
967 }
968
969 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { 971 void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
970 if (!BuildDefs::timers()) 972 if (!BuildDefs::timers())
971 return; 973 return;
972 auto Timers = getTimers(); 974 auto Timers = getTimers();
973 assert(Timers->size() > StackID); 975 assert(Timers->size() > StackID);
974 OstreamLocker L(this); 976 OstreamLocker L(this);
975 Timers->at(StackID).dump(getStrDump(), DumpCumulative); 977 Timers->at(StackID).dump(getStrDump(), DumpCumulative);
976 } 978 }
977 979
980 void GlobalContext::dumpLocalTimers(const std::string &TimerNameOverride,
981 TimerStackIdT StackID,
982 bool DumpCumulative) {
983 if (!BuildDefs::timers())
984 return;
985 auto *Timers = &ICE_TLS_GET_FIELD(TLS)->Timers;
986 assert(Timers->size() > StackID);
987 // Temporarily override the thread-local timer name with the given name.
988 // Don't do it permanently because the final timer merge at the end expects
989 // the thread-local timer names to be the same as the global timer name.
990 auto OrigName = getTimerName(StackID);
991 setTimerName(StackID, TimerNameOverride);
992 {
993 OstreamLocker _(this);
994 Timers->at(StackID).dump(getStrDump(), DumpCumulative);
995 }
996 setTimerName(StackID, OrigName);
997 }
998
978 LockedPtr<StringPool> 999 LockedPtr<StringPool>
979 GlobalStringPoolTraits::getStrings(const GlobalContext *PoolOwner) { 1000 GlobalStringPoolTraits::getStrings(const GlobalContext *PoolOwner) {
980 return PoolOwner->getStrings(); 1001 return PoolOwner->getStrings();
981 } 1002 }
982 1003
983 TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx, 1004 TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx,
984 const std::string &FuncName) { 1005 const std::string &FuncName) {
985 if (!BuildDefs::timers()) 1006 if (!BuildDefs::timers())
986 return 0; 1007 return 0;
987 if (!getFlags().getTimeEachFunction()) 1008 if (!getFlags().getTimeEachFunction())
(...skipping 20 matching lines...) Expand all
1008 void TimerMarker::pushCfg(const Cfg *Func) { 1029 void TimerMarker::pushCfg(const Cfg *Func) {
1009 Ctx = Func->getContext(); 1030 Ctx = Func->getContext();
1010 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled(); 1031 Active = Func->getFocusedTiming() || getFlags().getSubzeroTimingEnabled();
1011 if (Active) 1032 if (Active)
1012 Ctx->pushTimer(ID, StackID); 1033 Ctx->pushTimer(ID, StackID);
1013 } 1034 }
1014 1035
1015 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS); 1036 ICE_TLS_DEFINE_FIELD(GlobalContext::ThreadContext *, GlobalContext, TLS);
1016 1037
1017 } // end of namespace Ice 1038 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceGlobalContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698