split the method cache into 2 buckets. one for instance methods, another for class methods. the method type doesn't have to stored after this split.
This commit is contained in:
		| @ -775,7 +775,7 @@ static int async_signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem) | ||||
| 		moo_oop_semaphore_t* tmp; | ||||
|  | ||||
| 		new_capa = moo->sem_list_capa + SEM_LIST_INC; /* TODO: overflow check.. */ | ||||
| 		tmp = moo_reallocmem(moo, moo->sem_list, MOO_SIZEOF(moo_oop_semaphore_t) * new_capa); | ||||
| 		tmp = (moo_oop_semaphore_t*)moo_reallocmem(moo, moo->sem_list, MOO_SIZEOF(moo_oop_semaphore_t) * new_capa); | ||||
| 		if (!tmp) return -1; | ||||
|  | ||||
| 		moo->sem_list = tmp; | ||||
| @ -1729,9 +1729,9 @@ moo_oop_method_t moo_findmethod (moo_t* moo, moo_oop_t receiver, moo_oop_char_t | ||||
| 	mcidx &= (MOO_METHOD_CACHE_SIZE - 1);*/ | ||||
| 	/*mcidx = ((moo_oow_t)c + (moo_oow_t)selector) % MOO_METHOD_CACHE_SIZE; */ | ||||
| 	mcidx = ((moo_oow_t)_class ^ (moo_oow_t)selector) & (MOO_METHOD_CACHE_SIZE - 1); | ||||
| 	mcitm = &moo->method_cache[mcidx]; | ||||
| 	mcitm = &moo->method_cache[mth_type][mcidx]; | ||||
| 	 | ||||
| 	if (mcitm->receiver_class == c  && mcitm->selector == selector && mcitm->method_type == mth_type) | ||||
| 	if (mcitm->receiver_class == c  && mcitm->selector == selector /*&& mcitm->method_type == mth_type*/) | ||||
| 	{ | ||||
| 		/* cache hit */ | ||||
| 		/* TODO: moo->method_cache_hits++; */ | ||||
| @ -1745,7 +1745,7 @@ moo_oop_method_t moo_findmethod (moo_t* moo, moo_oop_t receiver, moo_oop_char_t | ||||
| 		/* TODO: moo->method_cache_misses++; */ | ||||
| 		mcitm->receiver_class = c; | ||||
| 		mcitm->selector = selector; | ||||
| 		mcitm->method_type = mth_type; | ||||
| 		/*mcitm->method_type = mth_type;*/ | ||||
| 		mcitm->method = mth; | ||||
| 		return mth; | ||||
| 	} | ||||
| @ -1762,9 +1762,9 @@ not_found: | ||||
| 		mcidx &= (MOO_METHOD_CACHE_SIZE - 1); */ | ||||
| 		/* mcidx = ((moo_oow_t)_class + (moo_oow_t)selector) % MOO_METHOD_CACHE_SIZE; */ | ||||
| 		mcidx = ((moo_oow_t)_class ^ (moo_oow_t)selector) & (MOO_METHOD_CACHE_SIZE - 1); | ||||
| 		mcitm = &moo->method_cache[mcidx]; | ||||
| 		mcitm = &moo->method_cache[MOO_METHOD_INSTANCE][mcidx]; | ||||
|  | ||||
| 		if (mcitm->receiver_class == _class  && mcitm->selector == selector && mcitm->method_type == MOO_METHOD_INSTANCE) | ||||
| 		if (mcitm->receiver_class == _class  && mcitm->selector == selector /*&& mcitm->method_type == MOO_METHOD_INSTANCE*/) | ||||
| 		{ | ||||
| 			/* cache  hit */ | ||||
| 			/* TODO: moo->method_cache_hits++; */ | ||||
| @ -1777,7 +1777,7 @@ not_found: | ||||
| 			/* TODO: moo->method_cache_misses++; */ | ||||
| 			mcitm->receiver_class = c; | ||||
| 			mcitm->selector = selector; | ||||
| 			mcitm->method_type = MOO_METHOD_INSTANCE; | ||||
| 			/*mcitm->method_type = MOO_METHOD_INSTANCE;*/ | ||||
| 			mcitm->method = mth; | ||||
| 			return mth; | ||||
| 		} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user