summaryrefslogtreecommitdiffstats
path: root/vm/UtfString.h
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2009-09-02 18:07:23 -0700
committerAndy McFadden <fadden@android.com>2009-09-03 12:22:51 -0700
commit59a434629ba06d4decf7bc88a62ae370a1935f0e (patch)
tree3b53b83996a3f8057f75716d84c74cb7acd23d67 /vm/UtfString.h
parent06f4a19f3c6d6503e936d252fb80d6ca57b29392 (diff)
downloadandroid_dalvik-59a434629ba06d4decf7bc88a62ae370a1935f0e.tar.gz
android_dalvik-59a434629ba06d4decf7bc88a62ae370a1935f0e.tar.bz2
android_dalvik-59a434629ba06d4decf7bc88a62ae370a1935f0e.zip
Add inline version of String.indexOf().
This provides an inline-native version of String.indexOf(int) and String.indexOf(int, int), i.e. the functions that work like strchr(). Has a fairly solid impact on specific benchmarks. Might give a boost to an app somewhere. Added some indexOf tests to 020-string. Added hard-coded field offsets for String. These are verified during startup. Improves some of our String micro-benchmarks by ~10%.
Diffstat (limited to 'vm/UtfString.h')
-rw-r--r--vm/UtfString.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/vm/UtfString.h b/vm/UtfString.h
index ca500a7b7..8f0f97286 100644
--- a/vm/UtfString.h
+++ b/vm/UtfString.h
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
/*
* UTF-8 and Unicode string manipulation functions, plus convenience
* functions for working with java/lang/String.
@@ -21,6 +22,30 @@
#define _DALVIK_STRING
/*
+ * (This is private to UtfString.c, but we cheat a bit and also use it
+ * for InlineNative.c. Not really worth creating a separate header.)
+ *
+ * We can avoid poking around in gDvm by hard-coding the expected values of
+ * the String field offsets. This will be annoying if String is in flux
+ * or the VM field layout is changing, so we use defines here to make it
+ * easy to switch back to the gDvm version.
+ *
+ * The values are checked for correctness during startup.
+ */
+//#define USE_GLOBAL_STRING_DEFS
+#ifdef USE_GLOBAL_STRING_DEFS
+# define STRING_FIELDOFF_VALUE gDvm.offJavaLangString_value
+# define STRING_FIELDOFF_OFFSET gDvm.offJavaLangString_offset
+# define STRING_FIELDOFF_COUNT gDvm.offJavaLangString_count
+# define STRING_FIELDOFF_HASHCODE gDvm.offJavaLangString_hashCode
+#else
+# define STRING_FIELDOFF_VALUE 8
+# define STRING_FIELDOFF_HASHCODE 12
+# define STRING_FIELDOFF_OFFSET 16
+# define STRING_FIELDOFF_COUNT 20
+#endif
+
+/*
* Hash function for modified UTF-8 strings.
*/
u4 dvmComputeUtf8Hash(const char* str);