diff --git a/.circleci/config.yml b/.circleci/config.yml index 286f759..385d2e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,20 +21,6 @@ workflows: oid_test_args: "-ftype-graph" tests_regex: "OidIntegration\\..*" exclude_regex: ".*inheritance_polymorphic.*|.*arrays_member_int0" - - test: - name: test-typed-data-segment-gcc - requires: - - build-gcc - oid_test_args: "-ftyped-data-segment" - tests_regex: "OidIntegration\\..*" - exclude_regex: ".*inheritance_polymorphic.*|.*pointers.*|.*arrays_member_int0|.*cycles_.*" - - test: - name: test-tree-builder-type-checking-gcc - requires: - - build-gcc - oid_test_args: "-ftree-builder-type-checking" - tests_regex: "OidIntegration\\..*" - exclude_regex: ".*inheritance_polymorphic.*|.*pointers.*|.*arrays_member_int0|.*cycles_.*" - coverage: name: coverage requires: diff --git a/oi/CodeGen.cpp b/oi/CodeGen.cpp index fef0a47..1830624 100644 --- a/oi/CodeGen.cpp +++ b/oi/CodeGen.cpp @@ -117,17 +117,14 @@ void addIncludes(const TypeGraph& typeGraph, FeatureSet features, std::string& code) { std::set includes{"cstddef"}; - if (features[Feature::TypedDataSegment]) { + if (features[Feature::TreeBuilderV2]) { + code += "#define DEFINE_DESCRIBE 1\n"; // added before all includes + includes.emplace("functional"); + includes.emplace("oi/exporters/inst.h"); + includes.emplace("oi/types/dy.h"); includes.emplace("oi/types/st.h"); } - if (features[Feature::TreeBuilderTypeChecking]) { - includes.emplace("oi/types/dy.h"); - - code += "#define DEFINE_DESCRIBE 1\n"; // added before all includes - } - if (features[Feature::TreeBuilderV2]) - includes.emplace("oi/exporters/inst.h"); if (features[Feature::Library]) { includes.emplace("vector"); includes.emplace("oi/IntrospectionResult.h"); @@ -830,8 +827,7 @@ void CodeGen::genClassTypeHandler(const Class& c, std::string& code) { code += " using type = "; genClassStaticType(c, code); code += ";\n"; - if (config_.features[Feature::TreeBuilderV2]) - genClassTreeBuilderInstructions(c, code); + genClassTreeBuilderInstructions(c, code); genClassTraversalFunction(c, code); code += "};\n"; } @@ -846,19 +842,6 @@ void genContainerTypeHandler(FeatureSet features, if (!used.insert(&c).second) return; - if (!features[Feature::TreeBuilderV2]) { - const auto& handler = c.codegen.handler; - if (handler.empty()) { - LOG(ERROR) << "`codegen.handler` must be specified for all containers " - "under \"-ftyped-data-segment\", not specified for \"" + - c.typeName + "\""; - throw std::runtime_error("missing `codegen.handler`"); - } - auto fmt = boost::format(c.codegen.handler) % c.typeName; - code += fmt.str(); - return; - } - code += c.codegen.extra; // TODO: Move this check into the ContainerInfo parsing once always enabled. @@ -1216,14 +1199,14 @@ void CodeGen::generate( if (!config_.features[Feature::Library]) { FuncGen::DeclareExterns(code); } - if (!config_.features[Feature::TypedDataSegment]) { + if (!config_.features[Feature::TreeBuilderV2]) { defineMacros(code); } addIncludes(typeGraph, config_.features, code); defineInternalTypes(code); FuncGen::DefineJitLog(code, config_.features); - if (config_.features[Feature::TypedDataSegment]) { + if (config_.features[Feature::TreeBuilderV2]) { if (config_.features[Feature::Library]) { FuncGen::DefineBackInserterDataBuffer(code); } else { @@ -1231,10 +1214,8 @@ void CodeGen::generate( } code += "using namespace oi;\n"; code += "using namespace oi::detail;\n"; - if (config_.features[Feature::TreeBuilderV2]) { - code += "using oi::exporters::ParsedData;\n"; - code += "using namespace oi::exporters;\n"; - } + code += "using oi::exporters::ParsedData;\n"; + code += "using namespace oi::exporters;\n"; code += "namespace OIInternal {\nnamespace {\n"; FuncGen::DefineBasicTypeHandlers(code, config_.features); code += "} // namespace\n} // namespace OIInternal\n"; @@ -1254,7 +1235,7 @@ void CodeGen::generate( * process faster. */ code += "namespace OIInternal {\nnamespace {\n"; - if (!config_.features[Feature::TypedDataSegment]) { + if (!config_.features[Feature::TreeBuilderV2]) { FuncGen::DefineEncodeData(code); FuncGen::DefineEncodeDataSize(code); FuncGen::DefineStoreData(code); @@ -1269,7 +1250,7 @@ void CodeGen::generate( genExclusiveSizes(typeGraph, code); } - if (config_.features[Feature::TypedDataSegment]) { + if (config_.features[Feature::TreeBuilderV2]) { addStandardTypeHandlers(typeGraph, config_.features, code); addTypeHandlers(typeGraph, code); } else { @@ -1286,10 +1267,8 @@ void CodeGen::generate( code += "} // namespace\n} // namespace OIInternal\n"; const auto typeName = SymbolService::getTypeName(drgnType); - if (config_.features[Feature::Library]) { + if (config_.features[Feature::TreeBuilderV2]) { FuncGen::DefineTopLevelIntrospect(code, typeName); - } else if (config_.features[Feature::TypedDataSegment]) { - FuncGen::DefineTopLevelGetSizeRefTyped(code, typeName, config_.features); } else { FuncGen::DefineTopLevelGetSizeRef(code, typeName, config_.features); } @@ -1298,8 +1277,6 @@ void CodeGen::generate( FuncGen::DefineTreeBuilderInstructions(code, typeName, calculateExclusiveSize(rootType), enumerateTypeNames(rootType)); - } else if (config_.features[Feature::TreeBuilderTypeChecking]) { - FuncGen::DefineOutputType(code, typeName); } if (!linkageName_.empty()) diff --git a/oi/ContainerInfo.cpp b/oi/ContainerInfo.cpp index a5703be..40ca6b4 100644 --- a/oi/ContainerInfo.cpp +++ b/oi/ContainerInfo.cpp @@ -274,10 +274,6 @@ ContainerInfo::ContainerInfo(const fs::path& path) { } else { throw ContainerInfoError(path, "`codegen.decl` is a required field"); } - if (std::optional str = - codegenToml["handler"].value()) { - codegen.handler = std::move(*str); - } if (std::optional str = codegenToml["traversal_func"].value()) { codegen.traversalFunc = std::move(*str); @@ -324,5 +320,5 @@ ContainerInfo::ContainerInfo(std::string typeName_, ctype(ctype_), header(std::move(header_)), codegen(Codegen{"// DummyDecl %1%\n", "// DummyFunc %1%\n", - "// DummyHandler %1%\n", "// DummyFunc\n"}) { + "// DummyFunc\n"}) { } diff --git a/oi/ContainerInfo.h b/oi/ContainerInfo.h index 0ad9da9..376274d 100644 --- a/oi/ContainerInfo.h +++ b/oi/ContainerInfo.h @@ -36,7 +36,6 @@ struct ContainerInfo { struct Codegen { std::string decl; std::string func; - std::string handler = ""; std::string traversalFunc = ""; std::string extra = ""; std::vector processors{}; diff --git a/oi/Features.cpp b/oi/Features.cpp index baf9344..9d82b17 100644 --- a/oi/Features.cpp +++ b/oi/Features.cpp @@ -40,11 +40,6 @@ std::optional featureHelp(Feature f) { return "Use Type Graph for code generation (CodeGen v2)."; case Feature::PruneTypeGraph: return "Prune unreachable nodes from the type graph"; - case Feature::TypedDataSegment: - return "Use Typed Data Segment in generated code."; - case Feature::TreeBuilderTypeChecking: - return "Use Typed Data Segment to perform runtime Type Checking in " - "TreeBuilder."; case Feature::Library: return std::nullopt; // Hide in OID help case Feature::TreeBuilderV2: @@ -65,14 +60,8 @@ std::optional featureHelp(Feature f) { std::span requirements(Feature f) { switch (f) { - case Feature::TypedDataSegment: - static constexpr std::array tds = {Feature::TypeGraph}; - return tds; - case Feature::TreeBuilderTypeChecking: - static constexpr std::array tc = {Feature::TypedDataSegment}; - return tc; case Feature::TreeBuilderV2: - static constexpr std::array tb2 = {Feature::TreeBuilderTypeChecking}; + static constexpr std::array tb2 = {Feature::TypeGraph}; return tb2; case Feature::Library: static constexpr std::array lib = {Feature::TreeBuilderV2}; diff --git a/oi/Features.h b/oi/Features.h index 2e92ba0..1d039b7 100644 --- a/oi/Features.h +++ b/oi/Features.h @@ -29,8 +29,6 @@ X(CaptureThriftIsset, "capture-thrift-isset") \ X(TypeGraph, "type-graph") \ X(PruneTypeGraph, "prune-type-graph") \ - X(TypedDataSegment, "typed-data-segment") \ - X(TreeBuilderTypeChecking, "tree-builder-type-checking") \ X(Library, "library") \ X(TreeBuilderV2, "tree-builder-v2") \ X(GenJitDebug, "gen-jit-debug") \ diff --git a/oi/FuncGen.cpp b/oi/FuncGen.cpp index dc494f9..d4f0e1e 100644 --- a/oi/FuncGen.cpp +++ b/oi/FuncGen.cpp @@ -352,83 +352,6 @@ void FuncGen::DefineTopLevelGetSizeRef(std::string& testCode, testCode.append(fmt.str()); } -/* - * DefineTopLevelGetSizeRefTyped - * - * Top level function to run OI on a type utilising static types and enabled - * with feature '-ftyped-data-segment'. - */ -void FuncGen::DefineTopLevelGetSizeRefTyped(std::string& testCode, - const std::string& rawType, - FeatureSet features) { - std::string func = R"( - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunknown-attributes" - /* RawType: %1% */ - void __attribute__((used, retain)) getSize_%2$016x(const OIInternal::__ROOT_TYPE__& t) - #pragma GCC diagnostic pop - { - )"; - if (features[Feature::JitTiming]) { - func += " const auto startTime = std::chrono::steady_clock::now();\n"; - } - func += R"( - pointers.initialize(); - pointers.add((uintptr_t)&t); - auto data = reinterpret_cast(dataBase); - - // TODO: Replace these with types::st::Uint64 once the VarInt decoding - // logic is moved out of OIDebugger and into new TreeBuilder. - size_t dataSegOffset = 0; - data[dataSegOffset++] = oidMagicId; - data[dataSegOffset++] = cookieValue; - uintptr_t& writtenSize = data[dataSegOffset++]; - writtenSize = 0; - uintptr_t& timeTakenNs = data[dataSegOffset++]; - - dataSegOffset *= sizeof(uintptr_t); - JLOG("%1% @"); - JLOGPTR(&t); - - using ContentType = OIInternal::TypeHandler::type; - using SuffixType = types::st::Pair< - DataBuffer::DataSegment, - types::st::VarInt, - types::st::VarInt - >; - using DataBufferType = types::st::Pair< - DataBuffer::DataSegment, - ContentType, - SuffixType - >; - - DataBufferType db = DataBuffer::DataSegment(dataSegOffset); - SuffixType suffix = db.delegate([&t](auto ret) { - return OIInternal::getSizeType(t, ret); - }); - types::st::Unit end = suffix - .write(123456789) - .write(123456789); - - dataSegOffset = end.offset(); - writtenSize = dataSegOffset; - dataBase += dataSegOffset; - )"; - if (features[Feature::JitTiming]) { - func += R"( - timeTakenNs = std::chrono::duration_cast( - std::chrono::steady_clock::now() - startTime).count(); - )"; - } - func += R"( - } - )"; - - boost::format fmt = - boost::format(func) % rawType % std::hash{}(rawType); - testCode.append(fmt.str()); -} - /* * DefineOutputType * @@ -803,23 +726,6 @@ ContainerInfo FuncGen::GetOiArrayContainerInfo() { ContainerInfo oiArray{"OIArray", UNKNOWN_TYPE, "cstdint"}; // TODO: remove the need for a dummy header - oiArray.codegen.handler = R"( -template -struct TypeHandler> { - using type = types::st::List::type>; - static types::st::Unit getSizeType( - const %1% &container, - typename TypeHandler>::type returnArg) { - auto tail = returnArg.write(N); - for (size_t i=0; i::getSizeType(container.vals[i], ret); - }); - } - return tail.finish(); - } -}; -)"; oiArray.codegen.traversalFunc = R"( auto tail = returnArg.write(N0); for (size_t i=0; i>, 7>{{ - {Feature::TypedDataSegment, {headers::oi_types_st_h, "oi/types/st.h"}}, - {Feature::TreeBuilderTypeChecking, - {headers::oi_types_dy_h, "oi/types/dy.h"}}, + {Feature::TreeBuilderV2, {headers::oi_types_st_h, "oi/types/st.h"}}, + {Feature::TreeBuilderV2, {headers::oi_types_dy_h, "oi/types/dy.h"}}, {Feature::TreeBuilderV2, {headers::oi_exporters_inst_h, "oi/exporters/inst.h"}}, {Feature::TreeBuilderV2, diff --git a/oi/OIGenerator.cpp b/oi/OIGenerator.cpp index d98e7b8..d929de1 100644 --- a/oi/OIGenerator.cpp +++ b/oi/OIGenerator.cpp @@ -181,8 +181,6 @@ int OIGenerator::generate(fs::path& primaryObject, SymbolService& symbols) { std::map featuresMap = { {Feature::TypeGraph, true}, - {Feature::TypedDataSegment, true}, - {Feature::TreeBuilderTypeChecking, true}, {Feature::TreeBuilderV2, true}, {Feature::Library, true}, {Feature::PackStructs, true}, diff --git a/oi/OILibraryImpl.cpp b/oi/OILibraryImpl.cpp index bade97c..6562cc8 100644 --- a/oi/OILibraryImpl.cpp +++ b/oi/OILibraryImpl.cpp @@ -174,8 +174,6 @@ namespace { std::map convertFeatures(std::unordered_set fs) { std::map out{ {Feature::TypeGraph, true}, - {Feature::TypedDataSegment, true}, - {Feature::TreeBuilderTypeChecking, true}, {Feature::TreeBuilderV2, true}, {Feature::Library, true}, {Feature::PackStructs, true}, diff --git a/types/README.md b/types/README.md index ebde86c..e2b70fd 100644 --- a/types/README.md +++ b/types/README.md @@ -62,14 +62,10 @@ This document describes the format of the container definition files contained i will collide if they share the same name. -## Changes introduced with Typed Data Segment -- `decl` and `func` fields are ignored when using `-ftyped-data-segment` and the - `handler` field is used instead. - ## Changes introduced with TreeBuilder V2 -- `decl`, `func`, and `handler` fields are ignored when using `-ftree-builder-v2`. - The `TypeHandler` is instead constructed from `traversal_func` and `processor` - entries. +- `decl` and `func` fields are ignored when using `-ftree-builder-v2`. The + `TypeHandler` is constructed from `traversal_func` field and `processor` + entries. ## Changes introduced with TypeGraph - `typeName` and `matcher` fields have been merged into the single field `type_name`.