• kmillikin@chromium.org's avatar
    Initial implementation of top-level compilation of expressions in test · ab3e85ee
    kmillikin@chromium.org authored
    context.  Test contexts are used for the left subexpressions of
    short-circuited boolean operators.  The right subexpressions inherit
    their expression context from the binary op expression.
    
    Compilation of short-circuited operations in effect and test context
    is straightforward:
    
    effect(e0 || e1) =
     test(e0, L0, L1)
     L1: effect(e1)
     L0:
    
    test(e0 || e1, L0, L1) =
     test(e0, L0, L2)
     L2: test(e1, L0, L1)
    
    Because the value of the first subexpression may be needed as the
    value of the whole expression in a value context, we introduce a
    hybrid value/test contest (the value is needed if true, but not if
    false).
    
    value(e0 || e1) =
     value/test(e0, L0, L1)
     L1: value(e1)
     L0:
    
    The compilation of value/test and test/value (introduced by boolean
    AND) is:
    
    value/test(e0 || e1, L0, L1) =
     value/test(e0, L0, L2)
     L2: value/test(e1, L0, L1)
    
    test/value(e0 || e1, L0, L1) =
     test(e0, L0, L2)
     L2: test/value(e1, L0, L1)
    
    Boolean AND is the dual.  The AST nodes themselves (not their parents)
    are responsible for producing the proper result (effect, value, or
    control flow) depending on their context.
    
    Review URL: http://codereview.chromium.org/339082
    
    git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3187 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
    ab3e85ee
fast-codegen-ia32.cc 31.8 KB