Closed Bug 1157533 Opened 9 years ago Closed 9 years ago

Share GC pointer dispatch logic for Value and jsid

Categories

(Core :: JavaScript: GC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: terrence, Assigned: terrence)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

We repeat the fiddly |if (val->isFoo()) DoSomething(val->asFoo())| all over the place. It would be better to share them. This seems to work locally.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=44a7bf4d4f54
The second try run from last night turned out quite green.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=84bfd5cc4a3f

However, I thought of a bunch of improvements this morning. The new patch is quite a bit nicer. New try run up to verify that I didn't break anything:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=41644ff5013c
Attachment #8596700 - Flags: review?(jcoppeard)
Attachment #8596288 - Attachment is obsolete: true
Comment on attachment 8596700 [details] [diff] [review]
10.0.0_shared_value_and_id_dispatch-v1.diff

Review of attachment 8596700 [details] [diff] [review]:
-----------------------------------------------------------------

I really like the DefaultAdaptors, that's a neat way of handling it.

::: js/public/Value.h
@@ +1878,5 @@
> +    return F::defaultValue(val);
> +}
> +
> +template <class S> struct VoidDefaultAdaptor { static void defaultValue(S) {} };
> +template <class S> struct CopyDefaultAdaptor { static S defaultValue(const S &v) { return v; } };

You could call this one IdentityDefaultAdapator.

::: js/src/gc/Marking.h
@@ +171,5 @@
> +#define DECLARE_REWRAP(S, T, method, prefix) \
> +    template <> struct RewrapValueOrId<S, T> { \
> +        static S wrap(T thing) { return method ( prefix thing ); } \
> +    }
> +DECLARE_REWRAP(JS::Value, JSObject*, JS::ObjectValue, *);

Do we ever try and re-wrap a null object pointer?  If so you could use ObjectOrNullValue here.
Attachment #8596700 - Flags: review?(jcoppeard) → review+
https://hg.mozilla.org/mozilla-central/rev/e8e50b26a090
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: