Closed Bug 1452818 Opened 4 years ago Closed 4 years ago

Eliminate the need for BytecodeCompiler::startPosition to be default-constructable

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

Details

Attachments

(2 files)

Some of the Unicode character-type work wants to be able to create character iterators that have Rust-like borrow-checking semantics.  Part of this requires that iterators always be initialized, which means they should never be default-constructed.

Unfortunately, TokenStreamCharsBase::Position *is* default-constructed now.  This can be fixed: move the single Position where this is necessary to a location where it can be constructed fully initialized, and then initialize those positions by directly constructing them from a |tokenStream|.
This doesn't really change anything, but it does get rid of a very small amount of useless code-execution when not compiling things that don't have handleParseFailure failure modes.
Attachment #8966427 - Flags: review?(arai.unmht)
Attachment #8966427 - Flags: review?(arai.unmht) → review+
Attachment #8966428 - Flags: review?(arai.unmht) → review+
Pushed by jwalden@mit.edu:
https://hg.mozilla.org/integration/mozilla-inbound/rev/d21bb4d700d8
Move BytecodeCompiler::startPosition into more locally-scoped stack-frame variables.  r=arai
https://hg.mozilla.org/integration/mozilla-inbound/rev/4f2a7bac2733
Make tokenstream positions be created by constructor-call so that their members don't have to be default-constructible.  r=arai
https://hg.mozilla.org/mozilla-central/rev/d21bb4d700d8
https://hg.mozilla.org/mozilla-central/rev/4f2a7bac2733
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Oh, for anyone wondering -- we have to have a |Position foo(...)| local declared that way, not a function that returns a Position, because returning a Position that way pre-C++17 is not guaranteed to not need to invoke a copy constructor or similar, and I may need to have that requirement for the work that motivated this.
You need to log in before you can comment on or make changes to this bug.