Closed
Bug 617254
Opened 15 years ago
Closed 15 years ago
Array changes to support ap-style arguments arrays
Categories
(Tamarin Graveyard :: Virtual Machine, enhancement)
Tamarin Graveyard
Virtual Machine
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: alexmac, Unassigned)
References
Details
Attachments
(1 file, 5 obsolete files)
|
4.83 KB,
patch
|
stejohns
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Build Identifier:
When transitioning from functions that require the ap-style convention to those that need the vm-style convention we need to parse a va_list and generate a dense Atom array suitable for use by an ArrayObject. I've pushed this logic inside ArrayClass/Object so that we can directly construct an ArrayObject given a cdecl argument descriptor and a va_list without exposing the inner working of ArrayObject to the rest of the codebase.
Reproducible: Always
| Reporter | ||
Comment 1•15 years ago
|
||
Attachment #495765 -
Flags: review?(stejohns)
| Reporter | ||
Updated•15 years ago
|
Attachment #495765 -
Flags: review?(lhansen)
Updated•15 years ago
|
Attachment #495765 -
Attachment is patch: true
Attachment #495765 -
Attachment mime type: application/octet-stream → text/plain
Comment 2•15 years ago
|
||
This can't land until the exactgc changes have landed (sometime this week), but otherwise there shouldn't be any problem. I will try to review it by early next week (big backlog).
Comment 3•15 years ago
|
||
Comment on attachment 495765 [details] [diff] [review]
Array changes
Rejecting only because I don't want to approve List::getRawPtr(), even ifdef AOT, unless it's shown that it's unacceptable to access the list entries via existing API. Otherwise looks OK.
If ArrayObject::getDenseCopy() is used only by AOT, it should be #ifdef FEATURE_AOT.
style nit: template args in Tamarin are generally all-caps, so
template <typename adt>
would be better off as
template <typename ADT>
style nit: preferred style in Tamarin is "if (cond)", not "if(cond)". Ditto "for ()" vs "for()".
Attachment #495765 -
Flags: review?(stejohns) → review-
| Reporter | ||
Comment 4•15 years ago
|
||
fixed the stylistic bugs with the previous patch
Attachment #495765 -
Attachment is obsolete: true
Attachment #495871 -
Flags: review?(stejohns)
Attachment #495765 -
Flags: review?(lhansen)
| Reporter | ||
Updated•15 years ago
|
Attachment #495871 -
Flags: review?(lhansen)
| Reporter | ||
Comment 5•15 years ago
|
||
(In reply to comment #3)
> Rejecting only because I don't want to approve List::getRawPtr(), even ifdef
> AOT, unless it's shown that it's unacceptable to access the list entries via
> existing API.
It would require a re-write of a large part of the cdecl code which I'd like to avoid at this stage of the game. Another approach that would avoid the direct access to the underlying buffer would be if we could construct an ArrayObject with a given Atom* buffer, but I couldn't see a clean way of doing that...
| Reporter | ||
Comment 6•15 years ago
|
||
missed a file in the updated patch
Attachment #495871 -
Attachment is obsolete: true
Attachment #495875 -
Flags: review?(stejohns)
Attachment #495871 -
Flags: review?(stejohns)
Attachment #495871 -
Flags: review?(lhansen)
| Reporter | ||
Updated•15 years ago
|
Attachment #495875 -
Flags: review?(lhansen)
Comment 7•15 years ago
|
||
(In reply to comment #5)
> access to the underlying buffer would be if we could construct an ArrayObject
> with a given Atom* buffer, but I couldn't see a clean way of doing that...
There is such a way; see
ArrayObject* ArrayClass::newarray(Atom* argv, int argc)
Comment 8•15 years ago
|
||
(In reply to comment #7)
> (In reply to comment #5)
> > access to the underlying buffer would be if we could construct an ArrayObject
> > with a given Atom* buffer, but I couldn't see a clean way of doing that...
>
> There is such a way; see
> ArrayObject* ArrayClass::newarray(Atom* argv, int argc)
Before I review the revised patch, could you take a look and see if this would solve your issue, allowing us to avoid getRawPtr()?
| Reporter | ||
Comment 9•15 years ago
|
||
(In reply to comment #8)
> (In reply to comment #7)
> > There is such a way; see
> > ArrayObject* ArrayClass::newarray(Atom* argv, int argc)
>
> Before I review the revised patch, could you take a look and see if this would
> solve your issue, allowing us to avoid getRawPtr()?
We're trying to avoid the unnecessary double allocation and copy, "newarray(Atom* argv, int argc)" copies the data out of the buffer rather than capturing the pointer
Comment 10•15 years ago
|
||
Wait, what? You want to alias the pointer from an Array? Sorry, I won't approve that.
| Reporter | ||
Comment 11•15 years ago
|
||
(In reply to comment #10)
> Wait, what? You want to alias the pointer from an Array? Sorry, I won't approve
> that.
no, no I don't want to do that. We need to convert a va_list into an ArrayObject, previously we would allocate an Atom* array parse the arg descriptor and put all the right atoms into this array, we would then pass this array to newArray(Atom*, int argc) so it could copy the data out and then we would delete our temporary array.
The proposed changes in this patch avoid this unnecessary allocation by creating an ArrayObject of the right size and then storing values directly into the backing store for the array object, ideally we'd do this with the exposed get/set operators but that would require a re-write of most of cdecl, instead we use the slightly ugly "getRawPtr()".
Comment 12•15 years ago
|
||
(In reply to comment #11)
> instead
> we use the slightly ugly "getRawPtr()".
The problem is not that it's slightly ugly; the problem is that it's allowing you to dance directly on the underlying storage of the List. This may happen to work correctly right now, but is 100% guaranteed to break in the future (in fact, I'll be quite surprised if this works properly post-ExactGC). The old List class had a way to peek directly at the data, and it was misused in various scary ways; I really don't want to re-open that door, even if this is specific for AOT.
| Reporter | ||
Comment 13•15 years ago
|
||
now with 100% less getRawPtr and a lot more cdecl refactoring
Attachment #496354 -
Flags: review?(stejohns)
| Reporter | ||
Updated•15 years ago
|
Attachment #496354 -
Flags: review?(lhansen)
| Reporter | ||
Updated•15 years ago
|
Attachment #496354 -
Flags: review?(speterse)
| Reporter | ||
Updated•15 years ago
|
Attachment #495875 -
Attachment is obsolete: true
Attachment #495875 -
Flags: review?(stejohns)
Attachment #495875 -
Flags: review?(lhansen)
Updated•15 years ago
|
Attachment #496354 -
Flags: review?(stejohns) → review+
Comment 14•15 years ago
|
||
Is this patch also including the cdecl refactoring?
| Reporter | ||
Comment 15•15 years ago
|
||
Updated to take the recent GC work into account and I've moved the cdecl work back into its original patch
Attachment #496354 -
Attachment is obsolete: true
Attachment #499002 -
Flags: review?(lhansen)
Attachment #496354 -
Flags: review?(speterse)
Attachment #496354 -
Flags: review?(lhansen)
Comment 16•15 years ago
|
||
Comment on attachment 499002 [details] [diff] [review]
Array changes v5
This seems fine. You can optimize the write barrier in denseCopy() a hair if you are concerned about performance because you know that the existing values in the array are NULL, hence there's no need to check whether a decrementref is needed - use atomWriteBarrier_ctor instead of plain atomWriteBarrier.
The multiplication in the call to AllocPtrZero is only safe because we know you're copying out of a structure that's as large as the one you're copying into, but that's pretty subtle and in general this kind of length calculation is prone to result in security problems and is considered very bad style indeed. Use Calloc() instead. Suggest you change it when you land the patch.
Attachment #499002 -
Flags: review?(lhansen) → review+
| Reporter | ||
Comment 17•15 years ago
|
||
rebase to take into account recent changes
Attachment #499002 -
Attachment is obsolete: true
Updated•15 years ago
|
Attachment #502535 -
Flags: review+
Comment 18•15 years ago
|
||
TR 5854:f33e20e92f91
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•