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

Method Invoke

core/codegen/builder.go:80–106  ·  view source on GitHub ↗

Invoke invokes the function f with the specified arguments. If an exception is thrown while calling f, then cleanup will be called before rethrowing the exception.

(f *Function, cleanup func(), args ...*Value)

Source from the content-addressed store, hash-verified

78// If an exception is thrown while calling f, then cleanup will be called before
79// rethrowing the exception.
80func (b *Builder) Invoke(f *Function, cleanup func(), args ...*Value) *Value {
81 fn, sig, name := f.llvm, f.Type.Signature, f.Name
82
83 l := b.callArgs(sig, name, args)
84
85 then := b.m.ctx.AddBasicBlock(b.function.llvm, fmt.Sprintf("%v_nothrow", name))
86 throw := b.m.ctx.AddBasicBlock(b.function.llvm, fmt.Sprintf("%v_catch", name))
87
88 if sig.Result == b.m.Types.Void {
89 name = ""
90 }
91
92 res := b.val(sig.Result, b.llvm.CreateInvoke(fn, l, then, throw, name))
93
94 b.function.llvm.SetPersonality(b.m.exceptions.personalityFn.llvm)
95
96 b.block(throw, llvm.BasicBlock{}, func() {
97 lp := b.llvm.CreateLandingPad(b.m.exceptions.exceptionTy.llvmTy(), 0, "cleanup")
98 lp.SetCleanup(true)
99 cleanup()
100 b.llvm.CreateResume(lp)
101 })
102
103 b.setInsertPointAtEnd(then)
104
105 return res
106}
107
108// Throw throws an exception with the given value.
109func (b *Builder) Throw(v *Value) {

Callers

nothing calls this directly

Calls 5

callArgsMethod · 0.95
valMethod · 0.95
blockMethod · 0.95
setInsertPointAtEndMethod · 0.95
llvmTyMethod · 0.65

Tested by

no test coverage detected