Commit 10c1cce
Refactor and optimize register allocator and live set computations (#1288)
* Refactor and optimize register allocator internals
Renamed KillSite to KillSites for clarity, replaced linear search with binary search in FindKillAllSite for better performance, and updated GetVirtualRegisters to skip physical registers. Improved GetRegisterMoves by indexing intervals by start slot and replaced break with continue for more accurate control flow. These changes enhance efficiency and maintainability of the register allocator.
* Refactor live set computation to reduce allocations
Refactored ComputeGlobalLiveSets to reuse BitArray instances for liveOut and liveIn, resetting and updating them in place instead of allocating new arrays per block. Improved change detection logic to update only when necessary, reducing memory usage and improving efficiency.
* Optimize LiveRange lookups with binary search helpers
Refactored use/def position lookups in LiveRange to use binary search methods, improving performance for large lists. Added GetPreviousUse and GetPreviousDef methods. Helper methods are implemented as private static functions.
* Optimize IntervalTree/DelayedIntervalTree & add tests
Refactored DelayedIntervalTree to delay add/remove operations and short-circuit queries, reducing tree manipulations. Added extensive unit tests for edge cases and pending operation logic. IntervalTree now uses loops instead of recursion for search/insertion and MaxEnd updates, improving performance and stack usage. Added overloads for search methods to reduce allocations and new TrySearchFirstOverlapping methods. Improved documentation and ensured no unsafe or auto-generated code was modified.
* Update Source/Mosa.Compiler.Framework/RegisterAllocator/RedBlackTree/DelayedIntervalTree.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Update Source/Mosa.Compiler.Framework/RegisterAllocator/RedBlackTree/DelayedIntervalTree.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Centralize platform registration; add Platforms project
Replaces reflection-based platform registration with explicit, centralized registration via PlatformRegistrations.Register(). Adds new Mosa.Compiler.Platforms project and updates all relevant .csproj and solution files to reference it. Updates PlatformRegistry to remove assembly scanning. Includes minor code cleanups and adds x64 build configs to Mosa.Linux.sln.
* Fix interval overlap logic and remove unused CPU core calc
- Remove unused equivalent CPU core calculation in ReportQueueStatus.
- Use Overlaps method for correct interval overlap detection in DelayedIntervalTree.Add.
- Fix off-by-one errors in IntervalTree by changing MaxEnd > to MaxEnd >= in search logic.
* Update Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Update Source/Mosa.Tool.Launcher.Console/Mosa.Tool.Launcher.Console.csproj
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Update Source/Mosa.Utility.UnitTests/Mosa.Utility.UnitTests.csproj
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Update Source/Mosa.Linux.sln
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Refactor Program.cs: centralize settings, improve logging
Refactored Program.cs to use static MosaSettings and Stopwatch instances, centralizing settings logic into SetRequiredSettings and UpdateSettings methods. The compile process now benchmarks multiple methods in Mosa.UnitTests.Fuzzy.Fuzz0009 and outputs timing for each via a new OutputStatus method with elapsed time prefixes. Increased default compile iterations from 10 to 100. Fuzz0009.cs changes are whitespace-only (CR removal, reformatting) with no logic modifications.
* Refactor performance tests and update Azure guidelines
Refactored Program.cs to separate single and multithreaded performance tests, reduced fuzz method count, and improved compiler hook event handling. Updated status messages and moved platform registration to its own method. Revised Azure Tools Guidelines in copilot-instructions.md for clarity. Set MethodScanner to false.
* Refactor: centralize compiler event formatting/filtering
Introduce static helpers in CompilerHooks to standardize event status message formatting and filtering. Replace duplicated logic across the codebase with calls to these new methods, improving consistency and maintainability.
* Suppress diagnostics when Diagnostic setting is disabled
Added checks in MainWindow.axaml.cs and MainForm.cs to skip handling CompilerEvent.Diagnostic events when the Diagnostic setting is off, preventing unnecessary diagnostic processing and output.
* Refactor foreach loop in CompileCompleted for clarity
Refactored the foreach loop in the CompileCompleted method to use explicit braces, improving readability. No functional changes were introduced.
* Refactor AddTraceEvent to use else-if for Exception
Changed AddTraceEvent to handle CompilerEvent.Exception with an else-if instead of a separate if. This ensures the Exception and Error cases are mutually exclusive and prevents both log blocks from executing for the same event.
* Fix typo: correct "Interations" to "Iterations"
Corrected a typo in the compile time measurement output message,
changing "Interations" to "Iterations" for clarity.
* Refactor: group standard event methods in a new region
Moved GetStandardNotifyEventStatus and IsStandardFilteredNotifyEvent into a new #region Standardization within CompilerHooks for better code organization. No functional changes were made.
* Refactor method scheduling and enable batch scheduling
Refactored MethodScanner to extract entry point and required type scheduling into separate methods for clarity. Added overloads to MethodScheduler and MosaCompiler to support batch scheduling of methods, improving performance in multithreaded fuzz tests. Changed MethodScanner default to enabled in settings. Cleaned up initialization logic for better maintainability.
* Update Source/Mosa.Compiler.Framework/MethodScheduler.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Phil Garcia <phil@thinkedge.com>
* Minor fixes
* Removed add't unit tests.
* Remove Fuzz0050.cs unit tests; add usings to MethodScanner
Removed a large set of `[MosaUnitTest]` methods (FuzzMethod5068–5099) from Fuzz0050.cs, significantly reducing test coverage for integer/control flow fuzzing. Also added several using directives to MethodScanner.cs; no functional changes in that file.
* Remove unused using directives from MethodScanner.cs
Cleaned up MethodScanner.cs by removing unnecessary using directives: System.Drawing, System.Reflection, System.Runtime.ConstrainedExecution, and static System.Runtime.InteropServices.JavaScript.JSType. No functional changes were made.
* Update queue status to omit maxWorkers in diagnostics
Removed maxWorkers from the "Active" field in the queue status diagnostic message in MethodScheduler.cs. The report now shows only the number of active workers and utilization percentage, simplifying the output.
* Refactor safepoint insertion at loop backedges
Insert safepoints by creating new blocks between backedges and loop headers, containing a SafePoint and jump. Track (backedge, header) pairs to avoid duplicates. Move insertion logic to a helper method for clarity and maintainability.
* Revert "Update queue status to omit maxWorkers in diagnostics"
This reverts commit 87aad42.
* Refactor safepoint insertion at loop backedges
Simplified safepoint insertion by inlining logic and removing the creation of new blocks and branch target replacement. Now uses a HashSet<BasicBlock> to track visited backedges and inserts IR.SafePoint directly after the branch. Updated logging to match the new approach.
* - Reduce unit test
* Enable scheduling of unit tests in MethodScanner
Uncommented the ScheduleUnitTests() call in the Initialize() method, ensuring that unit test methods are now scheduled during initialization.
---------
Signed-off-by: Phil Garcia <phil@thinkedge.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent fd50889 commit 10c1cce
48 files changed
Lines changed: 74004 additions & 5613 deletions
File tree
- Source
- .github
- Mosa.Compiler.Framework.xUnit
- Mosa.Compiler.Framework
- RegisterAllocator
- RedBlackTree
- Mosa.Compiler.Platforms
- Mosa.Tool.Compiler
- Mosa.Tool.Debugger
- Views
- Mosa.Tool.Explorer.Avalonia
- Mosa.Tool.Explorer.Common
- Mosa.Tool.Explorer
- Mosa.Tool.Launcher.Console
- Mosa.Tool.Launcher
- Mosa.UnitTests/Fuzzy
- Mosa.Utility.Configuration
- Mosa.Utility.Launcher
- Mosa.Utility.UnitTests
- Mosa.Workspace.Experiment.Debug
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
| 354 | + | |
355 | 355 | | |
356 | | - | |
357 | | - | |
358 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
Lines changed: 353 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
70 | 423 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
53 | 72 | | |
0 commit comments