Closed Bug 1702601 Opened 3 years ago Closed 3 years ago

Refactor BaseAbstractBindingIter::init to take a struct with compound literals

Categories

(Core :: JavaScript Engine, enhancement, P5)

enhancement

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: mgaudet, Assigned: ashwiniwankhede.aw, Mentored)

Details

Attachments

(2 files, 2 obsolete files)

BaseAbstractBindingIter has this horrible init function that takes a bunch of uint32_t parameters; but this leads to ugly ugly calls like this where you have a bunch of difficult to interpret parameters, and you end up counting zeros just to figure out what's relevant.

I'd like to see this refactored so that the init method takes a struct that we can use compound literals to make it much clearer what's going on; ie. instead of

  init(0, 0, 0, length, length, length,
       CanHaveFrameSlots | CanHaveEnvironmentSlots, firstFrameSlot,
       JSSLOT_FREE(&VarEnvironmentObject::class_),
       GetScopeDataTrailingNames(&data));

I'd like to see something akin to

 BindingIndexes bindingIndex ={.positionalFormalStart = 0, .nonPositionalFormalStart=0, .varStart=0, .letStart=length, .constStart=length}; 
  init(bindingIndexes, length,
       CanHaveFrameSlots | CanHaveEnvironmentSlots, firstFrameSlot,
       JSSLOT_FREE(&VarEnvironmentObject::class_),
       GetScopeDataTrailingNames(&data));
}

That or, an easier refactoring would be just to label all the parameters with comments:

  init(/* positionalFormalStart = */ 0, 
       /* nonPositionalFormalStart = */ 0, 
       ...

ashwiniwankhede is taking a peek at this at the moment.

refactored by labelling all the parameters with comments
changed js/src/vm/Scope.cpp

Assignee: nobody → ashwiniwankhede.aw
Status: NEW → ASSIGNED

implemented desired format changes.
refactored by labelling all the parameters with comments
changed js/src/vm/Scope.cpp

refactored by labelling all the parameters with comments(updated)
changed js/src/vm/Scope.cpp

Attachment #9215151 - Attachment description: Bug 1702601 Refactor BaseAbstractBindingIter::init to take a struct with compound literals r=mgaudet → Differential Revision: Bug 1702601 Refactor BaseAbstractBindingIter::init with commented parameters.
Attachment #9214621 - Attachment description: Bug 1702601 Refactor BaseAbstractBindingIter::init to take a struct with compound literals r=mgaudet → Bug 1702601 Refactor BaseAbstractBindingIter::init with commented parameters r=mgaudet
Attachment #9215151 - Attachment is obsolete: true

Refactored BaseAbstractBindingIter::init to take parameters through struct BindingIndexes

Depends on D111380

Pushed by mgaudet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/dfec7a664567
Refactor BaseAbstractBindingIter::init with commented parameters r=mgaudet
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
Attachment #9215221 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.