qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 07/22] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN


From: Richard Henderson
Subject: Re: [PATCH 07/22] plugins: Use emit_before_op for PLUGIN_GEN_AFTER_INSN
Date: Tue, 19 Mar 2024 09:56:33 -1000
User-agent: Mozilla Thunderbird

On 3/19/24 03:32, Pierrick Bouvier wrote:
  static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb)
  {
-    TCGOp *op;
+    TCGOp *op, *next;
      int insn_idx = -1;
      pr_ops();
-    QTAILQ_FOREACH(op, &tcg_ctx->ops, link) {
+    /*
+     * While injecting code, we cannot afford to reuse any ebb temps
+     * that might be live within the existing opcode stream.
+     * The simplest solution is to release them all and create new.
+     */
+    memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps));
+

Not an expert at this, but wouldn't that break an existing TB that already has some ops on those temps?

No, this only affects allocation of new temps -- if free_temps is empty, a new temp will be allocated from tcg_ctx->nb_temps++.

Zeroing free_temps here ensures that we *do not* reuse a temp that might already be live across any plugin insertion point. Between insertion points, we will free plugin temps and only reuse those.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]