Commit b621f2b
Coroutines (#12479)
* clean up a bit
* let's see if we can run HL
* expand coroutine function types for proper forward declarations
* add @:coroutine.transformed (#39)
* add delay test
closes #34
* get neko working
* make test output file consistent
* apparently python just works
* Run tests on php and lua (#43)
* try php
* and lua
* remove invalid extra type parameter
* Make coros exception-free (#40)
* make coros exception-free
* avoid double looping if there's no catch
* add more exception tests
* add test for nested try-catch
* try to get exce[topm value management right
* port remaining YieldTryCatch cases
* make nested test even crazier
* change throw to break to avoid inner exceptions
* fix indentation
* also test throw from child coro
* ignore some tests on lua because there's a codegen issue
* lua isn't ready for this
* try again
* Move recursion tests back to flow control suite
* Fix missing import
---------
Co-authored-by: Aidan Lee <[email protected]>
* Add type parameters to BaseContinuation and ContinuationResult (#45)
* make coros exception-free
* avoid double looping if there's no catch
* add more exception tests
* add test for nested try-catch
* try to get exce[topm value management right
* port remaining YieldTryCatch cases
* make nested test even crazier
* change throw to break to avoid inner exceptions
* fix indentation
* also test throw from child coro
* ignore some tests on lua because there's a codegen issue
* lua isn't ready for this
* try again
* it works I guess
* also add to BlockingContinuation to lose the casts
* run JVM tests through hxb roundtrip
* be more accurate
* deal with LocalFunc type paramters too
* use more precise type on suspend
* T for all
* Copy js' custom event loop, but add mutexes
* cache continuation_api on typer globals
* remove some API types that we don't need
* pass texprs as record type
The reason I prefer this is because it prevents us from accidentally messing up the order.
* clean up some outdated comments
* remove some unused internal data
* Optimize CFG a bit (#48)
* optimize
* another flag
* add missing catch handling, enable reindexing
* remove inner recursion from texpr transformer
* move functions to where they should be
* implement TCO (#49)
* add _hx_tmp local to deal with intermediate values (#53)
* don't forward blocks if their cb_catch differs
* rework error resume, again
closes #54
* actually we don't need the cb_catch check now, I think
* Add -D coroutine.throw for eager throws (#52)
* implement TCO
* add -D coroutine.throw for eager throws
* adjust
* Keep waiting if we haven't got a result but the loop reports no more events.
* set next state later
closes #55
* use Unit instead of Void
closes #56
* change how we run JVM tests on CI
* try a new way of expression building
* move local handling to own function
this should probably actually move to coro.ml because the only thing it needs from here are the states
* rename some things
* update resume-flag when forwarding blocks
closes #59
* Remove unreachable block (#60)
* remove cb_unreachable, use options instead
* add -D coroutine.noopt
* test all combinations
* nobody saw that
* pull structural changes from call-stacks branch
* pull null_pos changes from call-stacks branch
* always use the mangled name with the variable id
* no more _hx_ prefixes for core classes / interfaces
* Call stacks (#50)
* Update stack item just before suspension
* class field and local func stack items
* wrap thrown exceptions in a CoroutineException
* bung the exception stack in the result field
* remove commented out code
* move buildCallStack to end of function
* add takeExceptionCallStack
* unbreak CI
* fix some types
* don't let null_pos mess up JVM codegen positions
* change while to if
* ignore for now
broken by the CoroutineException wrapping
* get it working on JVM
* how could I forget about Flash
* coroStack can be null
* make it work on eval
* apparently that can raise
* move top stack handling to BlockingContinuation
this way it works for immediate exceptions too
* remove _hx_stackItem, work with _hx_result directly
* remove CoroutineException, modify error.stack directly
* move texpr builder to context
* embrace the builder
* even more builder
* update __exceptionStack when setting the stack
this should allow reentrancy with regards to exceptions
* add something resembling a test
* overdesign test case
* disable hxb roundtrip for now because that must be an unrelated haxe problem
* this won't work in throw-mode
* make call stack tests print more info on failures
* add __customStack assignment to HL
* remove null_pos from our lives
* cpp setting custom stack
* Add forgotten actual stack setting
* hack around top stack problem a bit to test cpp and eval
* Revert "disable hxb roundtrip for now because that must be an unrelated haxe problem"
This reverts commit d78590d.
---------
Co-authored-by: Simon Krajewski <[email protected]>
* interfaces seemingly working
* Add test
* number issue properly
* Add an assert.pass
we just want to know if this even compiles
* Fix coroutine overload resolution in jvm
* Expand coroutine arguments for php
* [std/hl] move some position for customStack and set_stack (#12217)
* send all types to analyzer for purity inference
see #12224
* Test for #12224 (#12227)
* Test for #11909 (#12218)
* [nullsafety] Allow statics init in main (#12211)
* [nullsafety] Allow statics init in main
* usage before init check
* Update TestStrict.hx (#12228)
* 4.3.7 changelog
* get call stack test passing on HL
* fix test
* rename state to gotoLabel and control to state (#73)
* never mind
* haxe/coro: add Mutex typedef for threaded targets, and stub for non (#72)
* haxe/coro: add Mutex typedef for threaded targets, and stub for non threaded targets
* haxe/coro: add body to Mutex stub constructor
* tests: add TestMutex
* more publicity
* fix package
* try to make doc gen happy
---------
Co-authored-by: Simon Krajewski <[email protected]>
* don't try to optimize resume states
closes #75
* avoid null issue
see #75
* also avoid JVM issue
* use ctx.type_params for type params
closes #77
* Extensible context (#78)
* get started on extensible contexts (again)
* introduce Element after all
* more API
* use BalancedTree instead of Array
* assign value blocks to temp var
closes #79
* change Element to IElement (#80)
* be more diligent with positions
* fix more optimization problems
* [WIP] Stack traces continued (#82)
* improve stack traces again
* rework it again
* Try a new stack trace approach (#84)
* good start potentially
* more hacks required
* remove wonky sync stack handling
* don't try to manage stack traces on JS because we can't
* avoid cpp test problem
* Make Context immutable (#87)
* make context immutable
* actually make it immutable
* remove -D coroutine.throw (#89)
* disable optimizations for now
too many distractions, will revisit this later
* deal with branching expressions in value places
closes #90
* assign suspension calls in value places to local
closes #93
* Revert "assign suspension calls in value places to local"
This reverts commit cc67f42.
* awkwardly deal with stack suspend problem
* Don't use the typers current module for manged class names
* per class anon function counter
* fix transformer bug and add more tests
* change context data structure to linked list (#100)
* Structured Concurrency with Task/Scope (#97)
* try yet another approach
* factor out startChildren
* Explicit type hint to make cpp generator happy
* adjust hierarchy once more
* bring back scope.with
I didn't notice the test was missing
* change entry point handling to support Coroutine.with
* add more tests and align with structured branch some more
* rework cancellation
* add wasResumed instead
* remove join, move loop handling back to entrypoint
* remove completion callbacks, instead store continuations directly
* adjust to feedback
* Add catch segv define to see if we get a stack trace in the future
* organize and document a bit
* refactor some more
* move scope addChild to its constructor
* support Coroutine.with().create
That's a neat looking API!
* scheduler experiments ported to new structured branch
* fix wasResume handling
* don't get distracted by optimization test insanity
* start children when beginning completion
This is much faster, but we should go back to counting completed children to make it faster still.
* fix wasResume handling
* work on event loop linked list from both ends
* go back to counting children to determine completion
* child scope test class uses virtual time scheduler
* optimize ms == 0 cases
* Other tests involving delay go through the virtual time scheduler
* make CI green because I want to see if PHP still explodes
* Try a double buffer for zero events
* switch schedule arguments around
* Make virtual time scheduler work how you'd expect it to work
* rename Scope to Node
* Move functions out of haxe.coro.Coroutine (#102)
* move coro API to hxcoro.Coro
* missed one
* move coro runner API to hxcoro.CoroRun
* missed another one
* change context to property
closes #101
* remove double allocation from suspend
closes #103
---------
Co-authored-by: Aidan Lee <[email protected]>
Co-authored-by: Aidan Lee <[email protected]>
* unset children when they completed
closes #105
* add some micro benchmarks
* Add some virtual time scheduler tests
* scheduler functions can be cancelled
* fix complex wrapper expressions
* Callback on abstract task for cancellation
* handle for stopping cancellation callback
* Cancellation token approach
* add Context.add
* walk event loop from both ends
* Cancellation token key
* static no-op cancellation handle
* lazy initialise cancellation callback and children array
* lets get fancy after all
* Add hxcoro.ds.Channel (#107)
* add hxcoro.ds.Channel
* maybe that's too much for some targets
* remove mutex
* fix wonky logic
* fix wonky logic differently and test with random delays
* change underlying data structure to paged deque
* move PagedDeque to its own file
* clean up a little and document random things
* document new interfaces
* timeout implementation
* Add some tests
* separate (#117)
* generate continuation stack traces only in debug mode
* avoid more array allocations
* Extra test
* Document timeout
* Bring back the event loop mutexes
* implement awaitChildren (#123)
* release future lock before calling the function
* don't hold onto zeroMutex while we're running
* also remove double loop because run itself is run in a loop
* Don't reschedule BaseContinuation.resume (#118)
* don't reschedule BaseContinuation.resume
* go back to scheduling somewhat
* disable linux lua because this is annoying
* even less lua
* go away...
* move task stuff to hxcoro.task
* add some API to PagedDeque
* add produce sample as a test because it happens to work right now
see #124
* Don't have RacingContinuation hold onto its mutex for so long (#127)
* don't have RacingContinuation hold onto its mutex for so long
also avoid some unnecessary scheduling
* go for yet another approach
* inline by hand because HL hates me
* avoid capturing `this`
* Add CoroMutex (#112)
* start over without task ID
* move to hxcoro.concurrent
* change API to match haxe.atomic.AtomicInt
* move to own file
* use native implementations where possible
* fixes and tests
* make task context lazy and avoid some retention
* add CoroTask.putOnHold and call it from CoroSemaphore
* make some more context retention adjustments
* enable optimizations again to see if we have broken anything in the meantime
* ignoring failing eval call stack test
* fix some potential null problems
* Cancelling suspend (#129)
* first pass at cancelling suspend
* tests
* Close handle on resuming
Otherwise callback could be invoked later on
* bounce continuation call through the scheduler
* Work with ICancellationHandle instead of its closure (#131)
* work with ICancellationHandle directly instead of closures
* rename to ICancellationCallback.onCancellation
* adjust to changes awkwardly
* add mutex cancellation test
* is it really that easy?
* add more elaborate semaphore cancelling test
* Immediate invoke callback if already cancelled
* Disallow multiple assignment of the callback
* flip the words
* change to cancellable
* I think this atomic state makes sense
* Interface name change for consistency
* document
* let's play sure it's not about this...
* less handle terminology
---------
Co-authored-by: Simon Krajewski <[email protected]>
* Prompt channels (#126)
* prompt write cancellation
* Use AssertAsync class I added a while back
* FIFO suspended writes
* prompt read cancellation
* actually assert the promptness of cancellations
also expected is actually actual
* go back to PagedDeque
* remove unintended double resume
curious that this doesn't cause anything to fail
* adapt
* Failing junction test (#128)
* add funny test that fails on some targets
* adapt
* fix order of operations
* change producer example to infinite loops
* use static extensions and port prime example
* change to bufferSize
---------
Co-authored-by: Simon Krajewski <[email protected]>
* finally add an id to tasks
* optimize common CancellationHandle.close case
* make Key interface nicer
* don't use @:native
* add hxcoro.components.CoroName
closes #67
* get the old generator tests working
see #5
* add Coro.supervisor
* add C type parameter to tasks (#135)
* move parent back to AbstractTask
* Add INodeStrategy (#136)
* add INodeStrategy, favor composition over inheritance
* use concrete parameters after all
* Revert "use concrete parameters after all"
This reverts commit 2e7ff68.
* revert type param changes
* split up CoroTask
* Add hxcoro.util.Convenience (#134)
* add hxcoro.Convenience
* adapt
* adapt more
* refine some toString
* fix double suspension_result wrapping
see #139
* fix some field hosts
see #139
* Schedulers use Int64 ms everywhere
* Change float literal
* Int64 literal to make some targets happy
* i64 literal here as well, for paranoia's sake
* Private access Int64.toString to make some targets happy
* spell things out for HL
* spell it out for every other target too
* Add ILocalContext (#137)
* add ILocalContext
* use for awaitingChildContinuation
* add initialState to AbstractTask constructor and `start` automatically if Running
closes #124
* [mad science] Get rid of explicit .key expressions (#141)
* add Key.fromClass to get rid of explicit .key expressions
* we actually don't care about the class itself at all
* add Channel benchmark
* remove expression mapping that doesn't seem to be needed anymore
* bring back some mapping that was needed after all
* re-enabled virtual time scheduler tests
* Implement yield as delay 0
* don't ignore RLocal when mapping complex expressions
closes #146
* Remove private access int64 workaround
* Clean up _hx_tmp handling (#145)
* split up hx_tmp for result/error
* try to get error wrapping under control
* add surprisingly simple tests
* clean up result handling a little
* make most Context functions inline
* add missing return
* Add IScheduleObject (#143)
* add IScheduleObject
* use for continuations
* use for async
* also use for CancellationContinuation
* implement suspendCancellable directly
closes #138
* avoid some double-scheduling
* use AtomicInt instead of simon-mutexes for RacingContinuation too
* factor out delayImpl so both delay and yield can call it
This avoids the double suspension call from yield to delay, which I noticed in the yield benchmarks.
* go back to Array context because that's simply faster
* reduce BaseContinuation data a little more
* eval has atomics now
* Change isCancellationRequested to cancellationException (#147)
* change isCancellationRequested to cancellationException
* bring back isCancellationRequested as a convenience method
* Make internal coroutine initialization lazy (#151)
* start moving some types to continuation api
* more
* more
* don't load exception twice
* be lazier
* be even lazier
* fix
* ignore that
* Add PagedDeque.remove (#154)
* support element deletion in Page
* get cpp green even though this seems weird
* add some more tests
* fix isEmpty but find more problems
* fix isEmpty resetting
* don't blit with length 0
* use ArraySort for stability
* change API to something that might actually be sound
* test middle page deletion
* move tests to TestPagedDeque
* Follow away abstracts before getting the default value
* Add test
* Add an assert
* treat {} as the special case that it is
* haxelib
* [tests] fix server tests (#164)
* [tests] fix server tests builder
* WIP fix server tests with coro
* [CI] enable server tests..
* Use promise wrapper instead of blocking run
* point to my updated utest coro branch
* Fix server display tests
---------
Co-authored-by: Aidan Lee <[email protected]>
* support static extensions
closes #167
* Add default value int64 test
* Fix scheduled events not being ordered by time
* Manual Int64 equality check
* Spilling (#152)
* Some initial work on variable spilling
* skip restoring with the first state
* bodge saving and restoring
* make arguments appear in the first state usage table
* Don't restore variables in their defined state
* Add loop iteration hoisting test
* another attempt
* sort out arguments
they're always a pain
* round and round we go...
Back to per state vars, was hoping the "tmp used without being initialised" would magically solve itself, but no. Might be related to TVar exprs
* give some vars default type expressions
* bodge it
* disable hanging test so we can look at actual failures
* hack it even more
* Add some comments so I don't forget what this all is again
* attempt at avoiding double wrapping
seems to work on some targets...
* mark them as captured as well
* don't duplicate half of capturedVars
* Fix dodgy merge
* Need to follow abstracts away before getting default values
Not sure why I need to do this now
---------
Co-authored-by: Simon Krajewski <[email protected]>
* Spilling Reads and Writes (#170)
* track local read and writes for states
* Use Texpr.skip
* Channel API (#150)
* add tryRead
* progress so far
* work around variance problem
* apply variance to bounded reader as well
* Add reader wakeup tests
* add write tests
* adjust
* generic createUnbounded
* load of bounded reader tests
* Remove test which I think we don't need
* channel kind enum
* add reader tests to main
* work around weird paged dequeue issue
* channel tests updated and passing
* bring back all tests
* Add basic creation tests
* add writer closing tests
* remove some unused imports
* reader cancellation
* async success, but immediate scheduler in tests
* Fix missing var
* Move existing tests into the bounded test class
* Writer sets out closed object
* Add another tests which includes the wait for read and channel closing
* use PagedDeque.remove
* go back to the dequeue tryPop loop
* add concurrent circular buffer
* configurable write behaviour when buffer is full
* experiments with single reader and writer combo
* drop callbacks
* Quickly thrown together and untested ubbounded channel
* prompt cancellation waitForWrite
* throw channel closed when writing to a closed channel
* Add unbounded writer tests
* work around weird issue
* disable single producer consumer implementation
will revisit at a later time
* Work around weird python issue by breaking these out into variables
* unbounded reader tests
* Add tryPeek to channel reader
* Have bounded channel use a circular buffer instead of an array
---------
Co-authored-by: Aidan Lee <[email protected]>
* Add thread pool scheduler (#159)
* Add thread pool scheduler
* Use event loop now
* Make negative time exception message consistent
* try sys wrap
* fix thread dodge
---------
Co-authored-by: Simon Krajewski <[email protected]>
* [std] move hxcoro package to hxcoro
And add basic 3rd party tests (eval only for now)
* [tests] remove tests moved to hxcoro
* Move continuations to be the leading argument
* Use the hxcoro branch
* remove ThreadPoolScheduler
* avoid default_value problem for now
* bring back double-ended list walking in scheduler
see HaxeFoundation/hxcoro#18
* Remove scheduler implementations
They have moved to hxcoro
* document things
* remove leading-completion references
* reset some things
* update Coro benchmark
* use real utest
* remove unused file
* fix bad control flow handling with empty blocks
* Don't try and wedge variable saving in between the last expr
Properly track the trailing return expr and inject before that one
* deal with mono default value
---------
Co-authored-by: Aidan Lee <[email protected]>
Co-authored-by: Aidan Lee <[email protected]>
Co-authored-by: Yuxiao Mao <[email protected]>
Co-authored-by: RblSb <[email protected]>
Co-authored-by: Rudy Ges <[email protected]>
Co-authored-by: Joey <[email protected]>
Co-authored-by: Rudy Ges <[email protected]>1 parent be20311 commit b621f2b
File tree
73 files changed
+3587
-391
lines changed- src-json
- src
- codegen
- context
- core
- coro
- filters
- safe
- generators
- cpp/gen
- optimization
- typing
- std
- haxe
- coro
- cancellation
- context
- schedulers
- exceptions
- tests
- benchs
- src/cases
- misc/projects/Issue10871/Context
- optimization/src/issues
- runci/targets
- server
- src
- cases
- issues
- utils/macro
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
73 files changed
+3587
-391
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
145 | 157 | | |
146 | 158 | | |
147 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
89 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
| 798 | + | |
798 | 799 | | |
799 | 800 | | |
800 | 801 | | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
801 | 808 | | |
802 | 809 | | |
803 | 810 | | |
| |||
929 | 936 | | |
930 | 937 | | |
931 | 938 | | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
932 | 946 | | |
933 | 947 | | |
934 | 948 | | |
| |||
1140 | 1154 | | |
1141 | 1155 | | |
1142 | 1156 | | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1143 | 1163 | | |
1144 | 1164 | | |
1145 | 1165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
| |||
288 | 290 | | |
289 | 291 | | |
290 | 292 | | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
291 | 296 | | |
292 | | - | |
| 297 | + | |
293 | 298 | | |
294 | 299 | | |
295 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
652 | 667 | | |
653 | 668 | | |
654 | 669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
485 | 491 | | |
486 | 492 | | |
487 | 493 | | |
| |||
491 | 497 | | |
492 | 498 | | |
493 | 499 | | |
494 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
495 | 504 | | |
496 | 505 | | |
497 | 506 | | |
| |||
549 | 558 | | |
550 | 559 | | |
551 | 560 | | |
| 561 | + | |
552 | 562 | | |
553 | 563 | | |
554 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
642 | 660 | | |
643 | 661 | | |
644 | 662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments