OSDN Git Service

Add isDebuggerActive API for the finalizer watchdog.
[android-x86/dalvik.git] / vm / IndirectRefTable.h
index f5157cb..165bfb1 100644 (file)
@@ -16,6 +16,7 @@
 
 #ifndef _DALVIK_INDIRECTREFTABLE
 #define _DALVIK_INDIRECTREFTABLE
+
 /*
  * Maintain a table of indirect references.  Used for local/global JNI
  * references.
@@ -90,22 +91,22 @@ typedef void* IndirectRef;
  *
  * For convenience these match up with enum jobjectRefType from jni.h.
  */
-typedef enum IndirectRefKind {
+enum IndirectRefKind {
     kIndirectKindInvalid    = 0,
     kIndirectKindLocal      = 1,
     kIndirectKindGlobal     = 2,
     kIndirectKindWeakGlobal = 3
-} IndirectRefKind;
+};
 
 /*
  * Extended debugging structure.  We keep a parallel array of these, one
  * per slot in the table.
  */
 #define kIRTPrevCount   4
-typedef struct IndirectRefSlot {
+struct IndirectRefSlot {
     u4          serial;         /* slot serial */
     Object*     previous[kIRTPrevCount];
-} IndirectRefSlot;
+};
 
 /*
  * Table definition.
@@ -174,14 +175,14 @@ typedef struct IndirectRefSlot {
  * add a "synchronized lookup" call that takes the mutex as an argument,
  * and either locks or doesn't lock based on internal details.
  */
-typedef union IRTSegmentState {
+union IRTSegmentState {
     u4          all;
     struct {
         u4      topIndex:16;            /* index of first unused entry */
         u4      numHoles:16;            /* #of holes in entire table */
     } parts;
-} IRTSegmentState;
-typedef struct IndirectRefTable {
+};
+struct IndirectRefTable {
     /* semi-public - read/write by interpreter in native call handler */
     IRTSegmentState segmentState;
 
@@ -196,7 +197,7 @@ typedef struct IndirectRefTable {
 
     // TODO: want hole-filling stats (#of holes filled, total entries scanned)
     //       for performance evaluation.
-} IndirectRefTable;
+};
 
 /* use as initial value for "cookie", and when table has only one segment */
 #define IRT_FIRST_SEGMENT   0
@@ -240,6 +241,11 @@ INLINE IndirectRefKind dvmGetIndirectRefType(IndirectRef iref)
 }
 
 /*
+ * Return a string constant describing the indirect ref type.
+ */
+const char* dvmIndirectRefTypeName(IndirectRef iref);
+
+/*
  * Initialize an IndirectRefTable.
  *
  * If "initialCount" != "maxCount", the table will expand as required.
@@ -347,16 +353,19 @@ INLINE IndirectRef dvmAppendToIndirectRefTable(IndirectRefTable* pRef,
 /* extra debugging checks */
 bool dvmGetFromIndirectRefTableCheck(IndirectRefTable* pRef, IndirectRef iref);
 
+/* magic failure value; must not pass dvmIsValidObject() */
+#define kInvalidIndirectRefObject ((Object*)0xdead4321)
+
 /*
  * Given an IndirectRef in the table, return the Object it refers to.
  *
- * Returns NULL if iref is invalid.
+ * Returns kInvalidIndirectRefObject if iref is invalid.
  */
 INLINE Object* dvmGetFromIndirectRefTable(IndirectRefTable* pRef,
     IndirectRef iref)
 {
     if (!dvmGetFromIndirectRefTableCheck(pRef, iref))
-        return NULL;
+        return kInvalidIndirectRefObject;
 
     int idx = dvmIndirectRefToIndex(iref);
     return pRef->table[idx];
@@ -376,6 +385,8 @@ bool dvmRemoveFromIndirectRefTable(IndirectRefTable* pRef, u4 cookie,
 
 /*
  * Dump the contents of a reference table to the log file.
+ *
+ * The caller should lock any external sync before calling.
  */
 void dvmDumpIndirectRefTable(const IndirectRefTable* pRef, const char* descr);