new strategy
authorPeizhao Ou <peizhaoo@uci.edu>
Thu, 24 Oct 2013 00:23:07 +0000 (17:23 -0700)
committerPeizhao Ou <peizhaoo@uci.edu>
Thu, 24 Oct 2013 00:23:07 +0000 (17:23 -0700)
benchmark/cliffc-hashtable/simplified_cliffc_hashtable.h
notes/generated_code_examples.txt
test.cc

index a37ebdb..299e7a3 100644 (file)
@@ -85,6 +85,7 @@ class cliffc_hashtable {
                @Begin
                @Options:
                        LANG = C;
+                       CLASS = cliffc_hashtable;
                @Global_define:
                        @DeclareVar:
                        spec_hashtable<TypeK, TypeV*> map;
index e1eed19..506c5af 100644 (file)
@@ -9,29 +9,73 @@ Global Variable Declaration
 #ifndef __SPEC_SEQUENTIAL_GENERATED_H
 #define __SPEC_SEQUENTIAL_GENERATED_H
 #include <specannotation.h>
-#include <spec_private_hashtable.h>
 #include <spec_tag.h>
 
-/* Beginning of struct Sequential */
-typedef struct Sequential {
-       spec_private_hashtable interface;
-       Tag global_call_sequence;
+/* Include all the header files that contains the interface declaration */
+#include <iostream>
+#inlcude <atomic>
+#include <memory>
+#include <assert.h>
+
+/* All other user-defined functions */
+ALL_USER_DEFINED_FUNCTIONS
 
-       /* Beginning of other user-defined variables */
-       bool lock_acquired;
-       int reader_lock_cnt;
-       /* End of other user-defined variables */
+/* Definition of interface info struct (per interface) */
+typedef struct Put_info {
+       shared_ptr<TypeV> __RET__;
+       TypeK & key;
+       TypeV & value;
+} Put_info;
+
+typedef struct Get_info {
+       shared_ptr<TypeV> __RET__;
+       TypeK & key;
+} Get_info;
+/* End of info struct definition */
+
+
+/* All function of action and check of interfaces */
+bool Put_check_action(void *info) {
+       bool check_passed;
+       Put_info *theInfo = (Put_info) info;
+       shared_ptr<TypeV> __RET__ = theInfo->__RET__;
+       TypeK & key = theInfo->key;
+       TypeV & value = theInfo->value;
+
+       // Check
+       check_passed = PUT_CHECK_EXPRESSION;
+       if (!check_passed)
+               return false;
+
+       // Action
+       PUT_ACTION
+
+       /* DefineVars */
+       TypeV *_Old_Val = DefineVarExpr;
+
+       // Post_check
+       check_passed = PUT_POST_CHECK_EXPRESSION;
+       if (!check_passed)
+               return false;
+
+       // Post_action
+       PUT_POST_ACTION
+}
 
-} Sequential; /* End of struct Sequential */
+id_t Put_id() {
+       id_t id = PUT_ID;
+       return id;
+}
+
+
+/* Beginning of other user-defined variables */
+bool lock_acquired;
+int reader_lock_cnt;
+/* End of other user-defined variables */
 
-/* Instance of the struct */
-Sequential __sequential;
 
 /* Define function for sequential code initialization */
 void __sequential_init() {
-       /* Init internal variables */
-       init(&__sequential.interface);
-       init(&global_call_sequence);
        /* Init user-defined variables */
        lock_acquired = false;
        reader_lock_cnt = 0;
@@ -49,9 +93,6 @@ void __sequential_init() {
        cdsannotate(SPEC_ANALYSIS, &hb_init0);
 }
 
-/* All other user-defined functions */
-ALL_USER_DEFINED_FUNCTIONS
-
 #endif
 
 
diff --git a/test.cc b/test.cc
index e69de29..b9b6ed3 100644 (file)
--- a/test.cc
+++ b/test.cc
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+typedef void (*action_t)(void*);
+
+class Class {
+       public:
+       struct A {
+               int &a;
+       };
+       
+       void action(void *info) {
+               printf("abc\n");
+       }
+
+       Class() {
+               action_t inst = (action_t) &Class::action;
+               //(*inst)(NULL);
+       }
+};
+
+int main() {
+       Class a;
+       Class &b = a;
+       Class *c = &b;
+       printf("%d\n", &b);
+       printf("%d\n", &c);
+       return 1;
+}