gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/vm/ASHandlers.cpp server...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/vm/ASHandlers.cpp server...
Date: Mon, 16 Jun 2008 12:23:07 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/06/16 12:23:07

Modified files:
        .              : ChangeLog 
        server/vm      : ASHandlers.cpp ActionExec.cpp ActionExec.h 

Log message:
                * server/vm/ASHandlers.cpp: minor cleanups.
                * server/vm/ActionExec.{cpp,h}: drop _function_var member as it 
can be
                  retrieved inexpensively from _func on the few occasions when 
it's
                  needed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6940&r2=1.6941
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.250&r2=1.251
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.cpp?cvsroot=gnash&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.h?cvsroot=gnash&r1=1.35&r2=1.36

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6940
retrieving revision 1.6941
diff -u -b -r1.6940 -r1.6941
--- ChangeLog   16 Jun 2008 11:16:09 -0000      1.6940
+++ ChangeLog   16 Jun 2008 12:23:05 -0000      1.6941
@@ -1,3 +1,10 @@
+2008-06-16 Benjamin Wolsey <address@hidden>
+
+       * server/vm/ASHandlers.cpp: minor cleanups.
+       * server/vm/ActionExec.{cpp,h}: drop _function_var member as it can be
+         retrieved inexpensively from _func on the few occasions when it's
+         needed.
+
 2008-06-16 Sandro Santilli <address@hidden>
 
        * libmedia/MediaParser.{cpp,h}: move _bytesLoaded to superclass, don't
@@ -27,7 +34,7 @@
        * server/asobj/NetStreamFfmpeg.{cpp,h}: push time *ahead* to decoded
          audio queue.
 
-2008-06-15 Benjamin Wolsey <address@hidden>
+2008-06-16 Benjamin Wolsey <address@hidden>
 
        * server/vm/ASHandlers.{cpp,h}: use std::string instead of C strings
          for CommonGetUrl (saves converting back and forth several times).

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -b -r1.250 -r1.251
--- server/vm/ASHandlers.cpp    16 Jun 2008 08:50:21 -0000      1.250
+++ server/vm/ASHandlers.cpp    16 Jun 2008 12:23:06 -0000      1.251
@@ -596,7 +596,7 @@
     
     // Will abort if code.read_string returns 0, but action
     // buffer should always have a null terminator at the
-    // end.
+    // end. This replaces an assertion in CommonGetUrl.
     const std::string target(code.read_string(pc + 3 + urlLength));
 
     IF_VERBOSE_ACTION (
@@ -2540,8 +2540,8 @@
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
     size_t pc = thread.getCurrentPC();
-    size_t& next_pc = thread.next_pc;
-    size_t& stop_pc = thread.stop_pc;
+    size_t next_pc = thread.next_pc;
+    size_t stop_pc = thread.stop_pc;
 
     assert(thread.atActionTag(SWF::ACTION_BRANCHIFTRUE));
 

Index: server/vm/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- server/vm/ActionExec.cpp    13 Jun 2008 13:42:41 -0000      1.81
+++ server/vm/ActionExec.cpp    16 Jun 2008 12:23:07 -0000      1.82
@@ -33,10 +33,7 @@
 #include "ASHandlers.h"
 #include "as_environment.h"
 #include "debugger.h"
-#include "WallClockTimer.h"
-
-#include <typeinfo>
-#include <boost/algorithm/string/case_conv.hpp>
+//#include "WallClockTimer.h" // will probably be used for scriptTimeout
 
 #include <sstream>
 #include <string>
@@ -72,15 +69,14 @@
     with_stack(),
     _scopeStack(func.getScopeStack()),
     // See comment in header
-    _with_stack_limit(7),
-    _function_var(func.isFunction2() ? 2 : 1),
+    _withStackLimit(7),
     _func(&func),
     _this_ptr(this_ptr),
-    _initial_stack_size(0),
+    _initialStackSize(0),
     _initialCallStackDepth(0),
-    _original_target(0),
+    _originalTarget(0),
     _tryList(),
-    mReturning(false),
+    _returning(false),
     _abortOnUnload(false),
     code(func.getActionBuffer()),
     env(newEnv),
@@ -91,11 +87,9 @@
 {
     assert(stop_pc < code.size());
 
-    //GNASH_REPORT_FUNCTION;
-
     // See comment in header
     if ( env.get_version() > 5 ) {
-        _with_stack_limit = 15;
+        _withStackLimit = 15;
     }
 
     // SWF version 6 and higher pushes the activation object to the scope stack
@@ -114,14 +108,13 @@
     :
     with_stack(),
     _scopeStack(), // TODO: initialize the scope stack somehow
-    _with_stack_limit(7),
-    _function_var(0),
+    _withStackLimit(7),
     _func(NULL),
-    _initial_stack_size(0),
+    _initialStackSize(0),
     _initialCallStackDepth(0),
-    _original_target(0),
+    _originalTarget(0),
     _tryList(),
-    mReturning(false),
+    _returning(false),
     _abortOnUnload(abortOnUnloaded),
     code(abuf),
     env(newEnv),
@@ -134,7 +127,7 @@
 
     /// See comment in header
     if ( env.get_version() > 5 ) {
-        _with_stack_limit = 15;
+        _withStackLimit = 15;
     }
 }
 
@@ -142,21 +135,14 @@
 ActionExec::operator() ()
 {
 
-#if 0
-    // Check the time
-    if (periodic_events.expired()) {
-    periodic_events.poll_event_handlers(&env);
-    }
-#endif
-
     // Do not execute if scripts are disabled
     if ( VM::get().getRoot().scriptsDisabled() ) return;
 
     static const SWF::SWFHandlers& ash = SWF::SWFHandlers::instance();
         
-    _original_target = env.get_target();
+    _originalTarget = env.get_target();
 
-    _initial_stack_size = env.stack_size();
+    _initialStackSize = env.stack_size();
 
     _initialCallStackDepth = env.callStackDepth();
 
@@ -177,10 +163,7 @@
     // TODO: specify in the .gnashrc !!
     static const size_t maxBranchCount = 65536; // what's enough ?
 
-#if 0
-    boost::uint32_t timeLimit = getScriptTimeout();
-#endif
-    WallClockTimer timer;
+    //WallClockTimer timer;
 
     // stop_pc: set to the code boundary at which we should check
     // for exceptions. If there is no exception in a TryBlock, it
@@ -261,7 +244,8 @@
                     log_swferror(_("Length %u (%d) of action tag"
                                    " id %u at pc %d"
                                    " overflows actions buffer size %d"),
-                      length, (int)length, (unsigned)action_id, pc,
+                      length, static_cast<int>(length),
+                      static_cast<unsigned>(action_id), pc,
                       stop_pc);
                     );
                     
@@ -289,7 +273,7 @@
 
             #if 0
                 // curveball.swf and feed.swf break with this
-                character* guardedChar = env.get_original_target(); // watch 
out : _original_target is not necessarely the same
+                character* guardedChar = env.get_original_target(); // watch 
out : _originalTarget is not necessarely the same
             #else
                 // curveball.swf and feed.swf suggest that it is the *current* 
target,
                 // not the *original* one that matters.
@@ -578,7 +562,7 @@
             _tryList.pop_back();
             
             // Will break of of action execution.
-            if (mReturning) return false;
+            if (_returning) return false;
                    
             break;
         }
@@ -592,51 +576,58 @@
 void
 ActionExec::cleanupAfterRun(bool expectInconsistencies)
 {
-    assert(_original_target);
-    env.set_target(_original_target);
-    _original_target = NULL;
+    assert(_originalTarget);
+    env.set_target(_originalTarget);
+    _originalTarget = NULL;
 
     // check if the stack was smashed
-    if ( _initial_stack_size > env.stack_size() ) {
+    if ( _initialStackSize > env.stack_size() )
+    {
     log_error(_("Stack smashed (ActionScript compiler bug?)."
             "Fixing by pushing undefined values to the missing slots, "
             " but don't expect things to work afterwards"));
-    size_t missing = _initial_stack_size - env.stack_size();
-    for (size_t i=0; i<missing; ++i) {
+        const size_t missing = _initialStackSize - env.stack_size();
+
+        for (size_t i = 0; i < missing; ++i)
+        {
         env.push(as_value());
     }
-    } else if ( _initial_stack_size < env.stack_size() ) {
+    }
+    else if ( _initialStackSize < env.stack_size() )
+    {
         if ( ! expectInconsistencies )
         {
     // We can argue this would be an "size-optimized" SWF instead...
     IF_VERBOSE_MALFORMED_SWF(
         log_swferror(_("%d elements left on the stack after block execution.  "
-            "Cleaning up"), env.stack_size()-_initial_stack_size);
+                "Cleaning up"), env.stack_size() - _initialStackSize);
         );
         }
-    env.drop(env.stack_size()-_initial_stack_size);
+        env.drop(env.stack_size() - _initialStackSize);
     }
 
     // Have movie_root flush any newly pushed actions in higher priority queues
     VM::get().getRoot().flushHigherPriorityActionQueues();
 
-    //log_debug("After cleanup of ActionExec %p, env %p has stack size of %d 
and callStackDepth of %d", (void*)this, (void*)&env, env.stack_size(), 
env.callStackDepth());
+//    log_debug("After cleanup of ActionExec %p, env %p has "
+//        "stack size of %d and callStackDepth of %d",
+//        (void*)this, (void*)&env, env.stack_size(), env.callStackDepth());
 }
 
 void
 ActionExec::skip_actions(size_t offset)
 {
-    //pc = next_pc;
 
-    for(size_t i=0; i<offset; ++i) {
+    for(size_t i=0; i<offset; ++i)
+    {
 #if 1
         // we need to check at every iteration because
         // an action can be longer then a single byte
-        if ( next_pc >= stop_pc ) {
+        if ( next_pc >= stop_pc )
+        {
         IF_VERBOSE_MALFORMED_SWF (
         log_swferror(_("End of DoAction block hit while skipping "
-              "%d action tags (pc:%d"
-              ", stop_pc:%d) "
+                  "%d action tags (pc:%d, stop_pc:%d) "
               "(WaitForFrame, probably)"), offset, next_pc,
               stop_pc);
         )
@@ -650,32 +641,33 @@
 
         // Set default next_pc offset, control flow action handlers
         // will be able to reset it.
-        if ((action_id & 0x80) == 0) {
+        if ((action_id & 0x80) == 0)
+        {
         // action with no extra data
         next_pc++;
-        } else {
+        }
+        else
+        {
         // action with extra data
         boost::int16_t length = code.read_int16(next_pc+1);
         assert( length >= 0 );
         next_pc += length + 3;
         }
-
-        //pc = next_pc;
     }
 }
 
 bool
 ActionExec::pushWithEntry(const with_stack_entry& entry)
 {
-    // See comment in header about _with_stack_limit
-    if (with_stack.size() >= _with_stack_limit)
+    // See comment in header about _withStackLimit
+    if (with_stack.size() >= _withStackLimit)
     {
         IF_VERBOSE_ASCODING_ERRORS (
         log_aserror(_("'With' stack depth (%d) "
             "exceeds the allowed limit for current SWF "
             "target version (%d for version %d)."
             " Don't expect this movie to work with all players."),
-            with_stack.size()+1, _with_stack_limit,
+            with_stack.size()+1, _withStackLimit,
             env.get_version());
         );
         return false;
@@ -749,7 +741,7 @@
 void
 ActionExec::fixStackUnderrun(size_t required)
 {
-    size_t slots_left = env.stack_size() - _initial_stack_size;
+    size_t slots_left = env.stack_size() - _initialStackSize;
     size_t missing = required-slots_left;
 
     // FIXME, the IF_VERBOSE used to be commented out.  strk, know why?
@@ -758,11 +750,11 @@
         "%d/%d available. "
         "Fixing by inserting %d undefined values on the"
         " missing slots."),
-        required, _initial_stack_size, env.stack_size(),
+        required, _initialStackSize, env.stack_size(),
         missing);
     );
 
-    env.padStack(_initial_stack_size, missing);
+    env.padStack(_initialStackSize, missing);
 }
 
 as_object*
@@ -796,7 +788,13 @@
     {
         *retval = t;
     }
-    mReturning = true;
+    _returning = true;
+}
+
+bool
+ActionExec::isFunction2() const
+{
+    return _func ? _func->isFunction2() : false;
 }
 
 void
@@ -812,7 +810,8 @@
 
         // Set default next_pc offset, control flow action handlers
         // will be able to reset it.
-        if ((action_id & 0x80) == 0) {
+        if ((action_id & 0x80) == 0)
+        {
         // action with no extra data
         lpc++;
         } else {
@@ -828,7 +827,7 @@
 as_object*
 ActionExec::getThisPointer()
 {
-    return _function_var ? _this_ptr.get() : env.get_original_target(); 
+    return _func ? _this_ptr.get() : env.get_original_target(); 
 }
 
 } // end of namespace gnash

Index: server/vm/ActionExec.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/vm/ActionExec.h      13 Jun 2008 20:06:48 -0000      1.35
+++ server/vm/ActionExec.h      16 Jun 2008 12:23:07 -0000      1.36
@@ -179,10 +179,7 @@
        /// warnings for coders (if ActionScript errors verbosity is
        /// enabled).
        ///
-       size_t _with_stack_limit;
-
-       /// 1 for function execution, 2 for function2 execution, 0 otherwise.
-       int _function_var;
+       size_t _withStackLimit;
 
        /// A pointer to the function being executed, or NULL
        /// for non-function execution
@@ -198,16 +195,16 @@
        boost::intrusive_ptr<as_object> _this_ptr;
 
        /// Stack size at start of execution
-       size_t _initial_stack_size;
+       size_t _initialStackSize;
 
        /// Call stack depth at start of execution
        size_t _initialCallStackDepth;
 
-       character* _original_target;
+       character* _originalTarget;
 
        std::list<TryBlock> _tryList;
 
-       bool mReturning;
+       bool _returning;
 
        /// Warn about a stack underrun and fix it 
        //
@@ -233,11 +230,11 @@
        ///
        void ensureStack(size_t required)
        {
-               // The stack_size() < _initial_stack_size case should
+               // The stack_size() < _initialStackSize case should
                // be handled this by stack smashing checks
-               assert( env.stack_size() >= _initial_stack_size );
+               assert( env.stack_size() >= _initialStackSize );
 
-               size_t slots_left = env.stack_size() - _initial_stack_size;
+               size_t slots_left = env.stack_size() - _initialStackSize;
                if ( slots_left < required )
                {
                        fixStackUnderrun(required);
@@ -293,10 +290,10 @@
        ActionExec(const swf_function& func, as_environment& newEnv, as_value* 
nRetVal, as_object* this_ptr);
 
        /// Is this execution thread a function2 call ?
-       bool isFunction2() { return _function_var == 2; }
+       bool isFunction2() const;
 
        /// Is this execution thread a function call ?
-       bool isFunction() { return _function_var!=0; }
+       bool isFunction() const { return _func != 0; }
 
        /// Get the current 'this' pointer, for use in function calls
        as_object* getThisPointer();
@@ -322,7 +319,7 @@
        ///
        size_t getWithStackLimit() const 
        {
-               return _with_stack_limit;
+               return _withStackLimit;
        }
 
        /// Push an entry to the with stack




reply via email to

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