Mercurial > octave
view libinterp/parse-tree/module.mk @ 32148:dea87a95ad18
experimental stack-based virtual machine
The patch adds a stack-based bytecode virtual machine (VM) for
executing Octave functions.
The user command __enable_vm_eval__ may be used to enables the VM
dynamically.
The VM is a work in progress. It does not currently support all
of the functionality of the existing interpreter that recursively
walks the parse tree to evaluate code.
* compile.cc, pt-bytecode-vm-internal.h, pt-bytecode-vm.cc,
pt-bytecode-vm.h, pt-bytecode-walk.cc, pt-bytecode-walk.h,
pt-bytecode.h, pt-vm-eval.cc: New files
* libinterp/corefcn/module.mk, libinterp/parse-tree/module.mk: Update.
* call-stack.h, call-stack.cc (call_stack::push): New overload to push
a stack frame for a bytecode compiled function on the stack.
(call_stack::set_active_bytecode_ip): New function.
(call_stack::find_current_user_frame, call_stack::dbupdown,
call_stack::backtrace_frames call_stack::backtrace_info,
call_stack::backtrace): Handle bytecode compiled function frames.
* stack-frame.h, stack-frame.cc (bytecode_fcn_stack_frame): New class.
(get_auto_fcn_var)
(stack_frame_walker::visit_bytecode_fcn_stack_frame):
New pure virtual function.
(symbol_cleaner::visit_bytecode_fcn_stack_frame): New function.
(symbol_info_accumulator::visit_bytecode_fcn_stack_frame): New function.
(stack_frame::create_bytecode): New function.
(stack_frame::is_bytecode_fcn_frame,
stack_frame::get_active_bytecode_call_arg_names,
stack_frame::set_active_bytecode_ip, stak_frame::vm_unwinds,
stack_frame::vm_dbg_check_scope, stack_frame::vm_clear_for_cache):
New virtual functions.
* ov.h (octave_value::vm_need_storable_call,
octave_value::vm_need_dispatch_assign_rhs,
octave_value::vm_need_dispatch_assign_lhs,
* ov-base.h (octave_base_value::vm_need_storable_call,
octave_base_value::vm_need_dispatch_assign_rhs,
octave_base_value::vm_need_dispatch_assign_lhs,
octave_base_value::vm_need_dispatch_push):
New virtual functions.
* ov-base-mat.h (octave_base_matrix<MT>::vm_need_storable_call):
New function.
* ov-base-scalar.h (octave_base_scalar<ST>::vm_need_dispatch_assign_rhs,
octave_base_scalar<ST>::vm_need_dispatch_assign_lhs,
octave_base_scalar<ST>::vm_need_dispatch_push): New functions.
* ov-magic-int.h (octave_base_magic_int<T>::vm_need_storable_call):
New function.
* ov-null-mat.h (octave_null_matrix::vm_need_storable_call,
octave_null_str::vm_need_storable_call,
octave_null_sq_str::vm_need_storable_call): New functions.
* ov-range.h (ov_range<T>::vm_need_storable_call): New function.
ov.h (octave_value::vm_need_dispatch_push, octave_value::same_rep):
New function.
* ov-fcn.cc (octave_function::call): Attempt to byte compile
user-defined functions.
* ov-user-fcn.h, ov-user-fcn.cc (octave_user_function::call):
Attempt to byte compile function.
(octave_user_function::set_bytecode, octave_user_function::clear_bytecode,
octave_user_function::is_compiled, octave_user_function::get_bytecode):
New functions.
(octave_user_function::m_compilation_failed): New public data member.
octave_user_function::m_bytecode): New data member.
* ov.h (class ov): Declare octave::vm and octave::bytecode_fcn_stack_frame
as friend classes.
* pt-eval.h, pt-eval.cc (tree_evaluator::set_active_bytecode_ip):
New function.
(tree_evaluator::push_stack_frame): New overload to push a stack frame
for a bytecode compiled function on the stack.
(tree_evaluator::execute_user_function): Handle byte-compiled functions.
author | Petter T. <petter.vilhelm@gmail.com> |
---|---|
date | Mon, 24 Apr 2023 20:34:39 +0200 |
parents | 92d897a2c1c3 |
children | f561b6a31e02 |
line wrap: on
line source
PARSE_TREE_INC = \ %reldir%/anon-fcn-validator.h \ %reldir%/bp-table.h \ %reldir%/comment-list.h \ %reldir%/filepos.h \ %reldir%/lex.h \ %reldir%/oct-lvalue.h \ %reldir%/parse.h \ %reldir%/profiler.h \ %reldir%/pt-all.h \ %reldir%/pt-anon-scopes.h \ %reldir%/pt-arg-list.h \ %reldir%/pt-args-block.h \ %reldir%/pt-array-list.h \ %reldir%/pt-assign.h \ %reldir%/pt-binop.h \ %reldir%/pt-bp.h \ %reldir%/pt-bytecode.h \ %reldir%/pt-bytecode-walk.h \ %reldir%/pt-bytecode-vm.h \ %reldir%/pt-bytecode-vm-internal.h \ %reldir%/pt-cbinop.h \ %reldir%/pt-cell.h \ %reldir%/pt-check.h \ %reldir%/pt-classdef.h \ %reldir%/pt-cmd.h \ %reldir%/pt-colon.h \ %reldir%/pt-const.h \ %reldir%/pt-decl.h \ %reldir%/pt-eval.h \ %reldir%/pt-except.h \ %reldir%/pt-exp.h \ %reldir%/pt-fcn-handle.h \ %reldir%/pt-id.h \ %reldir%/pt-idx.h \ %reldir%/pt-jump.h \ %reldir%/pt-loop.h \ %reldir%/pt-mat.h \ %reldir%/pt-misc.h \ %reldir%/pt-pr-code.h \ %reldir%/pt-select.h \ %reldir%/pt-spmd.h \ %reldir%/pt-stmt.h \ %reldir%/pt-tm-const.h \ %reldir%/pt-unop.h \ %reldir%/pt-walk.h \ %reldir%/pt.h \ %reldir%/token.h ## oct-gperf.h and oct-parse.h are in the SRC list so that they will ## be distributed but not installed. PARSE_TREE_SRC = \ %reldir%/anon-fcn-validator.cc \ %reldir%/bp-table.cc \ %reldir%/comment-list.cc \ %reldir%/lex.ll \ %reldir%/oct-gperf.h \ %reldir%/oct-lvalue.cc \ %reldir%/oct-parse.h \ %reldir%/oct-parse.yy \ %reldir%/profiler.cc \ %reldir%/pt-anon-scopes.cc \ %reldir%/pt-arg-list.cc \ %reldir%/pt-args-block.cc \ %reldir%/pt-array-list.cc \ %reldir%/pt-assign.cc \ %reldir%/pt-binop.cc \ %reldir%/pt-bp.cc \ %reldir%/pt-bytecode-walk.cc \ %reldir%/pt-bytecode-vm.cc \ %reldir%/pt-cbinop.cc \ %reldir%/pt-cell.cc \ %reldir%/pt-check.cc \ %reldir%/pt-classdef.cc \ %reldir%/pt-colon.cc \ %reldir%/pt-const.cc \ %reldir%/pt-decl.cc \ %reldir%/pt-eval.cc \ %reldir%/pt-except.cc \ %reldir%/pt-exp.cc \ %reldir%/pt-fcn-handle.cc \ %reldir%/pt-id.cc \ %reldir%/pt-idx.cc \ %reldir%/pt-loop.cc \ %reldir%/pt-mat.cc \ %reldir%/pt-misc.cc \ %reldir%/pt-pr-code.cc \ %reldir%/pt-select.cc \ %reldir%/pt-spmd.cc \ %reldir%/pt-stmt.cc \ %reldir%/pt-tm-const.cc \ %reldir%/pt-unop.cc \ %reldir%/pt-walk.cc \ %reldir%/pt.cc \ %reldir%/token.cc ## Special rules for sources which must be built before rest of compilation. ## Don't use a pipeline to process gperf output since if gperf ## is missing but sed is not, the exit status of the pipeline ## will still be success and we will end up creating an empty ## oct-gperf.h file. %reldir%/oct-gperf.h: %reldir%/octave.gperf $(AM_V_GEN)rm -f $@-t $@t1 $@ && \ $(GPERF) -t -C -D -G -L C++ -Z octave_kw_hash $< > $@-t1 && \ $(SED) -e 's,lookup\[,gperf_lookup[,' -e 's,register ,,g' < $@-t1 > $@-t && \ mv $@-t $@ && \ rm -f $@-t1 noinst_LTLIBRARIES += \ %reldir%/libparse-tree.la %canon_reldir%_libparse_tree_la_SOURCES = $(PARSE_TREE_SRC) %canon_reldir%_libparse_tree_la_CPPFLAGS = \ $(libinterp_liboctinterp_la_CPPFLAGS) \ $(OCTAVE_PARSER_CPPFLAGS) libinterp_EXTRA_DIST += \ %reldir%/octave.gperf