Giter Club home page Giter Club logo

gojit's Introduction

gojit -- pure-golang runtime code-generation

This is the result of my spending the hack day at Gophercon 2014 playing with doing JIT from golang code. This repository contains several packages:

  • gojit

    Contains the basic JIT support -- allocate executable chunks of memory, and convert them into callable golang functions.

  • amd64

    Contains a simplistic amd64 assembler designed for use with gojit

  • bf

    Contains a just-in-time compiler for Brainfuck that demos the above packages

  • gobf

    Contains a binary that provides a command-line interface to bf

Using

gobf can be fetched using

go get github.com/nelhage/gojit/gobf

And then run as gobf file.bf. For some built-in examples:

$ gobf $GOPATH/src/github.com/nelhage/gojit/bf/test/hello.bf
Hello World!
$ gobf $GOPATH/src/github.com/nelhage/gojit/bf/test/hello.bf | gobf $GOPATH/src/github.com/nelhage/gojit/bf/test/rot13.bf
Uryyb Jbeyq!

Portability

This code has been tested on darwin/amd64 and linux/amd64. It is extremely unlikely to work anywhere else.

gojit's People

Contributors

alex avatar jamesdunne avatar nelhage avatar sbinet 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

gojit's Issues

tests fail on go1.5 (pass on go1.4.2) darwin/amd64

Elliotts-MacBook-Pro15:gojit elliott$ go test
unexpected fault address 0x1000
fatal error: fault
[signal 0xb code=0x1 addr=0x1000 pc=0x1000]

goroutine 20 [running]:
runtime.throw(0x4187c48, 0x5)
    /usr/local/go/src/runtime/panic.go:527 +0x90 fp=0xc82003ce38 sp=0xc82003ce20
runtime.sigpanic()
    /usr/local/go/src/runtime/sigpanic_unix.go:27 +0x2ba fp=0xc82003ce88 sp=0xc82003ce38
created by testing.RunTests
    /usr/local/go/src/testing/testing.go:561 +0x86d

goroutine 1 [chan receive]:
testing.RunTests(0x41cd6e8, 0x4245180, 0x2, 0x2, 0x1)
    /usr/local/go/src/testing/testing.go:562 +0x8ad
testing.(*M).Run(0xc820051ef8, 0xc820076550)
    /usr/local/go/src/testing/testing.go:494 +0x70
main.main()
    github.com/nelhage/gojit/_test/_testmain.go:60 +0x116

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1696 +0x1
exit status 2
FAIL    github.com/nelhage/gojit    0.011s

License / Open source

Hi!

Any plans on open sourcing / adding a license file?

I'd love to use this and try to fix the issue with go 1.5, but hesitant to dig into the source as there is no license information.

Thanks!

example for JIT-ing a reflect.Func

hi,

it would be very interesting to be able to JIT, say, a simple reflect.Func or an equivalently simple go func().
The obvious use-case being a decoder/encoder (un|de)serialization layer...

I'd be happy with an adder func() to start with :)

-s

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.