You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2013/07/16 02:04:41 UTC
[lucy-commits] git commit: refs/heads/method-dispatch-benchmark - Add fixed-offset
method invocation (a la C++).
Updated Branches:
refs/heads/method-dispatch-benchmark e2604e9e8 -> f53d99c1a
Add fixed-offset method invocation (a la C++).
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f53d99c1
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f53d99c1
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f53d99c1
Branch: refs/heads/method-dispatch-benchmark
Commit: f53d99c1ab5e8be10039b2009404a38c59f02073
Parents: e2604e9
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Mon Jul 15 17:02:31 2013 -0700
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Mon Jul 15 17:02:31 2013 -0700
----------------------------------------------------------------------
devel/benchmarks/method_dispatch/dso.h | 1 +
devel/benchmarks/method_dispatch/exe.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/f53d99c1/devel/benchmarks/method_dispatch/dso.h
----------------------------------------------------------------------
diff --git a/devel/benchmarks/method_dispatch/dso.h b/devel/benchmarks/method_dispatch/dso.h
index 569f88e..f69aaed 100644
--- a/devel/benchmarks/method_dispatch/dso.h
+++ b/devel/benchmarks/method_dispatch/dso.h
@@ -6,6 +6,7 @@
extern class_t *OBJ;
extern size_t Obj_Hello_OFFSET;
extern method_t Obj_Hello_THUNK_PTR;
+#define Obj_Hello_FIXED_OFFSET (5 * sizeof(void*))
void bootstrap();
http://git-wip-us.apache.org/repos/asf/lucy/blob/f53d99c1/devel/benchmarks/method_dispatch/exe.c
----------------------------------------------------------------------
diff --git a/devel/benchmarks/method_dispatch/exe.c b/devel/benchmarks/method_dispatch/exe.c
index d696d0c..4e0b5d6 100644
--- a/devel/benchmarks/method_dispatch/exe.c
+++ b/devel/benchmarks/method_dispatch/exe.c
@@ -23,6 +23,13 @@ Obj_Hello(obj_t *obj) {
method(obj);
}
+static inline void
+Obj_Hello_FIXED(obj_t *obj) {
+ class_t *klass = obj->klass;
+ method_t method = *(method_t*)((char*)klass + Obj_Hello_FIXED_OFFSET);
+ method(obj);
+}
+
void
loop_with_method_ptr(obj_t *obj) {
method_t method = Obj_Hello_PTR(obj);
@@ -39,6 +46,13 @@ loop_with_wrapper(obj_t *obj) {
}
}
+void
+loop_with_fixed_offset_wrapper(obj_t *obj) {
+ for (uint64_t i = 0; i < ITERATIONS; ++i) {
+ Obj_Hello_FIXED(obj);
+ }
+}
+
#ifdef HAS_ALIAS
void
loop_with_thunk(obj_t *obj) {
@@ -135,6 +149,7 @@ main(int argc, char **argv) {
bench(loop_with_method_ptr, "method ptr loop");
bench(loop_with_wrapper, "wrapper loop");
+ bench(loop_with_fixed_offset_wrapper, "fixed offset wrapper loop");
#ifdef HAS_ALIAS
bench(loop_with_thunk, "thunk loop");
bench(loop_with_thunk_ptr, "thunk ptr loop");