harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r543437 - in /harmony/enhanced/drlvm/trunk/vm/em/src: EBProfileCollector.cpp EBProfileCollector.h EdgeProfileCollector.cpp EdgeProfileCollector.h NValueProfileCollector.cpp NValueProfileCollector.h
Date Fri, 01 Jun 2007 09:09:56 GMT
Author: varlax
Date: Fri Jun  1 02:09:55 2007
New Revision: 543437

URL: http://svn.apache.org/viewvc?view=rev&rev=543437
Log:
Applied HARMONY-4000 drlvm][em] DRLEM profile collectors code to access method profiles is
not thread safe 

Modified:
    harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.h
    harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.h
    harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp?view=diff&rev=543437&r1=543436&r2=543437
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp Fri Jun  1 02:09:55 2007
@@ -116,11 +116,14 @@
 }
 
 MethodProfile* EBProfileCollector::getMethodProfile(Method_Handle mh) const {
-     EBProfilesMap::const_iterator it = profilesByMethod.find(mh);
-     if (it == profilesByMethod.end()) {
-        return NULL;
-     }
-     return it->second;
+    hymutex_lock(&profilesLock);
+    MethodProfile* res = NULL;
+    EBProfilesMap::const_iterator it = profilesByMethod.find(mh);
+    if (it != profilesByMethod.end()) {
+        res = it->second;
+    }
+    hymutex_unlock(&profilesLock);
+    return res;
 }
 
 EBMethodProfile* EBProfileCollector::createProfile(Method_Handle mh) {

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.h?view=diff&rev=543437&r1=543436&r2=543437
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.h Fri Jun  1 02:09:55 2007
@@ -88,7 +88,7 @@
 
     // preallocated mem for temporary (method-local) needs
     std::vector<EBMethodProfile*> tmpProfiles;
-    hymutex_t profilesLock;
+    mutable hymutex_t profilesLock;
 };
 
 class EBMethodProfile : public MethodProfile {

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp?view=diff&rev=543437&r1=543436&r2=543437
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp Fri Jun  1 02:09:55 2007
@@ -119,11 +119,14 @@
 
 MethodProfile* EdgeProfileCollector::getMethodProfile(Method_Handle mh) const
 {
+    hymutex_lock(&profilesLock);
+    MethodProfile* res = NULL;
     EdgeProfilesMap::const_iterator it = profilesByMethod.find(mh);
-    if (it == profilesByMethod.end()) {
-        return NULL;
+    if (it != profilesByMethod.end()) {
+        res = it->second;    
     }
-    return it->second;
+    hymutex_unlock(&profilesLock);
+    return res;
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.h?view=diff&rev=543437&r1=543436&r2=543437
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.h Fri Jun  1 02:09:55 2007
@@ -64,7 +64,7 @@
     std::vector<EdgeMethodProfile*> greenProfiles;
     std::vector<EdgeMethodProfile*> newProfiles;
     std::vector<EdgeMethodProfile*> tmpProfiles;
-    hymutex_t profilesLock;
+    mutable hymutex_t profilesLock;
 };
 
 class EdgeMethodProfile : public MethodProfile {

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp?view=diff&rev=543437&r1=543436&r2=543437
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp Fri Jun  1 02:09:55
2007
@@ -127,7 +127,6 @@
 {
     hymutex_lock(&profilesLock);
     ValueMethodProfile* profile = new ValueMethodProfile(this, mh);
-    VPInstructionProfileData* vpmap = new VPInstructionProfileData[numkeys];
     // Allocate space for value maps
     for (uint32 index = 0; index < numkeys; index++){
         VPInstructionProfileData* profileData = new VPInstructionProfileData();
@@ -143,7 +142,8 @@
                 (profileData->TNV_clear_part[i]).value = 0;
             }
         }
-        (profile->ValueMap)[keys[index]] = profileData;
+        uint32 key = keys[index];
+        (profile->ValueMap)[key] = profileData;
     }
     assert(profilesByMethod.find(mh) == profilesByMethod.end());
     profilesByMethod[mh] = profile;
@@ -209,7 +209,9 @@
 {
     POINTER_SIZE_INT curr_value = valueToAdd;
     lockProfile();
-    VPInstructionProfileData* _temp_vp = ValueMap[instructionKey];
+    VPDataMap::const_iterator it =  ValueMap.find(instructionKey);
+    assert(it != ValueMap.end());
+    VPInstructionProfileData* _temp_vp = it->second;
     POINTER_SIZE_INT* last_value = &(_temp_vp->last_value);
     uint32* profile_tick = &(_temp_vp->profile_tick);
     uint32* num_times_profiled = &(_temp_vp->num_times_profiled);
@@ -238,9 +240,14 @@
 POINTER_SIZE_INT ValueMethodProfile::getResult(uint32 instructionKey)
 {
     lockProfile();
-    VPInstructionProfileData* _temp_vp = ValueMap[instructionKey];
+    VPDataMap::const_iterator it =  ValueMap.find(instructionKey);
+    if (it == ValueMap.end()) {
+        unlockProfile();
+        return 0;
+    }
+    VPInstructionProfileData* _temp_vp = it->second;
+    assert(_temp_vp);
     if (_temp_vp == NULL) {
-        assert(0);
         unlockProfile();
         return 0;
     }
@@ -262,7 +269,7 @@
 
 void ValueMethodProfile::dumpValues(std::ostream& os)
 {
-    std::map<uint32, VPInstructionProfileData*>::const_iterator mapIter;
+    VPDataMap::const_iterator mapIter;
     assert(pc->type == EM_PCTYPE_VALUE);
     lockProfile();
     os << "===== Value profile dump, " << ValueMap.size() << " element(s)
===" << std::endl;
@@ -314,11 +321,14 @@
 
 MethodProfile* ValueProfileCollector::getMethodProfile(Method_Handle mh) const
 {
+    MethodProfile* res = NULL;
+    hymutex_lock(&profilesLock);
     ValueProfilesMap::const_iterator it = profilesByMethod.find(mh);
-    if (it == profilesByMethod.end()) {
-        return NULL;
+    if (it != profilesByMethod.end()) {
+        res =  it->second;
     }
-    return it->second;
+    hymutex_unlock(&profilesLock);
+    return res;
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h?view=diff&rev=543437&r1=543436&r2=543437
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h Fri Jun  1 02:09:55 2007
@@ -69,7 +69,7 @@
     bool   loggingEnabled;
     typedef std::map<Method_Handle, ValueMethodProfile*> ValueProfilesMap;
     ValueProfilesMap profilesByMethod;
-    hymutex_t profilesLock;
+    mutable hymutex_t profilesLock;
 };
 
 class VPInstructionProfileData
@@ -85,9 +85,10 @@
     uint32 profile_tick;
 };
 
+typedef std::map<uint32, VPInstructionProfileData*> VPDataMap;
 class ValueMethodProfile : public MethodProfile {
 public:
-    std::map<uint32, VPInstructionProfileData*> ValueMap;
+    VPDataMap ValueMap;
 public:
     ValueMethodProfile(ValueProfileCollector* pc, Method_Handle mh);
     ~ValueMethodProfile();



Mime
View raw message