diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSGlobalData.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSGlobalData.cpp | 124 |
1 files changed, 35 insertions, 89 deletions
diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.cpp b/Source/JavaScriptCore/runtime/JSGlobalData.cpp index f138e75fb..b08c7dfa2 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalData.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalData.cpp @@ -40,7 +40,6 @@ #include "JSActivation.h" #include "JSAPIValueWrapper.h" #include "JSArray.h" -#include "JSByteArray.h" #include "JSClassRef.h" #include "JSFunction.h" #include "JSLock.h" @@ -62,33 +61,12 @@ #include "RegExp.h" #endif -#if PLATFORM(MAC) +#if USE(CF) #include <CoreFoundation/CoreFoundation.h> #endif using namespace WTF; -namespace { - -using namespace JSC; - -class Recompiler : public MarkedBlock::VoidFunctor { -public: - void operator()(JSCell*); -}; - -inline void Recompiler::operator()(JSCell* cell) -{ - if (!cell->inherits(&JSFunction::s_info)) - return; - JSFunction* function = asFunction(cell); - if (!function->executable() || function->executable()->isHostFunction()) - return; - function->jsExecutable()->discardCode(); -} - -} // namespace - namespace JSC { extern const HashTable arrayConstructorTable; @@ -110,8 +88,34 @@ extern const HashTable regExpPrototypeTable; extern const HashTable stringTable; extern const HashTable stringConstructorTable; +#if ENABLE(ASSEMBLER) && (ENABLE(CLASSIC_INTERPRETER) || ENABLE(LLINT)) +static bool enableAssembler(ExecutableAllocator& executableAllocator) +{ + if (!executableAllocator.isValid() || !Options::useJIT) + return false; + +#if USE(CF) + CFStringRef canUseJITKey = CFStringCreateWithCString(0 , "JavaScriptCoreUseJIT", kCFStringEncodingMacRoman); + CFBooleanRef canUseJIT = (CFBooleanRef)CFPreferencesCopyAppValue(canUseJITKey, kCFPreferencesCurrentApplication); + if (canUseJIT) { + return kCFBooleanTrue == canUseJIT; + CFRelease(canUseJIT); + } + CFRelease(canUseJITKey); +#endif + +#if USE(CF) || OS(UNIX) + char* canUseJITString = getenv("JavaScriptCoreUseJIT"); + return !canUseJITString || atoi(canUseJITString); +#else + return true; +#endif +} +#endif + JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType threadStackType, HeapSize heapSize) - : globalDataType(globalDataType) + : heap(this, heapSize) + , globalDataType(globalDataType) , clientData(0) , topCallFrame(CallFrame::noCaller()) , arrayConstructorTable(fastNew<HashTable>(JSC::arrayConstructorTable)) @@ -141,7 +145,6 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread , parserArena(adoptPtr(new ParserArena)) , keywords(adoptPtr(new Keywords(this))) , interpreter(0) - , heap(this, heapSize) , jsArrayClassInfo(&JSArray::s_info) , jsFinalObjectClassInfo(&JSFinalObject::s_info) #if ENABLE(DFG_JIT) @@ -160,8 +163,11 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread #if CPU(X86) && ENABLE(JIT) , m_timeoutCount(512) #endif +#if ENABLE(ASSEMBLER) && (ENABLE(CLASSIC_INTERPRETER) || ENABLE(LLINT)) + , m_canUseAssembler(enableAssembler(executableAllocator)) +#endif #if ENABLE(GC_VALIDATION) - , m_isInitializingObject(false) + , m_initializingObjectClass(0) #endif , m_inDefineOwnProperty(false) { @@ -193,33 +199,7 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread wtfThreadData().setCurrentIdentifierTable(existingEntryIdentifierTable); -#if ENABLE(JIT) && (ENABLE(CLASSIC_INTERPRETER) || ENABLE(LLINT)) -#if USE(CF) - CFStringRef canUseJITKey = CFStringCreateWithCString(0 , "JavaScriptCoreUseJIT", kCFStringEncodingMacRoman); - CFBooleanRef canUseJIT = (CFBooleanRef)CFPreferencesCopyAppValue(canUseJITKey, kCFPreferencesCurrentApplication); - if (canUseJIT) { - m_canUseJIT = kCFBooleanTrue == canUseJIT; - CFRelease(canUseJIT); - } else { - char* canUseJITString = getenv("JavaScriptCoreUseJIT"); - m_canUseJIT = !canUseJITString || atoi(canUseJITString); - } - CFRelease(canUseJITKey); -#elif OS(UNIX) - char* canUseJITString = getenv("JavaScriptCoreUseJIT"); - m_canUseJIT = !canUseJITString || atoi(canUseJITString); -#else - m_canUseJIT = true; -#endif -#endif #if ENABLE(JIT) -#if ENABLE(CLASSIC_INTERPRETER) || ENABLE(LLINT) - if (m_canUseJIT) - m_canUseJIT = executableAllocator.isValid(); - - if (!Options::useJIT) - m_canUseJIT = false; -#endif jitStubs = adoptPtr(new JITThunks(this)); #endif @@ -232,38 +212,13 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType thread llintData.performAssertions(*this); } -void JSGlobalData::clearBuiltinStructures() -{ - structureStructure.clear(); - debuggerActivationStructure.clear(); - activationStructure.clear(); - interruptedExecutionErrorStructure.clear(); - terminatedExecutionErrorStructure.clear(); - staticScopeStructure.clear(); - strictEvalActivationStructure.clear(); - stringStructure.clear(); - notAnObjectStructure.clear(); - propertyNameIteratorStructure.clear(); - getterSetterStructure.clear(); - apiWrapperStructure.clear(); - scopeChainNodeStructure.clear(); - executableStructure.clear(); - nativeExecutableStructure.clear(); - evalExecutableStructure.clear(); - programExecutableStructure.clear(); - functionExecutableStructure.clear(); - regExpStructure.clear(); - structureChainStructure.clear(); -} - JSGlobalData::~JSGlobalData() { - // By the time this is destroyed, heap.destroy() must already have been called. + heap.lastChanceToFinalize(); delete interpreter; #ifndef NDEBUG - // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance. - interpreter = 0; + interpreter = reinterpret_cast<Interpreter*>(0xbbadbeef); #endif arrayPrototypeTable->deleteTable(); @@ -443,15 +398,6 @@ void JSGlobalData::dumpSampleData(ExecState* exec) #endif } -void JSGlobalData::recompileAllJSFunctions() -{ - // If JavaScript is running, it's not safe to recompile, since we'll end - // up throwing away code that is live on the stack. - ASSERT(!dynamicGlobalObject); - - heap.objectSpace().forEachCell<Recompiler>(); -} - struct StackPreservingRecompiler : public MarkedBlock::VoidFunctor { HashSet<FunctionExecutable*> currentlyExecutingFunctions; void operator()(JSCell* cell) @@ -478,7 +424,7 @@ void JSGlobalData::releaseExecutableMemory() if (cell->inherits(&ScriptExecutable::s_info)) executable = static_cast<ScriptExecutable*>(*ptr); else if (cell->inherits(&JSFunction::s_info)) { - JSFunction* function = asFunction(*ptr); + JSFunction* function = jsCast<JSFunction*>(*ptr); if (function->isHostFunction()) continue; executable = function->jsExecutable(); |