void MainResourceLoader::continueAfterNavigationPolicy(const ResourceRequest& request, bool shouldContinue) { if (!shouldContinue) stopLoadingForPolicyChange(); else if (m_substituteData.isValid()) { // A redirect resulted in loading substitute data. ASSERT(documentLoader()->timing()->redirectCount()); clearResource(); handleSubstituteDataLoadSoon(request); } deref(); // balances ref in willSendRequest }
void sprint_ivector(LispObj o) { LispObj header = header_of(o); unsigned elements = header_element_count(header), subtag = header_subtag(header); switch(subtag) { case subtag_simple_base_string: add_char('"'); add_lisp_base_string(o); add_char('"'); return; case subtag_bignum: if (elements == 1) { sprint_signed_decimal((signed_natural)(deref(o, 1))); return; } if ((elements == 2) && (deref(o, 2) == 0)) { sprint_unsigned_decimal(deref(o, 1)); return; } break; case subtag_double_float: break; case subtag_macptr: add_c_string("#<MACPTR "); sprint_unsigned_hex(deref(o,1)); add_c_string(">"); break; default: sprint_random_vector(o, subtag, elements); } }
void QualifiedName::externalDeref() { if(m_impl) { m_impl->m_prefix.externalDeref(); m_impl->m_localName.externalDeref(); m_impl->m_namespace.externalDeref(); } //m_impl->deref(); //m_impl = NULL; deref(); m_impl=NULL; }
// private methods void SocketStreamHandle::processMessageOnMainThread(StreamMessage msg) { switch (msg) { case DidOpen: ASSERT(m_state == Open); if (m_client) m_client->didOpenSocketStream(this); break; case DidFail: ASSERT(m_curl_code != CURLE_OK); LOG_CONNECT(Network, "SocketStreamHandleCurl: DidFail, error %d (%s), curl error buffer: %s [%p][thread=%d]\n", m_curl_code, curl_easy_strerror(m_curl_code), m_curl_error_buffer, this, GetCurrentThreadId()); if (m_client) m_client->didFailSocketStream(this, SocketStreamError(m_curl_code, m_url.isEmpty() ? String() : m_url.string())); break; case DidReceiveData: didReceiveData(); break; case DidSelectForWrite: { deref(); // this balances the ref() when spinning up the send wait thread. // LOG(Network, "SocketStreamHandleCurl: DidSelectForWrite [%p][thread=%d]\n", this, GetCurrentThreadId()); if (!m_platformCloseRequested) { if (m_curl_code == CURLE_OK) { sendPendingData(); } else if (m_client) { m_client->didFailSocketStream(this, SocketStreamError(m_curl_code, m_url.isEmpty() ? String() : m_url.string())); } } } break; case DidClose: disconnect(); break; case DidStopRecvLoop: deref(); // this balances the ref() in the constructor. break; } deref(); }
static bool read_base(SerdReader* reader) { // `@' is already eaten in read_directive eat_string(reader, "base", 4); TRY_RET(read_ws_plus(reader)); Ref uri; TRY_RET(uri = read_IRIREF(reader)); if (reader->base_sink) { reader->base_sink(reader->handle, deref(reader, uri)); } pop_node(reader, uri); return true; }
void OfflineAudioDestinationNode::offlineRender() { ASSERT(!isMainThread()); ASSERT(m_renderBus.get()); if (!m_renderBus.get()) return; bool isAudioContextInitialized = context().isInitialized(); ASSERT(isAudioContextInitialized); if (!isAudioContextInitialized) return; bool channelsMatch = m_renderBus->numberOfChannels() == m_renderTarget->numberOfChannels(); ASSERT(channelsMatch); if (!channelsMatch) return; bool isRenderBusAllocated = m_renderBus->length() >= renderQuantumSize; ASSERT(isRenderBusAllocated); if (!isRenderBusAllocated) return; // Break up the render target into smaller "render quantize" sized pieces. // Render until we're finished. size_t framesToProcess = m_renderTarget->length(); unsigned numberOfChannels = m_renderTarget->numberOfChannels(); unsigned n = 0; while (framesToProcess > 0) { // Render one render quantum. render(0, m_renderBus.get(), renderQuantumSize); size_t framesAvailableToCopy = std::min(framesToProcess, renderQuantumSize); for (unsigned channelIndex = 0; channelIndex < numberOfChannels; ++channelIndex) { const float* source = m_renderBus->channel(channelIndex)->data(); float* destination = m_renderTarget->getChannelData(channelIndex)->data(); memcpy(destination + n, source, sizeof(float) * framesAvailableToCopy); } n += framesAvailableToCopy; framesToProcess -= framesAvailableToCopy; } // Our work is done. Let the AudioContext know. callOnMainThread([this] { notifyComplete(); deref(); }); }
void PQdelete(Halfedge * he) { Halfedge *last; if (he->vertex != (Site *) NULL) { last = &PQhash[PQbucket(he)]; while (last->PQnext != he) last = last->PQnext; last->PQnext = he->PQnext; PQcount -= 1; deref(he->vertex); he->vertex = (Site *) NULL; } }
Statement::~Statement() { inDestructor=true; cleanup(); if(acquiredMutex){ qDebug("COULD DELETE Statement WITH MUTEX ACQUIRED. THIS IS A BUG."); connection->unlock(); } //qDebug("deleted statement"); deref(); }
static int isallone (int start) { const char * p; Exp * e; start = deref (start); if (start < 0) { e = exps - start; if (!strcmp (e->op, "zero")) return 1; if (!e->name) return 0; if (!strcmp (e->op, "const") || !strcmp (e->op, "consth") || !strcmp (e->op, "constx")) { for (p = e->name; *p; p++) if (*p != '0') return 0; return 1; } } else { e = exps + start; if (!e->name) return 0; if (!strcmp (e->op, "const") || (e->width == 1 && (!strcmp (e->op, "consth") || !strcmp (e->op, "constx")))) { for (p = e->name; *p; p++) if (*p != '1') return 0; return 1; } } return 0; }
void ResourceHandle::fileLoadTimer(Timer<ResourceHandle>*) { RefPtr<ResourceHandle> protector(this); deref(); // balances ref in start if (firstRequest().url().protocolIsData()) { handleDataURL(this); return; } String fileName = firstRequest().url().fileSystemPath(); HANDLE fileHandle = CreateFileW(fileName.charactersWithNullTermination(), GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (fileHandle == INVALID_HANDLE_VALUE) { client()->didFail(this, ResourceError()); return; } ResourceResponse response; int dotPos = fileName.reverseFind('.'); int slashPos = fileName.reverseFind('/'); if (slashPos < dotPos && dotPos != -1) { String ext = fileName.substring(dotPos + 1); response.setMimeType(MIMETypeRegistry::getMIMETypeForExtension(ext)); } client()->didReceiveResponse(this, response); bool result = false; DWORD bytesRead = 0; do { const int bufferSize = 8192; char buffer[bufferSize]; result = ReadFile(fileHandle, &buffer, bufferSize, &bytesRead, 0); // FIXME: https://bugs.webkit.org/show_bug.cgi?id=19793 // -1 means we do not provide any data about transfer size to inspector so it would use // Content-Length headers or content size to show transfer size. if (result && bytesRead) client()->didReceiveData(this, buffer, bytesRead, -1); // Check for end of file. } while (result && bytesRead); CloseHandle(fileHandle); client()->didFinishLoading(this, 0); }
void MemoryManager::free(Value val){ switch (val.type){ case ValType::String: strings.free(val); break; case ValType::BuiltinFunction: builtinFuns.free(val); break; case ValType::UserClosure: userClosures.free(val); break; case ValType::BuiltinClosure: builtinClosures.free(val); break; case ValType::Continuation: continuations.free(val); break; case ValType::Table: for (auto pair : get<Table>(val)){ deref(pair.second); } tables.free(val); default: return; } }
FILE *open_file(NODE *arg, char *access) { char *fnstr; FILE *tstrm; ref(arg); arg = reref(arg, cnv_node_to_strnode(arg)); if (arg == UNBOUND) return(NULL); fnstr = (char *) malloc((size_t)getstrlen(arg) + 1); strnzcpy(fnstr, getstrptr(arg), getstrlen(arg)); tstrm = fopen(fnstr, access); deref(arg); free(fnstr); return(tstrm); }
/* This is where the handling of expressions breaks down into string * processing: */ static void print_expression( struct fragment_program *p, GLuint i, const char *fmt, va_list ap ) { while (*fmt) { if (*fmt == '%' && *(fmt+1) == 's') { int reg = va_arg(ap, int); /* Use of deref() is a bit of a hack: */ print_arg( p, deref(reg, i) ); fmt += 2; } else {
void check(unsigned int mem, unsigned int expected_val) { if(mem == expected_val) { putc('Y', vga); put_hex(mem, vga + 2); put_hex(expected_val, vga + 14); vga += screen_width/4; } else { deref(0xddd00000) = 0; putc('N', vga); put_hex(mem, vga + 2); put_hex(expected_val, vga + 14); vga += screen_width/4; } }
void PluginView::unprotectPluginFromDestruction() { if (m_isBeingDestroyed) return; // A plug-in may ask us to evaluate JavaScript that removes the plug-in from the // page, but expect the object to still be alive when the call completes. Flash, // for example, may crash if the plug-in is destroyed and we return to code for // the destroyed object higher on the stack. To prevent this, if the plug-in has // only one remaining reference, call deref() asynchronously. if (hasOneRef()) RunLoop::main()->dispatch(bind(derefPluginView, this)); else deref(); }
static Ref pop_node(SerdReader* reader, Ref ref) { if (ref && ref != reader->rdf_first && ref != reader->rdf_rest && ref != reader->rdf_nil) { #ifdef SERD_STACK_CHECK SERD_STACK_ASSERT_TOP(reader, ref); --reader->n_allocs; #endif SerdNode* const node = deref(reader, ref); uint8_t* const top = reader->stack.buf + reader->stack.size; serd_stack_pop(&reader->stack, top - (uint8_t*)node); } return 0; }
void LayoutPart::destroy() { willBeDestroyed(); // We call clearNode here because LayoutPart is ref counted. This call to destroy // may not actually destroy the layout object. We can keep it around because of // references from the FrameView class. (The actual destruction of the class happens // in postDestroy() which is called from deref()). // // But, we've told the system we've destroyed the layoutObject, which happens when // the DOM node is destroyed. So there is a good change the DOM node this object // points too is invalid, so we have to clear the node so we make sure we don't // access it in the future. clearNode(); deref(); }
void V8AbstractEventListener::clearListenerObject() { if (!hasExistingListenerObject()) return; m_listener.clear(); if (m_workerGlobalScope) { m_workerGlobalScope->deregisterEventListener(this); } else { #if ENABLE(OILPAN) m_keepAlive.clear(); #else deref(); #endif } }
void ScriptStreamer::streamingComplete() { // The background task is completed; do the necessary ramp-down in the main // thread. ASSERT(isMainThread()); // It's possible that the corresponding Resource was deleted before V8 // finished streaming. In that case, the data or the notification is not // needed. In addition, if the streaming is suppressed, the non-streaming // code path will resume after the resource has loaded, before the // background task finishes. if (m_detached || m_streamingSuppressed) { deref(); return; } // We have now streamed the whole script to V8 and it has parsed the // script. We're ready for the next step: compiling and executing the // script. notifyFinishedToClient(); // The background thread no longer holds an implicit reference. deref(); }
void ScriptStreamer::notifyFinished(Resource* resource) { ASSERT(isMainThread()); ASSERT(m_resource == resource); // A special case: empty and small scripts. We didn't receive enough data to // start the streaming before this notification. In that case, there won't // be a "parsing complete" notification either, and we should not wait for // it. if (!m_haveEnoughDataForStreaming) { const char* histogramName = startedStreamingHistogramName(m_scriptType); blink::Platform::current()->histogramEnumeration(histogramName, 0, 2); suppressStreaming(); } if (m_stream) m_stream->didFinishLoading(); m_loadingFinished = true; if (shouldBlockMainThread()) { // Make the main thead wait until the streaming is complete, to make // sure that the script gets the main thread's attention as early as // possible (for possible compiling, if the client wants to do it // right away). Note that blocking here is not any worse than the // non-streaming code path where the main thread eventually blocks // to parse the script. TRACE_EVENT0("v8", "v8.mainThreadWaitingForParserThread"); MutexLocker locker(m_mutex); while (!isFinished()) { ASSERT(!m_parsingFinished); ASSERT(!m_streamingSuppressed); m_mainThreadWaitingForParserThread = true; m_parsingFinishedCondition.wait(m_mutex); } } // Calling notifyFinishedToClient can result into the upper layers dropping // references to ScriptStreamer. Keep it alive until this function ends. RefPtr<ScriptStreamer> protect(this); notifyFinishedToClient(); if (m_mainThreadWaitingForParserThread) { ASSERT(m_parsingFinished); ASSERT(!m_streamingSuppressed); // streamingComplete won't be called, so do the ramp-down work // here. deref(); } }
void print_lisp_frame(lisp_frame *frame) { LispObj fun = frame->savefn, pc = frame->savelr; int delta = 0; Dl_info info; char *spname; if ((fun == 0) || (fun == fulltag_misc)) { spname = "unknown ?"; #ifndef STATIC if (dladdr((void *)ptr_from_lispobj(pc), &info)) { spname = (char *)(info.dli_sname); #ifdef DARWIN if (spname[-1] != '_') { --spname; } #endif } #endif #ifdef PPC64 Dprintf("(#x%016lX) #x%016lX : (subprimitive %s)", frame, pc, spname); #else Dprintf("(#x%08X) #x%08X : (subprimitive %s)", frame, pc, spname); #endif } else { if ((fulltag_of(fun) != fulltag_misc) || (header_subtag(header_of(fun)) != subtag_function)) { #ifdef PPC64 Dprintf("(#x%016lX) #x%016lX : (not a function!)", frame, pc); #else Dprintf("(#x%08X) #x%08X : (not a function!)", frame, pc); #endif } else { LispObj code_vector = deref(fun, 1); if ((pc >= (code_vector+misc_data_offset)) && (pc < ((code_vector+misc_data_offset)+(header_element_count(header_of(code_vector))<<2)))) { delta = (pc - (code_vector+misc_data_offset)); } #ifdef PPC64 Dprintf("(#x%016lX) #x%016lX : %s + %d", frame, pc, print_lisp_object(fun), delta); #else Dprintf("(#x%08X) #x%08X : %s + %d", frame, pc, print_lisp_object(fun), delta); #endif } } }
static Ref read_BLANK_NODE_LABEL(SerdReader* reader, bool* ate_dot) { eat_byte_safe(reader, '_'); eat_byte_check(reader, ':'); Ref ref = push_node(reader, SERD_BLANK, reader->bprefix ? (char*)reader->bprefix : "", reader->bprefix_len); uint8_t c = peek_byte(reader); // First: (PN_CHARS | '_' | [0-9]) if (is_digit(c) || c == '_') { push_byte(reader, ref, eat_byte_safe(reader, c)); } else if (!read_PN_CHARS(reader, ref)) { r_err(reader, SERD_ERR_BAD_SYNTAX, "invalid name start character\n"); return pop_node(reader, ref); } while ((c = peek_byte(reader))) { // Middle: (PN_CHARS | '.')* if (c == '.') { push_byte(reader, ref, eat_byte_safe(reader, c)); } else if (!read_PN_CHARS(reader, ref)) { break; } } SerdNode* n = deref(reader, ref); if (n->buf[n->n_bytes - 1] == '.' && !read_PN_CHARS(reader, ref)) { // Ate trailing dot, pop it from stack/node and inform caller --n->n_bytes; serd_stack_pop(&reader->stack, 1); *ate_dot = true; } if (reader->syntax == SERD_TURTLE) { if (is_digit(n->buf[reader->bprefix_len + 1])) { if ((n->buf[reader->bprefix_len]) == 'b') { ((char*)n->buf)[reader->bprefix_len] = 'B'; // Prevent clash reader->seen_genid = true; } else if (reader->seen_genid && n->buf[reader->bprefix_len] == 'B') { r_err(reader, SERD_ERR_ID_CLASH, "found both `b' and `B' blank IDs, prefix required\n"); return pop_node(reader, ref); } } } return ref; }
//remove the HalfEdge from the list of vertices void VoronoiDiagramGenerator::PQdelete(struct VoronoiDiagramGenerator::Halfedge *he) { struct Halfedge *last; if(he -> vertex != (struct Site *) NULL) { last = &PQhash[PQbucket(he)]; while (last -> PQnext != he) last = last -> PQnext; last -> PQnext = he -> PQnext; PQcount -= 1; deref(he -> vertex); he -> vertex = (struct Site *) NULL; }; }
internal Type *canonical_type(Type *type, TypePool *pool) { type = deref(type); if (IS_VAR(type)) { return type; } if (type->symbol == SYMBOL_UNIT) { return pool->unit; } if (type->symbol == SYMBOL_NUMBER) { return pool->number; } if (type->symbol == SYMBOL_BOOL) { return pool->boolean; } }
void RenderWidget::destroy() { #if ENABLE(ASSERT) && ENABLE(OILPAN) ASSERT(!m_didCallDestroy); m_didCallDestroy = true; #endif willBeDestroyed(); clearNode(); #if ENABLE(OILPAN) // In Oilpan, postDestroy doesn't delete |this|. So calling it here is safe // though |this| will be referred in FrameView. postDestroy(); #else deref(); #endif }
void StatsManager::run() { qDebug() << "StatsManager thread starting up."; while (true) { m_statsPipeLock.lock(); m_statsPipeCondition.wait(&m_statsPipeLock); // We want to process reports even when we are about to quit since we // want to print the most accurate stat report on shutdown. processIncomingStatReports(); m_statsPipeLock.unlock(); if (deref(m_quit) == 1) { qDebug() << "StatsManager thread shutting down."; break; } } }
void MainResourceLoader::didCancel(const ResourceError& error) { m_dataLoadTimer.stop(); // Calling receivedMainResourceError will likely result in the last reference to this object to go away. RefPtr<MainResourceLoader> protect(this); if (m_waitingForContentPolicy) { frameLoader()->cancelContentPolicyCheck(); ASSERT(m_waitingForContentPolicy); m_waitingForContentPolicy = false; deref(); // balances ref in didReceiveResponse } frameLoader()->receivedMainResourceError(error, true); ResourceLoader::didCancel(error); }
void NetworkResourceLoader::cleanup() { ASSERT(RunLoop::isMain()); invalidateSandboxExtensions(); // Tell the scheduler about this finished loader soon so it can start more network requests. NetworkProcess::shared().networkResourceLoadScheduler().scheduleRemoveLoader(this); if (m_handle) { // Explicit deref() balanced by a ref() in NetworkResourceLoader::start() // This might cause the NetworkResourceLoader to be destroyed and therefore we do it last. m_handle = 0; deref(); } }
static inline void push_byte(SerdReader* reader, Ref ref, const uint8_t c) { #ifdef SERD_STACK_CHECK assert(stack_is_top_string(reader, ref)); #endif serd_stack_push(&reader->stack, 1); SerdString* const str = deref(reader, ref); ++str->n_bytes; if ((c & 0xC0) != 0x80) { // Does not start with `10', start of a new character ++str->n_chars; } assert(str->n_bytes >= str->n_chars); str->buf[str->n_bytes - 1] = c; str->buf[str->n_bytes] = '\0'; }
void NetworkResourceLoader::cleanup() { ASSERT(RunLoop::isMain()); m_bufferingTimer.stop(); invalidateSandboxExtensions(); NetworkProcess::shared().networkResourceLoadScheduler().removeLoader(this); if (m_handle) { // Explicit deref() balanced by a ref() in NetworkResourceLoader::start() // This might cause the NetworkResourceLoader to be destroyed and therefore we do it last. m_handle = 0; deref(); } }