Closed Bug 638956 Opened 14 years ago Closed 14 years ago

ANI: Add a clean way to do isType/asType/coerceToType

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stejohns, Assigned: stejohns)

References

Details

Attachments

(1 file, 1 obsolete file)

It's common to do these operations in outside-the-VM glue code, but doing so requires access to the Traits type, which we'd like to reduce knowledge of.
Attached patch Patch (obsolete) — Splinter Review
This adds wrapper methods to all of the class stubs. Since all builtin classes are available via the classmanifest, this allows you to do builtinClasses()->get_StringClass()->isType(someAtom); GCRef<ArrayObject> builtinClasses()->get_ArrayClass()->asType(someAtom); GCRef<ArrayObject> builtinClasses()->get_ArrayClass()->coerceToType(someAtom); Note that in the last two cases, the wrapper is emitted with the proper return type, so no C++ cast is necessary. Patch also converts a handful of places to use these, as proof-of-concept, but real client for this is mostly Flash glue code. Two questions to ponder: -- I pondered adding versions that take ScriptObject* (instead of Atom) but decided against it for now. Opinions? -- these are emitted as normal C++ methods, so we rely on the linker dead-stripping the unused ones. Issue? (Also note: the "Atom" arguments will be converted to "avm::Value" when/if that lands.)
Assignee: nobody → stejohns
Attachment #517025 - Flags: superreview?(edwsmith)
Attachment #517025 - Flags: review?(rreitmai)
Comment on attachment 517025 [details] [diff] [review] Patch Probably outside the scope of this bug, but as we're working on an VM interface I'd rather see a single generic mechanism for accessing any class known by the VM, rather than have multiple techniques; e.g. builtinClasses()->get_xxxClass().
Attachment #517025 - Flags: review?(rreitmai) → review+
(In reply to comment #2) > Probably outside the scope of this bug, but as we're working on an VM interface > I'd rather see a single generic mechanism for accessing any class known by the > VM, rather than have multiple techniques; e.g. > builtinClasses()->get_xxxClass(). That's the One True Way; the other wrappers on Toplevel are for legacy code, and will gradually be removed.
After inquiring, it turns out dead-stripping isn't reliable in all cases we need to care about: "gcc/ld is notorious for not getting dead stripping right. Do not assume that compilers will do the right thing. In fact they do not by default. We use the '-ffunction-sections --gc-sections' hack for gcc/ld for now in Android and Linux builds but that has the downside that it impacts the optimizer and actually increases actual code size. Some more info: http://utilitybase.com/article/show/2007/04/09/225/Size+does+matter:+Optimizing+with+size+in+mind+with+GCC " So I will revisit this with an eye towards reducing the impact.
Attached patch Patch v2Splinter Review
Smarter version: use stubs in ClassClosure for all, and inlines to just typecast the result type into the proper C++ type.
Attachment #517025 - Attachment is obsolete: true
Attachment #517025 - Flags: superreview?(edwsmith)
Attachment #518573 - Flags: review?(rreitmai)
Attachment #518573 - Flags: review?(rreitmai) → review+
TR 6147:76020b2637d5
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
changeset: 6148:c482f8d25cd0 user: Steven Johnson <stejohns@adobe.com> summary: Bug 638956 followup: add missing explicit 'public' before isType, etc (r=me) http://hg.mozilla.org/tamarin-redux/rev/c482f8d25cd0
changeset: 6149:1e99d56d33a0 user: Steven Johnson <stejohns@adobe.com> summary: Bug 638956 followup: add ScriptObject overloads to isType, etc (r=me) http://hg.mozilla.org/tamarin-redux/rev/1e99d56d33a0
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: