Skip to content
  • oliver@apple.com's avatar
    Code cache stores bogus var references for functions in eval code · 0c14001a
    oliver@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=115747
    
    Reviewed by Mark Hahnenberg.
    
    Source/JavaScriptCore:
    
    Non-global eval now uses a per-CodeBlock cache, and only use it
    when we're at the top of a function's scope.  This means that we
    will no longer cache the parsing of a single string across
    multiple functions, and we won't cache when we're nested inside
    constructs like |with| and |catch| where previously we would, which
    is good because caching in those cases is unsound.
    
    * bytecode/EvalCodeCache.h:
    (JSC):
    (JSC::EvalCodeCache::getSlow):
    (JSC::EvalCodeCache::get):
    * bytecode/UnlinkedCodeBlock.h:
    (JSC::UnlinkedCodeBlock::codeCacheForEval):
    (UnlinkedCodeBlock):
    (RareData):
    * debugger/Debugger.cpp:
    (JSC::evaluateInGlobalCallFrame):
    * debugger/DebuggerCallFrame.cpp:
    (JSC::DebuggerCallFrame::evaluate):
    * interpreter/Interpreter.cpp:
    (JSC::eval):
    * runtime/CodeCache.cpp:
    (JSC::CodeCache::CodeCache):
    (JSC::CodeCache::generateBytecode):
    (JSC):
    (JSC::CodeCache::getCodeBlock):
    * runtime/CodeCache.h:
    (JSC::CodeCacheMap::CodeCacheMap):
    (CodeCacheMap):
    (JSC::CodeCacheMap::canPruneQuickly):
    (JSC::CodeCacheMap::prune):
    (JSC::CodeCache::create):
    (CodeCache):
    * runtime/Executable.cpp:
    (JSC::EvalExecutable::EvalExecutable):
    (JSC::EvalExecutable::compileInternal):
    * runtime/Executable.h:
    (JSC::EvalExecutable::create):
    (EvalExecutable):
    * runtime/JSGlobalObject.cpp:
    (JSC::JSGlobalObject::createEvalCodeBlock):
    * runtime/JSGlobalObject.h:
    (JSGlobalObject):
    * runtime/JSGlobalObjectFunctions.cpp:
    (JSC::globalFuncEval):
    * runtime/VM.cpp:
    (JSC::VM::VM):
    * runtime/VM.h:
    (VM):
    
    LayoutTests:
    
    Many tests
    
    * fast/js/eval-cache-scoped-lookup-expected.txt: Added.
    * fast/js/eval-cache-scoped-lookup.html: Added.
    * fast/js/script-tests/eval-cache-scoped-lookup.js: Added.
    (first):
    (a.string_appeared_here.second):
    (third):
    (fifth):
    (sixth):
    (seventh):
    (eighth):
    (nineth):
    (tenth):
    (eleventh):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    0c14001a