Giter Club home page Giter Club logo

el-compilador's People

Contributors

tromey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

el-compilador's Issues

implement functions needed by C back end

The C back end assumes that a few special functions can be defined by Emacs to implement primitives like catch. See elcomp--c-direct-renames ... the names here are invented and can be changed, but what is important is implementing these in the C core.

  • :elcomp-fetch-condition: evaluates to the error value in the error branch of a condition-case
  • :save-excursion-save and :save-excursion-restore: save and restore excursion data. These might be very easy based on the implementation of Fsave_excursion
  • :save-restriction-save, :save-restriction-restore: Ditto for restrictions. Also maybe easy.
  • :unwind-protect-continue: Called at the end of an unwind-protect to re-throw the exception in flight
  • :catch-value: Return the value thrown via throw
  • PUSH_HANDLER is emitted in various spots but is gone from lisp.h
  • handler_matches: emitted by elcomp--c-emit-condition-case to handle case matching

solve compile-time issues

Currently el-compile knows to handle eval-when-compile but it also needs some special treatment for defvar (mark as special), defmacro, and defsubst. Maybe special treatment for defconst would also be valuable.

missing loop optimization

Consider this code:

(elcomp--do '(
	      (defun test-case ()
		(let ((i 0) (s 0))
		  (while (<= i 10000000)
		    (setq s (+ s i))
		    (setq i (1+ i)))
		  ))

	      )
	    ;; #'elcomp--c-translate
	    )

Here the compiler should be able to entirely eliminate the loop.

el-compile command-line processing

The el-compile script currently doesn't really do command-linen processing. It should at least accept a list of .el files and an optional C output file name.

ffi support

elcomp should support the emacs-ffi API so that the C back end can compile code using it directly to the expected C.

extra handlerlist pop from unwind-protect

The C output for a simple unwind-protect case, like:

; -*- lexical-binding:t -*-
(defun x ()
  (save-excursion
    (message "hi")))

Ends up with:

  PUSH_HANDLER (h1, Qnil, UNWIND_PROTECT);
  if (sys_setjmp (h1->jmp))
    {
      handlerlist = handlerlist->next;
      goto BB_1;
    }
...
BB_1:
  handlerlist = handlerlist->next;

One of these is redundant.

include Qlsh in list of known functions

The compiler can emit an indirect call via Qlsh, but this is a good candidate for a direct call. There may be other simple math operations like this to check.

Reuse el-compilador SSA form to generate standard Emacs VM bytecode

Recently I began thinking about improving the built-in Emacs optimizer by converting lap code into SSA form, doing usual optimisations and converting back into lap code (or simplified Elisp).

Eventually I stumbled upon your project. It looks almost done, with everything ready, only one more backend needed.

So, I have a few of questions:

  1. Which algorithm do you use to build SSA? The code I saw looks a bit ad hoc.
  2. Why did you dump the project? Any problems I should be aware of?
  3. Any recommendations? Like things I have to look into, lacking functionality, etc?

Thank you!

SSA vs CPS for Lisp?

Hello,

I'm interested in Lisp compiler technology. I see you chose the SSA framework for your compiler. Some other compilers for functional-ish languages use CPS. Do you have an opinion on whether SSA or CPS is best suited for compiling Lisp?

specialize some built-in functions in C back end

Currently length (e.g.) is marked as :elcomp-direct. This is good but it could go farther by using type inference information. For example, length could lower to various macros like ASIZE or SCHARS.

Start a test suite

Currently there's no test suite but there should be one. It's not totally clear how it should work -- pattern-match the expected IR? Write an interpreter for the IR, then interpret various test cases?

miscompiles json--plist-reverse

I tried compiling json--plist-reverse. The compiler doesn't initialize a variable near the top.

BB_0:
  res_219 = Qnil;
  if (!NILP (plist_220))
    {
      goto BB_3;
    }

Here plist_220 should be initialized from plist.

compile regexps

Some uses of regular expressions could be compiled to inline code. Some ideas:

  • Match data is a bit of a problem but at least looking-at-p exists; maybe some other macros could be written to make this a bit better
  • Can use lex-parse-re from the lex package to parse a regexp to rx syntax

missed numeric optimizations with type-check

Consider if json--decode-utf16-surrogates checked the input types:

(defun json--decode-utf-16-surrogates (high low)
  "Return the code point represented by the UTF-16 surrogates HIGH and LOW."
  (cl-check-type high integer)
  (cl-check-type low integer)
  (+ (lsh (- high #xD800) 10) (- low #xDC00) #x10000))

This should compile to some ordinary arithmetic. Instead the compiler emits calls to Fminus, Qlsh, etc.

doc string support in C back end

Maybe the C back end should not use DEFUN but instead emit doc strings a different way? The current approach seems to require extra build steps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.