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
|
|
|
|
|
2023-01-16 19:25:59 +08:00
|
|
|
#include "zend_portability.h"
|
2018-10-17 20:52:50 +08:00
|
|
|
|
2024-05-21 04:30:38 +08:00
|
|
|
typedef struct _zend_string zend_string;
|
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
#define ZEND_MAP_PTR_KIND_PTR 0
|
|
|
|
#define ZEND_MAP_PTR_KIND_PTR_OR_OFFSET 1
|
|
|
|
|
2021-10-14 17:16:18 +08:00
|
|
|
#define ZEND_MAP_PTR_KIND ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
|
2018-10-17 20:52:50 +08:00
|
|
|
|
2021-08-23 19:04:02 +08:00
|
|
|
#define ZEND_MAP_PTR(ptr) \
|
2018-10-17 20:52:50 +08:00
|
|
|
ptr ## __ptr
|
2021-08-23 19:04:02 +08:00
|
|
|
#define ZEND_MAP_PTR_DEF(type, name) \
|
2021-10-14 17:16:18 +08:00
|
|
|
type ZEND_MAP_PTR(name)
|
2021-08-23 19:04:02 +08:00
|
|
|
#define ZEND_MAP_PTR_OFFSET2PTR(offset) \
|
|
|
|
((void**)((char*)CG(map_ptr_base) + offset))
|
|
|
|
#define ZEND_MAP_PTR_PTR2OFFSET(ptr) \
|
|
|
|
((void*)(((char*)(ptr)) - ((char*)CG(map_ptr_base))))
|
|
|
|
#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)
|
|
|
|
|
2021-10-14 17:16:18 +08:00
|
|
|
#if ZEND_MAP_PTR_KIND == ZEND_MAP_PTR_KIND_PTR_OR_OFFSET
|
2021-08-23 19:04:02 +08:00
|
|
|
# define ZEND_MAP_PTR_NEW_OFFSET() \
|
|
|
|
((uint32_t)(uintptr_t)zend_map_ptr_new())
|
2018-10-17 20:52:50 +08:00
|
|
|
# define ZEND_MAP_PTR_IS_OFFSET(ptr) \
|
|
|
|
(((uintptr_t)ZEND_MAP_PTR(ptr)) & 1L)
|
|
|
|
# define ZEND_MAP_PTR_GET(ptr) \
|
2021-10-14 17:16:18 +08:00
|
|
|
((ZEND_MAP_PTR_IS_OFFSET(ptr) ? \
|
|
|
|
ZEND_MAP_PTR_GET_IMM(ptr) : \
|
|
|
|
((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 { \
|
|
|
|
if (ZEND_MAP_PTR_IS_OFFSET(ptr)) { \
|
2021-10-14 17:16:18 +08:00
|
|
|
ZEND_MAP_PTR_SET_IMM(ptr, val); \
|
|
|
|
} else { \
|
|
|
|
ZEND_MAP_PTR_INIT(ptr, 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)
|
2021-08-26 18:27:25 +08:00
|
|
|
# define ZEND_MAP_PTR_BIASED_BASE(real_base) \
|
|
|
|
((void*)(((uintptr_t)(real_base)) - 1))
|
2018-10-17 20:52:50 +08:00
|
|
|
#else
|
|
|
|
# error "Unknown ZEND_MAP_PTR_KIND"
|
|
|
|
#endif
|
|
|
|
|
2022-03-18 02:28:34 +08:00
|
|
|
BEGIN_EXTERN_C()
|
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
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);
|
2021-08-11 16:28:52 +08:00
|
|
|
ZEND_API void zend_alloc_ce_cache(zend_string *type_name);
|
2018-10-17 20:52:50 +08:00
|
|
|
|
2022-03-18 02:28:34 +08:00
|
|
|
END_EXTERN_C()
|
|
|
|
|
2018-10-17 20:52:50 +08:00
|
|
|
#endif /* ZEND_MAP_PTR_H */
|