[wasm] Add WasmCodeRefScope for printing

Add a WasmCodeRefScope around _v8_internal_Print_Code() because that
is needed for debugging.

R=clemensh@chromium.org

Change-Id: Ifdb7a32695163e0a109567ec00a52196e79e03db
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1585844
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Commit-Queue: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61047}
diff --git a/src/objects-printer.cc b/src/objects-printer.cc
index 8c3c647..d086207 100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -2741,12 +2741,15 @@
   i::Address address = reinterpret_cast<i::Address>(object);
   i::Isolate* isolate = i::Isolate::Current();
 
-  i::wasm::WasmCode* wasm_code =
-      isolate->wasm_engine()->code_manager()->LookupCode(address);
-  if (wasm_code) {
-    i::StdoutStream os;
-    wasm_code->Disassemble(nullptr, os, address);
-    return;
+  {
+    i::wasm::WasmCodeRefScope scope;
+    i::wasm::WasmCode* wasm_code =
+        isolate->wasm_engine()->code_manager()->LookupCode(address);
+    if (wasm_code) {
+      i::StdoutStream os;
+      wasm_code->Disassemble(nullptr, os, address);
+      return;
+    }
   }
 
   if (!isolate->heap()->InSpaceSlow(address, i::CODE_SPACE) &&