vector<InvokeSet*> lookupInvokeSets(ObjectPtr callable) { assert(invokeTablesInitialized); vector<InvokeSet*> r; for (size_t i = 0; i < invokeTable.size(); ++i) { for (size_t j = 0; j < invokeTable[i].size(); ++j) { InvokeSet* set = invokeTable[i][j]; if (objectEquals(set->callable, callable)) { r.push_back(set); } } } return r; }
TypePtr staticType(ObjectPtr obj) { int h = objectHash(obj); h &= staticTypes.size() - 1; vector<StaticTypePtr> &bucket = staticTypes[h]; for (unsigned i = 0; i < bucket.size(); ++i) { if (objectEquals(obj, bucket[i]->obj)) return bucket[i].ptr(); } StaticTypePtr t = new StaticType(obj); bucket.push_back(t); return t.ptr(); }
InvokeSetPtr lookupInvokeSet(ObjectPtr callable, const vector<TypePtr> &argsKey) { if (!invokeTablesInitialized) initInvokeTables(); int h = objectHash(callable) + objectVectorHash(argsKey); h &= (invokeTable.size() - 1); vector<InvokeSetPtr> &bucket = invokeTable[h]; for (unsigned i = 0; i < bucket.size(); ++i) { InvokeSetPtr invokeSet = bucket[i]; if (objectEquals(invokeSet->callable, callable) && objectVectorEquals(invokeSet->argsKey, argsKey)) { return invokeSet; } } OverloadPtr interface = callableInterface(callable); const vector<OverloadPtr> &overloads = callableOverloads(callable); InvokeSetPtr invokeSet = new InvokeSet(callable, argsKey, interface, overloads); bucket.push_back(invokeSet); return invokeSet; }
InvokeSet* lookupInvokeSet(ObjectPtr callable, llvm::ArrayRef<TypePtr> argsKey) { if (!invokeTablesInitialized) initInvokeTables(); int h = objectHash(callable) + objectVectorHash(argsKey); h &= (invokeTable.size() - 1); llvm::SmallVector<InvokeSet*, 2> &bucket = invokeTable[h]; for (unsigned i = 0; i < bucket.size(); ++i) { InvokeSet* invokeSet = bucket[i]; if (objectEquals(invokeSet->callable, callable) && objectVectorEquals(invokeSet->argsKey, argsKey)) { return invokeSet; } } OverloadPtr interface = callableInterface(callable); llvm::ArrayRef<OverloadPtr> overloads = callableOverloads(callable); InvokeSet* invokeSet = new InvokeSet(callable, argsKey, interface, overloads); invokeSet->shouldLog = shouldLogCallable(callable); bucket.push_back(invokeSet); return invokeSet; }