Skip to content

Commit 6862d3e

Browse files
Merge main into feature/cppia-perf-b621b5
main adds the host_statics cppia workload, which joins the shared workload table here, so the cppia and HashLink harnesses both run it. This branch's Changes.md lines move under libhxcpp 6.1.0, and main has the unused cppia cast fix (#501) under 6.0.3.
2 parents b7e7e20 + 384fc87 commit 6862d3e

49 files changed

Lines changed: 792 additions & 52 deletions

File tree

Some content is hidden

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

‎.github/workflows/main.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ jobs:
4949
- name: Check the build tool's depend lists
5050
run: python3 tools/check-depends.py
5151

52+
- uses: krdlab/setup-haxe@v2
53+
with:
54+
haxe-version: 4.3.7
55+
56+
# The jobs build the build tool for neko only, so a change that broke the
57+
# C++ build tool, which run.n prefers once someone has built it, went
58+
# unseen (libhxcpp #471)
59+
- name: Type-check the C++ build tool
60+
run: haxe -cp tools/hxcpp -main BuildTool -D HXCPP_NEKO_BUILDTOOL=1 -cpp out --no-output
61+
5262
check-gc-defines:
5363
name: Check GC defines
5464
runs-on: ubuntu-latest

‎BENCHMARKS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ driver also checks that the interpreter and JIT return the same checksum.
139139
| `bunny_update` | The update loop of OpenFL's BunnyMark over 2,000 script objects that extend a host class, moved through its Float properties, in a listener the host calls once a frame |
140140
| `openfl_frame` | An OpenFL application's frame: 1,000 script objects extending a host display object, moved by an ENTER_FRAME listener the host calls, one in ten with a closure listener of its own, a small object made each update, dead ones replaced, and a host render reading every transform |
141141
| `call_by_name` | Script calls of an abstract's methods over a host type, which the host gives no binding for, as openfl.Vector's are: length, element reads and writes |
142+
| `host_sort` | `Array.sort`, which is host code, sorting a copy of 1,000 script Ints with a comparator the script gives it, ten times a run |
143+
| `host_statics` | Script reads and writes of a host class's static object fields |
142144

143145
The native timing harness loads one script module per process. Loading, linking,
144146
booting and JIT compilation happen in `setup()`, outside the timed samples.

‎Changes.md‎

Lines changed: 19 additions & 5 deletions
Large diffs are not rendered by default.

‎bench/cppia/Script.hx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Script {
1515
case "openfl_frame": new OpenflFrame();
1616
case "call_by_name": new CallByName();
1717
case "host_sort": new HostSort();
18+
case "host_statics": new HostStatics();
1819
default: throw 'Unknown CPPIA workload ${CppiaBridge.name}';
1920
};
2021
}
@@ -361,3 +362,18 @@ class HostSort implements CppiaWorkload {
361362
return sum;
362363
}
363364
}
365+
366+
class HostStatics implements CppiaWorkload {
367+
public function new() {}
368+
369+
public function run():Int {
370+
var sum = 0;
371+
for (i in 0...200000) {
372+
// A read and a write of host static objects each pass
373+
var values = CppiaBridge.values;
374+
sum += values[i & 15];
375+
CppiaBridge.last = values;
376+
}
377+
return sum;
378+
}
379+
}

‎bench/cppia/shared/CppiaBridge.hx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class CppiaBridge {
1111
// Builds HostVector's implementation class into the host
1212
public static function vector(count:Int):HostVector
1313
return new HostVector(count);
14+
/** Read and written by the host_statics workload. **/
15+
public static var values:Array<Int> = [for (i in 0...16) i];
16+
public static var last:Array<Int>;
1417

1518
@:noInline
1619
public static function step(value:Int):Int {

‎bench/cppia/shared/CppiaWorkloads.hx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ class CppiaWorkloads {
1919
{name: "openfl_frame", unit: "object frames", ops: 10000, reps: 5},
2020
{name: "call_by_name", unit: "calls", ops: 400000, reps: 5},
2121
{name: "host_sort", unit: "sorted elements", ops: 10000, reps: 5},
22+
{name: "host_statics", unit: "iterations", ops: 200000, reps: 10},
2223
];
2324
}

‎haxelib.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "BSD",
55
"tags": ["haxe", "hxcpp", "cpp", "libhxcpp"],
66
"description": "libhxcpp is the runtime for the C++ target of the Haxe compiler, continuing hxcpp. Run 'haxelib run libhxcpp setup' once so the compiler and libraries that ask for hxcpp use it.",
7-
"version": "6.0.3",
7+
"version": "6.1.0",
88
"releasenote": "See Changes.md",
99
"contributors": ["Dimensionscape", "singmajesty", "bowlerhat"],
1010
"binaryversion": 48,

‎include/cpp/Int64.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class Int64Handler
3232
}
3333
else if (op==dhoIs)
3434
{
35+
// Every Int64 boxes as one, small values included, so a boxed Int
36+
// is not one, as on the other targets
3537
StructHandlerDynamicParams *params = (StructHandlerDynamicParams *)outResult;
36-
hx::Object *obj = params->inData;
37-
int type = obj->__GetType();
38-
params->outProcessed = type==vtInt || type==vtInt64;
38+
params->outProcessed = params->inData->__GetType()==vtInt64;
3939
}
4040
else
4141
return DefaultStructHandler::handler(op,ioValue,inSize, outResult);

‎include/cpp/Pointer.h‎

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -574,21 +574,33 @@ T *StarOf(T &x) { return &x; }
574574
}
575575

576576

577-
// Haxe 4's haxe.atomic.AtomicInt is a cpp.Pointer<Int>, and its methods call
578-
// these. A thread spinning on one never otherwise reached a safe point, so a
579-
// collection on another thread waited for it for ever, as Haxe 5's
580-
// hx::atomic::AtomicInt does not (libhxcpp #455). The runtime's own spinlocks
581-
// call the volatile int * forms, which do not stop.
577+
// The forms of these that stop for a pending collection, for an int * and a
578+
// cpp::Pointer<int>. Haxe 4's haxe.atomic.AtomicInt is a cpp.Pointer<Int>, and
579+
// Haxe 5.0.0-preview.1's keeps an Int field and passes its address, a plain
580+
// int *. A thread spinning on either never otherwise reached a safe point, so
581+
// a collection on another thread waited for it for ever (libhxcpp #455).
582+
// Later Haxe 5's hx::atomic::AtomicInt stops by itself. The runtime's own
583+
// spinlocks call the volatile int * forms in hx/StdLibs.h, which do not stop.
582584
#define HX_ATOMIC_SAFE_POINT if (::hx::gPauseForCollect) __hxcpp_gc_safe_point();
583-
inline int _hx_atomic_add(::cpp::Pointer<int> a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_add((volatile int *)a.ptr, b); }
584-
inline int _hx_atomic_sub(::cpp::Pointer<int> a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_sub((volatile int *)a.ptr, b); }
585-
inline int _hx_atomic_and(::cpp::Pointer<int> a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_and((volatile int *)a.ptr, b); }
586-
inline int _hx_atomic_or(::cpp::Pointer<int> a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_or((volatile int *)a.ptr, b); }
587-
inline int _hx_atomic_xor(::cpp::Pointer<int> a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_xor((int *)a.ptr, b); }
588-
inline int _hx_atomic_compare_exchange(::cpp::Pointer<int> a, int expected, int replacement) { HX_ATOMIC_SAFE_POINT return _hx_atomic_compare_exchange((volatile int *)a.ptr, expected, replacement); }
589-
inline int _hx_atomic_exchange(::cpp::Pointer<int> a, int replacement) { HX_ATOMIC_SAFE_POINT return _hx_atomic_exchange((volatile int *)a.ptr, replacement); }
590-
inline int _hx_atomic_load(::cpp::Pointer<int> a) { HX_ATOMIC_SAFE_POINT return _hx_atomic_load((volatile int *)a.ptr); }
591-
inline int _hx_atomic_store(::cpp::Pointer<int> a, int value) { HX_ATOMIC_SAFE_POINT return _hx_atomic_store((volatile int *)a.ptr, value); }
585+
inline int _hx_atomic_add(int *a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_add((volatile int *)a, b); }
586+
inline int _hx_atomic_sub(int *a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_sub((volatile int *)a, b); }
587+
inline int _hx_atomic_and(int *a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_and((volatile int *)a, b); }
588+
inline int _hx_atomic_or(int *a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_or((volatile int *)a, b); }
589+
inline int _hx_atomic_xor(int *a, int b) { HX_ATOMIC_SAFE_POINT return _hx_atomic_xor((volatile int *)a, b); }
590+
inline int _hx_atomic_compare_exchange(int *a, int expected, int replacement) { HX_ATOMIC_SAFE_POINT return _hx_atomic_compare_exchange((volatile int *)a, expected, replacement); }
591+
inline int _hx_atomic_exchange(int *a, int replacement) { HX_ATOMIC_SAFE_POINT return _hx_atomic_exchange((volatile int *)a, replacement); }
592+
inline int _hx_atomic_load(int *a) { HX_ATOMIC_SAFE_POINT return _hx_atomic_load((volatile int *)a); }
593+
inline int _hx_atomic_store(int *a, int value) { HX_ATOMIC_SAFE_POINT return _hx_atomic_store((volatile int *)a, value); }
592594
#undef HX_ATOMIC_SAFE_POINT
593595

596+
inline int _hx_atomic_add(::cpp::Pointer<int> a, int b) { return _hx_atomic_add(a.ptr, b); }
597+
inline int _hx_atomic_sub(::cpp::Pointer<int> a, int b) { return _hx_atomic_sub(a.ptr, b); }
598+
inline int _hx_atomic_and(::cpp::Pointer<int> a, int b) { return _hx_atomic_and(a.ptr, b); }
599+
inline int _hx_atomic_or(::cpp::Pointer<int> a, int b) { return _hx_atomic_or(a.ptr, b); }
600+
inline int _hx_atomic_xor(::cpp::Pointer<int> a, int b) { return _hx_atomic_xor(a.ptr, b); }
601+
inline int _hx_atomic_compare_exchange(::cpp::Pointer<int> a, int expected, int replacement) { return _hx_atomic_compare_exchange(a.ptr, expected, replacement); }
602+
inline int _hx_atomic_exchange(::cpp::Pointer<int> a, int replacement) { return _hx_atomic_exchange(a.ptr, replacement); }
603+
inline int _hx_atomic_load(::cpp::Pointer<int> a) { return _hx_atomic_load(a.ptr); }
604+
inline int _hx_atomic_store(::cpp::Pointer<int> a, int value) { return _hx_atomic_store(a.ptr, value); }
605+
594606
#endif

‎include/hx/Macros.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static ::Dynamic Create##enum_obj(::String inName,::hx::DynamicArray inArgs) \
8181
static ::hx::ObjectPtr< ::hx::Class_obj> __mClass; \
8282
::hx::ObjectPtr< ::hx::Class_obj > __GetClass() const HXCPP_OVERRIDE { return __mClass; } \
8383
static ::hx::ObjectPtr< ::hx::Class_obj> &__SGetClass() { return __mClass; } \
84-
static inline bool _hx_isEnumValueOf(::hx::Object *inPtr) { return __mClass.mPtr && inPtr->__GetClass().mPtr == __mClass.mPtr; }
84+
static inline bool _hx_isEnumValueOf(::hx::Object *inPtr) { return __mClass.mPtr ? inPtr->__GetClass().mPtr == __mClass.mPtr : inPtr->_hx_isInstanceOf(::hx::clsIdEnum); }
8585

8686

8787
#define HX_DECLARE_IMPLEMENT_DYNAMIC ::Dynamic __mDynamicFields; \

0 commit comments

Comments
 (0)