remove oil v1 leftovers

This commit is contained in:
Jake Hillion 2023-10-27 07:06:09 -07:00 committed by Jake Hillion
parent 6f623e95a4
commit 6e1635ce1e
6 changed files with 18 additions and 122 deletions

View File

@ -1258,7 +1258,6 @@ void CodeGen::generate(
FuncGen::DefineEncodeData(code);
FuncGen::DefineEncodeDataSize(code);
FuncGen::DefineStoreData(code);
FuncGen::DefineAddData(code);
}
FuncGen::DeclareGetContainer(code);

View File

@ -142,12 +142,6 @@ void FuncGen::DeclareGetSize(std::string& testCode, const std::string& type) {
testCode.append(fmt.str());
}
void FuncGen::DeclareTopLevelGetSize(std::string& testCode,
const std::string& type) {
boost::format fmt = boost::format("void getSizeType(const %1% &t);\n") % type;
testCode.append(fmt.str());
}
void FuncGen::DeclareExterns(std::string& code) {
constexpr std::string_view vars = R"(
extern uint8_t* dataBase;
@ -202,9 +196,6 @@ void __jlogptr(uintptr_t ptr) {
void FuncGen::DeclareStoreData(std::string& testCode) {
testCode.append("void StoreData(uintptr_t data, size_t& dataSegOffset);\n");
}
void FuncGen::DeclareAddData(std::string& testCode) {
testCode.append("void AddData(uint64_t data, size_t& dataSegOffset);\n");
}
void FuncGen::DeclareEncodeData(std::string& testCode) {
testCode.append("size_t EncodeVarint(uint64_t val, uint8_t* buf);\n");
}
@ -260,33 +251,6 @@ void FuncGen::DefineStoreData(std::string& testCode) {
testCode.append(func);
}
void FuncGen::DefineAddData(std::string& testCode) {
std::string func = R"(
void AddData(uint64_t data, size_t& output) {
output += data;
}
)";
testCode.append(func);
}
void FuncGen::DefineTopLevelGetObjectSize(std::string& testCode,
const std::string& rawType,
const std::string& linkageName) {
std::string func = R"(
/* RawType: %1% */
extern "C" int %2%(const OIInternal::__ROOT_TYPE__* ObjectAddr, size_t* ObjectSize)
{
*ObjectSize = 0;
OIInternal::getSizeType(*ObjectAddr, *ObjectSize);
return 0;
}
)";
boost::format fmt = boost::format(func) % rawType % linkageName;
testCode.append(fmt.str());
}
void FuncGen::DefineTopLevelIntrospect(std::string& code,
const std::string& type) {
std::string func = R"(
@ -528,27 +492,6 @@ const std::array<std::string_view, )";
code += "#pragma GCC diagnostic pop\n";
}
void FuncGen::DefineTopLevelGetSizeRefRet(std::string& testCode,
const std::string& rawType) {
std::string func = R"(
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-attributes"
/* Raw Type: %1% */
size_t __attribute__((used, retain)) getSize(const OIInternal::__ROOT_TYPE__& t)
#pragma GCC diagnostic pop
{
pointers.initialize();
size_t ret = 0;
pointers.add((uintptr_t)&t);
OIInternal::getSizeType(t, ret);
return ret;
}
)";
boost::format fmt = boost::format(func) % rawType;
testCode.append(fmt.str());
}
void FuncGen::DefineTopLevelGetSizeSmartPtr(std::string& testCode,
const std::string& rawType,
FeatureSet features) {

View File

@ -35,9 +35,6 @@ class FuncGen {
static void DeclareStoreData(std::string& testCode);
static void DefineStoreData(std::string& testCode);
static void DeclareAddData(std::string& testCode);
static void DefineAddData(std::string& testCode);
static void DeclareEncodeData(std::string& testCode);
static void DefineEncodeData(std::string& testCode);
@ -55,11 +52,6 @@ class FuncGen {
static void DeclareGetSize(std::string& testCode, const std::string& type);
static void DeclareTopLevelGetSize(std::string& testCode,
const std::string& type);
static void DefineTopLevelGetObjectSize(std::string& testCode,
const std::string& type,
const std::string& linkageName);
static void DefineTopLevelIntrospect(std::string& code,
const std::string& type);
static void DefineTopLevelIntrospectNamed(std::string& code,
@ -80,9 +72,6 @@ class FuncGen {
size_t exclusiveSize,
std::span<const std::string_view> typeNames);
static void DefineTopLevelGetSizeRefRet(std::string& testCode,
const std::string& type);
static void DefineTopLevelGetSizeSmartPtr(std::string& testCode,
const std::string& rawType,
FeatureSet features);

View File

@ -3025,20 +3025,11 @@ bool OICodeGen::generateJitCode(std::string& code) {
code.append(">\n");
}
code.append("// storage macro definitions -----\n");
if (config.useDataSegment) {
code.append(R"(
// storage macro definitions -----
#define SAVE_SIZE(val)
#define SAVE_DATA(val) StoreData(val, returnArg)
)");
} else {
code.append(R"(
#define SAVE_SIZE(val) AddData(val, returnArg)
#define SAVE_DATA(val)
#define JLOG(str)
#define JLOGPTR(ptr)
)");
}
FuncGen::DefineJitLog(code, config.features);
@ -3240,16 +3231,9 @@ bool OICodeGen::generateJitCode(std::string& code) {
}
}
if (config.useDataSegment || feature(Feature::ChaseRawPointers)) {
funcGen.DeclareStoreData(functionsCode);
}
if (config.useDataSegment) {
funcGen.DeclareEncodeData(functionsCode);
funcGen.DeclareEncodeDataSize(functionsCode);
} else {
funcGen.DeclareAddData(functionsCode);
}
if (!funcGen.DefineGetSizeFuncs(functionsCode, containerTypesFuncDef,
config.features)) {
@ -3296,13 +3280,9 @@ bool OICodeGen::generateJitCode(std::string& code) {
}
}
if (config.useDataSegment) {
funcGen.DefineStoreData(functionsCode);
funcGen.DefineEncodeData(functionsCode);
funcGen.DefineEncodeDataSize(functionsCode);
} else {
funcGen.DefineAddData(functionsCode);
}
for (auto& structType : structDefType) {
// Don't generate member offset asserts for unions since we pad them out
@ -3345,7 +3325,6 @@ bool OICodeGen::generateJitCode(std::string& code) {
/* Start function definitions. First define top level func for root object
*/
auto rawTypeName = drgn_utils::typeToName(type);
if (config.useDataSegment) {
if (rootTypeStr.starts_with("unique_ptr") ||
rootTypeStr.starts_with("LowPtr") ||
rootTypeStr.starts_with("shared_ptr")) {
@ -3355,14 +3334,6 @@ bool OICodeGen::generateJitCode(std::string& code) {
funcGen.DefineTopLevelGetSizeRef(functionsCode, rawTypeName,
config.features);
}
} else {
if (linkageName.empty()) {
funcGen.DefineTopLevelGetSizeRefRet(functionsCode, rawTypeName);
} else {
funcGen.DefineTopLevelGetObjectSize(functionsCode, rawTypeName,
linkageName);
}
}
}
// Add definitions for Thrift data storage types.

View File

@ -65,7 +65,6 @@ class OICodeGen {
bool topLevel = false;
};
bool useDataSegment;
FeatureSet features;
std::set<std::filesystem::path> containerConfigPaths;
std::set<std::string> defaultHeaders;
@ -126,9 +125,6 @@ class OICodeGen {
drgn_qualified_type getRootType();
void setRootType(drgn_qualified_type rt);
void setLinkageName(std::string name) {
linkageName = name;
};
TypeHierarchy getTypeHierarchy();
std::map<std::string, PaddingInfo> getPaddingInfo();
@ -157,7 +153,6 @@ class OICodeGen {
using SortedTypeDefMap = std::vector<std::pair<drgn_type*, drgn_type*>>;
std::string rootTypeStr;
std::string linkageName;
std::map<drgn_type*, std::string> unnamedUnion;
std::map<std::string, size_t> sizeMap;
std::map<drgn_type*, ContainerTypeMapEntry> containerTypeMapDrgn;

View File

@ -666,7 +666,6 @@ int main(int argc, char* argv[]) {
OICompiler::Config compilerConfig{};
OICodeGen::Config codeGenConfig;
codeGenConfig.useDataSegment = true;
codeGenConfig.features = {}; // fill in after processing the config file
TreeBuilder::Config tbConfig{