LuaJIT 2.0.4

This commit is contained in:
darealshinji 2015-09-12 12:38:01 +02:00
parent 1f7a59afcb
commit 541a9ad590
163 changed files with 559 additions and 424 deletions

View File

@ -1,7 +1,7 @@
=============================================================================== ===============================================================================
LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
Copyright (C) 2005-2014 Mike Pall. All rights reserved. Copyright (C) 2005-2015 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,11 +1,11 @@
README for LuaJIT 2.0.3 README for LuaJIT 2.0.4
----------------------- -----------------------
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
Project Homepage: http://luajit.org/ Project Homepage: http://luajit.org/
LuaJIT is Copyright (C) 2005-2014 Mike Pall. LuaJIT is Copyright (C) 2005-2015 Mike Pall.
LuaJIT is free software, released under the MIT license. LuaJIT is free software, released under the MIT license.
See full Copyright Notice in the COPYRIGHT file or in luajit.h. See full Copyright Notice in the COPYRIGHT file or in luajit.h.

View File

@ -1,6 +1,6 @@
/* /*
** DynASM ARM encoding engine. ** DynASM ARM encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved. ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM ARM module. -- DynASM ARM module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -923,19 +923,22 @@ local function parse_template(params, template, nparams, pos)
end end
map_op[".template__"] = function(params, template, nparams) map_op[".template__"] = function(params, template, nparams)
if not params then return sub(template, 9) end if not params then return template:gsub("%x%x%x%x%x%x%x%x", "") end
-- Limit number of section buffer positions used by a single dasm_put(). -- Limit number of section buffer positions used by a single dasm_put().
-- A single opcode needs a maximum of 3 positions. -- A single opcode needs a maximum of 3 positions.
if secpos+3 > maxsecpos then wflush() end if secpos+3 > maxsecpos then wflush() end
local pos = wpos() local pos = wpos()
local apos, spos = #actargs, secpos local lpos, apos, spos = #actlist, #actargs, secpos
local ok, err local ok, err
for t in gmatch(template, "[^|]+") do for t in gmatch(template, "[^|]+") do
ok, err = pcall(parse_template, params, t, nparams, pos) ok, err = pcall(parse_template, params, t, nparams, pos)
if ok then return end if ok then return end
secpos = spos secpos = spos
actlist[lpos+1] = nil
actlist[lpos+2] = nil
actlist[lpos+3] = nil
actargs[apos+1] = nil actargs[apos+1] = nil
actargs[apos+2] = nil actargs[apos+2] = nil
actargs[apos+3] = nil actargs[apos+3] = nil

View File

@ -1,6 +1,6 @@
/* /*
** DynASM MIPS encoding engine. ** DynASM MIPS encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved. ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM MIPS module. -- DynASM MIPS module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
** DynASM PPC encoding engine. ** DynASM PPC encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved. ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM PPC module. -- DynASM PPC module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/* /*
** DynASM encoding engine prototypes. ** DynASM encoding engine prototypes.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved. ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM x64 module. -- DynASM x64 module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This module just sets 64 bit mode for the combined x86/x64 module. -- This module just sets 64 bit mode for the combined x86/x64 module.

View File

@ -1,6 +1,6 @@
/* /*
** DynASM x86 encoding engine. ** DynASM x86 encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved. ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice. ** Released under the MIT license. See dynasm.lua for full copyright notice.
*/ */

View File

@ -1,7 +1,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- DynASM x86/x64 module. -- DynASM x86/x64 module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice. -- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -1081,6 +1081,9 @@ local map_op = {
btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU", btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU",
bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU", bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU",
shld_3 = "mriqdw:0FA4RmU|mrCqdw:0FA5Rm",
shrd_3 = "mriqdw:0FACRmU|mrCqdw:0FADRm",
rdtsc_0 = "0F31", -- P1+ rdtsc_0 = "0F31", -- P1+
cpuid_0 = "0FA2", -- P1+ cpuid_0 = "0FA2", -- P1+
@ -1114,6 +1117,9 @@ local map_op = {
fucompp_0 = "DAE9", fucompp_0 = "DAE9",
fcompp_0 = "DED9", fcompp_0 = "DED9",
fldenv_1 = "x.:D94m",
fnstenv_1 = "x.:D96m",
fstenv_1 = "x.:9BD96m",
fldcw_1 = "xw:nD95m", fldcw_1 = "xw:nD95m",
fstcw_1 = "xw:n9BD97m", fstcw_1 = "xw:n9BD97m",
fnstcw_1 = "xw:nD97m", fnstcw_1 = "xw:nD97m",
@ -1189,6 +1195,8 @@ local map_op = {
cvttps2dq_2 = "rmo:F30F5BrM", cvttps2dq_2 = "rmo:F30F5BrM",
cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:", cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:",
cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:", cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:",
fxsave_1 = "x.:0FAE0m",
fxrstor_1 = "x.:0FAE1m",
ldmxcsr_1 = "xd:0FAE2m", ldmxcsr_1 = "xd:0FAE2m",
lfence_0 = "0FAEE8", lfence_0 = "0FAEE8",
maskmovdqu_2 = "rro:660FF7rM", maskmovdqu_2 = "rro:660FF7rM",

View File

@ -2,7 +2,7 @@
-- DynASM. A dynamic assembler for code generation engines. -- DynASM. A dynamic assembler for code generation engines.
-- Originally designed and implemented for LuaJIT. -- Originally designed and implemented for LuaJIT.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See below for full copyright notice. -- See below for full copyright notice.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -17,7 +17,7 @@ local _info = {
url = "http://luajit.org/dynasm.html", url = "http://luajit.org/dynasm.html",
license = "MIT", license = "MIT",
copyright = [[ copyright = [[
Copyright (C) 2005-2014 Mike Pall. All rights reserved. Copyright (C) 2005-2015 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the

View File

@ -1,6 +1,6 @@
/* /*
** Configuration header. ** Configuration header.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef luaconf_h #ifndef luaconf_h
@ -37,7 +37,7 @@
#endif #endif
#define LUA_LROOT "/usr/local" #define LUA_LROOT "/usr/local"
#define LUA_LUADIR "/lua/5.1/" #define LUA_LUADIR "/lua/5.1/"
#define LUA_LJDIR "/luajit-2.0.3/" #define LUA_LJDIR "/luajit-2.0.4/"
#ifdef LUA_ROOT #ifdef LUA_ROOT
#define LUA_JROOT LUA_ROOT #define LUA_JROOT LUA_ROOT

View File

@ -1,7 +1,7 @@
/* /*
** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ ** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
** **
** Copyright (C) 2005-2014 Mike Pall. All rights reserved. ** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** **
** Permission is hereby granted, free of charge, to any person obtaining ** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the ** a copy of this software and associated documentation files (the
@ -30,10 +30,10 @@
#include "lua.h" #include "lua.h"
#define LUAJIT_VERSION "LuaJIT 2.0.3" #define LUAJIT_VERSION "LuaJIT 2.0.4"
#define LUAJIT_VERSION_NUM 20003 /* Version 2.0.3 = 02.00.03. */ #define LUAJIT_VERSION_NUM 20004 /* Version 2.0.4 = 02.00.04. */
#define LUAJIT_VERSION_SYM luaJIT_version_2_0_3 #define LUAJIT_VERSION_SYM luaJIT_version_2_0_4
#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2014 Mike Pall" #define LUAJIT_COPYRIGHT "Copyright (C) 2005-2015 Mike Pall"
#define LUAJIT_URL "http://luajit.org/" #define LUAJIT_URL "http://luajit.org/"
/* Modes for luaJIT_setmode. */ /* Modes for luaJIT_setmode. */

View File

@ -1,6 +1,6 @@
/* /*
** Standard library header. ** Standard library header.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LUALIB_H #ifndef _LUALIB_H

View File

@ -7,12 +7,12 @@
# Also works with MinGW and Cygwin on Windows. # Also works with MinGW and Cygwin on Windows.
# Please check msvcbuild.bat for building with MSVC on Windows. # Please check msvcbuild.bat for building with MSVC on Windows.
# #
# Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h # Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
############################################################################## ##############################################################################
MAJVER= 2 MAJVER= 2
MINVER= 0 MINVER= 0
RELVER= 3 RELVER= 4
ABIVER= 5.1 ABIVER= 5.1
NODOTABIVER= 51 NODOTABIVER= 51
@ -55,11 +55,11 @@ CCOPT_ppc=
CCOPT_ppcspe= CCOPT_ppcspe=
CCOPT_mips= CCOPT_mips=
# #
CCDEBUG=-g CCDEBUG=
# Uncomment the next line to generate debug information: # Uncomment the next line to generate debug information:
#CCDEBUG= -g #CCDEBUG= -g
# #
CCWARN= -Wall -Wno-unused-function CCWARN= -Wall
# Uncomment the next line to enable more warnings: # Uncomment the next line to enable more warnings:
#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith #CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
# #
@ -72,10 +72,10 @@ CCWARN= -Wall -Wno-unused-function
# as dynamic mode. # as dynamic mode.
# #
# Mixed mode creates a static + dynamic library and a statically linked luajit. # Mixed mode creates a static + dynamic library and a statically linked luajit.
# BUILDMODE= mixed BUILDMODE= mixed
# #
# Static mode creates a static library and a statically linked luajit. # Static mode creates a static library and a statically linked luajit.
BUILDMODE= static #BUILDMODE= static
# #
# Dynamic mode creates a dynamic library and a dynamically linked luajit. # Dynamic mode creates a dynamic library and a dynamically linked luajit.
# Note: this executable will only run when the library is installed! # Note: this executable will only run when the library is installed!
@ -88,7 +88,7 @@ BUILDMODE= static
############################################################################## ##############################################################################
# Enable/disable these features as needed, but make sure you force a full # Enable/disable these features as needed, but make sure you force a full
# recompile with "make clean", followed by "make". # recompile with "make clean", followed by "make".
XCFLAGS=-Igen XCFLAGS=
# #
# Permanently disable the FFI extension to reduce the size of the LuaJIT # Permanently disable the FFI extension to reduce the size of the LuaJIT
# executable. But please consider that the FFI library is compiled-in, # executable. But please consider that the FFI library is compiled-in,
@ -100,7 +100,7 @@ XCFLAGS=-Igen
# enabled by default. Some other features that *might* break some existing # enabled by default. Some other features that *might* break some existing
# code (e.g. __pairs or os.execute() return values) can be enabled here. # code (e.g. __pairs or os.execute() return values) can be enabled here.
# Note: this does not provide full compatibility with Lua 5.2 at this time. # Note: this does not provide full compatibility with Lua 5.2 at this time.
XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT #XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
# #
# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
#XCFLAGS+= -DLUAJIT_DISABLE_JIT #XCFLAGS+= -DLUAJIT_DISABLE_JIT
@ -122,8 +122,10 @@ XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
# #
# Use the system provided memory allocator (realloc) instead of the # Use the system provided memory allocator (realloc) instead of the
# bundled memory allocator. This is slower, but sometimes helpful for # bundled memory allocator. This is slower, but sometimes helpful for
# debugging. It's helpful for Valgrind's memcheck tool, too. This option # debugging. This option cannot be enabled on x64, since realloc usually
# cannot be enabled on x64, since the built-in allocator is mandatory. # doesn't return addresses in the right address range.
# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
# the only way to get useful results from it for all other architectures.
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC #XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
# #
# This define is required to run LuaJIT under Valgrind. The Valgrind # This define is required to run LuaJIT under Valgrind. The Valgrind
@ -188,9 +190,9 @@ TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus TARGET_AR= $(CROSS)ar rcus
TARGET_STRIP= $(CROSS)strip TARGET_STRIP= $(CROSS)strip
TARGET_LIBPATH= ${CURDIR} TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER) TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
TARGET_DYLIBNAME= libluajit-aegisub.so TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME) TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME)
TARGET_DLLNAME= lua$(NODOTABIVER).dll TARGET_DLLNAME= lua$(NODOTABIVER).dll
TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME) TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
@ -288,15 +290,15 @@ ifeq (Windows,$(TARGET_SYS))
TARGET_XSHLDFLAGS= -shared TARGET_XSHLDFLAGS= -shared
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
else else
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifeq (Darwin,$(TARGET_SYS)) ifeq (Darwin,$(TARGET_SYS))
ifeq (,$(MACOSX_DEPLOYMENT_TARGET)) ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
export MACOSX_DEPLOYMENT_TARGET=10.4 export MACOSX_DEPLOYMENT_TARGET=10.4
endif endif
TARGET_STRIP+= -x TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null TARGET_AR+= 2>/dev/null
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-stack-protector
endif
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
@ -308,14 +310,10 @@ else
ifeq (iOS,$(TARGET_SYS)) ifeq (iOS,$(TARGET_SYS))
TARGET_STRIP+= -x TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null TARGET_AR+= 2>/dev/null
TARGET_XCFLAGS+= -fno-stack-protector
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
else else
ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs)))
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifneq (SunOS,$(TARGET_SYS)) ifneq (SunOS,$(TARGET_SYS))
ifneq (PS3,$(TARGET_SYS)) ifneq (PS3,$(TARGET_SYS))
TARGET_XLDFLAGS+= -Wl,-E TARGET_XLDFLAGS+= -Wl,-E
@ -475,12 +473,12 @@ LIB_VMDEFP= $(LIB_VMDEF)
LUAJIT_O= luajit.o LUAJIT_O= luajit.o
LUAJIT_A= libluajit.a LUAJIT_A= libluajit.a
LUAJIT_SO= libluajit-aegisub.so LUAJIT_SO= libluajit.so
LUAJIT_T= luajit LUAJIT_T= luajit
ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T)
ALL_HDRGEN= gen/lj_bcdef.h gen/lj_ffdef.h gen/lj_libdef.h gen/lj_recdef.h gen/lj_folddef.h \ ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
gen/buildvm_arch.h host/buildvm_arch.h
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)
@ -494,11 +492,25 @@ TARGET_O= $(LUAJIT_A)
TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
ifeq (Windows,$(TARGET_SYS))
TARGET_DYNCC= $(STATIC_CC)
LJVM_MODE= peobj
LJVM_BOUT= $(LJVM_O)
LUAJIT_T= luajit.exe
ifeq (cygwin,$(HOST_MSYS))
LUAJIT_SO= cyg$(TARGET_DLLNAME)
else
LUAJIT_SO= $(TARGET_DLLNAME)
endif
# Mixed mode is not supported on Windows. And static mode doesn't work well.
# C modules cannot be loaded, because they bind to lua51.dll.
ifneq (static,$(BUILDMODE))
BUILDMODE= dynamic
TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
endif
endif
ifeq (Darwin,$(TARGET_SYS)) ifeq (Darwin,$(TARGET_SYS))
LJVM_MODE= machasm LJVM_MODE= machasm
# -dead_strip breaks LuaJIT, but we really want it for everything else, so we
# have to dynamically link it
BUILDMODE= dynamic
endif endif
ifeq (iOS,$(TARGET_SYS)) ifeq (iOS,$(TARGET_SYS))
LJVM_MODE= machasm LJVM_MODE= machasm
@ -557,6 +569,7 @@ E= @echo
default all: $(TARGET_T) default all: $(TARGET_T)
amalg: amalg:
@grep "^[+|]" ljamalg.c
$(MAKE) all "LJCORE_O=ljamalg.o" $(MAKE) all "LJCORE_O=ljamalg.o"
clean: clean:
@ -586,10 +599,7 @@ $(MINILUA_T): $(MINILUA_O)
$(E) "HOSTLINK $@" $(E) "HOSTLINK $@"
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
gen: host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP)
mkdir -p gen
gen/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) gen
$(E) "DYNASM $@" $(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
@ -603,19 +613,19 @@ $(LJVM_BOUT): $(BUILDVM_T)
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@ $(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
gen/lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C) lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C) $(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
gen/lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C) lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C) $(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
gen/lj_libdef.h: $(BUILDVM_T) $(LJLIB_C) lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C) $(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
gen/lj_recdef.h: $(BUILDVM_T) $(LJLIB_C) lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C) $(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
@ -623,7 +633,7 @@ $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C) $(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
gen/lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
$(E) "BUILDVM $@" $(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c $(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c

View File

@ -4,39 +4,39 @@ lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \
lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \
gen/lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \
lj_lib.h gen/lj_libdef.h lj_lib.h lj_libdef.h
lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h gen/lj_libdef.h lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h
lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \
gen/lj_libdef.h lj_libdef.h
lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \
lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \ lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \
lj_ccallback.h lj_clib.h lj_ff.h gen/lj_ffdef.h lj_lib.h gen/lj_libdef.h lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \
gen/lj_ffdef.h lj_lib.h gen/lj_libdef.h lj_ffdef.h lj_lib.h lj_libdef.h
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \ lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \
lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \ lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \ lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \
lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \ lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \
gen/lj_libdef.h lj_libdef.h
lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_lib.h lj_vm.h gen/lj_libdef.h lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h
lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_err.h lj_errmsg.h lj_lib.h gen/lj_libdef.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h
lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h
lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \
lj_meta.h lj_state.h lj_ff.h gen/lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \ lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \
lj_lib.h gen/lj_libdef.h lj_lib.h lj_libdef.h
lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \ lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \
gen/lj_libdef.h lj_libdef.h
lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h
lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \ lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \
@ -48,7 +48,7 @@ lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \ lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \
lj_asm_*.h lj_asm_*.h
lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \ lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \
gen/lj_bcdef.h lj_bcdef.h
lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \ lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \
lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h
@ -83,28 +83,28 @@ lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \
lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \ lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \
gen/lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \ lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \
lj_crecord.h lj_crecord.h
lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h
lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \ lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \
lj_bc.h lj_jit.h lj_ir.h lj_bc.h lj_vm.h lj_jit.h lj_ir.h
lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \ lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \
lj_state.h lj_frame.h lj_bc.h lj_ff.h gen/lj_ffdef.h lj_jit.h lj_ir.h \ lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \
lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \ lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \
lj_vm.h luajit.h lj_vm.h luajit.h
lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \ lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \
lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \ lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \
lj_ff.h gen/lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \ lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \
lj_traceerr.h lj_vm.h lj_traceerr.h lj_vm.h
lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \
gen/lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \ lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \ lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \
lj_vm.h lj_strscan.h gen/lj_recdef.h lj_vm.h lj_strscan.h lj_recdef.h
lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \ lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \
lj_traceerr.h lj_vm.h lj_traceerr.h lj_vm.h
@ -140,7 +140,7 @@ lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \ lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \
lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \ lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \
lj_strscan.h gen/lj_folddef.h lj_strscan.h lj_folddef.h
lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \ lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h
@ -159,7 +159,7 @@ lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h
lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \ lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \ lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \
lj_ctype.h lj_gc.h lj_ff.h gen/lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \ lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \
lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \ lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \
lj_ffrecord.h lj_snap.h lj_vm.h lj_ffrecord.h lj_snap.h lj_vm.h
lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \ lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
@ -192,7 +192,7 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \ lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \
lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \ lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \
lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \ lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \
lj_debug.h lj_ff.h gen/lj_ffdef.h lj_char.c lj_char.h lj_bc.c gen/lj_bcdef.h \ lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \
lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \ lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \
lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \ lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \
luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \ luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \
@ -201,12 +201,12 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \ lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \
lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \ lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \
lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \ lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \
lj_opt_mem.c lj_opt_fold.c gen/lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \ lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \
lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \ lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \
lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \ lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \
lj_crecord.h lj_ffrecord.c gen/lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \ lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \
lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \ lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \
lib_base.c gen/lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \ lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \
lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \ lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \
lib_init.c lib_init.c
luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h
@ -214,7 +214,7 @@ host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \ lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \
lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \ lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \
lj_gc.h lj_ccall.h lj_ctype.h luajit.h \ lj_gc.h lj_ccall.h lj_ctype.h luajit.h \
gen/buildvm_arch.h lj_traceerr.h host/buildvm_arch.h lj_traceerr.h
host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \ host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_bc.h lj_def.h lj_arch.h lj_arch.h lj_bc.h lj_def.h lj_arch.h
host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \ host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder. ** LuaJIT VM builder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** This is a tool to build the hand-tuned assembler code required for ** This is a tool to build the hand-tuned assembler code required for
** LuaJIT's bytecode interpreter. It supports a variety of output formats ** LuaJIT's bytecode interpreter. It supports a variety of output formats

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder. ** LuaJIT VM builder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _BUILDVM_H #ifndef _BUILDVM_H

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: Assembler source code emitter. ** LuaJIT VM builder: Assembler source code emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "buildvm.h" #include "buildvm.h"
@ -286,7 +286,7 @@ void emit_asm(BuildCtx *ctx)
fprintf(ctx->fp, "\n"); fprintf(ctx->fp, "\n");
switch (ctx->mode) { switch (ctx->mode) {
case BUILD_elfasm: case BUILD_elfasm:
#if !LJ_TARGET_PS3 #if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA)
fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n"); fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n");
#endif #endif
#if LJ_TARGET_PPCSPE #if LJ_TARGET_PPCSPE

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: IR folding hash table generator. ** LuaJIT VM builder: IR folding hash table generator.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "buildvm.h" #include "buildvm.h"

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: library definition compiler. ** LuaJIT VM builder: library definition compiler.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "buildvm.h" #include "buildvm.h"

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT VM builder: PE object emitter. ** LuaJIT VM builder: PE object emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Only used for building on Windows, since we cannot assume the presence ** Only used for building on Windows, since we cannot assume the presence
** of a suitable assembler. The host and target byte order must match. ** of a suitable assembler. The host and target byte order must match.

View File

@ -2,7 +2,7 @@
-- Lua script to generate a customized, minified version of Lua. -- Lua script to generate a customized, minified version of Lua.
-- The resulting 'minilua' is used for the build process of LuaJIT. -- The resulting 'minilua' is used for the build process of LuaJIT.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT bytecode listing module. -- LuaJIT bytecode listing module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -41,7 +41,7 @@
-- Cache some library functions and objects. -- Cache some library functions and objects.
local jit = require("jit") local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local jutil = require("jit.util") local jutil = require("jit.util")
local vmdef = require("jit.vmdef") local vmdef = require("jit.vmdef")
local bit = require("bit") local bit = require("bit")

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT module to save/list bytecode. -- LuaJIT module to save/list bytecode.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -11,7 +11,7 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
local jit = require("jit") local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local bit = require("bit") local bit = require("bit")
-- Symbol name prefix for LuaJIT bytecode. -- Symbol name prefix for LuaJIT bytecode.
@ -69,7 +69,7 @@ local map_arch = {
local map_os = { local map_os = {
linux = true, windows = true, osx = true, freebsd = true, netbsd = true, linux = true, windows = true, osx = true, freebsd = true, netbsd = true,
openbsd = true, solaris = true, openbsd = true, dragonfly = true, solaris = true,
} }
local function checkarg(str, map, err) local function checkarg(str, map, err)

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT ARM disassembler module. -- LuaJIT ARM disassembler module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT MIPS disassembler module. -- LuaJIT MIPS disassembler module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h -- Released under the MIT/X license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT MIPSEL disassembler wrapper module. -- LuaJIT MIPSEL disassembler wrapper module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This module just exports the little-endian functions from the -- This module just exports the little-endian functions from the

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT PPC disassembler module. -- LuaJIT PPC disassembler module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h -- Released under the MIT/X license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT x64 disassembler wrapper module. -- LuaJIT x64 disassembler wrapper module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This module just exports the 64 bit functions from the combined -- This module just exports the 64 bit functions from the combined

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT x86/x64 disassembler module. -- LuaJIT x86/x64 disassembler module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module. -- This is a helper module used by the LuaJIT machine code dumper module.

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- LuaJIT compiler dump module. -- LuaJIT compiler dump module.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -55,7 +55,7 @@
-- Cache some library functions and objects. -- Cache some library functions and objects.
local jit = require("jit") local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local jutil = require("jit.util") local jutil = require("jit.util")
local vmdef = require("jit.vmdef") local vmdef = require("jit.vmdef")
local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc

View File

@ -1,7 +1,7 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Verbose mode of the LuaJIT compiler. -- Verbose mode of the LuaJIT compiler.
-- --
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved. -- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h -- Released under the MIT license. See Copyright Notice in luajit.h
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- --
@ -59,7 +59,7 @@
-- Cache some library functions and objects. -- Cache some library functions and objects.
local jit = require("jit") local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch") assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local jutil = require("jit.util") local jutil = require("jit.util")
local vmdef = require("jit.vmdef") local vmdef = require("jit.vmdef")
local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo

View File

@ -1,6 +1,6 @@
/* /*
** Auxiliary library for the Lua/C API. ** Auxiliary library for the Lua/C API.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major parts taken verbatim or adapted from the Lua interpreter. ** Major parts taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -302,7 +302,7 @@ static int panic(lua_State *L)
#ifdef LUAJIT_USE_SYSMALLOC #ifdef LUAJIT_USE_SYSMALLOC
#if LJ_64 #if LJ_64 && !defined(LUAJIT_USE_VALGRIND)
#error "Must use builtin allocator for 64 bit target" #error "Must use builtin allocator for 64 bit target"
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
** Base and coroutine library. ** Base and coroutine library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** Bit manipulation library. ** Bit manipulation library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lib_bit_c #define lib_bit_c

View File

@ -1,6 +1,6 @@
/* /*
** Debug library. ** Debug library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** FFI library. ** FFI library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lib_ffi_c #define lib_ffi_c
@ -136,6 +136,7 @@ static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm)
return 0; return 0;
} }
} }
copyTV(L, base, L->top);
tv = L->top-1; tv = L->top-1;
} }
return lj_meta_tailcall(L, tv); return lj_meta_tailcall(L, tv);

View File

@ -1,6 +1,6 @@
/* /*
** Library initialization. ** Library initialization.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major parts taken verbatim from the Lua interpreter. ** Major parts taken verbatim from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** I/O library. ** I/O library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -24,16 +24,6 @@
#include "lj_ff.h" #include "lj_ff.h"
#include "lj_lib.h" #include "lj_lib.h"
#if LJ_TARGET_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static int widen(const char *in, wchar_t *out)
{
return MultiByteToWideChar(CP_UTF8, 0, in, -1, out, MAX_PATH);
}
#endif
/* Userdata payload for I/O file. */ /* Userdata payload for I/O file. */
typedef struct IOFileUD { typedef struct IOFileUD {
FILE *fp; /* File handle. */ FILE *fp; /* File handle. */
@ -92,15 +82,7 @@ static IOFileUD *io_file_open(lua_State *L, const char *mode)
{ {
const char *fname = strdata(lj_lib_checkstr(L, 1)); const char *fname = strdata(lj_lib_checkstr(L, 1));
IOFileUD *iof = io_file_new(L); IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_WINDOWS
wchar_t wfname[MAX_PATH];
wchar_t wmode[MAX_PATH];
if (!widen(fname, wfname) || !widen(mode, wmode))
luaL_argerror(L, 1, lj_str_pushf(L, "%s: failed to convert path to utf-16", fname));
iof->fp = _wfopen(wfname, wmode);
#else
iof->fp = fopen(fname, mode); iof->fp = fopen(fname, mode);
#endif
if (iof->fp == NULL) if (iof->fp == NULL)
luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno))); luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno)));
return iof; return iof;
@ -417,14 +399,7 @@ LJLIB_CF(io_open)
GCstr *s = lj_lib_optstr(L, 2); GCstr *s = lj_lib_optstr(L, 2);
const char *mode = s ? strdata(s) : "r"; const char *mode = s ? strdata(s) : "r";
IOFileUD *iof = io_file_new(L); IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_WINDOWS
wchar_t wfname[MAX_PATH];
wchar_t wmode[MAX_PATH];
if (widen(fname, wfname) && widen(mode, wmode))
iof->fp = _wfopen(wfname, wmode);
#else
iof->fp = fopen(fname, mode); iof->fp = fopen(fname, mode);
#endif
return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname);
} }
@ -440,10 +415,7 @@ LJLIB_CF(io_popen)
fflush(NULL); fflush(NULL);
iof->fp = popen(fname, mode); iof->fp = popen(fname, mode);
#else #else
wchar_t wfname[MAX_PATH]; iof->fp = _popen(fname, mode);
wchar_t wmode[MAX_PATH];
if (widen(fname, wfname) && widen(mode, wmode))
iof->fp = _wpopen(wfname, wmode);
#endif #endif
return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname); return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname);
#else #else
@ -454,7 +426,7 @@ LJLIB_CF(io_popen)
LJLIB_CF(io_tmpfile) LJLIB_CF(io_tmpfile)
{ {
IOFileUD *iof = io_file_new(L); IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_PS3 || LJ_TARGET_PS4 #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
iof->fp = NULL; errno = ENOSYS; iof->fp = NULL; errno = ENOSYS;
#else #else
iof->fp = tmpfile(); iof->fp = tmpfile();

View File

@ -1,6 +1,6 @@
/* /*
** JIT library. ** JIT library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lib_jit_c #define lib_jit_c

View File

@ -1,6 +1,6 @@
/* /*
** Math library. ** Math library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include <math.h> #include <math.h>

View File

@ -1,13 +1,12 @@
/* /*
** OS library. ** OS library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
*/ */
#include <errno.h> #include <errno.h>
#include <locale.h>
#include <time.h> #include <time.h>
#define lib_os_c #define lib_os_c
@ -27,21 +26,8 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
/* ------------------------------------------------------------------------ */ #if !LJ_TARGET_PSVITA
#include <locale.h>
#if LJ_TARGET_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static wchar_t *widen_static(const char *narrow, int idx)
{
__declspec(thread) static wchar_t buffer[2][MAX_PATH];
return MultiByteToWideChar(CP_UTF8, 0, narrow, -1, buffer[idx], MAX_PATH) ? buffer[idx] : L"";
}
#define remove(x) _wremove(widen_static(x, 0))
#define system(x) _wsystem(widen_static(x, 0))
#define rename(x, y) _wrename(widen_static(x, 0), widen_static(y, 1))
#endif #endif
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
@ -87,7 +73,7 @@ LJLIB_CF(os_rename)
LJLIB_CF(os_tmpname) LJLIB_CF(os_tmpname)
{ {
#if LJ_TARGET_PS3 || LJ_TARGET_PS4 #if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
lj_err_caller(L, LJ_ERR_OSUNIQF); lj_err_caller(L, LJ_ERR_OSUNIQF);
return 0; return 0;
#else #else
@ -271,6 +257,9 @@ LJLIB_CF(os_difftime)
LJLIB_CF(os_setlocale) LJLIB_CF(os_setlocale)
{ {
#if LJ_TARGET_PSVITA
lua_pushliteral(L, "C");
#else
GCstr *s = lj_lib_optstr(L, 1); GCstr *s = lj_lib_optstr(L, 1);
const char *str = s ? strdata(s) : NULL; const char *str = s ? strdata(s) : NULL;
int opt = lj_lib_checkopt(L, 2, 6, int opt = lj_lib_checkopt(L, 2, 6,
@ -282,6 +271,7 @@ LJLIB_CF(os_setlocale)
else if (opt == 4) opt = LC_MONETARY; else if (opt == 4) opt = LC_MONETARY;
else if (opt == 6) opt = LC_ALL; else if (opt == 6) opt = LC_ALL;
lua_pushstring(L, setlocale(opt, str)); lua_pushstring(L, setlocale(opt, str));
#endif
return 1; return 1;
} }

View File

@ -1,6 +1,6 @@
/* /*
** Package library. ** Package library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** String library. ** String library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** Table library. ** Table library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -179,23 +179,29 @@ static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size)
#if defined(MAP_32BIT) #if defined(MAP_32BIT)
#if defined(__sun__)
#define MMAP_REGION_START ((uintptr_t)0x1000)
#else
/* Actually this only gives us max. 1GB in current Linux kernels. */ /* Actually this only gives us max. 1GB in current Linux kernels. */
#define MMAP_REGION_START ((uintptr_t)0)
#endif
static LJ_AINLINE void *CALL_MMAP(size_t size) static LJ_AINLINE void *CALL_MMAP(size_t size)
{ {
int olderr = errno; int olderr = errno;
void *ptr = mmap(NULL, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0); void *ptr = mmap((void *)MMAP_REGION_START, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0);
errno = olderr; errno = olderr;
return ptr; return ptr;
} }
#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__) #elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__)
/* OSX and FreeBSD mmap() use a naive first-fit linear search. /* OSX and FreeBSD mmap() use a naive first-fit linear search.
** That's perfect for us. Except that -pagezero_size must be set for OSX, ** That's perfect for us. Except that -pagezero_size must be set for OSX,
** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs ** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs
** to be reduced to 250MB on FreeBSD. ** to be reduced to 250MB on FreeBSD.
*/ */
#if LJ_TARGET_OSX #if LJ_TARGET_OSX || defined(__DragonFly__)
#define MMAP_REGION_START ((uintptr_t)0x10000) #define MMAP_REGION_START ((uintptr_t)0x10000)
#elif LJ_TARGET_PS4 #elif LJ_TARGET_PS4
#define MMAP_REGION_START ((uintptr_t)0x4000) #define MMAP_REGION_START ((uintptr_t)0x4000)
@ -232,7 +238,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
return p; return p;
} }
if (p != CMFAIL) munmap(p, size); if (p != CMFAIL) munmap(p, size);
#ifdef __sun__ #if defined(__sun__) || defined(__DragonFly__)
alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */ alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */
if (alloc_hint + size < MMAP_REGION_END) continue; if (alloc_hint + size < MMAP_REGION_END) continue;
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
** Public Lua/C API. ** Public Lua/C API.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** Target architecture selection. ** Target architecture selection.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_ARCH_H #ifndef _LJ_ARCH_H
@ -67,7 +67,8 @@
#elif defined(__MACH__) && defined(__APPLE__) #elif defined(__MACH__) && defined(__APPLE__)
#define LUAJIT_OS LUAJIT_OS_OSX #define LUAJIT_OS LUAJIT_OS_OSX
#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(__ORBIS__) defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)) && !defined(__ORBIS__)
#define LUAJIT_OS LUAJIT_OS_BSD #define LUAJIT_OS LUAJIT_OS_BSD
#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__) #elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)
#define LUAJIT_OS LUAJIT_OS_POSIX #define LUAJIT_OS LUAJIT_OS_POSIX
@ -111,6 +112,11 @@
#define NULL ((void*)0) #define NULL ((void*)0)
#endif #endif
#ifdef __psp2__
#define LJ_TARGET_PSVITA 1
#define LJ_TARGET_CONSOLE 1
#endif
#if _XBOX_VER >= 200 #if _XBOX_VER >= 200
#define LJ_TARGET_XBOX360 1 #define LJ_TARGET_XBOX360 1
#define LJ_TARGET_CONSOLE 1 #define LJ_TARGET_CONSOLE 1
@ -175,7 +181,9 @@
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */ #define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL #define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ #if __ARM_ARCH____ARM_ARCH_8__ || __ARM_ARCH_8A__
#define LJ_ARCH_VERSION 80
#elif __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ || __ARM_ARCH_7VE__
#define LJ_ARCH_VERSION 70 #define LJ_ARCH_VERSION 70
#elif __ARM_ARCH_6T2__ #elif __ARM_ARCH_6T2__
#define LJ_ARCH_VERSION 61 #define LJ_ARCH_VERSION 61
@ -334,6 +342,9 @@
#if defined(__mips_soft_float) #if defined(__mips_soft_float)
#error "No support for MIPS CPUs without FPU" #error "No support for MIPS CPUs without FPU"
#endif #endif
#if defined(_LP64)
#error "No support for MIPS64"
#endif
#endif #endif
#endif #endif

View File

@ -1,6 +1,6 @@
/* /*
** IR assembler (SSA IR -> machine code). ** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_asm_c #define lj_asm_c
@ -353,6 +353,7 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
static int32_t ra_spill(ASMState *as, IRIns *ir) static int32_t ra_spill(ASMState *as, IRIns *ir)
{ {
int32_t slot = ir->s; int32_t slot = ir->s;
lua_assert(ir >= as->ir + REF_TRUE);
if (!ra_hasspill(slot)) { if (!ra_hasspill(slot)) {
if (irt_is64(ir->t)) { if (irt_is64(ir->t)) {
slot = as->evenspill; slot = as->evenspill;
@ -1372,6 +1373,11 @@ static void asm_head_side(ASMState *as)
int pass3 = 0; int pass3 = 0;
IRRef i; IRRef i;
if (as->snapno && as->topslot > as->parent->topslot) {
/* Force snap #0 alloc to prevent register overwrite in stack check. */
as->snapno = 0;
asm_snap_alloc(as);
}
allow = asm_head_side_base(as, irp, allow); allow = asm_head_side_base(as, irp, allow);
/* Scan all parent SLOADs and collect register dependencies. */ /* Scan all parent SLOADs and collect register dependencies. */

View File

@ -1,6 +1,6 @@
/* /*
** IR assembler (SSA IR -> machine code). ** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_ASM_H #ifndef _LJ_ASM_H

View File

@ -1,6 +1,6 @@
/* /*
** ARM IR assembler (SSA IR -> machine code). ** ARM IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Register allocator extensions --------------------------------------- */ /* -- Register allocator extensions --------------------------------------- */

View File

@ -1,6 +1,6 @@
/* /*
** MIPS IR assembler (SSA IR -> machine code). ** MIPS IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Register allocator extensions --------------------------------------- */ /* -- Register allocator extensions --------------------------------------- */

View File

@ -1,6 +1,6 @@
/* /*
** PPC IR assembler (SSA IR -> machine code). ** PPC IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Register allocator extensions --------------------------------------- */ /* -- Register allocator extensions --------------------------------------- */
@ -49,6 +49,8 @@ static void asm_exitstub_setup(ASMState *as, ExitNo nexits)
{ {
ExitNo i; ExitNo i;
MCode *mxp = as->mctop; MCode *mxp = as->mctop;
if (mxp - (nexits + 3 + MCLIM_REDZONE) < as->mclim)
asm_mclimit(as);
/* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */ /* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */
for (i = nexits-1; (int32_t)i >= 0; i--) for (i = nexits-1; (int32_t)i >= 0; i--)
*--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2); *--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2);

View File

@ -1,6 +1,6 @@
/* /*
** x86/x64 IR assembler (SSA IR -> machine code). ** x86/x64 IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Guard handling ------------------------------------------------------ */ /* -- Guard handling ------------------------------------------------------ */
@ -325,6 +325,14 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
as->mrm.base = as->mrm.idx = RID_NONE; as->mrm.base = as->mrm.idx = RID_NONE;
return RID_MRM; return RID_MRM;
} }
} else if (ir->o == IR_KINT64) {
RegSet avail = as->freeset & ~as->modset & RSET_GPR;
lua_assert(allow != RSET_EMPTY);
if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */
as->mrm.ofs = ptr2addr(ir_kint64(ir));
as->mrm.base = as->mrm.idx = RID_NONE;
return RID_MRM;
}
} else if (mayfuse(as, ref)) { } else if (mayfuse(as, ref)) {
RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR;
if (ir->o == IR_SLOAD) { if (ir->o == IR_SLOAD) {
@ -361,7 +369,7 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
return RID_MRM; return RID_MRM;
} }
} }
if (!(as->freeset & allow) && if (!(as->freeset & allow) && !irref_isk(ref) &&
(allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref))) (allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref)))
goto fusespill; goto fusespill;
return ra_allocref(as, ref, allow); return ra_allocref(as, ref, allow);
@ -571,7 +579,7 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
lua_assert(!irt_ispri(ir->t)); lua_assert(!irt_ispri(ir->t));
ra_destreg(as, ir, RID_RET); ra_destreg(as, ir, RID_RET);
} }
} else if (LJ_32 && irt_isfp(ir->t)) { } else if (LJ_32 && irt_isfp(ir->t) && !(ci->flags & CCI_CASTU64)) {
emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */ emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */
} }
} }
@ -1828,8 +1836,12 @@ static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa)
Reg dest, right; Reg dest, right;
int32_t k = 0; int32_t k = 0;
if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */ if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */
as->flagmcp = NULL; MCode *p = as->mcp + ((LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2);
as->mcp += (LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2; if ((p[1] & 15) < 14) {
if ((p[1] & 15) >= 12) p[1] -= 4; /* L <->S, NL <-> NS */
as->flagmcp = NULL;
as->mcp = p;
} /* else: cannot transform LE/NLE to cc without use of OF. */
} }
right = IR(rref)->r; right = IR(rref)->r;
if (ra_hasreg(right)) { if (ra_hasreg(right)) {

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode instruction modes. ** Bytecode instruction modes.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_bc_c #define lj_bc_c

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode instruction format. ** Bytecode instruction format.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_BC_H #ifndef _LJ_BC_H

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode dump definitions. ** Bytecode dump definitions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_BCDUMP_H #ifndef _LJ_BCDUMP_H

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode reader. ** Bytecode reader.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_bcread_c #define lj_bcread_c

View File

@ -1,6 +1,6 @@
/* /*
** Bytecode writer. ** Bytecode writer.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_bcwrite_c #define lj_bcwrite_c

View File

@ -1,6 +1,6 @@
/* /*
** C data arithmetic. ** C data arithmetic.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"
@ -62,7 +62,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
TValue *o2 = i == 0 ? o+1 : o-1; TValue *o2 = i == 0 ? o+1 : o-1;
CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid); CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid);
ca->ct[i] = NULL; ca->ct[i] = NULL;
ca->p[i] = NULL; ca->p[i] = (uint8_t *)strVdata(o);
ok = 0; ok = 0;
if (ctype_isenum(ct->info)) { if (ctype_isenum(ct->info)) {
CTSize ofs; CTSize ofs;
@ -79,7 +79,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
} }
} else { } else {
ca->ct[i] = NULL; ca->ct[i] = NULL;
ca->p[i] = NULL; ca->p[i] = (void *)(intptr_t)1; /* To make it unequal. */
ok = 0; ok = 0;
} }
} }
@ -234,7 +234,9 @@ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
const char *repr[2]; const char *repr[2];
int i, isenum = -1, isstr = -1; int i, isenum = -1, isstr = -1;
if (mm == MM_eq) { /* Equality checks never raise an error. */ if (mm == MM_eq) { /* Equality checks never raise an error. */
setboolV(L->top-1, 0); int eq = ca->p[0] == ca->p[1];
setboolV(L->top-1, eq);
setboolV(&G(L)->tmptv2, eq); /* Remember for trace recorder. */
return 1; return 1;
} }
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {

View File

@ -1,6 +1,6 @@
/* /*
** C data arithmetic. ** C data arithmetic.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CARITH_H #ifndef _LJ_CARITH_H

View File

@ -1,6 +1,6 @@
/* /*
** FFI C call handling. ** FFI C call handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"

View File

@ -1,6 +1,6 @@
/* /*
** FFI C call handling. ** FFI C call handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CCALL_H #ifndef _LJ_CCALL_H

View File

@ -1,6 +1,6 @@
/* /*
** FFI C callback handling. ** FFI C callback handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"

View File

@ -1,6 +1,6 @@
/* /*
** FFI C callback handling. ** FFI C callback handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CCALLBACK_H #ifndef _LJ_CCALLBACK_H

View File

@ -1,6 +1,6 @@
/* /*
** C type conversions. ** C type conversions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"
@ -702,6 +702,7 @@ static void cconv_substruct_init(CTState *cts, CType *d, uint8_t *dp,
} else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) { } else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) {
cconv_substruct_init(cts, ctype_rawchild(cts, df), cconv_substruct_init(cts, ctype_rawchild(cts, df),
dp+df->size, o, len, ip); dp+df->size, o, len, ip);
if ((d->info & CTF_UNION)) break;
} /* Ignore all other entries in the chain. */ } /* Ignore all other entries in the chain. */
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
** C type conversions. ** C type conversions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CCONV_H #ifndef _LJ_CCONV_H

View File

@ -1,6 +1,6 @@
/* /*
** C data management. ** C data management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"
@ -127,16 +127,16 @@ collect_attrib:
integer_key: integer_key:
if (ctype_ispointer(ct->info)) { if (ctype_ispointer(ct->info)) {
CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */ CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */
if (sz != CTSIZE_INVALID) { if (sz == CTSIZE_INVALID)
if (ctype_isptr(ct->info)) { lj_err_caller(cts->L, LJ_ERR_FFI_INVSIZE);
p = (uint8_t *)cdata_getptr(p, ct->size); if (ctype_isptr(ct->info)) {
} else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) { p = (uint8_t *)cdata_getptr(p, ct->size);
if ((ct->info & CTF_COMPLEX)) idx &= 1; } else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) {
*qual |= CTF_CONST; /* Valarray elements are constant. */ if ((ct->info & CTF_COMPLEX)) idx &= 1;
} *qual |= CTF_CONST; /* Valarray elements are constant. */
*pp = p + idx*(int32_t)sz;
return ct;
} }
*pp = p + idx*(int32_t)sz;
return ct;
} }
} else if (tviscdata(key)) { /* Integer cdata key. */ } else if (tviscdata(key)) { /* Integer cdata key. */
GCcdata *cdk = cdataV(key); GCcdata *cdk = cdataV(key);

View File

@ -1,6 +1,6 @@
/* /*
** C data management. ** C data management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CDATA_H #ifndef _LJ_CDATA_H

View File

@ -1,6 +1,6 @@
/* /*
** FFI C library loader. ** FFI C library loader.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"

View File

@ -1,6 +1,6 @@
/* /*
** FFI C library loader. ** FFI C library loader.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CLIB_H #ifndef _LJ_CLIB_H

View File

@ -1,6 +1,6 @@
/* /*
** C declaration parser. ** C declaration parser.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"

View File

@ -1,6 +1,6 @@
/* /*
** C declaration parser. ** C declaration parser.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CPARSE_H #ifndef _LJ_CPARSE_H

View File

@ -1,6 +1,6 @@
/* /*
** Trace recorder for C data operations. ** Trace recorder for C data operations.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_ffrecord_c #define lj_ffrecord_c
@ -794,7 +794,7 @@ again:
} }
} else if (tref_isstr(idx)) { } else if (tref_isstr(idx)) {
GCstr *name = strV(&rd->argv[1]); GCstr *name = strV(&rd->argv[1]);
if (cd->ctypeid == CTID_CTYPEID) if (cd && cd->ctypeid == CTID_CTYPEID)
ct = ctype_raw(cts, crec_constructor(J, cd, ptr)); ct = ctype_raw(cts, crec_constructor(J, cd, ptr));
if (ctype_isstruct(ct->info)) { if (ctype_isstruct(ct->info)) {
CTSize fofs; CTSize fofs;
@ -835,6 +835,7 @@ again:
CType *cct = ctype_rawchild(cts, ct); CType *cct = ctype_rawchild(cts, ct);
if (ctype_isstruct(cct->info)) { if (ctype_isstruct(cct->info)) {
ct = cct; ct = cct;
cd = NULL;
if (tref_isstr(idx)) goto again; if (tref_isstr(idx)) goto again;
} }
} }
@ -847,8 +848,11 @@ again:
/* Resolve reference for field. */ /* Resolve reference for field. */
ct = ctype_get(cts, sid); ct = ctype_get(cts, sid);
if (ctype_isref(ct->info)) if (ctype_isref(ct->info)) {
ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0); ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0);
sid = ctype_cid(ct->info);
ct = ctype_get(cts, sid);
}
while (ctype_isattrib(ct->info)) while (ctype_isattrib(ct->info))
ct = ctype_child(cts, ct); /* Skip attributes. */ ct = ctype_child(cts, ct); /* Skip attributes. */
@ -1317,7 +1321,8 @@ static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm)
} }
/* Record ctype arithmetic metamethods. */ /* Record ctype arithmetic metamethods. */
static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd) static TRef crec_arith_meta(jit_State *J, TRef *sp, CType **s, CTState *cts,
RecordFFData *rd)
{ {
cTValue *tv = NULL; cTValue *tv = NULL;
if (J->base[0]) { if (J->base[0]) {
@ -1338,13 +1343,20 @@ static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd)
if (tvisfunc(tv)) { if (tvisfunc(tv)) {
J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME; J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME;
rd->nres = -1; /* Pending tailcall. */ rd->nres = -1; /* Pending tailcall. */
return; return 0;
} /* NYI: non-function metamethods. */ } /* NYI: non-function metamethods. */
} else if ((MMS)rd->data == MM_eq) { } else if ((MMS)rd->data == MM_eq) { /* Fallback cdata pointer comparison. */
J->base[0] = TREF_FALSE; if (sp[0] && sp[1] && ctype_isnum(s[0]->info) == ctype_isnum(s[1]->info)) {
return; /* Assume true comparison. Fixup and emit pending guard later. */
lj_ir_set(J, IRTG(IR_EQ, IRT_PTR), sp[0], sp[1]);
J->postproc = LJ_POST_FIXGUARD;
return TREF_TRUE;
} else {
return TREF_FALSE;
}
} }
lj_trace_err(J, LJ_TRERR_BADTYPE); lj_trace_err(J, LJ_TRERR_BADTYPE);
return 0;
} }
void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd) void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
@ -1357,7 +1369,7 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
TRef tr = J->base[i]; TRef tr = J->base[i];
CType *ct = ctype_get(cts, CTID_DOUBLE); CType *ct = ctype_get(cts, CTID_DOUBLE);
if (!tr) { if (!tr) {
goto trymeta; lj_trace_err(J, LJ_TRERR_BADTYPE);
} else if (tref_iscdata(tr)) { } else if (tref_iscdata(tr)) {
CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid; CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid;
IRType t; IRType t;
@ -1387,11 +1399,12 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
} }
if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct); if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct);
if (ctype_isnum(ct->info)) { if (ctype_isnum(ct->info)) {
if (t == IRT_CDATA) goto trymeta; if (t == IRT_CDATA) {
if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J); tr = 0;
tr = emitir(IRT(IR_XLOAD, t), tr, 0); } else {
} else if (!(ctype_isptr(ct->info) || ctype_isrefarray(ct->info))) { if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J);
goto trymeta; tr = emitir(IRT(IR_XLOAD, t), tr, 0);
}
} }
} else if (tref_isnil(tr)) { } else if (tref_isnil(tr)) {
tr = lj_ir_kptr(J, NULL); tr = lj_ir_kptr(J, NULL);
@ -1411,10 +1424,17 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str)); emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str));
ct = ctype_child(cts, cct); ct = ctype_child(cts, cct);
tr = lj_ir_kint(J, (int32_t)ofs); tr = lj_ir_kint(J, (int32_t)ofs);
} /* else: interpreter will throw. */ } else { /* Interpreter will throw or return false. */
} /* else: interpreter will throw. */ ct = ctype_get(cts, CTID_P_VOID);
}
} else if (ctype_isptr(ct->info)) {
tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr)));
} else {
ct = ctype_get(cts, CTID_P_VOID);
}
} else if (!tref_isnum(tr)) { } else if (!tref_isnum(tr)) {
goto trymeta; tr = 0;
ct = ctype_get(cts, CTID_P_VOID);
} }
ok: ok:
s[i] = ct; s[i] = ct;
@ -1422,22 +1442,20 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
} }
{ {
TRef tr; TRef tr;
if ((tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) || if (!(tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) &&
(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data))) { !(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data)) &&
J->base[0] = tr; !(tr = crec_arith_meta(J, sp, s, cts, rd)))
/* Fixup cdata comparisons, too. Avoids some cdata escapes. */ return;
if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) && J->base[0] = tr;
!irt_isguard(J->guardemit)) { /* Fixup cdata comparisons, too. Avoids some cdata escapes. */
const BCIns *pc = frame_contpc(J->L->base-1) - 1; if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) &&
if (bc_op(*pc) <= BC_ISNEP) { !irt_isguard(J->guardemit)) {
setframe_pc(&J2G(J)->tmptv, pc); const BCIns *pc = frame_contpc(J->L->base-1) - 1;
J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1); if (bc_op(*pc) <= BC_ISNEP) {
J->postproc = LJ_POST_FIXCOMP; setframe_pc(&J2G(J)->tmptv, pc);
} J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1);
J->postproc = LJ_POST_FIXCOMP;
} }
} else {
trymeta:
crec_arith_meta(J, cts, rd);
} }
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
** Trace recorder for C data operations. ** Trace recorder for C data operations.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CRECORD_H #ifndef _LJ_CRECORD_H

View File

@ -1,6 +1,6 @@
/* /*
** C type management. ** C type management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#include "lj_obj.h" #include "lj_obj.h"

View File

@ -1,6 +1,6 @@
/* /*
** C type management. ** C type management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_CTYPE_H #ifndef _LJ_CTYPE_H

View File

@ -1,6 +1,6 @@
/* /*
** Debugging and introspection. ** Debugging and introspection.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_debug_c #define lj_debug_c
@ -14,6 +14,7 @@
#include "lj_state.h" #include "lj_state.h"
#include "lj_frame.h" #include "lj_frame.h"
#include "lj_bc.h" #include "lj_bc.h"
#include "lj_vm.h"
#if LJ_HASJIT #if LJ_HASJIT
#include "lj_jit.h" #include "lj_jit.h"
#endif #endif
@ -86,7 +87,8 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
if (frame_islua(f)) { if (frame_islua(f)) {
f = frame_prevl(f); f = frame_prevl(f);
} else { } else {
if (frame_isc(f)) if (frame_isc(f) || (LJ_HASFFI && frame_iscont(f) &&
(f-1)->u32.lo == LJ_CONT_FFI_CALLBACK))
cf = cframe_raw(cframe_prev(cf)); cf = cframe_raw(cframe_prev(cf));
f = frame_prevd(f); f = frame_prevd(f);
} }
@ -463,7 +465,7 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
lj_debug_shortname(ar->short_src, name); lj_debug_shortname(ar->short_src, name);
ar->linedefined = (int)firstline; ar->linedefined = (int)firstline;
ar->lastlinedefined = (int)(firstline + pt->numline); ar->lastlinedefined = (int)(firstline + pt->numline);
ar->what = firstline ? "Lua" : "main"; ar->what = (firstline || !pt->numline) ? "Lua" : "main";
} else { } else {
ar->source = "=[C]"; ar->source = "=[C]";
ar->short_src[0] = '['; ar->short_src[0] = '[';

View File

@ -1,6 +1,6 @@
/* /*
** Debugging and introspection. ** Debugging and introspection.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_DEBUG_H #ifndef _LJ_DEBUG_H

View File

@ -1,6 +1,6 @@
/* /*
** LuaJIT common internal definitions. ** LuaJIT common internal definitions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_DEF_H #ifndef _LJ_DEF_H
@ -111,7 +111,7 @@ typedef uintptr_t BloomFilter;
#define bloomset(b, x) ((b) |= bloombit((x))) #define bloomset(b, x) ((b) |= bloombit((x)))
#define bloomtest(b, x) ((b) & bloombit((x))) #define bloomtest(b, x) ((b) & bloombit((x)))
#if defined(__GNUC__) #if defined(__GNUC__) || defined(__psp2__)
#define LJ_NORET __attribute__((noreturn)) #define LJ_NORET __attribute__((noreturn))
#define LJ_ALIGN(n) __attribute__((aligned(n))) #define LJ_ALIGN(n) __attribute__((aligned(n)))
@ -119,7 +119,7 @@ typedef uintptr_t BloomFilter;
#define LJ_AINLINE inline __attribute__((always_inline)) #define LJ_AINLINE inline __attribute__((always_inline))
#define LJ_NOINLINE __attribute__((noinline)) #define LJ_NOINLINE __attribute__((noinline))
#if defined(__ELF__) || defined(__MACH__) #if defined(__ELF__) || defined(__MACH__) || defined(__psp2__)
#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__)) #if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__))
#define LJ_NOAPI extern __attribute__((visibility("hidden"))) #define LJ_NOAPI extern __attribute__((visibility("hidden")))
#endif #endif
@ -150,6 +150,9 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
#if defined(__arm__) #if defined(__arm__)
static LJ_AINLINE uint32_t lj_bswap(uint32_t x) static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
{ {
#if defined(__psp2__)
return __builtin_rev(x);
#else
uint32_t r; uint32_t r;
#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\ #if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\
__ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ __ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
@ -163,6 +166,7 @@ static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
#endif #endif
return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8); return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8);
#endif #endif
#endif
} }
static LJ_AINLINE uint64_t lj_bswap64(uint64_t x) static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)

View File

@ -1,6 +1,6 @@
/* /*
** Instruction dispatch handling. ** Instruction dispatch handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_dispatch_c #define lj_dispatch_c

View File

@ -1,6 +1,6 @@
/* /*
** Instruction dispatch handling. ** Instruction dispatch handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_DISPATCH_H #ifndef _LJ_DISPATCH_H

View File

@ -1,6 +1,6 @@
/* /*
** ARM instruction emitter. ** ARM instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Constant encoding --------------------------------------------------- */ /* -- Constant encoding --------------------------------------------------- */

View File

@ -1,6 +1,6 @@
/* /*
** MIPS instruction emitter. ** MIPS instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Emit basic instructions --------------------------------------------- */ /* -- Emit basic instructions --------------------------------------------- */

View File

@ -1,6 +1,6 @@
/* /*
** PPC instruction emitter. ** PPC instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Emit basic instructions --------------------------------------------- */ /* -- Emit basic instructions --------------------------------------------- */

View File

@ -1,6 +1,6 @@
/* /*
** x86/x64 instruction emitter. ** x86/x64 instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* -- Emit basic instructions --------------------------------------------- */ /* -- Emit basic instructions --------------------------------------------- */

View File

@ -1,6 +1,6 @@
/* /*
** Error handling. ** Error handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_err_c #define lj_err_c
@ -378,7 +378,7 @@ typedef struct UndocumentedDispatcherContext {
ULONG64 EstablisherFrame; ULONG64 EstablisherFrame;
ULONG64 TargetIp; ULONG64 TargetIp;
PCONTEXT ContextRecord; PCONTEXT ContextRecord;
PEXCEPTION_ROUTINE LanguageHandler; void (*LanguageHandler)(void);
PVOID HandlerData; PVOID HandlerData;
PUNWIND_HISTORY_TABLE HistoryTable; PUNWIND_HISTORY_TABLE HistoryTable;
ULONG ScopeIndex; ULONG ScopeIndex;
@ -499,8 +499,7 @@ static ptrdiff_t finderrfunc(lua_State *L)
{ {
cTValue *frame = L->base-1, *bot = tvref(L->stack); cTValue *frame = L->base-1, *bot = tvref(L->stack);
void *cf = L->cframe; void *cf = L->cframe;
while (frame > bot) { while (frame > bot && cf) {
lua_assert(cf != NULL);
while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */ while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */
if (frame >= restorestack(L, -cframe_nres(cf))) if (frame >= restorestack(L, -cframe_nres(cf)))
break; break;
@ -518,12 +517,14 @@ static ptrdiff_t finderrfunc(lua_State *L)
case FRAME_C: case FRAME_C:
cf = cframe_prev(cf); cf = cframe_prev(cf);
/* fallthrough */ /* fallthrough */
case FRAME_VARG:
frame = frame_prevd(frame);
break;
case FRAME_CONT: case FRAME_CONT:
#if LJ_HASFFI #if LJ_HASFFI
if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK)
cf = cframe_prev(cf); cf = cframe_prev(cf);
#endif #endif
case FRAME_VARG:
frame = frame_prevd(frame); frame = frame_prevd(frame);
break; break;
case FRAME_CP: case FRAME_CP:
@ -725,9 +726,23 @@ LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em)
/* Typecheck error for arguments. */ /* Typecheck error for arguments. */
LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname) LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname)
{ {
TValue *o = narg < 0 ? L->top + narg : L->base + narg-1; const char *tname, *msg;
const char *tname = o < L->top ? lj_typename(o) : lj_obj_typename[0]; if (narg <= LUA_REGISTRYINDEX) {
const char *msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname); if (narg >= LUA_GLOBALSINDEX) {
tname = lj_obj_itypename[~LJ_TTAB];
} else {
GCfunc *fn = curr_func(L);
int idx = LUA_GLOBALSINDEX - narg;
if (idx <= fn->c.nupvalues)
tname = lj_typename(&fn->c.upvalue[idx-1]);
else
tname = lj_obj_typename[0];
}
} else {
TValue *o = narg < 0 ? L->top + narg : L->base + narg-1;
tname = o < L->top ? lj_typename(o) : lj_obj_typename[0];
}
msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname);
err_argmsg(L, narg, msg); err_argmsg(L, narg, msg);
} }

View File

@ -1,6 +1,6 @@
/* /*
** Error handling. ** Error handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_ERR_H #ifndef _LJ_ERR_H

View File

@ -1,6 +1,6 @@
/* /*
** VM error messages. ** VM error messages.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
/* This file may be included multiple times with different ERRDEF macros. */ /* This file may be included multiple times with different ERRDEF macros. */

View File

@ -1,6 +1,6 @@
/* /*
** Fast function IDs. ** Fast function IDs.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_FF_H #ifndef _LJ_FF_H

View File

@ -1,6 +1,6 @@
/* /*
** Fast function call recorder. ** Fast function call recorder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#define lj_ffrecord_c #define lj_ffrecord_c

View File

@ -1,6 +1,6 @@
/* /*
** Fast function call recorder. ** Fast function call recorder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_FFRECORD_H #ifndef _LJ_FFRECORD_H

View File

@ -1,6 +1,6 @@
/* /*
** Stack frames. ** Stack frames.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_FRAME_H #ifndef _LJ_FRAME_H

View File

@ -1,6 +1,6 @@
/* /*
** Function handling (prototypes, functions and upvalues). ** Function handling (prototypes, functions and upvalues).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Portions taken verbatim or adapted from the Lua interpreter. ** Portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View File

@ -1,6 +1,6 @@
/* /*
** Function handling (prototypes, functions and upvalues). ** Function handling (prototypes, functions and upvalues).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_FUNC_H #ifndef _LJ_FUNC_H

View File

@ -1,6 +1,6 @@
/* /*
** Garbage collector. ** Garbage collector.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
** **
** Major portions taken verbatim or adapted from the Lua interpreter. ** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -631,6 +631,8 @@ static size_t gc_onestep(lua_State *L)
case GCSsweep: { case GCSsweep: {
MSize old = g->gc.total; MSize old = g->gc.total;
setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX));
lua_assert(old >= g->gc.total);
g->gc.estimate -= old - g->gc.total;
if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) {
gc_shrink(g, L); gc_shrink(g, L);
if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ if (gcref(g->gc.mmudata)) { /* Need any finalizations? */
@ -643,8 +645,6 @@ static size_t gc_onestep(lua_State *L)
g->gc.debt = 0; g->gc.debt = 0;
} }
} }
lua_assert(old >= g->gc.total);
g->gc.estimate -= old - g->gc.total;
return GCSWEEPMAX*GCSWEEPCOST; return GCSWEEPMAX*GCSWEEPCOST;
} }
case GCSfinalize: case GCSfinalize:

View File

@ -1,6 +1,6 @@
/* /*
** Garbage collector. ** Garbage collector.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/ */
#ifndef _LJ_GC_H #ifndef _LJ_GC_H

Some files were not shown because too many files have changed in this diff Show More