gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, objecturi, updated. a0f2a194599a84598


From: Sandro Santilli
Subject: [Gnash-commit] [SCM] Gnash branch, objecturi, updated. a0f2a194599a84598b58312e30df108a051903be
Date: Thu, 23 Sep 2010 08:07:29 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, objecturi has been updated
       via  a0f2a194599a84598b58312e30df108a051903be (commit)
       via  4290cea040bbe227b55c072e3e0af4377bc69a5a (commit)
       via  e0f194e3863800390c85089443f1e4bd2c72b5c5 (commit)
       via  4cba3502445feb647d80df353d4cb64b67921aad (commit)
       via  4d36bb5aa21ace862d926b97ee980c5f042a4682 (commit)
      from  2b517c88e595102b1abd98aff9b5426d6dc73ae1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=a0f2a194599a84598b58312e30df108a051903be


commit a0f2a194599a84598b58312e30df108a051903be
Author: Sandro Santilli <address@hidden>
Date:   Thu Sep 23 10:07:07 2010 +0200

    Add stats debugging for PropertyList lookups

diff --git a/libcore/PropertyList.cpp b/libcore/PropertyList.cpp
index 103d52b..7ac2f76 100644
--- a/libcore/PropertyList.cpp
+++ b/libcore/PropertyList.cpp
@@ -37,6 +37,15 @@
 // Define this to get verbosity of properties insertion and flags setting
 //#define GNASH_DEBUG_PROPERTY 1
 
+// Define this to get stats of property lookups 
+#define GNASH_STATS_PROPERTY_LOOKUPS 1
+
+
+#ifdef GNASH_STATS_PROPERTY_LOOKUPS
+# include "Stats.h"
+# include "namedStrings.h"
+#endif
+
 namespace gnash {
 
 namespace {
@@ -119,6 +128,12 @@ PropertyList::setFlagsAll(int setFlags, int clearFlags)
 Property*
 PropertyList::getProperty(const ObjectURI& uri) const
 {
+#ifdef GNASH_STATS_PROPERTY_LOOKUPS
+    // HINT: can add a final arg to KeyLookup ctor, like 
NSV::PROP_ON_MOUSE_MOVE
+    //       to have *that* property lookup drive dump triggers
+    static stats::KeyLookup kcl("getProperty", getStringTable(_owner), 10000);
+    kcl.check(uri.name);
+#endif // GNASH_STATS_PROPERTY_LOOKUPS
        iterator found = iterator_find(_props, uri, getVM(_owner));
        if (found == _props.end()) return 0;
        return const_cast<Property*>(&(found->first));

http://git.savannah.gnu.org/cgit//commit/?id=4290cea040bbe227b55c072e3e0af4377bc69a5a


commit 4290cea040bbe227b55c072e3e0af4377bc69a5a
Author: Sandro Santilli <address@hidden>
Date:   Thu Sep 23 10:01:14 2010 +0200

    Use the generic KeyLookup stats class for stats gathering, raise checkpoint 
string_table size stats printing

diff --git a/libbase/string_table.cpp b/libbase/string_table.cpp
index 5e57e44..0d3d1b6 100644
--- a/libbase/string_table.cpp
+++ b/libbase/string_table.cpp
@@ -24,44 +24,11 @@
 //#define GNASH_PARANOIA_LEVEL 3
 
 #ifdef DEBUG_STRING_TABLE
-# include <iostream>
-# include <iomanip>
+# include "Stats.h"
 #endif
 
 namespace gnash {
 
-#ifdef DEBUG_STRING_TABLE
-    namespace {
-    class KeyCaseLookup {
-        typedef std::map<string_table::key, unsigned long int> Stat;
-        Stat stat;
-        const string_table* _st;
-    public:
-        KeyCaseLookup(const string_table* st) : _st(st) {}
-
-        void check(string_table::key k) {
-            ++stat[k];
-        }
-        ~KeyCaseLookup(){ 
-            typedef std::map<unsigned long int, string_table::key> Sorted;
-            Sorted sorted;
-            for (Stat::iterator i=stat.begin(), e=stat.end(); i!=e; ++i)
-                sorted[i->second] = i->first;
-            for (Sorted::reverse_iterator i=sorted.rbegin(), e=sorted.rend();
-                    i!=e; ++i)
-                std::cerr
-                          << std::setw(10)
-                          << i->first
-                          << ":"
-                          << _st->value(i->second) << "("
-                          << i->second << ")"
-                          << std::endl;
-        }
-    };
-    } // namespace anonymous
-#endif // DEBUG_STRING_TABLE
-
-
 const std::string string_table::_empty;
 
 string_table::key
@@ -132,7 +99,7 @@ string_table::already_locked_insert(const std::string& 
to_insert)
        const key ret = _table.insert(svt(to_insert, ++_highestKey)).first->id;
 
 #ifdef DEBUG_STRING_TABLE
-    int tscp = 20; // table size checkpoint
+    int tscp = 100; // table size checkpoint
     size_t ts = _table.size();
     if ( ! (ts % tscp) ) { std::cerr << "string_table size grew to " << ts << 
std::endl; }
 #endif
@@ -172,7 +139,7 @@ string_table::key
 string_table::noCase(key a) const
 {
 #ifdef DEBUG_STRING_TABLE
-    static KeyCaseLookup kcl(this);
+    static stats::KeyLookup kcl("string_table::noCase(maplookups)", *this);
 #endif // DEBUG_STRING_TABLE
 
     // Avoid checking keys known to be lowercase

http://git.savannah.gnu.org/cgit//commit/?id=e0f194e3863800390c85089443f1e4bd2c72b5c5


commit e0f194e3863800390c85089443f1e4bd2c72b5c5
Author: Sandro Santilli <address@hidden>
Date:   Thu Sep 23 10:00:31 2010 +0200

    Add class to help gathering stats about key lookups

diff --git a/libbase/Makefile.am b/libbase/Makefile.am
index bd79907..0f962e2 100644
--- a/libbase/Makefile.am
+++ b/libbase/Makefile.am
@@ -194,6 +194,7 @@ endif
 
 EXTENSIONS_API = \
        StringPredicates.h \
+       Stats.h \
        FileTypes.h \
        smart_ptr.h \
        string_table.h \
diff --git a/libbase/Stats.h b/libbase/Stats.h
new file mode 100644
index 0000000..eac2395
--- /dev/null
+++ b/libbase/Stats.h
@@ -0,0 +1,97 @@
+// Stats.h -- classes for generic statistics gathering
+// 
+//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+//   Foundation, Inc
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+#include <map>
+#include <iostream>
+#include <iomanip>
+
+#include "string_table.h"
+
+namespace gnash {
+namespace stats {
+
+class KeyLookup {
+
+    typedef std::map<string_table::key, unsigned long int> Stat;
+
+public:
+
+    /// @param label The label to print for dumps of this stat
+    /// @param st The string table to use for resolving stats values
+    /// @param dumpTrigger The number of calls to check() that should be
+    ///                    triggering a dump
+    /// @param restrict If non-zero dumpTrigger refers to this key lookups
+    /// @param dumpCount Number of items to print in the dump (makes sense if 
not restricted)
+    ///
+    KeyLookup(const std::string& label, const string_table& st, int 
dumpTrigger=0,
+            string_table::key restrict=0, int dumpCount=5)
+        :
+        _st(st),
+        _dumpCount(dumpCount),
+        _dumpTrigger(dumpTrigger),
+        _label(label),
+        _restrict(restrict)
+    {}
+
+    ~KeyLookup()
+    {
+        dump(_dumpCount);
+    }
+
+    void check(string_table::key k) {
+        int gotTo = ++stat[k];
+        if ( _restrict && k != _restrict ) return;
+        if ( ! _dumpTrigger ) return;
+        if ( ! ( gotTo % _dumpTrigger ) ) dump(_dumpCount);
+    }
+
+    void dump(int count) {
+        typedef std::map<unsigned long int, string_table::key> Sorted;
+        Sorted sorted;
+        for (Stat::iterator i=stat.begin(), e=stat.end(); i!=e; ++i)
+            sorted[i->second] = i->first;
+        std::cerr << _label << " lookups: " << std::endl;
+        for (Sorted::reverse_iterator i=sorted.rbegin(), e=sorted.rend();
+                i!=e; ++i) {
+            std::cerr
+                      << std::setw(10)
+                      << i->first
+                      << ":"
+                      << _st.value(i->second) << "("
+                      << i->second << ")"
+                      << std::endl;
+            if ( ! --count ) break;
+        }
+    }
+
+private:
+
+    Stat stat;
+    const string_table& _st;
+    int _dumpCount;
+    int _dumpTrigger;
+    std::string _label;
+    string_table::key _restrict;
+
+
+};
+
+} // namespace gnash.stats
+} // namespace gnash

http://git.savannah.gnu.org/cgit//commit/?id=4cba3502445feb647d80df353d4cb64b67921aad


commit 4cba3502445feb647d80df353d4cb64b67921aad
Author: Sandro Santilli <address@hidden>
Date:   Thu Sep 23 09:15:42 2010 +0200

    Port BroadcasterVisitor to ObjectURI, to cache caseless keys during 
broadcasts

diff --git a/libcore/asobj/AsBroadcaster.cpp b/libcore/asobj/AsBroadcaster.cpp
index 4d4aece..a6fb847 100644
--- a/libcore/asobj/AsBroadcaster.cpp
+++ b/libcore/asobj/AsBroadcaster.cpp
@@ -26,6 +26,15 @@
 #include "NativeFunction.h" 
 #include "Global_as.h"
 #include "namedStrings.h"
+#include "ObjectURI.h"
+
+//#define GNASH_DEBUG_BROADCASTER 1
+
+#ifdef GNASH_DEBUG_BROADCASTER
+# include <iostream>
+# include <iomanip>
+# include <map>
+#endif
 
 namespace gnash {
 
@@ -42,6 +51,36 @@ namespace {
 /// Helper for notifying listeners
 namespace {
 
+#ifdef GNASH_DEBUG_BROADCASTER
+struct BroadcasterStats {
+    typedef std::map<string_table::key, unsigned long int> Stat;
+    Stat stat;
+    const string_table& _st;
+    BroadcasterStats(const string_table& st) : _st(st) {}
+    void check(string_table::key k) {
+        if ( ! (++stat[k] % 100) ) dump();
+    }
+    void dump() {
+        using namespace std;
+        typedef std::map<unsigned long int, string_table::key> Sorted;
+        Sorted sorted;
+        for (Stat::iterator i=stat.begin(), e=stat.end(); i!=e; ++i)
+            sorted[i->second] = i->first;
+        cerr << "Broadcaster stats follow:" << endl;
+        for (Sorted::reverse_iterator i=sorted.rbegin(), e=sorted.rend();
+                i!=e; ++i)
+            std::cerr
+                      << std::setw(10)
+                      << i->first
+                      << ":"
+                      << _st.value(i->second) << "("
+                      << i->second << ")"
+                      << std::endl;
+        
+    }
+};
+#endif // GNASH_DEBUG_BROADCASTER
+
 class BroadcasterVisitor
 {
     
@@ -49,7 +88,7 @@ class BroadcasterVisitor
     /// appropriately cased based on SWF version
     /// of the current VM
     std::string _eventName;
-    string_table::key _eventKey;
+    const ObjectURI& _eventURI;
 
     // These two will be needed for consistency checking
     //size_t _origEnvStackSize;
@@ -68,27 +107,33 @@ public:
     ///
     BroadcasterVisitor(const fn_call& fn)
         :
-        _eventName(),
-        _eventKey(0),
+        _eventName(fn.arg(0).to_string()),
+        _eventURI(getStringTable(fn).find(_eventName)),
         _dispatched(0),
         _fn(fn)
     {
-        _eventName = fn.arg(0).to_string();
-        _eventKey = getStringTable(fn).find(_eventName);
         _fn.drop_bottom();
     }
 
     /// Call a method on the given value
     void operator()(const as_value& v)
     {
+#ifdef GNASH_DEBUG_BROADCASTER
+        static BroadcasterStats stats(getStringTable(_fn));
+#endif
+
         boost::intrusive_ptr<as_object> o = v.to_object(getGlobal(_fn));
         if ( ! o ) return;
 
+#ifdef GNASH_DEBUG_BROADCASTER
+        stats.check(_eventURI.name);
+#endif
+
         as_value method;
-        o->get_member(_eventKey, &method);
+        o->get_member(_eventURI, &method);
 
         if (method.is_function()) {
-            _fn.super = o->get_super(_eventKey);
+            _fn.super = o->get_super(_eventURI);
             _fn.this_ptr = o.get();
             method.to_function()->call(_fn);
         }
@@ -387,6 +432,10 @@ asbroadcaster_broadcastMessage(const fn_call& fn)
 
     BroadcasterVisitor visitor(fn); 
     foreachArray(*listeners, visitor);
+#ifdef GNASH_DEBUG_BROADCASTER
+    std::cerr << "BradcasterVisitor dispatched to "
+        << visitor.eventDispatched() << " listeners" << std::endl;
+#endif
 
     const size_t dispatched = visitor.eventsDispatched();
 

http://git.savannah.gnu.org/cgit//commit/?id=4d36bb5aa21ace862d926b97ee980c5f042a4682


commit 4d36bb5aa21ace862d926b97ee980c5f042a4682
Author: Sandro Santilli <address@hidden>
Date:   Thu Sep 23 06:53:03 2010 +0200

    Switch get_super over to ObjectURI, and split the version taking no arg 
from the other (the no-arg doesn't even need to be virtual)

diff --git a/libcore/as_object.cpp b/libcore/as_object.cpp
index d2d3268..df61755 100644
--- a/libcore/as_object.cpp
+++ b/libcore/as_object.cpp
@@ -143,7 +143,7 @@ public:
 
     virtual bool isSuper() const { return true; }
 
-    virtual as_object* get_super(string_table::key fname = 0);
+    virtual as_object* get_super(const ObjectURI& fname);
 
     // Fetching members from 'super' yelds a lookup on the associated prototype
     virtual bool get_member(const ObjectURI& uri, as_value* val)
@@ -194,7 +194,7 @@ private:
 };
 
 as_object*
-as_super::get_super(string_table::key fname)
+as_super::get_super(const ObjectURI& fname)
 {
     // Super references the super class of our class prototype.
     // Our class prototype is __proto__.
@@ -204,7 +204,7 @@ as_super::get_super(string_table::key fname)
     as_object* proto = get_prototype(); 
     if (!proto) return new as_super(getGlobal(*this), 0);
 
-    if (!fname || getSWFVersion(*this) <= 6) {
+    if (fname.empty() || getSWFVersion(*this) <= 6) {
         return new as_super(getGlobal(*this), proto);
     }
 
@@ -232,7 +232,6 @@ as_super::get_super(string_table::key fname)
 
 }
 
-
 /// A PropertyList visitor copying properties to an object
 class PropsCopier : public AbstractPropertyVisitor
 {
@@ -442,7 +441,7 @@ as_object::get_member(const ObjectURI& uri, as_value* val)
 
 
 as_object*
-as_object::get_super(string_table::key fname)
+as_object::get_super(const ObjectURI& fname)
 {
     // Super references the super class of our class prototype.
     // Our class prototype is __proto__.
@@ -451,7 +450,7 @@ as_object::get_super(string_table::key fname)
     // Our class prototype is __proto__.
     as_object* proto = get_prototype();
 
-    if (fname && getSWFVersion(*this) > 6) {
+    if ( ! fname.empty() && getSWFVersion(*this) > 6) {
         as_object* owner = 0;
         findProperty(fname, &owner);
         // should be 0 if findProperty returned 0
@@ -463,6 +462,16 @@ as_object::get_super(string_table::key fname)
     return super;
 }
 
+as_object*
+as_object::get_super()
+{
+    // Our class prototype is __proto__.
+    as_object* proto = get_prototype();
+    as_object* super = new as_super(getGlobal(*this), proto);
+
+    return super;
+}
+
 /*private*/
 Property*
 as_object::findProperty(const ObjectURI& uri, as_object **owner)
diff --git a/libcore/as_object.h b/libcore/as_object.h
index 71b8297..926d9de 100644
--- a/libcore/as_object.h
+++ b/libcore/as_object.h
@@ -479,7 +479,8 @@ public:
     /// itself, or __proto__.__proto__ if this is not a prototype
     /// object. This is only conceptual however, and may be more
     /// convoluted to obtain the actual super.
-    virtual as_object* get_super(string_table::key fname = 0);
+    virtual as_object* get_super(const ObjectURI& fname);
+    as_object* get_super();
 
     /// Get a member as_value by name in an AS-compatible way
     //

-----------------------------------------------------------------------

Summary of changes:
 libbase/Makefile.am             |    1 +
 libbase/Stats.h                 |   97 +++++++++++++++++++++++++++++++++++++++
 libbase/string_table.cpp        |   39 +--------------
 libcore/PropertyList.cpp        |   15 ++++++
 libcore/as_object.cpp           |   21 ++++++--
 libcore/as_object.h             |    3 +-
 libcore/asobj/AsBroadcaster.cpp |   63 ++++++++++++++++++++++---
 7 files changed, 189 insertions(+), 50 deletions(-)
 create mode 100644 libbase/Stats.h


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]