static assertFunction_Type handler( int nLevel) { handlerCollection_Type::const_iterator found = handlers().find( nLevel); if ( found != handlers().end() ) return found->second; else // we always assume the debug handler has been set return handlers().find( lvl_debug)->second; }
void Notifier::detach(Callback cb, Update::t n, void * rcvr){ if(hasHandlers()){ for(unsigned int i=0; i<handlers()[n].size(); i++){ Handler& h = handlers()[n][i]; if(h.handler == cb && h.receiver == rcvr) handlers()[n].erase(handlers()[n].begin() + i); } } }
void Notifier::notify(void * sender, Update::t n, void * data){ if(!hasHandlers() || handlers()[n].empty()) return; // call handlers in FIFO order int i=handlers()[n].size(); while(i--){ Handler& h = handlers()[n][i]; if(h.handler) h.handler(Notification(sender, h.receiver, data)); } }
tree connection_handlers (string name) { static hashmap<string,tree> handlers (tuple ()); if (!handlers->contains (name)) handlers (name)= stree_to_tree (call ("connection-get-handlers", name)); return handlers[name]; }
void syncmp_registry::pull_remote_choice() { for(syncmp_handler* phandler : handlers()) { phandler->pull_remote_choice(); } }
void syncmp_registry::send_user_choice() { for(syncmp_handler* phandler : handlers()) { phandler->send_user_choice(); } }
/*! Returns a deep-copied clone of the QUmlReadLinkObjectEndAction. */ QModelingElement *QUmlReadLinkObjectEndAction::clone() const { QUmlReadLinkObjectEndAction *c = new QUmlReadLinkObjectEndAction; c->asQModelingObject()->setObjectName(this->asQModelingObject()->objectName()); c->asQModelingObject()->setProperty("role", this->asQModelingObject()->property("role")); foreach (QUmlComment *element, ownedComments()) c->addOwnedComment(dynamic_cast<QUmlComment *>(element->clone())); c->setName(name()); if (nameExpression()) c->setNameExpression(dynamic_cast<QUmlStringExpression *>(nameExpression()->clone())); c->setVisibility(visibility()); c->setLeaf(isLeaf()); foreach (QUmlExceptionHandler *element, handlers()) c->addHandler(dynamic_cast<QUmlExceptionHandler *>(element->clone())); c->setLocallyReentrant(isLocallyReentrant()); foreach (QUmlConstraint *element, localPostconditions()) c->addLocalPostcondition(dynamic_cast<QUmlConstraint *>(element->clone())); foreach (QUmlConstraint *element, localPreconditions()) c->addLocalPrecondition(dynamic_cast<QUmlConstraint *>(element->clone())); if (object()) c->setObject(dynamic_cast<QUmlInputPin *>(object()->clone())); if (result()) c->setResult(dynamic_cast<QUmlOutputPin *>(result()->clone())); return c; }
Array AutoloadHandler::getHandlers() { if (!m_spl_stack_inited) { return null_array; } PackedArrayInit handlers(m_handlers.size()); for (const HandlerBundle& hb : m_handlers) { handlers.append(hb.m_handler); } return handlers.toArray(); }
//! @name Constructors and destructor //@{ Assert( const char * expr): SMART_ASSERT_A( *this), SMART_ASSERT_B( *this), M_needsHandling( true) { M_context.setExpression( expr); if ( ( logger() == 0) || handlers().size() < 4) { // used before main! Private::initAssert(); } }
MethodLiveness::MethodLiveness(Arena* arena, ciMethod* method) #ifdef COMPILER1 : _bci_block_start((uintptr_t*)arena->Amalloc((method->code_size() >> LogBitsPerByte) + 1), method->code_size()) #endif { _arena = arena; _method = method; _bit_map_size_bits = method->max_locals(); _bit_map_size_words = (_bit_map_size_bits / sizeof(unsigned int)) + 1; #ifdef COMPILER1 _bci_block_start.clear(); #endif } void MethodLiveness::compute_liveness() { #ifndef PRODUCT if (TraceLivenessGen) { tty->print_cr("################################################################"); tty->print("# Computing liveness information for "); method()->print_short_name(); } if (TimeLivenessAnalysis) _time_total.start(); #endif { TraceTime buildGraph(NULL, &_time_build_graph, TimeLivenessAnalysis); init_basic_blocks(); } { TraceTime genKill(NULL, &_time_gen_kill, TimeLivenessAnalysis); init_gen_kill(); } { TraceTime flow(NULL, &_time_flow, TimeLivenessAnalysis); propagate_liveness(); } #ifndef PRODUCT if (TimeLivenessAnalysis) _time_total.stop(); if (TimeLivenessAnalysis) { // Collect statistics _total_bytes += method()->code_size(); _total_methods++; int num_blocks = _block_count; _total_blocks += num_blocks; _max_method_blocks = MAX2(num_blocks,_max_method_blocks); for (int i=0; i<num_blocks; i++) { BasicBlock *block = _block_list[i]; int numEdges = block->_normal_predecessors->length(); int numExcEdges = block->_exception_predecessors->length(); _total_edges += numEdges; _total_exc_edges += numExcEdges; _max_block_edges = MAX2(numEdges,_max_block_edges); _max_block_exc_edges = MAX2(numExcEdges,_max_block_exc_edges); } int numLocals = _bit_map_size_bits; _total_method_locals += numLocals; _max_method_locals = MAX2(numLocals,_max_method_locals); } #endif } void MethodLiveness::init_basic_blocks() { bool bailout = false; int method_len = method()->code_size(); ciMethodBlocks *mblocks = method()->get_method_blocks(); // Create an array to store the bci->BasicBlock mapping. _block_map = new (arena()) GrowableArray<BasicBlock*>(arena(), method_len, method_len, NULL); _block_count = mblocks->num_blocks(); _block_list = (BasicBlock **) arena()->Amalloc(sizeof(BasicBlock *) * _block_count); // Used for patching up jsr/ret control flow. GrowableArray<BasicBlock*>* jsr_exit_list = new GrowableArray<BasicBlock*>(5); GrowableArray<BasicBlock*>* ret_list = new GrowableArray<BasicBlock*>(5); // generate our block list from ciMethodBlocks for (int blk = 0; blk < _block_count; blk++) { ciBlock *cib = mblocks->block(blk); int start_bci = cib->start_bci(); _block_list[blk] = new (arena()) BasicBlock(this, start_bci, cib->limit_bci()); _block_map->at_put(start_bci, _block_list[blk]); #ifdef COMPILER1 // mark all bcis where a new basic block starts _bci_block_start.set_bit(start_bci); #endif // COMPILER1 } // fill in the predecessors of blocks ciBytecodeStream bytes(method()); for (int blk = 0; blk < _block_count; blk++) { BasicBlock *current_block = _block_list[blk]; int bci = mblocks->block(blk)->control_bci(); if (bci == ciBlock::fall_through_bci) { int limit = current_block->limit_bci(); if (limit < method_len) { BasicBlock *next = _block_map->at(limit); assert( next != NULL, "must be a block immediately following this one."); next->add_normal_predecessor(current_block); } continue; } bytes.reset_to_bci(bci); Bytecodes::Code code = bytes.next(); BasicBlock *dest; // Now we need to interpret the instruction's effect // on control flow. assert (current_block != NULL, "we must have a current block"); switch (code) { case Bytecodes::_ifeq: case Bytecodes::_ifne: case Bytecodes::_iflt: case Bytecodes::_ifge: case Bytecodes::_ifgt: case Bytecodes::_ifle: case Bytecodes::_if_icmpeq: case Bytecodes::_if_icmpne: case Bytecodes::_if_icmplt: case Bytecodes::_if_icmpge: case Bytecodes::_if_icmpgt: case Bytecodes::_if_icmple: case Bytecodes::_if_acmpeq: case Bytecodes::_if_acmpne: case Bytecodes::_ifnull: case Bytecodes::_ifnonnull: // Two way branch. Set predecessors at each destination. dest = _block_map->at(bytes.next_bci()); assert(dest != NULL, "must be a block immediately following this one."); dest->add_normal_predecessor(current_block); dest = _block_map->at(bytes.get_dest()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); break; case Bytecodes::_goto: dest = _block_map->at(bytes.get_dest()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); break; case Bytecodes::_goto_w: dest = _block_map->at(bytes.get_far_dest()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); break; case Bytecodes::_tableswitch: { Bytecode_tableswitch *tableswitch = Bytecode_tableswitch_at(bytes.cur_bcp()); int len = tableswitch->length(); dest = _block_map->at(bci + tableswitch->default_offset()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); while (--len >= 0) { dest = _block_map->at(bci + tableswitch->dest_offset_at(len)); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); } break; } case Bytecodes::_lookupswitch: { Bytecode_lookupswitch *lookupswitch = Bytecode_lookupswitch_at(bytes.cur_bcp()); int npairs = lookupswitch->number_of_pairs(); dest = _block_map->at(bci + lookupswitch->default_offset()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); while(--npairs >= 0) { LookupswitchPair *pair = lookupswitch->pair_at(npairs); dest = _block_map->at( bci + pair->offset()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); } break; } case Bytecodes::_jsr: { assert(bytes.is_wide()==false, "sanity check"); dest = _block_map->at(bytes.get_dest()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); BasicBlock *jsrExit = _block_map->at(current_block->limit_bci()); assert(jsrExit != NULL, "jsr return bci must start a block."); jsr_exit_list->append(jsrExit); break; } case Bytecodes::_jsr_w: { dest = _block_map->at(bytes.get_far_dest()); assert(dest != NULL, "branch desination must start a block."); dest->add_normal_predecessor(current_block); BasicBlock *jsrExit = _block_map->at(current_block->limit_bci()); assert(jsrExit != NULL, "jsr return bci must start a block."); jsr_exit_list->append(jsrExit); break; } case Bytecodes::_wide: assert(false, "wide opcodes should not be seen here"); break; case Bytecodes::_athrow: case Bytecodes::_ireturn: case Bytecodes::_lreturn: case Bytecodes::_freturn: case Bytecodes::_dreturn: case Bytecodes::_areturn: case Bytecodes::_return: // These opcodes are not the normal predecessors of any other opcodes. break; case Bytecodes::_ret: // We will patch up jsr/rets in a subsequent pass. ret_list->append(current_block); break; case Bytecodes::_breakpoint: // Bail out of there are breakpoints in here. bailout = true; break; default: // Do nothing. break; } } // Patch up the jsr/ret's. We conservatively assume that any ret // can return to any jsr site. int ret_list_len = ret_list->length(); int jsr_exit_list_len = jsr_exit_list->length(); if (ret_list_len > 0 && jsr_exit_list_len > 0) { for (int i = jsr_exit_list_len - 1; i >= 0; i--) { BasicBlock *jsrExit = jsr_exit_list->at(i); for (int i = ret_list_len - 1; i >= 0; i--) { jsrExit->add_normal_predecessor(ret_list->at(i)); } } } // Compute exception edges. for (int b=_block_count-1; b >= 0; b--) { BasicBlock *block = _block_list[b]; int block_start = block->start_bci(); int block_limit = block->limit_bci(); ciExceptionHandlerStream handlers(method()); for (; !handlers.is_done(); handlers.next()) { ciExceptionHandler* handler = handlers.handler(); int start = handler->start(); int limit = handler->limit(); int handler_bci = handler->handler_bci(); int intersect_start = MAX2(block_start, start); int intersect_limit = MIN2(block_limit, limit); if (intersect_start < intersect_limit) { // The catch range has a nonempty intersection with this // basic block. That means this basic block can be an // exceptional predecessor. _block_map->at(handler_bci)->add_exception_predecessor(block); if (handler->is_catch_all()) { // This is a catch-all block. if (intersect_start == block_start && intersect_limit == block_limit) { // The basic block is entirely contained in this catch-all block. // Skip the rest of the exception handlers -- they can never be // reached in execution. break; } } } } } }
int Notifier::numObservers(Update::t n) const { if(hasHandlers()) return handlers()[n].size(); return 0; }
static void setHandler( int nLevel, assertFunction_Type handler) { handlers()[ nLevel] = handler; }
void Notifier::attach(Callback cb, Update::t n, void * rcvr){ handlers()[n].push_back(Handler(cb, rcvr)); }
void syncmp_registry::add_handler(syncmp_handler* handler) { t_handlers::iterator elem = std::find(handlers().begin(), handlers().end(), handler); assert(elem == handlers().end()); handlers().push_back(handler); }
void syncmp_registry::remove_handler(syncmp_handler* handler) { t_handlers::iterator elem = std::find(handlers().begin(), handlers().end(), handler); assert(elem != handlers().end()); handlers().erase(elem); }
void MethodLiveness::init_basic_blocks() { bool bailout = false; int method_len = method()->code_size(); // Create an array to store the bci->BasicBlock mapping. _block_map = new (arena()) GrowableArray<BasicBlock*>(arena(), method_len, method_len, NULL); _block_list = new (arena()) GrowableArray<BasicBlock*>(arena(), 128, 0, NULL); // Used for patching up jsr/ret control flow. GrowableArray<BasicBlock*>* jsr_exit_list = new GrowableArray<BasicBlock*>(5); GrowableArray<BasicBlock*>* ret_list = new GrowableArray<BasicBlock*>(5); // Make blocks begin at all exception handling instructions. { ciExceptionHandlerStream handlers(method()); for (; !handlers.is_done(); handlers.next()) { ciExceptionHandler* handler = handlers.handler(); int handler_bci = handler->handler_bci(); make_block_at(handler_bci, NULL); } } BasicBlock *current_block = NULL; ciByteCodeStream bytes(method()); Bytecodes::Code code; while ((code = bytes.next()) != ciByteCodeStream::EOBC && !bailout) { int bci = bytes.cur_bci(); // Should we start a new block here? BasicBlock *other = _block_map->at(bci); if (other == NULL) { // This bci has not yet been marked as the start of // a new basic block. If current_block is NULL, then // we are beginning a new block. Otherwise, we continue // with the old block. if (current_block == NULL) { // Make a new block with no predecessors. current_block = make_block_at(bci, NULL); } // Mark this index as belonging to the current block. _block_map->at_put(bci, current_block); } else { // This bci has been marked as the start of a new basic // block. if (current_block != NULL) { other->add_normal_predecessor(current_block); current_block->set_limit_bci(bci); } current_block = other; } // Now we need to interpret the instruction's effect // on control flow. switch (code) { assert (current_block != NULL, "we must have a current block"); case Bytecodes::_ifeq: case Bytecodes::_ifne: case Bytecodes::_iflt: case Bytecodes::_ifge: case Bytecodes::_ifgt: case Bytecodes::_ifle: case Bytecodes::_if_icmpeq: case Bytecodes::_if_icmpne: case Bytecodes::_if_icmplt: case Bytecodes::_if_icmpge: case Bytecodes::_if_icmpgt: case Bytecodes::_if_icmple: case Bytecodes::_if_acmpeq: case Bytecodes::_if_acmpne: case Bytecodes::_ifnull: case Bytecodes::_ifnonnull: // Two way branch. Make a new block at each destination. make_block_at(bytes.next_bci(), current_block); make_block_at(bytes.get_dest(), current_block); current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; case Bytecodes::_goto: make_block_at(bytes.get_dest(), current_block); current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; case Bytecodes::_goto_w: make_block_at(bytes.get_far_dest(), current_block); current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; case Bytecodes::_tableswitch: { Bytecode_tableswitch *tableswitch = Bytecode_tableswitch_at(bytes.cur_bcp()); int len = tableswitch->length(); make_block_at(bci + tableswitch->default_offset(), current_block); while (--len >= 0) { make_block_at(bci + tableswitch->dest_offset_at(len), current_block); } current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; } // Some synthetic opcodes here case Bytecodes::_fast_linearswitch: case Bytecodes::_fast_binaryswitch: case Bytecodes::_lookupswitch: { Bytecode_lookupswitch *lookupswitch = Bytecode_lookupswitch_at(bytes.cur_bcp()); int npairs = lookupswitch->number_of_pairs(); make_block_at(bci + lookupswitch->default_offset(), current_block); while(--npairs >= 0) { LookupswitchPair *pair = lookupswitch->pair_at(npairs); make_block_at(bci + pair->offset(), current_block); } current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; } case Bytecodes::_jsr: { assert(bytes.is_wide()==false, "sanity check"); make_block_at(bytes.get_dest(), current_block); BasicBlock *jsrExit = make_block_at(bci + 3, NULL); jsr_exit_list->append(jsrExit); current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; } case Bytecodes::_jsr_w: { make_block_at(bytes.get_far_dest(), current_block); BasicBlock *jsrExit = make_block_at(bci + 5, NULL); jsr_exit_list->append(jsrExit); current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; } case Bytecodes::_wide: assert(false, "wide opcodes should not be seen here"); break; case Bytecodes::_athrow: case Bytecodes::_ireturn: case Bytecodes::_lreturn: case Bytecodes::_freturn: case Bytecodes::_dreturn: case Bytecodes::_areturn: case Bytecodes::_return: // We are done with the current block. These opcodes are // not the normal predecessors of any other opcodes. current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; case Bytecodes::_ret: // We will patch up jsr/rets in a subsequent pass. ret_list->append(current_block); current_block->set_limit_bci(bytes.next_bci()); current_block = NULL; break; case Bytecodes::_breakpoint: // Bail out of there are breakpoints in here. bailout = true; break; default: // Do nothing. break; } } if (bailout) { _block_list->clear(); _block_map = NULL; // do not use this field now! return; } // Patch up the jsr/ret's. We conservatively assume that any ret // can return to any jsr site. int ret_list_len = ret_list->length(); int jsr_exit_list_len = jsr_exit_list->length(); if (ret_list_len > 0 && jsr_exit_list_len > 0) { for (int i = jsr_exit_list_len - 1; i >= 0; i--) { BasicBlock *jsrExit = jsr_exit_list->at(i); for (int i = ret_list_len - 1; i >= 0; i--) { jsrExit->add_normal_predecessor(ret_list->at(i)); } } } // Compute exception edges. for (int b=_block_list->length()-1; b >= 0; b--) { BasicBlock *block = _block_list->at(b); int block_start = block->start_bci(); int block_limit = block->limit_bci(); ciExceptionHandlerStream handlers(method()); for (; !handlers.is_done(); handlers.next()) { ciExceptionHandler* handler = handlers.handler(); int start = handler->start(); int limit = handler->limit(); int handler_bci = handler->handler_bci(); int intersect_start = MAX2(block_start, start); int intersect_limit = MIN2(block_limit, limit); if (intersect_start < intersect_limit) { // The catch range has a nonempty intersection with this // basic block. That means this basic block can be an // exceptional predecessor. _block_map->at(handler_bci)->add_exception_predecessor(block); if (handler->is_catch_all()) { // This is a catch-all block. if (intersect_start == block_start && intersect_limit == block_limit) { // The basic block is entirely contained in this catch-all block. // Skip the rest of the exception handlers -- they can never be // reached in execution. break; } } } } } }
int init(int argc, char **argv, char **home, struct edes_params *edes, char *buffer) { size_t edes_len; FILE *cfp; int i, j, k, nsys, sint, datlen, rev; char *log = NULL, *dbspec = DEFAULT_DBSPEC, *mapname; int debug = NRTS_DEFLOG; int to = NRTS_DEFTCPTO; char *system[MAXSYS]; char fname[MAXPATHLEN+1]; struct nrts_files *file; struct xfer_packet *packet; struct rlimit rlimit; DBIO *db; int nice, nerror; ISI_STREAM_NAME name; ISI_COORDS coords; ISI_INST inst; BOOL dump, incomplete; static char PeerString[MAXPATHLEN], *peer; static char *fid = "init"; *home = NULL; nice = 1; dump = FALSE; /* Get command line arguments */ for (i = 1; i < argc; i++) { if (strncmp(argv[i], "db=", strlen("db=")) == 0) { dbspec = argv[i] + strlen("db="); } else if (strncmp(argv[i], "home=", strlen("home=")) == 0) { *home = argv[i] + strlen("home="); } else if (strncmp(argv[i], "debug=", strlen("debug=")) == 0) { debug = atoi(argv[i]+strlen("debug=")); } else if (strncmp(argv[i], "log=", strlen("log=")) == 0) { log = argv[i] + strlen("log="); } else if (strncmp(argv[i], "to=", strlen("to=")) == 0) { to = atoi(argv[i] + strlen("to=")); } else if (strcasecmp(argv[i], "+dbd") == 0) { dump = TRUE; } else if (strcasecmp(argv[i], "-dbd") == 0) { dump = FALSE; } else if (strcmp(argv[i], "config") == 0) { fprintf(stderr, "nrts_edes config is no longer required\n"); exit(0); } else if (strcmp(argv[i], "+nice") == 0) { nice = 1; } else if (strcmp(argv[i], "-nice") == 0) { nice = 0; } else { xfer_errno = XFER_EFAULT; return -1; } } /* Determine working home */ if (*home == NULL) { *home = getenv(NRTS_HOME); } if (*home == NULL) { *home = NRTS_DEFHOME; } /* Start logging facility */ peer = util_peer(fileno(stdin), PeerString, MAXPATHLEN); if (peer != NULL) { if (NotOnSilentList(peer)) { util_logopen(log, 1, NRTS_MAXLOG, debug, NULL, argv[0]); util_log(2, VersionIdentString); util_log(2, "Connection from %s", PeerString); } } else { util_logopen(log, 1, NRTS_MAXLOG, debug, NULL, argv[0]); util_log(2, VersionIdentString); util_log(2, "Connection from <can't determine peer string>\n"); } if (chdir(*home) != 0) { util_log(1, "%s: can't chdir %s: %s", fid, *home, syserrmsg(errno)); xfer_errno = XFER_EFAULT; return -2; } /* Connect to database */ if ((db = dbioOpen(dbspec, NULL)) == NULL) { util_log(1, "dbioOpen failed"); return -3; } /* Set niceness */ set_wait_flag(nice); /* Initialize Xfer routines */ if (Xfer_ServInit(*home, to) != XFER_OK) { util_log(1, "%s: Xfer_ServInit: %s", fid, Xfer_ErrStr()); xfer_errno = XFER_EFAULT; return -4; } /* Check implementation limits */ if (XFER_SNAMLEN < NRTS_SNAMLEN) { util_log(1, "%s: increase XFER_SNAMLEN", fid); xfer_errno = XFER_ELIMIT; return -5; } if (XFER_CNAMLEN < NRTS_CNAMLEN) { util_log(1, "%s: increase XFER_CNAMLEN", fid); xfer_errno = XFER_ELIMIT; return -6; } if (XFER_INAMLEN < NRTS_INAMLEN) { util_log(1, "%s: increase XFER_INAMLEN", fid); xfer_errno = XFER_ELIMIT; return -7; } if (XFER_MAXSTA < NRTS_MAXSTA) { util_log(1, "%s: increase XFER_MAXSTA", fid); xfer_errno = XFER_ELIMIT; return -8; } if (XFER_MAXCHN < NRTS_MAXCHN) { util_log(1, "%s: increase XFER_MAXCHN", fid); xfer_errno = XFER_ELIMIT; return -9; } /* Get info about all supported systems */ if ((nsys = nrts_systems(*home, system, MAXSYS)) < 0) { util_log(1, "%s: nrts_systems: status %d", fid, nsys); xfer_errno = XFER_EFAULT; return -10; } edes->tstamp = time(NULL); edes->nsys = nsys; edes->isd = fileno(stdin); edes->osd = fileno(stdout); utilSetNonBlockingSocket(edes->isd); utilSetNonBlockingSocket(edes->osd); /* Set the resource limits for number of open files to the max */ if (getrlimit(RLIMIT_NOFILE, &rlimit) != 0) { util_log(1, "can't get resource limits: %s", syserrmsg(errno)); xfer_errno = XFER_EFAULT; return -11; } rlimit.rlim_cur = rlimit.rlim_max; if (setrlimit(RLIMIT_NOFILE, &rlimit) != 0) { util_log(1, "can't set resource limits: %s", syserrmsg(errno)); xfer_errno = XFER_EFAULT; return -12; } /* Get NRTS system information for everything on this host */ for (nerror = 0, i = 0; i < edes->nsys; i++) { /* Determine dl file names for this system */ file = nrts_files(home, system[i]); /* Get mmapd NRTS system descriptor */ if (nrts_mmap(file->sys, "r", NRTS_SYSTEM, edes->map + i) != 0) { util_log(1, "%s: nrts_mmap: %s: %s", fid, system[i], syserrmsg(errno) ); xfer_errno = XFER_EFAULT; return -13; } *(SYS) = *((struct nrts_sys *) edes->map[i].ptr); if (SYS->nsta != 1) { util_log(1, "%s: %s has %d stations, not allowed", fid, system[i], SYS->nsta); return -14; } /* Open dl header file */ if ((edes->inf[i].hfd = open(file->hdr, O_RDONLY)) < 0) { util_log(1, "%s: can't open dl hdr file `%s': %s", fid, file->hdr, syserrmsg(errno) ); xfer_errno = XFER_EFAULT; return -15; } /* Open dl data file */ if ((edes->inf[i].dfd = open(file->dat, O_RDONLY)) < 0) { util_log(1, "%s: can't open dl dat file `%s': %s", fid, file->dat, syserrmsg(errno) ); xfer_errno = XFER_EFAULT; return -16; } /* Determine raw packet decoders */ switch (SYS->type) { case NRTS_IDA: edes->decode[i] = ida_decode; rev = ((struct nrts_ida *) SYS->info)->rev; mapname = ((struct nrts_ida *) SYS->info)->map; ida_decode_init(dump); break; case NRTS_IDA10: edes->decode[i] = ida10_decode; rev = 10; mapname = NULL; ida10_decode_init(dump); break; default: util_log(1, "%s: unsupported system `%d'", fid, SYS->type); xfer_errno = XFER_EFAULT; return -17; } if ((edes->inf[i].ida = idaCreateHandle(SYS->sta[0].name, rev, mapname, db, NULL, 0)) == NULL) { util_log(1, "%s: idaCreateHandle failed for site %s, rev %d", fid, SYS->sta[0].name, rev); return -18; } /* Load static parameters from the database */ for (j = 0; j < SYS->nsta; j++) { isidbLookupCoords(db, SSTA->name, (UINT32) edes->tstamp, &coords); CSTA->lat = coords.lat; CSTA->lon = coords.lon; CSTA->elev = coords.elev; CSTA->depth = coords.depth; for (k = 0; k < SSTA->nchn; k++) { incomplete = FALSE; isiStaChnLocToStreamName(SSTA->name, SCHN->name, NULL, &name); isidbLookupInst(db, &name, (UINT32) edes->tstamp, &inst); CCHN->calib = inst.calib; CCHN->calper = inst.calper; CCHN->hang = inst.hang; CCHN->vang = inst.vang; memcpy(CCHN->instype, inst.type, NRTS_INAMLEN); CCHN->instype[NRTS_INAMLEN] = 0; if (!isidbLookupSint(db, &name, &sint)) { incomplete = TRUE; } else if (!isidbLookupDatlen(db, &name, &datlen)) { incomplete = TRUE; } else if (!isidbLookupWrdsiz(db, &name, &CCHN->wrdsiz)) { incomplete = TRUE; } if (incomplete) { util_log(1, "WARNING: incomplete sint map for %s:%s", SSTA->name, SCHN->name); ++nerror; } else { CCHN->sint = (float) sint / 1000.0; CCHN->order = util_order(); CCHN->paklen = CCHN->sint * (datlen / CCHN->wrdsiz); } } } } if (nerror != 0) { util_log(1, "ERROR - incomplete sint database"); xfer_errno = XFER_EFAULT; return -19; } /* Load server specific signal handlers */ if (handlers(fileno(stdout)) != 0) { util_log(1, "%s: load signal handler(s): %s", fid, *home, syserrmsg(errno)); xfer_errno = XFER_EFAULT; return -20; } return 0; }
//----------------------------catch_inline_exceptions-------------------------- // Handle all exceptions thrown by an inlined method or individual bytecode. // Common case 1: we have no handler, so all exceptions merge right into // the rethrow case. // Case 2: we have some handlers, with loaded exception klasses that have // no subklasses. We do a Deutsch-Shiffman style type-check on the incoming // exception oop and branch to the handler directly. // Case 3: We have some handlers with subklasses or are not loaded at // compile-time. We have to call the runtime to resolve the exception. // So we insert a RethrowCall and all the logic that goes with it. void Parse::catch_inline_exceptions(SafePointNode* ex_map) { // Caller is responsible for saving away the map for normal control flow! assert(stopped(), "call set_map(NULL) first"); assert(method()->has_exception_handlers(), "don't come here w/o work to do"); Node* ex_node = saved_ex_oop(ex_map); if (ex_node == top()) { // No action needed. return; } const TypeInstPtr*ex_type=_gvn.type(ex_node)->is_instptr(); // determine potential exception handlers ciExceptionHandlerStream handlers(method(), bci(), ex_type->klass()->as_instance_klass(), ex_type->klass_is_exact()); // Start executing from the given throw state. (Keep its stack, for now.) // Get the exception oop as known at compile time. ex_node = use_exception_state(ex_map); // Get the exception oop klass from its header const TypeOopPtr *toop = ex_node->bottom_type()->is_oopptr(); const TypeKlassPtr *tkid = TypeKlassPtr::make_kid(toop->klass(),toop->klass_is_exact()); Node*ex_kid_node=_gvn.transform(new(C,2)GetKIDNode(control(),ex_node,tkid)); // Have handlers and the exception klass is not exact? It might be the // merging of many exact exception klasses (happens alot with nested inlined // throw/catch blocks). if (has_ex_handler() && !ex_type->klass_is_exact()) { // Compute the exception klass a little more cleverly. // Obvious solution is to simple do a GetKlass from the 'ex_node'. // However, if the ex_node is a PhiNode, I'm going to do a GetKlass for // each arm of the Phi. If I know something clever about the exceptions // I'm loading the class from, I can replace the GetKlass with the // klass constant for the exception oop. if( ex_node->is_Phi() ) { ex_kid_node=new(C,ex_node->req())PhiNode(ex_node->in(0),TypeKlassPtr::KID); for( uint i = 1; i < ex_node->req(); i++ ) { const TypeOopPtr *toopi = ex_node->in(i)->bottom_type()->is_oopptr(); const TypeKlassPtr *tkidi = TypeKlassPtr::make_kid(toop->klass(),toop->klass_is_exact()); Node *kid = _gvn.transform(new (C, 2) GetKIDNode(ex_node->in(0)->in(i), ex_node->in(i),tkidi)); ex_kid_node->init_req(i,kid); } _gvn.set_type(ex_kid_node,TypeKlassPtr::KID); } } // Scan the exception table for applicable handlers. // If none, we can call rethrow() and be done! // If precise (loaded with no subklasses), insert a D.S. style // pointer compare to the correct handler and loop back. // If imprecise, switch to the Rethrow VM-call style handling. int remaining = handlers.count_remaining(); // iterate through all entries sequentially ciInstanceKlass*handler_catch_klass=NULL; for (;!handlers.is_done(); handlers.next()) { // Do nothing if turned off if( !DeutschShiffmanExceptions ) break; ciExceptionHandler* handler = handlers.handler(); if (handler->is_rethrow()) { // If we fell off the end of the table without finding an imprecise // exception klass (and without finding a generic handler) then we // know this exception is not handled in this method. We just rethrow // the exception into the caller. throw_to_exit(make_exception_state(ex_node)); return; } // exception handler bci range covers throw_bci => investigate further int handler_bci = handler->handler_bci(); if (remaining == 1) { push_ex_oop(ex_node); // Push exception oop for handler merge_exception(handler_bci); // jump to handler return; // No more handling to be done here! } handler_catch_klass=handler->catch_klass(); if(!handler_catch_klass->is_loaded())//klass is not loaded? break; // Must call Rethrow! // Sharpen handler klass. Some klasses cannot have any oops // (e.g. interface with no implementations). const TypePtr* tpx = TypeOopPtr::make_from_klass_unique(handler_catch_klass); const TypeOopPtr *tp = tpx->isa_oopptr(); // Oop of this klass is possible? Node *handler_klass = tp ? _gvn.makecon( TypeKlassPtr::make_kid(tp->klass(),true) ) : NULL; Node *failure = gen_subtype_check( ex_kid_node, handler_klass, _gvn.type(ex_node) ); { PreserveJVMState pjvms(this); Node*ex_oop=_gvn.transform(new(C,2)CheckCastPPNode(control(),ex_node,tpx)); push_ex_oop(ex_oop); // Push exception oop for handler merge_exception(handler_bci); } // Come here if exception does not match handler. // Carry on with more handler checks. set_control(failure); --remaining; } assert(!stopped(), "you should return if you finish the chain"); if (remaining == 1) { // Further checks do not matter. } if (can_rerun_bytecode()) { // Do not push_ex_oop here! // Re-executing the bytecode will reproduce the throwing condition. bool must_throw = true; uncommon_trap(Deoptimization::Reason_unloaded,handler_catch_klass,"matching handler klass not loaded", must_throw); return; } // Oops, need to call into the VM to resolve the klasses at runtime. // Note: This call must not deoptimize, since it is not a real at this bci! kill_dead_locals(); make_runtime_call(RC_NO_LEAF | RC_MUST_THROW, false /* !must_callruntimenode */, OptoRuntime::forward_exception2_Type(), StubRoutines::forward_exception_entry2(), "forward_exception2", TypeRawPtr::BOTTOM, // sets the exception oop back into thr->_pending_ex ex_node); // Rethrow is a pure call, no side effects, only a result. // The result cannot be allocated, so we use I_O // Catch exceptions from the rethrow catch_call_exceptions(handlers); }
static void _sql(Request& r, MethodParams& params) { Value& statement=params.as_junction(0, "statement must be code"); HashStringValue* bind=0; ulong limit=SQL_NO_LIMIT; ulong offset=0; bool distinct=false; Table2hash_value_type value_type=C_HASH; if(params.count()>1) if(HashStringValue* options=params.as_hash(1, "sql options")) { int valid_options=0; if(Value* vbind=options->get(sql_bind_name)) { valid_options++; bind=vbind->get_hash(); } if(Value* vlimit=options->get(sql_limit_name)) { valid_options++; limit=(ulong)r.process_to_value(*vlimit).as_double(); } if(Value* voffset=options->get(sql_offset_name)) { valid_options++; offset=(ulong)r.process_to_value(*voffset).as_double(); } if(Value* vdistinct=options->get(sql_distinct_name)) { valid_options++; distinct=r.process_to_value(*vdistinct).as_bool(); } if(Value* vvalue_type=options->get(sql_value_type_name)) { valid_options++; value_type=get_value_type(r.process_to_value(*vvalue_type)); } if(valid_options!=options->count()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); } SQL_Driver::Placeholder* placeholders=0; uint placeholders_count=0; if(bind) placeholders_count=marshal_binds(*bind, placeholders); Temp_lang temp_lang(r, String::L_SQL); const String& statement_string=r.process_to_string(statement); const char* statement_cstr=statement_string.untaint_cstr(r.flang, r.connection()); HashStringValue& hash=GET_SELF(r, VHash).hash(); hash.clear(); Hash_sql_event_handlers handlers( statement_string, statement_cstr, distinct, hash, value_type); r.connection()->query( statement_cstr, placeholders_count, placeholders, offset, limit, handlers, statement_string); if(bind) unmarshal_bind_updates(*bind, placeholders_count, placeholders); }
int MulticastClientTransport::send( ClientTransportCallback & clientStub, const std::vector<ByteBuffer> & data, unsigned int timeoutMs) { // NB: As the same buffer is sent on all transports, the transports and // filters should never modify the buffer. Any transport that transforms // data needs to do so in a separate per-transport buffer. RCF_UNUSED_VARIABLE(timeoutMs); RCF_LOG_2()(lengthByteBuffers(data))(timeoutMs) << "MulticastClientTransport::send() - entry."; mLastRequestSize = lengthByteBuffers(data); mRunningTotalBytesSent += mLastRequestSize; bringInNewTransports(); Lock lock(mClientTransportsMutex); std::size_t transportsInitial = mClientTransports.size(); PublishCompletionInfo info( mClientTransports.size() ); // Setup completion handlers. std::vector<PublishCompletionHandler> handlers( mClientTransports.size() ); for (std::size_t i=0; i<mClientTransports.size(); ++i) { ClientTransport * pTransport = (*mClientTransports[i]).get(); handlers[i] = PublishCompletionHandler(pTransport, &info); } // Async send on all transports. for (std::size_t i=0; i<handlers.size(); ++i) { try { handlers[i].mpClientTransport->setAsync(true); handlers[i].mpClientTransport->send(handlers[i], data, 0); } catch(const Exception &e) { Exception err( _RcfError_SyncPublishError(e.what()) ); handlers[i].onError(err); } } // Wait for async completions. boost::uint32_t completionDurationMs = 0; { Timer timer; info.wait(timeoutMs); completionDurationMs = timer.getDurationMs(); } // Cancel any outstanding sends. for (std::size_t i=0; i<handlers.size(); ++i) { if (!handlers[i].mCompleted) { (*mClientTransports[i])->cancel(); RCF_LOG_2()(i) << "MulticastClientTransport::send() - cancel send."; } } // Wait for canceled ops to complete. boost::uint32_t cancelDurationMs = 0; { Timer timer; info.wait(timeoutMs); cancelDurationMs = timer.getDurationMs(); } RCF_ASSERT(info.getCompletionCount() == handlers.size()); // Close and remove any subscriber transports with errors. std::size_t transportsRemoved = 0; for (std::size_t i=0; i<handlers.size(); ++i) { RCF_ASSERT(handlers[i].mCompleted); if (!handlers[i].mOk) { mClientTransports[i] = ClientTransportAutoPtrPtr(); ++transportsRemoved; RCF_LOG_2()(i)(handlers[i].mCompleted)(handlers[i].mOk)(handlers[i].mError) << "MulticastClientTransport::send() - remove subscriber transport."; } } eraseRemove(mClientTransports, ClientTransportAutoPtrPtr()); clientStub.onSendCompleted(); std::size_t transportsFinal = transportsInitial - transportsRemoved; RCF_LOG_2() (lengthByteBuffers(data))(completionDurationMs)(cancelDurationMs)(transportsInitial)(transportsFinal) << "MulticastClientTransport::send() - exit."; return 1; }