[Vm-dev] [commit] r2139 - try to gnuify interp.c if compiling with
gcc
commits at squeakvm.org
commits at squeakvm.org
Thu Sep 17 15:56:33 UTC 2009
Author: piumarta
Date: 2009-09-17 08:56:33 -0700 (Thu, 17 Sep 2009)
New Revision: 2139
Added:
trunk/platforms/unix/cmake/gnuify
trunk/platforms/unix/cmake/gnuify.awk
Modified:
trunk/platforms/unix/ChangeLog
trunk/platforms/unix/cmake/configure
trunk/platforms/unix/vm/build.cmake
trunk/platforms/unix/vm/config.cmake
Log:
try to gnuify interp.c if compiling with gcc
Modified: trunk/platforms/unix/ChangeLog
===================================================================
--- trunk/platforms/unix/ChangeLog 2009-09-17 01:56:43 UTC (rev 2138)
+++ trunk/platforms/unix/ChangeLog 2009-09-17 15:56:33 UTC (rev 2139)
@@ -1,3 +1,19 @@
+2009-09-17 <piumarta at ubuntu.piumarta.com>
+
+ * vm/config.cmake: Configure interp as "gnu-interp" if compiler is
+ GCC, otherwise "interp".
+
+ * vm/build.cmake: squeakvm depends on bld/${interp}.c. Implicitly
+ build bld/gnu-interp.c from src/vm/interp.c using gnuify.
+ Implicitly build bld/interp.c by copying src/vm/interp.c.
+
+ * cmake/gnuify: Try gnuify.awk with gawk then awk then cp.
+
+ * cmake/gnuify.awk: Copied from old config/gnuify.
+
+ * cmake/configure (svnversion): Quote unix/.svn to permit spaces
+ in pathnames.
+
2009-09-16 Ian Piumarta <com -dot- gmail -at- piumarta (backwards)>
* doc/RELEASE_NOTES_3.11.3.2135: Release 3.11.3.2135.
Modified: trunk/platforms/unix/cmake/configure
===================================================================
--- trunk/platforms/unix/cmake/configure 2009-09-17 01:56:43 UTC (rev 2138)
+++ trunk/platforms/unix/cmake/configure 2009-09-17 15:56:33 UTC (rev 2139)
@@ -1,6 +1,6 @@
#!/bin/sh
-# Last edited: 2009-09-16 14:37:45 by piumarta on ubuntu.piumarta.com
+# Last edited: 2009-09-16 14:48:48 by piumarta on ubuntu.piumarta.com
RELEASE_TAG=""
@@ -89,7 +89,7 @@
vmmversion="`tr '\015 ' '\012\012' < \"${interp_h}\" | sed '1,/VMMaker/d;q'`"
-if test -d ${unix}/.svn; then
+if test -d "${unix}/.svn"; then
svnversion=`svn info "${unix}/ChangeLog" | fgrep Revision: | awk '{print $2}'`
echo "${svnversion}" > "${unix}/svnversion"
else
Added: trunk/platforms/unix/cmake/gnuify
===================================================================
--- trunk/platforms/unix/cmake/gnuify (rev 0)
+++ trunk/platforms/unix/cmake/gnuify 2009-09-17 15:56:33 UTC (rev 2139)
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# Last edited: 2009-09-17 08:47:30 by piumarta on ubuntu.piumarta.com
+
+gfy="$1"
+src="$2"
+dst="$3"
+log="${dst}.log"
+
+rm -f "${dst}" "${log}"
+
+exec >> "${log}" 2>&1
+
+set -x
+
+try () { "$1" -f "${gfy}" "${src}" > "${dst}" 2>> "${log}"; }
+
+try gawk || try awk || cp -p "${src}" "${dst}"
Property changes on: trunk/platforms/unix/cmake/gnuify
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/platforms/unix/cmake/gnuify.awk
===================================================================
--- trunk/platforms/unix/cmake/gnuify.awk (rev 0)
+++ trunk/platforms/unix/cmake/gnuify.awk 2009-09-17 15:56:33 UTC (rev 2139)
@@ -0,0 +1,183 @@
+#!/usr/bin/awk -f
+#
+# Rewrite the interpreter source in $1 to use GNU C extensions, writing the
+# modified file to stdout.
+#
+# Author: Ian.Piumarta at INRIA.Fr
+#
+# Last edited: 2009-09-17 08:34:23 by piumarta on ubuntu.piumarta.com
+
+# Copyright (C) 1996-2004 by Ian Piumarta and other authors/contributors
+# listed elsewhere in this file.
+# All rights reserved.
+#
+# This file is part of Unix Squeak.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+BEGIN {
+ print "/* This file has been post-processed for GNU C */\n\n";
+# print "copying first section of file" > "/dev/stderr";
+ stage= 0;
+}
+
+/#include "sq.h"/ {
+ print "#include \"sqGnu.h\"\n";
+ next;
+}
+
+# An inlining comment means the interpreter was not inlined
+
+/inline\: true/ {
+# print NR, $0 > "/dev/stderr";
+# print "" > "/dev/stderr";
+# print "*** interpreter was not inlined: bailing out! ***" > "/dev/stderr";
+# print "" > "/dev/stderr";
+ stage= -1;
+}
+
+
+(stage == 0) && /^int interpret\(void\) \{/ {
+# print "interpret: adding static register assignments" > "/dev/stderr";
+ stage= 1;
+ print;
+ next;
+}
+
+(stage == 0) && /^sqInt interpret\(void\) \{/ {
+# print "interpret: adding static register assignments" > "/dev/stderr";
+ stage= 1;
+ print;
+ next;
+}
+
+(stage == 1) && /^ char\* localIP;/ {
+ print " register char* localIP IP_REG;";
+ next;
+}
+
+(stage == 1) && /^register struct foo \* foo = &fum;/ {
+ print " register struct foo * foo GP_REG= &fum;";
+ next;
+}
+
+(stage == 1) && /^ char\* localSP;/ {
+ print " register char* localSP SP_REG;";
+ next;
+}
+
+(stage == 1) && /^ int currentBytecode;/ {
+ print " register int currentBytecode CB_REG;";
+ next;
+}
+
+(stage == 1) && /^ sqInt currentBytecode;/ {
+ print " register int currentBytecode CB_REG;";
+ next;
+}
+
+(stage == 1) && /^$/ {
+# print "interpret: adding bytecode dispatch table" > "/dev/stderr";
+ print " JUMP_TABLE;\n";
+# print "interpret: rewriting case labels and outer breaks" > "/dev/stderr";
+ stage= 2;
+ FS=" ";
+# FS="[ :]+";
+ next;
+}
+
+(stage == 2) && /^ case / {
+ print " CASE(" (($NF) + 0) ")";
+# print " CASE(" $3 ")";
+ next;
+}
+
+(stage == 2) && /^ break;/ {
+ print " BREAK;";
+ next;
+}
+
+(stage == 2) && /^\}/ {
+ stage= -1;
+ print;
+ next;
+}
+
+(stage == 3) && /^int primitiveResponse\(/ {
+ print;
+# print "primitiveResponse: adding primitive dispatch table" > "/dev/stderr";
+ print " PRIM_TABLE;\n";
+# print "primitiveResponse: rewriting case labels" > "/dev/stderr";
+ stage= 4;
+ FS=" ";
+# FS="[ :]+";
+ next;
+}
+
+(stage == 3) && /^sqInt primitiveResponse\(/ {
+ print;
+# print "primitiveResponse: adding primitive dispatch table" > "/dev/stderr";
+ print " PRIM_TABLE;\n";
+# print "primitiveResponse: rewriting case labels" > "/dev/stderr";
+ stage= 4;
+ FS=" ";
+# FS="[ :]+";
+ next;
+}
+
+
+(stage == 4) && /^ switch \(primitiveIndex\) \{/ {
+# print "primitiveResponse: adding primitive dispatch" > "/dev/stderr";
+ print " PRIM_DISPATCH;";
+ print;
+ next;
+}
+
+(stage == 4) && /^ switch \(foo->primitiveIndex\) \{/ {
+# print "primitiveResponse: adding primitive dispatch" > "/dev/stderr";
+ print " PRIM_DISPATCH;";
+ print;
+ next;
+}
+
+(stage == 4) && /^ case / {
+ print " CASE(" (($NF) + 0) ")";
+# print " CASE(" $3 ")";
+ next;
+}
+
+(stage == 4) && /^\}/ {
+# print "copying last section of file" > "/dev/stderr";
+ stage= -1;
+ FS=" ";
+ print;
+ next;
+}
+
+# default
+{
+ print;
+ next;
+}
+
+END {
+ if (stage != -1) {
+ print "#error GNUIFICATION FAILED (", stage, ")"
+ }
+}
Modified: trunk/platforms/unix/vm/build.cmake
===================================================================
--- trunk/platforms/unix/vm/build.cmake 2009-09-17 01:56:43 UTC (rev 2138)
+++ trunk/platforms/unix/vm/build.cmake 2009-09-17 15:56:33 UTC (rev 2139)
@@ -1,7 +1,7 @@
LINK_DIRECTORIES (${vm_link_directories})
ADD_EXECUTABLE (squeakvm
- ${src}/vm/interp.c
+ ${bld}/${interp}.c
${unix}/vm/aio.c
${unix}/vm/debug.c
${unix}/vm/osExports.c
@@ -20,6 +20,16 @@
COMMAND ${config}/verstamp ${bld}/version.c ${CMAKE_C_COMPILER}
)
+ADD_CUSTOM_COMMAND (
+ OUTPUT ${bld}/interp.c
+ COMMAND ${CMAKE_COMMAND} -E copy ${src}/vm/interp.c ${bld}/interp.c}
+)
+
+ADD_CUSTOM_COMMAND (
+ OUTPUT ${bld}/gnu-interp.c
+ COMMAND ${config}/gnuify ${config}/gnuify.awk ${src}/vm/interp.c ${bld}/gnu-interp.c
+)
+
INCLUDE_DIRECTORIES (
${bld}
${src}/vm
Modified: trunk/platforms/unix/vm/config.cmake
===================================================================
--- trunk/platforms/unix/vm/config.cmake 2009-09-17 01:56:43 UTC (rev 2138)
+++ trunk/platforms/unix/vm/config.cmake 2009-09-17 15:56:33 UTC (rev 2139)
@@ -16,7 +16,12 @@
CONFIG_DEFINE (DARWIN)
-SET (interp interp)
+IF (CMAKE_COMPILER_IS_GNUCC)
+ SET (interp gnu-interp)
+ELSE ()
+ SET (interp interp)
+ MESSAGE ("!! Cannot optimise interpreter performance for GCC")
+ENDIF (CMAKE_COMPILER_IS_GNUCC)
INCLUDE (TestBigEndian)
INCLUDE (CheckIncludeFile)
More information about the Vm-dev
mailing list