bugGNU Octave - Bugs: bug #50116, libinterp functions should call...

 
 

bug #50116: libinterp functions should call C++ directly rather than calling through feval

Submitted by:  Rik <rik5>
Submitted on:  Sat 21 Jan 2017 11:07:17 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Performance
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Wed 01 Feb 2017 01:30:34 AM UTC, comment #6:

I replaced the possible feval calls in libinterp with direct calls to C++ function in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/35e3d199527c). Closing report.

Rik <rik5>
Project Administrator
Tue 24 Jan 2017 05:20:14 PM UTC, comment #5:

Yes, you can call the built-in functions directly in some cases. But we should not do that when it is possible to use liboctave functions directly. For example, we shouldn't be packing matrix objects inside octave_value{,_list} objects just so Fsum can unpack them, then compute the sum, then put them back in octave_value{,_list} objects so we can unpack them again.

John W. Eaton <jwe>
Project Administrator
Tue 24 Jan 2017 05:03:59 PM UTC, comment #4:

Another note, looking in the list of instances that I got from grep'ing the code, this instance should not be replaced

This is executing a callback function which is held in the variable "fcn". This instance needs to continue using feval.

Rik <rik5>
Project Administrator
Tue 24 Jan 2017 04:56:02 PM UTC, comment #3:

The second argument is the number of output arguments (nargout). For the function "sum", there is only one output. But a function like "sort" might have two outputs.

I hadn't gotten around to it but this is exactly the way I was going to proceed. Add

to the top of the files that need it, and then replace

with

Rik <rik5>
Project Administrator
Tue 24 Jan 2017 09:02:47 AM UTC, comment #2:

The example of comment #1 is bad, as "isequal" is a pure M-file. Another example:

Before:

After:

Kai Torben Ohlhus <siko1056>
Project Member
Tue 24 Jan 2017 08:52:58 AM UTC, comment #1:

A remedy could be the following pattern to refactor the code:

Before:

After:

The remedy is inspired by "examples/code/standalonebuiltin.cc". This compiles for me (I am currently working on bug #50105 but decided to post here for generality). Now I want to know if this approach is desired and what does the "1" in the end of Fisequal (args, 1) mean? In "libinterpreter/builtin-defun-decls.h" it is "0" by default. Is there any documentation available? The file "libinterpreter/builtin-defun-decls.h" is generated by the undocumented "build-aux/mk-builtins.pl".

Kai Torben Ohlhus <siko1056>
Project Member
Sat 21 Jan 2017 11:07:17 PM UTC, original submission:

Within C++, interpreter functions written in C++ like "sum" can be called directly using the name with 'F' prepended. For example, "Fsum" or "Flasterr". However, the code often makes use of feval to do this instead.

Whenever the function name might be overloaded in the symbol table, such as with display for class objects, then the invocation implementation needs to remain as feval. However, the rest of the time these could be

Examples:

See the related bug #50105.

Rik <rik5>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by siko1056 (Knows everything about Octave.)
  • -unavailable- added by siko1056 (Posted a comment)
  • -unavailable- added by rik5 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 01 Feb 2017 01:30:34 AM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 24 Jan 2017 09:02:47 AM UTCsiko1056Carbon-Copy-=>Added jwe

    Back to the top


    Powered by Savane 3.1-cleanup1