Commit Graph

25 Commits

Author SHA1 Message Date
Kan-Ru Chen
b6d880aca1 Bug 1297276 - Rename mfbt/unused.h to mfbt/Unused.h for consistency. r=froydnj
The patch is generated from following command:

  rgrep -l unused.h|xargs sed -i -e s,mozilla/unused.h,mozilla/Unused.h,

MozReview-Commit-ID: AtLcWApZfES


--HG--
rename : mfbt/unused.h => mfbt/Unused.h
2016-08-24 14:47:04 +08:00
Jim Chen
ac1b87c36f Bug 1292323 - Optimize native call dispatching; r=snorp
Refactor the dispatching code to be more streamlined, and add two
optimizations to the way we dispatch a call:

* avoid a pair of unnecessary calls to add/delete the global class ref,
  when dispatching a static call to the Gecko thread without a class ref
  parameter.

* avoid an extra allocation when dispatching to a proxy function.
2016-08-12 23:15:53 -04:00
Jim Chen
0ca0344ec2 Bug 1292323 - Merge NativeStubImpl into NativeStub; r=snorp
Merge all the NativeStubImpl specializations in jni/Natives.h into one
NativeStub, which makes it more organized and facilitates code sharing.
2016-08-12 23:15:53 -04:00
Jim Chen
36628f0198 Bug 1292323 - Implement JNI thread checking and dispatching; r=snorp
Implement checking the calling thread of a JNI call based on the
calledFrom attribute set in WrapForJNI. Also implement automatic call
dispatching based on the dispatchTo attribute set in WrapForJNI. This
eliminates the use of UsesNativeCallProxy and UsesGeckoThreadProxy.
2016-08-12 23:15:52 -04:00
Jim Chen
9f20364a07 Bug 1277624 - Don't use anonymous namespace in headers; r=me
Trivial patch to not use anonymous namespace in headers, which can
introduce multiple copies of the same code in different compilation
units.
2016-06-27 14:49:55 -04:00
Nathan Froyd
154bef14bf Bug 1277650 - part 3 - add MOZ_JNICALL attribute to MakeNativeMethod's argument; r=darchons
clang complains that it's unable to instantiate this template because
the functions being passed as arguments are MOZ_JNICALL, while the
actual parameter to the function has no such attribute.  Adding the
attribute makes everything line up.
2016-06-06 16:58:55 -04:00
Nathan Froyd
9e9c7538de Bug 1277650 - part 2 - more explicit friending between NativeStubImpl and ProxyNativeCall; r=darchons
clang complains about specializations of NativeStubImpl not being able
to see the private constructor of ProxyNativeCall.  While
ProxyNativeCall includes a friend declaration for NativeStubImpl, it's
not obvious *which* NativeStubImpl is being friended, as NativeStubImpl
hasn't been forward declared and exists in a completely separate
namespace.  Forward declaring NativeStubImpl and adjusting the friend
declaration makes everything more correct.
2016-06-06 16:58:55 -04:00
Jim Chen
d8cd767aac Bug 1270202 - Move WindowEvent to outside of GeckoViewSupport; r=snorp
WindowEvent is not specific to GeckoViewSupport, and classes other than
GeckoViewSupport use it, so this patch moves it to outside of
GeckoViewSupport.
2016-05-05 11:39:02 -04:00
Jim Chen
46edf980e0 Bug 1244875 - Refactor JNI templates; r=snorp
Improve the performance of JNI calls by making JNI calls require a
Context object. LocalRef inherits from Context and can make calls
directly. Non-local Ref classes will generate a Context object when
making a call. The patch also makes the template design cleaner in
several cases.
2016-02-09 17:27:28 -05:00
Jim Chen
dd04b2cada Bug 1235475 - Crash at the exception source when an exception is in native code; r=snorp
When we have a Java exception in native code, the Java stack in the
exception will not be very useful because the top frame is the native
entry point. In this case, the native stack is more useful. However,
currently we don't get a good native stack in this situation because we
go through Java when handling the exception, and the native stack we get
will have a lot of unknown frames inside libdvm or libart. This patch
makes us stay in native code when handling an uncaught exception from
native code, so that we get a good native stack.
2015-12-30 18:36:41 -05:00
Jim Chen
827f34efc0 Bug 1227706 - Implement nsWindow::GLControllerSupport; r=snorp
This patch adds native method implementations in GLControllerSupport to
manage compositor creation/pause/resume.
2015-12-23 22:03:34 -05:00
Jim Chen
11f74c6395 Bug 1227731 - Add ability to redirect proxied native calls; r=snorp
This patch adds a way to set the target of a proxied native call, so the
call goes to another C++ function / class member than the original
target.
2015-12-23 22:03:34 -05:00
Birunthan Mohanathas
9985829ecc Bug 1219392 - Capitalize mozilla::unused to avoid conflicts. r=froydnj 2015-11-02 07:53:26 +02:00
Jim Chen
4bce9b46f1 Bug 1211704 - Count key and IME events as UI events; r=esawin
GeckoEvent.KEY_EVENT and GeckoEvent.IME_EVENT used to count as UI events
for the hang monitor. We should count the new native calls as native
events too through this patch.
2015-10-22 17:45:47 -04:00
Jim Chen
be2a6f1785 Bug 1215139 - Make NativeImpl::DisposeNative a static member; r=snorp
It's helpful to have a static DisposeNative when disposing of instances
that are still associated with a native object through an null weak
pointer. In that case, we can't call instance methods because the weak
pointer is null, but we can still call static methods.
2015-10-22 17:45:46 -04:00
Jim Chen
aacb32b312 Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry. r=snorp
Use the force_align_arg_pointer attribute to force realigning stack at JNI entry points.
2015-10-21 08:27:00 -04:00
Jim Chen
b62c5aa0a3 Bug 1192043 - Add support for proxying native calls; r=snorp
If a C++ class implements native calls that all return void, it can
choose to have those calls go through a custom proxy function by
inheriting from mozilla::jni::UsesNativeCallProxy and override the
ProxyNativeCall member.

ProxyNativeCall accepts a rvalue reference to a
functor object specific to each call, and can alter the calling
environment (e.g. dispatch the call to another thread) before issuing
the actual native call through the functor's operator().

Any JNI refs contained in the call are automatically turned into global
refs so that the call can continue to work outside of the original JNI
call.

Native call proxy will be used to implement automatic dispatching of
native calls from the main thread to run on the Gecko thread.
2015-08-25 14:52:16 -04:00
Jim Chen
b8013723d5 Bug 1192043 - Fix compile errors in Natives.h; r=snorp
This patch fixes a compile error when using WeakPtr, where Impl* was
expected but SupportsWeakPtr<Impl>* was given.

This patch also fixes a compile error when using the DisposeNative
implementation provided by the autogenerated Natives class. e.g.,

> struct Foo : Bar::Natives<Foo> {
>     using Bar::Natives<Foo>::DisposeNative;
> };

This uses a default implementation of DisposeNative instead of a custom
implementation, and resulted in a compile error that this patch fixes.
2015-08-25 14:52:16 -04:00
Jim Chen
8323512edf Bug 1192043 - Clean up NativeStubImpl template parameters; r=snorp
The mangled name of a NativeStubImpl instantiation is longer than
necessary because of the ReturnType arg. This patch turns it into a bool
parameter. It also reorders the parameters for cleanness.
2015-08-25 14:52:16 -04:00
Jim Chen
d1f529698f Bug 1192077 - Convert AndroidBridge JNIEnv calls; r=esawin 2015-08-13 00:53:39 -04:00
Jim Chen
81d1a5cdea Bug 1187552 - Support direct ownership of C++ objects by Java objects; r=snorp
Add a direct ownership model where the Java object owns the
corresponding C++ object directly, in addition to the WeakPtr model
where the Java object owns a WeakPtr to the C++ object. The WeakPtr
model is chosen when the implementing C++ class inherits from
SupportsWeakPtr. Otherwise, the direct ownership model is chosen. Under
the direct ownership model, a UniquePtr object must be used to attach
the containing C++ object to a Java object, to ensure ownership is
passed on to the Java object.
2015-08-04 17:47:28 -04:00
Jim Chen
7ec24cf6cd Bug 1186530 - Add support for instance native pointers; r=snorp
Introduce a JNIObject class that serves as a base class for classes
that wish to use per-instance native methods. JNIObject includes a long
native pointer field that the C++ code accesses to associate the Java
object instance with a C++ object instance.
2015-07-29 15:11:15 -04:00
Jim Chen
788c0ad4c8 Bug 1178850 - Add supporting classes for native JNI calls; r=snorp 2015-07-10 23:41:36 -04:00
Wes Kocher
027fd9354a Backed out 5 changesets (bug 1178850) for android build bustage CLOSED TREE
Backed out changeset 79085d3894e8 (bug 1178850)
Backed out changeset c02b603104ea (bug 1178850)
Backed out changeset d6dab7810669 (bug 1178850)
Backed out changeset 8ee5809f349b (bug 1178850)
Backed out changeset 821b22ce79e1 (bug 1178850)
2015-07-10 14:17:53 -07:00
Jim Chen
096176c3f0 Bug 1178850 - Add supporting classes for native JNI calls; r=snorp 2015-07-10 16:52:52 -04:00