phpng-int
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
phpng-int [2014/07/23 06:36] – dmitry | phpng-int [2018/01/09 15:49] – kalle | ||
---|---|---|---|
Line 5: | Line 5: | ||
===== Value Representation ===== | ===== Value Representation ===== | ||
- | All values in existing Zend Engine implementation were allocated on heap and they are subject for reference counting and garbage collection. Zend engine mostly | + | All values in existing Zend Engine implementation were allocated on heap and they were subject for reference counting and garbage collection. Zend engine mostly |
- | The new implementation operates by zval structures their selves (not pointers). It stores new zval structures directly on stack, in HashTable buckets, and property slots. It dramatically reduces number of heap allocations/ | + | The new implementation operates by zval structures their selves (not pointers). It stores new zval structures directly on VM stack, in HashTable buckets, and property slots. It dramatically reduces number of heap allocations/ |
- | The new implementation uses more VM stack space (instead of heap), because now it keeps there zval structures instead of pointers. Anyway, the overall memory usage is reduced. In some cases new approach assumes full zval copying instead of copy-on write implemented before, but it doesn' | + | The new implementation uses more VM stack space (instead of heap), because now it keeps there zval structures instead of pointers. Anyway, the overall memory usage is reduced. In some cases new approach assumes full zval copying instead of copy-on-write implemented before, but it doesn' |
==== CELL Format (zval) ==== | ==== CELL Format (zval) ==== | ||
Line 21: | Line 21: | ||
</ | </ | ||
- | The value cell represented as two 64-bit words. The first word contains actual value (it's defined as a union of possible value types), the second contains type tag and some flags. The type and flags may be accessed together as a single 32-bit | + | The value cell represented as two 64-bit words. The first word contains actual value (it's defined as a union of possible value types), the second contains type tag and some flags. The type and flags may be accessed together as a single 32-bit |
- | The re-factored engine defines the following data types most of that are well known from the exiting | + | The re-factored engine defines the following data types. Most of them are well known from PHP-5 engine: |
* IS_UNDEF – we use a special type for undefined variables | * IS_UNDEF – we use a special type for undefined variables | ||
Line 31: | Line 31: | ||
* IS_LONG | * IS_LONG | ||
* IS_DOUBLE | * IS_DOUBLE | ||
- | * IS_STRING – interned | + | * IS_STRING – regular |
- | * IS_ARRAY | + | * IS_ARRAY |
* IS_OBJECT | * IS_OBJECT | ||
* IS_RESOURCE | * IS_RESOURCE | ||
- | * IS_REFERENCE – a separate type for references (t'll be explained later) | + | * IS_REFERENCE – a separate type for references (it'll be explained later) |
* IS_CONSTANT – named constant | * IS_CONSTANT – named constant | ||
Line 49: | Line 49: | ||
Except for types itself, the engine defines few type flags to uniform handling of different data types with similar behavior. | Except for types itself, the engine defines few type flags to uniform handling of different data types with similar behavior. | ||
- | * IS_TYPE_CONSTANT – the type is a constant (IS_CONSTANT, IS_CONSTANT_ARRAY, IS_CONSTANT_AST) | + | * IS_TYPE_CONSTANT – the type is a constant (IS_CONSTANT, |
- | * IS_TYPE_REFCOUNTED – the type is a subject for reference counting (IS_STRING excluding interned srings, IS_ARRAY, IS_OBJECT, IS_RESOURCE, | + | * IS_TYPE_REFCOUNTED – the type is a subject for reference counting (IS_STRING excluding interned srings, IS_ARRAY |
* IS_TYPE_COLLECTABLE – the type may be a root of unreferenced cycle and it's a subject for Garbage Collection (IS_ARRAY, IS_OBJECT). | * IS_TYPE_COLLECTABLE – the type may be a root of unreferenced cycle and it's a subject for Garbage Collection (IS_ARRAY, IS_OBJECT). | ||
* IS_TYPE_COPYABLE – the type has to be duplicated using zval_copy_ctor() on assignment or copy on write (IS_STRING excluding interned strings, IS_ARRAY) | * IS_TYPE_COPYABLE – the type has to be duplicated using zval_copy_ctor() on assignment or copy on write (IS_STRING excluding interned strings, IS_ARRAY) | ||
+ | * IS_TYPE_IMMUTABLE - the type can't be changed directly, but may be copied on write. Used by immutable arrays to avoid unnecessary array duplication. | ||
- | Few constants | + | Few constants flags are used as modifiers for IS_CONSTANT. Their meaning kept exactly |
- | The type may be read using Z_TYPE() or Z_TYPE_P() macros, type flags using Z_TYPE_FLAGS() or Z_TYPE_FLAGS_P(), | + | * IS_CONSTANT_UNQUALIFIED |
+ | * IS_LEXICAL_VAR | ||
+ | * IS_LEXICAL_REF | ||
+ | * IS_CONSTANT_IN_NAMESPACE | ||
+ | |||
+ | The type of zval may be read using Z_TYPE() or Z_TYPE_P() macros, type flags using Z_TYPE_FLAGS() or Z_TYPE_FLAGS_P(), | ||
==== IS_UNDEF ==== | ==== IS_UNDEF ==== | ||
Line 113: | Line 119: | ||
| DOUBLE VALUE (64-bit) | | DOUBLE VALUE (64-bit) | ||
+--------------------------+-------------+-------------+-------------+-------------+ | +--------------------------+-------------+-------------+-------------+-------------+ | ||
- | | UNUSED (32-bit) | + | | UNUSED (32-bit) |
+--------------------------+-------------+-------------+-------------+-------------+ | +--------------------------+-------------+-------------+-------------+-------------+ | ||
| | ||
Line 419: | Line 425: | ||
[TO BE CONTINUED] | [TO BE CONTINUED] | ||
- |
phpng-int.txt · Last modified: 2018/01/09 16:34 by kelunik