void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString* errorString, const RefPtr<Inspector::InspectorArray>& locations, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>>& typeDescriptions) { static const bool verbose = false; VM& vm = globalVM(); typeDescriptions = Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>::create(); if (!vm.typeProfiler()) { *errorString = ASCIILiteral("The VM does not currently have Type Information."); return; } double start = currentTimeMS(); vm.typeProfilerLog()->processLogEntries(ASCIILiteral("User Query")); for (size_t i = 0; i < locations->length(); i++) { RefPtr<Inspector::InspectorValue> value = locations->get(i); RefPtr<InspectorObject> location; if (!value->asObject(&location)) { *errorString = ASCIILiteral("Array of TypeLocation objects has an object that does not have type of TypeLocation."); return; } int descriptor; String sourceIDAsString; int divot; location->getInteger(ASCIILiteral("typeInformationDescriptor"), &descriptor); location->getString(ASCIILiteral("sourceID"), &sourceIDAsString); location->getInteger(ASCIILiteral("divot"), &divot); bool okay; TypeLocation* typeLocation = vm.typeProfiler()->findLocation(divot, sourceIDAsString.toIntPtrStrict(&okay), static_cast<TypeProfilerSearchDescriptor>(descriptor)); RefPtr<Inspector::Protocol::Runtime::TypeDescription> description = Inspector::Protocol::Runtime::TypeDescription::create() .setIsValid(!!typeLocation); if (typeLocation) { RefPtr<TypeSet> typeSet; if (typeLocation->m_globalTypeSet && typeLocation->m_globalVariableID != TypeProfilerNoGlobalIDExists) typeSet = typeLocation->m_globalTypeSet; else typeSet = typeLocation->m_instructionTypeSet; description->setLeastCommonAncestor(typeSet->leastCommonAncestor()); description->setPrimitiveTypeNames(typeSet->allPrimitiveTypeNames()); description->setStructures(typeSet->allStructureRepresentations()); description->setTypeSet(typeSet->inspectorTypeSet()); description->setIsTruncated(typeSet->isOverflown()); } typeDescriptions->addItem(description); } double end = currentTimeMS(); if (verbose) dataLogF("Inspector::getRuntimeTypesForVariablesAtOffsets took %lfms\n", end - start); }
Decimal TimeInputType::defaultValueForStepUp() const { DateComponents date; date.setMillisecondsSinceMidnight(convertToLocalTime(currentTimeMS())); double milliseconds = date.millisecondsSinceEpoch(); DCHECK(std::isfinite(milliseconds)); return Decimal::fromDouble(milliseconds); }
static void _logUsageLocked() { double now = currentTimeMS(); if (now - s_lastLogged > 5) { s_lastLogged = now; ALOGV("Total memory usage: %d kb", s_totalAllocations / 1024); } }
void MHTMLArchive::generateMHTMLHeader( const String& boundary, const String& title, const String& mimeType, SharedBuffer& outputBuffer) { DateComponents now; now.setMillisecondsSinceEpochForDateTime(currentTimeMS()); // TODO(lukasza): Passing individual date/time components seems fragile. String dateString = makeRFC2822DateString( now.weekDay(), now.monthDay(), now.month(), now.fullYear(), now.hour(), now.minute(), now.second(), 0); StringBuilder stringBuilder; stringBuilder.appendLiteral("From: <Saved by Blink>\r\n"); stringBuilder.appendLiteral("Subject: "); // We replace non ASCII characters with '?' characters to match IE's behavior. stringBuilder.append(replaceNonPrintableCharacters(title)); stringBuilder.appendLiteral("\r\nDate: "); stringBuilder.append(dateString); stringBuilder.appendLiteral("\r\nMIME-Version: 1.0\r\n"); stringBuilder.appendLiteral("Content-Type: multipart/related;\r\n"); stringBuilder.appendLiteral("\ttype=\""); stringBuilder.append(mimeType); stringBuilder.appendLiteral("\";\r\n"); stringBuilder.appendLiteral("\tboundary=\""); stringBuilder.append(boundary); stringBuilder.appendLiteral("\"\r\n\r\n"); // We use utf8() below instead of ascii() as ascii() replaces CRLFs with ?? // (we still only have put ASCII characters in it). ASSERT(stringBuilder.toString().containsOnlyASCII()); CString asciiString = stringBuilder.toString().utf8(); outputBuffer.append(asciiString.data(), asciiString.length()); }
// ECMA 15.9.2 static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec) { VM& vm = exec->vm(); GregorianDateTime ts; msToGregorianDateTime(vm, currentTimeMS(), false, ts); return JSValue::encode(jsNontrivialString(&vm, formatDateTime(ts, DateTimeFormatDateAndTime, false))); }
void FileWriter::didWrite(long long bytes, bool complete) { if (m_operationInProgress == OperationAbort) { completeAbort(); return; } ASSERT(m_readyState == WRITING); ASSERT(m_truncateLength == -1); ASSERT(m_operationInProgress == OperationWrite); ASSERT(!m_bytesToWrite || bytes + m_bytesWritten > 0); ASSERT(bytes + m_bytesWritten <= m_bytesToWrite); m_bytesWritten += bytes; ASSERT((m_bytesWritten == m_bytesToWrite) || !complete); setPosition(position() + bytes); if (position() > length()) setLength(position()); if (complete) { m_blobBeingWritten.clear(); m_operationInProgress = OperationNone; } int numAborts = m_numAborts; // We could get an abort in the handler for this event. If we do, it's // already handled the cleanup and signalCompletion call. double now = currentTimeMS(); if (complete || !m_lastProgressNotificationTimeMS || (now - m_lastProgressNotificationTimeMS > progressNotificationIntervalMS)) { m_lastProgressNotificationTimeMS = now; fireEvent(EventTypeNames::progress); } if (complete) { if (numAborts == m_numAborts) signalCompletion(FileError::OK); } }
void PromiseTracker::didCreatePromise(const ScriptObject& promise) { ASSERT(isEnabled()); double timestamp = currentTimeMS(); m_promiseDataMap.set(promise, adoptRef(new PromiseData(promise, ScriptObject(), ScriptValue(), V8PromiseCustom::Pending, timestamp))); }
// static File* File::create( ExecutionContext* context, const HeapVector<ArrayBufferOrArrayBufferViewOrBlobOrUSVString>& fileBits, const String& fileName, const FilePropertyBag& options, ExceptionState& exceptionState) { ASSERT(options.hasType()); if (!options.type().containsOnlyASCII()) { exceptionState.throwDOMException( SyntaxError, "The 'type' property must consist of ASCII characters."); return nullptr; } double lastModified; if (options.hasLastModified()) lastModified = static_cast<double>(options.lastModified()); else lastModified = currentTimeMS(); ASSERT(options.hasEndings()); bool normalizeLineEndingsToNative = options.endings() == "native"; if (normalizeLineEndingsToNative) UseCounter::count(context, UseCounter::FileAPINativeLineEndings); std::unique_ptr<BlobData> blobData = BlobData::create(); blobData->setContentType(options.type().lower()); populateBlobData(blobData.get(), fileBits, normalizeLineEndingsToNative); long long fileSize = blobData->length(); return File::create(fileName, lastModified, BlobDataHandle::create(std::move(blobData), fileSize)); }
NativeImagePtr ImageBuffer::copyNativeImage(BackingStoreCopy copyBehavior) const { CGImageRef image = 0; if (!m_context->isAcceleratedContext()) { switch (copyBehavior) { case DontCopyBackingStore: image = CGImageCreate(internalSize().width(), internalSize().height(), 8, 32, m_data.m_bytesPerRow.unsafeGet(), m_data.m_colorSpace, m_data.m_bitmapInfo, m_data.m_dataProvider.get(), 0, true, kCGRenderingIntentDefault); break; case CopyBackingStore: image = CGBitmapContextCreateImage(context()->platformContext()); break; default: ASSERT_NOT_REACHED(); break; } } #if USE(IOSURFACE_CANVAS_BACKING_STORE) else { image = wkIOSurfaceContextCreateImage(context()->platformContext()); #if defined(BUILDING_ON_LION) m_data.m_lastFlushTime = currentTimeMS(); #endif } #endif return image; }
void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime(const FontResource* font) { if (m_fallbackPaintTime <= 0) return; int duration = static_cast<int>(currentTimeMS() - m_fallbackPaintTime); blink::Platform::current()->histogramCustomCounts("WebFont.BlankTextShownTime", duration, 0, 10000, 50); m_fallbackPaintTime = -1; }
void LayoutAnalyzer::reset() { m_startMs = currentTimeMS(); m_depth = 0; for (size_t i = 0; i < NumCounters; ++i) { m_counters[i] = 0; } }
GraphicsContext* ImageBuffer::context() const { #if defined(BUILDING_ON_LION) // Force a flush if last flush was more than 20ms ago if (m_context->isAcceleratedContext()) { double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime; double maxFlushInterval = 20; // in ms if (elapsedTime > maxFlushInterval) { CGContextRef context = m_context->platformContext(); CGContextFlush(context); m_data.m_lastFlushTime = currentTimeMS(); } } #endif return m_context.get(); }
long Timer::stop() { m_stopMS = currentTimeMS(); if (!m_isStarted) { // error("Timer is not started"); m_startMS = m_stopMS; } m_isStarted = false; return elapsed(); }
void TilesProfiler::start() { m_enabled = true; m_goodTiles = 0; m_badTiles = 0; m_records.clear(); m_time = currentTimeMS(); XLOG("initializing tileprofiling"); }
// ECMA 15.9.2 static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec) { GregorianDateTime ts; msToGregorianDateTime(exec, currentTimeMS(), false, ts); DateConversionBuffer date; DateConversionBuffer time; formatDate(ts, date); formatTime(ts, time); return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time)); }
PassRefPtr<ByteArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const { if (m_context->isAcceleratedContext()) { CGContextFlush(context()->platformContext()); #if defined(BUILDING_ON_LION) m_data.m_lastFlushTime = currentTimeMS(); #endif } return m_data.getData(rect, internalSize(), m_context->isAcceleratedContext(), false); }
void RemoteFontFaceSource::FontLoadHistograms::recordFallbackTime( const FontResource* font) { if (m_blankPaintTime <= 0) return; int duration = static_cast<int>(currentTimeMS() - m_blankPaintTime); DEFINE_STATIC_LOCAL(CustomCountHistogram, blankTextShownTimeHistogram, ("WebFont.BlankTextShownTime", 0, 10000, 50)); blankTextShownTimeHistogram.count(duration); m_blankPaintTime = -1; }
PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, CoordinateSystem coordinateSystem) const { if (m_context->isAcceleratedContext()) { CGContextFlush(context()->platformContext()); #if defined(BUILDING_ON_LION) m_data.m_lastFlushTime = currentTimeMS(); #endif } return m_data.getData(rect, internalSize(), m_context->isAcceleratedContext(), false, coordinateSystem == LogicalCoordinateSystem ? m_resolutionScale : 1); }
void Plan::compileInThread(LongLivedState& longLivedState, ThreadData* threadData) { this->threadData = threadData; double before = 0; if (reportCompileTimes()) before = currentTimeMS(); SamplingRegion samplingRegion("DFG Compilation (Plan)"); CompilationScope compilationScope; if (logCompilationChanges(mode)) dataLog("DFG(Plan) compiling ", *codeBlock, " with ", mode, ", number of instructions = ", codeBlock->instructionCount(), "\n"); CompilationPath path = compileInThreadImpl(longLivedState); RELEASE_ASSERT(finalizer); if (reportCompileTimes()) { const char* pathName; switch (path) { case FailPath: pathName = "N/A (fail)"; break; case DFGPath: pathName = "DFG"; break; case FTLPath: pathName = "FTL"; break; default: RELEASE_ASSERT_NOT_REACHED(); pathName = ""; break; } double now = currentTimeMS(); dataLog("Optimized ", *codeBlock, " using ", mode, " with ", pathName, " into ", finalizer->codeSize(), " bytes in ", now - before, " ms"); if (path == FTLPath) dataLog(" (DFG: ", beforeFTL - before, ", LLVM: ", now - beforeFTL, ")"); dataLog(".\n"); } }
void TypeProfilerLog::processLogEntries(const String& reason) { double before = 0; if (verbose) { dataLog("Process caller:'", reason, "'"); before = currentTimeMS(); } LogEntry* entry = m_logStartPtr; HashMap<Structure*, RefPtr<StructureShape>> seenShapes; while (entry != m_currentLogEntryPtr) { StructureID id = entry->structureID; RefPtr<StructureShape> shape; JSValue value = entry->value; Structure* structure = nullptr; if (id) { structure = Heap::heap(value.asCell())->structureIDTable().get(id); auto iter = seenShapes.find(structure); if (iter == seenShapes.end()) { shape = structure->toStructureShape(value); seenShapes.set(structure, shape); } else shape = iter->value; } RuntimeType type = runtimeTypeForValue(value); TypeLocation* location = entry->location; location->m_lastSeenType = type; if (location->m_globalTypeSet) location->m_globalTypeSet->addTypeInformation(type, shape, structure); location->m_instructionTypeSet->addTypeInformation(type, shape, structure); entry++; } m_currentLogEntryPtr = m_logStartPtr; if (verbose) { double after = currentTimeMS(); dataLogF(" Processing the log took: '%f' ms\n", after - before); } }
void FileReader::didReceiveData() { // Fire the progress event at least every 50ms. double now = currentTimeMS(); if (!m_lastProgressNotificationTimeMS) m_lastProgressNotificationTimeMS = now; else if (now - m_lastProgressNotificationTimeMS > progressNotificationIntervalMS) { fireEvent(EventTypeNames::progress); m_lastProgressNotificationTimeMS = now; } }
void V8File::lastModifiedAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info) { File* file = V8File::toNative(info.Holder()); double lastModified = file->lastModifiedDate(); if (!isValidFileTime(lastModified)) lastModified = currentTimeMS(); // lastModified returns a number, not a Date instance. // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs v8SetReturnValue(info, floor(lastModified)); }
void PaintTileOperation::endTime() { if (m_startTimeMS == 0.0) return; double timeDelta = currentTimeMS() - m_startTimeMS; m_startTimeMS = 0.0; #if ENABLE(IMPROVE_TEXTURES_GENERATOR_MULTI_CORE) TilesManager* tilesManager = TilesManager::instance(); bool supportMultiCoreTextGen = (tilesManager && tilesManager->supportMultiCoreTexturesGen()); XLOGD2("Support multi-thread texture generator = %d >> %f", supportMultiCoreTextGen, timeDelta); #else XLOGD2("%f", timeDelta); #endif }
Decimal TimeInputType::defaultValueForStepUp() const { double current = currentTimeMS(); int offset = calculateLocalTimeOffset(current).offset / msPerMinute; current += offset * msPerMinute; DateComponents date; date.setMillisecondsSinceMidnight(current); double milliseconds = date.millisecondsSinceEpoch(); ASSERT(std::isfinite(milliseconds)); return Decimal::fromDouble(milliseconds); }
double File::lastModifiedMS() const { if (hasValidSnapshotMetadata() && isValidFileTime(m_snapshotModificationTimeMS)) return m_snapshotModificationTimeMS; double modificationTimeMS; if (hasBackingFile() && getFileModificationTime(m_path, modificationTimeMS) && isValidFileTime(modificationTimeMS)) return modificationTimeMS; return currentTimeMS(); }
void PromiseTracker::didUpdatePromiseState(const ScriptObject& promise, V8PromiseCustom::PromiseState state, const ScriptValue& result) { ASSERT(isEnabled()); double timestamp = currentTimeMS(); RefPtr<PromiseData> data = m_promiseDataMap.get(promise); ASSERT(data != NULL && data->m_promise == promise); data->m_state = state; data->m_result = result; if (state == V8PromiseCustom::Fulfilled || state == V8PromiseCustom::Rejected) data->didSettlePromise(timestamp); }
long long File::lastModified() const { double modifiedDate = lastModifiedMS(); // The getter should return the current time when the last modification time // isn't known. if (!isValidFileTime(modifiedDate)) modifiedDate = currentTimeMS(); // lastModified returns a number, not a Date instance, // http://dev.w3.org/2006/webapi/FileAPI/#file-attrs return floor(modifiedDate); }
double File::lastModifiedDate() const { double modifiedDate = lastModifiedMS(); // The getter should return the current time when the last modification time // isn't known. if (!isValidFileTime(modifiedDate)) modifiedDate = currentTimeMS(); // lastModifiedDate returns a Date instance, // http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate return modifiedDate; }
int DateTimeYearFieldElement::defaultValueForStepDown() const { double current = currentTimeMS(); double utcOffset = calculateUTCOffset(); double dstOffset = calculateDSTOffset(current, utcOffset); int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute); current += offset * msPerMinute; DateComponents date; date.setMillisecondsSinceEpochForMonth(current); return date.fullYear(); }
static int currentFullYear() { double current = currentTimeMS(); double utcOffset = calculateUTCOffset(); double dstOffset = calculateDSTOffset(current, utcOffset); int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute); current += offset * msPerMinute; DateComponents date; date.setMillisecondsSinceEpochForMonth(current); return date.fullYear(); }