diff --git a/oi/CodeGen.cpp b/oi/CodeGen.cpp index 161d8f6..fef0a47 100644 --- a/oi/CodeGen.cpp +++ b/oi/CodeGen.cpp @@ -1258,7 +1258,6 @@ void CodeGen::generate( FuncGen::DefineEncodeData(code); FuncGen::DefineEncodeDataSize(code); FuncGen::DefineStoreData(code); - FuncGen::DefineAddData(code); } FuncGen::DeclareGetContainer(code); diff --git a/oi/FuncGen.cpp b/oi/FuncGen.cpp index 85045fb..dc494f9 100644 --- a/oi/FuncGen.cpp +++ b/oi/FuncGen.cpp @@ -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 typeNames); - static void DefineTopLevelGetSizeRefRet(std::string& testCode, - const std::string& type); - static void DefineTopLevelGetSizeSmartPtr(std::string& testCode, const std::string& rawType, FeatureSet features); diff --git a/oi/OICodeGen.cpp b/oi/OICodeGen.cpp index baffd70..0cbbfc9 100644 --- a/oi/OICodeGen.cpp +++ b/oi/OICodeGen.cpp @@ -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"( - #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) - )"); - } + code.append(R"( + // storage macro definitions ----- + #define SAVE_SIZE(val) + #define SAVE_DATA(val) StoreData(val, returnArg) + )"); 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); - } + funcGen.DeclareStoreData(functionsCode); + funcGen.DeclareEncodeData(functionsCode); + funcGen.DeclareEncodeDataSize(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); - } + funcGen.DefineStoreData(functionsCode); + funcGen.DefineEncodeData(functionsCode); + funcGen.DefineEncodeDataSize(functionsCode); for (auto& structType : structDefType) { // Don't generate member offset asserts for unions since we pad them out @@ -3345,23 +3325,14 @@ 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")) { - funcGen.DefineTopLevelGetSizeSmartPtr(functionsCode, rawTypeName, - config.features); - } else { - funcGen.DefineTopLevelGetSizeRef(functionsCode, rawTypeName, - config.features); - } + if (rootTypeStr.starts_with("unique_ptr") || + rootTypeStr.starts_with("LowPtr") || + rootTypeStr.starts_with("shared_ptr")) { + funcGen.DefineTopLevelGetSizeSmartPtr(functionsCode, rawTypeName, + config.features); } else { - if (linkageName.empty()) { - funcGen.DefineTopLevelGetSizeRefRet(functionsCode, rawTypeName); - } else { - funcGen.DefineTopLevelGetObjectSize(functionsCode, rawTypeName, - linkageName); - } + funcGen.DefineTopLevelGetSizeRef(functionsCode, rawTypeName, + config.features); } } diff --git a/oi/OICodeGen.h b/oi/OICodeGen.h index aab069f..a01548f 100644 --- a/oi/OICodeGen.h +++ b/oi/OICodeGen.h @@ -65,7 +65,6 @@ class OICodeGen { bool topLevel = false; }; - bool useDataSegment; FeatureSet features; std::set containerConfigPaths; std::set 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 getPaddingInfo(); @@ -157,7 +153,6 @@ class OICodeGen { using SortedTypeDefMap = std::vector>; std::string rootTypeStr; - std::string linkageName; std::map unnamedUnion; std::map sizeMap; std::map containerTypeMapDrgn; diff --git a/oi/OID.cpp b/oi/OID.cpp index 9732fd6..e0f810c 100644 --- a/oi/OID.cpp +++ b/oi/OID.cpp @@ -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{