Closed Bug 1037319 Opened 12 years ago Closed 8 days ago

IonMonkey: ensureOsiSpace inserts too many nop instructions for padding on ARM.

Categories

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

ARM
All
defect

Tracking

()

RESOLVED DUPLICATE of bug 2089860

People

(Reporter: dougc, Unassigned, Mentored)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

CodeGeneratorShared::ensureOsiSpace() does not appear to account for the size of the NOP instruction being 4 bytes on the ARM and MIPS backends which would lead to excessive fill. The source comments are not very clear for a reader with little background in this area of the code, and the comments do not appear to even mention the real issue being addressed by ensureOsiSpace(). There appears to be potential for a clash between a invalidation jump patched in at an OSI point and an invalidation offset written over an immediately adjacent call? There appears to be potential for the patched near call to override a pool guard, and might this invalidate tracing of the code object. Are invalidated code objects ever traced? If there are real issues here then a solution might be to always insert a NOP at the OSI point on the ARM.
Could use some help understanding this code. If you could have a read of the source comment changes and see if they look accurate it would help? Need to sort out the requirements on the assembler here for future work as this code is working with offsets in the code buffer during assembly.
Attachment #8454274 - Flags: feedback?(mrosenberg)
Attachment #8454274 - Flags: feedback?(jdemooij)
Comment on attachment 8454274 [details] [diff] [review] Rework the source comments, and address NOP instruction size. Review of attachment 8454274 [details] [diff] [review]: ----------------------------------------------------------------- That comment is quite useful! ::: js/src/jit/shared/CodeGenerator-shared.cpp @@ +435,5 @@ > if (masm.currentOffset() - lastOsiPointOffset_ < Assembler::PatchWrite_NearCallSize()) { > +#if defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_MIPS) > + unsigned nopSize = 4; > +#else > + unsigned nopSize = 1; As a complete aside, doesn't x86 have 2, 3, and 4 byte nops, so this can always be implemented as a single nop, theoretically making executing this faster?
Attachment #8454274 - Flags: feedback?(mrosenberg) → feedback+
Comment on attachment 8454274 [details] [diff] [review] Rework the source comments, and address NOP instruction size. Review of attachment 8454274 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit/shared/CodeGenerator-shared.cpp @@ +399,5 @@ > // For a refresher, an invalidation point is of the form: > + // call <target> > + // <return address> > + // Code to save the state. > + // <osipoint> "Code to save the state." is pretty vague. It's the code between a VM call instruction emitted as part of a LIR instruction and the LOsiPoint LIR that follows it. @@ +435,4 @@ > if (masm.currentOffset() - lastOsiPointOffset_ < Assembler::PatchWrite_NearCallSize()) { > +#if defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_MIPS) > + unsigned nopSize = 4; > +#else I think it'd be nicer to either add a nop() method to the macro assemblers that takes the number of bytes, or a constant so that you can do i += Assembler::NopSize below. This way we don't need an #ifdef and when we add a new architecture we don't have to update this again.
Attachment #8454274 - Flags: feedback?(jdemooij)
We have a nop(size_t) on x86, I guess it would make sense to add one on ARM as well, even if it has some granularity of 4. The verification of OSI point is ensured by the VerifyOSIPoint implemented as part of the try block implementation in IonMonkey.
Priority: -- → P3
Mentor: nicolas.b.pierron
Summary: IonMonkey: ensuring space between OSI sequences. → IonMonkey: ensureOsiSpace inserts too many nop instructions for padding on ARM.
Severity: normal → S3

This bug is still valid and this should be a simple fix:
https://searchfox.org/mozilla-central/rev/2a69486ab1df00b1ea8ecd14027e2cc6c0415ed0/js/src/jit/shared/CodeGenerator-shared.cpp#951

By incrementing i using the currentOffset instead of counting the number of nop instructions.

The current code will add too many no-op on ARM and ARM64.

Severity: S3 → S4
Status: NEW → RESOLVED
Closed: 8 days ago
Duplicate of bug: 2089860
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: