Skip to content

Commit 75237a2

Browse files
Merge pull request #484 from openfl/feature/sljit-0.95
Upgrade the cppia JIT's sljit to 0.95
2 parents fce802b + 1a2555c commit 75237a2

61 files changed

Lines changed: 49782 additions & 25708 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
project/thirdparty/*/** linguist-vendored
22
*.sh text eol=lf
3+
src/hx/cppia/sljit_src/** linguist-vendored

‎Changes.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
libhxcpp 6.0.0
33
------------------------------------------------------------
44

5+
* Updated the cppia JIT's sljit from 0.93 with local patches to 0.95, commit 39c508d1 (2026-09-30) of github.com/zherczeg/sljit, the commit hxcpp vendors (HaxeFoundation/hxcpp#1434), with none of our patches: upstream sljit covers what they fixed (the arm64 load and store base register of libhxcpp #271, MAP_JIT and write protection on Apple Silicon of #266, 16-byte stack alignment at calls on 32-bit x86, the Windows ARM64 cache flush), and the JIT compares Floats with sljit's NaN-aware comparisons instead of patching its argument checks. On 32-bit x86 this changes the calling convention of the script stubs Haxe generates into a scriptable host: CPPIA_CALL, in hx/Object.h, was fastcall there and is now the C convention, as on every other platform, because sljit no longer calls with fastcall. A 32-bit x86 host must be compiled with these headers throughout: object files or static libraries built with an older libhxcpp or hxcpp and linked with this runtime crash when cppia calls into them, interpreted or jitted. A host rebuilt from source, and .cppia files, are unaffected (libhxcpp #419)
6+
* The cppia JIT no longer runs on ARMv5, which sljit dropped: such a build says once that scripts run in the interpreter (libhxcpp #419)
57
* Builds with the compile cache no longer size the whole cache each time: with 29792 files that took 98 ms to over a second before every build, even one with nothing to compile, and takes 3 to 14 ms now. The cache is trimmed to HXCPP_CACHE_MB at most once in ten minutes (libhxcpp #473)
68
* Fixed an edit to some of the runtime's headers rebuilding nothing, as when a haxelib git or dev checkout updates: hxcpp.h includes headers, hx/Functions.h and cpp/FastIterator.h among them, that the build tool's depend lists did not name, so neither the objects compiled with them nor the compile cache were checked against them, and a stale precompiled header stopped clang builds. Every header hxcpp.h and the runtime include is listed now, and CI checks that it stays so (libhxcpp #469)
79
* Fixed three build tool settings that did nothing or failed: a file with its own cxx_standard in a group with a precompiled header failed to compile (C2855 on MSVC), an <nvcc/> group was given the host compiler's flags because its tag was compared instead of set, and -DNDKV20 and up were ignored, so the newest NDK was used instead; an ANDROID_NDK_ROOT that is already the requested version is used as it is. An NDK without meta/platforms.json no longer stops the build with "Invalid field access : toString" (libhxcpp #472)

‎include/hx/Object.h‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,12 @@ HXCPP_EXTERN_CLASS_ATTRIBUTES null BadCast();
3939

4040
#ifdef HXCPP_SCRIPTABLE
4141

42-
// CPPIA_CALL = fastcall on x86(32), nothing otherwise
43-
#if (defined(_WIN32) && !defined(_M_X64) && !defined(__x86_64__) && !defined(_ARM_) ) || \
44-
defined(HXCPP_X86) || defined(__i386__) || defined(__i386) || \
45-
(!defined(_WIN32) && !defined(_ARM_) && !defined(__arm__) && !defined(__aarch64__) && !defined(__x86_64__) )
46-
47-
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
48-
#define CPPIA_CALL __attribute__ ((fastcall))
49-
#elif defined(_MSC_VER)
50-
#define CPPIA_CALL __fastcall
51-
#endif
52-
#endif
53-
54-
#ifndef CPPIA_CALL
55-
#define CPPIA_CALL
56-
#endif
42+
// The calling convention of the script stubs Haxe generates into host code,
43+
// which the runtime and the cppia JIT call. It is the C one on every platform,
44+
// as sljit's is since 0.95. It was fastcall on 32-bit x86, so there a host
45+
// object compiled with older headers does not match this runtime
46+
// (openfl/libhxcpp#419). Haxe still writes the name, so it stays.
47+
#define CPPIA_CALL
5748

5849

5950
typedef void (CPPIA_CALL *StackExecute)(struct StackContext *ctx);

‎src/hx/cppia/ArrayBuiltin.cpp‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ CppiaExpr *ArrayBuiltinBase::link(CppiaModule &inData)
9393
template<typename ELEM>
9494
inline JitType elem4JitType() { return ExprTypeOf<ELEM>::value==etFloat ? jtFloat32 : jtAny; }
9595

96-
static ArrayBase * SLJIT_CALL array_expand_size(ArrayBase *inArray, int inSize)
96+
static ArrayBase * SLJIT_FUNC array_expand_size(ArrayBase *inArray, int inSize)
9797
{
9898
TRY_NATIVE
9999
inArray->Realloc(inSize+1);
@@ -108,21 +108,21 @@ static ArrayBase * SLJIT_CALL array_expand_size(ArrayBase *inArray, int inSize)
108108
// each is one function here: a copy for every element type and builtin, each
109109
// with its own exception handling, would take more sections than MSVC's
110110
// object file format allows.
111-
static void SLJIT_CALL array_set_size_exact(ArrayBase *inArray, int inSize)
111+
static void SLJIT_FUNC array_set_size_exact(ArrayBase *inArray, int inSize)
112112
{
113113
TRY_NATIVE
114114
inArray->__SetSizeExact(inSize);
115115
CATCH_NATIVE
116116
}
117117

118-
static void SLJIT_CALL array_resize(ArrayBase *inArray, int inSize)
118+
static void SLJIT_FUNC array_resize(ArrayBase *inArray, int inSize)
119119
{
120120
TRY_NATIVE
121121
inArray->resize(inSize);
122122
CATCH_NATIVE
123123
}
124124

125-
static void SLJIT_CALL array_blit(JitMultiArg *inArgs)
125+
static void SLJIT_FUNC array_blit(JitMultiArg *inArgs)
126126
{
127127
// this, inDestElement, inSourceArray, inSourceElement, inElementCount
128128
TRY_NATIVE
@@ -236,7 +236,7 @@ struct ArraySetter : public ArrayBuiltinBase
236236

237237
#ifdef CPPIA_JIT
238238

239-
static void * SLJIT_CALL nativeRunInt(JitMultiArg *args)
239+
static void * SLJIT_FUNC nativeRunInt(JitMultiArg *args)
240240
{
241241
TRY_NATIVE
242242
Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM> *>(JitArg(args,0).obj);
@@ -252,7 +252,7 @@ struct ArraySetter : public ArrayBuiltinBase
252252
return 0;
253253
}
254254

255-
static void * SLJIT_CALL nativeRunFloat(JitMultiArg *args)
255+
static void * SLJIT_FUNC nativeRunFloat(JitMultiArg *args)
256256
{
257257
TRY_NATIVE
258258
Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM> *>(JitArg(args,0).obj);
@@ -268,7 +268,7 @@ struct ArraySetter : public ArrayBuiltinBase
268268
return 0;
269269
}
270270

271-
static void * SLJIT_CALL nativeRunObject(JitMultiArg *args)
271+
static void * SLJIT_FUNC nativeRunObject(JitMultiArg *args)
272272
{
273273
TRY_NATIVE
274274
Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM> *>(JitArg(args,0).obj);
@@ -284,7 +284,7 @@ struct ArraySetter : public ArrayBuiltinBase
284284
return 0;
285285
}
286286

287-
static void * SLJIT_CALL nativeRunString(JitMultiArg *args)
287+
static void * SLJIT_FUNC nativeRunString(JitMultiArg *args)
288288
{
289289
TRY_NATIVE
290290
Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM> *>(JitArg(args,0).obj);
@@ -493,7 +493,7 @@ struct ArraySetter : public ArrayBuiltinBase
493493
};
494494

495495
#ifdef CPPIA_JIT
496-
static hx::Object *SLJIT_CALL objGetIndex(hx::Object *inArray, int inIndex)
496+
static hx::Object *SLJIT_FUNC objGetIndex(hx::Object *inArray, int inIndex)
497497
{
498498
return Dynamic(inArray->__GetItem(inIndex)).mPtr;
499499
}
@@ -1200,28 +1200,28 @@ struct ArrayBuiltin : public ArrayBuiltinBase
12001200
}
12011201

12021202
#ifdef CPPIA_JIT
1203-
static ArrayBase * SLJIT_CALL array_expand(ArrayBase *inArray)
1203+
static ArrayBase * SLJIT_FUNC array_expand(ArrayBase *inArray)
12041204
{
12051205
TRY_NATIVE
12061206
inArray->Realloc( inArray->length + 1 );
12071207
return inArray;
12081208
CATCH_NATIVE
12091209
return 0;
12101210
}
1211-
static void SLJIT_CALL runSort( Array_obj<ELEM> *inArray, hx::Object *inFunc)
1211+
static void SLJIT_FUNC runSort( Array_obj<ELEM> *inArray, hx::Object *inFunc)
12121212
{
12131213
TRY_NATIVE
12141214
inArray->sort( Dynamic(inFunc) );
12151215
CATCH_NATIVE
12161216
}
1217-
static void SLJIT_CALL runJoin( Array_obj<ELEM> *inArray, String *ioValue)
1217+
static void SLJIT_FUNC runJoin( Array_obj<ELEM> *inArray, String *ioValue)
12181218
{
12191219
TRY_NATIVE
12201220
JitStore(ioValue, inArray->join( JitLoad(ioValue) ));
12211221
CATCH_NATIVE
12221222
}
12231223

1224-
static void SLJIT_CALL runElem( Array_obj<ELEM> *inArray, int inIndex)
1224+
static void SLJIT_FUNC runElem( Array_obj<ELEM> *inArray, int inIndex)
12251225
{
12261226
TRY_NATIVE
12271227
ELEM &t = Array<ELEM>(inArray)[inIndex];
@@ -1233,7 +1233,7 @@ struct ArrayBuiltin : public ArrayBuiltinBase
12331233
CATCH_NATIVE
12341234
}
12351235

1236-
static int SLJIT_CALL runIntCrement( Array_obj<ELEM> *inArray, int inIndex)
1236+
static int SLJIT_FUNC runIntCrement( Array_obj<ELEM> *inArray, int inIndex)
12371237
{
12381238
TRY_NATIVE
12391239
ELEM &t = Array<ELEM>(inArray)[inIndex];
@@ -1247,7 +1247,7 @@ struct ArrayBuiltin : public ArrayBuiltinBase
12471247
return 0;
12481248
}
12491249

1250-
static void SLJIT_CALL runFloatCrement( Array_obj<ELEM> *inArray, int inIndex, double *d)
1250+
static void SLJIT_FUNC runFloatCrement( Array_obj<ELEM> *inArray, int inIndex, double *d)
12511251
{
12521252
TRY_NATIVE
12531253
ELEM &t = Array<ELEM>(inArray)[inIndex];
@@ -1259,7 +1259,7 @@ struct ArrayBuiltin : public ArrayBuiltinBase
12591259
CATCH_NATIVE
12601260
}
12611261

1262-
static hx::Object * SLJIT_CALL runObjCrement( Array_obj<ELEM> *inArray, int inIndex)
1262+
static hx::Object * SLJIT_FUNC runObjCrement( Array_obj<ELEM> *inArray, int inIndex)
12631263
{
12641264
TRY_NATIVE
12651265
ELEM &t = Array<ELEM>(inArray)[inIndex];
@@ -1273,63 +1273,63 @@ struct ArrayBuiltin : public ArrayBuiltinBase
12731273
return 0;
12741274
}
12751275

1276-
static int SLJIT_CALL runContains( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase)
1276+
static int SLJIT_FUNC runContains( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase)
12771277
{
12781278
return inArray->contains(inBase);
12791279
}
12801280

1281-
static int SLJIT_CALL runRemove( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase)
1281+
static int SLJIT_FUNC runRemove( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase)
12821282
{
12831283
return inArray->remove(inBase);
12841284
}
12851285

12861286

1287-
static void SLJIT_CALL runUnshift( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase)
1287+
static void SLJIT_FUNC runUnshift( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase)
12881288
{
12891289
inArray->unshift(inBase);
12901290
}
12911291

12921292

1293-
static int SLJIT_CALL runIndex( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase, hx::Object *pos)
1293+
static int SLJIT_FUNC runIndex( Array_obj<ELEM> *inArray, typename ExprBaseTypeOf<ELEM>::Base inBase, hx::Object *pos)
12941294
{
12951295
if (FUNC==afIndexOf)
12961296
return inArray->indexOf(inBase,pos);
12971297
else
12981298
return inArray->lastIndexOf(inBase,pos);
12991299
}
13001300

1301-
static void SLJIT_CALL runInsert( Array_obj<ELEM> *inArray, int pos, typename ExprBaseTypeOf<ELEM>::Base inBase)
1301+
static void SLJIT_FUNC runInsert( Array_obj<ELEM> *inArray, int pos, typename ExprBaseTypeOf<ELEM>::Base inBase)
13021302
{
13031303
inArray->insert(pos, inBase);
13041304
}
13051305

13061306
// TODO - string
1307-
static hx::Object * SLJIT_CALL runShift( Array_obj<ELEM> *inArray )
1307+
static hx::Object * SLJIT_FUNC runShift( Array_obj<ELEM> *inArray )
13081308
{
13091309
return Dynamic(inArray->shift()).mPtr;
13101310
}
13111311

1312-
static hx::Object * SLJIT_CALL runSlice( Array_obj<ELEM> *inArray, int pos, hx::Object *end )
1312+
static hx::Object * SLJIT_FUNC runSlice( Array_obj<ELEM> *inArray, int pos, hx::Object *end )
13131313
{
13141314
return inArray->slice(pos, end).mPtr;
13151315
}
13161316

1317-
static hx::Object * SLJIT_CALL runSplice( Array_obj<ELEM> *inArray, int pos, int len )
1317+
static hx::Object * SLJIT_FUNC runSplice( Array_obj<ELEM> *inArray, int pos, int len )
13181318
{
13191319
return inArray->splice(pos, len).mPtr;
13201320
}
13211321

1322-
static void SLJIT_CALL runRemoveRange( Array_obj<ELEM> *inArray, int pos, int len )
1322+
static void SLJIT_FUNC runRemoveRange( Array_obj<ELEM> *inArray, int pos, int len )
13231323
{
13241324
inArray->removeRange(pos, len);
13251325
}
13261326

1327-
static void SLJIT_CALL runReverse( Array_obj<ELEM> *inArray )
1327+
static void SLJIT_FUNC runReverse( Array_obj<ELEM> *inArray )
13281328
{
13291329
inArray->reverse();
13301330
}
13311331

1332-
static hx::Object *SLJIT_CALL runConcat( Array_obj<ELEM> *inArray, Array_obj<ELEM> *inOther )
1332+
static hx::Object *SLJIT_FUNC runConcat( Array_obj<ELEM> *inArray, Array_obj<ELEM> *inOther )
13331333
{
13341334
// A null array to append throws: the exception becomes the script's
13351335
// pending one, which the code after the call checks
@@ -1340,31 +1340,31 @@ struct ArrayBuiltin : public ArrayBuiltinBase
13401340
}
13411341

13421342

1343-
static hx::Object *SLJIT_CALL runGetIteratator( Array_obj<ELEM> *inArray )
1343+
static hx::Object *SLJIT_FUNC runGetIteratator( Array_obj<ELEM> *inArray )
13441344
{
13451345
return inArray->iterator().mPtr;
13461346
}
13471347

1348-
static hx::Object *SLJIT_CALL runGetKeyValueIteratator( Array_obj<ELEM> *inArray )
1348+
static hx::Object *SLJIT_FUNC runGetKeyValueIteratator( Array_obj<ELEM> *inArray )
13491349
{
13501350
return inArray->keyValueIterator().mPtr;
13511351
}
13521352

13531353

1354-
static void SLJIT_CALL runToString( Array_obj<ELEM> *inArray, String *outString )
1354+
static void SLJIT_FUNC runToString( Array_obj<ELEM> *inArray, String *outString )
13551355
{
13561356
TRY_NATIVE
13571357
JitStore(outString, inArray->toString());
13581358
CATCH_NATIVE
13591359
}
13601360

1361-
static hx::Object * SLJIT_CALL runCopy( Array_obj<ELEM> *inArray)
1361+
static hx::Object * SLJIT_FUNC runCopy( Array_obj<ELEM> *inArray)
13621362
{
13631363
return inArray->copy().mPtr;
13641364
}
13651365

13661366

1367-
static hx::Object * SLJIT_CALL runProcess( Array_obj<ELEM> *inArray, hx::Object *inFunction)
1367+
static hx::Object * SLJIT_FUNC runProcess( Array_obj<ELEM> *inArray, hx::Object *inFunction)
13681368
{
13691369
TRY_NATIVE
13701370
if (FUNC==afMap)

0 commit comments

Comments
 (0)