Closed Bug 523348 Opened 16 years ago Closed 16 years ago

Vector and Array functions wrongly assume args won't be modified by callee

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: edwsmith, Assigned: edwsmith)

Details

Attachments

(1 file)

In the course of implementing in-place unboxing in coerceUnboxEnter, I ran into call sites which wrongly assume that calling a function will not modify the args passed in. Our calling protocol requires that the callee can modify the arguments in place, to avoid extra copies and stack allocation. ArrayClass:: generic_every() generic_filter() generic_forEach() generic_some() generic_map() VectorBaseObject:: map() filter()
Assignee: nobody → edwsmith
Attachment #407283 - Flags: review?(tharwood)
Attachment #407283 - Flags: review?(tharwood) → review+
Comment on attachment 407283 [details] [diff] [review] never reuse args after passing them to callee The change to VectorBaseClass::filter() that returns "element" allows the callback to change the property, but puts the previous value into the result. The docs for Vector are not explicit on this point, unsurprisingly. It'd be good to have them updated, too.
The previous code assumed that coerceEnter() made a copy of args[] before calling the callback (which it always does, currently, but is not guaranteed to do). so, it always preserved the old value of element, and the patch preserves this behavior. its true that callback() can mutate the array we're working on, but i haven't intended to change anything in that area.
Attachment #407283 - Flags: superreview?(stejohns)
Comment on attachment 407283 [details] [diff] [review] never reuse args after passing them to callee would be useful to add an arg reminding why the args are done that way, so someone doesn't try to "improve" it in the future
Attachment #407283 - Flags: superreview?(stejohns) → superreview+
will do. (s/arg/comment)
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: