From 2103212164c4ba717940991ec3bf222b17073d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Mon, 25 Jul 2022 18:34:07 +0200 Subject: [PATCH] Manually inline System.identityHashCode into Object.hashCode. Since there is a dedicated IR node for the identity hash code, we can directly use that in `j.l.Object.hashCode()`. This simplifies the hard-coded IR of `j.l.Object`, and allows to remove `System` from the minilib. --- project/JavaLangObject.scala | 10 +++------- project/MiniLib.scala | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/project/JavaLangObject.scala b/project/JavaLangObject.scala index 8ebc44f2d6..2487e451a9 100644 --- a/project/JavaLangObject.scala +++ b/project/JavaLangObject.scala @@ -63,7 +63,7 @@ object JavaLangObject { GetClass(This()(ThisType)) })(OptimizerHints.empty.withInline(true), None), - /* def hashCode(): Int = System.identityHashCode(this) */ + /* def hashCode(): Int = (this) */ MethodDef( MemberFlags.empty, MethodIdent(MethodName("hashCode", Nil, IntRef)), @@ -71,12 +71,8 @@ object JavaLangObject { Nil, IntType, Some { - Apply( - EAF, - LoadModule(ClassName("java.lang.System$")), - MethodIdent(MethodName("identityHashCode", List(ObjectClassRef), IntRef)), - List(This()(ThisType)))(IntType) - })(OptimizerHints.empty, None), + IdentityHashCode(This()(ThisType)) + })(OptimizerHints.empty.withInline(true), None), /* def equals(that: Object): Boolean = this eq that */ MethodDef( diff --git a/project/MiniLib.scala b/project/MiniLib.scala index 2b873dc5f3..a9b9026765 100644 --- a/project/MiniLib.scala +++ b/project/MiniLib.scala @@ -5,7 +5,6 @@ object MiniLib { val inJavaLang = List( "Object", "Class", - "System", "CharSequence", "Cloneable",