4 research outputs found
Customisable Handling of Java References in Prolog Programs
Integration techniques for combining programs written in distinct language
paradigms facilitate the implementation of specialised modules in the best
language for their task. In the case of Java-Prolog integration, a known
problem is the proper representation of references to Java objects on the
Prolog side. To solve it adequately, multiple dimensions should be considered,
including reference representation, opacity of the representation, identity
preservation, reference life span, and scope of the inter-language conversion
policies. This paper presents an approach that addresses all these dimensions,
generalising and building on existing representation patterns of foreign
references in Prolog, and taking inspiration from similar inter-language
representation techniques found in other domains. Our approach maximises
portability by making few assumptions about the Prolog engine interacting with
Java (e.g., embedded or executed as an external process). We validate our work
by extending JPC, an open-source integration library, with features supporting
our approach. Our JPC library is currently compatible with three different open
source Prolog engines (SWI, YAP} and XSB) by means of drivers. To appear in
Theory and Practice of Logic Programming (TPLP).Comment: 10 pages, 2 figure
Lock-free atom garbage collection for multithreaded Prolog
The runtime system of dynamic languages such as Prolog or Lisp and their
derivatives contain a symbol table, in Prolog often called the atom table. A
simple dynamically resizing hash-table used to be an adequate way to implement
this table. As Prolog becomes fashionable for 24x7 server processes we need to
deal with atom garbage collection and concurrent access to the atom table.
Classical lock-based implementations to ensure consistency of the atom table
scale poorly and a stop-the-world approach to implement atom garbage collection
quickly becomes a bottle-neck, making Prolog unsuitable for soft real-time
applications. In this article we describe a novel implementation for the atom
table using lock-free techniques where the atom-table remains accessible even
during atom garbage collection. Relying only on CAS (Compare And Swap) and not
on external libraries, the implementation is straightforward and portable.
Under consideration for acceptance in TPLP.Comment: Paper presented at the 32nd International Conference on Logic
Programming (ICLP 2016), New York City, USA, 16-21 October 2016, 14 pages,
LaTeX, 4 PDF figure
Lightweight compilation of (C)LP to JavaScript
We present and evaluate a compiler from Prolog (and extensions) to JavaScript which makes it possible to use (constraint) logic programming to develop the client side of web applications while being compliant with current industry standards. Targeting JavaScript makes (C)LP programs executable in virtually every modern computing device with no additional software requirements from the point of view of the user. In turn, the use of a very high-level language facilitates the development of high-quality, complex software. The compiler is a back end of the Ciao system and supports most of its features, including its module system and its rich language extension mechanism based on packages. We present an overview of the compilation process and a detailed description of the run-time system, including the support for modular compilation into separate JavaScript code. We demonstrate the maturity of the compiler by testing it with complex code such as a CLP(FD) library written in Prolog with attributed variables. Finally, we validate our proposal by measuring the performance of some LP and CLP(FD) benchmarks running on top of major JavaScript engines