制御フローの平坦化
controlFlowFlattening
~1.5x slower
コードの構造を変換して、元のプログラムの流れを隠します。直線的なコードを switch 文によるステートマシンへと変換することで、手作業による解析を大幅に困難にします。
// Before
function process() {
step1();
step2();
step3();
}
// After (flattened)
function process() {
var state = '0|1|2'.split('|'), i = 0;
while (true) {
switch (state[i++]) {
case '0': step1(); continue;
case '1': step2(); continue;
case '2': step3(); continue;
}
break;
}
}
制御フローの平坦化は、他の基本オプションや VM 難読化とうまく組み合わせられます。VM を有効にすると、平坦化されたステートマシンはさらにバイトコードへと変換されます。
