• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 29913976205

22 Jul 2026 10:58AM UTC coverage: 61.522%. Remained the same
29913976205

push

github

web-flow
Fixed shortcircuit optimization for consecutive jumps (#898)

* added test which will fail

* disabled short-circuit jump combiner

* docs

* reactivating logical convert remove

* dedicated step to optimize jumps based on instructions

removed disabled ShortCircuit code

* added more tests, adapted corechanges

* added dedicated CodeSection optimizer

30 of 33 new or added lines in 4 files covered. (90.91%)

45089 of 73289 relevant lines covered (61.52%)

497779.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.29
/pol-core/bscript/compiler/optimizer/CodeSectionOptimizer.cpp
1
#include "bscript/compiler/optimizer/CodeSectionOptimizer.h"
2
#include "bscript/StoredToken.h"
3
#include "bscript/compilercfg.h"
4
#include "bscript/tokens.h"
5

6
namespace Pol::Bscript::Compiler
7
{
8
void CodeSectionOptimizer::optimize( CodeSection& code ) const
2,263✔
9
{
10
  if ( compilercfg.ShortCircuitEvaluation )
2,263✔
11
    short_circuit_jumps( code );
665✔
12
}
2,263✔
13

14
void CodeSectionOptimizer::short_circuit_jumps( CodeSection& code ) const
665✔
15
{
16
  // recursivly check if a logical jump would jump to another jump and update the final jump
17
  // location
18
  auto combine = [&]( StoredToken& jump, auto&& combine )
596✔
19
  {
20
    const auto& loc = code[jump.offset];
596✔
21
    if ( loc.id == RSV_JMPIFFALSE )
596✔
22
    {
23
      if ( jump.type == TYP_LOGICAL_JUMP_FALSE )
165✔
24
        jump.offset = loc.offset;
71✔
25
      else
26
        jump.offset++;
94✔
27
    }
28
    else if ( loc.id == RSV_JMPIFTRUE )
431✔
29
    {
NEW
30
      if ( jump.type != TYP_LOGICAL_JUMP_FALSE )
×
NEW
31
        jump.offset = loc.offset;
×
32
      else
NEW
33
        jump.offset++;
×
34
    }
35
    else if ( loc.id == INS_LOGICAL_JUMP )
431✔
36
    {
37
      if ( loc.type == jump.type )
174✔
38
        jump.offset = loc.offset;
139✔
39
      else
40
        jump.offset++;
35✔
41
    }
42
    else if ( loc.id == INS_LOGICAL_CONVERT )
257✔
43
    {
44
      jump.offset++;
18✔
45
    }
46
    else
47
    {
48
      return;
239✔
49
    }
50
    return combine( jump, combine );
357✔
51
  };
665✔
52
  for ( auto& c : code )
42,168✔
53
    if ( c.id == INS_LOGICAL_JUMP )
41,503✔
54
      combine( c, combine );
239✔
55
}
665✔
56
}  // namespace Pol::Bscript::Compiler
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc