• mdempsky's avatar
    Split AssembleFilter into comprehensible chunks · d2283ac2
    mdempsky authored
    Previously SandboxBPF constructed the CodeGen Instruction sequence
    primarily in one large, complex function.  Additionally, it made
    extensive use of the CodeGen::JoinInstructions() function to
    conditionally arrange various bits of instructions, which made it
    harder to follow.
    
    This CL splits the Instruction assembly code into 5 mostly distinct
    functions and eliminates all use of JoinInstruction() in favor of
    function composition.  E.g., instead of
    
        foo = gen->MakeInstruction(...);
        bar = gen->MakeInstruction(...);
        gen->JoinInstructions(foo, bar);
    
    this CL favors writing
    
        MakeFoo(MakeBar())
    
    with the convention that Instruction-constructing functions should
    arrange for control to transfer to the Instruction sequence argument
    when complete.  (I.e., "continuation-passing style":
    http://en.wikipedia.org/wiki/Continuation-passing_style)
    
    BUG=414363
    
    Review URL: https://codereview.chromium.org/568053005
    
    Cr-Commit-Position: refs/heads/master@{#295015}
    d2283ac2
sandbox_bpf.cc 40.6 KB