dotgnu-pnet-commits
[Top][All Lists]
Advanced

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

[dotgnu-pnet-commits] libjit ChangeLog include/jit/jit-plus.h jitplus...


From: Aleksey Demakov
Subject: [dotgnu-pnet-commits] libjit ChangeLog include/jit/jit-plus.h jitplus...
Date: Fri, 29 Feb 2008 11:10:42 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    libjit
Changes by:     Aleksey Demakov <avd>   08/02/29 11:10:42

Modified files:
        .              : ChangeLog 
        include/jit    : jit-plus.h 
        jitplus        : Makefile.am jit-plus-function.cpp 
Added files:
        jitplus        : jit-plus-jump-table.cpp 

Log message:
        add jump table support to jitplus interface

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libjit/ChangeLog?cvsroot=dotgnu-pnet&r1=1.347&r2=1.348
http://cvs.savannah.gnu.org/viewcvs/libjit/include/jit/jit-plus.h?cvsroot=dotgnu-pnet&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/libjit/jitplus/Makefile.am?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/libjit/jitplus/jit-plus-function.cpp?cvsroot=dotgnu-pnet&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/libjit/jitplus/jit-plus-jump-table.cpp?cvsroot=dotgnu-pnet&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/ChangeLog,v
retrieving revision 1.347
retrieving revision 1.348
diff -u -b -r1.347 -r1.348
--- ChangeLog   27 Feb 2008 08:53:40 -0000      1.347
+++ ChangeLog   29 Feb 2008 11:10:41 -0000      1.348
@@ -1,3 +1,11 @@
+2008-02-29  Aleksey Demakov  <address@hidden>
+
+       * include/jit/jit-plus.h, jitplus/jit-plus-jump-table.cpp:
+       * jitplus/jit-plus-function.cpp, jitplus/Makefile.am: add
+       jit_jump_table class and jit_function::insn_jump_table method, add
+       jit-plus-jump-table.cpp file, move jit_build_exception class from
+       jit-plus-function.cpp to jit-plus.h.
+
 2008-02-26  Aleksey Demakov  <address@hidden>
 
        * use LGPL 2.1 for all the rest - dpas, tools, tests, and doc.

Index: include/jit/jit-plus.h
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/include/jit/jit-plus.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- include/jit/jit-plus.h      24 Jan 2008 20:12:50 -0000      1.15
+++ include/jit/jit-plus.h      29 Feb 2008 11:10:42 -0000      1.16
@@ -25,6 +25,15 @@
 
 #ifdef __cplusplus
 
+class jit_build_exception
+{
+public:
+       jit_build_exception(int result) { this->result = result; }
+       ~jit_build_exception() {}
+
+       int result;
+};
+
 class jit_value
 {
 public:
@@ -110,6 +119,30 @@
        jit_label_t label;
 };
 
+class jit_jump_table
+{
+ public:
+
+       jit_jump_table(int size);
+       ~jit_jump_table();
+
+       int size() { return num_labels; }
+       jit_label_t *raw() { return labels; }
+
+       jit_label get(int index);
+
+       void set(int index, jit_label label);
+
+ private:
+
+       jit_label_t *labels;
+       int num_labels;
+
+       // forbid copying
+       jit_jump_table(const jit_jump_table&);
+       jit_jump_table& operator=(const jit_jump_table&);
+};
+
 class jit_context
 {
 public:
@@ -286,6 +319,7 @@
        void insn_branch(jit_label& label);
        void insn_branch_if(const jit_value& value, jit_label& label);
        void insn_branch_if_not(const jit_value& value, jit_label& label);
+       void insn_jump_table(const jit_value& value, jit_jump_table& 
jump_table);
        jit_value insn_address_of(const jit_value& value1);
        jit_value insn_address_of_label(jit_label& label);
        jit_value insn_convert

Index: jitplus/Makefile.am
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/jitplus/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- jitplus/Makefile.am 30 Aug 2006 19:43:13 -0000      1.4
+++ jitplus/Makefile.am 29 Feb 2008 11:10:42 -0000      1.5
@@ -4,7 +4,8 @@
 libjitplus_la_SOURCES = \
                jit-plus-context.cpp \
                jit-plus-function.cpp \
-               jit-plus-value.cpp
+               jit-plus-value.cpp \
+               jit-plus-jump-table.cpp
 
 AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I. -I$(srcdir)
 

Index: jitplus/jit-plus-function.cpp
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/jitplus/jit-plus-function.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- jitplus/jit-plus-function.cpp       24 Jan 2008 20:12:55 -0000      1.16
+++ jitplus/jit-plus-function.cpp       29 Feb 2008 11:10:42 -0000      1.17
@@ -42,15 +42,6 @@
 
 #define        JITPP_MAPPING           20000
 
-class jit_build_exception
-{
-public:
-       jit_build_exception(int result) { this->result = result; }
-       ~jit_build_exception() {}
-
-       int result;
-};
-
 jit_type_t const jit_function::end_params = (jit_type_t)0;
 
 /*@
@@ -1081,6 +1072,14 @@
        }
 }
 
+void jit_function::insn_jump_table(const jit_value& value, jit_jump_table& 
jump_table)
+{
+       if(!jit_insn_jump_table(func, value.raw(), jump_table.raw(), 
jump_table.size()))
+       {
+               out_of_memory();
+       }
+}
+
 jit_value jit_function::insn_address_of(const jit_value& value1)
 {
        value_wrap(jit_insn_address_of(func, value1.raw()));

Index: jitplus/jit-plus-jump-table.cpp
===================================================================
RCS file: jitplus/jit-plus-jump-table.cpp
diff -N jitplus/jit-plus-jump-table.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ jitplus/jit-plus-jump-table.cpp     29 Feb 2008 11:10:42 -0000      1.1
@@ -0,0 +1,65 @@
+/*
+ * jit-plus-jump-table.cpp - C++ wrapper for JIT jump tables.
+ *
+ * Copyright (C) 2008  Southern Storm Software, Pty Ltd.
+ *
+ * This file is part of the libjit library.
+ *
+ * The libjit library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * The libjit library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the libjit library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include <jit/jit-plus.h>
+
+jit_jump_table::jit_jump_table(int size)
+{
+       try
+       {
+               labels = new jit_label_t[size];
+       }
+       catch(...)
+       {
+               throw jit_build_exception(JIT_RESULT_OUT_OF_MEMORY);
+       }
+       for (int i = 0; i < size; i++)
+       {
+               labels[i] = jit_label_undefined;
+       }
+       num_labels = size;
+}
+
+jit_jump_table::~jit_jump_table()
+{
+       delete [] labels;
+}
+
+jit_label
+jit_jump_table::get(int index)
+{
+       if (index < 0 || index >= num_labels)
+       {
+               throw jit_build_exception(JIT_RESULT_COMPILE_ERROR);
+       }
+       return jit_label(labels[index]);
+}
+
+void
+jit_jump_table::set(int index, jit_label label)
+{
+       if (index < 0 || index >= num_labels)
+       {
+               throw jit_build_exception(JIT_RESULT_COMPILE_ERROR);
+       }
+       labels[index] = label.raw();
+}




reply via email to

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