[dart2wasm] Don't downcast the receiver in Object methods

Methods on Object can be called on the box classes, whose Wasm
representations are not subtypes of the Object struct. Thus, the
downcast of the receiver for the preciseThis local will fail for
instances of these types.

Since the only addition in the Object struct is the identity hash
code, and this is only accessed through the _getHash and _setHash
intrinsics, no Object members need access to the precise receiver.

Change-Id: Ice8d4292019618b71ee6aaf7550010f6d1d29d01
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252380
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
diff --git a/pkg/dart2wasm/lib/code_generator.dart b/pkg/dart2wasm/lib/code_generator.dart
index e10b3e2..0120221 100644
--- a/pkg/dart2wasm/lib/code_generator.dart
+++ b/pkg/dart2wasm/lib/code_generator.dart
@@ -256,7 +256,8 @@
       thisLocal = paramLocals[0];
       w.RefType thisType = info.nonNullableType;
       if (translator.needsConversion(paramLocals[0].type, thisType) &&
-          !(cls == translator.ffiPointerClass ||
+          !(cls == translator.objectInfo.cls ||
+              cls == translator.ffiPointerClass ||
               translator.isFfiCompound(cls))) {
         preciseThisLocal = addLocal(thisType);
         b.local_get(paramLocals[0]);