Closed Bug 1706190 Opened 5 years ago Closed 5 years ago

Simplify arguments to IRGenerator constructor

Categories

(Core :: JavaScript Engine: JIT, task, P3)

task

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: iain, Assigned: mehaboob097, Mentored)

References

Details

(Keywords: good-first-bug)

Attachments

(1 file)

Note: this bug is currently reserved for Outreachy applicants for the Spring/Summer 2021 cycle. If it has not been completed by the end of the application cycle, we will open it up.

Background

Inline caches (ICs) are an important technique for optimizing JS. When we execute code that has many possible behaviours (for example, a + b might be addition or string concatenation, depending on what a and b are), we call a fallback function that tries to attach an IC stub. (For example, it might check whether a and b are numbers, and immediately return their sum if they are.) The next time we execute that code, we will try the stub first, and only execute the fallback function if the stub fails. If the code is polymorphic, we may attach several stubs to the same IC chain.

There are many different kinds of IC, each of which has its own implementation of IRGenerator.

This Bug

In bug 1695396, we modified IRGenerator and its subclasses so that we know whether this is the first time we have ever executed this code. We do this by looking at the ICState and passing an isFirstStub argument into each constructor.

We were already passing a mode argument to each constructor, which also comes from the ICState. To reduce the number of arguments, we should replace the mode and isFirstStub arguments to the IRGenerator constructor with a single ICState& argument, and use it to initialize isFirstStub_ and mode_. This will make it easier to make similar changes in the future.

We should also move the implementation of newStubIsFirstStub from ICFallbackStub into ICState, to make it easier to share between baseline and Ion ICs.

To fix this bug, you will likely have to modify CacheIR.h, CacheIR.cpp, BaselineIC.cpp, IonIC.cpp, and ICState.h. Looking at the patch for bug 1695396 is a good starting point.

When you're done, you should be able to run the test suite (./mach jit-test) without any failures. (You will want to build SpiderMonkey with --enable-optimize --enable-debug while running the tests.)

Prerequisites

Before getting started, you'll want to ensure:

Getting help

Leave comments on this bug for questions, or ask in #spidermonkey on chat.mozilla.org.

Hello Iain,
I'd like to take up this bug.

Just a few doubts before getting started :

  1. Unlike the previous patch, now I will have to remove isFirstStub along with mode from all the constructors (also from protected member of IRGenerator) that I have passed into earlier right ?

  2. But then then will be no need of isFirstStub anywhere because we directly call it from ICState by using newStubIsFirstStub

one more thing is that can you let me know how to check for these whitespaces before submission.
I have used an extension in VScode to remove whitespaces and also checked using clang-format to remove these but still one or two white blanks remained

Assignee: nobody → mehaboob097
Status: NEW → ASSIGNED

Hi Iain ,
I'd have made a submission but there is a mistake I did while trying to solve the conflicts (merged with some other patch so there are some changes in code which I haven't made and is causing an error) as sfink suggested.
I'll correct it and submit again

I think I answered most of these questions on the Phabricator revision.

I believe clang-format should remove end-of-line whitespace, so the only other whitespace changes you have to watch out for are new/removed newlines. Skimming through the output of hg diff to see if there are any changes that don't belong should be sufficient. If one sneaks through, it's not a big deal.

Hi Iain,
Sorry I haven't refreshed the phabricator page so I didn't see your message and made a submit.
I have just seen your approach but I already changed the code that is using mode and isFirstStub , if it a problem then let me know I'll change the code again and resubmit.
Thank you for the clarification on the merge conflict part and also noted about the convention of commit message.

Attachment #9217451 - Attachment description: Bug 1706190: Simplified the arguments to IRGenerator constructor r=iain → Bug 1706190: Simplify the arguments to IRGenerator constructor r=iain

would you mind if you could point me to some other good bugs as I couldn't find one which is not occupied

Pushed by iireland@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b35ee13d7aa5 Simplify the arguments to IRGenerator constructor r=iain

Is there something that needs to be done?

Flags: needinfo?(mehaboob097)
Pushed by iireland@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e3261528439b Simplify the arguments to IRGenerator constructor r=iain
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: