VirtualBox

Changeset 100744 in vbox


Ignore:
Timestamp:
Jul 31, 2023 8:57:57 AM (16 months ago)
Author:
vboxsync
Message:

VMM/IEM: Reworking the recompiler call emitting in the python script in preparation for compile time (gcc) optimizations. bugref:10369

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllThrdPython.py

    r100743 r100744  
    10341034            return self.aoVariations[0].emitThreadedCallStmts(0);
    10351035
    1036         # Currently only have variations for address mode.
     1036        class Case:
     1037            def __init__(self, sCond, aoBody = None):
     1038                self.sCond  = sCond;
     1039                self.aoBody = aoBody  # type: list(iai.McCppGeneric)
     1040            def toCode(self):
     1041                aoStmts = [ iai.McCppGeneric('case %s:' % (self.sCond), cchIndent = 4), ];
     1042                aoStmts.extend(self.aoBody);
     1043                aoStmts.append(iai.McCppGeneric('break;', cchIndent = 8));
     1044                return aoStmts;
     1045
     1046        # Generate the case statements.
     1047        # pylintx: disable=x
    10371048        dByVari = self.dVariations;
    1038 
     1049        aoCases = [];
     1050        if ThreadedFunctionVariation.ksVariation_64_Addr32 in dByVari:
     1051            aoCases.append(Case('IEMMODE_64BIT', [
     1052                iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_64BIT)', fDecode = True, cchIndent = 8,
     1053                              aoIfBranch   = dByVari[ThrdFnVar.ksVariation_64].emitThreadedCallStmts(0),
     1054                              aoElseBranch = dByVari[ThrdFnVar.ksVariation_64_Addr32].emitThreadedCallStmts(0)),
     1055            ]));
     1056        elif ThrdFnVar.ksVariation_64 in dByVari:
     1057            aoCases.append(Case('IEMMODE_64BIT', dByVari[ThrdFnVar.ksVariation_64].emitThreadedCallStmts(8)));
     1058
     1059        if ThrdFnVar.ksVariation_32_Addr16 in dByVari:
     1060            aoCases.extend([
     1061                Case('IEMMODE_32BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK', [
     1062                    iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_32BIT)', fDecode = True, cchIndent = 8,
     1063                                  aoIfBranch   = dByVari[ThrdFnVar.ksVariation_32_Flat].emitThreadedCallStmts(0),
     1064                                  aoElseBranch = dByVari[ThrdFnVar.ksVariation_32_Addr16].emitThreadedCallStmts(0)),
     1065                ]),
     1066                Case('IEMMODE_32BIT', [
     1067                    iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_32BIT)', fDecode = True, cchIndent = 8,
     1068                                  aoIfBranch   = dByVari[ThrdFnVar.ksVariation_32].emitThreadedCallStmts(0),
     1069                                  aoElseBranch = dByVari[ThrdFnVar.ksVariation_32_Addr16].emitThreadedCallStmts(0)),
     1070                ]),
     1071            ]);
     1072        elif ThrdFnVar.ksVariation_32 in dByVari:
     1073            aoCases.append(Case('IEMMODE_32BIT', dByVari[ThrdFnVar.ksVariation_32].emitThreadedCallStmts(8)));
     1074
     1075        if ThrdFnVar.ksVariation_16_Addr32 in dByVari:
     1076            aoCases.append(Case('IEMMODE_16BIT', [
     1077                iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_16BIT)', fDecode = True, cchIndent = 8,
     1078                              aoIfBranch   = dByVari[ThrdFnVar.ksVariation_16].emitThreadedCallStmts(0),
     1079                              aoElseBranch = dByVari[ThrdFnVar.ksVariation_16_Addr32].emitThreadedCallStmts(0)),
     1080            ]));
     1081        elif ThrdFnVar.ksVariation_16 in dByVari:
     1082            aoCases.append(Case('IEMMODE_16BIT', dByVari[ThrdFnVar.ksVariation_16].emitThreadedCallStmts(8)));
     1083
     1084        if ThrdFnVar.ksVariation_16_Pre386 in dByVari:
     1085            aoCases.append(Case('IEMMODE_16BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK',
     1086                                dByVari[ThrdFnVar.ksVariation_16_Pre386].emitThreadedCallStmts(8)));
     1087
     1088        # Generate the switch statement.
    10391089        sExecMask = 'IEM_F_MODE_CPUMODE_MASK';
    1040         if (   ThreadedFunctionVariation.ksVariation_64_Addr32 in dByVari
    1041             or ThreadedFunctionVariation.ksVariation_32_Addr16 in dByVari
    1042             or ThreadedFunctionVariation.ksVariation_32_Flat   in dByVari
    1043             or ThreadedFunctionVariation.ksVariation_16_Addr32 in dByVari):
     1090        if (   ThrdFnVar.ksVariation_64_Addr32 in dByVari
     1091            or ThrdFnVar.ksVariation_32_Addr16 in dByVari
     1092            or ThrdFnVar.ksVariation_32_Flat   in dByVari
     1093            or ThrdFnVar.ksVariation_16_Addr32 in dByVari):
    10441094            sExecMask = '(IEM_F_MODE_CPUMODE_MASK | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK)';
     1095
    10451096        aoStmts = [
    10461097            iai.McCppGeneric('switch (pVCpu->iem.s.fExec & %s)' % (sExecMask,)),
    10471098            iai.McCppGeneric('{'),
    10481099        ];
    1049 
    1050         if ThreadedFunctionVariation.ksVariation_64_Addr32 in dByVari:
    1051             aoStmts.extend([
    1052                 iai.McCppGeneric('case IEMMODE_64BIT:', cchIndent = 4),
    1053                 iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_64BIT)', fDecode = True, cchIndent = 8,
    1054                               aoIfBranch   = dByVari[ThreadedFunctionVariation.ksVariation_64].emitThreadedCallStmts(0),
    1055                               aoElseBranch = dByVari[ThreadedFunctionVariation.ksVariation_64_Addr32].emitThreadedCallStmts(0)),
    1056                 iai.McCppGeneric('break;', cchIndent = 8),
    1057             ]);
    1058         elif ThreadedFunctionVariation.ksVariation_64 in dByVari:
    1059             aoStmts.append(iai.McCppGeneric('case IEMMODE_64BIT:', cchIndent = 4));
    1060             aoStmts.extend(dByVari[ThreadedFunctionVariation.ksVariation_64].emitThreadedCallStmts(8));
    1061             aoStmts.append(iai.McCppGeneric('break;', cchIndent = 8));
    1062 
    1063         if ThreadedFunctionVariation.ksVariation_32_Addr16 in dByVari:
    1064             aoStmts.extend([
    1065                 iai.McCppGeneric('case IEMMODE_32BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK:', cchIndent = 4),
    1066                 iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_32BIT)', fDecode = True, cchIndent = 8,
    1067                               aoIfBranch   = dByVari[ThreadedFunctionVariation.ksVariation_32_Flat].emitThreadedCallStmts(0),
    1068                               aoElseBranch = dByVari[ThreadedFunctionVariation.ksVariation_32_Addr16].emitThreadedCallStmts(0)),
    1069                 iai.McCppGeneric('break;', cchIndent = 8),
    1070                 iai.McCppGeneric('case IEMMODE_32BIT:', cchIndent = 4),
    1071                 iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_32BIT)', fDecode = True, cchIndent = 8,
    1072                               aoIfBranch   = dByVari[ThreadedFunctionVariation.ksVariation_32].emitThreadedCallStmts(0),
    1073                               aoElseBranch = dByVari[ThreadedFunctionVariation.ksVariation_32_Addr16].emitThreadedCallStmts(0)),
    1074                 iai.McCppGeneric('break;', cchIndent = 8),
    1075             ]);
    1076         elif ThreadedFunctionVariation.ksVariation_32 in dByVari:
    1077             aoStmts.append(iai.McCppGeneric('case IEMMODE_32BIT:', cchIndent = 4));
    1078             aoStmts.extend(dByVari[ThreadedFunctionVariation.ksVariation_32].emitThreadedCallStmts(8));
    1079             aoStmts.append(iai.McCppGeneric('break;', cchIndent = 8));
    1080 
    1081         if ThreadedFunctionVariation.ksVariation_16_Addr32 in dByVari:
    1082             aoStmts.extend([
    1083                 iai.McCppGeneric('case IEMMODE_16BIT:', cchIndent = 4),
    1084                 iai.McCppCond('RT_LIKELY(pVCpu->iem.s.enmEffAddrMode == IEMMODE_16BIT)', fDecode = True, cchIndent = 8,
    1085                               aoIfBranch   = dByVari[ThreadedFunctionVariation.ksVariation_16].emitThreadedCallStmts(0),
    1086                               aoElseBranch = dByVari[ThreadedFunctionVariation.ksVariation_16_Addr32].emitThreadedCallStmts(0)),
    1087                 iai.McCppGeneric('break;', cchIndent = 8),
    1088             ]);
    1089         elif ThreadedFunctionVariation.ksVariation_16 in dByVari:
    1090             aoStmts.append(iai.McCppGeneric('case IEMMODE_16BIT:', cchIndent = 4));
    1091             aoStmts.extend(dByVari[ThreadedFunctionVariation.ksVariation_16].emitThreadedCallStmts(8));
    1092             aoStmts.append(iai.McCppGeneric('break;', cchIndent = 8));
    1093 
    1094         if ThreadedFunctionVariation.ksVariation_16_Pre386 in dByVari:
    1095             aoStmts.append(iai.McCppGeneric('case IEMMODE_16BIT | IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK:', cchIndent = 4));
    1096             aoStmts.extend(dByVari[ThreadedFunctionVariation.ksVariation_16_Pre386].emitThreadedCallStmts(8));
    1097             aoStmts.append(iai.McCppGeneric('break;', cchIndent = 8));
    1098 
     1100        for oCase in aoCases:
     1101            aoStmts.extend(oCase.toCode());
    10991102        aoStmts.extend([
    11001103            iai.McCppGeneric('IEM_NOT_REACHED_DEFAULT_CASE_RET();', cchIndent = 4),
     
    11751178        return iai.McStmt.renderCodeForList(self.morphInputCode(self.oMcBlock.aoStmts)[0],
    11761179                                            cchIndent = cchIndent).replace('\n', ' /* gen */\n', 1);
     1180
     1181# Short alias for ThreadedFunctionVariation.
     1182ThrdFnVar = ThreadedFunctionVariation;
    11771183
    11781184
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette