Commit Graph

185 Commits

Author SHA1 Message Date
Yiding Jia bb933c8ad4 Make custom jsc initialization a link-time replacable function.
Reviewed By: bnham

Differential Revision: D3880106

fbshipit-source-id: 2a3c3c8ff120ecc66b31325700c187cbd957f361
2016-09-20 16:58:42 -07:00
Pieter De Baets 21fda19ca9 Consistently handle startup errors
Summary:
If we use RCTLogError, we show a redbox with a native stacktrace before we can actually show the JS stacktrace (which is only done through dispatch_async). Instead use RCTLogWarn so its logged to console but not reported as a redbox.

Also fix call to RCTNSErrorFromJSErrorRef off the main thread RCTJSCExecutor.

Reviewed By: majak, mmmulani

Differential Revision: D3886813

fbshipit-source-id: 119d04858cb0c85c79e12ff8a79806711f8e0b27
2016-09-20 06:28:36 -07:00
Pieter De Baets 9ff4d31dc4 Remove unnecessary JSContextGetGlobalContext call
Reviewed By: majak, alexeylang

Differential Revision: D3871178

fbshipit-source-id: 4a6dff7cce233e9bc2e2a80858774a2e6af6b67d
2016-09-16 06:28:48 -07:00
Pieter De Baets 228f104dad Improve RCTNSErrorFromJSError
Reviewed By: adamjernst

Differential Revision: D3871146

fbshipit-source-id: 44de849852d8c00ab4589938ef317e4c8d98d7e6
2016-09-16 06:28:48 -07:00
Pieter De Baets 95cce07baf Support invoking method that returns result and flushes call queue
Reviewed By: mhorowitz

Differential Revision: D3870879

fbshipit-source-id: bc8f70d9866dfc25468c9072c209cc6842b98575
2016-09-16 06:28:48 -07:00
Pieter De Baets d6926c5468 Allow precreated JSC executor init without applicationScript
Reviewed By: mmmulani

Differential Revision: D3836643

fbshipit-source-id: 18937ef5b39ebe3b3fd743490f86e40ffa6ee015
2016-09-13 06:43:40 -07:00
Alexey Lang d6fe78fc25 Refactor measuring native requires
Reviewed By: javache

Differential Revision: D3829204

fbshipit-source-id: 9a3a29bfc12e3af60eeac1e03b93a626d0d256c8
2016-09-09 15:28:44 -07:00
Pieter De Baets 99e0267c25 Cleanup and document native module configuration
Summary: Get rid of the old behaviour of JSON encoding in `nativeRequireModuleConfig` and consistently use the same names for function types "async/promise/sync"

Reviewed By: lexs

Differential Revision: D3819348

fbshipit-source-id: fc798a5abcaf6a3ef9d95bd8654afa7825c83967
2016-09-08 04:13:51 -07:00
Pieter De Baets 1a7c231ef3 Remove last arg from RCTProfileEnd, make macro's function-like
Reviewed By: tadeuzagallo

Differential Revision: D3801302

fbshipit-source-id: 297a58db876366e21e232094c1361aa0dcd9016d
2016-09-05 11:13:33 -07:00
Pieter De Baets dda3c5f48d Support sync method calls in the objc bridge
Reviewed By: mhorowitz

Differential Revision: D3801188

fbshipit-source-id: b990680049a46840472a25e66882f8a29890ae90
2016-09-05 07:44:00 -07:00
Indragie Karunaratne 31c8e20c8e Remove -[RCTJSExecutor errorForJSError:]
Reviewed By: javache

Differential Revision: D3814718

fbshipit-source-id: 9b8c91cb81d77fda4959df26806d54c9b7be42a0
2016-09-02 17:43:37 -07:00
Ben Nham 7db93a376b configure glog sink for custom jsc
Reviewed By: alexeylang

Differential Revision: D3789493

fbshipit-source-id: b3ecbd1caddfeef5e948e43444be95207c573f67
2016-08-31 11:29:05 -07:00
Ben Nham 4ad01be3a0 Remove iOS 7 version check in RCTJSCWrapperCreate
Reviewed By: michalgr

Differential Revision: D3729175

fbshipit-source-id: 43ee2ba19b3d8fed20bd268d1e2d0fab83e2fe9f
2016-08-18 03:28:34 -07:00
Ben Nham 53c5c4f8c3 Rename custom JavaScriptCore.framework to JSC.framework
Reviewed By: michalgr

Differential Revision: D3709748

fbshipit-source-id: bc2a7124127944c5d24e584747074065eefa1207
2016-08-15 15:13:40 -07:00
Ben Nham d22003a0de dynamically load JavaScriptCore with RTLD_LOCAL option
Reviewed By: tadeuzagallo

Differential Revision: D3703415

fbshipit-source-id: c67865b7fe75c21a3b620dc3a794b5a0005cf71e
2016-08-13 03:31:08 -07:00
Ben Nham ce2f119222 fix loading of dynamic linked JavaScriptCore on iOS simulator
Reviewed By: michalgr

Differential Revision: D3703392

fbshipit-source-id: 670185de1eefd1c542de2df96e40aede3b2c12cc
2016-08-11 18:43:27 -07:00
Pieter De Baets 335132ad63 Fix some analyzer warnings
Reviewed By: majak

Differential Revision: D3683672

fbshipit-source-id: 879578b050186bc779d01a17822d41bf7e473123
2016-08-09 03:58:36 -07:00
Pieter De Baets e762d961cd Use new enqueueJSCall method everywhere
Reviewed By: majak

Differential Revision: D3605263

fbshipit-source-id: 215f896d675b937593c8b796ed6ec5261ac74dbf
2016-08-02 11:14:06 -07:00
Pieter De Baets 63e0e6c7e4 Add more profiling markers to RCTJSCExecutor
Summary: Add some additional perf markers, and remove the usage of RCTProfileBlock as it completely breaks debugging / stepping in those blocks.

Reviewed By: majak

Differential Revision: D3579900

fbshipit-source-id: 8846dfc39b2448daa3669d5e1e8efb9096f183c5
2016-07-19 07:28:34 -07:00
Pieter De Baets 7fa677f7c3 Add MessageQueue method for executing function and returning its result
Reviewed By: majak

Differential Revision: D3175793

fbshipit-source-id: e1e66e3dcde8b1fb35973340e12d947a0e955775
2016-07-18 07:13:32 -07:00
Adam Ernst 3b4120d595 Simplify JS error to NSError API
Summary: No need to specify duplicative information.

Reviewed By: javache

Differential Revision: D3550805

fbshipit-source-id: b5abc3f1c74e26b4d4641c29fedba189cc46406e
2016-07-13 08:28:34 -07:00
David Aurelio c33084cc94 Read within bounds of `NSData` object
Summary: This prevents the `isUnbundle` check to read beyond the end of an `NSData` instance by using `getBytes:length:` instead of accessing the underlying buffer directly.

Reviewed By: javache

Differential Revision: D3548874

fbshipit-source-id: 7c93c66cc6abb4a2a321888ab394212f4d14a03e
2016-07-12 10:13:24 -07:00
Adam Ernst 80c71e5cae Refine RCTJSCExecutor's APIs for using a thread/context that already exists
Summary:
The `initWithJSContextProvider:` API created a `RCTJSCExecutor` with a thread/context that already exists, but it did not solve the problem of loading an actual application script; the `executeApplicationScript:` API is also asynchronous.

Create a new merged API that allows you to pass in a pre-created thread/context pair and immediately receive an `RCTJSCExector` that has already executed a specified application script.

This also removes the `underlyingJSContext` API entirely, in favor of passing it back in a byref variable in the new API. This minimizes the surface area for API abuse.

Reviewed By: bnham

Differential Revision: D3545349

fbshipit-source-id: 1c564f44d2a5379b5e6f75640079a28fd7169f67
2016-07-12 05:28:36 -07:00
Adam Ernst 0a98b612aa Change how native require hook is registered
Summary:
Instead of two separate dispatches to the JavaScript thread, only do one. Avoid the strongSelf dance entirely.

This refactor does mean that the cost of registering the nativeRequire hook on the context is not measured by the `RCTPLRAMBundleLoad` tag. However it should be almost zero-cost to construct and set a single block, so I'm OK with that change.

Reviewed By: bnham

Differential Revision: D3542940

fbshipit-source-id: d6bd26e478d0d33b56f8116d7efe6aac80c91711
2016-07-11 15:58:20 -07:00
Adam Ernst af7104b49e Extract part of executeApplicationScript into a C function
Reviewed By: javache

Differential Revision: D3542897

fbshipit-source-id: aa74c0c7c4477158fc9c8aff69432aed592f472f
2016-07-11 13:33:50 -07:00
Adam Ernst 5e89baa7a0 Remove needless weakSelf from executeApplicationScript
Reviewed By: javache

Differential Revision: D3542798

fbshipit-source-id: bf3fe15c78b55691176aecf209210a6f35f98862
2016-07-11 13:33:48 -07:00
Adam Ernst 8fb6111fa5 Make loadRAMBundle a C function, not a method
Summary: This makes the state it uses more explicit. It also makes a bug with performance measurement obvious: if we early return to error, we never mark stop for `RCTPLRAMStartupCodeSize`.

Reviewed By: javache

Differential Revision: D3542751

fbshipit-source-id: e6c1e3f3a76098ca37b8078f6e9abc805ad2d9da
2016-07-11 13:33:46 -07:00
Adam Ernst 39cb110c5b Add the ability to pre-create the JavaScript thread with RCTJSCExecutor
Summary: This can be used to create a JavaScript thread and `JSContext` in advance, then supply them to the `RCTJSCExecutor` at creation time later.

Reviewed By: javache

Differential Revision: D3534553

fbshipit-source-id: 99ccf711928cd12e84c9fbe142c6d19a7af55d07
2016-07-08 12:35:50 -07:00
Adam Ernst 294173a427 Organize ivars in RCTJSCExecutor
Reviewed By: javache

Differential Revision: D3534380

fbshipit-source-id: 364213f24256602471a5b3cd1afe6c7be4aab743
2016-07-08 12:35:48 -07:00
Adam Ernst 7ee2f48451 Remove left-over ctx property from RCTJavaScriptContext
Summary: This was left over from a previous change.

Reviewed By: javache

Differential Revision: D3534376

fbshipit-source-id: 6932364d1c32d8fbdf56c642893f9ea5e6dc1fee
2016-07-08 12:35:45 -07:00
Adam Ernst 1ebd9c5dea Create JSContext inside setUp
Summary:
In practice, it *MUST* be the call to `self.context` within `setUp` that triggers the creation of the context:

- It can't come before that point because `_jscWrapper` has not been set up yet
- It can't come after that point since `self.context` would create the context there.

Just move the creation to be inline, enforced by assert. This makes it easier to reason about where the context is created, and easier to change how it is created later.

Reviewed By: javache

Differential Revision: D3529843

fbshipit-source-id: 8ed5a9861ebefd4b9e0f7155db8587dcf0442b7a
2016-07-08 09:13:59 -07:00
Adam Ernst 29f9be6d9c Remove needless weak self in RCTJSCExecutor
Summary: There's no reason for this; setUp is once-and-done. Probably just trying to ignore the incorrect clang warning.

Reviewed By: javache

Differential Revision: D3528494

fbshipit-source-id: e4f986df8d097e4720dfd4a51e7fb6c9c9b5108f
2016-07-08 09:13:59 -07:00
Adam Ernst 222060b218 Remove needless helper method
Summary: I think this obscures more than it helps. Remove it.

Reviewed By: javache

Differential Revision: D3528677

fbshipit-source-id: d90a636a6e34b66563d9a02e255c6ebc4cee1294
2016-07-07 16:44:15 -07:00
Adam Ernst 2b397c5094 Redo cookie map for nativeTraceBeginAsyncSection
Reviewed By: javache

Differential Revision: D3528604

fbshipit-source-id: 0feff3a09214af7c9c193733a5ad05d7de0dd21d
2016-07-07 16:44:14 -07:00
Adam Ernst dd5bb7b9e0 Pull native hook registration into class method
Summary:
Ideally, native hooks should not require any sort of reference to self. Pull all those that fulfill this criteria into a class method (to make it impossible to accidentally capture self).

Future diffs will pull more and more hooks into this category.

Reviewed By: javache

Differential Revision: D3528558

fbshipit-source-id: 270c5bec53674a91ec2129d55e5cad59440a51da
2016-07-07 16:44:14 -07:00
Adam Ernst 96b47eb933 Inline _addSynchronousHookWithName
Summary: It's just a simple helper. It's actually more readable and performant when inlined.

Reviewed By: javache

Differential Revision: D3528540

fbshipit-source-id: 8086770f7fd88b40623dc943c715deb4f9fd9262
2016-07-07 16:44:13 -07:00
Adam Ernst a203cf4791 Make addSynchronousHookWithName private
Summary: It's not widely used, and you can do something equivalent anyway by using existing public API.

Reviewed By: javache

Differential Revision: D3518896

fbshipit-source-id: 6995a5d840aecfff4ffd78ac43f3f592a4f47f91
2016-07-07 13:43:39 -07:00
Adam Ernst 5323b77fba Expose a way to get the JSContext from a RCTJSCExecutor
Reviewed By: javache

Differential Revision: D3517664

fbshipit-source-id: cafda7eccbf25f6e197ba9bd18e82c814f08e3bb
2016-07-07 13:43:38 -07:00
Skotch Vail bcf4bb6edd Automated changes to remove implicit capture of self in blocks: Libraries/FBReactKit/BUCK
Reviewed By: javache

Differential Revision: D3442470

fbshipit-source-id: 584a2bb3df5f7122166778b8fd44fae45560491e
2016-07-07 12:44:14 -07:00
Alexey Lang 97299260b6 Refactor RCTPerformanceLogger to avoid having global state
Reviewed By: javache

Differential Revision: D3509004

fbshipit-source-id: c4ab12b3f1defa32c2b1c211e775f6782ede4b7f
2016-07-07 07:29:57 -07:00
Alexey Lang 85983d0ae4 Change API for iOS
Reviewed By: michalgr

Differential Revision: D3514778

fbshipit-source-id: 29dc12ad0a701fd08262be3aa81ae990d4fc63a9
2016-07-04 09:28:27 -07:00
Alexey Lang 6a1324e8f6 Fix codesign and enable in Wilde again
Reviewed By: michalgr

Differential Revision: D3497518

fbshipit-source-id: 615679fdfa22f9a03535248ebaa80ff9aa2e9e71
2016-07-01 04:43:28 -07:00
Alexey Lang b36eaeda5d Replace RCT_DEV with RCT_PROFILE
Reviewed By: javache

Differential Revision: D3462735

fbshipit-source-id: 44513a9540b3111e036c4b14e0fda2d34b43cdf6
2016-06-21 12:15:45 -07:00
Pieter De Baets b90b57c9a1 Cache __fbBatchedBridge reference
Summary:
We already do this on Android, and it allows uw to avoid doing this global object lookup for every call. Since there's only a couple of global functions we ever call, we should consider caching all of them in the new bridge.

I didn't ValueProtect/ValueUnprotect since these are already globals, and those methods are not exposed on the JSC wrapper.

Reviewed By: mhorowitz

Differential Revision: D3411487

fbshipit-source-id: 7feaf8803665b77d649e84edad875d31c5acee4b
2016-06-14 05:14:01 -07:00
Pieter De Baets c25e48abfc Allow additional information to be passed to systrace events
Summary: Expose the ability to provide extra information to Systrace events from JS. This is specifically useful for instrumenting generic recursive method that are defined completely through their params.

Reviewed By: tadeuzagallo

Differential Revision: D3423595

fbshipit-source-id: 7f2dedf02bf901401a6b391b85b1a0bb6782349c
2016-06-13 04:28:38 -07:00
Pieter De Baets d7fc58f32c Add RCT_PROFILE define
Reviewed By: tadeuzagallo

Differential Revision: D3423593

fbshipit-source-id: cc04add1bee16fbb4c2491bd229f23244fe3e7bd
2016-06-13 04:28:38 -07:00
Alexey Lang 42a5568419 Change API for using custom JSC
Reviewed By: javache

Differential Revision: D3392219

fbshipit-source-id: ae372dfe9ceab7f7c2da69c731515a05eb3b020a
2016-06-06 11:13:22 -07:00
Alexey Lang abe0b349bc Implement RCTJSCWrapper
Reviewed By: tadeuzagallo

Differential Revision: D3258713

fbshipit-source-id: 418eb9d350bf3541c976b631bd9799a1c578f5e5
2016-05-31 12:58:25 -07:00
David Aurelio 4c76e5476c remove premature optimizations
Reviewed By: javache

Differential Revision: D3325805

fbshipit-source-id: cdf8f4f3744d70fd37e8fa35c44ca8110ea4395a
2016-05-23 07:28:25 -07:00
David Aurelio 2f41c56f59 change to fixed size offset table + indexed lookup
Reviewed By: javache

Differential Revision: D3281989

fbshipit-source-id: 52db9f441dd46024eafac46ae8d32b26640cad71
2016-05-16 04:43:24 -07:00