Add a 'SINGLETON' directive to kobj interface definition
Summary: This makes the interface described in the definition file act like a pseudo-IFUNC service, by caching the found method locally. Applying this to the PowerPC MMU definitions, it yields a significant (15-20%) performance improvement, seen in both a 'make buildworld' and a parallel build of LLVM, on a POWER9 system. Reviewed By: imp Differential Revision: https://reviews.freebsd.org/D23245
This commit is contained in:
parent
2d0c620272
commit
de8dd262c4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356860
@ -43,6 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
INTERFACE moea64;
|
INTERFACE moea64;
|
||||||
|
SINGLETON;
|
||||||
|
|
||||||
CODE {
|
CODE {
|
||||||
static moea64_pte_replace_t moea64_pte_replace_default;
|
static moea64_pte_replace_t moea64_pte_replace_default;
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
INTERFACE mmu;
|
INTERFACE mmu;
|
||||||
|
SINGLETON;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Default implementations of some methods
|
# Default implementations of some methods
|
||||||
|
@ -325,13 +325,18 @@ function handle_method (static, doc)
|
|||||||
line_width, length(prototype)));
|
line_width, length(prototype)));
|
||||||
}
|
}
|
||||||
printh("{");
|
printh("{");
|
||||||
printh("\tkobjop_t _m;");
|
if (singleton)
|
||||||
|
printh("\tstatic kobjop_t _m;");
|
||||||
|
else
|
||||||
|
printh("\tkobjop_t _m;");
|
||||||
if (ret != "void")
|
if (ret != "void")
|
||||||
printh("\t" ret " rc;");
|
printh("\t" ret " rc;");
|
||||||
if (!static)
|
if (!static)
|
||||||
firstvar = "((kobj_t)" firstvar ")";
|
firstvar = "((kobj_t)" firstvar ")";
|
||||||
if (prolog != "")
|
if (prolog != "")
|
||||||
printh(prolog);
|
printh(prolog);
|
||||||
|
if (singleton)
|
||||||
|
printh("\tif (_m == NULL)");
|
||||||
printh("\tKOBJOPLOOKUP(" firstvar "->ops," mname ");");
|
printh("\tKOBJOPLOOKUP(" firstvar "->ops," mname ");");
|
||||||
rceq = (ret != "void") ? "rc = " : "";
|
rceq = (ret != "void") ? "rc = " : "";
|
||||||
printh("\t" rceq "((" mname "_t *) _m)(" varname_list ");");
|
printh("\t" rceq "((" mname "_t *) _m)(" varname_list ");");
|
||||||
@ -453,6 +458,7 @@ for (file_i = 0; file_i < num_files; file_i++) {
|
|||||||
lastdoc = "";
|
lastdoc = "";
|
||||||
prolog = "";
|
prolog = "";
|
||||||
epilog = "";
|
epilog = "";
|
||||||
|
singleton = 0;
|
||||||
|
|
||||||
while (!error && (getline < src) > 0) {
|
while (!error && (getline < src) > 0) {
|
||||||
lineno++;
|
lineno++;
|
||||||
@ -497,6 +503,8 @@ for (file_i = 0; file_i < num_files; file_i++) {
|
|||||||
prolog = handle_code();
|
prolog = handle_code();
|
||||||
else if (/^EPILOG[ ]*{$/)
|
else if (/^EPILOG[ ]*{$/)
|
||||||
epilog = handle_code();
|
epilog = handle_code();
|
||||||
|
else if (/^SINGLETON/)
|
||||||
|
singleton = 1;
|
||||||
else {
|
else {
|
||||||
debug($0);
|
debug($0);
|
||||||
warnsrc("Invalid line encountered");
|
warnsrc("Invalid line encountered");
|
||||||
|
Loading…
Reference in New Issue
Block a user