diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGDriver.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGDriver.cpp')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGDriver.cpp | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGDriver.cpp b/Source/JavaScriptCore/dfg/DFGDriver.cpp index 780ad6c22..79377e7f9 100644 --- a/Source/JavaScriptCore/dfg/DFGDriver.cpp +++ b/Source/JavaScriptCore/dfg/DFGDriver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2011-2014, 2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -34,12 +34,13 @@ #include "DFGPlan.h" #include "DFGThunks.h" #include "DFGWorklist.h" -#include "Debugger.h" +#include "FunctionWhitelist.h" #include "JITCode.h" -#include "Operations.h" +#include "JSCInlines.h" #include "Options.h" -#include "SamplingTool.h" +#include "TypeProfilerLog.h" #include <wtf/Atomics.h> +#include <wtf/NeverDestroyed.h> #if ENABLE(FTL_JIT) #include "FTLThunks.h" @@ -55,33 +56,34 @@ unsigned getNumCompilations() } #if ENABLE(DFG_JIT) +static FunctionWhitelist& ensureGlobalDFGWhitelist() +{ + static LazyNeverDestroyed<FunctionWhitelist> dfgWhitelist; + static std::once_flag initializeWhitelistFlag; + std::call_once(initializeWhitelistFlag, [] { + const char* functionWhitelistFile = Options::dfgWhitelist(); + dfgWhitelist.construct(functionWhitelistFile); + }); + return dfgWhitelist; +} + static CompilationResult compileImpl( - VM& vm, CodeBlock* codeBlock, CompilationMode mode, unsigned osrEntryBytecodeIndex, - const Operands<JSValue>& mustHandleValues, - PassRefPtr<DeferredCompilationCallback> callback, Worklist* worklist) + VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationMode mode, + unsigned osrEntryBytecodeIndex, const Operands<JSValue>& mustHandleValues, + Ref<DeferredCompilationCallback>&& callback) { - SamplingRegion samplingRegion("DFG Compilation (Driver)"); + if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount()) + || !ensureGlobalDFGWhitelist().contains(codeBlock)) + return CompilationFailed; numCompilations++; ASSERT(codeBlock); ASSERT(codeBlock->alternative()); ASSERT(codeBlock->alternative()->jitType() == JITCode::BaselineJIT); + ASSERT(!profiledDFGCodeBlock || profiledDFGCodeBlock->jitType() == JITCode::DFGJIT); - if (!Options::useDFGJIT() || !MacroAssembler::supportsFloatingPoint()) - return CompilationFailed; - - if (!Options::bytecodeRangeToDFGCompile().isInRange(codeBlock->instructionCount())) - return CompilationFailed; - - if (vm.enabledProfiler()) - return CompilationInvalidated; - - Debugger* debugger = codeBlock->globalObject()->debugger(); - if (debugger && (debugger->isStepping() || codeBlock->baselineAlternative()->hasDebuggerRequests())) - return CompilationInvalidated; - - if (logCompilationChanges()) + if (logCompilationChanges(mode)) dataLog("DFG(Driver) compiling ", *codeBlock, " with ", mode, ", number of instructions = ", codeBlock->instructionCount(), "\n"); // Make sure that any stubs that the DFG is going to use are initialized. We want to @@ -89,44 +91,45 @@ static CompilationResult compileImpl( vm.getCTIStub(osrExitGenerationThunkGenerator); vm.getCTIStub(throwExceptionFromCallSlowPathGenerator); vm.getCTIStub(linkCallThunkGenerator); - vm.getCTIStub(linkConstructThunkGenerator); - vm.getCTIStub(linkClosureCallThunkGenerator); - vm.getCTIStub(virtualCallThunkGenerator); - vm.getCTIStub(virtualConstructThunkGenerator); + vm.getCTIStub(linkPolymorphicCallThunkGenerator); + + if (vm.typeProfiler()) + vm.typeProfilerLog()->processLogEntries(ASCIILiteral("Preparing for DFG compilation.")); - RefPtr<Plan> plan = adoptRef( - new Plan(codeBlock, mode, osrEntryBytecodeIndex, mustHandleValues)); + Ref<Plan> plan = adoptRef( + *new Plan(codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues)); - if (worklist) { - plan->callback = callback; - if (logCompilationChanges()) - dataLog("Deferring DFG compilation of ", *codeBlock, " with queue length ", worklist->queueLength(), ".\n"); - worklist->enqueue(plan); + plan->callback = WTFMove(callback); + if (Options::useConcurrentJIT()) { + Worklist& worklist = ensureGlobalWorklistFor(mode); + if (logCompilationChanges(mode)) + dataLog("Deferring DFG compilation of ", *codeBlock, " with queue length ", worklist.queueLength(), ".\n"); + worklist.enqueue(WTFMove(plan)); return CompilationDeferred; } - plan->compileInThread(*vm.dfgState); + plan->compileInThread(*vm.dfgState, 0); return plan->finalizeWithoutNotifyingCallback(); } #else // ENABLE(DFG_JIT) static CompilationResult compileImpl( - VM&, CodeBlock*, CompilationMode, unsigned, const Operands<JSValue>&, - PassRefPtr<DeferredCompilationCallback>, Worklist*) + VM&, CodeBlock*, CodeBlock*, CompilationMode, unsigned, const Operands<JSValue>&, + Ref<DeferredCompilationCallback>&&) { return CompilationFailed; } #endif // ENABLE(DFG_JIT) CompilationResult compile( - VM& vm, CodeBlock* codeBlock, CompilationMode mode, unsigned osrEntryBytecodeIndex, - const Operands<JSValue>& mustHandleValues, - PassRefPtr<DeferredCompilationCallback> passedCallback, Worklist* worklist) + VM& vm, CodeBlock* codeBlock, CodeBlock* profiledDFGCodeBlock, CompilationMode mode, + unsigned osrEntryBytecodeIndex, const Operands<JSValue>& mustHandleValues, + Ref<DeferredCompilationCallback>&& callback) { - RefPtr<DeferredCompilationCallback> callback = passedCallback; CompilationResult result = compileImpl( - vm, codeBlock, mode, osrEntryBytecodeIndex, mustHandleValues, callback, worklist); + vm, codeBlock, profiledDFGCodeBlock, mode, osrEntryBytecodeIndex, mustHandleValues, + callback.copyRef()); if (result != CompilationDeferred) - callback->compilationDidComplete(codeBlock, result); + callback->compilationDidComplete(codeBlock, profiledDFGCodeBlock, result); return result; } |