Skip to content

Commit dec8eb4

Browse files
committed
noted the TSRM changes to UPGRADING.INTERNALS
1 parent e8acb9f commit dec8eb4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

UPGRADING.INTERNALS

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ PHP 7.0 INTERNALS UPGRADE NOTES
1414
m. Other portable macros info
1515
n. ZEND_ENGINE_2 removal
1616
o. Updated final class modifier
17+
p. TSRM changes
1718

1819
2. Build system changes
1920
a. Unix build system changes
@@ -128,6 +129,47 @@ PHP 7.0 INTERNALS UPGRADE NOTES
128129
o. Removed ZEND_ACC_FINAL_CLASS in favour of ZEND_ACC_FINAL, turning final class
129130
modifier now a different class entry flag. Update your extensions.
130131

132+
p. TSRM changes
133+
134+
The TSRM layer undergone significant changes. It is not necessary anymore to
135+
pass the tsrm_ls pointer explicitly. The TSRMLS_* macros should not be used
136+
in any new developments.
137+
138+
The recommended way accessing globals in TS builds is by implementing it
139+
to use a local thread unique pointer to the corresponding data pool. These
140+
are the new macros that serve to achieve this goal:
141+
142+
- ZEND_TSRMG - based on TSRMG and if static pointer for data pool access is
143+
implemented, will use it
144+
- ZEND_TSRMLS_CACHE_EXTERN - to be used in a header shared across multiple
145+
C/C++ files
146+
- ZEND_TSRMLS_CACHE_DEFINE - to be used in the main extension C/C++ file
147+
- ZEND_TSRMLS_CACHE_UPDATE - to be integrated at the top of the globals
148+
ctor or RINIT function
149+
- ZEND_ENABLE_STATIC_TSRMLS_CACHE - to be used in the config.[m4|w32] for
150+
enabling the globals access per thread unique pointer
151+
- TSRMLS_CACHE - expands to the variable name which links to the thread
152+
unique data pool
153+
154+
Note that usually it will work without implementing the globals access per
155+
a thread unique pointer, however it might cause a slowdown. The reason is
156+
that the access model to the extension/SAPI own globals as well as the
157+
access to the core globals is determined in the compilation phase depending
158+
on whether ZEND_ENABLE_STATIC_TSRMLS_CACHE macro is defined.
159+
160+
Due to the current compiler evolution state, the TSRMLS_CACHE pointer
161+
(when implemented) has to be present and updated in every binary unit which
162+
is not compiled statically into PHP. So any DLL, DSO, EXE, etc. has to take
163+
care about defining and updating it's TSRMLS cache. An update should happen
164+
before any globals was accessed.
165+
166+
Porting an extension or SAPI is usually as easy as removing all the TSRMLS_*
167+
ocurrences and integrating the macros mentioned above. However if tsrm_ls
168+
is used explicitly, its usage can considered obsolete in most cases.
169+
Additionally, if an extension triggers its own threads, TSRMLS_CACHE shouldn't
170+
be passed to that threads directly.
171+
172+
131173
========================
132174
2. Build system changes
133175
========================

0 commit comments

Comments
 (0)