The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SPVM - Static Perl Virtual Machine. Fast Calculation, Fast Array Operation, and Easy C/C++ Binding.

SYNOPSIS

SPVM Module:

  # lib/MyMath.spvm
  package MyMath {
    sub sum : int ($nums : int[]) {

      my $total = 0;
      for (my $i = 0; $i < @$nums; $i++) {
        $total += $nums->[$i];
      }

      return $total;
    }
  }

Call SPVM subroutine from Perl

  # spvm.pl
  use strict;
  use warnings;
  use FindBin;
  use lib "$FindBin::Bin/lib";

  use SPVM 'MyMath';

  # Call subroutine
  my $total = MyMath->sum([3, 6, 8, 9]);

  print "Total: $total\n";

  # Call subroutine with packed data
  my $nums_packed = pack('l*', 3, 6, 8, 9);
  my $sv_nums = SPVM::new_int_array_from_bin($nums_packed);
  my $total_packed = MyMath->sum($sv_nums);

  print "Total Packed: $total_packed\n";

Precompiled SPVM Subroutine. This code is converted to C language and then converted to a shared library.

  # lib/MyMath.spvm
  package MyMath : precompile {
    sub sum : int ($nums : int[]) {

      my $total = 0;
      for (my $i = 0; $i < @$nums; $i++) {
        $total += $nums->[$i];
      }

      return $total;
    }
  }

DESCRIPTION

SPVM is Static Perl Virtual Machine. SPVM is a programming language which has Perlish syntax. SPVM provides fast Calculation & easy C/C++ Binding.

FEATURES

  • Fast culcuration, Fast array operation

  • Precompile Subroutine, Easy way to C/C++ binding, C99 math functions

  • Perlish syntax, Static typing, Type inference

  • Reference count GC, Weaken reference, Exception, Module

  • Object oriented programming

DOCUMENT

See SPVM Tutorial at first. If you want to know SPVM language, see SPVM Language Specification. If you know SPVM core module, see SPVM Core Modules If you check SPVM performance, see SPVM Performance Benchmark. If you want to convert Perl Data structres to SPVM data structures, see SPVM Exchange API. If you call C function from SPVM, see SPVM Native API.

ENVIRONMENT VARIABLE

SPVM_BUILD_DIR

SPVM build directory for precompile and native subroutine.

If SPVM_BUILD_DIR environment variable is not set, SPVM can't compile precompile subroutine and native subroutine, and a exception occur. You see error message "SPVM_BUILD_DIR environment variable must be set ...".

In bash, you can set SPVM_BUILD_DIR to the following.

  export SPVM_BUILD_DIR=~/.spvm_build

CAUTION

This release is beta release before SPVM 1.0. The features is changed without warnings.

REPOSITORY

SPVM - Github

BUG REPORT

GitHub Issue

SUPPORT

Github Discussions

AUTHOR

Yuki Kimoto <kimoto.yuki@gmail.com>

CORE DEVELOPERS

moti<motohiko.ave@gmail.com>

CONTRIBUTERS

  • Mohammad S Anwar

  • akinomyoga

  • NAGAYASU Shinya

  • Reini Urban

  • chromatic

  • Kazutake Hiramatsu

  • Yasuaki Omokawa

COPYRIGHT & LICENSE

Copyright 2018-2021 Yuki Kimoto, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.