[Paper Reading] The Implementation of Lua 5.0
2016-04-10 20:36
393 查看
Ierusalimschy, R., De Figueiredo, L. H., & Celes Filho, W. (2005). The Implementation of Lua 5.0. J. UCS, 11(7), 1159-1176.
Register-based virtual machine
Optimized tables
Closures
Coroutines
nil
boolean: true, false
number: double (float/long)
string: arrays of bytes
table: associative arrays
function
userdata: pointers to user memory blocks: heavy, subject to garbage collection; light, freed by user
thread: coroutines
Hybrid: hash part and array part
Growth of array part:
at least half the slots between 1 and n are in use
at least on used slot between n/2+1 and n
Hash part: uses a mix of chained scatter table with Brent’s variation
Implement closures: upvalue,
flat closures
interpreter cannot use its internal C stack to implement calls in the interpreted code
uses C stack to keep track of the stack of active coroutines at any given time
cactus structure
Introduction
Main novelties:Register-based virtual machine
Optimized tables
Closures
Coroutines
Values
Dynamically-typed language, basic types:nil
boolean: true, false
number: double (float/long)
string: arrays of bytes
table: associative arrays
function
userdata: pointers to user memory blocks: heavy, subject to garbage collection; light, freed by user
thread: coroutines
typedef struct { int tag; /* Identify the type */ Value v; } TObject; typedef union { GCObject *gc; /* strings, functions, heavy userdata and threads */ void *p; /* light userdata */ lua_Number n; /* numbers */ int b; /* booleans */ } Value;
Tables
Hybrid: hash part and array part
Growth of array part:
at least half the slots between 1 and n are in use
at least on used slot between n/2+1 and n
Hash part: uses a mix of chained scatter table with Brent’s variation
Functions and Closures
Implement closures: upvalue,
flat closures
Threads and Coroutines
create, resume, yieldinterpreter cannot use its internal C stack to implement calls in the interpreted code
uses C stack to keep track of the stack of active coroutines at any given time
cactus structure
The Virtual Machine
相关文章推荐
- Lua函数
- Lua语句
- Lua表达式
- Evaluate Reverse Polish Notation
- Metatable让我从心认知了Lua(相知篇)
- Lua基础
- LuaFileSystem学习心得
- lua中table如何安全移除元素
- lua编译环境搭建
- 项目记录33--tolua 框架 回顾架构和重构事件派发LNotice
- 项目记录32--tolua build android错误tolua.lua no found
- lua 表赋值是引用关系
- Lua学习笔记-习题5.4
- Lua中的loadfile,dofile,require使用,最后还有调试
- Lua语法基础(3)--迭代器和泛型for
- lua学习笔记
- lua string 库
- lua中的table的应用
- Lua语法基础(2)--基本语法、函数
- lua ffi access to alien static or global variables