Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable the IR checker post optimizer with RT longs#5077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
gzm0 wants to merge4 commits intoscala-js:main
base:main
Choose a base branch
Loading
fromgzm0:ir-check-long

Conversation

gzm0
Copy link
Contributor

The first two commits are not strictly necessary. However, I felt they significantly help understanding of what the optimizer is doing.

@gzm0gzm0force-pushed their-check-long branch 2 times, most recently fromc527a00 to256a2f4CompareNovember 24, 2024 09:26
@gzm0
Copy link
ContributorAuthor

It looks like the change in subtyping checks (3rd commit) causes long literals to become allocated as RT long:

 $c_jl_Math$.prototype.multiplyExact__J__J__J = (function(a, b) {   var ahi = b.RTLong__f_hi;   if (((ahi === 0) ? (b.RTLong__f_lo !== 0) : (ahi > 0))) {-    var this$1 = $m_RTLong$();-    var lo = this$1.divideImpl__I__I__I__I__I((-1), 2147483647, b.RTLong__f_lo, b.RTLong__f_hi);-    var hi = this$1.RTLong$__f_org$scalajs$linker$runtime$RuntimeLong$$hiReturn;+    var this$1 = new $c_RTLong((-1), 2147483647);+    var this$2 = $m_RTLong$();+    var lo = this$2.divideImpl__I__I__I__I__I(this$1.RTLong__f_lo, this$1.RTLong__f_hi, b.RTLong__f_lo, b.RTLong__f_hi);+    var hi = this$2.RTLong$__f_org$scalajs$linker$runtime$RuntimeLong$$hiReturn;     var ahi$1 = a.RTLong__f_hi;     if (((ahi$1 === hi) ? (((-2147483648) ^ a.RTLong__f_lo) > ((-2147483648) ^ lo)) : (ahi$1 > hi))) {       var overflow = true;

I'm trying to identify where the "offending" subtyping check is in the optimizer.

@gzm0
Copy link
ContributorAuthor

I have not gotten to a conclusion here yet. But it seems the issue is due to casts inserted on the receiver when inlining method calls: We need these when, say, calling+ on a literal long for the IR to be correctly typed. OTOH, inserting them (which is what the 3rd commit causes) prevents farther inlining and folding of runtime long methods.

@gzm0
Copy link
ContributorAuthor

I have managed to fix the execution tests: the claim that we never do anisInstance check on RT long was wrong: RT long itself does one in its equals method. As a result, when inliningx.equals(y) with longs, the compiler generated wrong folded constants.

I have not figured out yet what causes long literals to be stack allocated rather than inlined like before.

gzm0 added a commit to gzm0/scala-js that referenced this pull requestJun 1, 2025
Discovered while working onscala-js#5077. This allows to remove unnecessaryunboxes and unlocks more inlining.
Going foward, we want to cast pre transformed records (for longs). Sowe need PreTransCast to avoid eagerly transforming the record.As a nice side effect, we see better receiver variable allocation:```diff--- baseline.js 2025-06-07 09:56:18.846667192 +0200+++ pre-trans-cast.js   2025-06-08 14:20:11.704783221 +0200@@ -17540,8 +17540,7 @@   var logException = ((!$n($thiz.Lorg_scalajs_junit_Reporter__f_settings).Lorg_scalajs_junit_RunSettings__f_notLogExceptionClass) && ($n($thiz.Lorg_scalajs_junit_Reporter__f_settings).Lorg_scalajs_junit_RunSettings__f_logAssert || (!(t instanceof $c_jl_AssertionError))));   if (logException) {     var this$1 = $n(t);-    var this$2 = $objectGetClass(this$1);-    var fmtName = ($p_Lorg_scalajs_junit_Reporter__formatClass__T__T__T($thiz, this$2.data.name, "\u001b[31m") + ": ");+    var fmtName = ($p_Lorg_scalajs_junit_Reporter__formatClass__T__T__T($thiz, $objectClassName(this$1), "\u001b[31m") + ": ");   } else {     var fmtName = "";   }```
Since we have PreTransCast now, we do not need to push down casts topreserve aliases.No diff.Related:6fd9322
This will become relevant, as we introduce casts for RuntimeLong.No diff (TODO: re-check)
This allows us to enable the IRChecker.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@gzm0

[8]ページ先頭

©2009-2025 Movatter.jp