A scheme for dynamically integrating C library functions into a λProlog implementation

06/03/2019
by   Duanyang Jing, et al.
0

The Teyjus system realizes the higher-order logic programming languageλProlog by compiling programs into bytecode for an abstract machine and executing this translated form using a simulator for the machine. Teyjus supports a number of builtin relations that are realized through C code. In the current scheme, these relations are realized by including the C programs that implement them within the simulator and tailoring the compiler to produce instructions to invoke such code. There are two drawbacks to such an approach. First, the entire collection of library functions must be included within the system, thereby leading to a larger than necessary memory footprint. Second, enhancing the collection of built-in predicates requires changing parts of the simulator and compiler, a task whose accomplishment requires specific knowledge of these two subsystems. This project addresses these problems in three steps. First, the code for the builtin functions is moved from the simulator into a library from where relevant parts, determined by information in the bytecode file, are linked into the runtime system at load time. Second, information is associated with each library function about how it can be invoked from a λProlog program and where the C code for it is to be found. Finally, the compiler is modified to use the preceding information to include relevant linking instructions in the bytecode file and to translate invocations to builtin relations into a special instruction that calls the dynamically linked code. More generally, these ideas are capable of supporting an interface in λProlog to "foreign functions" implemented in C, a possibility that is also discussed.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
12/09/2017

Code Generation Techniques for Raw Data Processing

The motivation of the current study was to design an algorithm that can ...
research
02/05/2022

Source Matching and Rewriting

A typical compiler flow relies on a uni-directional sequence of translat...
research
12/19/2021

COX: CUDA on X86 by Exposing Warp-Level Functions to CPUs

As CUDA programs become the de facto program among data parallel applica...
research
10/19/2021

The Creation of Puffin, the Automatic Uncertainty Compiler

An uncertainty compiler is a tool that automatically translates original...
research
05/12/2020

CapablePtrs: Securely Compiling Partial Programs using the Pointers-as-Capabilities Principle

Capability machines such as CHERI provide memory capabilities that can b...
research
04/06/2018

Combinatorial Register Allocation and Instruction Scheduling

This paper introduces a combinatorial optimization approach to register ...
research
05/06/2021

Flex Net Sim: A Lightly Manual

A common problem in elastic optical networks is to study the behavior of...

Please sign up or login with your details

Forgot password? Click here to reset