void NetworkStorageSession::switchToNewTestingSession() { // Session name should be short enough for shared memory region name to be under the limit, otehrwise sandbox rules won't work (see <rdar://problem/13642852>). String sessionName = String::format("WebKit Test-%u", static_cast<uint32_t>(getCurrentProcessID())); #if PLATFORM(COCOA) defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get()))); #else defaultNetworkStorageSession() = std::make_unique<NetworkStorageSession>(SessionID::defaultSessionID(), adoptCF(wkCreatePrivateStorageSession(sessionName.createCFString().get(), defaultNetworkStorageSession()->platformSession()))); #endif }
String createCommandLineForLaunchingServer (const String& pipeName, const String& projectUID, const File& cacheLocation) { StringArray info; info.add (pipeName); info.add (projectUID); info.add (cacheLocation.getFullPathName()); #if JUCE_WINDOWS info.add (String::toHexString (getCurrentProcessID())); #endif const File exe (File::getSpecialLocation (File::currentExecutableFile).getFullPathName()); return "\"" + exe.getFullPathName() + "\" " + commandPrefix + info.joinIntoString (commandTokenSeparator); }
uint32_t ranval(ranctx* x) { spinLockLock(&x->lock); if (UNLIKELY(!x->initialized)) { x->initialized = true; char c; uint32_t seed = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&c)); seed ^= static_cast<uint32_t>(getCurrentProcessID()); x->a = 0xf1ea5eed; x->b = x->c = x->d = seed; for (int i = 0; i < 20; ++i) { (void) ranvalInternal(x); } } uint32_t ret = ranvalInternal(x); spinLockUnlock(&x->lock); return ret; }
static void methodCallCallback(GDBusConnection* connection, const char* sender, const char* objectPath, const char* interfaceName, const char* methodName, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer userData) { if (g_strcmp0(interfaceName, "org.webkit.gtk.WebExtensionTest")) return; if (!g_strcmp0(methodName, "GetTitle")) { uint64_t pageID; g_variant_get(parameters, "(t)", &pageID); WebKitWebPage* page = getWebPage(WEBKIT_WEB_EXTENSION(userData), pageID, invocation); if (!page) return; WebKitDOMDocument* document = webkit_web_page_get_dom_document(page); GUniquePtr<char> title(webkit_dom_document_get_title(document)); g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", title.get())); } else if (!g_strcmp0(methodName, "RunJavaScriptInIsolatedWorld")) { uint64_t pageID; const char* script; g_variant_get(parameters, "(t&s)", &pageID, &script); WebKitWebPage* page = getWebPage(WEBKIT_WEB_EXTENSION(userData), pageID, invocation); if (!page) return; GRefPtr<WebKitScriptWorld> world = adoptGRef(webkit_script_world_new()); g_assert(webkit_script_world_get_default() != world.get()); WebKitFrame* frame = webkit_web_page_get_main_frame(page); JSGlobalContextRef jsContext = webkit_frame_get_javascript_context_for_script_world(frame, world.get()); JSRetainPtr<JSStringRef> jsScript(Adopt, JSStringCreateWithUTF8CString(script)); JSEvaluateScript(jsContext, jsScript.get(), 0, 0, 0, 0); g_dbus_method_invocation_return_value(invocation, 0); } else if (!g_strcmp0(methodName, "AbortProcess")) { abort(); } else if (!g_strcmp0(methodName, "GetInitializationUserData")) { g_assert(initializationUserData); g_assert(g_variant_is_of_type(initializationUserData.get(), G_VARIANT_TYPE_STRING)); g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", g_variant_get_string(initializationUserData.get(), nullptr))); } else if (!g_strcmp0(methodName, "GetProcessIdentifier")) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(u)", static_cast<guint32>(getCurrentProcessID()))); } }
VM::VM(VMType vmType, HeapType heapType) : m_apiLock(adoptRef(new JSLock(this))) #if ENABLE(ASSEMBLER) , executableAllocator(*this) #endif , heap(this, heapType) , vmType(vmType) , clientData(0) , topVMEntryFrame(nullptr) , topCallFrame(CallFrame::noCaller()) , m_atomicStringTable(vmType == Default ? wtfThreadData().atomicStringTable() : new AtomicStringTable) , propertyNames(nullptr) , emptyList(new MarkedArgumentBuffer) , customGetterSetterFunctionMap(*this) , stringCache(*this) , prototypeMap(*this) , interpreter(0) , jsArrayClassInfo(JSArray::info()) , jsFinalObjectClassInfo(JSFinalObject::info()) , sizeOfLastScratchBuffer(0) , entryScope(0) , m_regExpCache(new RegExpCache(this)) #if ENABLE(REGEXP_TRACING) , m_rtTraceList(new RTTraceList()) #endif #if ENABLE(ASSEMBLER) , m_canUseAssembler(enableAssembler(executableAllocator)) #endif #if ENABLE(JIT) , m_canUseJIT(m_canUseAssembler && Options::useJIT()) #endif #if ENABLE(YARR_JIT) , m_canUseRegExpJIT(m_canUseAssembler && Options::useRegExpJIT()) #endif #if ENABLE(GC_VALIDATION) , m_initializingObjectClass(0) #endif , m_stackPointerAtVMEntry(0) , m_stackLimit(0) #if !ENABLE(JIT) , m_jsStackLimit(0) #endif #if ENABLE(FTL_JIT) , m_ftlStackLimit(0) , m_largestFTLStackSize(0) #endif , m_inDefineOwnProperty(false) , m_codeCache(std::make_unique<CodeCache>()) , m_enabledProfiler(nullptr) , m_builtinExecutables(std::make_unique<BuiltinExecutables>(*this)) , m_typeProfilerEnabledCount(0) , m_controlFlowProfilerEnabledCount(0) { interpreter = new Interpreter(*this); StackBounds stack = wtfThreadData().stack(); updateReservedZoneSize(Options::reservedZoneSize()); #if !ENABLE(JIT) interpreter->stack().setReservedZoneSize(Options::reservedZoneSize()); #endif setLastStackTop(stack.origin()); // Need to be careful to keep everything consistent here JSLockHolder lock(this); AtomicStringTable* existingEntryAtomicStringTable = wtfThreadData().setCurrentAtomicStringTable(m_atomicStringTable); propertyNames = new CommonIdentifiers(this); structureStructure.set(*this, Structure::createStructure(*this)); structureRareDataStructure.set(*this, StructureRareData::createStructure(*this, 0, jsNull())); terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull())); stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull())); notAnObjectStructure.set(*this, JSNotAnObject::createStructure(*this, 0, jsNull())); propertyNameEnumeratorStructure.set(*this, JSPropertyNameEnumerator::createStructure(*this, 0, jsNull())); getterSetterStructure.set(*this, GetterSetter::createStructure(*this, 0, jsNull())); customGetterSetterStructure.set(*this, CustomGetterSetter::createStructure(*this, 0, jsNull())); scopedArgumentsTableStructure.set(*this, ScopedArgumentsTable::createStructure(*this, 0, jsNull())); apiWrapperStructure.set(*this, JSAPIValueWrapper::createStructure(*this, 0, jsNull())); JSScopeStructure.set(*this, JSScope::createStructure(*this, 0, jsNull())); executableStructure.set(*this, ExecutableBase::createStructure(*this, 0, jsNull())); nativeExecutableStructure.set(*this, NativeExecutable::createStructure(*this, 0, jsNull())); evalExecutableStructure.set(*this, EvalExecutable::createStructure(*this, 0, jsNull())); programExecutableStructure.set(*this, ProgramExecutable::createStructure(*this, 0, jsNull())); functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, 0, jsNull())); #if ENABLE(WEBASSEMBLY) webAssemblyExecutableStructure.set(*this, WebAssemblyExecutable::createStructure(*this, 0, jsNull())); #endif moduleProgramExecutableStructure.set(*this, ModuleProgramExecutable::createStructure(*this, 0, jsNull())); regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull())); symbolStructure.set(*this, Symbol::createStructure(*this, 0, jsNull())); symbolTableStructure.set(*this, SymbolTable::createStructure(*this, 0, jsNull())); structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull())); sparseArrayValueMapStructure.set(*this, SparseArrayValueMap::createStructure(*this, 0, jsNull())); templateRegistryKeyStructure.set(*this, JSTemplateRegistryKey::createStructure(*this, 0, jsNull())); arrayBufferNeuteringWatchpointStructure.set(*this, ArrayBufferNeuteringWatchpoint::createStructure(*this)); unlinkedFunctionExecutableStructure.set(*this, UnlinkedFunctionExecutable::createStructure(*this, 0, jsNull())); unlinkedProgramCodeBlockStructure.set(*this, UnlinkedProgramCodeBlock::createStructure(*this, 0, jsNull())); unlinkedEvalCodeBlockStructure.set(*this, UnlinkedEvalCodeBlock::createStructure(*this, 0, jsNull())); unlinkedFunctionCodeBlockStructure.set(*this, UnlinkedFunctionCodeBlock::createStructure(*this, 0, jsNull())); unlinkedModuleProgramCodeBlockStructure.set(*this, UnlinkedModuleProgramCodeBlock::createStructure(*this, 0, jsNull())); propertyTableStructure.set(*this, PropertyTable::createStructure(*this, 0, jsNull())); weakMapDataStructure.set(*this, WeakMapData::createStructure(*this, 0, jsNull())); inferredValueStructure.set(*this, InferredValue::createStructure(*this, 0, jsNull())); inferredTypeStructure.set(*this, InferredType::createStructure(*this, 0, jsNull())); inferredTypeTableStructure.set(*this, InferredTypeTable::createStructure(*this, 0, jsNull())); functionRareDataStructure.set(*this, FunctionRareData::createStructure(*this, 0, jsNull())); generatorFrameStructure.set(*this, GeneratorFrame::createStructure(*this, 0, jsNull())); exceptionStructure.set(*this, Exception::createStructure(*this, 0, jsNull())); promiseDeferredStructure.set(*this, JSPromiseDeferred::createStructure(*this, 0, jsNull())); internalPromiseDeferredStructure.set(*this, JSInternalPromiseDeferred::createStructure(*this, 0, jsNull())); programCodeBlockStructure.set(*this, ProgramCodeBlock::createStructure(*this, 0, jsNull())); moduleProgramCodeBlockStructure.set(*this, ModuleProgramCodeBlock::createStructure(*this, 0, jsNull())); evalCodeBlockStructure.set(*this, EvalCodeBlock::createStructure(*this, 0, jsNull())); functionCodeBlockStructure.set(*this, FunctionCodeBlock::createStructure(*this, 0, jsNull())); #if ENABLE(WEBASSEMBLY) webAssemblyCodeBlockStructure.set(*this, WebAssemblyCodeBlock::createStructure(*this, 0, jsNull())); #endif iterationTerminator.set(*this, JSFinalObject::create(*this, JSFinalObject::createStructure(*this, 0, jsNull(), 1))); nativeStdFunctionCellStructure.set(*this, NativeStdFunctionCell::createStructure(*this, 0, jsNull())); smallStrings.initializeCommonStrings(*this); wtfThreadData().setCurrentAtomicStringTable(existingEntryAtomicStringTable); #if ENABLE(JIT) jitStubs = std::make_unique<JITThunks>(); allCalleeSaveRegisterOffsets = std::make_unique<RegisterAtOffsetList>(RegisterSet::vmCalleeSaveRegisters(), RegisterAtOffsetList::ZeroBased); #endif arityCheckData = std::make_unique<CommonSlowPaths::ArityCheckData>(); #if ENABLE(FTL_JIT) ftlThunks = std::make_unique<FTL::Thunks>(); #endif // ENABLE(FTL_JIT) interpreter->initialize(); #if ENABLE(JIT) initializeHostCallReturnValue(); // This is needed to convince the linker not to drop host call return support. #endif heap.notifyIsSafeToCollect(); LLInt::Data::performAssertions(*this); if (Options::useProfiler()) { m_perBytecodeProfiler = std::make_unique<Profiler::Database>(*this); StringPrintStream pathOut; const char* profilerPath = getenv("JSC_PROFILER_PATH"); if (profilerPath) pathOut.print(profilerPath, "/"); pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json"); m_perBytecodeProfiler->registerToSaveAtExit(pathOut.toCString().data()); } callFrameForCatch = nullptr; #if ENABLE(DFG_JIT) if (canUseJIT()) dfgState = std::make_unique<DFG::LongLivedState>(); #endif // Initialize this last, as a free way of asserting that VM initialization itself // won't use this. m_typedArrayController = adoptRef(new SimpleTypedArrayController()); m_bytecodeIntrinsicRegistry = std::make_unique<BytecodeIntrinsicRegistry>(*this); if (Options::useTypeProfiler()) enableTypeProfiler(); if (Options::useControlFlowProfiler()) enableControlFlowProfiler(); #if ENABLE(SAMPLING_PROFILER) if (Options::useSamplingProfiler()) { setShouldBuildPCToCodeOriginMapping(); m_samplingProfiler = adoptRef(new SamplingProfiler(*this, Stopwatch::create())); m_samplingProfiler->start(); } #endif // ENABLE(SAMPLING_PROFILER) if (Options::alwaysGeneratePCToCodeOriginMap()) setShouldBuildPCToCodeOriginMapping(); if (Options::watchdog()) { std::chrono::milliseconds timeoutMillis(Options::watchdog()); Watchdog& watchdog = ensureWatchdog(); watchdog.setTimeLimit(timeoutMillis); } }
VM::VM(VMType vmType, HeapType heapType) : m_apiLock(adoptRef(new JSLock(this))) #if ENABLE(ASSEMBLER) , executableAllocator(*this) #endif , heap(this, heapType) , vmType(vmType) , clientData(0) , topCallFrame(CallFrame::noCaller()) , arrayConstructorTable(fastNew<HashTable>(JSC::arrayConstructorTable)) , arrayPrototypeTable(fastNew<HashTable>(JSC::arrayPrototypeTable)) , booleanPrototypeTable(fastNew<HashTable>(JSC::booleanPrototypeTable)) , dateTable(fastNew<HashTable>(JSC::dateTable)) , dateConstructorTable(fastNew<HashTable>(JSC::dateConstructorTable)) , errorPrototypeTable(fastNew<HashTable>(JSC::errorPrototypeTable)) , globalObjectTable(fastNew<HashTable>(JSC::globalObjectTable)) , jsonTable(fastNew<HashTable>(JSC::jsonTable)) , mathTable(fastNew<HashTable>(JSC::mathTable)) , numberConstructorTable(fastNew<HashTable>(JSC::numberConstructorTable)) , numberPrototypeTable(fastNew<HashTable>(JSC::numberPrototypeTable)) , objectConstructorTable(fastNew<HashTable>(JSC::objectConstructorTable)) , privateNamePrototypeTable(fastNew<HashTable>(JSC::privateNamePrototypeTable)) , regExpTable(fastNew<HashTable>(JSC::regExpTable)) , regExpConstructorTable(fastNew<HashTable>(JSC::regExpConstructorTable)) , regExpPrototypeTable(fastNew<HashTable>(JSC::regExpPrototypeTable)) , stringConstructorTable(fastNew<HashTable>(JSC::stringConstructorTable)) , identifierTable(vmType == Default ? wtfThreadData().currentIdentifierTable() : createIdentifierTable()) , propertyNames(new CommonIdentifiers(this)) , emptyList(new MarkedArgumentBuffer) , parserArena(adoptPtr(new ParserArena)) , keywords(adoptPtr(new Keywords(this))) , interpreter(0) , jsArrayClassInfo(&JSArray::s_info) , jsFinalObjectClassInfo(&JSFinalObject::s_info) #if ENABLE(DFG_JIT) , sizeOfLastScratchBuffer(0) #endif , dynamicGlobalObject(0) , cachedUTCOffset(QNaN) , m_enabledProfiler(0) , m_regExpCache(new RegExpCache(this)) #if ENABLE(REGEXP_TRACING) , m_rtTraceList(new RTTraceList()) #endif #ifndef NDEBUG , exclusiveThread(0) #endif , m_newStringsSinceLastHashCons(0) #if ENABLE(ASSEMBLER) , m_canUseAssembler(enableAssembler(executableAllocator)) #endif #if ENABLE(JIT) , m_canUseJIT(m_canUseAssembler && Options::useJIT()) #endif #if ENABLE(YARR_JIT) , m_canUseRegExpJIT(m_canUseAssembler && Options::useRegExpJIT()) #endif #if ENABLE(GC_VALIDATION) , m_initializingObjectClass(0) #endif , m_inDefineOwnProperty(false) , m_codeCache(CodeCache::create()) { interpreter = new Interpreter(*this); // Need to be careful to keep everything consistent here JSLockHolder lock(this); IdentifierTable* existingEntryIdentifierTable = wtfThreadData().setCurrentIdentifierTable(identifierTable); structureStructure.set(*this, Structure::createStructure(*this)); structureRareDataStructure.set(*this, StructureRareData::createStructure(*this, 0, jsNull())); debuggerActivationStructure.set(*this, DebuggerActivation::createStructure(*this, 0, jsNull())); terminatedExecutionErrorStructure.set(*this, TerminatedExecutionError::createStructure(*this, 0, jsNull())); stringStructure.set(*this, JSString::createStructure(*this, 0, jsNull())); notAnObjectStructure.set(*this, JSNotAnObject::createStructure(*this, 0, jsNull())); propertyNameIteratorStructure.set(*this, JSPropertyNameIterator::createStructure(*this, 0, jsNull())); getterSetterStructure.set(*this, GetterSetter::createStructure(*this, 0, jsNull())); apiWrapperStructure.set(*this, JSAPIValueWrapper::createStructure(*this, 0, jsNull())); JSScopeStructure.set(*this, JSScope::createStructure(*this, 0, jsNull())); executableStructure.set(*this, ExecutableBase::createStructure(*this, 0, jsNull())); nativeExecutableStructure.set(*this, NativeExecutable::createStructure(*this, 0, jsNull())); evalExecutableStructure.set(*this, EvalExecutable::createStructure(*this, 0, jsNull())); programExecutableStructure.set(*this, ProgramExecutable::createStructure(*this, 0, jsNull())); functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, 0, jsNull())); regExpStructure.set(*this, RegExp::createStructure(*this, 0, jsNull())); sharedSymbolTableStructure.set(*this, SharedSymbolTable::createStructure(*this, 0, jsNull())); structureChainStructure.set(*this, StructureChain::createStructure(*this, 0, jsNull())); sparseArrayValueMapStructure.set(*this, SparseArrayValueMap::createStructure(*this, 0, jsNull())); withScopeStructure.set(*this, JSWithScope::createStructure(*this, 0, jsNull())); unlinkedFunctionExecutableStructure.set(*this, UnlinkedFunctionExecutable::createStructure(*this, 0, jsNull())); unlinkedProgramCodeBlockStructure.set(*this, UnlinkedProgramCodeBlock::createStructure(*this, 0, jsNull())); unlinkedEvalCodeBlockStructure.set(*this, UnlinkedEvalCodeBlock::createStructure(*this, 0, jsNull())); unlinkedFunctionCodeBlockStructure.set(*this, UnlinkedFunctionCodeBlock::createStructure(*this, 0, jsNull())); propertyTableStructure.set(*this, PropertyTable::createStructure(*this, 0, jsNull())); smallStrings.initializeCommonStrings(*this); wtfThreadData().setCurrentIdentifierTable(existingEntryIdentifierTable); #if ENABLE(JIT) jitStubs = adoptPtr(new JITThunks()); performPlatformSpecificJITAssertions(this); #endif interpreter->initialize(this->canUseJIT()); #if ENABLE(JIT) initializeHostCallReturnValue(); // This is needed to convince the linker not to drop host call return support. #endif heap.notifyIsSafeToCollect(); LLInt::Data::performAssertions(*this); if (Options::enableProfiler()) { m_perBytecodeProfiler = adoptPtr(new Profiler::Database(*this)); StringPrintStream pathOut; #if !OS(WINCE) const char* profilerPath = getenv("JSC_PROFILER_PATH"); if (profilerPath) pathOut.print(profilerPath, "/"); #endif pathOut.print("JSCProfile-", getCurrentProcessID(), "-", m_perBytecodeProfiler->databaseID(), ".json"); m_perBytecodeProfiler->registerToSaveAtExit(pathOut.toCString().data()); } #if ENABLE(DFG_JIT) if (canUseJIT()) m_dfgState = adoptPtr(new DFG::LongLivedState()); #endif }
static EncodedJSValue JSC_HOST_CALL functionGetPID(ExecState*) { return JSValue::encode(jsNumber(getCurrentProcessID())); }