MCPcopy Create free account
hub / github.com/bytedance/bolt / codegen

Method codegen

bolt/jit/RowContainer/RowContainerCodeGenerator.cpp:111–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109} // namespace
110
111CompiledModuleSP RowContainerCodeGenerator::codegen() {
112 auto fn = GetCmpFuncName();
113
114 auto jit = ThrustJITv2::getInstance();
115
116 if (auto mod = jit->LookupSymbolsInCache(fn)) {
117 return mod;
118 }
119
120 auto genIR = [this](llvm::Module& m) -> bool {
121 ensureBuiltinDeclarations(m);
122 this->setModule(&m);
123 return this->GenCmpIR();
124 };
125
126 auto module = jit->CompileModule(genIR, fn);
127 if (isEqualOp() || !flags.empty()) { // only for row cmp/= row
128 auto cacheTypes = std::make_unique<std::vector<bytedance::bolt::TypePtr>>();
129 for (auto& t : keysTypes) {
130 switch (t->kind()) {
131 case bytedance::bolt::TypeKind::ARRAY:
132 case bytedance::bolt::TypeKind::ROW:
133 case bytedance::bolt::TypeKind::MAP:
134 cacheTypes->push_back(t);
135 break;
136 default:
137 break;
138 }
139 }
140
141 if (cacheTypes->size() > 0) {
142 auto* userData = static_cast<void*>(cacheTypes.get());
143 if (module->compareExchangeUserData(nullptr, userData)) {
144 cacheTypes.release();
145 module->appendCleanCallback([mod = module.get()] {
146 auto* raw = mod->getUserData();
147 mod->compareExchangeUserData(raw, nullptr);
148 auto* cacheTypes =
149 static_cast<std::vector<bytedance::bolt::TypePtr>*>(raw);
150 delete cacheTypes;
151 });
152 }
153 }
154 }
155 return module;
156}
157
158/// util functions
159std::string RowContainerCodeGenerator::GetCmpFuncName() {

Callers 3

codegenCompareMethod · 0.80
codegenRowEqVectorsMethod · 0.80
TEST_FFunction · 0.80

Calls 13

GenCmpIRMethod · 0.95
LookupSymbolsInCacheMethod · 0.80
CompileModuleMethod · 0.80
appendCleanCallbackMethod · 0.80
getUserDataMethod · 0.80
emptyMethod · 0.45
kindMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by 1

TEST_FFunction · 0.64