am 03c7547c: Merge change 24425 into eclair
Merge commit '03c7547c40e6fc5b29b929b64f114e2dd3894e8e' into eclair-plus-aosp
* commit '03c7547c40e6fc5b29b929b64f114e2dd3894e8e':
vm: Add support for using scheduler policies instead of cgroups
diff --git a/libcore/regex/src/main/java/java/util/regex/Pattern.java b/libcore/regex/src/main/java/java/util/regex/Pattern.java
index 2853bbe..2c71de1 100644
--- a/libcore/regex/src/main/java/java/util/regex/Pattern.java
+++ b/libcore/regex/src/main/java/java/util/regex/Pattern.java
@@ -47,7 +47,7 @@
* boolean b2 = Pattern.matches("Hello, A[a-z]*!", "Hello, Robot!"); // false
* </pre>
* <p/>
- * Please consult the <a href="package.html">package documentation</a> for an
+ * Please consult the <a href="package-summary.html">package documentation</a> for an
* overview of the regular expression syntax used in this class as well as
* Android-specific implementation details.
*
diff --git a/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp b/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
index 7149272..40a4116 100644
--- a/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
+++ b/libcore/xml/src/main/native/org_apache_harmony_xml_ExpatParser.cpp
@@ -479,7 +479,7 @@
* @returns index of the separator
*/
static int findSeparator(const char* s) {
- char* pointer = strchr(s, '|');
+ const char* pointer = strchr(s, '|');
return pointer == NULL ? -1 : pointer - s;
}
diff --git a/vm/oo/Class.c b/vm/oo/Class.c
index 1bde718..115a122 100644
--- a/vm/oo/Class.c
+++ b/vm/oo/Class.c
@@ -180,6 +180,8 @@
const DexField* pDexSField, StaticField* sfield);
static void loadIFieldFromDex(ClassObject* clazz,
const DexField* pDexIField, InstField* field);
+static bool precacheReferenceOffsets(ClassObject* clazz);
+static void computeRefOffsets(ClassObject* clazz);
static void freeMethodInnards(Method* meth);
static bool createVtable(ClassObject* clazz);
static bool createIftable(ClassObject* clazz);
@@ -2289,7 +2291,7 @@
/*
* Cache java.lang.ref.Reference fields and methods.
*/
-static bool precacheReferenceOffsets(ClassObject *clazz)
+static bool precacheReferenceOffsets(ClassObject* clazz)
{
Method *meth;
int i;
@@ -2388,6 +2390,51 @@
/*
+ * Set the bitmap of reference offsets, refOffsets, from the ifields
+ * list.
+ */
+static void computeRefOffsets(ClassObject* clazz)
+{
+ if (clazz->super != NULL) {
+ clazz->refOffsets = clazz->super->refOffsets;
+ } else {
+ clazz->refOffsets = 0;
+ }
+ /*
+ * If our superclass overflowed, we don't stand a chance.
+ */
+ if (clazz->refOffsets != CLASS_WALK_SUPER) {
+ InstField *f;
+ int i;
+
+ /* All of the fields that contain object references
+ * are guaranteed to be at the beginning of the ifields list.
+ */
+ f = clazz->ifields;
+ const int ifieldRefCount = clazz->ifieldRefCount;
+ for (i = 0; i < ifieldRefCount; i++) {
+ /*
+ * Note that, per the comment on struct InstField,
+ * f->byteOffset is the offset from the beginning of
+ * obj, not the offset into obj->instanceData.
+ */
+ assert(f->byteOffset >= CLASS_SMALLEST_OFFSET);
+ assert((f->byteOffset & (CLASS_OFFSET_ALIGNMENT - 1)) == 0);
+ if (CLASS_CAN_ENCODE_OFFSET(f->byteOffset)) {
+ u4 newBit = CLASS_BIT_FROM_OFFSET(f->byteOffset);
+ assert(newBit != 0);
+ clazz->refOffsets |= newBit;
+ } else {
+ clazz->refOffsets = CLASS_WALK_SUPER;
+ break;
+ }
+ f++;
+ }
+ }
+}
+
+
+/*
* Link (prepare and resolve). Verification is deferred until later.
*
* This converts symbolic references into pointers. It's independent of
@@ -2755,6 +2802,13 @@
}
/*
+ * Compact the offsets the GC has to examine into a bitmap, if
+ * possible. (This has to happen after Reference.referent is
+ * massaged in precacheReferenceOffsets.)
+ */
+ computeRefOffsets(clazz);
+
+ /*
* Done!
*/
if (IS_CLASS_FLAG_SET(clazz, CLASS_ISPREVERIFIED))
@@ -4421,44 +4475,6 @@
dvmCallMethod(self, method, NULL, &unused);
}
- /* Set the bitmap of reference offsets. Except for class Object,
- * start with the superclass offsets.
- */
- if (clazz->super != NULL) {
- clazz->refOffsets = clazz->super->refOffsets;
- } else {
- clazz->refOffsets = 0;
- }
- /*
- * If our superclass overflowed, we don't stand a chance.
- */
- if (clazz->refOffsets != CLASS_WALK_SUPER) {
- InstField *f;
- int i;
-
- /* All of the fields that contain object references
- * are guaranteed to be at the beginning of the ifields list.
- */
- f = clazz->ifields;
- for (i = 0; i < clazz->ifieldRefCount; i++) {
- /*
- * Note that, per the comment on struct InstField,
- * f->byteOffset is the offset from the beginning of
- * obj, not the offset into obj->instanceData.
- */
- assert(f->byteOffset >= (int) CLASS_SMALLEST_OFFSET);
- assert((f->byteOffset & (CLASS_OFFSET_ALIGNMENT - 1)) == 0);
- u4 newBit = CLASS_BIT_FROM_OFFSET(f->byteOffset);
- if (newBit != 0) {
- clazz->refOffsets |= newBit;
- } else {
- clazz->refOffsets = CLASS_WALK_SUPER;
- break;
- }
- f++;
- }
- }
-
if (dvmCheckException(self)) {
/*
* We've had an exception thrown during static initialization. We
diff --git a/vm/oo/Object.h b/vm/oo/Object.h
index 3e724f4..e467fe9 100644
--- a/vm/oo/Object.h
+++ b/vm/oo/Object.h
@@ -187,12 +187,23 @@
#define CLASS_OFFSET_ALIGNMENT 4
#define CLASS_HIGH_BIT ((unsigned int)1 << (CLASS_BITS_PER_WORD - 1))
/*
- * Return a single bit, or zero if the encoding can't encode the offset.
+ * Given an offset, return the bit number which would encode that offset.
+ * Local use only.
+ */
+#define _CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset) \
+ (((unsigned int)(byteOffset) - CLASS_SMALLEST_OFFSET) / \
+ CLASS_OFFSET_ALIGNMENT)
+/*
+ * Is the given offset too large to be encoded?
+ */
+#define CLASS_CAN_ENCODE_OFFSET(byteOffset) \
+ (_CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset) < CLASS_BITS_PER_WORD)
+/*
+ * Return a single bit, encoding the offset.
+ * Undefined if the offset is too large, as defined above.
*/
#define CLASS_BIT_FROM_OFFSET(byteOffset) \
- (CLASS_HIGH_BIT >> \
- (((unsigned int)(byteOffset) - CLASS_SMALLEST_OFFSET) / \
- CLASS_OFFSET_ALIGNMENT))
+ (CLASS_HIGH_BIT >> _CLASS_BIT_NUMBER_FROM_OFFSET(byteOffset))
/*
* Return an offset, given a bit number as returned from CLZ.
*/