2018-10-17 20:52:50 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2019-01-30 17:23:29 +08:00
|
|
|
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
|
2018-10-17 20:52:50 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2018-11-01 23:20:07 +08:00
|
|
|
| Authors: Dmitry Stogov <dmitry@php.net> |
|
2018-10-17 20:52:50 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEND_MAP_PTR_H
|
|
|
|
#define ZEND_MAP_PTR_H
|
|
|
|
|
|
|
|
#include "zend_portability.h"
|
|
|
|
|
|
|
|
#define ZEND_MAP_PTR_KIND_PTR 0
|
|
|
|
#define ZEND_MAP_PTR_KIND_PTR_OR_OFFSET 1
|
|
|
|
|
|
|
|
//#if defined(ZTS) || defined(TSRM_WIN32)
|
|
|
|
# define ZEND_MAP_PTR_KIND ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
|
|
|
|
//#else
|
|
|
|
//# define ZEND_MAP_PTR_KIND ZEND_MAP_PTR_KIND_PTR
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR
|
|
|
|
# define ZEND_MAP_PTR(ptr) \
|
|
|
|
ptr ## __ptr
|
|
|
|
# define ZEND_MAP_PTR_DEF(type, name) \
|
|
|
|
type * ZEND_MAP_PTR(name)
|
|
|
|
# define ZEND_MAP_PTR_GET(ptr) \
|
|
|
|
(*(ZEND_MAP_PTR(ptr)))
|
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-10 03:53:57 +08:00
|
|
|
# define ZEND_MAP_PTR_GET_IMM(ptr) \
|
|
|
|
ZEND_MAP_PTR_GET(ptr)
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_SET(ptr, val) do { \
|
|
|
|
(*(ZEND_MAP_PTR(ptr))) = (val); \
|
|
|
|
} while (0)
|
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-10 03:53:57 +08:00
|
|
|
# define ZEND_MAP_PTR_SET_IMM(ptr, val) \
|
|
|
|
ZEND_MAP_PTR_SET(ptr, val)
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_INIT(ptr, val) do { \
|
|
|
|
ZEND_MAP_PTR(ptr) = (val); \
|
|
|
|
} while (0)
|
|
|
|
# define ZEND_MAP_PTR_NEW(ptr) do { \
|
|
|
|
ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
|
|
|
|
} while (0)
|
2020-01-13 19:27:35 +08:00
|
|
|
# define ZEND_MAP_PTR_REAL_BASE(base) \
|
|
|
|
(base)
|
|
|
|
# define ZEND_MAP_PTR_SET_REAL_BASE(base, ptr) do { \
|
|
|
|
base = (ptr); \
|
|
|
|
} while (0)
|
2021-04-09 04:37:40 +08:00
|
|
|
# define ZEND_MAP_PTR_OFFSET2PTR(offset) \
|
|
|
|
((void**)((char*)CG(map_ptr_base) + offset))
|
2018-10-17 20:52:50 +08:00
|
|
|
#elif ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
|
|
|
|
# define ZEND_MAP_PTR(ptr) \
|
|
|
|
ptr ## __ptr
|
|
|
|
# define ZEND_MAP_PTR_DEF(type, name) \
|
|
|
|
type * ZEND_MAP_PTR(name)
|
|
|
|
# define ZEND_MAP_PTR_IS_OFFSET(ptr) \
|
|
|
|
(((uintptr_t)ZEND_MAP_PTR(ptr)) & 1L)
|
2021-04-09 04:37:40 +08:00
|
|
|
# define ZEND_MAP_PTR_OFFSET2PTR(offset) \
|
|
|
|
((void**)((char*)CG(map_ptr_base) + offset))
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_PTR2OFFSET(ptr) \
|
2020-01-13 19:27:35 +08:00
|
|
|
((void*)(((char*)(ptr)) - ((char*)CG(map_ptr_base))))
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_GET(ptr) \
|
2020-01-13 19:27:35 +08:00
|
|
|
(*(ZEND_MAP_PTR_IS_OFFSET(ptr) ? \
|
2021-04-09 04:37:40 +08:00
|
|
|
ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)) : \
|
2020-01-13 19:27:35 +08:00
|
|
|
((void**)(ZEND_MAP_PTR(ptr)))))
|
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-10 03:53:57 +08:00
|
|
|
# define ZEND_MAP_PTR_GET_IMM(ptr) \
|
2021-04-09 04:37:40 +08:00
|
|
|
(*ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)))
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_SET(ptr, val) do { \
|
2020-01-13 19:27:35 +08:00
|
|
|
void **__p = (void**)(ZEND_MAP_PTR(ptr)); \
|
2018-10-17 20:52:50 +08:00
|
|
|
if (ZEND_MAP_PTR_IS_OFFSET(ptr)) { \
|
2021-04-09 04:37:40 +08:00
|
|
|
__p = ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)); \
|
2018-10-17 20:52:50 +08:00
|
|
|
} \
|
2020-01-13 19:27:35 +08:00
|
|
|
*__p = (val); \
|
2018-10-17 20:52:50 +08:00
|
|
|
} while (0)
|
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-10 03:53:57 +08:00
|
|
|
# define ZEND_MAP_PTR_SET_IMM(ptr, val) do { \
|
2021-04-09 04:37:40 +08:00
|
|
|
void **__p = ZEND_MAP_PTR_OFFSET2PTR((uintptr_t)ZEND_MAP_PTR(ptr)); \
|
Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.
PHP classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.
Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).
The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-10 03:53:57 +08:00
|
|
|
*__p = (val); \
|
|
|
|
} while (0)
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_INIT(ptr, val) do { \
|
|
|
|
ZEND_MAP_PTR(ptr) = (val); \
|
|
|
|
} while (0)
|
|
|
|
# define ZEND_MAP_PTR_NEW(ptr) do { \
|
|
|
|
ZEND_MAP_PTR(ptr) = zend_map_ptr_new(); \
|
|
|
|
} while (0)
|
2020-01-13 19:27:35 +08:00
|
|
|
# define ZEND_MAP_PTR_REAL_BASE(base) \
|
2020-01-28 18:23:16 +08:00
|
|
|
((void*)(((uintptr_t)(base)) + 1))
|
2020-01-13 19:27:35 +08:00
|
|
|
# define ZEND_MAP_PTR_SET_REAL_BASE(base, ptr) do { \
|
2020-01-28 18:23:16 +08:00
|
|
|
base = (void*)(((uintptr_t)(ptr)) - 1); \
|
2020-01-13 19:27:35 +08:00
|
|
|
} while (0)
|
2018-10-17 20:52:50 +08:00
|
|
|
#else
|
|
|
|
# error "Unknown ZEND_MAP_PTR_KIND"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ZEND_API void zend_map_ptr_reset(void);
|
|
|
|
ZEND_API void *zend_map_ptr_new(void);
|
|
|
|
ZEND_API void zend_map_ptr_extend(size_t last);
|
|
|
|
|
|
|
|
#endif /* ZEND_MAP_PTR_H */
|