| 4151 | } |
| 4152 | |
| 4153 | void Program::linkCppAot ( Context & context, AotLibrary & aotLib, TextWriter & logs ) { |
| 4154 | bool logIt = options.getBoolOption("log_aot",false); |
| 4155 | // make list of functions |
| 4156 | vector<Function *> fnn; fnn.reserve(totalFunctions); |
| 4157 | das_hash_map<int,Function *> indexToFunction; |
| 4158 | for (auto & pm : library.modules) { |
| 4159 | pm->functions.foreach([&](auto pfun){ |
| 4160 | if (pfun->index < 0 || !pfun->used || pfun->isTemplate) |
| 4161 | return; |
| 4162 | fnn.push_back(pfun); |
| 4163 | indexToFunction[pfun->index] = pfun; |
| 4164 | }); |
| 4165 | } |
| 4166 | for ( int fni=0, fnis=context.totalFunctions; fni!=fnis; ++fni ) { |
| 4167 | if ( !fnn[fni]->noAot ) { |
| 4168 | SimFunction & fn = context.functions[fni]; |
| 4169 | fnn[fni]->hash = getFunctionHash(fnn[fni], fn.code, &context); |
| 4170 | } |
| 4171 | } |
| 4172 | for ( int fni=0, fnis=context.totalFunctions; fni!=fnis; ++fni ) { |
| 4173 | if ( !fnn[fni]->noAot ) { |
| 4174 | SimFunction & fn = context.functions[fni]; |
| 4175 | uint64_t semHash = getFunctionAotHash(fnn[fni]); |
| 4176 | auto it = aotLib.find(semHash); |
| 4177 | if ( it != aotLib.end() ) { |
| 4178 | fn.code = (it->second)(context); |
| 4179 | fn.aot = true; |
| 4180 | if ( logIt ) logs << fn.mangledName << " AOT=0x" << HEX << semHash << DEC << "\n"; |
| 4181 | auto fcb = (SimNode_CallBase *) fn.code; |
| 4182 | fn.aotFunction = fcb->aotFunction; |
| 4183 | } else { |
| 4184 | if ( logIt ) logs << "NOT FOUND " << fn.mangledName << " AOT=0x" << HEX << semHash << DEC << "\n"; |
| 4185 | TextWriter tp; |
| 4186 | tp << "semantic hash is " << HEX << semHash << DEC << "\n"; |
| 4187 | tp << "// " << getAotHashComment(fnn[fni]) << "\n"; |
| 4188 | printSimFunction(tp, &context, indexToFunction[fni], fn.code, true); |
| 4189 | linkError(string(fn.mangledName), tp.str() ); |
| 4190 | } |
| 4191 | } |
| 4192 | } |
| 4193 | } |
| 4194 | } |
nothing calls this directly
no test coverage detected