Closed Bug 891585 Opened 9 years ago Closed 9 years ago

Avoid unnecessary JS_WrapValue calls when returning typed arrays in WebIDL bindings

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla25

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

(Keywords: perf)

Attachments

(2 files, 1 obsolete file)

Attached file Testcase
The attached testcase gets >2x faster with the upcoming patch.
Comment on attachment 772901 [details] [diff] [review]
Don't JS_WrapValue same-compartment typed array return values in bindings code (e.g. ImageData.data).

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

::: dom/bindings/BindingUtils.h
@@ +576,5 @@
> +  }
> +  return MaybeWrapObjectValue(cx, rval);
> +}
> +
> +// Wrapping for objects that are known to not be DOM or XPConnect objects

Can we assert that?
> Can we assert that?

Yes.
Attachment #773283 - Flags: review?(peterv)
Attachment #772901 - Attachment is obsolete: true
Attachment #772901 - Flags: review?(peterv)
Comment on attachment 773283 [details] [diff] [review]
With more asserts

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

::: dom/bindings/BindingUtils.h
@@ +586,5 @@
> +  MOZ_ASSERT(!GetDOMClass(&rval.toObject()));
> +#ifdef DEBUG
> +  js::Class* clasp = js::GetObjectClass(&rval.toObject());
> +  MOZ_ASSERT(!(clasp->flags & JSCLASS_HAS_PRIVATE) ||
> +             !(clasp->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS));

Isn't checking for JSCLASS_PRIVATE_IS_NSISUPPORTS enough?
Attachment #773283 - Flags: review?(peterv) → review+
> Isn't checking for JSCLASS_PRIVATE_IS_NSISUPPORTS enough?

Right you are.
https://hg.mozilla.org/integration/mozilla-inbound/rev/88d451420219
Flags: in-testsuite-
Keywords: perf
Whiteboard: [need review]
Target Milestone: --- → mozilla25
https://hg.mozilla.org/mozilla-central/rev/88d451420219
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.