MCPcopy Create free account
hub / github.com/ZDoom/Raze / Codegen

Method Codegen

source/common/scripting/jit/jit.cpp:108–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106};
107
108asmjit::CCFunc *JitCompiler::Codegen()
109{
110 Setup();
111
112 int lastLine = -1;
113
114 pc = sfunc->Code;
115 auto end = pc + sfunc->CodeSize;
116 while (pc != end)
117 {
118 int i = (int)(ptrdiff_t)(pc - sfunc->Code);
119 op = pc->op;
120
121 int curLine = sfunc->PCToLine(pc);
122 if (curLine != lastLine)
123 {
124 lastLine = curLine;
125
126 auto label = cc.newLabel();
127 cc.bind(label);
128
129 JitLineInfo info;
130 info.Label = label;
131 info.LineNumber = curLine;
132 LineInfo.Push(info);
133 }
134
135 if (op != OP_PARAM && op != OP_PARAMI && op != OP_VTBL)
136 {
137 FString lineinfo;
138 lineinfo.Format("; line %d: %02x%02x%02x%02x %s", curLine, pc->op, pc->a, pc->b, pc->c, OpNames[op]);
139 cc.comment("", 0);
140 cc.comment(lineinfo.GetChars(), lineinfo.Len());
141 }
142
143 labels[i].cursor = cc.getCursor();
144 ResetTemp();
145 EmitOpcode();
146
147 pc++;
148 }
149
150 BindLabels();
151
152 cc.endFunc();
153 cc.finalize();
154
155 auto code = cc.getCode ();
156 for (unsigned int j = 0; j < LineInfo.Size (); j++)
157 {
158 auto info = LineInfo[j];
159
160 if (!code->isLabelValid (info.Label))
161 {
162 continue;
163 }
164
165 info.InstructionIndex = code->getLabelOffset (info.Label);

Callers 2

JitDumpLogFunction · 0.80
AddJitFunctionFunction · 0.80

Calls 15

PCToLineMethod · 0.80
LenMethod · 0.80
getCursorMethod · 0.80
endFuncMethod · 0.80
getLabelOffsetMethod · 0.80
newLabelMethod · 0.45
bindMethod · 0.45
PushMethod · 0.45
FormatMethod · 0.45
commentMethod · 0.45
GetCharsMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected