• R/O
  • SSH
  • HTTPS

adp: Commit


Commit MetaInfo

Revisión301 (tree)
Tiempo2012-06-08 00:41:51
Autorohfuji

Log Message

インライン化の徹底(一部インライン関数にしない方が早かった)

Cambiar Resumen

Diferencia incremental

--- trunk/adp_unify.cpp (revision 300)
+++ trunk/adp_unify.cpp (revision 301)
@@ -53,7 +53,7 @@
5353 /*************************************** unify ******************************************/
5454
5555 // 変項のunify本体で使うテンプレート関数
56-template <class V, class T> bool inline vunify(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal)
56+template <class V, class T> bool __forceinline vunify(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
5757 {
5858 const PObject *gitem = (*glocal)[goal.idx];
5959 if ( gitem == 0 ) {
@@ -65,7 +65,7 @@
6565 return true;
6666 }
6767
68-template <class V, class T> bool inline vmatch_h_g(const V &horn, const T &goal, ExecContext *c, VLocal *hlocal)
68+template <class V, class T> bool __forceinline vmatch_h_g(const V &horn, const T &goal, ExecContext *c, VLocal *hlocal) __attribute__((always_inline))
6969 {
7070 const PObject *item = (*hlocal)[horn.idx];
7171 if ( item == 0 ) {
@@ -77,7 +77,7 @@
7777 return true;
7878 }
7979
80-template <class V, class T> bool inline vmatch_g_h(const V &goal, const T &horn, ExecContext *c, VLocal *glocal)
80+template <class V, class T> bool __forceinline vmatch_g_h(const V &goal, const T &horn, ExecContext *c, VLocal *glocal) __attribute__((always_inline))
8181 {
8282 const PObject *item = (*glocal)[goal.idx];
8383 if ( item == 0 ) {
@@ -89,7 +89,7 @@
8989 return true;
9090 }
9191
92-template <class V, class T> bool inline vunify_getval(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal)
92+template <class V, class T> bool __forceinline vunify_getval(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
9393 {
9494 const PObject *gitem = (*glocal)[goal.idx];
9595 if ( gitem == 0 ) {
@@ -102,7 +102,7 @@
102102 return true;
103103 }
104104
105-template <class V, class T> bool inline vmatch_getval_h_g(const V &horn, const T &goal, ExecContext *c, VLocal *hlocal)
105+template <class V, class T> bool __forceinline vmatch_getval_h_g(const V &horn, const T &goal, ExecContext *c, VLocal *hlocal) __attribute__((always_inline))
106106 {
107107 const PObject *item = (*hlocal)[horn.idx];
108108 if ( item == 0 ) {
@@ -119,7 +119,7 @@
119119 return true;
120120 }
121121
122-template <class V, class T> bool inline vmatch_getval_g_h(const V &goal, const T &horn, ExecContext *c, VLocal *glocal)
122+template <class V, class T> bool __forceinline vmatch_getval_g_h(const V &goal, const T &horn, ExecContext *c, VLocal *glocal) __attribute__((always_inline))
123123 {
124124 const PObject *item = (*glocal)[goal.idx];
125125 if ( item == 0 ) {
@@ -136,7 +136,7 @@
136136 return true;
137137 }
138138
139-template <class V, class T> bool inline vunify_ver(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal)
139+template <class V, class T> bool __forceinline vunify_ver(const V &goal, const T &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
140140 {
141141 const PObject *gval = (*glocal)[goal.idx];
142142 const PObject *hval = (*hlocal)[horn.idx];
@@ -156,7 +156,7 @@
156156 return true;
157157 }
158158
159-template <class V, class T> bool inline vmatch_ver_g_h(const V &goal, const T &horn, ExecContext *c, VLocal *glocal, VLocal *hlocal)
159+template <class V, class T> bool __forceinline vmatch_ver_g_h(const V &goal, const T &horn, ExecContext *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
160160 {
161161 const PObject *gval = (*glocal)[goal.idx];
162162 const PObject *hval = (*hlocal)[horn.idx];
@@ -271,18 +271,18 @@
271271 bool PInteger::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_h_g(horn, *this, c, horn.vl); }
272272
273273 /*************************************** PList ******************************************/
274-static inline bool PList_unify(const PList &list)
274+static __forceinline bool PList_unify(const PList &list) __attribute__((always_inline))
275275 {
276276 if ( typeid(*list.lvalue) == typeid(PNil) && typeid(*list.rvalue) == typeid(PNil) ) return true;
277277 return false;
278278 }
279-static inline bool PList_unify(const PList &goal, const PList &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal)
279+static __forceinline bool PList_unify(const PList &goal, const PList &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
280280 {
281281 if ( horn.lvalue->unify( *goal.lvalue, c, hlocal, glocal) && horn.rvalue->unify( *goal.rvalue, c, hlocal, glocal) ) return true;
282282 return false;
283283 }
284284
285-static inline bool PList_match(const PList &goal, const PList &horn, ExecContext *c)
285+static __forceinline bool PList_match(const PList &goal, const PList &horn, ExecContext *c) __attribute__((always_inline))
286286 {
287287 if ( horn.lvalue->match_h_g( *goal.lvalue, c) && horn.rvalue->match_h_g( *goal.rvalue, c) ) return true;
288288 return false;
@@ -311,7 +311,7 @@
311311 bool PList::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); }
312312
313313 /*************************************** PArray ******************************************/
314-static inline bool PArray_unify(const PArray &goal, const PArray &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal)
314+static __forceinline bool PArray_unify(const PArray &goal, const PArray &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
315315 {
316316 size_t gsiz = goal.value.size();
317317 size_t hsiz = horn.value.size();
@@ -361,7 +361,7 @@
361361 return true;
362362 }
363363
364-static inline bool PArray_match(const PArray &goal, const PArray &horn, ExecContext *c)
364+static __forceinline bool PArray_match(const PArray &goal, const PArray &horn, ExecContext *c) __attribute__((always_inline))
365365 {
366366 size_t gsiz = goal.value.size();
367367 size_t hsiz = horn.value.size();
@@ -433,7 +433,7 @@
433433 bool PArray::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); }
434434
435435 /*************************************** PPredicate ******************************************/
436-static inline bool PPredicate_unify(const PPredicate &goal, const PPredicate &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal)
436+static __forceinline bool PPredicate_unify(const PPredicate &goal, const PPredicate &horn, ExecContextRoot *c, VLocal *glocal, VLocal *hlocal) __attribute__((always_inline))
437437 {
438438 // 呼び出し側(goal)がnamespaceを指定した場合、namespaceが一致している必要がある。
439439 if ( !goal.nspace.empty() && strcmp( horn.nspace.c_str(), goal.nspace.c_str()) != 0 ) { return false; }
@@ -442,7 +442,7 @@
442442 return goal.arglist.unify( horn.arglist, c, glocal, hlocal); // horn.arglistがPObjectでない場合はこのように呼び出す
443443 }
444444
445-static inline bool PPredicate_match(const PPredicate &goal, const PPredicate &horn, ExecContext *c)
445+static __forceinline bool PPredicate_match(const PPredicate &goal, const PPredicate &horn, ExecContext *c) __attribute__((always_inline))
446446 {
447447 // 呼び出し側(goal)がnamespaceを指定した場合、namespaceが一致している必要がある。
448448 if ( !goal.nspace.empty() && strcmp( horn.nspace.c_str(), goal.nspace.c_str()) != 0 ) { return false; }
@@ -552,18 +552,6 @@
552552 bool PEVeriable::match_g_h(const PVeriable &horn, ExecContext *c) const { return vmatch_ver_g_h(*this, horn, c, vl, c->hl); }
553553 bool PEVeriable::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_ver_g_h(*this, horn, c, vl, horn.vl); }
554554
555-
556-/*************************************** uphorn ******************************************/
557-bool PHorn::upHorn(const PPredicate &goal, ExecContext &c, bool skipnamechk)
558-{
559- if ( skipnamechk ) {
560- // ホーン節頭部の述語名の確認は既に終わっている
561- return goal.arglist.match_g_h( head.arglist, &c); // horn.arglistがPObjectでない場合はこのように呼び出す
562- } else {
563- return goal.match_g_h(head, &c); // horn.arglistがPObjectでない場合はこのように呼び出す
564- }
565-}
566-
567555 /*************************************** getval ******************************************/
568556 const PObject *PList::getval( ExecContextRoot *c) const
569557 {
--- trunk/adp_compile.h (revision 300)
+++ trunk/adp_compile.h (revision 301)
@@ -1980,7 +1980,14 @@
19801980 vstat = vstat_;
19811981 constant = goal_.isc();
19821982 }
1983- bool upHorn( const PPredicate &goal, ExecContext &c, bool skipnamechk);
1983+ bool upHorn( const PPredicate &goal, ExecContext &c, bool skipnamechk) {
1984+ if ( skipnamechk ) {
1985+ // ホーン節頭部の述語名の確認は既に終わっている
1986+ return goal.arglist.match_g_h( head.arglist, &c); // horn.arglistがPObjectでない場合はこのように呼び出す
1987+ } else {
1988+ return goal.match_g_h(head, &c); // horn.arglistがPObjectでない場合はこのように呼び出す
1989+ }
1990+ }
19841991 bool headName( string &name) {
19851992 const PObject *pobj = head.getNamePtr();
19861993 return pobj != 0 && pobj->cnv_string(name);
--- trunk/adp_execute.h (revision 300)
+++ trunk/adp_execute.h (revision 301)
@@ -302,7 +302,8 @@
302302
303303
304304 // Expression functions
305- PObject *add(const PObject *args0, const PObject *args1, PObjectArray *pobjs_, bool w) {
305+ // __forceinlineは指定しない方が速かった
306+ PObject *add(const PObject *args0, const PObject *args1, PObjectArray *pobjs_, bool w) __attribute__((always_inline)) {
306307 // 試しの最適化
307308 const PINTEGER *a1 = args0->p_integer(this);
308309 const PINTEGER *a2 = args1->p_integer(this);
@@ -319,7 +320,7 @@
319320 return args0->getval(this)->add(*args1->getval(this),pobjs_, w);
320321 }
321322
322- PObject *sub(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
323+ PObject *sub(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
323324 // 試しの最適化
324325 const PINTEGER *a1 = args0->p_integer(this);
325326 const PINTEGER *a2 = args1->p_integer(this);
@@ -329,7 +330,7 @@
329330 return args0->getval(this)->sub(*args1->getval(this),pobjs_);
330331 }
331332
332- PObject *mul(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
333+ PObject *mul(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
333334 // 試しの最適化
334335 const PINTEGER *a1 = args0->p_integer(this);
335336 const PINTEGER *a2 = args1->p_integer(this);
@@ -339,7 +340,7 @@
339340 return args0->getval(this)->mul(*args1->getval(this),pobjs_);
340341 }
341342
342- PObject *div(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
343+ PObject *div(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
343344 // 試しの最適化
344345 const PINTEGER *a1 = args0->p_integer(this);
345346 const PINTEGER *a2 = args1->p_integer(this);
@@ -349,7 +350,7 @@
349350 return args0->getval(this)->div(*args1->getval(this),pobjs_);
350351 }
351352
352- PObject *mod(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
353+ PObject *mod(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
353354 // 試しの最適化
354355 const PINTEGER *a1 = args0->p_integer(this);
355356 const PINTEGER *a2 = args1->p_integer(this);
@@ -359,7 +360,7 @@
359360 return args0->getval(this)->mod(*args1->getval(this),pobjs_);
360361 }
361362
362- PObject *_and(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
363+ PObject *_and(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
363364 const PINTEGER *a1 = args0->p_integer(this);
364365 const PINTEGER *a2 = args1->p_integer(this);
365366 if ( a1 && a2 ) {
@@ -368,7 +369,7 @@
368369 return 0;
369370 }
370371
371- PObject *_or(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
372+ PObject *_or(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
372373 const PINTEGER *a1 = args0->p_integer(this);
373374 const PINTEGER *a2 = args1->p_integer(this);
374375 if ( a1 && a2 ) {
@@ -377,7 +378,7 @@
377378 return 0;
378379 }
379380
380- PObject *_xor(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) {
381+ PObject *_xor(const PObject *args0, const PObject *args1, PObjectArray *pobjs_) __attribute__((always_inline)) {
381382 const PINTEGER *a1 = args0->p_integer(this);
382383 const PINTEGER *a2 = args1->p_integer(this);
383384 if ( a1 && a2 ) {
--- trunk/adp.cpp (revision 300)
+++ trunk/adp.cpp (revision 301)
@@ -23,12 +23,12 @@
2323
2424 // 定数
2525 #ifdef ___X64____
26-#define VERSION_TEXT "ADP Ver 0.82.0300 X64 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n"
26+#define VERSION_TEXT "ADP Ver 0.82.0301 X64 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n"
2727 #else
2828 #if _WIN32
29-#define VERSION_TEXT "ADP Ver 0.82.0300 x86 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n"
29+#define VERSION_TEXT "ADP Ver 0.82.0301 x86 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n"
3030 #else
31-#define VERSION_TEXT "ADP Ver 0.82.0300 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n"
31+#define VERSION_TEXT "ADP Ver 0.82.0301 (http://www.adp.la/)\nCopyright (C) 2010-2012 Katsuhisa Ohfuji. This progman is distributed under GPL.\n"
3232 #endif
3333 #endif
3434
Show on old repository browser