Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ir #498

Merged
merged 10 commits into from
Oct 12, 2024
Merged

Feat/ir #498

merged 10 commits into from
Oct 12, 2024

Conversation

SuperFola
Copy link
Member

@SuperFola SuperFola commented Oct 6, 2024

Description

Add an additional IR generation step, between the compiler and bytecode generation.

We now have AST -> Compiler -> IR -> IRCompiler -> Bytecode.

The goal is to be able to add an IROptimizer before the IRCompiler.

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
  • I have added tests that prove my fix/feature is working
  • New and existing tests pass locally with my changes

Copy link

github-actions bot commented Oct 6, 2024

Static analysis report

Lizard report

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

Filename Start line:end line Function name Parameters NLOC CCN
src/arkreactor/VM/VM.cpp 320:1259 Ark::VM::safeRun 3 762 159
src/arkreactor/Compiler/BytecodeReader.cpp 197:446 Ark::BytecodeReader::display 4 214 76
src/arkreactor/Compiler/IntermediateRepresentation/IROptimizer.cpp 9:133 Ark::internal::IROptimizer::process 3 102 42
src/arkreactor/Compiler/Compiler.cpp 412:574 Ark::internal::Compiler::handleCalls 5 131 39
src/arkscript/main.cpp 17:336 main 2 276 30
src/arkreactor/Compiler/Compiler.cpp 118:209 Ark::internal::Compiler::compileExpression 5 75 25
include/Ark/Compiler/AST/Predicates.hpp 132:156 Ark::internal::IsSymbol::operator ( ) 1 24 16
Report about files you didn't modify in this PR
Filename Start line:end line Function name Parameters NLOC CCN
src/arkreactor/Compiler/Macros/Processor.cpp 266:574 Ark::internal::MacroProcessor::evaluate 3 291 118
src/arkscript/REPL/Repl.cpp 17:229 Ark::Repl::Repl 1 180 35
include/Ark/Compiler/AST/Parser.hpp 105:194 Ark::internal::ARK_APIParser::string 0 87 32
src/arkscript/JsonCompiler.cpp 26:206 JsonCompiler::_compile 1 151 27
src/arkreactor/Compiler/NameResolutionPass.cpp 172:271 Ark::internal::NameResolutionPass::visitKeyword 2 90 25
src/arkreactor/Compiler/AST/Node.cpp 201:271 Ark::internal::Node::debugPrint 1 61 23
include/utf8.hpp 138:184 utf8::isValid 1 44 21
src/arkreactor/Compiler/AST/Parser.cpp 266:393 Ark::internal::Parser::import_ 0 103 21
src/arkreactor/Compiler/Macros/Processor.cpp 117:187 Ark::internal::MacroProcessor::processNode 2 54 21
src/arkreactor/Compiler/Macros/Executors/Function.cpp 12:86 Ark::internal::FunctionExecutor::applyMacro 2 60 18
src/arkreactor/Compiler/NameResolutionPass.cpp 108:170 Ark::internal::NameResolutionPass::visit 1 53 18
src/arkreactor/VM/Value.cpp 67:125 Ark::Value::toString 1 46 17
src/arkreactor/Compiler/AST/Node.cpp 135:199 Ark::internal::Node::repr 0 56 17
src/arkreactor/Compiler/Macros/Processor.cpp 46:91 Ark::internal::MacroProcessor::registerMacro 1 41 16
src/arkscript/Formatter.cpp 161:214 Formatter::format 3 51 15
src/arkreactor/TypeChecker.cpp 28:85 Ark::types::displayContract 2 51 15
src/arkreactor/Exceptions.cpp 86:130 Ark::Diagnostics::makeContext 6 35 15
src/arkreactor/Exceptions.cpp 133:142 Ark::Diagnostics::helper 9 9 3
include/Ark/Exceptions.hpp 92:101 Ark::CodeError::CodeError 6 10 1

CppCheck report

Filename Line Type Description
src/arkreactor/Compiler/BytecodeReader.cpp 332 style struct member 'Arg::arg' is never used.
src/arkreactor/VM/VM.cpp 433 style Statements following return, break, continue, goto or throw will never be executed.
src/arkreactor/VM/VM.cpp 358 error syntax error
src/arkscript/main.cpp 84 information Unmatched suppression: constStatement
Report files about files you didn't modify in this PR
Filename Line Type Description
src/arkreactor/Builtins/IO.cpp 24 style Parameter 'n' can be declared with const
src/arkreactor/Builtins/IO.cpp 43 style Parameter 'n' can be declared with const
include/Ark/Compiler/AST/Optimizer.hpp 64 style Unused private function: 'Optimizer::throwOptimizerError'
include/Ark/Compiler/AST/Optimizer.hpp 70 style Unused private function: 'Optimizer::removeUnused'
src/arkreactor/Compiler/AST/Parser.cpp 385 error Uninitialized variable: import_data.with_prefix
include/Ark/Compiler/Macros/Processor.hpp 170 performance Function parameter 'origin' should be passed by const reference.
src/arkreactor/Compiler/Macros/Executor.cpp 12 performance Function parameter 'origin' should be passed by const reference.
include/Ark/Compiler/Macros/Executor.hpp 71 performance Function parameter 'origin' should be passed by const reference.
src/arkreactor/Compiler/Macros/Executors/Function.cpp 14 style The scope of the variable 'first' can be reduced.
src/arkreactor/Compiler/Macros/Processor.cpp 245 performance Function parameter 'origin' should be passed by const reference.
src/arkreactor/VM/Scope.cpp 51 style Variable 'id' is not assigned a value.
src/arkreactor/VM/Scope.cpp 61 style Variable 'id' is not assigned a value.
src/arkreactor/VM/Scope.cpp 71 style Variable 'id' is not assigned a value.
src/arkscript/JsonCompiler.cpp 156 style Consider using std::accumulate algorithm instead of a raw loop.
src/arkscript/JsonCompiler.cpp 163 style Consider using std::transform algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 24 style Consider using std::copy algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 26 style Consider using std::copy algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 28 style Consider using std::copy algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 30 style Consider using std::copy algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 36 style Consider using std::transform algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 38 style Consider using std::transform algorithm instead of a raw loop.
src/arkscript/REPL/Repl.cpp 47 style Consider using std::transform algorithm instead of a raw loop.

@SuperFola SuperFola force-pushed the feat/ir branch 2 times, most recently from 5e2e3b6 to 71ade80 Compare October 6, 2024 21:03
@coveralls
Copy link

coveralls commented Oct 6, 2024

Coverage Status

coverage: 76.391% (+1.2%) from 75.225%
when pulling 139084d on feat/ir
into 973eba8 on dev.

Copy link

github-actions bot commented Oct 6, 2024

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 : 38 thousands
 Cumulative speed : 127 execs/sec
    Pending items : 88 faves, 786 total
 Coverage reached : 8.74%
    Crashes saved : 3
      Hangs saved : 0

Cycles without finds : 0
Time without finds : 0

[+] Captured 33211 tuples (map size 183478, highest value 255, total values 253815698) in '/dev/null'.
[+] A coverage of 33211 edges were achieved out of 183488 existing (18.10%) with 797 input files.

@SuperFola SuperFola marked this pull request as ready for review October 12, 2024 07:36
@SuperFola SuperFola force-pushed the feat/ir branch 2 times, most recently from 423b5e2 to f770469 Compare October 12, 2024 08:25
… map of instruction -> argument kind to avoid an horrendous if/else chain
Also initializes the IROptimizer, currently equivalent to a NOP.
…ntroducing super instructions

Also placed the primary argument of super instructions at the end so that we just have to bit mask on arg
@SuperFola SuperFola merged commit 2266f3b into dev Oct 12, 2024
26 checks passed
@SuperFola SuperFola deleted the feat/ir branch October 12, 2024 08:54
Sign up for free to 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