$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r83920 - trunk/tools/build/v2/engine
From: steven_at_[hidden]
Date: 2013-04-15 19:30:37
Author: steven_watanabe
Date: 2013-04-15 19:30:36 EDT (Mon, 15 Apr 2013)
New Revision: 83920
URL: http://svn.boost.org/trac/boost/changeset/83920
Log:
Eliminate some extra list_copy/INSTR_POPs.
Text files modified: 
   trunk/tools/build/v2/engine/function.c |    50 ++++++++++++++++++++++++++++------------
   1 files changed, 35 insertions(+), 15 deletions(-)
Modified: trunk/tools/build/v2/engine/function.c
==============================================================================
--- trunk/tools/build/v2/engine/function.c	(original)
+++ trunk/tools/build/v2/engine/function.c	2013-04-15 19:30:36 EDT (Mon, 15 Apr 2013)
@@ -2325,7 +2325,6 @@
         compile_set_label( c, top );
         compile_emit_branch( c, INSTR_FOR_LOOP, end );
         compile_emit( c, INSTR_SET, var );
-        compile_emit( c, INSTR_POP, 0 );
 
         /* Run the loop body */
         compile_parse( parse->right, c, RESULT_NONE );
@@ -2600,6 +2599,10 @@
                     group->elems, 0 ) )->s );
                 var_parse_group_free( group );
                 compile_parse( parse->right, c, RESULT_STACK );
+                if ( result_location != RESULT_NONE )
+                {
+                    compile_emit( c, INSTR_SET_RESULT, 1 );
+                }
                 compile_emit( c, op_code, name );
             }
             else
@@ -2607,6 +2610,10 @@
                 var_parse_group_compile( group, c );
                 var_parse_group_free( group );
                 compile_parse( parse->right, c, RESULT_STACK );
+                if ( result_location != RESULT_NONE )
+                {
+                    compile_emit( c, INSTR_SET_RESULT, 1 );
+                }
                 compile_emit( c, op_code_group, 0 );
             }
         }
@@ -2614,9 +2621,16 @@
         {
             compile_parse( parse->left, c, RESULT_STACK );
             compile_parse( parse->right, c, RESULT_STACK );
+            if ( result_location != RESULT_NONE )
+            {
+                compile_emit( c, INSTR_SET_RESULT, 1 );
+            }
             compile_emit( c, op_code_group, 0 );
         }
-        adjust_result( c, RESULT_STACK, result_location );
+        if ( result_location != RESULT_NONE )
+        {
+            adjust_result( c, RESULT_RETURN, result_location );
+        }
     }
     else if ( parse->type == PARSE_SETCOMP )
     {
@@ -3761,7 +3775,10 @@
 
         case INSTR_SET_RESULT:
             list_free( result );
-            result = stack_pop( s );
+            if ( !code->arg )
+                result = stack_pop( s );
+            else
+                result = list_copy( stack_top( s ) );
             break;
 
         case INSTR_PUSH_RESULT:
@@ -3997,18 +4014,18 @@
          */
 
         case INSTR_SET:
-            function_set_variable( function, frame, code->arg, list_copy(
-                stack_top( s ) ) );
+            function_set_variable( function, frame, code->arg,
+                stack_pop( s ) );
             break;
 
         case INSTR_APPEND:
-            function_append_variable( function, frame, code->arg, list_copy(
-                stack_top( s ) ) );
+            function_append_variable( function, frame, code->arg,
+                stack_pop( s ) );
             break;
 
         case INSTR_DEFAULT:
-            function_default_variable( function, frame, code->arg, list_copy(
-                stack_top( s ) ) );
+            function_default_variable( function, frame, code->arg,
+                stack_pop( s ) );
             break;
 
         case INSTR_SET_FIXED:
@@ -4016,7 +4033,7 @@
             LIST * * ptr = &frame->module->fixed_variables[ code->arg ];
             assert( code->arg < frame->module->num_fixed_variables );
             list_free( *ptr );
-            *ptr = list_copy( stack_top( s ) );
+            *ptr = stack_pop( s );
             break;
         }
 
@@ -4024,16 +4041,19 @@
         {
             LIST * * ptr = &frame->module->fixed_variables[ code->arg ];
             assert( code->arg < frame->module->num_fixed_variables );
-            *ptr = list_append( *ptr, list_copy( stack_top( s ) ) );
+            *ptr = list_append( *ptr, stack_pop( s ) );
             break;
         }
 
         case INSTR_DEFAULT_FIXED:
         {
             LIST * * ptr = &frame->module->fixed_variables[ code->arg ];
+            LIST * value = stack_pop( s );
             assert( code->arg < frame->module->num_fixed_variables );
             if ( list_empty( *ptr ) )
-                *ptr = list_copy( stack_top( s ) );
+                *ptr = value;
+            else
+                list_free( value );
             break;
         }
 
@@ -4047,7 +4067,7 @@
                 function_set_named_variable( function, frame, list_item( iter ),
                     list_copy( value ) );
             list_free( vars );
-            stack_push( s, value );
+            list_free( value );
             break;
         }
 
@@ -4061,7 +4081,7 @@
                 function_append_named_variable( function, frame, list_item( iter
                     ), list_copy( value ) );
             list_free( vars );
-            stack_push( s, value );
+            list_free( value );
             break;
         }
 
@@ -4075,7 +4095,7 @@
                 function_default_named_variable( function, frame, list_item(
                     iter ), list_copy( value ) );
             list_free( vars );
-            stack_push( s, value );
+            list_free( value );
             break;
         }