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: Thu, 12 Jun 2008 09:36:01 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/06/12 09:36:01

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

Log message:
                * server/vm/ActionExec.{h,cpp}: remove some of the debug 
logging.
                  Start making data members private and provide accessors. Drop
                  getScriptTimeout(), which should now be obtained from 
movie_root
                  when the timeout limits are implemented. 
                * server/vm/ASHandlers.cpp: use accessors rather than ActionExec
                  members directly. Delegate some operations entirely to 
ActionExec.
        
                More clean-ups and isolation of data members to come.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6906&r2=1.6907
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.243&r2=1.244
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.cpp?cvsroot=gnash&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.h?cvsroot=gnash&r1=1.31&r2=1.32

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6906
retrieving revision 1.6907
diff -u -b -r1.6906 -r1.6907
--- ChangeLog   12 Jun 2008 03:13:40 -0000      1.6906
+++ ChangeLog   12 Jun 2008 09:35:59 -0000      1.6907
@@ -1,3 +1,12 @@
+2008-06-12 Benjamin Wolsey <address@hidden>
+
+       * server/vm/ActionExec.{h,cpp}: remove some of the debug logging.
+         Start making data members private and provide accessors. Drop
+         getScriptTimeout(), which should now be obtained from movie_root
+         when the timeout limits are implemented. 
+       * server/vm/ASHandlers.cpp: use accessors rather than ActionExec
+         members directly. Delegate some operations entirely to ActionExec.
+
 2008-06-12 Zou Lunkai <address@hidden>
        
        * server/matrix.{h, cpp}: drop transform_by_inverse() and set_inverse(),

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -b -r1.243 -r1.244
--- server/vm/ASHandlers.cpp    23 May 2008 21:15:17 -0000      1.243
+++ server/vm/ASHandlers.cpp    12 Jun 2008 09:36:00 -0000      1.244
@@ -99,7 +99,7 @@
 static void unsupported_action_handler(ActionExec& thread)
 {
     log_error(_("Unsupported action handler invoked, code at pc is %#x"),
-            static_cast<int>(thread.code[thread.pc]));
+            static_cast<int>(thread.code[thread.getCurrentPC()]));
 }
 
 ActionHandler::ActionHandler()
@@ -458,12 +458,11 @@
 {
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_END );
+    assert(thread.atActionTag(SWF::ACTION_END));
 #endif
 
     log_error (_("%s: CHECKME: was broken"), __PRETTY_FUNCTION__);
-    thread.next_pc=thread.stop_pc;
+    thread.skipRemainingBuffer();
 }
 
 
@@ -474,8 +473,7 @@
     as_environment& env = thread.env;
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_NEXTFRAME );
+    assert(thread.atActionTag(SWF::ACTION_NEXTFRAME));
 #endif
 
     sprite_instance* tgt = env.get_target()->to_movie();
@@ -490,8 +488,7 @@
     as_environment& env = thread.env;
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_PREVFRAME );
+    assert(thread.atActionTag(SWF::ACTION_PREVFRAME));
 #endif
 
     sprite_instance* tgt = env.get_target()->to_movie();
@@ -506,8 +503,7 @@
     as_environment& env = thread.env;
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_PLAY );
+    assert(thread.atActionTag(SWF::ACTION_PLAY));
 #endif
 
     sprite_instance* tgt = env.get_target()->to_movie();
@@ -522,8 +518,7 @@
     as_environment& env = thread.env;
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_STOP );
+    assert(thread.atActionTag(SWF::ACTION_STOP));
 #endif
 
     sprite_instance* tgt = env.get_target()->to_movie();
@@ -537,8 +532,7 @@
 {
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_TOGGLEQUALITY );
+    assert(thread.atActionTag(SWF::ACTION_TOGGLEQUALITY));
 #endif
 
     log_unimpl (__PRETTY_FUNCTION__);
@@ -549,8 +543,7 @@
 {
 
 #ifndef NDEBUG
-    const action_buffer& code = thread.code;
-    assert( code[thread.pc] == SWF::ACTION_STOPSOUNDS );
+    assert(thread.atActionTag(SWF::ACTION_STOPSOUNDS));
 #endif
 
     media::sound_handler* s = get_sound_handler();
@@ -567,9 +560,9 @@
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
 
-    assert( code[thread.pc] == SWF::ACTION_GOTOFRAME );
+    assert(thread.atActionTag(SWF::ACTION_GOTOFRAME));
 
-    size_t frame = code.read_int16(thread.pc+3);
+    size_t frame = code.read_int16(thread.getCurrentPC()+3);
 
     sprite_instance* tgt = env.get_target()->to_movie();
     assert(tgt);
@@ -585,9 +578,9 @@
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
 
-    assert( code[thread.pc] == SWF::ACTION_GETURL );
+    assert(thread.atActionTag(SWF::ACTION_GETURL));
 
-    size_t& pc = thread.pc;
+    size_t pc = thread.getCurrentPC();
 
     // If this is an FSCommand, then call the callback
     // handler, if any.
@@ -615,10 +608,10 @@
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
 
-    assert( code[thread.pc] == SWF::ACTION_WAITFORFRAME );
+    assert(thread.atActionTag(SWF::ACTION_WAITFORFRAME));
 
     // SWF integrity check
-    size_t tag_len = code.read_int16(thread.pc+1);
+    size_t tag_len = code.read_int16(thread.getCurrentPC()+1);
     if ( tag_len != 3 )
     {
         IF_VERBOSE_MALFORMED_SWF (
@@ -630,8 +623,8 @@
     // If we haven't loaded a specified frame yet, then
     // skip the specified number of actions.
     //
-    unsigned int framenum = code.read_int16(thread.pc+3);
-    boost::uint8_t skip = code[thread.pc+5];
+    unsigned int framenum = code.read_int16(thread.getCurrentPC()+3);
+    boost::uint8_t skip = code[thread.getCurrentPC()+5];
 
     character* target = env.get_target();
     sprite_instance* target_sprite = target->to_movie();
@@ -663,9 +656,9 @@
 {
 
     const action_buffer& code = thread.code;
-    size_t pc = thread.pc;
+    size_t pc = thread.getCurrentPC();
 
-    assert(code[pc] == SWF::ACTION_SETTARGET); // 0x8B
+    assert(thread.atActionTag(SWF::ACTION_SETTARGET)); // 0x8B
 
     // Change the movie we're working on.
     std::string target_name ( code.read_string(pc+3) );
@@ -680,7 +673,7 @@
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
 
-    const char* frame_label = code.read_string(thread.pc+3);
+    const char* frame_label = code.read_string(thread.getCurrentPC()+3);
     character *target = env.get_target();
     sprite_instance *target_sprite = target->to_movie();
     if ( ! target_sprite )
@@ -758,7 +751,7 @@
 
     as_environment& env = thread.env;
 
-    assert(thread.code[thread.pc] == SWF::ACTION_EQUAL); // 0x0E
+    assert(thread.atActionTag(SWF::ACTION_EQUAL)); // 0x0E
 
     thread.ensureStack(2);
 
@@ -1235,7 +1228,7 @@
 
     as_environment& env = thread.env;
 
-    assert(thread.code[thread.pc] == SWF::ACTION_STARTDRAGMOVIE);
+    assert(thread.atActionTag(SWF::ACTION_STARTDRAGMOVIE));
 
     thread.ensureStack(3);
 
@@ -1335,7 +1328,7 @@
     env.top(0).flag_exception();
 
     // Proceed to the end of the code block to throw.
-    thread.next_pc = thread.stop_pc;
+    thread.skipRemainingBuffer();
 }
 
 void
@@ -1477,7 +1470,7 @@
 {
     
 
-    assert(thread.code[thread.pc] == SWF::ACTION_FSCOMMAND2); // 0x0E
+    assert(thread.atActionTag(SWF::ACTION_FSCOMMAND2)); // 0x0E
 
     as_environment& env = thread.env;
 
@@ -1882,7 +1875,7 @@
     thread.ensureStack(1); // expression
 
     // how many actions to skip if frame has not been loaded
-    boost::uint8_t skip = code[thread.pc+3];
+    boost::uint8_t skip = code[thread.getCurrentPC()+3];
 
     // env.top(0) contains frame specification,
     // evaluated as for ActionGotoExpression
@@ -1960,7 +1953,7 @@
 
     const action_buffer& code = thread.code;
 
-    size_t pc = thread.pc;
+    size_t pc = thread.getCurrentPC();
     boost::int16_t length = code.read_int16(pc+1);
     assert( length >= 0 );
 
@@ -2139,7 +2132,7 @@
 {
     
 
-    boost::int16_t offset = thread.code.read_int16(thread.pc+3);
+    boost::int16_t offset = thread.code.read_int16(thread.getCurrentPC()+3);
     thread.next_pc += offset;
     // @@ TODO range checks
 }
@@ -2522,9 +2515,9 @@
 
     const action_buffer& code = thread.code;
 
-    assert( code[thread.pc] == SWF::ACTION_GETURL2 );
+    assert(thread.atActionTag(SWF::ACTION_GETURL2));
 
-    boost::uint8_t method = code[thread.pc + 3];
+    boost::uint8_t method = code[thread.getCurrentPC() + 3];
 
     as_value url_val = env.top(1);
     if ( url_val.is_undefined() )
@@ -2547,11 +2540,11 @@
     // Alias these
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
-    size_t& pc = thread.pc;
+    size_t pc = thread.getCurrentPC();
     size_t& next_pc = thread.next_pc;
     size_t& stop_pc = thread.stop_pc;
 
-    assert( code[pc] == SWF::ACTION_BRANCHIFTRUE );
+    assert(thread.atActionTag(SWF::ACTION_BRANCHIFTRUE));
 
     thread.ensureStack(1); // bool
 
@@ -2624,7 +2617,7 @@
     thread.ensureStack(1); // expression
 
     const action_buffer& code = thread.code;
-    size_t pc = thread.pc;
+    size_t pc = thread.getCurrentPC();
 
 
     // From Alexi's SWF ref:
@@ -2695,7 +2688,7 @@
     //GNASH_REPORT_FUNCTION;
     as_environment& env = thread.env;
 
-    assert(thread.code[thread.pc] == SWF::ACTION_DELETE); // 0x3A
+    assert(thread.atActionTag(SWF::ACTION_DELETE)); // 0x3A
 
     thread.ensureStack(2); // obj, member
 
@@ -2728,7 +2721,7 @@
 
     as_environment& env = thread.env;
 
-    assert(thread.code[thread.pc] == SWF::ACTION_DELETE2); // 0x3B
+    assert(thread.atActionTag(SWF::ACTION_DELETE2)); // 0x3B
 
     thread.ensureStack(1); // var
 
@@ -2837,7 +2830,7 @@
     // If the function threw an exception, do so here.
     if (result.is_exception())
     {
-        thread.next_pc = thread.stop_pc;
+        thread.skipRemainingBuffer();
     }
 
     //env.dump_stack();
@@ -2867,7 +2860,7 @@
     //env.dump_stack();
 
     // Skip the rest of this buffer (return from this action_buffer).
-    thread.next_pc = thread.stop_pc;
+    thread.skipRemainingBuffer();
 
 }
 
@@ -3223,7 +3216,7 @@
     //GNASH_REPORT_FUNCTION;
     as_environment& env = thread.env;
 
-    assert(thread.code[thread.pc] == SWF::ACTION_NEWEQUALS);
+    assert(thread.atActionTag(SWF::ACTION_NEWEQUALS));
 
     thread.ensureStack(2);
 
@@ -3615,7 +3608,7 @@
     // Now, if there was an exception, proceed to the end of the block.
     if (result.is_exception())
     {
-        thread.next_pc = thread.stop_pc;
+        thread.skipRemainingBuffer();
     }
     // This is to check stack status after call method
     //log_debug(_("at doActionCallMethod() end, stack: ")); env.dump_stack();
@@ -3629,7 +3622,7 @@
 
     as_environment& env = thread.env;
 
-    assert( thread.code[thread.pc] == SWF::ACTION_NEWMETHOD );
+    assert(thread.atActionTag(SWF::ACTION_NEWMETHOD));
 
     thread.ensureStack(3); // method, object, nargs
 
@@ -3963,7 +3956,7 @@
 SWFHandlers::ActionConstantPool(ActionExec& thread)
 {
     
-    thread.code.process_decl_dict(thread.pc, thread.next_pc);
+    thread.code.process_decl_dict(thread.getCurrentPC(), thread.next_pc);
 }
 
 void
@@ -3982,7 +3975,7 @@
 
     func->set_is_function2();
 
-    size_t i = thread.pc + 3; // skip tag id and length
+    size_t i = thread.getCurrentPC() + 3; // skip tag id and length
 
     // Extract name.
     // @@ security: watch out for possible missing terminator here!
@@ -4089,11 +4082,10 @@
     const action_buffer& code = thread.code;
 
 #ifndef NDEBUG
-    size_t pc = thread.pc;
-    assert( code[pc] == SWF::ACTION_TRY );
+    assert(thread.atActionTag(SWF::ACTION_TRY));
 #endif
 
-    size_t i = thread.pc + 3; // skip tag id and length
+    size_t i = thread.getCurrentPC() + 3; // skip tag id and length
 
     boost::uint8_t flags = code[i];
     ++i;
@@ -4148,9 +4140,9 @@
 
     as_environment& env = thread.env;
     const action_buffer& code = thread.code;
-    size_t pc = thread.pc;
+    size_t pc = thread.getCurrentPC();
 
-    assert( code[pc] == SWF::ACTION_WITH );
+    assert(thread.atActionTag(SWF::ACTION_WITH));
 
     thread.ensureStack(1);  // the object
     as_value with_obj_val = env.pop().to_object();
@@ -4212,7 +4204,7 @@
     const action_buffer& code = thread.code;
 
 #ifndef NDEBUG
-    boost::int16_t length = code.read_int16(thread.pc+1);
+    boost::int16_t length = code.read_int16(thread.getCurrentPC()+1);
     assert( length >= 0 );
 #endif
 
@@ -4223,7 +4215,7 @@
     swf_function* func = new swf_function(
         &code, &env, thread.next_pc, thread.getScopeStack());
 
-    size_t i = thread.pc + 3;
+    size_t i = thread.getCurrentPC() + 3;
 
     // Extract name.
     // @@ security: watch out for possible missing terminator here!
@@ -4306,7 +4298,7 @@
 
     const action_buffer& code = thread.code;
 
-    unsigned int reg = code[thread.pc + 3];
+    unsigned int reg = code[thread.getCurrentPC() + 3];
 
     // Save top of stack in specified register.
     if ( thread.isFunction2() && env.num_local_registers() )

Index: server/vm/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- server/vm/ActionExec.cpp    11 Jun 2008 20:54:45 -0000      1.77
+++ server/vm/ActionExec.cpp    12 Jun 2008 09:36:00 -0000      1.78
@@ -80,11 +80,11 @@
     mReturning(false),
     _abortOnUnload(false),
     code(func.getActionBuffer()),
+    env(newEnv),
+    retval(nRetVal),
     pc(func.getStartPC()),
     stop_pc(pc+func.getLength()),
-    next_pc(pc),
-    env(newEnv),
-    retval(nRetVal)
+    next_pc(pc)
 {
     assert(stop_pc < code.size());
 
@@ -121,11 +121,11 @@
     mReturning(false),
     _abortOnUnload(abortOnUnloaded),
     code(abuf),
+    env(newEnv),
+    retval(0),
     pc(0),
     stop_pc(code.size()),
-    next_pc(0),
-    env(newEnv),
-    retval(0)
+    next_pc(0)
 {
     //GNASH_REPORT_FUNCTION;
 
@@ -238,12 +238,10 @@
                 // If we are in a try block, check to see if we have thrown.
                 tryBlock& t = _tryList.back();
 
-                log_debug ("PC: %d, stop pc: %d, tryState: %d", pc, stop_pc, 
t._tryState);
+                //log_debug ("PC: %d, stop pc: %d, tryState: %d", pc, stop_pc, 
t._tryState);
 
                 if (t._tryState == tryBlock::TRY_TRY)
                 {
-                
-                    log_debug("TRY block");
                     if (env.stack_size() && env.top(0).is_exception())
                     {
                         as_value ex = env.top(0);
@@ -292,7 +290,6 @@
                 }
                 else if (t._tryState == tryBlock::TRY_CATCH)
                 {
-                    log_debug("CATCH block");
                     log_debug("CATCH: tryBlock name = %s", t._name);           
     
                     // Process exceptions. The code in catch { } will 
                     // be executed whether this block is reached or not.
@@ -327,7 +324,6 @@
                 {
                     // FINALLY. This may or may not exist, but these actions
                     // are carried out anyway.
-                    log_debug("FINALLY block");
                     log_debug("FINALLY: tryBlock name = %s", t._name);         
        
 
                     // If the exception is here, we have thrown in catch.
@@ -344,7 +340,6 @@
                 }
                 else // Everything finished. Check for exceptions.
                 {
-                    log_debug("END");
                     // If there's no exception here, we can execute the
                     // rest of the code. If there is, it will be caught
                     // by the next TryBlock or stop execution.
@@ -794,15 +789,6 @@
     return _function_var ? _this_ptr.get() : env.get_original_target(); 
 }
 
-boost::uint32_t
-ActionExec::getScriptTimeout()
-{
-    // TODO1: allow specifying this in the .gnashrc file
-    // TODO2: possibly use the SWF tag for this
-    return 15000;
-    //return 2000;
-}
-
 } // end of namespace gnash
 
 

Index: server/vm/ActionExec.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/vm/ActionExec.h      11 Jun 2008 20:54:45 -0000      1.31
+++ server/vm/ActionExec.h      12 Jun 2008 09:36:00 -0000      1.32
@@ -21,12 +21,13 @@
 #include "with_stack_entry.h"
 #include "as_environment.h" // for ensureStack
 #include "smart_ptr.h"
+#include "swf.h"
+#include "action_buffer.h"
 
 #include <vector>
 
 // Forward declarations
 namespace gnash {
-       class action_buffer;
        class as_value;
        class swf_function;
        class ActionExec;
@@ -207,10 +208,6 @@
 
        bool _abortOnUnload;
 
-       /// Return the number of milliseconds after which
-       /// execution of a script block should abort.
-       boost::uint32_t getScriptTimeout();
-
 public:
 
        /// \brief
@@ -249,21 +246,6 @@
        ///
        const action_buffer& code;
 
-       /// Program counter (offset of current action tag)
-       //
-       /// TODO: provide mutator funx and make private
-       ///
-       size_t pc;
-
-       /// End of current function execution
-       //
-       /// Used for try/throw/catch blocks.
-       ///
-       size_t stop_pc;
-
-       /// Offset to next action tag
-       size_t next_pc;
-
        /// TODO: provide a getter and make private ?
        as_environment& env;
 
@@ -456,6 +438,31 @@
 
        /// Execute.
        void operator() ();
+
+    bool atActionTag(SWF::action_type t) { return code[pc] == t; }
+       
+       size_t getCurrentPC() const { return pc; }
+       
+       void skipRemainingBuffer() { next_pc = stop_pc; }
+
+// This is just a temporary mess for initialization order
+// while I sort out accessors.
+
+private:
+
+    /// Program counter (offset of current action tag)
+       size_t pc;
+
+public:
+
+       /// End of current function execution
+       /// Used for try/throw/catch blocks.
+       size_t stop_pc;
+
+       /// Offset to next action tag
+       size_t next_pc;
+
+       
 };
 
 } // namespace gnash




reply via email to

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