• fpizlo@apple.com's avatar
    Stores to local captured variables should be intercepted · 0309686b
    fpizlo@apple.com authored
    Reviewed by Mark Hahnenberg.
    Previously, in bytecode, you could assign to a captured variable just as you would
    assign to any other kind of variable. This complicates closure variable constant
    inference because we don't have any place where we can intercept stores to captured
    variables in the LLInt.
    This patch institutes a policy that only certain instructions can store to captured
    variables. If you interpret those instructions and you are required to notifyWrite()
    then you need to check if the relevant variable is captured. Those instructions are
    tracked in CodeBlock.cpp's VerifyCapturedDef. The main one is simply op_captured_mov.
    In the future, we'll probably modify those instructions to have a pointer directly to
    the VariableWatchpointSet; but for now we just introduce the captured instructions as
    In order to validate that the placeholders are inserted correctly, this patch improves
    the CodeBlock validation to be able to inspect every def in the bytecode. To do that,
    this patch refactors the liveness analysis' use/def calculator to be reusable; it now
    takes a functor for each use or def.
    In the process of refactoring the liveness analysis, I noticed that op_enter was
    claiming to def all callee registers. That's wrong; it only defs the non-temporary
    variables. Making that change revealed preexisting bugs in the liveness analysis, since
    now the validator would pick up cases where the bytecode claimed to use a temporary and
    the def calculator never noticed the definition (or the converse - where the bytecode
    was actually not using a temporary but the liveness analysis thought that it was a
    use). This patch fixes a few of those bugs.
    * GNUmakefile.list.am:
    * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * bytecode/BytecodeLivenessAnalysis.cpp:
    * bytecode/BytecodeUseDef.h: Added.
    * bytecode/CodeBlock.cpp:
    * bytecode/CodeBlock.h:
    * bytecode/Opcode.h:
    * bytecompiler/BytecodeGenerator.cpp:
    * bytecompiler/BytecodeGenerator.h:
    * bytecompiler/NodesCodegen.cpp:
    * dfg/DFGByteCodeParser.cpp:
    * dfg/DFGCapabilities.cpp:
    * jit/JIT.cpp:
    * llint/LowLevelInterpreter32_64.asm:
    * llint/LowLevelInterpreter64.asm:
    * runtime/SymbolTable.h:
    Reviewed by Mark Hahnenberg.
    * js/regress/captured-assignments-expected.txt: Added.
    * js/regress/captured-assignments.html: Added.
    * js/regress/script-tests/captured-assignments.js: Added.
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
ChangeLog 340 KB