MCPcopy Create free account
hub / github.com/google/gapid / Executor

Method Executor

core/codegen/output.go:159–203  ·  view source on GitHub ↗

Executor constructs an executor.

(optimize bool)

Source from the content-addressed store, hash-verified

157
158// Executor constructs an executor.
159func (m *Module) Executor(optimize bool) (*Executor, error) {
160 m.dbg.finalize()
161
162 if err := m.Verify(); err != nil {
163 return nil, err
164 }
165
166 opts := llvm.NewMCJITCompilerOptions()
167 if optimize {
168 opts.SetMCJITOptimizationLevel(2)
169 } else {
170 opts.SetMCJITOptimizationLevel(0)
171 }
172
173 engine, err := llvm.NewMCJITCompiler(m.llvm, opts)
174 if err != nil {
175 return nil, err
176 }
177
178 // Check target data is as expected.
179 m.validateTargetData(engine.TargetData())
180
181 // Check for unresolved extern symbols.
182 var unresolved []string
183 for _, f := range m.funcs {
184 if f.built || strings.HasPrefix(f.Name, "llvm.") {
185 continue
186 }
187 if linker.ProcAddress(f.Name) == 0 {
188 unresolved = append(unresolved, fmt.Sprint(f))
189 }
190 }
191 if len(unresolved) > 0 {
192 sort.Strings(unresolved)
193 msg := fmt.Sprintf("Unresolved external functions:\n%v", strings.Join(unresolved, "\n"))
194 fail(msg)
195 }
196
197 engine.RunStaticConstructors()
198
199 return &Executor{
200 llvm: engine,
201 funcPtrs: map[string]unsafe.Pointer{},
202 }, nil
203}
204
205// FunctionAddress returns the address of the function f.
206func (e *Executor) FunctionAddress(f *Function) unsafe.Pointer {

Callers 2

TestCodegenFunction · 0.95
NewFunction · 0.80

Calls 8

VerifyMethod · 0.95
validateTargetDataMethod · 0.95
finalizeMethod · 0.80
SprintMethod · 0.80
failFunction · 0.70
StringsMethod · 0.65
HasPrefixMethod · 0.45
JoinMethod · 0.45

Tested by 1

TestCodegenFunction · 0.76