Skip to content

Special JIT support for FFI #14491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 101 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
c3186c4
Initial JIT/FFI PoC
dstogov Sep 26, 2024
ca9079e
JIT: Implement FFI Array Bounds Checks
dstogov Jun 7, 2024
95581ee
JIT: Separate FFI assing_op helper. Add support for all SUB, AND, etc
dstogov Jun 7, 2024
68d146e
JIT: Fix NULL dereference
dstogov Jun 7, 2024
e748d7a
JIT: Fix FFI pointer access through FETCH_DIM, ASSIGN_DIM
dstogov Jun 7, 2024
6e6147a
JIT: Fix memory leak in ext/ffi/tests/032.phpt
dstogov Jun 7, 2024
9d94552
Support for 32-bit build
dstogov Jun 10, 2024
1899954
Move "zend_ffi_cdata_ce" to Zend to allow JIT<->FFI interopability on…
dstogov Jun 10, 2024
f6f9cf3
Cache FFI types in opcache SHM (incomplete)
dstogov Jun 14, 2024
3d20a0a
Make cached HashTables immutable
dstogov Jun 14, 2024
c3bee27
Cache FFI types and scopes in opcache SHM
dstogov Jun 17, 2024
a5b089b
Fix incorrect return type
dstogov Jun 17, 2024
e4e34f1
Cache FFI scope created by FFI::load()
dstogov Jun 17, 2024
ff5e593
Add class abd FFI type guards
dstogov Jun 18, 2024
6032baa
Avoid repeatable FFI type guards (no LICM yet)
dstogov Jun 18, 2024
566b3eb
JIT: Implement special support for FFI "struct" access
dstogov Jun 19, 2024
bfcd371
Fix incorrect 64-bit reads
dstogov Jun 20, 2024
ad6a6c1
Prevent JIT code generation for 64-bit FFI data in 32-bit build
dstogov Jun 20, 2024
e0063a8
Synch register allocation rules
dstogov Jun 21, 2024
693de69
Support for assignment FFI CData to another CData array/struct
dstogov Jun 21, 2024
83e6e8e
Disable modification of "const" fields
dstogov Jun 24, 2024
7fb3a2c
JIT to read FFI variables
dstogov Jun 24, 2024
e2ee57c
Add FFI class and cdef guards
dstogov Jun 24, 2024
7fc144a
JIT to write to FFI variables
dstogov Jun 24, 2024
f6c3acd
Fix 32-bit build
dstogov Jun 25, 2024
0ffbb8d
Fix Windows build
dstogov Jun 25, 2024
066a523
JIT support for FFI calls (incomplete)
dstogov Jun 27, 2024
fe2de10
Fix memory leaks
dstogov Jun 27, 2024
861c6c6
iFix build wthout FFI
dstogov Jun 27, 2024
7791255
Make predefined types pesistent
dstogov Jun 27, 2024
00cb74f
Reset persistent attribute
dstogov Jun 27, 2024
bad5a61
Make FFI type cache context senseive
dstogov Jul 3, 2024
72e86a5
Cleanup pointer compression
dstogov Jul 3, 2024
05bee9d
Add symbols guard
dstogov Jul 3, 2024
3605a6f
Allow JIT for reading FFI arrays/structs/pointers
dstogov Jul 3, 2024
cb6cbff
Fix registers update
dstogov Jul 4, 2024
09f4381
FFI and CData are "final" classes. Their object handlers can't be cal…
dstogov Jul 4, 2024
05aea36
Support for FFI pointer math
dstogov Jul 4, 2024
7b432e4
Support for ASSIGN_OBJ/DIM with result
dstogov Jul 4, 2024
3a14b04
Support for FFI pointer assignment
dstogov Jul 4, 2024
735482f
FFI JIT for FETCH_DIM/OBJ_W
dstogov Jul 4, 2024
a873c71
Fix uninitialized data access
dstogov Jul 5, 2024
8d39cfe
Fix calling convention
dstogov Jul 5, 2024
9ae9158
FFI JIT for FETCH_DIM/OBJ_W + ASSIGN_DIM
dstogov Jul 5, 2024
ed6ee1e
FFI JIT for FETCH_DIM_RW + ASSIGN_DIM_OP
dstogov Jul 5, 2024
0d04e48
FFI JIT for PRE/POST_INC/DEC_OBJ
dstogov Jul 5, 2024
42cc7cd
Remove useless checks
dstogov Jul 25, 2024
1857948
Move FFI related JIT code generation into zend_jit_ir_ffi.c
dstogov Jul 25, 2024
3c9b7bc
Better JIT support for FFI function calls
dstogov Jul 26, 2024
9c44a26
JIT/FFI support for "cdata" property of scalar ffi objects
dstogov Jul 30, 2024
ec6f8b1
Avoid modification of "const" CData
dstogov Jul 30, 2024
21b3db4
Add JIT/FFI tests
dstogov Jul 30, 2024
7cb6c2e
Add SKIPIF sectionis and "stdout" recovery code
dstogov Jul 30, 2024
515aa4d
Reciver "stdout" before calling var_dump()
dstogov Jul 30, 2024
65db269
Add EXTENSIONS section
dstogov Jul 30, 2024
7398254
Fix SKIPIF sections
dstogov Jul 30, 2024
8806658
JIT/FFI support for closure calls (pointers to functions)
dstogov Aug 5, 2024
23158ff
JIT/FFI cleanup arguments
dstogov Aug 5, 2024
f0f1a22
FFI/JIT better support for enums
dstogov Aug 5, 2024
fa52d0a
JIT/FFI add tet for closure call
dstogov Aug 6, 2024
842202f
JIT/FFI print FFI types in JIT debug traces
dstogov Aug 6, 2024
79285ca
JIT/FFI support for temporary POINTER types (e.g. created by FFI::addr)
dstogov Aug 6, 2024
469322a
JIT/FFI better support for temporary POINTER types
dstogov Aug 6, 2024
34472ab
Fixed support for lazy objects
dstogov Sep 10, 2024
9288fcf
Fix register allocation
dstogov Sep 17, 2024
53f43c5
Use signed comparison
dstogov Sep 19, 2024
2265c3b
Improve register allocation
dstogov Sep 19, 2024
145f654
Fix tests for 32-bit systems
dstogov Sep 20, 2024
96581d1
Redesign JIT/FFI API
dstogov Sep 26, 2024
8a7719b
Fix few problems in passing argumets to FFI calls
dstogov Sep 26, 2024
c21268f
Regenrate ext/ffi/ffi_arginfo.h
dstogov Sep 26, 2024
1e5fad4
Fix FFI caching
dstogov Sep 30, 2024
2f7ed89
JIT for FFI::addr()
dstogov Oct 9, 2024
11cf0c1
Passing values to FFI functions won't change their types
dstogov Oct 22, 2024
e74f5a3
Eliminate some FFI related type guards
dstogov Oct 22, 2024
c1741f0
Fix build without FFI
dstogov Oct 23, 2024
b22fbd8
Fix incorrect type info
dstogov Oct 23, 2024
60f01a3
Fix arguments cleanup
dstogov Oct 24, 2024
523f745
JIR for FFI::string()
dstogov Oct 24, 2024
1e067d5
JIT for FFI::typeof() and FFI:isNull()
dstogov Oct 25, 2024
453226a
ws
dstogov Oct 28, 2024
247927e
Improve FFI type compatibility checks
dstogov Oct 28, 2024
52dab23
Fix FFI scope reference counting during FFI call
dstogov Oct 29, 2024
3e4e6d0
Improve type inference for ZEND_FETCH_OBJ/DIM_FUNC_ARG
dstogov Oct 29, 2024
086efde
Add IS_OBJECT type assertions
dstogov Oct 31, 2024
ea75ce1
cleanup
dstogov Oct 31, 2024
c3ec5a7
cleanup
dstogov Oct 31, 2024
082d01d
JIT for FFI::memcpy(), FFI::memcmp() and FFI::memset()
dstogov Oct 31, 2024
3efb86c
Add test for FETCH_DIM_W/VAR
dstogov Nov 1, 2024
c9853b6
JIT for FFI::sizeof() and FFI::alignof()
dstogov Nov 1, 2024
474866e
JIT for FETCH_DIM_W/VAR with FFI::CData op1
dstogov Nov 2, 2024
4f0ee23
Record FFI::CTypes
dstogov Nov 5, 2024
6affe2c
Add test for FFI::type()
dstogov Nov 5, 2024
850a281
JIT for FFI::type()
dstogov Nov 5, 2024
f5b390c
JIT for FFI::new() with single argument
dstogov Nov 5, 2024
a1adbe7
JIT for FFI::new() with 2 and 3 arguments
dstogov Nov 6, 2024
3305bb5
JIT for FFI::free()
dstogov Nov 6, 2024
dc68c96
JIT for FFI::cast()
dstogov Nov 8, 2024
5fb8e8e
Eliminate useless guards
dstogov Nov 11, 2024
7998262
Properly restore FFI_G(persistent)
dstogov Nov 12, 2024
18c9ee5
Refactor information about FFI calls
dstogov Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ ZEND_API void (*zend_accel_schedule_restart_hook)(int reason) = NULL;
ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result (*zend_random_bytes)(void *bytes, size_t size, char *errstr, size_t errstr_size) = NULL;
ZEND_ATTRIBUTE_NONNULL ZEND_API void (*zend_random_bytes_insecure)(zend_random_bytes_insecure_state *state, void *bytes, size_t size) = NULL;

/* FFI/OPCache interopability API */
ZEND_API struct _zend_ffi_api *zend_ffi_api = NULL;

/* This callback must be signal handler safe! */
void (*zend_on_timeout)(int seconds);

Expand Down
3 changes: 3 additions & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ ZEND_API ZEND_COLD ZEND_NORETURN void zend_strerror_noreturn(int type, int errn,
extern ZEND_API zend_class_entry *zend_standard_class_def;
extern ZEND_API zend_utility_values zend_uv;

/* FFI/OPCache interopability API */
extern ZEND_API struct _zend_ffi_api *zend_ffi_api;

/* If DTrace is available and enabled */
extern ZEND_API bool zend_dtrace_enabled;
END_EXTERN_C()
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,8 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
#define IS_STR_PERSISTENT GC_PERSISTENT /* allocated using malloc */
#define IS_STR_PERMANENT (1<<8) /* relives request boundary */
#define IS_STR_VALID_UTF8 (1<<9) /* valid UTF-8 according to PCRE */
#define IS_STR_FFI_TYPE (1<<10) /* intrned string associated with FFI type */
#define IS_STR_FFI_SCOPE (1<<11) /* intrned string associated with FFI declaration object */

/* array flags */
#define IS_ARRAY_IMMUTABLE GC_IMMUTABLE
Expand Down
Loading
Loading