This commit is contained in:
2024-07-09 08:53:19 +00:00
parent b36ef5eb52
commit f5ec1b8229

View File

@@ -206,9 +206,9 @@ Proposing a computational model for signal processing that is based on the more
Currently, it has been proved that BDA can be converted to a general-purpose functional language in the form of using Arrows, a higher-level abstraction of monads\cite{gaster2018}. But higher-order functions on general-purpose functional languages are often implemented on the basis of dynamic memory allocation and release, which makes it difficult to use them in host languages for the real-time signal processing. Currently, it has been proved that BDA can be converted to a general-purpose functional language in the form of using Arrows, a higher-level abstraction of monads\cite{gaster2018}. But higher-order functions on general-purpose functional languages are often implemented on the basis of dynamic memory allocation and release, which makes it difficult to use them in host languages for the real-time signal processing.
Also, Kronos\cite{norilo2015} and W-calculus\cite{arias2021} are examples of attempts at lambda-calculus-based abstraction, while being influenced by Faust. Kronos is based on the theoretical foundation of System-$F\omega$, a lambda computation in which the type itself is the object of the lambda abstraction (a function can be defined that computes the type and returns a new type). The W-calculus limits the systems it represents to linear time-invariant ones and defines a more formal semantics, aiming at automatic proofs of the identity of graphs with seemingly different topologies, etc. It aims, for example, at automatic proofs of identity between graphs of seemingly different topologies. Also, Kronos\cite{norilo2015} and W-calculus\cite{arias2021} are examples of attempts at lambda-calculus-based abstraction, while being influenced by Faust. Kronos is based on the theoretical foundation of System-$F\omega$, a lambda computation in which the type itself is the object of the lambda abstraction (a function can be defined that computes the type and returns a new type). The W-calculus limits the systems it represents to linear time-invariant ones and defines a more formal semantics, aiming at automatic proofs of the linearlity and an identity of graph topologies.
Previously, the author proposed programming language \textit{mimium} that by adding the basic operators of delay and feedback to lambda-calculus, signal processing can be expressed concisely while having a syntax close to that of general-purpose programming languages\cite{Matsuura2021}. Previously, the author designed a programming language for music \textit{mimium} \cite{Matsuura2021}. It adds the basic operations of delay and feedback to lambda-calculus, signal processing can be expressed concisely while having a syntax close to that of general-purpose programming languages.
In this paper, we present the syntax and semantics of a computational model: \lambdammm, which is an intermediate representation of mimium based on W-calculus. We also propose a virtual machine and its instruction set for efficient execution of this computational model. In this paper, we present the syntax and semantics of a computational model: \lambdammm, which is an intermediate representation of mimium based on W-calculus. We also propose a virtual machine and its instruction set for efficient execution of this computational model.
@@ -265,7 +265,6 @@ In \lambdammm, the problem of memory allocation for closures is left to the impl
The operational semantics of the \lambdammm is shown in Fig.\ref{fig:semantics}. This big-step semantics is a conceptual explanation of the evaluation that, when the current time is $n$, the previous evaluation environment $t$ samples before can be referred to as $E^{n-t}$ , and that when the time < 0, the evaluation of any term is evaluated to the default value of its type (0 for the numeric types). The operational semantics of the \lambdammm is shown in Fig.\ref{fig:semantics}. This big-step semantics is a conceptual explanation of the evaluation that, when the current time is $n$, the previous evaluation environment $t$ samples before can be referred to as $E^{n-t}$ , and that when the time < 0, the evaluation of any term is evaluated to the default value of its type (0 for the numeric types).
\section{VM Model and Instruction Set} \section{VM Model and Instruction Set}
\label{sec:vm} \label{sec:vm}
@@ -275,8 +274,9 @@ When executing a computational model based on lambda calculus, the problem is ho
On the contrary, a runtime performance can be improved by performing a process called closure transformation (or lambda lifting), which analyses all the names of outer variables referred by the inner function and transforms the inner function by adding argument so that the variables can be referred explicitly, but the compiler implementation of the transformation is relatively complex. On the contrary, a runtime performance can be improved by performing a process called closure transformation (or lambda lifting), which analyses all the names of outer variables referred by the inner function and transforms the inner function by adding argument so that the variables can be referred explicitly, but the compiler implementation of the transformation is relatively complex.
The Lua VM takes an intermediate approach between these two by adding the VM instructions \textit{GetUpValue/SetUpValue}, which allows the outer variables to be referenced dynamically at runtime. The implementation of compiler and VM using \textit{UpValue} is simpler than closure conversion, while at the same time preventing execution performance degradation, as outer variables can be referenced via the call stack rather than on the heap memory unless the closure object escapes from the context of the original function\cite{nystrom2021}. The Lua VM takes an intermediate approach between these two by adding the VM instructions \textit{GetUpValue/SetUpValue}, which allows the outer variables to be referenced dynamically at runtime. The implementation of compiler and VM using \textit{Upvalue} is simpler than closure conversion, while at the same time preventing execution performance degradation, as outer variables can be referenced via the call stack rather than on the heap memory unless the closure object escapes from the context of the original function\cite{nystrom2021}.
Also, Upvalue helps interoperations between other programming languages, as Lua can be easily embedded through C language API and even in an external library function written in C, programmer can read and write Lua's Upvalue.
\subsection{Instruction Set} \subsection{Instruction Set}
\label{sec:instruction} \label{sec:instruction}
@@ -286,8 +286,8 @@ VM Instructions for \lambdammm differs from Lua VM in the following respects.
\begin{enumerate} \begin{enumerate}
\item{Since mimium is a statically typed language unlike Lua, instructions for basic arithmetics are provided for each type.} \item{Since mimium is a statically typed language unlike Lua, instructions for basic arithmetics are provided for each type.}
\item{If statements are realised by a combination of two instructions, \textrm{JMP} and \textrm{JMPIFNEG}, whereas the Lua VM uses a dedicated \textrm{TEST} instruction.} \item{If statements are realised by a combination of two instructions, \texttt{JMP} and \texttt{JMPIFNEG}, whereas the Lua VM uses a dedicated \texttt{TEST} instruction.}
\item{Instructions related to for loop, the \textrm{SELF} instruction used for object-oriented programming and the \textrm{TABLE}-related instructions for metadata references to variables are omitted in mimium as they are not used.} \item{Instructions related to for loop, the \texttt{SELF} instruction used for object-oriented programming and the \texttt{TABLE}-related instructions for metadata references to variables are omitted in mimium as they are not used.}
\item{Instructions related to list-related data structures are also omitted in this paper, as the implementation of data structures such as tuples and arrays was omitted in the description of the \lambdammm in this paper.} \item{Instructions related to list-related data structures are also omitted in this paper, as the implementation of data structures such as tuples and arrays was omitted in the description of the \lambdammm in this paper.}
\end{enumerate} \end{enumerate}