Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove oil v1 leftovers #394

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion oi/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,6 @@ void CodeGen::generate(
FuncGen::DefineEncodeData(code);
FuncGen::DefineEncodeDataSize(code);
FuncGen::DefineStoreData(code);
FuncGen::DefineAddData(code);
}
FuncGen::DeclareGetContainer(code);

Expand Down
57 changes: 0 additions & 57 deletions oi/FuncGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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"(
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 0 additions & 11 deletions oi/FuncGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
Expand All @@ -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);
Expand Down
65 changes: 18 additions & 47 deletions oi/OICodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down
5 changes: 0 additions & 5 deletions oi/OICodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class OICodeGen {
bool topLevel = false;
};

bool useDataSegment;
FeatureSet features;
std::set<std::filesystem::path> containerConfigPaths;
std::set<std::string> defaultHeaders;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion oi/OID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down