Exemple #1
0
void bc_finalizer::run_on(container_node* c) {
	node *prev_node = NULL;
	for (node_iterator I = c->begin(), E = c->end(); I != E; ++I) {
		node *n = *I;

		if (n->is_alu_group()) {
			finalize_alu_group(static_cast<alu_group_node*>(n), prev_node);
		} else {
			if (n->is_alu_clause()) {
				cf_node *c = static_cast<cf_node*>(n);

				if (c->bc.op == CF_OP_ALU_PUSH_BEFORE && ctx.is_egcm()) {
					if (ctx.stack_workaround_8xx) {
						region_node *r = c->get_parent_region();
						if (r) {
							unsigned ifs, loops;
							unsigned elems = get_stack_depth(r, loops, ifs);
							unsigned dmod1 = elems % ctx.stack_entry_size;
							unsigned dmod2 = (elems + 1) % ctx.stack_entry_size;

							if (elems && (!dmod1 || !dmod2))
								c->flags |= NF_ALU_STACK_WORKAROUND;
						}
					} else if (ctx.stack_workaround_9xx) {
						region_node *r = c->get_parent_region();
						if (r) {
							unsigned ifs, loops;
							get_stack_depth(r, loops, ifs);
							if (loops >= 2)
								c->flags |= NF_ALU_STACK_WORKAROUND;
						}
					}
				}
			} else if (n->is_fetch_inst()) {
				finalize_fetch(static_cast<fetch_node*>(n));
			} else if (n->is_cf_inst()) {
				finalize_cf(static_cast<cf_node*>(n));
			}
			if (n->is_container())
				run_on(static_cast<container_node*>(n));
		}
		prev_node = n;
	}
}
Exemple #2
0
bool ThreadStackTrace::is_owned_monitor_on_stack(oop object) {
  assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");

  bool found = false;
  int num_frames = get_stack_depth();
  for (int depth = 0; depth < num_frames; depth++) {
    StackFrameInfo* frame = stack_frame_at(depth);
    int len = frame->num_locked_monitors();
    GrowableArray<oop>* locked_monitors = frame->locked_monitors();
    for (int j = 0; j < len; j++) {
      oop monitor = locked_monitors->at(j);
      assert(monitor != NULL, "must be a Java object");
      if (monitor == object) {
        found = true;
        break;
      }
    }
  }
  return found;
}
Exemple #3
0
DEFINEFN
void psyco_dump_code_buffers(void)
{
  static int is_dumping = 0;
  FILE* f;

#if CODE_DUMP >= 3
  static int alt = 1;
  char filename[200];
  sprintf(filename, "%s-%d", CODE_DUMP_FILE, alt);
  alt = 3-alt;
#else
  char* filename = CODE_DUMP_FILE;
#endif

#if defined(PSYCO_TRACE)
  trace_flush();
#endif
  
  if (is_dumping) return;
  is_dumping = 1;
  f = fopen(filename, "wb");
  if (f != NULL)
    {
      CodeBufferObject* obj;
      PyObject *exc, *val, *tb;
      long buftablepos;
      void** chain;
      int bufcount = 0;
      long* buftable;
      PyErr_Fetch(&exc, &val, &tb);
      debug_printf(1, ("writing %s\n", filename));

      for (obj=psyco_codebuf_chained_list; obj != NULL; obj=obj->chained_list)
        bufcount++;
      buftable = PyMem_NEW(long, bufcount);
      fprintf(f, "Psyco dump [%s]\n", MACHINE_CODE_FORMAT);
      fwrite(&bufcount, sizeof(bufcount), 1, f);
      buftablepos = ftell(f);
      fwrite(buftable, sizeof(long), bufcount, f);

      /* give the address of an arbitrary symbol from the Python interpreter
         and from the Psyco module */
      fprintf(f, "PyInt_FromLong: 0x%lx\n", (long) &PyInt_FromLong);
      fprintf(f, "psyco_dump_code_buffers: 0x%lx\n",
              (long) &psyco_dump_code_buffers);

      for (obj=psyco_codebuf_chained_list; obj != NULL; obj=obj->chained_list)
        {
          PyCodeObject* co = obj->snapshot.fz_pyc_data ?
		  obj->snapshot.fz_pyc_data->co : NULL;
          fprintf(f, "CodeBufferObject 0x%lx %d '%s' '%s' %d '%s'\n",
                  (long) obj->codestart, get_stack_depth(&obj->snapshot),
                  co?PyString_AsString(co->co_filename):"",
                  co?PyCodeObject_NAME(co):"",
                  co?obj->snapshot.fz_pyc_data->next_instr:-1,
                  obj->codemode);
        }
      
      psyco_dump_bigbuffers(f);

      for (chain = psyco_codebuf_spec_dict_list; chain; chain=(void**)*chain)
        {
          PyObject* spec_dict = (PyObject*)(chain[-1]);
          int i = 0;
          PyObject *key, *value;
          fprintf(f, "spec_dict 0x%lx\n", (long) chain);
          while (PyDict_Next(spec_dict, &i, &key, &value))
            {
              PyObject* repr;
              if (PyInt_Check(key))
                {
                  repr = (key->ob_type->tp_as_number->nb_hex)(key);
                }
              else
                {
                  repr = PyObject_Repr(key);
                }
              psyco_assert(!PyErr_Occurred());
              psyco_assert(PyString_Check(repr));
              psyco_assert(CodeBuffer_Check(value));
              fprintf(f, "0x%lx %s\n",
                      (long)((CodeBufferObject*)value)->codestart,
                      PyString_AsString(repr));
              Py_DECREF(repr);
            }
          fprintf(f, "\n");
        }
      {
        int i = 0;
        fprintf(f, "vinfo_array\n");
        for (obj=psyco_codebuf_chained_list; obj != NULL; obj=obj->chained_list)
          {
            PsycoObject* live_po;
            PyObject* d;
            if (psyco_top_array_count(&obj->snapshot) > 0)
              live_po = fpo_unfreeze(&obj->snapshot);
            else
              live_po = NULL;
            d = PyDict_New();
            psyco_assert(d);
            buftable[i++] = ftell(f);
            vinfo_array_dump(live_po ? &live_po->vlocals : NullArray, f, d);
            Py_DECREF(d);
            if (live_po)
              PsycoObject_Delete(live_po);
          }
        psyco_assert(i==bufcount);
        fseek(f, buftablepos, 0);
        fwrite(buftable, sizeof(long), bufcount, f);
      }
      PyMem_FREE(buftable);
      psyco_assert(!PyErr_Occurred());
      fclose(f);
      PyErr_Restore(exc, val, tb);
    }