diff options
Diffstat (limited to 'JavaScriptCore/runtime/JSGlobalData.cpp')
| -rw-r--r-- | JavaScriptCore/runtime/JSGlobalData.cpp | 135 |
1 files changed, 99 insertions, 36 deletions
diff --git a/JavaScriptCore/runtime/JSGlobalData.cpp b/JavaScriptCore/runtime/JSGlobalData.cpp index 45abc86..9948877 100644 --- a/JavaScriptCore/runtime/JSGlobalData.cpp +++ b/JavaScriptCore/runtime/JSGlobalData.cpp @@ -49,6 +49,13 @@ #include "Lookup.h" #include "Nodes.h" #include "Parser.h" +#include "RegExpCache.h" +#include "StrictEvalActivation.h" +#include <wtf/WTFThreadData.h> +#if ENABLE(REGEXP_TRACING) +#include "RegExp.h" +#endif + #if ENABLE(JSC_MULTIPLE_THREADS) #include <wtf/Threading.h> @@ -56,6 +63,7 @@ #if PLATFORM(MAC) #include "ProfilerServer.h" +#include <CoreFoundation/CoreFoundation.h> #endif using namespace WTF; @@ -82,7 +90,7 @@ void JSGlobalData::storeVPtrs() void* storage = &cell; COMPILE_ASSERT(sizeof(JSArray) <= sizeof(CollectorCell), sizeof_JSArray_must_be_less_than_CollectorCell); - JSCell* jsArray = new (storage) JSArray(JSArray::createStructure(jsNull())); + JSCell* jsArray = new (storage) JSArray(JSArray::VPtrStealingHack); JSGlobalData::jsArrayVPtr = jsArray->vptr(); jsArray->~JSCell(); @@ -102,8 +110,8 @@ void JSGlobalData::storeVPtrs() jsFunction->~JSCell(); } -JSGlobalData::JSGlobalData(bool isShared) - : isSharedInstance(isShared) +JSGlobalData::JSGlobalData(GlobalDataType globalDataType, ThreadStackType threadStackType) + : globalDataType(globalDataType) , clientData(0) , arrayTable(fastNew<HashTable>(JSC::arrayTable)) , dateTable(fastNew<HashTable>(JSC::dateTable)) @@ -115,42 +123,62 @@ JSGlobalData::JSGlobalData(bool isShared) , stringTable(fastNew<HashTable>(JSC::stringTable)) , activationStructure(JSActivation::createStructure(jsNull())) , interruptedExecutionErrorStructure(JSObject::createStructure(jsNull())) + , terminatedExecutionErrorStructure(JSObject::createStructure(jsNull())) , staticScopeStructure(JSStaticScopeObject::createStructure(jsNull())) + , strictEvalActivationStructure(StrictEvalActivation::createStructure(jsNull())) , stringStructure(JSString::createStructure(jsNull())) - , notAnObjectErrorStubStructure(JSNotAnObjectErrorStub::createStructure(jsNull())) , notAnObjectStructure(JSNotAnObject::createStructure(jsNull())) , propertyNameIteratorStructure(JSPropertyNameIterator::createStructure(jsNull())) , getterSetterStructure(GetterSetter::createStructure(jsNull())) , apiWrapperStructure(JSAPIValueWrapper::createStructure(jsNull())) , dummyMarkableCellStructure(JSCell::createDummyStructure()) -#if USE(JSVALUE32) - , numberStructure(JSNumberCell::createStructure(jsNull())) -#endif - , identifierTable(createIdentifierTable()) + , identifierTable(globalDataType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable()) , propertyNames(new CommonIdentifiers(this)) , emptyList(new MarkedArgumentBuffer) , lexer(new Lexer(this)) , parser(new Parser) , interpreter(new Interpreter) -#if ENABLE(JIT) - , jitStubs(this) -#endif , heap(this) - , initializingLazyNumericCompareFunction(false) , head(0) , dynamicGlobalObject(0) - , functionCodeBlockBeingReparsed(0) , firstStringifierToMark(0) , markStack(jsArrayVPtr) , cachedUTCOffset(NaN) - , weakRandom(static_cast<int>(currentTime())) + , maxReentryDepth(threadStackType == ThreadStackTypeSmall ? MaxSmallThreadReentryDepth : MaxLargeThreadReentryDepth) + , m_regExpCache(new RegExpCache(this)) +#if ENABLE(REGEXP_TRACING) + , m_rtTraceList(new RTTraceList()) +#endif #ifndef NDEBUG - , mainThreadOnly(false) + , exclusiveThread(0) #endif { #if PLATFORM(MAC) startProfilerServerIfNeeded(); #endif +#if ENABLE(JIT) && ENABLE(INTERPRETER) +#if PLATFORM(CF) + CFStringRef canUseJITKey = CFStringCreateWithCString(0 , "JavaScriptCoreUseJIT", kCFStringEncodingMacRoman); + CFBooleanRef canUseJIT = (CFBooleanRef)CFPreferencesCopyAppValue(canUseJITKey, kCFPreferencesCurrentApplication); + if (canUseJIT) { + m_canUseJIT = kCFBooleanTrue == canUseJIT; + CFRelease(canUseJIT); + } else + m_canUseJIT = !getenv("JavaScriptCoreUseJIT"); + CFRelease(canUseJITKey); +#elif OS(UNIX) + m_canUseJIT = !getenv("JavaScriptCoreUseJIT"); +#else + m_canUseJIT = true; +#endif +#endif +#if ENABLE(JIT) +#if ENABLE(INTERPRETER) + if (m_canUseJIT) + m_canUseJIT = executableAllocator.isValid(); +#endif + jitStubs = new JITThunks(this); +#endif } JSGlobalData::~JSGlobalData() @@ -189,28 +217,30 @@ JSGlobalData::~JSGlobalData() delete emptyList; delete propertyNames; - deleteIdentifierTable(identifierTable); + if (globalDataType != Default) + deleteIdentifierTable(identifierTable); delete clientData; + delete m_regExpCache; +#if ENABLE(REGEXP_TRACING) + delete m_rtTraceList; +#endif } -PassRefPtr<JSGlobalData> JSGlobalData::createNonDefault() +PassRefPtr<JSGlobalData> JSGlobalData::createContextGroup(ThreadStackType type) { - return adoptRef(new JSGlobalData(false)); + return adoptRef(new JSGlobalData(APIContextGroup, type)); } -PassRefPtr<JSGlobalData> JSGlobalData::create() +PassRefPtr<JSGlobalData> JSGlobalData::create(ThreadStackType type) { - JSGlobalData* globalData = new JSGlobalData(false); - setDefaultIdentifierTable(globalData->identifierTable); - setCurrentIdentifierTable(globalData->identifierTable); - return adoptRef(globalData); + return adoptRef(new JSGlobalData(Default, type)); } -PassRefPtr<JSGlobalData> JSGlobalData::createLeaked() +PassRefPtr<JSGlobalData> JSGlobalData::createLeaked(ThreadStackType type) { Structure::startIgnoringLeaks(); - RefPtr<JSGlobalData> data = create(); + RefPtr<JSGlobalData> data = create(type); Structure::stopIgnoringLeaks(); return data.release(); } @@ -224,7 +254,7 @@ JSGlobalData& JSGlobalData::sharedInstance() { JSGlobalData*& instance = sharedInstanceInternal(); if (!instance) { - instance = new JSGlobalData(true); + instance = adoptRef(new JSGlobalData(APIShared, ThreadStackTypeSmall)).leakRef(); #if ENABLE(JSC_MULTIPLE_THREADS) instance->makeUsableFromMultipleThreads(); #endif @@ -239,18 +269,16 @@ JSGlobalData*& JSGlobalData::sharedInstanceInternal() return sharedInstance; } -// FIXME: We can also detect forms like v1 < v2 ? -1 : 0, reverse comparison, etc. -const Vector<Instruction>& JSGlobalData::numericCompareFunction(ExecState* exec) +#if ENABLE(JIT) +PassRefPtr<NativeExecutable> JSGlobalData::getHostFunction(NativeFunction function) { - if (!lazyNumericCompareFunction.size() && !initializingLazyNumericCompareFunction) { - initializingLazyNumericCompareFunction = true; - RefPtr<FunctionExecutable> function = FunctionExecutable::fromGlobalCode(Identifier(exec, "numericCompare"), exec, 0, makeSource(UString("(function (v1, v2) { return v1 - v2; })")), 0, 0); - lazyNumericCompareFunction = function->bytecode(exec, exec->scopeChain()).instructions(); - initializingLazyNumericCompareFunction = false; - } - - return lazyNumericCompareFunction; + return jitStubs->hostFunctionStub(this, function); } +PassRefPtr<NativeExecutable> JSGlobalData::getHostFunction(NativeFunction function, ThunkGenerator generator) +{ + return jitStubs->hostFunctionStub(this, function, generator); +} +#endif JSGlobalData::ClientData::~ClientData() { @@ -261,6 +289,7 @@ void JSGlobalData::resetDateCache() cachedUTCOffset = NaN; dstOffsetCache.reset(); cachedDateString = UString(); + cachedDateStringValue = NaN; dateInstanceCache.reset(); } @@ -279,4 +308,38 @@ void JSGlobalData::dumpSampleData(ExecState* exec) interpreter->dumpSampleData(exec); } + +#if ENABLE(REGEXP_TRACING) +void JSGlobalData::addRegExpToTrace(PassRefPtr<RegExp> regExp) +{ + m_rtTraceList->add(regExp); +} + +void JSGlobalData::dumpRegExpTrace() +{ + // The first RegExp object is ignored. It is create by the RegExpPrototype ctor and not used. + RTTraceList::iterator iter = ++m_rtTraceList->begin(); + + if (iter != m_rtTraceList->end()) { + printf("\nRegExp Tracing\n"); + printf(" match() matches\n"); + printf("Regular Expression JIT Address calls found\n"); + printf("----------------------------------------+----------------+----------+----------\n"); + + unsigned reCount = 0; + + for (; iter != m_rtTraceList->end(); ++iter, ++reCount) + (*iter)->printTraceData(); + + printf("%d Regular Expressions\n", reCount); + } + + m_rtTraceList->clear(); +} +#else +void JSGlobalData::dumpRegExpTrace() +{ +} +#endif + } // namespace JSC |
