关于luajit的bytecode模式

来源:互联网 发布:海洛因的网络名称 编辑:程序博客网 时间:2024/05/04 12:35

最近把android下的Lua换成了Luajit,并且使用了bytecode,后来发现某些品牌的手机崩溃的比较多,于是怀疑是不是luajit的问题,所以就对Luajit的bytecode模式做了点调研,我们先来看一下-b参数的说明

-b[options] input output

This option saves or lists bytecode. The following additional options are accepted:

  • -l — Only list bytecode.
  • -s — Strip debug info (this is the default).
  • -g — Keep debug info.
  • -n name — Set module name (default: auto-detect from input name)
  • -t type — Set output file type (default: auto-detect from output name).
  • -a arch — Override architecture for object files (default: native).
  • -o os — Override OS for object files (default: native).
  • -e chunk — Use chunk string as input.
  • - (a single minus sign) — Use stdin as input and/or stdout as output.

The output file type is auto-detected from the extension of the output file name:

  • c — C source file, exported bytecode data.
  • h — C header file, static bytecode data.
  • obj or o — Object file, exported bytecode data (OS- and architecture-specific).
  • raw or any other extension — Raw bytecode file (portable).

比较值得说的一点是Output那里,根据文档,luajit -b是根据output的后缀名来决定应该编译成什么东西的

luajit -b main.lua main.c 输出就是一个c文件

luajit -b main.lua main.h 输出就是一个头文件

luajit -b main.lua main.o 输出就是一个object文件,这个时候要注意了,如果是交叉编译,那就得指定-o -a

luajit -b main.lua main.lua 输出就是一个原生的bytecode文件,这个文件是跨平台的,就跟普通的lua文件一样


所以看来崩溃跟Luajit关系不大了,继续找吧。

搜索了一下luajit的邮件列表,发现确认有人也发现会core在luajit里,必须如果使用了bytecode模式的话,情况会更糟糕,

另外发现cocos2dx自带的Luajit版本有点低了,先换到2.0.3看看效果

0 0
原创粉丝点击