Skip to content

Feat/inliner - #705

Merged
SuperFola merged 26 commits into
devfrom
feat/inliner
Jul 21, 2026
Merged

Feat/inliner#705
SuperFola merged 26 commits into
devfrom
feat/inliner

Conversation

@SuperFola

@SuperFolaSuperFola commented Jul 19, 2026

Copy link
Copy Markdown
Member

Description

Add an IR inliner to the compiler pipeline.

  • Benchmarks needed.
  • Need to update documentation about the new debugger command, and add a test for it.
  • IR inlining tests needed.
  • Need to update documentation about the compilation process, to reference the inliner.

Checklist

  • I have read the Contributor guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation if needed (on https://github.com/ArkScript-lang/website, content/docs/)
  • I have added tests that prove my fix/feature is working
  • New and existing tests pass locally with my changes
  • I confirm that I am the author of this code and release it to the ArkScript project under the MPL-2.0 license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

@github-actions

github-actionsBot commented Jul 19, 2026

Copy link
Copy Markdown

Static analysis report

Lizard report

Listing only functions with cyclomatic complexity >= 15 or NLOC >= 100 or parameters >= 6.

FilenameStart line:end lineFunction nameParametersNLOCCCN
src/arkreactor/VM/VM.cpp457:2165Ark::VM::unsafeRun21437283
src/arkscript/main.cpp24:389main231543
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp361:440Ark::internal::ASTLowerer::compileListInstruction36432
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp212:322Ark::internal::ASTLowerer::compileExpression59231
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp891:1039Ark::internal::ASTLowerer::handleFunctionCall311631
src/arkreactor/Compiler/IntermediateRepresentation/IRInliner.cpp267:339Ark::internal::IRInliner::extractPagesMetadata16321
src/arkreactor/VM/VM.cpp2319:2413Ark::VM::backtrace38120
src/arkreactor/Compiler/IntermediateRepresentation/IRInliner.cpp137:198Ark::internal::IRInliner::isBuiltinProxy14819
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp520:613Ark::internal::ASTLowerer::compileFunction36719
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp837:889Ark::internal::ASTLowerer::handleOperator34218
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp107:129Ark::internal::ASTLowerer::nodeProducesOutput11817
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp635:683Ark::internal::ASTLowerer::compileLetMutSet44017
src/arkreactor/VM/VM.cpp2177:2234Ark::VM::throwArityError44715
src/arkreactor/Compiler/IntermediateRepresentation/IROptimizer.cpp22:259Ark::internal::IROptimizer::IROptimizer121512
Report about files you didn't modify in this PR
FilenameStart line:end lineFunction nameParametersNLOCCCN
src/arkreactor/Compiler/Macros/Processor.cpp259:643Ark::internal::MacroProcessor::evaluate3353119
src/arkreactor/Compiler/BytecodeReader.cpp385:596Ark::BytecodeReader::display417192
src/arkreactor/Error/Diagnostics.cpp45:192Ark::Diagnostics::makeContext410944
src/arkreactor/Compiler/AST/Parser.cpp841:975Ark::internal::Parser::string113142
src/arkscript/JsonCompiler.cpp27:276JsonCompiler::_compile121438
src/arkreactor/Compiler/NameResolution/NameResolutionPass.cpp163:268Ark::internal::NameResolutionPass::visitKeyword38535
src/arkreactor/Builtins/Slice.cpp21:93Ark::internal::Builtins::slice16334
src/arkreactor/Compiler/AST/Node.cpp179:285Ark::internal::Node::repr09030
src/arkreactor/Compiler/Macros/Processor.cpp107:191Ark::internal::MacroProcessor::processNode36328
src/arkreactor/Compiler/AST/Node.cpp287:368Ark::internal::Node::debugPrint17026
src/arkreactor/Compiler/BytecodeReader.cpp612:713Ark::BytecodeReader::printInstruction79825
src/arkreactor/TypeChecker.cpp149:236Ark::types::generateError67525
src/arkreactor/Compiler/NameResolution/StaticScope.cpp70:124Ark::internal::NamespaceScope::get34224
src/arkreactor/TypeChecker.cpp32:147Ark::types::displayContract610224
src/arkreactor/Compiler/AST/Parser.cpp289:417Ark::internal::Parser::import_19823
src/arkreactor/Compiler/NameResolution/NameResolutionPass.cpp57:161Ark::internal::NameResolutionPass::visit28323
include/utf8.hpp138:184utf8::isValid14421
src/arkreactor/VM/Value/Value.cpp81:149Ark::Value::toString25421
src/arkreactor/Compiler/AST/Optimizer.cpp35:85Ark::internal::Optimizer::countAndPruneDeadCode14220
src/arkreactor/Compiler/AST/Optimizer.cpp87:144Ark::internal::Optimizer::pruneUnusedGlobalVariables15018
src/arkreactor/Builtins/String.cpp47:113fmt::formatter::parse15918
src/arkscript/Formatter.cpp212:274Formatter::format35918
src/arkscript/Formatter.cpp527:585Formatter::formatCall25018
src/arkreactor/Compiler/Macros/Executors/Function.cpp16:89Ark::internal::FunctionExecutor::applyMacro25617
include/Ark/Compiler/AST/Predicates.hpp142:166Ark::internal::IsSymbol::operator ( )12416
src/arkscript/Formatter.cpp324:366Formatter::formatFunction23616
src/arkreactor/Compiler/Macros/Executors/Function.cpp99:156Ark::internal::FunctionExecutor::unify55015
src/arkreactor/Builtins/Time.cpp72:92Ark::internal::Builtins::Time::makeTimestamp6205
src/arkreactor/Error/Diagnostics.cpp194:211Ark::Diagnostics::helper7172

CppCheck report

FilenameLineTypeDescription
src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp658styleConsider using std::count_if algorithm instead of a raw loop.
src/arkreactor/VM/Debugger.cpp352styleParameter 'context' can be declared as reference to const
src/arkreactor/VM/VM.cpp0informationToo many #ifdef configurations - cppcheck only checks 12 of 13 configurations. Use --force to check all configurations.
src/arkreactor/VM/VM.cpp281errorIterators of different containers 'm_execution_contexts.emplace_back(std::make_unique())' and 'm_execution_contexts.front()' are used together.
Report files about files you didn't modify in this PR
FilenameLineTypeDescription
include/Ark/VM/VM.inl267styleVariable 'maybe_value_ptr' can be declared as pointer to const
src/arkreactor/Builtins/Bytecode.cpp23styleParameter 'vm' can be declared as pointer to const
src/arkreactor/Builtins/Time.cpp32styleParameter 'n' can be declared as reference to const
src/arkreactor/Compiler/BytecodeReader.cpp20performanceVariable 'm_arg_kinds' is assigned in constructor body. Consider performing initialization in initialization list.
src/arkreactor/Compiler/Lowerer/LocalsLocator.cpp26styleThe scope of the variable 'data' can be reduced.
src/arkreactor/Compiler/NameResolution/ScopeResolver.cpp136styleConsider using std::find_if algorithm instead of a raw loop.
src/arkreactor/State.cpp183styleVariable 'bytecode_hash' is assigned a value that is never used.
src/arkreactor/VM/SharedLibrary.cpp0informationToo many #ifdef configurations - cppcheck only checks 12 of 13 configurations. Use --force to check all configurations.
include/Ark/VM/Value/Future.hpp50styleUnused private function: 'Future::deleteSelfViaVM'
src/arkreactor/VM/Value/Future.cpp23performanceVariable 'm_value' is assigned in constructor body. Consider performing initialization in initialization list.

@codspeed-hq

codspeed-hqBot commented Jul 19, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 2.27%

⚠️Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 4 (👁 4) regressed benchmarks
✅ 14 untouched benchmarks

Performance Changes

BenchmarkBASEHEADEfficiency
👁Welder - Big - 665 nodes[2]43.5 ms44.5 ms-2.32%
👁Welder - Simple - 39 nodes[0]1.1 ms1.1 ms-2.56%
👁Welder - Medium - 83 nodes[1]2.1 ms2.1 ms-2.56%
👁Welder - Bigger[3]70.3 ms71.5 ms-1.62%

Comparing feat/inliner (4274418) with dev (00cfbe9)

Open in CodSpeed

…wise some compilers complain the expression is not a constant expression and performs head allocations
@github-actions

github-actionsBot commented Jul 19, 2026

Copy link
Copy Markdown

Super Instructions report

Some Super Instructions are under the usage threshold (24).

Super InstructionUses in compiled code
APPEND_IN_PLACE_SYM_INDEX23
INCREMENT23
DECREMENT21
STORE_FROM15
LT_CONST_JUMP_IF_FALSE9
NEQ_SYM_JUMP_IF_FALSE4
CHECK_TYPE_OF4
SET_VAL_TAIL4
STORE_HEAD2
NEQ_CONST_JUMP_IF_TRUE2
SET_VAL_TAIL_BY_INDEX1
SET_VAL_HEAD_BY_INDEX1
MUL_SET_VAL1
SET_VAL_HEAD1
STORE_TAIL1
Super Instructions over the threshold
Super InstructionUses in compiled code
LOAD_CONST_LOAD_CONST5972
CALL_SYMBOL5479
LOAD_CONST_STORE3201
CALL_BUILTIN_WITHOUT_RETURN_ADDRESS1582
CALL_BUILTIN976
LOAD_CONST_SET_VAL965
INCREMENT_STORE623
AT_SYM_SYM572
GET_FIELD_FROM_SYMBOL_INDEX505
STORE_LIST385
GET_FIELD_FROM_SYMBOL349
APPEND_IN_PLACE_SYM342
LT_LEN_SYM_JUMP_IF_FALSE331
CALL_SYMBOL_BY_INDEX285
EQ_SYM_INDEX_JUMP_IF_TRUE219
SET_VAL_FROM_INDEX160
FUSED_MATH143
SET_VAL_FROM141
LT_SYM_JUMP_IF_FALSE130
STORE_FROM_INDEX127
DECREMENT_STORE120
STORE_LEN116
DECREMENT_BY_INDEX116
GT_CONST_JUMP_IF_FALSE112
LT_CONST_JUMP_IF_TRUE96
GT_CONST_JUMP_IF_TRUE84
AT_SYM_INDEX_SYM_INDEX83
MUL_BY_INDEX80
CALL_CURRENT_PAGE75
EQ_CONST_JUMP_IF_TRUE53
AT_SYM_INDEX_CONST51
MUL_BY47
GT_SYM_JUMP_IF_FALSE39
STORE_HEAD_BY_INDEX36
STORE_TAIL_BY_INDEX35
INCREMENT_BY_INDEX33
CHECK_TYPE_OF_BY_INDEX30

@SuperFola

Copy link
Copy Markdown
MemberAuthor

The welder performance regression here is not important ; that's because a new compilation pass was added.

@github-actions

github-actionsBot commented Jul 19, 2026

Copy link
Copy Markdown

Fuzzing report

/usr/local/bin/afl-whatsup status check tool for afl-fuzz by Michal Zalewski

Summary stats

 Fuzzers alive : 0
Dead or remote : 1 (included in stats)
Total run time : 5 minutes, 0 seconds
Total execs : 21 thousands
Cumulative speed : 72 execs/sec
Pending items : 0 faves, 1231 total
Coverage reached : 8.37%
Crashes saved : 0
Hangs saved : 0

Cycles without finds : 0
Time without finds : 0

[+] Captured 46319 tuples (map size 277202, highest value 255, total values 476332336) in '/dev/null'.
[+] A coverage of 46319 edges were achieved out of 277248 existing (16.71%) with 1237 input files.

@coveralls

coveralls commented Jul 20, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29847311836

Coverage increased (+0.005%) to 94.39%

Details

  • Coverage increased (+0.005%) from the base build.
  • Patch coverage: 23 uncovered changes across 5 files (440 of 463 lines covered, 95.03%).
  • 4 coverage regressions across 1 file.

Uncovered Changes

FileChangedCovered%
src/arkreactor/Compiler/IntermediateRepresentation/IRCompiler.cpp251768.0%
src/arkreactor/Compiler/IntermediateRepresentation/IRInliner.cpp22922196.51%
include/Ark/Compiler/IntermediateRepresentation/Entity.hpp494591.84%
src/arkreactor/VM/Debugger.cpp484695.83%
include/Ark/Compiler/Lowerer/ASTLowerer.hpp232295.65%
Total (11 files)46344095.03%

Coverage Regressions

4 previously-covered lines in 1 file lost coverage.

FileLines Losing CoverageCoverage
src/arkreactor/Compiler/BytecodeReader.cpp485.71%

Coverage Stats

Coverage Status
Relevant Lines:11336
Covered Lines:10700
Line Coverage:94.39%
Coverage Strength:1164645.14 hits per line

💛 - Coveralls

@SuperFola
SuperFola marked this pull request as ready for review July 21, 2026 16:10
@SuperFola
SuperFola merged commit 68b3ba7 into devJul 21, 2026
38 checks passed
@SuperFola
SuperFola deleted the feat/inliner branch July 21, 2026 17:05
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@SuperFola@coveralls