changeset 15125:0464e3ceb85b

Skip functions when resolving end context in JIT * src/interp-core/jit-ir.cc (jit_magic_end::resolve_context): Skip functions. * src/interp-core/jit-typeinfo.cc (jit_type::jit_type): Add askip_paren parameter. (jit_typeinfo::addbuiltin): Skip end resolution for builtin functions. * src/interp-core/jit-typeinfo.h (jit_type::skip_paren): New function. (jit_typeinfo::new_type): Add skip_paren argument.
author Max Brister <max@2bass.com>
date Tue, 07 Aug 2012 14:59:58 -0500
parents 4e0ab3b28418
children 067699edef86
files src/interp-core/jit-ir.cc src/interp-core/jit-typeinfo.cc src/interp-core/jit-typeinfo.h
diffstat 3 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/interp-core/jit-ir.cc
+++ b/src/interp-core/jit-ir.cc
@@ -619,9 +619,19 @@
 jit_magic_end::context
 jit_magic_end::resolve_context (void) const
 {
-  // FIXME: We need to have a way of marking functions so we can skip them here
-  context ret = contexts[0];
-  ret.value = argument (0);
+  size_t idx;
+  for (idx = 0; idx < contexts.size (); ++idx)
+    {
+      jit_type *ctx_type = contexts[idx].value->type ();
+      if (! ctx_type || ctx_type->skip_paren ())
+        break;
+    }
+
+  if (idx >= contexts.size ())
+    idx = 0;
+
+  context ret = contexts[idx];
+  ret.value = argument (idx);
   return ret;
 }
 
--- a/src/interp-core/jit-typeinfo.cc
+++ b/src/interp-core/jit-typeinfo.cc
@@ -500,9 +500,9 @@
 
 // -------------------- jit_type --------------------
 jit_type::jit_type (const std::string& aname, jit_type *aparent,
-                    llvm::Type *allvm_type, int aid) :
+                    llvm::Type *allvm_type, bool askip_paren, int aid) :
   mname (aname), mparent (aparent), llvm_type (allvm_type), mid (aid),
-  mdepth (aparent ? aparent->mdepth + 1 : 0)
+  mdepth (aparent ? aparent->mdepth + 1 : 0), mskip_paren (askip_paren)
 {
   std::memset (msret, 0, sizeof (msret));
   std::memset (mpointer_arg, 0, sizeof (mpointer_arg));
@@ -1800,9 +1800,9 @@
 
 jit_type*
 jit_typeinfo::new_type (const std::string& name, jit_type *parent,
-                        llvm::Type *llvm_type)
+                        llvm::Type *llvm_type, bool skip_paren)
 {
-  jit_type *ret = new jit_type (name, parent, llvm_type, next_id++);
+  jit_type *ret = new jit_type (name, parent, llvm_type, skip_paren, next_id++);
   id_to_type.push_back (ret);
   return ret;
 }
@@ -1918,7 +1918,7 @@
 void
 jit_typeinfo::add_builtin (const std::string& name)
 {
-  jit_type *btype = new_type (name, any, any->to_llvm ());
+  jit_type *btype = new_type (name, any, any->to_llvm (), true);
   builtins[name] = btype;
 
   octave_builtin *ov_builtin = find_builtin (name);
--- a/src/interp-core/jit-typeinfo.h
+++ b/src/interp-core/jit-typeinfo.h
@@ -132,7 +132,7 @@
   typedef llvm::Value *(*convert_fn) (llvm::IRBuilderD&, llvm::Value *);
 
   jit_type (const std::string& aname, jit_type *aparent, llvm::Type *allvm_type,
-            int aid);
+            bool askip_paren, int aid);
 
   // a user readable type name
   const std::string& name (void) const { return mname; }
@@ -151,6 +151,8 @@
 
   size_t depth (void) const { return mdepth; }
 
+  bool skip_paren (void) const { return mskip_paren; }
+
   // -------------------- Calling Convention information --------------------
 
   // A function declared like: mytype foo (int arg0, int arg1);
@@ -195,6 +197,7 @@
   llvm::Type *llvm_type;
   int mid;
   size_t mdepth;
+  bool mskip_paren;
 
   bool msret[jit_convention::length];
   bool mpointer_arg[jit_convention::length];
@@ -625,7 +628,7 @@
                               jit_value *count);
 
   jit_type *new_type (const std::string& name, jit_type *parent,
-                      llvm::Type *llvm_type);
+                      llvm::Type *llvm_type, bool skip_paren = false);
 
 
   void add_print (jit_type *ty, void *fptr);