インライン化の徹底(一部インライン関数にしない方が早かった)
@@ -53,7 +53,7 @@ | ||
53 | 53 | /*************************************** unify ******************************************/ |
54 | 54 | |
55 | 55 | // 変項の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)) | |
57 | 57 | { |
58 | 58 | const PObject *gitem = (*glocal)[goal.idx]; |
59 | 59 | if ( gitem == 0 ) { |
@@ -65,7 +65,7 @@ | ||
65 | 65 | return true; |
66 | 66 | } |
67 | 67 | |
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)) | |
69 | 69 | { |
70 | 70 | const PObject *item = (*hlocal)[horn.idx]; |
71 | 71 | if ( item == 0 ) { |
@@ -77,7 +77,7 @@ | ||
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
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)) | |
81 | 81 | { |
82 | 82 | const PObject *item = (*glocal)[goal.idx]; |
83 | 83 | if ( item == 0 ) { |
@@ -89,7 +89,7 @@ | ||
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | |
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)) | |
93 | 93 | { |
94 | 94 | const PObject *gitem = (*glocal)[goal.idx]; |
95 | 95 | if ( gitem == 0 ) { |
@@ -102,7 +102,7 @@ | ||
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | |
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)) | |
106 | 106 | { |
107 | 107 | const PObject *item = (*hlocal)[horn.idx]; |
108 | 108 | if ( item == 0 ) { |
@@ -119,7 +119,7 @@ | ||
119 | 119 | return true; |
120 | 120 | } |
121 | 121 | |
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)) | |
123 | 123 | { |
124 | 124 | const PObject *item = (*glocal)[goal.idx]; |
125 | 125 | if ( item == 0 ) { |
@@ -136,7 +136,7 @@ | ||
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | |
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)) | |
140 | 140 | { |
141 | 141 | const PObject *gval = (*glocal)[goal.idx]; |
142 | 142 | const PObject *hval = (*hlocal)[horn.idx]; |
@@ -156,7 +156,7 @@ | ||
156 | 156 | return true; |
157 | 157 | } |
158 | 158 | |
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)) | |
160 | 160 | { |
161 | 161 | const PObject *gval = (*glocal)[goal.idx]; |
162 | 162 | const PObject *hval = (*hlocal)[horn.idx]; |
@@ -271,18 +271,18 @@ | ||
271 | 271 | bool PInteger::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_h_g(horn, *this, c, horn.vl); } |
272 | 272 | |
273 | 273 | /*************************************** PList ******************************************/ |
274 | -static inline bool PList_unify(const PList &list) | |
274 | +static __forceinline bool PList_unify(const PList &list) __attribute__((always_inline)) | |
275 | 275 | { |
276 | 276 | if ( typeid(*list.lvalue) == typeid(PNil) && typeid(*list.rvalue) == typeid(PNil) ) return true; |
277 | 277 | return false; |
278 | 278 | } |
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)) | |
280 | 280 | { |
281 | 281 | if ( horn.lvalue->unify( *goal.lvalue, c, hlocal, glocal) && horn.rvalue->unify( *goal.rvalue, c, hlocal, glocal) ) return true; |
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
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)) | |
286 | 286 | { |
287 | 287 | if ( horn.lvalue->match_h_g( *goal.lvalue, c) && horn.rvalue->match_h_g( *goal.rvalue, c) ) return true; |
288 | 288 | return false; |
@@ -311,7 +311,7 @@ | ||
311 | 311 | bool PList::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); } |
312 | 312 | |
313 | 313 | /*************************************** 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)) | |
315 | 315 | { |
316 | 316 | size_t gsiz = goal.value.size(); |
317 | 317 | size_t hsiz = horn.value.size(); |
@@ -361,7 +361,7 @@ | ||
361 | 361 | return true; |
362 | 362 | } |
363 | 363 | |
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)) | |
365 | 365 | { |
366 | 366 | size_t gsiz = goal.value.size(); |
367 | 367 | size_t hsiz = horn.value.size(); |
@@ -433,7 +433,7 @@ | ||
433 | 433 | bool PArray::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_getval_h_g(horn, *this, c, horn.vl); } |
434 | 434 | |
435 | 435 | /*************************************** 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)) | |
437 | 437 | { |
438 | 438 | // 呼び出し側(goal)がnamespaceを指定した場合、namespaceが一致している必要がある。 |
439 | 439 | if ( !goal.nspace.empty() && strcmp( horn.nspace.c_str(), goal.nspace.c_str()) != 0 ) { return false; } |
@@ -442,7 +442,7 @@ | ||
442 | 442 | return goal.arglist.unify( horn.arglist, c, glocal, hlocal); // horn.arglistがPObjectでない場合はこのように呼び出す |
443 | 443 | } |
444 | 444 | |
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)) | |
446 | 446 | { |
447 | 447 | // 呼び出し側(goal)がnamespaceを指定した場合、namespaceが一致している必要がある。 |
448 | 448 | if ( !goal.nspace.empty() && strcmp( horn.nspace.c_str(), goal.nspace.c_str()) != 0 ) { return false; } |
@@ -552,18 +552,6 @@ | ||
552 | 552 | bool PEVeriable::match_g_h(const PVeriable &horn, ExecContext *c) const { return vmatch_ver_g_h(*this, horn, c, vl, c->hl); } |
553 | 553 | bool PEVeriable::match_g_h(const PEVeriable &horn, ExecContext *c) const { return vmatch_ver_g_h(*this, horn, c, vl, horn.vl); } |
554 | 554 | |
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 | - | |
567 | 555 | /*************************************** getval ******************************************/ |
568 | 556 | const PObject *PList::getval( ExecContextRoot *c) const |
569 | 557 | { |
@@ -1980,7 +1980,14 @@ | ||
1980 | 1980 | vstat = vstat_; |
1981 | 1981 | constant = goal_.isc(); |
1982 | 1982 | } |
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 | + } | |
1984 | 1991 | bool headName( string &name) { |
1985 | 1992 | const PObject *pobj = head.getNamePtr(); |
1986 | 1993 | return pobj != 0 && pobj->cnv_string(name); |
@@ -302,7 +302,8 @@ | ||
302 | 302 | |
303 | 303 | |
304 | 304 | // 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)) { | |
306 | 307 | // 試しの最適化 |
307 | 308 | const PINTEGER *a1 = args0->p_integer(this); |
308 | 309 | const PINTEGER *a2 = args1->p_integer(this); |
@@ -319,7 +320,7 @@ | ||
319 | 320 | return args0->getval(this)->add(*args1->getval(this),pobjs_, w); |
320 | 321 | } |
321 | 322 | |
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)) { | |
323 | 324 | // 試しの最適化 |
324 | 325 | const PINTEGER *a1 = args0->p_integer(this); |
325 | 326 | const PINTEGER *a2 = args1->p_integer(this); |
@@ -329,7 +330,7 @@ | ||
329 | 330 | return args0->getval(this)->sub(*args1->getval(this),pobjs_); |
330 | 331 | } |
331 | 332 | |
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)) { | |
333 | 334 | // 試しの最適化 |
334 | 335 | const PINTEGER *a1 = args0->p_integer(this); |
335 | 336 | const PINTEGER *a2 = args1->p_integer(this); |
@@ -339,7 +340,7 @@ | ||
339 | 340 | return args0->getval(this)->mul(*args1->getval(this),pobjs_); |
340 | 341 | } |
341 | 342 | |
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)) { | |
343 | 344 | // 試しの最適化 |
344 | 345 | const PINTEGER *a1 = args0->p_integer(this); |
345 | 346 | const PINTEGER *a2 = args1->p_integer(this); |
@@ -349,7 +350,7 @@ | ||
349 | 350 | return args0->getval(this)->div(*args1->getval(this),pobjs_); |
350 | 351 | } |
351 | 352 | |
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)) { | |
353 | 354 | // 試しの最適化 |
354 | 355 | const PINTEGER *a1 = args0->p_integer(this); |
355 | 356 | const PINTEGER *a2 = args1->p_integer(this); |
@@ -359,7 +360,7 @@ | ||
359 | 360 | return args0->getval(this)->mod(*args1->getval(this),pobjs_); |
360 | 361 | } |
361 | 362 | |
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)) { | |
363 | 364 | const PINTEGER *a1 = args0->p_integer(this); |
364 | 365 | const PINTEGER *a2 = args1->p_integer(this); |
365 | 366 | if ( a1 && a2 ) { |
@@ -368,7 +369,7 @@ | ||
368 | 369 | return 0; |
369 | 370 | } |
370 | 371 | |
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)) { | |
372 | 373 | const PINTEGER *a1 = args0->p_integer(this); |
373 | 374 | const PINTEGER *a2 = args1->p_integer(this); |
374 | 375 | if ( a1 && a2 ) { |
@@ -377,7 +378,7 @@ | ||
377 | 378 | return 0; |
378 | 379 | } |
379 | 380 | |
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)) { | |
381 | 382 | const PINTEGER *a1 = args0->p_integer(this); |
382 | 383 | const PINTEGER *a2 = args1->p_integer(this); |
383 | 384 | if ( a1 && a2 ) { |
@@ -23,12 +23,12 @@ | ||
23 | 23 | |
24 | 24 | // 定数 |
25 | 25 | #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" | |
27 | 27 | #else |
28 | 28 | #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" | |
30 | 30 | #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" | |
32 | 32 | #endif |
33 | 33 | #endif |
34 | 34 |