bugGNU Octave - Bugs: bug #64674, VM Add support for scripts

 
 

bug #64674: VM Add support for scripts

Submitter:  Petter <petter>
Submitted:  Thu 14 Sep 2023 10:31:59 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Ready For Test Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 21 Sep 2023 12:26:21 AM UTC, comment #5: 

Thanks. Pushed here: https://hg.savannah.gnu.org/hgweb/octave/rev/8d3b15dd7505

I expanded and edited the commit message to refer to this bug number.

Arun Giridhar <arungiridhar>
Group Member
Wed 20 Sep 2023 09:19:45 PM UTC, comment #4: 

I've made four patches to address separate issues with scripts, anonymous functions etc.

I'll post a list here to get the order straight in which they probably need to be applied to not get small merge conflicts.

https://savannah.gnu.org/bugs/?64674 (octave_32431.patch, this bug report)
https://savannah.gnu.org/bugs/?64557 (octave_32432.patch)
https://savannah.gnu.org/bugs/?64690 (octave_32433.patch)
https://savannah.gnu.org/bugs/?64688 (octave_32434.patch)

Test suite runs fine.

Petter <petter>
Wed 20 Sep 2023 08:47:54 PM UTC, comment #3: 

It seems like there is a "collect frames walker" used by e.g. who which collects to many frames for bytecode scripts. It should only collect the outer since.

I've attached a patch to address the issue.



(file #55150)

Petter <petter>
Tue 19 Sep 2023 02:40:34 PM UTC, comment #2: 

There's a problem with this patch, bisected to hg id 56acd8f390f8. It causes `whos` to print its results twice.

Test: create the following two files foofun.m and fooscript.m:


$ cat foofun.m
function foofun
  a = 1;
  b = 2;
  whos
endfunction

$ cat fooscript.m
c = 3;
d = 4;
whos


Then call them from Octave. The function works correctly:

octave:1> foofun
Variables visible from the current scope:

variables in scope: foofun: /tmp/foofun.m

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         a           1x1                          8  double
         b           1x1                          8  double

Total is 2 elements using 16 bytes


But the script prints the output of `whos` twice, once in "script scope" and once in "top scope":


octave:2> fooscript
Variables visible from the current scope:

variables in scope: /tmp/fooscript.m

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         c           1x1                          8  double
         d           1x1                          8  double

Total is 2 elements using 16 bytes

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         c           1x1                          8  double
         d           1x1                          8  double

Total is 2 elements using 16 bytes


The hg id just before this patch works properly, but that doesn't have VM support for scripts.

Arun Giridhar <arungiridhar>
Group Member
Sun 17 Sep 2023 01:24:16 AM UTC, comment #1: 

Thanks. Tested and pushed to: https://hg.savannah.gnu.org/hgweb/octave/rev/56acd8f390f8

Ready for test.

Arun Giridhar <arungiridhar>
Group Member
Thu 14 Sep 2023 10:31:59 PM UTC, original submission:  


The patch adds support for executing scripts in the VM. When a VM script frame is pushed, the VM steals the variables it needs from parent stacks, and puts a reference type value in its place. When exiting the script frame, the value is restored.

* libinterp/corefcn/call-stack.cc: push() script frame
* libinterp/corefcn/call-stack.h: New overload for push()
* libinterp/corefcn/compile.cc: Accept scripts compiling
* libinterp/corefcn/stack-frame.cc: Follow 'refs', assoc frames
* libinterp/corefcn/stack-frame.h: New functions, signatures
* libinterp/octave-value/ov-ref.cc: New ref class 'octave_value_ref_vmlocal'
* libinterp/octave-value/ov-ref.h:
* libinterp/octave-value/ov-usr-fcn.cc: Move functionality to parent class
                                        for scripts and functions.
                                        Auto-compile scripts.
* libinterp/octave-value/ov-usr-fcn.h:
* libinterp/octave-value/ov.h: Make ov and scope_stack_frame friends to call
                               is_ref().
* libinterp/parse-tree/pt-bytecode-vm.cc: New opcodes for entering and
                                          exiting scripts.
* libinterp/parse-tree/pt-bytecode-walk.cc: Compile scripts
* libinterp/parse-tree/pt-bytecode-walk.h:
* libinterp/parse-tree/pt-bytecode.h: New opcodes
* libinterp/parse-tree/pt-eval.cc: Execute scripts in VM, push frames
* libinterp/parse-tree/pt-eval.h:

Updated tests for scripts:
  * test/compile/bytecode_scripts.m: Added
  * test/compile/script1.m: Added
  * test/compile/script11.m: Added
  * test/compile/script2.m: Added
  * test/compile/script3.m: Added
  * test/compile/bytecode.tst: Updated
  * test/compile/module.mk: Include new files


Petter <petter>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55150:  octave_32431.patch added by petter (1KiB - text/plain)
file #55138:  octave_32350.patch added by petter (52KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by petter (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-09-21 arungiridhar StatusIn Progress Ready For Test
    2023-09-20 petter Attached File- Added octave_32431.patch, #55150
    2023-09-19 arungiridhar StatusReady For Test In Progress
    2023-09-17 arungiridhar StatusNone Ready For Test
    2023-09-14 petter Attached File- Added octave_32350.patch, #55138

    Back to the top

    Powered by Savane 3.12