1. 07 May, 2021 2 commits
    • Yedidya Feldblum's avatar
      a non-concurrent token-bucket variation · 97e3d72b
      Yedidya Feldblum authored
      Summary: Adds a policy around whether token-bucket is used only non-concurrently, in which case compare-exchanges can be optimized to stores.
      
      Differential Revision: D28230482
      
      fbshipit-source-id: 2c00797dc943e9ea8985737a8c7dda059a195cfe
      97e3d72b
    • Yedidya Feldblum's avatar
      exception_wrapper thrown variant via abi/runtime · aa7f74aa
      Yedidya Feldblum authored
      Summary:
      Reimplement `folly::exception_wrapper` thrown variant not to need to cache any pointers and rather to access the exception object and runtime type, and to perform runtime upcasting, via the platform runtime.
      
      This both simplifies and extends the capability of the thrown variant.
      
      Reviewed By: luciang
      
      Differential Revision: D26331579
      
      fbshipit-source-id: a6fe0f10434956efa5ba4b4bcd1bd3a1b48466a4
      aa7f74aa
  2. 06 May, 2021 8 commits
    • Igor Sugak's avatar
      fix clang-12 -Wdeprecated-copy · 808c2600
      Igor Sugak authored
      Summary:
      Starting with C++11, implicit generation of the copy constructor is declared as deprecated.
      > § D.2 Implicit declaration of copy functions [depr.impldec]
      > The implicit definition of a copy constructor as defaulted is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared copy constructor or a user-declared destructor (15.4, 15.8). In a future revision of this International Standard, these implicit definitions could become deleted (11.4).
      
      Clang-12 produces diagnostics for these cases, which is turned into errors for folly:
      ```
      folly/test/AtomicHashMapTest.cpp:330:12: error: definition of implicit copy constructor for 'Integer' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
        Integer& operator=(const Integer& a) {
                 ^
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28239770
      
      fbshipit-source-id: a28d19ec774264944b750aa267e93d4fa6d1744e
      808c2600
    • Yedidya Feldblum's avatar
      use relaxed memory order in TokenBucket · 72bbd4c1
      Yedidya Feldblum authored
      Summary: The atomic location is not used to order memory.
      
      Reviewed By: jbeshay
      
      Differential Revision: D28229348
      
      fbshipit-source-id: c6206d4b72025e1f7f68adc822e9ae4ed13bd8b4
      72bbd4c1
    • Yedidya Feldblum's avatar
      policy structure for TokenBucket · 3b0e443c
      Yedidya Feldblum authored
      Summary: Items which are subject to policy: align, atom, and clock.
      
      Differential Revision: D28229049
      
      fbshipit-source-id: e65512265abaa8b777f95cf3233d96a70df73c5f
      3b0e443c
    • Jaroslaw Kasperkiewicz's avatar
      Enabling support for folly::splitTo<std::string_view> · 6f38cd40
      Jaroslaw Kasperkiewicz authored
      Summary:
      Adding new `parseTo` overload for `std::string_view`, and related tests.
      
      Facilitates migration from `folly::StringPiece` to `std::string_view` by supporting:
      
      ```lang=c++
      splitTo<string_view>(...)
      ```
      
      Reviewed By: yfeldblum
      
      Differential Revision: D27971000
      
      fbshipit-source-id: 732f968eb6797447ae12bdc70dbb82d5fc6a8a33
      6f38cd40
    • Yedidya Feldblum's avatar
      tweak size checks in to_ascii · ea1cdd1a
      Yedidya Feldblum authored
      Summary: If inlining and constant folding can determine that the buffer is larger than the `to_ascii_size_max` constant, then there is no need to call the `to_ascii_size` function an extra time.
      
      Differential Revision: D27986105
      
      fbshipit-source-id: d088001a7b3632dabb794c86dafdaa93dd0c1348
      ea1cdd1a
    • Yedidya Feldblum's avatar
      rename the redefined __cxa_exception · a8a754aa
      Yedidya Feldblum authored
      Summary: In case some `<cxxabi.h>` actually defines it rather than keeping it defined in some unincluded helper.
      
      Reviewed By: luciang
      
      Differential Revision: D28239978
      
      fbshipit-source-id: 4d824892966de4b9f8de775d947f5d7d749a02bb
      a8a754aa
    • Yedidya Feldblum's avatar
      cut the global mutex in EventBase · 7605607e
      Yedidya Feldblum authored
      Summary: It was needed only to call into legacy APIs which are themselves unneeded.
      
      Differential Revision: D28227187
      
      fbshipit-source-id: 4248a7f39c7bea3224f4c2eb73e4815db71c9584
      7605607e
    • Joe Loser's avatar
      Replace folly::make_unique with std::make_unique (#1572) · 0b29ff65
      Joe Loser authored
      Summary:
      Problem:
      - Some call sites use `folly::make_unique` whose functionality exists in
        the standard library now. In the future, `folly::make_unique` may be
        removed.
      
      Solution:
      - Replace call sites to use `std::make_unique`.
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1572
      
      Differential Revision: D28235226
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 2dd85f4d234881d682adaf4b5bbe947f56edaa4e
      0b29ff65
  3. 05 May, 2021 7 commits
    • Yedidya Feldblum's avatar
      remove the use of _LIBCXXABI_HIDDEN · e2ca17cb
      Yedidya Feldblum authored
      Summary:
      The macro `_LIBCXXABI_HIDDEN` is seeminly unavailable on FreeBSD so avoid its use in the exception-ptr abi accessors.
      
      Fixes: https://github.com/facebook/folly/issues/1570.
      
      Reviewed By: luciang
      
      Differential Revision: D28217011
      
      fbshipit-source-id: c745ae468c840c33df921c68fb06759c078b6df0
      e2ca17cb
    • Pedro Eugenio Rocha Pedreira's avatar
      Add re2 as a dependency on getpdeps · 4e46fb83
      Pedro Eugenio Rocha Pedreira authored
      Summary: Add re2 as a dependency on getpdeps
      
      Reviewed By: funrollloops
      
      Differential Revision: D28208007
      
      fbshipit-source-id: 7e6ab7a0a01f4b2fe264780e09befc34a030a896
      4e46fb83
    • Samuel Miller's avatar
      Add an OpenSSLTransportCertificate · 9e136862
      Samuel Miller authored
      Summary:
      To remove OpenSSL dependencies from some of our public interfaces, we need to
      make `AsyncTransportCertificate` more implementation-agnostic. To start, we can
      create an `OpenSSLTransportCertificate` that will have the `getX509()` method
      instead of the `AsyncTransportCertificate`.
      
      I start here by making `OpenSSLTransportCertificate` a dummy class, then I'll
      update all our callsites to ensure that `getX509()` is only called on instances
      of this class. After that, I can move `getX509()` exclusively to
      `OpenSSLTransportCertificate`.
      
      This means that in the future interfaces can use `AsyncTransportCertificate`
      without depending on OpenSSL.
      
      Reviewed By: yfeldblum, mingtaoy
      
      Differential Revision: D26583479
      
      fbshipit-source-id: 664e697a32fce61d22ee9842f998c4de1182924c
      9e136862
    • Yedidya Feldblum's avatar
      fake the libcxxabi type-info shim · 7063a736
      Yedidya Feldblum authored
      Summary: The actual shim type may sometimes not be linkable. So fake it - as long as the vtable is the same, it should not make a difference.
      
      Reviewed By: luciang
      
      Differential Revision: D28216291
      
      fbshipit-source-id: 8c493a207cfb5414684147ddb850835bc0965bc5
      7063a736
    • John Reese's avatar
      apply upgraded black 21.4b2 formatting to fbsource · 62c4eb40
      John Reese authored
      Summary:
      This applies the formatting changes from black v21.4b2 to all covered
      projects in fbsource. Most changes are to single line docstrings, as black
      will now remove leading and trailing whitespace to match PEP8. Any other
      formatting changes are likely due to files that landed without formatting,
      or files that previously triggered errors in black.
      
      Any changes to code should be AST identical. Any test failures are likely
      due to bad tests, or testing against the output of pyfmt.
      
      Reviewed By: thatch
      
      Differential Revision: D28204910
      
      fbshipit-source-id: 804725bcd14f763e90c5ddff1d0418117c15809a
      62c4eb40
    • Yedidya Feldblum's avatar
      revise int128 traits · 0383893a
      Yedidya Feldblum authored
      Summary:
      Rather than specializing standard library numeric traits for `signed __int128` and `unsigned __int128`, bring these traits into folly and choose them where needed.
      
      Note that it is undefined behavior to specialize the standard traits types.
      
      Reviewed By: ericniebler
      
      Differential Revision: D26506904
      
      fbshipit-source-id: 0f7b0fa445c2713961b345b453fef8ff58032ee5
      0383893a
    • Andrii Grynenko's avatar
      GCC compiler bug workaround for timed_wait and detachOnCancel · 4720e456
      Andrii Grynenko authored
      Summary: GCC seems to be generating incorrect code for some mix of co_invoke and start/startInline. This workaround makes coro tests pass.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28174118
      
      fbshipit-source-id: b8178d7711ed5619a37c169f8f18dd125bf08f0b
      4720e456
  4. 04 May, 2021 8 commits
    • Maged Michael's avatar
      HazptrDomain: Change DCHECK of tagged_empty() in dtor to a warning · 9454bc45
      Maged Michael authored
      Summary:
      Replace DCHECK(tagged_empty()) with a warning.
      
      The rationale is that the DCHECK was intended to help higher level users detect memory leaks, but since the DCHECK fails at domain destruction, the stack trace is not really helpful to users. By changing it to a warning, at least the user gets a hint that there may be a leak of object(s) that use hazptr_obj_cohort (e.g., ConcurrentHashMap, RequestContext).
      
      Reviewed By: yfeldblum
      
      Differential Revision: D28145864
      
      fbshipit-source-id: 8a79e25efd21f0b1d713202f2fe8954c17a7d4de
      9454bc45
    • Srivatsan Ramesh's avatar
      Fix for proxygen fuzz build failure · 0ff4306d
      Srivatsan Ramesh authored
      Summary: Fix for the proxygen fuzz [build error]( https://oss-fuzz-build-logs.storage.googleapis.com/log-e58a42bb-98c0-4643-b842-b06f708eba12.txt) introduced by D27384053 (https://github.com/facebook/folly/commit/cdf0badc831c3aed7a740185d23728f779be8ba7)
      
      Reviewed By: yfeldblum, lnicco
      
      Differential Revision: D28154352
      
      fbshipit-source-id: 6d98d9a3c9064de8f70506425dd790aa0cc3d9a6
      0ff4306d
    • Mark Santaniello's avatar
      Allow BenchmarkSuspender to be created in an initially-dismissed state · 7a875f2a
      Mark Santaniello authored
      Summary:
      Suppose we have this:
      
      ```
      void myBenchmark() {
          do_setup();
          do_processing();
      }
      ```
      
      Maybe we want to benchmark both including and excluding the setup.  Today, we have some options:
      
      One possibility:
      ```
      void myBenchmarkIncludeSetup() {
          do_setup();
          do_processing();
      }
      
      void myBenchmarkExcludeSetup() {
          BENCHMARK_SUSPEND {
             do_setup();
          }
          do_processing();
      }
      ```
      
      Another possibility -- but this is pretty verbose:
      
      ```
      void myBenchmark(bool exclude_setup) {
          BenchmarkSuspender bs;
          bs.dismiss()
      
          if(exclude_setup) bs.rehire();
          do_setup();
          if(exclude_setup) bs.dismiss();
      
          do_processing();
      }
      ```
      
      We can simplify if we no longer require that BenchmarkSuspenders begin life as "hired".
      
      After this diff, we can instead do this.  I think it reads better:
      ```
      void myBenchmark(bool exclude_setup) {
          BenchmarkSuspender bs{BenchmarkSuspender::Dismissed};
      
          if(exclude_setup) bs.rehire();
          do_setup();
          if(exclude_setup) bs.dismiss();
      
          do_processing();
      }
      ```
      
      Reviewed By: yfeldblum, ot, luciang
      
      Differential Revision: D28151318
      
      fbshipit-source-id: bca5a41158430844748a812bbe30173adbad5307
      7a875f2a
    • Yedidya Feldblum's avatar
      move return type calculation in catch_exception · 6cd060f1
      Yedidya Feldblum authored
      Summary: Ideal for dependent return types to be calculated in the template param list rather since the putting them in the leading or trailing return type slot makes the function name opaque to demangling.
      
      Reviewed By: Orvid
      
      Differential Revision: D28140885
      
      fbshipit-source-id: 0f9bc182f12a6383205863ce9a79b01961d644a6
      6cd060f1
    • REDMOND\agnel's avatar
      Adding x86 support for to_ascii_port_clzll() (#1567) · 0f30fbc4
      REDMOND\agnel authored
      Summary:
      Currently to_ascii_port_clzll() in ToAscii.h always returns 0 in x86. This switches to __builtin_clzll() backed by a polyfill.
      
      Closes https://github.com/facebook/folly/issues/1566.
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1567
      
      Reviewed By: luciang
      
      Differential Revision: D28162903
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: 1872cda7aa155b84086bd15ad6cd40475eeb0ac4
      0f30fbc4
    • Yedidya Feldblum's avatar
      cut unused macro FOLLY_TLS · 896a7356
      Yedidya Feldblum authored
      Summary: Best to use C++ syntax `thread_local` instead since it is language-native and cross-platform.
      
      Reviewed By: Orvid
      
      Differential Revision: D27671626
      
      fbshipit-source-id: 8ef0c487bfa20ab323067c05862998df25d2a53b
      896a7356
    • Yedidya Feldblum's avatar
      init SocketAddress::port_ in default-ctor · e1582a7f
      Yedidya Feldblum authored
      Summary: The port is not accessed in such a state, but nevertheless zero it.
      
      Differential Revision: D28155314
      
      fbshipit-source-id: 0ee6a617be5de66d1e068c242d52423adb31f486
      e1582a7f
    • Yedidya Feldblum's avatar
      fewer bind-to-device conditions in AsyncUDPSocket · cf5906ec
      Yedidya Feldblum authored
      Differential Revision: D28163554
      
      fbshipit-source-id: 2167a39e88f7aa6053dea5119a30947d2f3304f3
      cf5906ec
  5. 03 May, 2021 1 commit
  6. 02 May, 2021 4 commits
    • Yedidya Feldblum's avatar
      revise exceptionStr · 4e7efffd
      Yedidya Feldblum authored
      Summary: Revise all overloads of `folly::exceptionStr` in terms of `type_info_of`, `exception_ptr_get_type`, and `exception_ptr_get_object`. No longer rely on `catch_exception` and no longer have inline preprocessor conditionals.
      
      Reviewed By: Orvid, luciang
      
      Differential Revision: D26333081
      
      fbshipit-source-id: 318ce83b9f15a12d5a33f528134e6fb38bb78a62
      4e7efffd
    • Yedidya Feldblum's avatar
      use to-ascii array vs table on mobile · 93d52d89
      Yedidya Feldblum authored
      Summary: The table is large while the array is small.
      
      Reviewed By: luciang
      
      Differential Revision: D27986020
      
      fbshipit-source-id: b6896514408758c592e2b74d801e38f217163f61
      93d52d89
    • Yedidya Feldblum's avatar
      exception_ptr_get_type, exception_ptr_get_object · ab79b855
      Yedidya Feldblum authored
      Summary:
      Introduce functions `exception_ptr_get_type`, `exception_ptr_get_object` for inspecting and upcasting the content of `std::exception_ptr`. Since these facilities are not exposed in any standard way, reach into the platform abi/runtime to implement them.
      
      Includes implementations for these platforms:
      * libstdc++
      * libc++
      * win32
      
      Reviewed By: mzlee, luciang
      
      Differential Revision: D26306199
      
      fbshipit-source-id: 3b655476b69f4456f4e4f88135fbba70a8c4a2a6
      ab79b855
    • Yedidya Feldblum's avatar
      assume thread_local in StaticMeta · 64484582
      Yedidya Feldblum authored
      Reviewed By: Orvid
      
      Differential Revision: D27671636
      
      fbshipit-source-id: 82cab152ecb606235ee66c026ecafecfe52a88a5
      64484582
  7. 01 May, 2021 1 commit
    • Kenny Yu's avatar
      walk async stack traces correctly · 94d0da77
      Kenny Yu authored
      Summary:
      This correctly walks the async stack traces. Previously, we were not following the async stack root
      from the last async stack frame.
      
      High level stack walking strategy is as follows:
      1) Start walking the normal stack up to the first normal stack frame holding the first async stack root
      2) Walk the async stack frame chain from the provided async stack root
      3) When we reach the end of the current async stack frame chain, check if the last async stack frame references an async stack root R1.
         If there is one, use R1 to find the start of the next normal stack frame when walking the normal stack frame.
      4) If that async stack root R1 has a next async stack root R2, the normal stack frame walk should end at the normal stack frame
         holding the next async stack root R2. Otherwise the normal stack frame walk should continue all the way until it hits nullptr.
      5) The next async stack walk should begin at the top async frame referenced by the next async stack root R2.
      6) Repeat until we've reached the end of both the normal and async stack frame chains.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D28102128
      
      fbshipit-source-id: c412a2a253720867c257d5cbaa9a6b22e96154f2
      94d0da77
  8. 30 Apr, 2021 7 commits
    • Yedidya Feldblum's avatar
      assume thread_local in AtFork · 29ba83e5
      Yedidya Feldblum authored
      Reviewed By: Orvid
      
      Differential Revision: D27671208
      
      fbshipit-source-id: 44710468544eebbb8f4ed0ecd5621bce0b56d248
      29ba83e5
    • Yedidya Feldblum's avatar
      shrink UniqueInstance ctor · 6ed9d378
      Yedidya Feldblum authored
      Summary:
      It is monomorphized but called rarely. Best to optimize for size.
      
      The `UniqueInstance` ctor is currently called in the constructor of each translation unit for each distinct instance of `SingletonThreadLocal`.
      
      `UniqueInstance` may be extended to more use-cases so it is worthwhile optimizing for size.
      
      Reviewed By: luciang
      
      Differential Revision: D27602938
      
      fbshipit-source-id: e4077830544516219485814ccc48805b7bb38e34
      6ed9d378
    • Vishal Sahu's avatar
      coro helper for FAIL() gtest macro · ebe2f775
      Vishal Sahu authored
      Summary: Need this to migrate CO_TEST using FAIL() fully on coroutines.
      
      Reviewed By: ispeters
      
      Differential Revision: D28099628
      
      fbshipit-source-id: c79658809210184d8895c3d1551e04b1baf88cae
      ebe2f775
    • Yedidya Feldblum's avatar
      tweak catch_exception taking fun-ptrs · 9552fbcd
      Yedidya Feldblum authored
      Summary: To reduce build size, avoid creating unnecessary functions. If the provided callable is already a function-pointer, the callee will already not be inlined.
      
      Differential Revision: D27984345
      
      fbshipit-source-id: a5a31330541338eb04e802bd9dafd99188af3ab9
      9552fbcd
    • Yedidya Feldblum's avatar
      work around gcc < 7 in UniqueInstance · f35ba916
      Yedidya Feldblum authored
      Summary: Some older versions of gcc cannot deduce the relevant types correctly, and they are still in use in corners of the codebase.
      
      Differential Revision: D28111907
      
      fbshipit-source-id: 0367cb102f450f0f601350308a5831c7fd68f775
      f35ba916
    • Yedidya Feldblum's avatar
      assume thread_local in SingletonThreadLocal · 3bab334d
      Yedidya Feldblum authored
      Differential Revision: D27582896
      
      fbshipit-source-id: e4228117ba02fe18bd6e8964640f293c963a8732
      3bab334d
    • REDMOND\agnel's avatar
      Fix several C++ warnings (#1565) · 3cdd3009
      REDMOND\agnel authored
      Summary:
      Fixes warnings about implicit type truncation. By making the conversions explicit, react-native-windows will be able to remove suppressions for several warnings required per SDL.
      
      Pull Request resolved: https://github.com/facebook/folly/pull/1565
      
      Reviewed By: igorsugak
      
      Differential Revision: D27964258
      
      Pulled By: yfeldblum
      
      fbshipit-source-id: b13f8728ecda0b38c2fd661199d6551c5ff87993
      3cdd3009
  9. 29 Apr, 2021 2 commits
    • Yedidya Feldblum's avatar
      tweak FOLLY_LIKELY to accept complex expressions · 903990db
      Yedidya Feldblum authored
      Summary: Complex expressions involving certain tokens parse at preprocessor time as multiple preprocessor arguments. Quite awkward. The trick is to change the preprocessor macro to deal in variadic arguments.
      
      Reviewed By: ot, Orvid, luciang
      
      Differential Revision: D27986071
      
      fbshipit-source-id: a126fca260396418b14b7367e3e41ddeea78b7af
      903990db
    • Srivatsan Ramesh's avatar
      Change socket QueueMessage to a variant · cdf0badc
      Srivatsan Ramesh authored
      Summary: QueueMessage is now a variant of NewConnMessage and ErrorMessage
      
      Reviewed By: praihan
      
      Differential Revision: D27384053
      
      fbshipit-source-id: a92f514b56f31e879dc329984bf0a615ed339836
      cdf0badc