Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (208767 => 208768)
--- trunk/Source/_javascript_Core/ChangeLog 2016-11-16 00:19:54 UTC (rev 208767)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-11-16 00:23:01 UTC (rev 208768)
@@ -1,3 +1,29 @@
+2016-11-15 Geoffrey Garen <[email protected]>
+
+ Debugging and other tools should not disable the code cache
+ https://bugs.webkit.org/show_bug.cgi?id=164802
+
+ Reviewed by Mark Lam.
+
+ * bytecode/UnlinkedFunctionExecutable.cpp:
+ (JSC::UnlinkedFunctionExecutable::fromGlobalCode): Updated for interface
+ change.
+
+ * parser/SourceCodeKey.h:
+ (JSC::SourceCodeFlags::SourceCodeFlags):
+ (JSC::SourceCodeFlags::bits):
+ (JSC::SourceCodeKey::SourceCodeKey): Treat debugging and other tools
+ as part of our key so that we can cache code while using tools. Be sure
+ to include these bits in our hash function so you don't get storms of
+ collisions as you open and close the Web Inspector.
+
+ * runtime/CodeCache.cpp:
+ (JSC::CodeCache::getUnlinkedGlobalCodeBlock):
+ (JSC::CodeCache::getUnlinkedGlobalFunctionExecutable): Treat tools as
+ a part of our key instead of as a reason to disable caching.
+
+ * runtime/CodeCache.h:
+
2016-11-15 Mark Lam <[email protected]>
Remove JSString::SafeView and replace its uses with StringViewWithUnderlyingString.
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (208767 => 208768)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2016-11-16 00:19:54 UTC (rev 208767)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp 2016-11-16 00:23:01 UTC (rev 208768)
@@ -179,10 +179,11 @@
{
ParserError error;
VM& vm = exec.vm();
+ auto& globalObject = *exec.lexicalGlobalObject();
CodeCache* codeCache = vm.codeCache();
- UnlinkedFunctionExecutable* executable = codeCache->getUnlinkedGlobalFunctionExecutable(vm, name, source, error);
+ DebuggerMode debuggerMode = globalObject.hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;
+ UnlinkedFunctionExecutable* executable = codeCache->getUnlinkedGlobalFunctionExecutable(vm, name, source, debuggerMode, error);
- auto& globalObject = *exec.lexicalGlobalObject();
if (globalObject.hasDebugger())
globalObject.debugger()->sourceParsed(&exec, source.provider(), error.line(), error.message());
Modified: trunk/Source/_javascript_Core/parser/SourceCodeKey.h (208767 => 208768)
--- trunk/Source/_javascript_Core/parser/SourceCodeKey.h 2016-11-16 00:19:54 UTC (rev 208767)
+++ trunk/Source/_javascript_Core/parser/SourceCodeKey.h 2016-11-16 00:23:01 UTC (rev 208768)
@@ -33,13 +33,21 @@
namespace JSC {
enum class SourceCodeType { EvalType, ProgramType, FunctionType, ModuleType };
+enum class TypeProfilerEnabled { No, Yes };
+enum class ControlFlowProfilerEnabled { No, Yes };
class SourceCodeFlags {
public:
SourceCodeFlags() = default;
- SourceCodeFlags(SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext)
+ SourceCodeFlags(
+ SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode,
+ DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext,
+ DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled)
: m_flags(
+ (static_cast<unsigned>(debuggerMode) << 8) |
+ (static_cast<unsigned>(typeProfilerEnabled) << 7) |
+ (static_cast<unsigned>(controlFlowProfilerEnabled) << 6) |
(static_cast<unsigned>(scriptMode) << 5) |
(static_cast<unsigned>(isArrowFunctionContext) << 4) |
(static_cast<unsigned>(evalContextType) << 3) |
@@ -55,6 +63,8 @@
return m_flags == rhs.m_flags;
}
+ unsigned bits() { return m_flags; }
+
private:
unsigned m_flags { 0 };
};
@@ -65,11 +75,14 @@
{
}
- SourceCodeKey(const SourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext)
- : m_sourceCode(sourceCode)
- , m_name(name)
- , m_flags(codeType, strictMode, scriptMode, derivedContextType, evalContextType, isArrowFunctionContext)
- , m_hash(sourceCode.hash())
+ SourceCodeKey(
+ const SourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode,
+ JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext,
+ DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled)
+ : m_sourceCode(sourceCode)
+ , m_name(name)
+ , m_flags(codeType, strictMode, scriptMode, derivedContextType, evalContextType, isArrowFunctionContext, debuggerMode, typeProfilerEnabled, controlFlowProfilerEnabled)
+ , m_hash(sourceCode.hash() ^ m_flags.bits())
{
}
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.cpp (208767 => 208768)
--- trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2016-11-16 00:19:54 UTC (rev 208767)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.cpp 2016-11-16 00:23:01 UTC (rev 208768)
@@ -53,10 +53,13 @@
{
DerivedContextType derivedContextType = executable->derivedContextType();
bool isArrowFunctionContext = executable->isArrowFunctionContext();
- SourceCodeKey key(source, String(), CacheTypes<UnlinkedCodeBlockType>::codeType, strictMode, scriptMode, derivedContextType, evalContextType, isArrowFunctionContext);
+ SourceCodeKey key(
+ source, String(), CacheTypes<UnlinkedCodeBlockType>::codeType, strictMode, scriptMode,
+ derivedContextType, evalContextType, isArrowFunctionContext, debuggerMode,
+ vm.typeProfiler() ? TypeProfilerEnabled::Yes : TypeProfilerEnabled::No,
+ vm.controlFlowProfiler() ? ControlFlowProfilerEnabled::Yes : ControlFlowProfilerEnabled::No);
SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key);
- bool canCache = debuggerMode == DebuggerOff && !vm.typeProfiler() && !vm.controlFlowProfiler() && Options::useCodeCache();
- if (cache && canCache) {
+ if (cache && Options::useCodeCache()) {
UnlinkedCodeBlockType* unlinkedCodeBlock = jsCast<UnlinkedCodeBlockType*>(cache->cell.get());
unsigned firstLine = source.firstLine() + unlinkedCodeBlock->firstLine();
unsigned lineCount = unlinkedCodeBlock->lineCount();
@@ -72,7 +75,7 @@
VariableEnvironment variablesUnderTDZ;
UnlinkedCodeBlockType* unlinkedCodeBlock = generateUnlinkedCodeBlock<UnlinkedCodeBlockType, ExecutableType>(vm, executable, source, strictMode, scriptMode, debuggerMode, error, evalContextType, &variablesUnderTDZ);
- if (unlinkedCodeBlock && canCache)
+ if (unlinkedCodeBlock && Options::useCodeCache())
m_sourceCode.addCache(key, SourceCodeValue(vm, unlinkedCodeBlock, m_sourceCode.age()));
return unlinkedCodeBlock;
@@ -93,7 +96,7 @@
return getUnlinkedGlobalCodeBlock<UnlinkedModuleProgramCodeBlock>(vm, executable, source, JSParserStrictMode::Strict, JSParserScriptMode::Module, debuggerMode, error, EvalContextType::None);
}
-UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& vm, const Identifier& name, const SourceCode& source, ParserError& error)
+UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& vm, const Identifier& name, const SourceCode& source, DebuggerMode debuggerMode, ParserError& error)
{
bool isArrowFunctionContext = false;
SourceCodeKey key(
@@ -102,7 +105,10 @@
JSParserScriptMode::Classic,
DerivedContextType::None,
EvalContextType::None,
- isArrowFunctionContext);
+ isArrowFunctionContext,
+ debuggerMode,
+ vm.typeProfiler() ? TypeProfilerEnabled::Yes : TypeProfilerEnabled::No,
+ vm.controlFlowProfiler() ? ControlFlowProfilerEnabled::Yes : ControlFlowProfilerEnabled::No);
SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key);
if (cache && Options::useCodeCache()) {
UnlinkedFunctionExecutable* executable = jsCast<UnlinkedFunctionExecutable*>(cache->cell.get());
Modified: trunk/Source/_javascript_Core/runtime/CodeCache.h (208767 => 208768)
--- trunk/Source/_javascript_Core/runtime/CodeCache.h 2016-11-16 00:19:54 UTC (rev 208767)
+++ trunk/Source/_javascript_Core/runtime/CodeCache.h 2016-11-16 00:23:01 UTC (rev 208768)
@@ -196,7 +196,7 @@
UnlinkedProgramCodeBlock* getUnlinkedProgramCodeBlock(VM&, ProgramExecutable*, const SourceCode&, JSParserStrictMode, DebuggerMode, ParserError&);
UnlinkedEvalCodeBlock* getUnlinkedGlobalEvalCodeBlock(VM&, IndirectEvalExecutable*, const SourceCode&, JSParserStrictMode, DebuggerMode, ParserError&, EvalContextType);
UnlinkedModuleProgramCodeBlock* getUnlinkedModuleProgramCodeBlock(VM&, ModuleProgramExecutable*, const SourceCode&, DebuggerMode, ParserError&);
- UnlinkedFunctionExecutable* getUnlinkedGlobalFunctionExecutable(VM&, const Identifier&, const SourceCode&, ParserError&);
+ UnlinkedFunctionExecutable* getUnlinkedGlobalFunctionExecutable(VM&, const Identifier&, const SourceCode&, DebuggerMode, ParserError&);
void clear() { m_sourceCode.clear(); }