help-smalltalk
[Top][All Lists]
Advanced

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

[Help-smalltalk] [PATCH] embedded: Allow to disable the line number byte


From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] [PATCH] embedded: Allow to disable the line number bytecode
Date: Fri, 17 May 2013 14:31:16 +0200

This is more noticable on smaller devices. Allow to disable the
line number bytecode. This changes the runtime of Bench.st for
4 iterations from 26s to 19s.
---
 gst-tool.c      |    7 ++++++-
 libgst/byte.c   |    8 ++++++--
 libgst/files.h  |    5 +++++
 libgst/gst.h    |    3 ++-
 libgst/gstpub.c |    1 +
 libgst/interp.c |    5 +++++
 main.c          |    6 ++++++
 7 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/gst-tool.c b/gst-tool.c
index 9cbadce..552c214 100644
--- a/gst-tool.c
+++ b/gst-tool.c
@@ -138,7 +138,7 @@ const struct tool tools[] = {
     "gst-remote", "scripts/Remote.st",
     "-h|--help --version --daemon --server -p|--port: -f|--file: -e|--eval: \
        -l|--login: --package: --start: --stop: --pid --kill --snapshot:: \
-       -I|--image-file: --kernel-directory: -v|-V|--verbose",
+       -I|--image-file: --kernel-directory: -v|-V|--verbose --no-line-numbers",
     NULL, true
   },
   {
@@ -293,6 +293,11 @@ parse_option (int short_opt, const char *long_opt, const 
char *arg)
 #endif
     }
 
+  if (long_opt && !strcmp (long_opt, "no-line-numbers"))
+    {
+      gst_set_var(GST_NO_LINE_NUMBERS, true);
+    }
+
   if (long_opt && !strcmp (long_opt, "version"))
     usage = 1;
 
diff --git a/libgst/byte.c b/libgst/byte.c
index 6eed361..50ff07c 100644
--- a/libgst/byte.c
+++ b/libgst/byte.c
@@ -59,6 +59,8 @@
 /* Where the compiled bytecodes go.  */
 bc_vector _gst_cur_bytecodes;
 
+mst_Boolean _gst_omit_line_numbers = 0;
+
 /* Reallocate an array of bytecodes, leaving space for DELTA more
    bytes.  */
 static void realloc_bytecodes (bc_vector bytecodes,
@@ -127,7 +129,8 @@ _gst_line_number (int n, int flags)
       assert (n > 0);
       if (flags & LN_ABSOLUTE)
        {
-         compile_byte (LINE_NUMBER_BYTECODE, n);
+          if (!_gst_omit_line_numbers)
+           compile_byte (LINE_NUMBER_BYTECODE, n);
          _gst_compiler_state->prev_line = n;
        }
       _gst_compiler_state->line_offset = n - 1;
@@ -158,7 +161,8 @@ _gst_compile_byte (gst_uchar byte, int arg)
 {
   if (next_line_number != -1)
     {
-      compile_byte (LINE_NUMBER_BYTECODE, next_line_number);
+      if (!_gst_omit_line_numbers)
+        compile_byte (LINE_NUMBER_BYTECODE, next_line_number);
       next_line_number = -1;
     }
 
diff --git a/libgst/files.h b/libgst/files.h
index 2983c32..68f5f68 100644
--- a/libgst/files.h
+++ b/libgst/files.h
@@ -142,4 +142,9 @@ extern char *_gst_find_file (const char *fileName,
                             enum gst_file_dir dir)
   ATTRIBUTE_HIDDEN;
 
+/* Omit line numbers in the generated bytecode.  */
+extern mst_Boolean _gst_omit_line_numbers
+   ATTRIBUTE_HIDDEN;
+
+
 #endif /* GST_LIB_H */
diff --git a/libgst/gst.h b/libgst/gst.h
index 5b95023..da81618 100644
--- a/libgst/gst.h
+++ b/libgst/gst.h
@@ -222,7 +222,8 @@ enum gst_var_index {
   GST_GC_MESSAGE,
   GST_VERBOSITY,
   GST_MAKE_CORE_FILE,
-  GST_REGRESSION_TESTING
+  GST_REGRESSION_TESTING,
+  GST_NO_LINE_NUMBERS
 };
 
 enum gst_init_flags {
diff --git a/libgst/gstpub.c b/libgst/gstpub.c
index 2ebdfe2..29c4d19 100644
--- a/libgst/gstpub.c
+++ b/libgst/gstpub.c
@@ -609,3 +609,4 @@ gst_set_event_loop_handlers(mst_Boolean (*poll) (int ms),
 {
   return _gst_set_event_loop_handlers(poll, dispatch);
 }
+
diff --git a/libgst/interp.c b/libgst/interp.c
index 3b74614..0ec2def 100644
--- a/libgst/interp.c
+++ b/libgst/interp.c
@@ -2160,6 +2160,8 @@ _gst_get_var (enum gst_var_index index)
       return (_gst_make_core_file);
     case GST_REGRESSION_TESTING:
       return (_gst_regression_testing);
+    case GST_NO_LINE_NUMBERS:
+      return (_gst_omit_line_numbers);
     default:
       return (-1);
     }
@@ -2195,6 +2197,9 @@ _gst_set_var (enum gst_var_index index, int value)
     case GST_REGRESSION_TESTING:
       _gst_regression_testing = true;
       break;
+    case GST_NO_LINE_NUMBERS:
+      _gst_omit_line_numbers = value;
+      break;
     default:
       return (-1);
     }
diff --git a/main.c b/main.c
index 9c6bc60..f28aad3 100644
--- a/main.c
+++ b/main.c
@@ -92,6 +92,7 @@ static const char help_text[] =
   "\n      --kernel-directory DIR\t Look for kernel files in directory DIR."
   "\n      --no-user-files\t\t Don't read user customization files.\n"
   "\n   -\t\t\t\t Read input from standard input explicitly."
+  "\n      --no-line-numbers\t\t Do not generate line numbers in the bytecode."
   "\n"
   "\nFiles are loaded one after the other.  After the last one is loaded,"
   "\nSmalltalk will exit.  If no files are specified, Smalltalk reads from"
@@ -122,6 +123,7 @@ static const char copyright_and_legal_stuff_text[] =
 #define OPT_NO_USER 3
 #define OPT_EMACS_MODE 4
 #define OPT_MAYBE_REBUILD 5
+#define OPT_NO_LINE_NUMBERS 6
 
 #define OPTIONS "-acDEf:ghiI:K:lL:QqrSvV"
 
@@ -147,6 +149,7 @@ static const struct option long_options[] = {
   {"snapshot", 0, 0, 'S'},
   {"version", 0, 0, 'v'},
   {"verbose", 0, 0, 'V'},
+  {"no-line-numbers", 0, 0, OPT_NO_LINE_NUMBERS},
   {NULL, 0, 0, 0}
 };
 
@@ -299,6 +302,9 @@ parse_args (int argc,
          loaded_files[n_loaded_files].kernel_path = false;
          loaded_files[n_loaded_files++].file_name = optarg;
          break;
+       case OPT_NO_LINE_NUMBERS:
+         gst_set_var(GST_NO_LINE_NUMBERS, true);
+         break;
 
        default:
          /* Fall through and show help message */
-- 
1.7.10.4




reply via email to

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