diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..c6fcc550fc
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,10 @@
+language: nix
+sudo: false
+script:
+ - nix-build -A test-O3
+ - nix-build -A test-O2
+ - nix-build -A test-O1
+ - nix-build -A test-nojit
+ - nix-build -A test-capi
+ - nix-build -A test-libraptorjit
+ - nix-build -A check-generated-code --arg check true
diff --git a/CONDUCT.md b/CONDUCT.md
new file mode 100644
index 0000000000..38f2cb8f96
--- /dev/null
+++ b/CONDUCT.md
@@ -0,0 +1,7 @@
+### Code of conduct
+
+Follow the [Contributor Covenant](http://contributor-covenant.org/) and report problems to `lukego@gmail.com`.
+
+Help people achieve their goals. Don't stand between people who want to cooperate.
+
+Keep people in the loop. Use Github Issues for important discussions.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..5d56fb834e
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,21 @@
+Thank you for your contribution!
+
+Please be aware that RaptorJIT is [Apache 2.0 licensed](https://www.apache.org/licenses/LICENSE-2.0)
+and when you contribute code you are also releasing it under the same
+license. If this is a problem, for example because you are unwilling
+or unable to release your code under this license, then please explain
+the situation in your pull request so that we can find an appropriate
+solution.
+
+Please do not put individual copyright notices into source files. This
+leads to clutter over time and complicates refactoring. If you own the
+copyright of your contribution then this will be implicit in the Git
+history (as clarified in the COPYING/COPYRIGHT files) and no notice is
+needed. If you are not the copyright owner, perhaps due to a copyright
+assignment agreement with your employer, then please mention this in
+your Pull Request and we will add an appropriate clarification to the
+COPYRIGHT file.
+
+Please also respect the
+[Contributor Covenant Code of Conduct](http://contributor-covenant.org/version/1/4/)
+in your interactions with the RaptorJIT community.
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000000..e1d5871f5c
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,217 @@
+RaptorJIT is a fork of LuaJIT. Code merged from LuaJIT is copyright
+Mike Pall and released under the MIT license.
+
+New code contributed independently to RaptorJIT is licensed under the
+Apache License 2.0 and its copyright is retained by the original
+authors (except as otherwise noted in this file.)
+
+Here are the copyright and license terms for the code from LuaJIT:
+
+ LuaJIT is Copyright (C) 2005-2017 Mike Pall.
+ LuaJIT is free software, released under the MIT license.
+ See full Copyright Notice in the COPYRIGHT file or in luajit.h.
+
+Here is the Apache License that applies to all other code (apart from
+exceptions noted in this file):
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/COPYRIGHT b/COPYRIGHT
index 6ed40025ae..17a037c14e 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,3 +1,10 @@
+RaptorJIT -- a LuaJIT fork for Linux/x86-64.
+
+Copyright is retained by the individual authors and contributors.
+
+[ Apache 2.0 license - see the file COPYING. ]
+
+[ RaptorJIT includes code from LuaJIT 2.1 which has the following statements: ]
===============================================================================
LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
diff --git a/Makefile b/Makefile
index 489d7e754c..8a0d5b0253 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
##############################################################################
-# LuaJIT top level Makefile for installation. Requires GNU Make.
+# RaptorJIT top level Makefile for installation. Requires GNU Make.
#
# Please read doc/install.html before changing any variables!
#
@@ -13,10 +13,10 @@
# Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
##############################################################################
-MAJVER= 2
-MINVER= 1
+MAJVER= 1
+MINVER= 0
RELVER= 0
-PREREL= -beta2
+PREREL=
VERSION= $(MAJVER).$(MINVER).$(RELVER)$(PREREL)
ABIVER= 5.1
@@ -33,27 +33,22 @@ DPREFIX= $(DESTDIR)$(PREFIX)
INSTALL_BIN= $(DPREFIX)/bin
INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
INSTALL_SHARE= $(DPREFIX)/share
-INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
+INSTALL_INC= $(DPREFIX)/include/raptorjit-$(MAJVER).$(MINVER)
-INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION)
+INSTALL_LJLIBD= $(INSTALL_SHARE)/raptorjit-$(VERSION)
INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
-INSTALL_LMODD= $(INSTALL_SHARE)/lua
-INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER)
-INSTALL_CMODD= $(INSTALL_LIB)/lua
-INSTALL_CMOD= $(INSTALL_CMODD)/$(ABIVER)
-INSTALL_MAN= $(INSTALL_SHARE)/man/man1
INSTALL_PKGCONFIG= $(INSTALL_LIB)/pkgconfig
-INSTALL_TNAME= luajit-$(VERSION)
-INSTALL_TSYMNAME= luajit
-INSTALL_ANAME= libluajit-$(ABIVER).a
-INSTALL_SOSHORT1= libluajit-$(ABIVER).so
-INSTALL_SOSHORT2= libluajit-$(ABIVER).so.$(MAJVER)
+INSTALL_TNAME= raptorjit-$(VERSION)
+INSTALL_TSYMNAME= raptorjit
+INSTALL_ANAME= libraptorjit-$(ABIVER).a
+INSTALL_SOSHORT1= libraptorjit-$(ABIVER).so
+INSTALL_SOSHORT2= libraptorjit-$(ABIVER).so.$(MAJVER)
INSTALL_SONAME= $(INSTALL_SOSHORT2).$(MINVER).$(RELVER)
-INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib
-INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib
-INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib
-INSTALL_PCNAME= luajit.pc
+INSTALL_DYLIBSHORT1= libraptorjit-$(ABIVER).dylib
+INSTALL_DYLIBSHORT2= libraptorjit-$(ABIVER).$(MAJVER).dylib
+INSTALL_DYLIBNAME= libraptorjit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib
+INSTALL_PCNAME= raptorjit.pc
INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME)
INSTALL_DYN= $(INSTALL_LIB)/$(INSTALL_SONAME)
@@ -63,10 +58,9 @@ INSTALL_T= $(INSTALL_BIN)/$(INSTALL_TNAME)
INSTALL_TSYM= $(INSTALL_BIN)/$(INSTALL_TSYMNAME)
INSTALL_PC= $(INSTALL_PKGCONFIG)/$(INSTALL_PCNAME)
-INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) $(INSTALL_MAN) \
- $(INSTALL_PKGCONFIG) $(INSTALL_JITLIB) $(INSTALL_LMOD) $(INSTALL_CMOD)
-UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC) \
- $(INSTALL_LMOD) $(INSTALL_LMODD) $(INSTALL_CMOD) $(INSTALL_CMODD)
+INSTALL_DIRS= $(INSTALL_BIN) $(INSTALL_LIB) $(INSTALL_INC) \
+ $(INSTALL_JITLIB)
+UNINSTALL_DIRS= $(INSTALL_JITLIB) $(INSTALL_LJLIBD) $(INSTALL_INC)
RM= rm -f
MKDIR= mkdir -p
@@ -79,16 +73,12 @@ LDCONFIG= ldconfig -n
SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
-e "s|^multilib=.*|multilib=$(MULTILIB)|"
-FILE_T= luajit
-FILE_A= libluajit.a
-FILE_SO= libluajit.so
-FILE_MAN= luajit.1
-FILE_PC= luajit.pc
+FILE_T= raptorjit
+FILE_A= libraptorjit.a
+FILE_SO= libraptorjit.so
+FILE_PC= raptorjit.pc
FILES_INC= lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h
-FILES_JITLIB= bc.lua bcsave.lua dump.lua p.lua v.lua zone.lua \
- dis_x86.lua dis_x64.lua dis_arm.lua dis_arm64.lua \
- dis_ppc.lua dis_mips.lua dis_mipsel.lua dis_mips64.lua \
- dis_mips64el.lua vmdef.lua
+FILES_JITLIB= bc.lua bcsave.lua vmdef.lua
ifeq (,$(findstring Windows,$(OS)))
HOST_SYS:= $(shell uname -s)
@@ -106,15 +96,18 @@ endif
##############################################################################
-INSTALL_DEP= src/luajit
+INSTALL_DEP= src/raptorjit
default all $(INSTALL_DEP):
- @echo "==== Building LuaJIT $(VERSION) ===="
+ @echo "==== Building RaptorJIT $(VERSION) ===="
$(MAKE) -C src
- @echo "==== Successfully built LuaJIT $(VERSION) ===="
+ @echo "==== Successfully built RaptorJIT $(VERSION) ===="
+
+reusevm:
+ $(MAKE) -C src reusevm
install: $(INSTALL_DEP)
- @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ===="
+ @echo "==== Installing RaptorJIT $(VERSION) to $(PREFIX) ===="
$(MKDIR) $(INSTALL_DIRS)
cd src && $(INSTALL_X) $(FILE_T) $(INSTALL_T)
cd src && test -f $(FILE_A) && $(INSTALL_F) $(FILE_A) $(INSTALL_STATIC) || :
@@ -124,24 +117,18 @@ install: $(INSTALL_DEP)
$(LDCONFIG) $(INSTALL_LIB) && \
$(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT1) && \
$(SYMLINK) $(INSTALL_SONAME) $(INSTALL_SHORT2) || :
- cd etc && $(INSTALL_F) $(FILE_MAN) $(INSTALL_MAN)
cd etc && $(SED_PC) $(FILE_PC) > $(FILE_PC).tmp && \
- $(INSTALL_F) $(FILE_PC).tmp $(INSTALL_PC) && \
+ $(INSTALL_F) -D $(FILE_PC).tmp $(INSTALL_PC) && \
$(RM) $(FILE_PC).tmp
cd src && $(INSTALL_F) $(FILES_INC) $(INSTALL_INC)
cd src/jit && $(INSTALL_F) $(FILES_JITLIB) $(INSTALL_JITLIB)
- @echo "==== Successfully installed LuaJIT $(VERSION) to $(PREFIX) ===="
- @echo ""
- @echo "Note: the development releases deliberately do NOT install a symlink for luajit"
- @echo "You can do this now by running this command (with sudo):"
- @echo ""
- @echo " $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)"
+ $(SYMLINK) $(INSTALL_TNAME) $(INSTALL_TSYM)
@echo ""
uninstall:
- @echo "==== Uninstalling LuaJIT $(VERSION) from $(PREFIX) ===="
- $(UNINSTALL) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2) $(INSTALL_MAN)/$(FILE_MAN) $(INSTALL_PC)
+ @echo "==== Uninstalling RaptorJIT $(VERSION) from $(PREFIX) ===="
+ $(UNINSTALL) $(INSTALL_T) $(INSTALL_STATIC) $(INSTALL_DYN) $(INSTALL_SHORT1) $(INSTALL_SHORT2)
for file in $(FILES_JITLIB); do \
$(UNINSTALL) $(INSTALL_JITLIB)/$$file; \
done
@@ -150,17 +137,16 @@ uninstall:
done
$(LDCONFIG) $(INSTALL_LIB)
$(RMDIR) $(UNINSTALL_DIRS) || :
- @echo "==== Successfully uninstalled LuaJIT $(VERSION) from $(PREFIX) ===="
+ @echo "==== Successfully uninstalled RaptorJIT $(VERSION) from $(PREFIX) ===="
##############################################################################
-amalg:
- @echo "Building LuaJIT $(VERSION)"
- $(MAKE) -C src amalg
-
clean:
$(MAKE) -C src clean
-.PHONY: all install amalg clean
+bootstrapclean:
+ $(MAKE) -C src bootstrapclean
+
+.PHONY: all install clean
##############################################################################
diff --git a/PROFESSIONAL-SUPPORT.md b/PROFESSIONAL-SUPPORT.md
new file mode 100644
index 0000000000..30dcd0bccf
--- /dev/null
+++ b/PROFESSIONAL-SUPPORT.md
@@ -0,0 +1,10 @@
+Professional support is available to help you use RaptorJIT
+successfully. You can contact the parties listed below if you need
+help to design your application; to understand the compiler and the
+tools; to fix bugs and optimize code; to maintain a port to a new
+platform; etc.
+
+Links in alphabetical order with one-sentence summaries:
+
+- [Snabb Solutions](https://snabb.solutions/) offers consulting and standard support agreements for RaptorJIT and related projects.
+
diff --git a/README b/README
deleted file mode 100644
index 719e6118ab..0000000000
--- a/README
+++ /dev/null
@@ -1,16 +0,0 @@
-README for LuaJIT 2.1.0-beta2
------------------------------
-
-LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
-
-Project Homepage: http://luajit.org/
-
-LuaJIT is Copyright (C) 2005-2017 Mike Pall.
-LuaJIT is free software, released under the MIT license.
-See full Copyright Notice in the COPYRIGHT file or in luajit.h.
-
-Documentation for LuaJIT is available in HTML format.
-Please point your favorite browser to:
-
- doc/luajit.html
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..d7b0247db5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,205 @@
+
+
+[![Build Status](https://travis-ci.org/raptorjit/raptorjit.svg?branch=master)](https://travis-ci.org/raptorjit/raptorjit)
+
+**RaptorJIT** is a Lua implementation suitable for high-performance
+low-level system programming. If you want to use a simple dynamic
+language to write a network stack; a hypervisor; a unikernel; a
+database; etc, then you have come to the right place.
+
+RaptorJIT is a fork of [LuaJIT](https://luajit.org/) where we aim to
+provide:
+
+- Ubiquitous tracing and profiling to make application
+ performance and compiler behaviour transparent to programmers.
+- Interactive tools for inspecting and cross-referencing
+ trace and profiler data ([Studio](https://github.com/studio/studio/)).
+- Collaborative and distributed development based on the Linux kernel
+ fork-and-merge model.
+
+The most notable technical changes since forking LuaJIT are:
+
+- Added `auditlog` and `vmprofile` low-overhead ("always on") binary
+ tracing and profiler logging features. Removed obsoleted tracing
+ based on introspection including `jit.v`, `jit.dump`, and `jit.p`.
+- Reduced code maintenance footprint ~50% by removing `#ifdef`
+ features that are not required for Linux/x86-64 e.g. Windows
+ support, 32-bit heap support, and non-x86 backends. This is a
+ necessary short-term expedient to make the code maintainable while
+ we bootstrap the project.
+- Compiler heuristics tightened to reduce the risk of bytecode
+ blacklisting causing catastrophic performance drops.
+- Started using `git merge` to accept contributions of both code and
+ development history from other forks.
+
+RaptorJIT is used successfully by
+the [Snabb](https://github.com/snabbco/snabb) community to develop
+high-performance production network equipment. Join us!
+
+### RaptorJIT compilation for users
+
+Build using LuaJIT to bootstrap the VM:
+
+```shell
+$ make # requires LuaJIT (2.0 or 2.1) to run DynASM
+```
+
+Build without bootstrapping, when not hacking the VM:
+
+```shell
+$ make reusevm # Reuse reference copy of the generated VM code
+$ make # Does not require LuaJIT now
+```
+
+### Inspecting trace and profiler data interactively
+
+To understand how your program executes you first produce diagnostic data (*auditlog* and *vmprofile* files) and then you inspect them interactively with [Studio](https://github.com/studio/studio).
+
+You can produce diagnostic data on the command line:
+
+```shell
+$ raptorjit -a audit.log -p default.vmprofile ...
+```
+
+Or within your Lua code:
+
+```lua
+jit.auditlog("audit.log")
+local vmprofile = require("jit.vmprofile")
+vmprofile.open("default.vmprofile")
+```
+
+Then you can copy the file `audit.log` and `*.vmprofile` into a
+directory `/somepath` and inspect that with the Studio script:
+
+```
+with import ;
+raptorjit.inspect /somepath
+```
+
+Studio will then parse, analyze, cross-reference, etc, the diagnostic
+data and present an interactive user-interface for browsing how the
+program ran.
+
+Here are tutorial videos for Studio:
+
+- [How to load Snabb diagnostic data into Studio](https://www.youtube.com/watch?v=x6e1vFFpq5Q). Covers installing Studio and running a script. (Uses a Snabb-specific mechanism for producing diagnostic data which is implemented in Lua.)
+- [Inspecting RaptorJIT IR code with Studio](https://www.youtube.com/watch?v=MQyxXSPXcwg). Covers profiling and inspecting small Lua scripts. Runs Lua code directly from the Studio UI.
+
+### RaptorJIT compilation for VM hackers
+
+RaptorJIT uses [Nix](http://nixos.org/nix/) to provide a reference
+build environment. You can use Nix to build/test/benchmark RaptorJIT
+with suitable versions of all dependencies provided.
+
+Note: Building with nix will be slow the first time because it
+downloads the exact reference versions of the toolchain (gcc, etc)
+and all dependencies (glibc, etc). This is all cached for future
+builds.
+
+#### Build with nix
+
+Install nix:
+
+```
+$ curl https://nixos.org/nix/install | sh
+```
+
+Build in batch-mode and run the test suite (option 1a):
+
+```shell
+$ nix-build # produces result/bin/raptorjit
+```
+
+Build in batch-mode without the test suite (option 1b):
+
+```shell
+$ nix-build -A raptorjit
+```
+
+Build interactively (option 2):
+
+```shell
+$ nix-shell # start sub-shell with pristine build environment in $PATH
+[nix-shell]$ make -j # build manually as many times as you like
+[nix-shell]$ exit # quit when done
+```
+
+#### Build without nix
+
+```shell
+$ make
+```
+
+... but make sure you have at least `make`, `gcc`, and `luajit` in your `$PATH`.
+
+### Run the benchmarks
+
+Nix can also run the full benchmark suite and generate visualizations
+with R/ggplot2.
+
+The simplest incantation tests one branch:
+
+```shell
+$ nix-build testsuite/bench --arg Asrc ./. # note: ./. means ./
+```
+
+You can also test several branches (A-E), give them names, specify
+command-line arguments, say how many tests to run, and allow parallel
+execution:
+
+```shell
+# Run the benchmarks and create result visualizations result/
+$ nix-build testsuite/bench \
+ --arg Asrc ~/git/raptorjit \
+ --argstr Aname master \
+ --arg Bsrc ~/git/raptorjit-hack \
+ --argstr Bname hacked \
+ --arg Csrc ~/git/raptorjit-hack2 \
+ --argstr Cname hacked-O1 \
+ --argstr Cargs -O1 \
+ --arg runs 100 \
+ -j 5 # Run up to 5 tests in parallel
+```
+
+If you are using a distributed nix environment such
+as [Hydra](https://nixos.org/hydra/) then the tests can be
+automatically parallelized and distributed across a suitable build
+farm.
+
+### Optimization resources
+
+These are the authoritative optimization resources for processors
+supported by RaptorJIT. If you are confused by references to CPU
+details in discussions then these are the places to look for answers.
+
+- [Computer Architecture: A Quantitative Approach](https://www.amazon.com/Computer-Architecture-Fifth-Quantitative-Approach/dp/012383872X) by Hennessy and Patterson.
+- [Intel Architectures Optimization Reference Manual](http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html).
+- Agner Fog's [software optimization resources](http://www.agner.org/optimize/):
+ - [Instruction latency and throughput tables](http://www.agner.org/optimize/instruction_tables.pdf).
+ - [Microarchitecture of Intel, AMD, and VIA CPUs](http://www.agner.org/optimize/microarchitecture.pdf).
+ - [Optimizing subroutines in assembly language for x86](http://www.agner.org/optimize/optimizing_assembly.pdf).
+
+The [AnandTech review of the Haswell microarchitecture](http://www.anandtech.com/show/6355/intels-haswell-architecture) is also excellent lighter reading.
+
+### Quotes
+
+Here are some borrowed words to put this branch into context:
+
+> I'm outta here in a couple of days. Good luck. You'll need it.
+> _[Mike Pall](http://www.freelists.org/post/luajit/Turning-Lua-into-C-was-alleviate-the-load-of-the-GC)_
+
+> Optimal code is not optimal to maintain. _[Vyacheslav Egorov](https://www.youtube.com/watch?v=EaLboOUG9VQ)_
+
+> If a programmer is indispensable, get rid of him as quickly as possible. _[Gerald M. Weinberg](https://www.amazon.com/Psychology-Computer-Programming-Silver-Anniversary/dp/0932633420)_
+
+> If a system is to serve the creative spirit, it
+> must be entirely comprehensible to a single individual. _[Dan
+> Ingalls](https://www.cs.virginia.edu/~evans/cs655/readings/smalltalk.html)_
+
+> The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague. _[E.W. Dijkstra](https://www.cs.utexas.edu/~EWD/transcriptions/EWD03xx/EWD340.html)_
+
+> There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. _[C.A.R. Hoare](http://zoo.cs.yale.edu/classes/cs422/2014/bib/hoare81emperor.pdf)_
+
+> Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? _[Brian Kernighan](http://www2.ing.unipi.it/~a009435/issw/extra/kp_elems_of_pgmng_sty.pdf)_
+
diff --git a/check-generated-code.nix b/check-generated-code.nix
new file mode 100644
index 0000000000..78ff51b2f8
--- /dev/null
+++ b/check-generated-code.nix
@@ -0,0 +1,20 @@
+# Check that generated sources match the repo version.
+{ pkgs, raptorjit }:
+with pkgs; with lib;
+
+# Generated files that are kept in tree.
+let generatedFiles =
+ "lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h";
+in
+
+overrideDerivation raptorjit (as:
+ {
+ checkPhase = ''
+ for f in ${generatedFiles}; do
+ echo "checking $f.."
+ diff -u src/reusevm/$f src/$f
+ done
+ echo "all files ok"
+ '';
+ doCheck = true;
+ })
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000000..59500d4725
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,48 @@
+# default.nix - define the build environment for RaptorJIT
+#
+# This file can be used by 'nix-build' or 'nix-shell' to create a
+# pristine build environment with precisely the expected software in
+# $PATH. This makes it possible to build raptorjit in the same way on
+# any machine.
+#
+# See README.md for usage instructions.
+
+{ pkgs ? (import ./pkgs.nix) {}
+, source ? pkgs.lib.cleanSource ./.
+, version ? "dev"
+, check ? false }:
+
+let
+ callPackage = (pkgs.lib.callPackageWith { inherit pkgs source version; });
+ raptorjit = (callPackage ./raptorjit.nix {});
+ raptorjit-assert = raptorjit.overrideAttrs(
+ old: { NIX_CFLAGS_COMPILE = " -DLUA_USE_ASSERT"; });
+ test = name: args: (callPackage ./test.nix { inherit name args; raptorjit = raptorjit-assert; });
+ test-capi = callPackage ./test-capi.nix { inherit pkgs raptorjit; };
+ test-libraptorjit = callPackage ./test-libraptorjit.nix { inherit pkgs raptorjit; };
+ check-generated-code = (callPackage ./check-generated-code.nix { inherit raptorjit; });
+ nowarnings = raptorjit.overrideAttrs(
+ old: { NIX_CFLAGS_COMPILE = "-Werror"; });
+in
+
+# Build RaptorJIT and run multiple test suites.
+{
+ raptorjit = raptorjit;
+ test-O3 = test "O3" "-O3";
+ test-O2 = test "O2" "-O2";
+ test-O1 = test "O1" "-O1";
+ test-nojit = test "nojit" "-joff";
+ test-capi = test-capi;
+ test-libraptorjit = test-libraptorjit;
+ # Test that generated bytecode is compatible
+ test-bytecode-compat = pkgs.runCommand "test-bytecode-compat"
+ { buildInputs = [ raptorjit ]; }
+ ''
+ echo "print('ok')" > test.lua
+ raptorjit -bg test.lua test.raw
+ raptorjit test.raw | grep ok
+ touch $out
+ '';
+} //
+(if check then { inherit nowarnings check-generated-code; } else {})
+
diff --git a/doc/changes.html b/doc/changes.html
index 426b18f783..44e03293c3 100644
--- a/doc/changes.html
+++ b/doc/changes.html
@@ -44,8 +44,6 @@ LuaJIT Change History
jit.* Library
Lua/C API
-
-Profiler
Status
diff --git a/doc/contact.html b/doc/contact.html
index fe4751c0ea..5e07bded58 100644
--- a/doc/contact.html
+++ b/doc/contact.html
@@ -41,8 +41,6 @@ Contact
jit.* Library
Lua/C API
-
-Profiler
Status
diff --git a/doc/ext_c_api.html b/doc/ext_c_api.html
index ad462c63e5..041a722009 100644
--- a/doc/ext_c_api.html
+++ b/doc/ext_c_api.html
@@ -41,8 +41,6 @@ Lua/C API Extensions
jit.* Library
Lua/C API
-
-Profiler
Status
diff --git a/doc/ext_ffi.html b/doc/ext_ffi.html
index 5e1daaf54b..d48d77fae3 100644
--- a/doc/ext_ffi.html
+++ b/doc/ext_ffi.html
@@ -41,8 +41,6 @@ FFI Library
jit.* Library
Lua/C API
-
-Profiler
Status
diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html
index 91af2e1d43..5cedcf0e7e 100644
--- a/doc/ext_ffi_api.html
+++ b/doc/ext_ffi_api.html
@@ -46,8 +46,6 @@ ffi.* API Functions
jit.* Library
Lua/C API
-
-Profiler
Status
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html
index bba03b7b43..f7480be0dd 100644
--- a/doc/ext_ffi_semantics.html
+++ b/doc/ext_ffi_semantics.html
@@ -46,8 +46,6 @@ FFI Semantics
jit.* Library
Lua/C API
-
-Profiler
Status
@@ -864,7 +862,7 @@ Parameterized Types
The main use for parameterized types are libraries implementing abstract
data types
-(» example),
+(example),
similar to what can be achieved with C++ template metaprogramming.
Another use case are derived types of anonymous structs, which avoids
pollution of the global struct namespace.
@@ -1215,19 +1213,17 @@
Current Status
The JIT compiler already handles a large subset of all FFI operations.
It automatically falls back to the interpreter for unimplemented
-operations (you can check for this with the
--jv command line option).
+operations.
The following operations are currently not compiled and may exhibit
suboptimal performance, especially when used in inner loops:
-- Bitfield accesses and initializations.
- Vector operations.
- Table initializers.
- Initialization of nested struct/union types.
- Non-default initialization of VLA/VLS or large C types
(> 128 bytes or > 16 array elements.
-- Conversions from lightuserdata to void *.
+- Bitfield initializations.
- Pointer differences for element sizes that are not a power of
two.
- Calls to C functions with aggregates passed or returned by
diff --git a/doc/ext_ffi_tutorial.html b/doc/ext_ffi_tutorial.html
index 3650066440..29cf549e2c 100644
--- a/doc/ext_ffi_tutorial.html
+++ b/doc/ext_ffi_tutorial.html
@@ -48,8 +48,6 @@
FFI Tutorial
jit.* Library
-
Lua/C API
-
-
-Profiler
Status
diff --git a/doc/ext_jit.html b/doc/ext_jit.html
index e4088bcbd2..0b0924a896 100644
--- a/doc/ext_jit.html
+++ b/doc/ext_jit.html
@@ -41,8 +41,6 @@ jit.* Library
jit.* Library
Lua/C API
-
-Profiler
Status
@@ -176,17 +174,6 @@ jit.opt.* — JIT compiler optimization control
-jit.util.* — JIT compiler introspection
-
-This sub-module holds functions to introspect the bytecode, generated
-traces, the IR and the generated machine code. The functionality
-provided by this module is still in flux and therefore undocumented.
-
-
-The debug modules -jbc, -jv and -jdump make
-extensive use of these functions. Please check out their source code,
-if you want to know more.
-