void LIR_OopMapGenerator::iterate_one(BlockBegin* block) {
#ifndef PRODUCT
  if (TraceLIROopMaps) {
    tty->print_cr("Iterating through block %d", block->block_id());
  }
#endif

  set_block(block);
  block->set(BlockBegin::lir_oop_map_gen_reachable_flag);

  int i;

  if (!is_caching_change_block(block)) {
    LIR_OpVisitState state;
    LIR_OpList* inst = block->lir()->instructions_list();
    int length = inst->length();
    for (i = 0; i < length; i++) {
      LIR_Op* op = inst->at(i);
      LIR_Code code = op->code();

      state.visit(op);
      for (int j = 0; j < state.info_count(); j++) {
        process_info(state.info_at(j));
      }

      if (code == lir_volatile_move ||
          code == lir_move) {
        process_move(op);
      }
    }
  }

  // Process successors
  if (block->end() != _base) {
    for (i = 0; i < block->end()->number_of_sux(); i++) {
      merge_state(block->end()->sux_at(i));
    }
  } else {
    // Do not traverse OSR entry point of the base
    merge_state(_base->std_entry());
  }

  set_block(NULL);
}
void LIR_OopMapGenerator::process_info(CodeEmitInfo* info) {
  if (info != NULL) {
    // The presence of a CodeEmitInfo typically means an exception can
    // be thrown. At this point we need to take our current oop map
    // state and propagate it to all exception handlers covering this
    // instruction. FIXME: need to determine whether we need to do a
    // "join" or whether we can just assert that the state matches
    // that at the beginning of the exception handler block (if the
    // state there is already present).

#ifndef PRODUCT      
    if (TraceLIROopMaps) {
      tty->print_cr("  Checking %d exception handlers of block %d",
                    cur_block()->number_of_exception_handlers(),
                    cur_block()->block_id());
    }
#endif
    for (int j = 0; j < cur_block()->number_of_exception_handlers(); j++) {
      BlockBegin* exc = cur_block()->exception_handler_at(j);
      if (exception_handler_covers(info, exc)) {
        merge_state(exc); // Causes block to be added to work list if needed
      }
    }

    // Finally, we always have to put the oop map state into the CodeEmitInfo
    info->set_lir_oop_map(oop_map());

    // If this CodeEmitInfo is present only because of an implicit
    // exception, in order to match the CI's oop maps, we need to
    // check to see whether the top scope has any exception handlers
    // and clear all oop locals in the top scope if not. This should
    // be taken care of automatically by the new register allocator.
    if (is_implicit_exception_info(info)) {
      // The test against the aastore bytecode can be removed once we
      // don't have to match the CI's oop maps exactly. With the new
      // subtype check in place, aastore no longer has a runtime call
      // in its slow case so it behaves like the other implicit
      // exception bytecodes.
      if (info->scope()->method()->java_code_at_bci(info->bci())
          != Bytecodes::_aastore) {
        // Same test as in ciOopMap.cpp
        if (!info->scope()->method()->has_exception_handlers() &&
            !info->scope()->method()->is_synchronized()) {
          // Clear oops in topmost scope
          int first = info->scope()->first_local_name();
          int last = info->scope()->last_local_name();
          if (first >= 0 && last >= first) {
            info->lir_oop_map()->at_put_range(first, last + 1, false);
          }
        }
      }
    }
  }
}
Exemple #3
0
/*
 * clear some bits on a range in the tree.
 */
static int clear_state_bit(struct extent_io_tree *tree,
                           struct extent_state *state, int bits)
{
    int ret = state->state & bits;

    state->state &= ~bits;
    if (state->state == 0) {
        remove_cache_extent(&tree->state, &state->cache_node);
        btrfs_free_extent_state(state);
    } else {
        merge_state(tree, state);
    }
    return ret;
}
  void checkAggregationAvgGeneric() {
    const GenericType &type = GenericType::Instance(true);
    initializeHandle(type);
    EXPECT_TRUE(aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_).isNull());

    typename GenericType::cpptype val;
    typename GenericType::cpptype sum;
    SetDataType(0, &sum);

    iterateHandle(aggregation_handle_avg_state_.get(), type.makeNullValue());
    for (int i = 0; i < kNumSamples; ++i) {
      if (type.getTypeID() == kInt || type.getTypeID() == kLong) {
        SetDataType(i - 10, &val);
      } else {
        SetDataType(static_cast<float>(i - 10)/10, &val);
      }
      iterateHandle(aggregation_handle_avg_state_.get(), type.makeValue(&val));
      sum += val;
    }
    iterateHandle(aggregation_handle_avg_state_.get(), type.makeNullValue());
    CheckAvgValue<typename OutputType::cpptype>(static_cast<typename OutputType::cpptype>(sum) / kNumSamples,
                                                *aggregation_handle_avg_,
                                                *aggregation_handle_avg_state_);

    // Test mergeStates().
    std::unique_ptr<AggregationState> merge_state(
        aggregation_handle_avg_->createInitialState());
    aggregation_handle_avg_->mergeStates(*merge_state,
                                         aggregation_handle_avg_state_.get());

    iterateHandle(merge_state.get(), type.makeNullValue());
    for (int i = 0; i < kNumSamples; ++i) {
      if (type.getTypeID() == kInt || type.getTypeID() == kLong) {
        SetDataType(i - 10, &val);
      } else {
        SetDataType(static_cast<float>(i - 10)/10, &val);
      }
      iterateHandle(merge_state.get(), type.makeValue(&val));
      sum += val;
    }

    aggregation_handle_avg_->mergeStates(*merge_state,
                                         aggregation_handle_avg_state_.get());
    CheckAvgValue<typename OutputType::cpptype>(
        static_cast<typename OutputType::cpptype>(sum) / (2 * kNumSamples),
        *aggregation_handle_avg_,
        *aggregation_handle_avg_state_);
  }
Exemple #5
0
/*
 * insert an extent_state struct into the tree.  'bits' are set on the
 * struct before it is inserted.
 */
static int insert_state(struct extent_io_tree *tree,
                        struct extent_state *state, u64 start, u64 end,
                        int bits)
{
    int ret;

    BUG_ON(end < start);
    state->state |= bits;
    state->start = start;
    state->end = end;
    update_extent_state(state);
    ret = insert_cache_extent(&tree->state, &state->cache_node);
    BUG_ON(ret);
    merge_state(tree, state);
    return 0;
}
void FilterFileLine::merge_state (node_t * lhs, node_t const * rhs)
{
	node_t * lhs_child = lhs->children;

	while (lhs_child)
	{
		node_t * rhs_child = rhs->children;
		bool found = false;
		while (rhs_child)
		{
			if (rhs_child->key == lhs_child->key)
			{
				found = true;
				// assert na state
				break;
			}
			rhs_child = rhs_child->next;
		}

		if (found)
		{
			lhs_child->data = rhs_child->data;
			merge_state(lhs_child, rhs_child);
		}
		else
		{
			node_t * parent = lhs_child->parent;
			if (parent)
			{
				switch (parent->data.m_state)
				{
					case e_Unchecked:
						m_data.set_state_to_childs(lhs_child, parent->data);
						break;
					case e_PartialCheck:
						m_data.set_state_to_childs(lhs_child, TreeModelItem(e_Unchecked, 1));
						break;
					case e_Checked:
						m_data.set_state_to_childs(lhs_child, parent->data);
						break;
				}
			}
		}

		lhs_child = lhs_child->next;
	}
}
void LIR_OopMapGenerator::generate() {
  // Initialize by iterating down the method's signature and marking
  // oop locals in the state

  assert((int) oop_map()->size() == frame_map()->num_local_names(), "just checking");
  oop_map()->clear();
  ciSignature* sig = ir()->method()->signature();
  int idx = 0;
  // Handle receiver for non-static methods
  if (!ir()->method()->is_static()) {
    mark(frame_map()->name_for_argument(idx));
    ++idx;
  }
  for (int i = 0; i < sig->count(); i++) {
    ciType* type = sig->type_at(i);
    if (!type->is_primitive_type()) {
      mark(frame_map()->name_for_argument(idx));
    }
    idx += type->size();
  }

  // The start block contains a Base instruction, which causes the LIR
  // for ref-uninit conflicts to be generated. We need to handle this
  // block specially so we don't traverse its "osr_entry" successor,
  // because we don't know how to set up the state appropriately for
  // that entry point.
  _base = ir()->start()->end()->as_Base();

  // Always start iterating at the start (even for OSR compiles)
  merge_state(ir()->start());
  
  BlockBegin* block = work_list_dequeue();
  while (block != NULL) {
    oop_map()->set_from(*block->lir_oop_map());
    iterate_one(block);
    block = work_list_dequeue();
  }
}
Exemple #8
0
/*
 * set some bits on a range in the tree.
 */
int set_extent_bits(struct extent_io_tree *tree, u64 start,
                    u64 end, int bits, gfp_t mask)
{
    struct extent_state *state;
    struct extent_state *prealloc = NULL;
    struct cache_extent *node;
    int err = 0;
    u64 last_start;
    u64 last_end;
again:
    if (!prealloc) {
        prealloc = alloc_extent_state();
        if (!prealloc)
            return -ENOMEM;
    }

    /*
     * this search will find the extents that end after
     * our range starts
     */
    node = search_cache_extent(&tree->state, start);
    if (!node) {
        err = insert_state(tree, prealloc, start, end, bits);
        BUG_ON(err == -EEXIST);
        prealloc = NULL;
        goto out;
    }

    state = container_of(node, struct extent_state, cache_node);
    last_start = state->start;
    last_end = state->end;

    /*
     * | ---- desired range ---- |
     * | state |
     *
     * Just lock what we found and keep going
     */
    if (state->start == start && state->end <= end) {
        state->state |= bits;
        merge_state(tree, state);
        if (last_end == (u64)-1)
            goto out;
        start = last_end + 1;
        goto search_again;
    }
    /*
     *     | ---- desired range ---- |
     * | state |
     *   or
     * | ------------- state -------------- |
     *
     * We need to split the extent we found, and may flip bits on
     * second half.
     *
     * If the extent we found extends past our
     * range, we just split and search again.  It'll get split
     * again the next time though.
     *
     * If the extent we found is inside our range, we set the
     * desired bit on it.
     */
    if (state->start < start) {
        err = split_state(tree, state, prealloc, start);
        BUG_ON(err == -EEXIST);
        prealloc = NULL;
        if (err)
            goto out;
        if (state->end <= end) {
            state->state |= bits;
            start = state->end + 1;
            merge_state(tree, state);
            if (last_end == (u64)-1)
                goto out;
            start = last_end + 1;
        } else {
            start = state->start;
        }
        goto search_again;
    }
    /*
     * | ---- desired range ---- |
     *     | state | or               | state |
     *
     * There's a hole, we need to insert something in it and
     * ignore the extent we found.
     */
    if (state->start > start) {
        u64 this_end;
        if (end < last_start)
            this_end = end;
        else
            this_end = last_start -1;
        err = insert_state(tree, prealloc, start, this_end,
                           bits);
        BUG_ON(err == -EEXIST);
        prealloc = NULL;
        if (err)
            goto out;
        start = this_end + 1;
        goto search_again;
    }
    /*
     * | ---- desired range ---- |
     * | ---------- state ---------- |
     * We need to split the extent, and set the bit
     * on the first half
     */
    err = split_state(tree, state, prealloc, end + 1);
    BUG_ON(err == -EEXIST);

    state->state |= bits;
    merge_state(tree, prealloc);
    prealloc = NULL;
out:
    if (prealloc)
        btrfs_free_extent_state(prealloc);
    return err;
search_again:
    if (start > end)
        goto out;
    goto again;
}
Exemple #9
0
/* dequeue should be called by kperf_*()
   NB: these calls are already in place
*/
void message_dequeue(CSOUND *csound) {
  if(csound->msg_queue != NULL) {
    long rp = csound->msg_queue_rstart;
    long items = csound->msg_queue_items;
    long rend = rp + items;

    while(rp < rend) {
      message_queue_t* msg = csound->msg_queue[rp % API_MAX_QUEUE];
      switch(msg->message) {
      case INPUT_MESSAGE:
        {
          const char *str = msg->args;
          csoundInputMessageInternal(csound, str);
        }

        break;
      case READ_SCORE:
        {
          const char *str = msg->args;
          csoundReadScoreInternal(csound, str);
        }
        break;
      case SCORE_EVENT:
        {
          char type;
          const MYFLT *pfields;
          long numFields;
          type = msg->args[0];
          memcpy(&pfields, msg->args + ARG_ALIGN,
                 sizeof(MYFLT *));
          memcpy(&numFields, msg->args + ARG_ALIGN*2,
                 sizeof(long));

          csoundScoreEventInternal(csound, type, pfields, numFields);
        }
        break;
      case SCORE_EVENT_ABS:
        {
          char type;
          const MYFLT *pfields;
          long numFields;
          double ofs;
          type = msg->args[0];
          memcpy(&pfields, msg->args + ARG_ALIGN,
                 sizeof(MYFLT *));
          memcpy(&numFields, msg->args + ARG_ALIGN*2,
                 sizeof(long));
          memcpy(&ofs, msg->args + ARG_ALIGN*3,
                 sizeof(double));

          csoundScoreEventAbsoluteInternal(csound, type, pfields, numFields,
                                             ofs);
        }
        break;
      case TABLE_COPY_OUT:
        {
          int table;
          MYFLT *ptable;
          memcpy(&table, msg->args, sizeof(int));
          memcpy(&ptable, msg->args + ARG_ALIGN,
                 sizeof(MYFLT *));
          csoundTableCopyOutInternal(csound, table, ptable);
        }
        break;
      case TABLE_COPY_IN:
        {
          int table;
          MYFLT *ptable;
          memcpy(&table, msg->args, sizeof(int));
          memcpy(&ptable, msg->args + ARG_ALIGN,
                 sizeof(MYFLT *));
          csoundTableCopyInInternal(csound, table, ptable);
        }
        break;
      case TABLE_SET:
        {
          int table, index;
          MYFLT value;
          memcpy(&table, msg->args, sizeof(int));
          memcpy(&index, msg->args + ARG_ALIGN,
                 sizeof(int));
          memcpy(&value, msg->args + 2*ARG_ALIGN,
                 sizeof(MYFLT));
          csoundTableSetInternal(csound, table, index, value);
        }
        break;
      case MERGE_STATE:
        {
          ENGINE_STATE *e;
          TYPE_TABLE *t;
          OPDS *ids;
          memcpy(&e, msg->args, sizeof(ENGINE_STATE *));
          memcpy(&t, msg->args + ARG_ALIGN,
                 sizeof(TYPE_TABLE *));
          memcpy(&ids, msg->args + 2*ARG_ALIGN,
                 sizeof(OPDS *));
          merge_state(csound, e, t, ids);
        }
        break;
      case KILL_INSTANCE:
        {
          MYFLT instr;
          int mode, insno, rls;
          INSDS *ip;
          memcpy(&instr, msg->args, sizeof(MYFLT));
          memcpy(&insno, msg->args + ARG_ALIGN,
                 sizeof(int));
          memcpy(&ip, msg->args + ARG_ALIGN*2,
                 sizeof(INSDS *));
          memcpy(&mode, msg->args + ARG_ALIGN*3,
                 sizeof(int));
          memcpy(&rls, msg->args  + ARG_ALIGN*4,
                 sizeof(int));
          killInstance(csound, instr, insno, ip, mode, rls);
        }
        break;
      }
      msg->message = 0;
      rp += 1;
    }
    ATOMIC_SUB(csound->msg_queue_items, items);
    csound->msg_queue_rstart = rp % API_MAX_QUEUE;
  }
}
void FilterFileLine::merge (node_t * lhs, node_t const * rhs)
{
	merge_rhs(lhs, rhs);
	merge_state(lhs, rhs);
}