summaryrefslogtreecommitdiff
path: root/src/upb_string.h
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-04-01 15:40:06 -0700
committerJoshua Haberman <joshua@reverberate.org>2011-04-01 15:40:06 -0700
commit9eb4d695c49a85f7f72ad68c3c31affd61fef984 (patch)
tree79b7fde57e6f31a19405688a5f9e29e3f9cf7ab2 /src/upb_string.h
parent19517cc6f39871abf4a0705b49cfed9049ca6033 (diff)
First rough version of the JIT.
It can successfully parse SpeedMessage1. Preliminary results: 750MB/s on Core2 2.4GHz. This number is 2.5x proto2. This isn't apples-to-apples, because proto2 is parsing to a struct and we are just doing stream parsing, but for apps that are currently using proto2, this is the improvement they would see if they could move to stream-based processing. Unfortunately perf-regression-test.py is broken, and I'm not 100% sure why. It would be nice to fix it first (to ensure that there are no performance regressions for the table-based decoder) but I'm really impatient to get the JIT checked in.
Diffstat (limited to 'src/upb_string.h')
-rw-r--r--src/upb_string.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/upb_string.h b/src/upb_string.h
index 88a513f..5aa5f3b 100644
--- a/src/upb_string.h
+++ b/src/upb_string.h
@@ -155,9 +155,13 @@ INLINE const char *upb_string_getbufend(upb_string *str) {
}
// Attempts to recycle the string "str" so it may be reused and have different
-// data written to it. After the function returns, "str" points to a writable
-// string, which is either the original string if it had no other references
-// or a newly created string if it did have other references.
+// data written to it. The caller MUST own a reference on the given string
+// prior to making this call (ie. the caller must have either created the
+// string or obtained a reference with upb_string_getref()).
+//
+// After the function returns, "str" points to a writable string, which is
+// either the original string if it had no other references or a newly created
+// string if it did have other references.
//
// As a special case, passing a pointer to NULL will allocate a new string.
// This is convenient for the pattern:
@@ -171,7 +175,9 @@ INLINE const char *upb_string_getbufend(upb_string *str) {
// }
INLINE void upb_string_recycle(upb_string **_str) {
upb_string *str = *_str;
- if(str && upb_atomic_only(&str->refcount)) {
+ int r;
+ if(str && ((r = upb_atomic_read(&str->refcount)) == 1 ||
+ (r == _UPB_STRING_REFCOUNT_STACK))) {
str->ptr = NULL;
str->len = 0;
_upb_string_release(str);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback