From f0fc170209a6eaf2ca7807dbde721240ffb47d18 Mon Sep 17 00:00:00 2001 From: Michael O'Farrell Date: Wed, 14 Mar 2018 12:55:22 -0700 Subject: [PATCH] Codemod asserts to assertxs in the runtime Summary: swap assert for assertx in the runtime. Reviewed By: markw65 Differential Revision: D7272543 fbshipit-source-id: 2583d2bec9282cb6f2fa2b123ad2a622453ded6a --- hphp/runtime/base/annot-type.cpp | 4 +- hphp/runtime/base/annot-type.h | 8 +- hphp/runtime/base/apc-array.cpp | 2 +- hphp/runtime/base/apc-array.h | 20 +- hphp/runtime/base/apc-collection.cpp | 6 +- hphp/runtime/base/apc-collection.h | 4 +- hphp/runtime/base/apc-file-storage.cpp | 10 +- hphp/runtime/base/apc-gc-manager.cpp | 50 +-- hphp/runtime/base/apc-handle-defs.h | 10 +- hphp/runtime/base/apc-handle.cpp | 42 +- hphp/runtime/base/apc-handle.h | 6 +- hphp/runtime/base/apc-local-array-defs.h | 8 +- hphp/runtime/base/apc-local-array.cpp | 28 +- hphp/runtime/base/apc-local-array.h | 2 +- hphp/runtime/base/apc-object.cpp | 14 +- hphp/runtime/base/apc-object.h | 4 +- hphp/runtime/base/apc-stats.cpp | 6 +- hphp/runtime/base/apc-stats.h | 14 +- hphp/runtime/base/apc-string.cpp | 12 +- hphp/runtime/base/apc-string.h | 8 +- hphp/runtime/base/apc-typed-value.cpp | 54 +-- hphp/runtime/base/array-common.cpp | 6 +- hphp/runtime/base/array-data-defs.h | 36 +- hphp/runtime/base/array-data-inl.h | 18 +- hphp/runtime/base/array-data.cpp | 16 +- hphp/runtime/base/array-init.cpp | 6 +- hphp/runtime/base/array-init.h | 32 +- hphp/runtime/base/array-iterator-defs.h | 2 +- hphp/runtime/base/array-iterator.cpp | 142 +++--- hphp/runtime/base/array-iterator.h | 46 +- hphp/runtime/base/array-sort.cpp | 36 +- hphp/runtime/base/array-util.cpp | 6 +- hphp/runtime/base/atomic-shared-ptr.h | 2 +- hphp/runtime/base/autoload-handler.cpp | 24 +- hphp/runtime/base/backtrace.cpp | 6 +- hphp/runtime/base/builtin-functions.cpp | 18 +- hphp/runtime/base/collections.cpp | 12 +- hphp/runtime/base/comparisons.cpp | 2 +- hphp/runtime/base/comparisons.h | 56 +-- hphp/runtime/base/concurrent-shared-store.cpp | 22 +- hphp/runtime/base/concurrent-shared-store.h | 16 +- hphp/runtime/base/config.cpp | 4 +- hphp/runtime/base/container-functions.h | 12 +- hphp/runtime/base/countable.h | 48 +- hphp/runtime/base/data-stream-wrapper.cpp | 2 +- hphp/runtime/base/datetime.cpp | 4 +- hphp/runtime/base/directory.cpp | 6 +- hphp/runtime/base/empty-array.cpp | 44 +- hphp/runtime/base/emulate-zend.cpp | 2 +- hphp/runtime/base/enum-cache.cpp | 4 +- hphp/runtime/base/enum-cache.h | 6 +- hphp/runtime/base/exceptions.h | 2 +- hphp/runtime/base/execution-context.cpp | 134 +++--- hphp/runtime/base/file-await.cpp | 6 +- hphp/runtime/base/file-util.cpp | 6 +- hphp/runtime/base/file.cpp | 16 +- hphp/runtime/base/hash-table-inl.h | 22 +- hphp/runtime/base/hash-table.h | 18 +- hphp/runtime/base/heap-collect.cpp | 20 +- hphp/runtime/base/heap-graph.cpp | 2 +- hphp/runtime/base/heap-report.cpp | 4 +- hphp/runtime/base/heap-scan.h | 4 +- hphp/runtime/base/hhprof.cpp | 2 +- hphp/runtime/base/ini-setting.cpp | 38 +- hphp/runtime/base/init-fini-node.h | 4 +- hphp/runtime/base/intercept.cpp | 2 +- hphp/runtime/base/libevent-http-client.cpp | 4 +- hphp/runtime/base/mem-file.cpp | 28 +- hphp/runtime/base/memory-manager-defs.h | 50 +-- hphp/runtime/base/memory-manager-inl.h | 40 +- hphp/runtime/base/memory-manager.cpp | 90 ++-- hphp/runtime/base/mixed-array-defs.h | 48 +- hphp/runtime/base/mixed-array.cpp | 332 +++++++------- hphp/runtime/base/mixed-array.h | 24 +- hphp/runtime/base/object-data-inl.h | 34 +- hphp/runtime/base/object-data.cpp | 84 ++-- hphp/runtime/base/object-data.h | 8 +- hphp/runtime/base/output-file.cpp | 2 +- hphp/runtime/base/packed-array-defs.h | 8 +- hphp/runtime/base/packed-array.cpp | 488 ++++++++++----------- hphp/runtime/base/pipe.cpp | 6 +- hphp/runtime/base/plain-file.cpp | 34 +- hphp/runtime/base/preg.cpp | 20 +- hphp/runtime/base/program-functions.cpp | 16 +- hphp/runtime/base/property-table.cpp | 16 +- hphp/runtime/base/property-table.h | 4 +- hphp/runtime/base/purger.cpp | 6 +- hphp/runtime/base/rds.cpp | 20 +- hphp/runtime/base/ref-data.h | 12 +- hphp/runtime/base/repo-auth-type-array-inl.h | 6 +- hphp/runtime/base/repo-auth-type-array.cpp | 16 +- hphp/runtime/base/repo-auth-type-array.h | 10 +- hphp/runtime/base/repo-auth-type-codec-inl.h | 4 +- hphp/runtime/base/repo-auth-type-codec.cpp | 4 +- hphp/runtime/base/repo-auth-type.cpp | 6 +- hphp/runtime/base/repo-auth-type.h | 12 +- hphp/runtime/base/req-ptr.h | 6 +- hphp/runtime/base/req-root.cpp | 2 +- hphp/runtime/base/request-injection-data.cpp | 4 +- hphp/runtime/base/request-local.h | 2 +- hphp/runtime/base/resource-data.cpp | 2 +- hphp/runtime/base/resource-data.h | 22 +- hphp/runtime/base/root-map.h | 4 +- hphp/runtime/base/runtime-error.cpp | 2 +- hphp/runtime/base/set-array.cpp | 188 ++++---- hphp/runtime/base/set-array.h | 18 +- hphp/runtime/base/simple-counter.cpp | 2 +- hphp/runtime/base/slab-manager.h | 6 +- hphp/runtime/base/socket.cpp | 10 +- hphp/runtime/base/sort-flags.h | 2 +- hphp/runtime/base/sort-helpers.h | 8 +- hphp/runtime/base/sparse-heap.cpp | 2 +- hphp/runtime/base/ssl-socket.cpp | 4 +- hphp/runtime/base/ssl-socket.h | 2 +- hphp/runtime/base/stat-cache.cpp | 16 +- hphp/runtime/base/static-string-table.cpp | 46 +- hphp/runtime/base/stats.cpp | 6 +- hphp/runtime/base/stream-wrapper-registry.cpp | 2 +- hphp/runtime/base/string-buffer.cpp | 42 +- hphp/runtime/base/string-buffer.h | 8 +- hphp/runtime/base/string-data-inl.h | 40 +- hphp/runtime/base/string-data.cpp | 202 ++++----- hphp/runtime/base/string-data.h | 2 +- hphp/runtime/base/string-util.cpp | 12 +- hphp/runtime/base/sweepable.h | 2 +- hphp/runtime/base/temp-file.cpp | 8 +- hphp/runtime/base/thread-hooks.cpp | 2 +- hphp/runtime/base/thread-info.cpp | 4 +- hphp/runtime/base/thrift-buffer.h | 4 +- hphp/runtime/base/tv-arith.cpp | 38 +- hphp/runtime/base/tv-comparisons.cpp | 124 +++--- hphp/runtime/base/tv-conversions-inl.h | 4 +- hphp/runtime/base/tv-conversions.cpp | 188 ++++---- hphp/runtime/base/tv-helpers.cpp | 86 ++-- hphp/runtime/base/tv-mutate.h | 56 +-- hphp/runtime/base/tv-refcount.h | 20 +- hphp/runtime/base/tv-type.h | 2 +- hphp/runtime/base/tv-variant.h | 16 +- hphp/runtime/base/type-array.cpp | 26 +- hphp/runtime/base/type-object.h | 22 +- hphp/runtime/base/type-string.cpp | 10 +- hphp/runtime/base/type-string.h | 16 +- hphp/runtime/base/type-structure.cpp | 62 +-- hphp/runtime/base/type-variant.cpp | 14 +- hphp/runtime/base/type-variant.h | 150 ++++--- hphp/runtime/base/typed-value.h | 18 +- hphp/runtime/base/unit-cache.cpp | 4 +- hphp/runtime/base/url-file.cpp | 4 +- hphp/runtime/base/url.cpp | 4 +- hphp/runtime/base/user-file.cpp | 2 +- hphp/runtime/base/user-fs-node.cpp | 2 +- hphp/runtime/base/user-stream-wrapper.cpp | 2 +- hphp/runtime/base/utf8-decode.cpp | 2 +- hphp/runtime/base/variable-serializer.cpp | 70 +-- hphp/runtime/base/variable-unserializer.cpp | 28 +- hphp/runtime/base/weakref-data.cpp | 2 +- hphp/runtime/base/zend-collator.cpp | 10 +- hphp/runtime/base/zend-string.cpp | 56 +-- hphp/runtime/base/zend-url.cpp | 2 +- hphp/runtime/debugger/break_point.cpp | 20 +- hphp/runtime/debugger/cmd/cmd_break.cpp | 10 +- hphp/runtime/debugger/cmd/cmd_complete.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_constant.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_continue.cpp | 4 +- hphp/runtime/debugger/cmd/cmd_eval.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_extended.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_extension.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_flow_control.cpp | 4 +- hphp/runtime/debugger/cmd/cmd_flow_control.h | 4 +- hphp/runtime/debugger/cmd/cmd_info.cpp | 4 +- hphp/runtime/debugger/cmd/cmd_interrupt.cpp | 8 +- hphp/runtime/debugger/cmd/cmd_list.cpp | 4 +- hphp/runtime/debugger/cmd/cmd_next.cpp | 26 +- hphp/runtime/debugger/cmd/cmd_out.cpp | 4 +- hphp/runtime/debugger/cmd/cmd_print.cpp | 8 +- hphp/runtime/debugger/cmd/cmd_step.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_thread.cpp | 2 +- hphp/runtime/debugger/cmd/cmd_variable.cpp | 10 +- hphp/runtime/debugger/debugger.cpp | 6 +- hphp/runtime/debugger/debugger_client.cpp | 40 +- hphp/runtime/debugger/debugger_client.h | 2 +- hphp/runtime/debugger/debugger_command.cpp | 6 +- hphp/runtime/debugger/debugger_proxy.cpp | 10 +- hphp/runtime/debugger/debugger_thrift_buffer.cpp | 4 +- hphp/runtime/ext/apc/ext_apc.cpp | 14 +- hphp/runtime/ext/apc/snapshot.cpp | 12 +- hphp/runtime/ext/array/ext_array.cpp | 50 +-- hphp/runtime/ext/array/ext_array.h | 2 +- hphp/runtime/ext/asio/asio-blockable.cpp | 22 +- hphp/runtime/ext/asio/asio-blockable.h | 6 +- hphp/runtime/ext/asio/asio-context-enter-inl.h | 2 +- hphp/runtime/ext/asio/asio-context-enter.cpp | 18 +- hphp/runtime/ext/asio/asio-context-inl.h | 2 +- hphp/runtime/ext/asio/asio-context.cpp | 12 +- .../ext/asio/asio-external-thread-event-queue.cpp | 20 +- .../ext/asio/asio-external-thread-event.cpp | 8 +- hphp/runtime/ext/asio/asio-external-thread-event.h | 6 +- hphp/runtime/ext/asio/asio-session.cpp | 10 +- hphp/runtime/ext/asio/asio-session.h | 6 +- .../ext/asio/ext_async-function-wait-handle-inl.h | 4 +- .../ext/asio/ext_async-function-wait-handle.cpp | 42 +- .../ext/asio/ext_async-function-wait-handle.h | 4 +- .../ext/asio/ext_async-generator-wait-handle.cpp | 18 +- .../ext/asio/ext_async-generator-wait-handle.h | 2 +- hphp/runtime/ext/asio/ext_async-generator.cpp | 18 +- hphp/runtime/ext/asio/ext_async-generator.h | 2 +- .../runtime/ext/asio/ext_await-all-wait-handle.cpp | 18 +- hphp/runtime/ext/asio/ext_await-all-wait-handle.h | 2 +- .../runtime/ext/asio/ext_condition-wait-handle.cpp | 10 +- hphp/runtime/ext/asio/ext_condition-wait-handle.h | 2 +- .../asio/ext_external-thread-event-wait-handle.cpp | 18 +- .../asio/ext_external-thread-event-wait-handle.h | 6 +- .../ext/asio/ext_reschedule-wait-handle.cpp | 4 +- hphp/runtime/ext/asio/ext_reschedule-wait-handle.h | 2 +- hphp/runtime/ext/asio/ext_resumable-wait-handle.h | 3 +- hphp/runtime/ext/asio/ext_sleep-wait-handle.cpp | 8 +- hphp/runtime/ext/asio/ext_sleep-wait-handle.h | 2 +- hphp/runtime/ext/asio/ext_static-wait-handle.cpp | 4 +- hphp/runtime/ext/asio/ext_static-wait-handle.h | 2 +- hphp/runtime/ext/asio/ext_wait-handle.cpp | 22 +- hphp/runtime/ext/asio/ext_wait-handle.h | 16 +- .../ext/asio/ext_waitable-wait-handle-inl.h | 8 +- hphp/runtime/ext/asio/ext_waitable-wait-handle.cpp | 10 +- hphp/runtime/ext/async_mysql/ext_async_mysql.cpp | 16 +- hphp/runtime/ext/bz2/bz2-file.cpp | 16 +- hphp/runtime/ext/bz2/ext_bz2.cpp | 2 +- .../ext/collections/ext_collections-map.cpp | 64 +-- hphp/runtime/ext/collections/ext_collections-map.h | 12 +- .../ext/collections/ext_collections-set.cpp | 58 +-- hphp/runtime/ext/collections/ext_collections-set.h | 8 +- .../ext/collections/ext_collections-vector.cpp | 30 +- .../ext/collections/ext_collections-vector.h | 42 +- hphp/runtime/ext/collections/hash-collection.cpp | 96 ++-- hphp/runtime/ext/collections/hash-collection.h | 78 ++-- hphp/runtime/ext/curl/curl-resource.cpp | 2 +- hphp/runtime/ext/curl/ext_curl.cpp | 2 +- hphp/runtime/ext/datetime/ext_datetime.cpp | 6 +- hphp/runtime/ext/domdocument/ext_domdocument.cpp | 16 +- hphp/runtime/ext/domdocument/ext_domdocument.h | 6 +- hphp/runtime/ext/extension-registry.cpp | 32 +- hphp/runtime/ext/extension.h | 2 +- hphp/runtime/ext/fb/ext_fb.cpp | 18 +- hphp/runtime/ext/filter/logical_filters.cpp | 6 +- hphp/runtime/ext/gd/ext_gd.cpp | 24 +- hphp/runtime/ext/gd/libgd/gd_gd2.cpp | 2 +- hphp/runtime/ext/generator/ext_generator.cpp | 18 +- hphp/runtime/ext/generator/ext_generator.h | 14 +- hphp/runtime/ext/hash/ext_hash.cpp | 6 +- hphp/runtime/ext/hash/hash_engine.h | 9 +- hphp/runtime/ext/hash/hash_furc.cpp | 5 +- hphp/runtime/ext/hash/hash_haval.cpp | 4 +- hphp/runtime/ext/hash/hash_keccak.cpp | 8 +- hphp/runtime/ext/hh/ext_hh.cpp | 2 +- hphp/runtime/ext/hotprofiler/ext_hotprofiler.cpp | 4 +- hphp/runtime/ext/hotprofiler/ext_hotprofiler.h | 2 +- hphp/runtime/ext/icu/ext_icu_break_iterator.h | 6 +- hphp/runtime/ext/icu/ext_icu_calendar.cpp | 8 +- hphp/runtime/ext/icu/ext_icu_calendar.h | 2 +- hphp/runtime/ext/icu/ext_icu_collator.cpp | 2 +- hphp/runtime/ext/icu/ext_icu_date_fmt.h | 2 +- hphp/runtime/ext/icu/ext_icu_date_pattern_gen.h | 2 +- hphp/runtime/ext/icu/ext_icu_iterator.h | 2 +- hphp/runtime/ext/icu/ext_icu_locale.cpp | 4 +- hphp/runtime/ext/icu/ext_icu_msg_fmt.cpp | 2 +- hphp/runtime/ext/icu/ext_icu_num_fmt.h | 2 +- hphp/runtime/ext/icu/ext_icu_rsrc_bundle.h | 4 +- hphp/runtime/ext/icu/ext_icu_timezone.h | 2 +- hphp/runtime/ext/icu/ext_icu_transliterator.h | 2 +- hphp/runtime/ext/icu/ext_icu_uconverter.cpp | 2 +- hphp/runtime/ext/icu/ext_icu_ucsdet.h | 2 +- hphp/runtime/ext/icu/icu.cpp | 6 +- hphp/runtime/ext/imagick/ext_imagick.h | 2 +- hphp/runtime/ext/json/JSON_parser.cpp | 14 +- hphp/runtime/ext/json/ext_json.cpp | 2 +- hphp/runtime/ext/libxml/ext_libxml.cpp | 6 +- hphp/runtime/ext/libxml/ext_libxml.h | 14 +- hphp/runtime/ext/mailparse/mime.cpp | 2 +- hphp/runtime/ext/mcrouter/ext_mcrouter.cpp | 6 +- hphp/runtime/ext/memcache/ext_memcache.cpp | 2 +- hphp/runtime/ext/mysql/ext_mysqli.cpp | 6 +- hphp/runtime/ext/mysql/mysql_common.cpp | 24 +- hphp/runtime/ext/mysql/mysql_common.h | 2 +- hphp/runtime/ext/mysql/mysql_stats.cpp | 4 +- hphp/runtime/ext/objprof/ext_heapgraph.cpp | 2 +- hphp/runtime/ext/objprof/ext_objprof.cpp | 8 +- hphp/runtime/ext/odbc/ext_odbc.cpp | 4 +- hphp/runtime/ext/openssl/ext_openssl.cpp | 44 +- hphp/runtime/ext/pcre/ext_pcre.cpp | 4 +- hphp/runtime/ext/pdo/ext_pdo.cpp | 32 +- hphp/runtime/ext/pdo/pdo_driver.h | 2 +- hphp/runtime/ext/pdo_mysql/pdo_mysql.cpp | 2 +- hphp/runtime/ext/pdo_sqlite/pdo_sqlite.cpp | 4 +- hphp/runtime/ext/pgsql/pgsql.cpp | 2 +- hphp/runtime/ext/phar/ext_phar.cpp | 4 +- hphp/runtime/ext/posix/ext_posix.cpp | 8 +- hphp/runtime/ext/reflection/ext_reflection.cpp | 48 +- hphp/runtime/ext/reflection/ext_reflection.h | 28 +- hphp/runtime/ext/session/ext_session.cpp | 6 +- hphp/runtime/ext/shmop/ext_shmop.cpp | 2 +- hphp/runtime/ext/simplexml/ext_simplexml.cpp | 18 +- hphp/runtime/ext/soap/ext_soap.cpp | 4 +- hphp/runtime/ext/soap/ext_soap.h | 2 +- hphp/runtime/ext/soap/packet.cpp | 2 +- hphp/runtime/ext/sockets/ext_sockets.cpp | 10 +- hphp/runtime/ext/sqlite3/ext_sqlite3.cpp | 10 +- hphp/runtime/ext/std/ext_std_classobj.cpp | 10 +- hphp/runtime/ext/std/ext_std_closure.cpp | 2 +- hphp/runtime/ext/std/ext_std_file.cpp | 2 +- hphp/runtime/ext/std/ext_std_misc.cpp | 10 +- hphp/runtime/ext/std/ext_std_options.cpp | 16 +- hphp/runtime/ext/std/ext_std_process.cpp | 6 +- hphp/runtime/ext/std/ext_std_variable.cpp | 10 +- hphp/runtime/ext/stream/ext_stream.cpp | 6 +- hphp/runtime/ext/string/ext_string.cpp | 12 +- hphp/runtime/ext/thrift/transport.h | 2 +- hphp/runtime/ext/vsdebug/breakpoint.cpp | 2 +- hphp/runtime/ext/vsdebug/command.cpp | 4 +- hphp/runtime/ext/vsdebug/command_queue.cpp | 6 +- hphp/runtime/ext/vsdebug/completions_command.cpp | 2 +- hphp/runtime/ext/vsdebug/debugger.cpp | 54 +-- hphp/runtime/ext/vsdebug/evaluate_command.cpp | 6 +- hphp/runtime/ext/vsdebug/ext_vsdebug.cpp | 8 +- hphp/runtime/ext/vsdebug/session.cpp | 10 +- hphp/runtime/ext/vsdebug/set_variable_command.cpp | 6 +- hphp/runtime/ext/vsdebug/socket_transport.cpp | 6 +- hphp/runtime/ext/vsdebug/transport.cpp | 8 +- hphp/runtime/ext/vsdebug/variables_command.cpp | 16 +- hphp/runtime/ext/wddx/ext_wddx.cpp | 2 +- hphp/runtime/ext/weakref/ext_weakref.cpp | 2 +- hphp/runtime/ext/xdebug/ext_xdebug.cpp | 26 +- hphp/runtime/ext/xdebug/php5_xdebug/xdebug_var.cpp | 4 +- hphp/runtime/ext/xdebug/server.cpp | 12 +- hphp/runtime/ext/xdebug/xdebug_profiler.cpp | 14 +- hphp/runtime/ext/xml/ext_xml.cpp | 4 +- hphp/runtime/ext/xsl/ext_xsl.cpp | 10 +- hphp/runtime/ext/zlib/ext_zlib.cpp | 8 +- hphp/runtime/ext/zlib/zip-file.cpp | 16 +- hphp/runtime/server/access-log.cpp | 2 +- hphp/runtime/server/admin-request-handler.cpp | 4 +- hphp/runtime/server/cli-server.cpp | 4 +- .../server/fastcgi/fastcgi-server-factory.cpp | 2 +- hphp/runtime/server/fastcgi/fastcgi-session.cpp | 8 +- hphp/runtime/server/host-health-monitor.cpp | 2 +- hphp/runtime/server/host-health-monitor.h | 2 +- hphp/runtime/server/http-protocol.cpp | 14 +- hphp/runtime/server/http-request-handler.cpp | 8 +- hphp/runtime/server/http-server.cpp | 10 +- hphp/runtime/server/ip-block-map.cpp | 4 +- hphp/runtime/server/log-writer.cpp | 4 +- hphp/runtime/server/memory-stats.cpp | 2 +- hphp/runtime/server/pagelet-server.cpp | 16 +- .../runtime/server/proxygen/proxygen-transport.cpp | 18 +- hphp/runtime/server/replay-transport.cpp | 10 +- hphp/runtime/server/rpc-request-handler.cpp | 6 +- hphp/runtime/server/satellite-server.cpp | 2 +- hphp/runtime/server/server-stats.cpp | 8 +- hphp/runtime/server/server-worker.h | 4 +- hphp/runtime/server/server.h | 2 +- hphp/runtime/server/source-root-info.cpp | 2 +- hphp/runtime/server/takeover-agent.cpp | 2 +- hphp/runtime/server/transport.cpp | 42 +- hphp/runtime/server/virtual-host.cpp | 14 +- hphp/runtime/server/xbox-server.cpp | 8 +- hphp/runtime/server/xbox-server.h | 2 +- hphp/runtime/vm/act-rec-defs.h | 2 +- hphp/runtime/vm/act-rec-inl.h | 28 +- hphp/runtime/vm/act-rec.cpp | 6 +- hphp/runtime/vm/as.cpp | 10 +- hphp/runtime/vm/async-flow-stepper.cpp | 12 +- hphp/runtime/vm/bc-pattern.cpp | 2 +- hphp/runtime/vm/bc-pattern.h | 2 +- hphp/runtime/vm/blob-helper.h | 8 +- hphp/runtime/vm/bytecode.cpp | 420 +++++++++--------- hphp/runtime/vm/bytecode.h | 172 ++++---- hphp/runtime/vm/class-inl.h | 14 +- hphp/runtime/vm/class.cpp | 128 +++--- hphp/runtime/vm/debug/dwarf.cpp | 4 +- hphp/runtime/vm/debug/dwarf.h | 12 +- hphp/runtime/vm/disas.cpp | 6 +- hphp/runtime/vm/fixed-string-map-inl.h | 16 +- hphp/runtime/vm/func-emitter-inl.h | 12 +- hphp/runtime/vm/func-emitter.cpp | 36 +- hphp/runtime/vm/func-inl.h | 46 +- hphp/runtime/vm/func.cpp | 42 +- hphp/runtime/vm/globals-array.cpp | 8 +- hphp/runtime/vm/hhbc-codec.h | 6 +- hphp/runtime/vm/hhbc.cpp | 42 +- hphp/runtime/vm/indexed-string-map.h | 10 +- hphp/runtime/vm/instance-bits.cpp | 8 +- hphp/runtime/vm/jit/align-arm.cpp | 2 +- hphp/runtime/vm/jit/cfg-clean.cpp | 2 +- hphp/runtime/vm/jit/code-cache.cpp | 12 +- hphp/runtime/vm/jit/extra-data.h | 4 +- hphp/runtime/vm/jit/fixup.cpp | 4 +- hphp/runtime/vm/jit/gvn.cpp | 4 +- hphp/runtime/vm/jit/ir-unit-inl.h | 2 +- hphp/runtime/vm/jit/irgen-arith.cpp | 22 +- hphp/runtime/vm/jit/irgen-builtin.cpp | 6 +- hphp/runtime/vm/jit/irgen-internal.h | 4 +- hphp/runtime/vm/jit/irgen-interpone.cpp | 2 +- hphp/runtime/vm/jit/irgen-minstr.cpp | 2 +- hphp/runtime/vm/jit/irgen-resumable.cpp | 2 +- hphp/runtime/vm/jit/irgen-types.cpp | 8 +- hphp/runtime/vm/jit/irlower-class-func.cpp | 4 +- hphp/runtime/vm/jit/irlower-cmp.cpp | 12 +- hphp/runtime/vm/jit/irlower-internal-inl.h | 4 +- hphp/runtime/vm/jit/irlower-refcount.cpp | 2 +- hphp/runtime/vm/jit/licm.cpp | 4 +- hphp/runtime/vm/jit/load-elim.cpp | 2 +- hphp/runtime/vm/jit/mcgen-translate.cpp | 2 +- hphp/runtime/vm/jit/minstr-helpers.h | 6 +- hphp/runtime/vm/jit/mutation.cpp | 2 +- hphp/runtime/vm/jit/phys-reg.h | 8 +- hphp/runtime/vm/jit/reg-algorithms.cpp | 4 +- hphp/runtime/vm/jit/region-hot-cfg.cpp | 4 +- hphp/runtime/vm/jit/region-tracelet.cpp | 2 +- hphp/runtime/vm/jit/relocation-ppc64.cpp | 4 +- hphp/runtime/vm/jit/relocation-x64.cpp | 2 +- hphp/runtime/vm/jit/relocation.cpp | 4 +- hphp/runtime/vm/jit/service-request-handlers.cpp | 6 +- hphp/runtime/vm/jit/service-requests.cpp | 4 +- hphp/runtime/vm/jit/simplify.cpp | 2 +- hphp/runtime/vm/jit/smashable-instr-x64.cpp | 2 +- hphp/runtime/vm/jit/srcdb.cpp | 6 +- hphp/runtime/vm/jit/srcdb.h | 2 +- hphp/runtime/vm/jit/store-elim.cpp | 4 +- hphp/runtime/vm/jit/target-cache.cpp | 2 +- hphp/runtime/vm/jit/tc-internal.cpp | 2 +- hphp/runtime/vm/jit/tc-internal.h | 2 +- hphp/runtime/vm/jit/tc-record.cpp | 2 +- hphp/runtime/vm/jit/tc-recycle.cpp | 2 +- hphp/runtime/vm/jit/tc-relocate.cpp | 14 +- hphp/runtime/vm/jit/translator-runtime.cpp | 20 +- hphp/runtime/vm/jit/translator.cpp | 8 +- hphp/runtime/vm/jit/unwind-itanium.cpp | 6 +- hphp/runtime/vm/jit/vasm-check.cpp | 4 +- hphp/runtime/vm/jit/vasm-copy.cpp | 2 +- hphp/runtime/vm/jit/vasm-phi.cpp | 4 +- hphp/runtime/vm/jit/vasm-ppc64.cpp | 4 +- hphp/runtime/vm/jit/vasm-reg.h | 2 +- hphp/runtime/vm/jit/vasm-simplify.cpp | 2 +- hphp/runtime/vm/jit/vm-protect.cpp | 2 +- hphp/runtime/vm/jit/vtune-jit.cpp | 2 +- hphp/runtime/vm/litstr-table-inl.h | 14 +- hphp/runtime/vm/litstr-table.cpp | 2 +- hphp/runtime/vm/member-key.cpp | 2 +- hphp/runtime/vm/member-operations.cpp | 18 +- hphp/runtime/vm/member-operations.h | 36 +- hphp/runtime/vm/method-lookup.cpp | 26 +- hphp/runtime/vm/name-value-table.cpp | 48 +- hphp/runtime/vm/named-entity-pair-table-inl.h | 8 +- hphp/runtime/vm/named-entity.cpp | 4 +- hphp/runtime/vm/named-entity.h | 2 +- hphp/runtime/vm/native-data.cpp | 20 +- hphp/runtime/vm/native-data.h | 4 +- hphp/runtime/vm/native-prop-handler.cpp | 18 +- hphp/runtime/vm/native.cpp | 24 +- hphp/runtime/vm/native.h | 6 +- hphp/runtime/vm/pc-filter.cpp | 10 +- hphp/runtime/vm/preclass-emitter.cpp | 14 +- hphp/runtime/vm/preclass-inl.h | 6 +- hphp/runtime/vm/repo-helpers.cpp | 22 +- hphp/runtime/vm/repo-helpers.h | 2 +- hphp/runtime/vm/repo.cpp | 16 +- hphp/runtime/vm/repo.h | 6 +- hphp/runtime/vm/resumable.h | 18 +- hphp/runtime/vm/ringbuffer-print.cpp | 2 +- hphp/runtime/vm/runtime.cpp | 8 +- hphp/runtime/vm/runtime.h | 24 +- hphp/runtime/vm/srckey-inl.h | 18 +- hphp/runtime/vm/trait-method-import-data-inl.h | 2 +- hphp/runtime/vm/tread-hash-map.h | 17 +- hphp/runtime/vm/treadmill.cpp | 8 +- hphp/runtime/vm/type-alias-inl.h | 4 +- hphp/runtime/vm/type-alias.h | 4 +- hphp/runtime/vm/type-constraint.cpp | 48 +- hphp/runtime/vm/type-constraint.h | 6 +- hphp/runtime/vm/unit-emitter-inl.h | 4 +- hphp/runtime/vm/unit-emitter.cpp | 50 +-- hphp/runtime/vm/unit-inl.h | 18 +- hphp/runtime/vm/unit-util.h | 6 +- hphp/runtime/vm/unit.cpp | 49 ++- hphp/runtime/vm/unwind-inl.h | 4 +- hphp/runtime/vm/unwind.cpp | 30 +- hphp/runtime/vm/verifier/cfg.cpp | 13 +- hphp/runtime/vm/verifier/cfg.h | 8 +- hphp/runtime/vm/verifier/check-func.cpp | 14 +- hphp/runtime/vm/vm-regs.cpp | 6 +- hphp/runtime/vm/vm-regs.h | 16 +- 489 files changed, 4243 insertions(+), 4223 deletions(-) diff --git a/hphp/runtime/base/annot-type.cpp b/hphp/runtime/base/annot-type.cpp index 44fcc0b03bd..a1513cc4f02 100644 --- a/hphp/runtime/base/annot-type.cpp +++ b/hphp/runtime/base/annot-type.cpp @@ -106,7 +106,7 @@ static const std::pair& getAnnotTypeMaps() { } const AnnotType* nameToAnnotType(const StringData* typeName) { - assert(typeName); + assertx(typeName); auto const& mapPair = getAnnotTypeMaps(); return folly::get_ptr(mapPair.first, typeName); } @@ -114,7 +114,7 @@ const AnnotType* nameToAnnotType(const StringData* typeName) { const AnnotType* nameToAnnotType(const std::string& typeName) { auto const& mapPair = getAnnotTypeMaps(); auto const* at = folly::get_ptr(mapPair.second, typeName); - assert(!at || *at != AnnotType::Object); + assertx(!at || *at != AnnotType::Object); return at; } diff --git a/hphp/runtime/base/annot-type.h b/hphp/runtime/base/annot-type.h index 02d99dd95fc..2cda1e00e3f 100644 --- a/hphp/runtime/base/annot-type.h +++ b/hphp/runtime/base/annot-type.h @@ -85,7 +85,7 @@ inline DataType getAnnotDataType(AnnotType at) { } inline AnnotType dataTypeToAnnotType(DataType dt) { - assert(dt == KindOfUninit || dt == KindOfBoolean || dt == KindOfInt64 || + assertx(dt == KindOfUninit || dt == KindOfBoolean || dt == KindOfInt64 || dt == KindOfDouble || dt == KindOfString || dt == KindOfArray || dt == KindOfVec || dt == KindOfDict || dt == KindOfKeyset || dt == KindOfObject || dt == KindOfResource); @@ -176,8 +176,8 @@ enum class AnnotAction { */ inline AnnotAction annotCompat(DataType dt, AnnotType at, const StringData* annotClsName) { - assert(dt != KindOfRef); - assert(IMPLIES(at == AnnotType::Object, annotClsName != nullptr)); + assertx(dt != KindOfRef); + assertx(IMPLIES(at == AnnotType::Object, annotClsName != nullptr)); auto const metatype = getAnnotMetaType(at); switch (metatype) { @@ -232,7 +232,7 @@ annotCompat(DataType dt, AnnotType at, const StringData* annotClsName) { break; } - assert(metatype == AnnotMetaType::Precise); + assertx(metatype == AnnotMetaType::Precise); if (at != AnnotType::Object) { // If `at' is "bool", "int", "float", "string", "array", or "resource", // then equivDataTypes() can definitively tell us whether or not `dt' diff --git a/hphp/runtime/base/apc-array.cpp b/hphp/runtime/base/apc-array.cpp index 05888c92da6..feff75d2fcf 100644 --- a/hphp/runtime/base/apc-array.cpp +++ b/hphp/runtime/base/apc-array.cpp @@ -212,7 +212,7 @@ APCHandle* APCArray::MakeUncountedArray(ArrayData* array, PointerMap* m) { auto const mem = reinterpret_cast(data) - 1; return new(mem) APCTypedValue(APCTypedValue::UncountedArr{}, data); } - assert(array->isMixed()); + assertx(array->isMixed()); auto const data = MixedArray::MakeUncounted(array, true, m); auto const mem = reinterpret_cast(data) - 1; return new(mem) APCTypedValue(APCTypedValue::UncountedArr{}, data); diff --git a/hphp/runtime/base/apc-array.h b/hphp/runtime/base/apc-array.h index e4a5ee6b949..b0f4f604dc7 100644 --- a/hphp/runtime/base/apc-array.h +++ b/hphp/runtime/base/apc-array.h @@ -59,8 +59,8 @@ struct APCArray { static void Delete(APCHandle* handle); static APCArray* fromHandle(APCHandle* handle) { - assert(handle->checkInvariants()); - assert(handle->kind() == APCKind::SharedArray || + assertx(handle->checkInvariants()); + assertx(handle->kind() == APCKind::SharedArray || handle->kind() == APCKind::SharedPackedArray || handle->kind() == APCKind::SharedVArray || handle->kind() == APCKind::SharedDArray || @@ -72,8 +72,8 @@ struct APCArray { } static const APCArray* fromHandle(const APCHandle* handle) { - assert(handle->checkInvariants()); - assert(handle->kind() == APCKind::SharedArray || + assertx(handle->checkInvariants()); + assertx(handle->kind() == APCKind::SharedArray || handle->kind() == APCKind::SharedPackedArray || handle->kind() == APCKind::SharedVArray || handle->kind() == APCKind::SharedDArray || @@ -110,19 +110,19 @@ struct APCArray { Variant getKey(ssize_t pos) const { if (isPacked()) { - assert(static_cast(pos) < m_size); + assertx(static_cast(pos) < m_size); return pos; } - assert(static_cast(pos) < m.m_num); + assertx(static_cast(pos) < m.m_num); return buckets()[pos].key->toLocal(); } APCHandle* getValue(ssize_t pos) const { if (isPacked()) { - assert(static_cast(pos) < m_size); + assertx(static_cast(pos) < m_size); return vals()[pos]; } - assert(static_cast(pos) < m.m_num); + assertx(static_cast(pos) < m.m_num); return buckets()[pos].val; } @@ -196,12 +196,12 @@ private: enum class PackedCtor {}; APCArray(PackedCtor, APCKind kind, size_t size) : m_handle(kind, kInvalidDataType), m_size(size) { - assert(isPacked()); + assertx(isPacked()); } enum class HashedCtor {}; APCArray(HashedCtor, APCKind kind, unsigned int cap) : m_handle(kind) { - assert(isHashed()); + assertx(isHashed()); m.m_capacity_mask = cap - 1; m.m_num = 0; } diff --git a/hphp/runtime/base/apc-collection.cpp b/hphp/runtime/base/apc-collection.cpp index 93ced10b169..0a5cfb8d75e 100644 --- a/hphp/runtime/base/apc-collection.cpp +++ b/hphp/runtime/base/apc-collection.cpp @@ -102,7 +102,7 @@ APCHandle::Pair APCCollection::Make(const ObjectData* obj, !array->empty()) { DataWalker walker(DataWalker::LookupFeature::HasObjectOrResource); auto const features = walker.traverseData(const_cast(array)); - assert(!features.isCircular); + assertx(!features.isCircular); if (!features.hasObjectOrResource) { auto const makeUncounted = [&] () { if (isVectorCollection(obj->collectionType())) { @@ -131,7 +131,7 @@ APCHandle::Pair APCCollection::Make(const ObjectData* obj, } void APCCollection::Delete(APCHandle* h) { - assert(offsetof(APCCollection, m_handle) == 0); + assertx(offsetof(APCCollection, m_handle) == 0); delete reinterpret_cast(h); } @@ -156,7 +156,7 @@ APCHandle::Pair APCCollection::WrapArray(APCHandle::Pair inner, Object APCCollection::createObject() const { if (m_arrayHandle->isTypedValue()) { Variant local(m_arrayHandle->toLocal()); - assert(local.isArray()); + assertx(local.isArray()); return Object::attach( collections::alloc(m_colType, local.getArrayData()) ); diff --git a/hphp/runtime/base/apc-collection.h b/hphp/runtime/base/apc-collection.h index 7532834d0d2..26249c92a09 100644 --- a/hphp/runtime/base/apc-collection.h +++ b/hphp/runtime/base/apc-collection.h @@ -32,8 +32,8 @@ struct APCCollection { static void Delete(APCHandle*); static const APCCollection* fromHandle(const APCHandle* handle) { - assert(handle->checkInvariants()); - assert(handle->kind() == APCKind::SharedCollection); + assertx(handle->checkInvariants()); + assertx(handle->kind() == APCKind::SharedCollection); static_assert(offsetof(APCCollection, m_handle) == 0, ""); return reinterpret_cast(handle); } diff --git a/hphp/runtime/base/apc-file-storage.cpp b/hphp/runtime/base/apc-file-storage.cpp index 43042280f9c..23cabdc4530 100644 --- a/hphp/runtime/base/apc-file-storage.cpp +++ b/hphp/runtime/base/apc-file-storage.cpp @@ -45,7 +45,7 @@ void APCFileStorage::enable(const std::string& prefix, size_t chunkSize) { if (chunkSize <= PaddingSize) return; m_prefix = prefix; m_chunkSize = chunkSize; - assert(m_chunkSize < ~uint32_t(0)); // Must fit in low 32 bits of m_current. + assertx(m_chunkSize < ~uint32_t(0)); // Must fit in low 32 bits of m_current. if (m_state != StorageState::Invalid) { return; } @@ -61,7 +61,7 @@ char* APCFileStorage::put(const char* data, uint32_t len) { auto maxOffset = m_chunkSize - totalLen; auto current = m_current.load(std::memory_order_relaxed); // m_current is intialized to -1 to postpone allocation to first 'put'. - assert(!m_chunks.empty() || current == ~0ull); + assertx(!m_chunks.empty() || current == ~0ull); do { if (UNLIKELY(static_cast(current) > maxOffset)) { std::lock_guard lock(m_lock); @@ -94,7 +94,7 @@ char* APCFileStorage::put(const char* data, uint32_t len) { uint64_t h = hash_string_cs_unsafe(data, len); *(uint64_t*)base = h | (static_cast(len) << 32); base += sizeof(uint64_t); - assert(base[len] == '\0'); // Should already be 0 after mmap. + assertx(base[len] == '\0'); // Should already be 0 after mmap. // Return the starting address of the string. return static_cast(memcpy(base, data, len)); } @@ -104,7 +104,7 @@ void APCFileStorage::seal() { if (m_state == StorageState::Sealed || m_chunks.empty()) { return; } - assert(m_state == StorageState::Open || m_state == StorageState::Full); + assertx(m_state == StorageState::Open || m_state == StorageState::Full); m_state = StorageState::Sealed; auto const current = m_current.load(std::memory_order_acquire); @@ -250,7 +250,7 @@ bool APCFileStorage::addFile() { std::memory_order_acquire, std::memory_order_relaxed)) { // Guaranteed by the memory_order_acquire - assert(current >> 32 == m_chunks.size() - 1); + assertx(current >> 32 == m_chunks.size() - 1); auto const p = m_chunks.back() + static_cast(current); *reinterpret_cast(p) = TombHash; break; diff --git a/hphp/runtime/base/apc-gc-manager.cpp b/hphp/runtime/base/apc-gc-manager.cpp index cdb29851394..9eb2d9ed465 100644 --- a/hphp/runtime/base/apc-gc-manager.cpp +++ b/hphp/runtime/base/apc-gc-manager.cpp @@ -193,7 +193,7 @@ APCGCManager& APCGCManager::getInstance() { ALWAYS_INLINE void RegisterUncountedTvAllocations(TypedValue& tv, APCHandle* rootAPCHandle) { if (isStringType(tv.m_type)) { - assert(!tv.m_data.pstr->isRefCounted()); + assertx(!tv.m_data.pstr->isRefCounted()); if (tv.m_data.pstr->isUncounted()) { tv.m_data.pstr->registerUncountedAllocation(rootAPCHandle); } @@ -201,7 +201,7 @@ void RegisterUncountedTvAllocations(TypedValue& tv, APCHandle* rootAPCHandle) { } if (isArrayLikeType(tv.m_type)) { auto arr = tv.m_data.parr; - assert(!arr->isRefCounted()); + assertx(!arr->isRefCounted()); if (!arr->isStatic()) { if (arr->hasPackedLayout()) { PackedArray::RegisterUncountedAllocations(arr, rootAPCHandle); @@ -222,11 +222,11 @@ void RegisterUncountedTvAllocations(TypedValue& tv, APCHandle* rootAPCHandle) { * with APCGCManager */ void APCTypedValue::registerUncountedAllocations() { - assert(m_handle.isUncounted()); - assert(RuntimeOption::EvalGCForAPC); + assertx(m_handle.isUncounted()); + assertx(RuntimeOption::EvalGCForAPC); auto kind = m_handle.kind(); - assert(kind == APCKind::UncountedString || + assertx(kind == APCKind::UncountedString || kind == APCKind::UncountedArray || kind == APCKind::UncountedVec || kind == APCKind::UncountedDict || @@ -234,7 +234,7 @@ void APCTypedValue::registerUncountedAllocations() { if (kind == APCKind::UncountedString) { m_data.str->registerUncountedAllocation(&m_handle); } else if (kind == APCKind::UncountedArray) { - assert(m_data.arr->isPHPArray()); + assertx(m_data.arr->isPHPArray()); if (m_data.arr->hasPackedLayout()) { auto arr = m_data.arr; PackedArray::RegisterUncountedAllocations(arr, &m_handle); @@ -246,17 +246,17 @@ void APCTypedValue::registerUncountedAllocations() { } } else if (kind == APCKind::UncountedVec) { auto vec = m_data.vec; - assert(vec->isVecArray()); + assertx(vec->isVecArray()); PackedArray::RegisterUncountedAllocations(vec, &m_handle); return; } else if (kind == APCKind::UncountedDict) { auto dict = m_data.dict; - assert(dict->isDict()); + assertx(dict->isDict()); MixedArray::RegisterUncountedAllocations(dict, &m_handle); return; } else if (kind == APCKind::UncountedKeyset) { auto keyset = m_data.keyset; - assert(keyset->isKeyset()); + assertx(keyset->isKeyset()); SetArray::RegisterUncountedAllocations(keyset, &m_handle); return; } @@ -265,9 +265,9 @@ void APCTypedValue::registerUncountedAllocations() { // Register {allocation, rootAPCHandle} with APCGCManager void StringData::registerUncountedAllocation(APCHandle* rootAPCHandle) { - assert(checkSane() && isUncounted()); - assert(isFlat()); - assert(RuntimeOption::EvalGCForAPC); + assertx(checkSane() && isUncounted()); + assertx(isFlat()); + assertx(RuntimeOption::EvalGCForAPC); // [this, this + 1) doesn't give us address of the string // But we assume reference point only at the header of a StringData APCGCManager::getInstance().registerAllocation(this, @@ -281,16 +281,16 @@ void StringData::registerUncountedAllocation(APCHandle* rootAPCHandle) { */ void PackedArray::RegisterUncountedAllocations(ArrayData* ad, APCHandle* rootAPCHandle) { - assert(checkInvariants(ad)); - assert(ad->isUncounted()); + assertx(checkInvariants(ad)); + assertx(ad->isUncounted()); auto const data = packedData(ad); auto const stop = data + ad->m_size; for (auto ptr = data; ptr != stop; ++ptr) { RegisterUncountedTvAllocations(*ptr, rootAPCHandle); } - assert(!has_strong_iterator(ad)); - assert(RuntimeOption::EvalGCForAPC); + assertx(!has_strong_iterator(ad)); + assertx(RuntimeOption::EvalGCForAPC); APCGCManager::getInstance().registerAllocation(ad, (char*)ad + PackedArray::heapSize(ad), rootAPCHandle); @@ -303,7 +303,7 @@ void PackedArray::RegisterUncountedAllocations(ArrayData* ad, void MixedArray::RegisterUncountedAllocations(ArrayData* in, APCHandle* rootAPCHandle) { auto const ad = asMixed(in); - assert(ad->isUncounted()); + assertx(ad->isUncounted()); if (!ad->isZombie()) { auto const data = ad->data(); auto const stop = data + ad->m_used; @@ -311,16 +311,16 @@ void MixedArray::RegisterUncountedAllocations(ArrayData* in, for (auto ptr = data; ptr != stop; ++ptr) { if (isTombstone(ptr->data.m_type)) continue; if (ptr->hasStrKey()) { - assert(!ptr->skey->isRefCounted()); + assertx(!ptr->skey->isRefCounted()); if (ptr->skey->isUncounted()) { ptr->skey->registerUncountedAllocation(rootAPCHandle); } } RegisterUncountedTvAllocations(ptr->data, rootAPCHandle); } - assert(!has_strong_iterator(ad)); + assertx(!has_strong_iterator(ad)); } - assert(RuntimeOption::EvalGCForAPC); + assertx(RuntimeOption::EvalGCForAPC); APCGCManager::getInstance().registerAllocation(ad, (char*)ad + ad->heapSize(), rootAPCHandle); @@ -332,7 +332,7 @@ void MixedArray::RegisterUncountedAllocations(ArrayData* in, */ void SetArray::RegisterUncountedAllocations(ArrayData* in, APCHandle* rootAPCHandle) { - assert(in->isUncounted()); + assertx(in->isUncounted()); auto const ad = asSet(in); if (!ad->isZombie()) { @@ -341,18 +341,18 @@ void SetArray::RegisterUncountedAllocations(ArrayData* in, for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); if (elm.hasStrKey()) { auto const skey = elm.strKey(); - assert(!skey->isRefCounted()); + assertx(!skey->isRefCounted()); if (skey->isUncounted()) { skey->registerUncountedAllocation(rootAPCHandle); } } } - assert(!has_strong_iterator(ad)); + assertx(!has_strong_iterator(ad)); } - assert(RuntimeOption::EvalGCForAPC); + assertx(RuntimeOption::EvalGCForAPC); APCGCManager::getInstance().registerAllocation(ad, (char*)ad + ad->heapSize(), rootAPCHandle); diff --git a/hphp/runtime/base/apc-handle-defs.h b/hphp/runtime/base/apc-handle-defs.h index b1a82e068d4..f690468b62d 100644 --- a/hphp/runtime/base/apc-handle-defs.h +++ b/hphp/runtime/base/apc-handle-defs.h @@ -36,7 +36,7 @@ inline void APCHandle::unreferenceNonRoot() const { } inline void APCHandle::unreferenceRoot(size_t size) { - assert(isSingletonKind() || m_unref_root_count++ == 0); + assertx(isSingletonKind() || m_unref_root_count++ == 0); if (!isUncounted()) { atomicDecRef(); } else { @@ -50,17 +50,17 @@ inline bool APCHandle::isAtomicCounted() const { } inline void APCHandle::atomicIncRef() const { - assert(isAtomicCounted()); + assertx(isAtomicCounted()); ++m_count; } inline void APCHandle::atomicDecRef() const { - assert(m_count.load() > 0); + assertx(m_count.load() > 0); if (m_count > 1) { - assert(isAtomicCounted()); + assertx(isAtomicCounted()); if (--m_count) return; } - assert(isSingletonKind() || m_unref_root_count == 1); + assertx(isSingletonKind() || m_unref_root_count == 1); const_cast(this)->deleteShared(); } diff --git a/hphp/runtime/base/apc-handle.cpp b/hphp/runtime/base/apc-handle.cpp index 1371ef24785..2d6c5949a2d 100644 --- a/hphp/runtime/base/apc-handle.cpp +++ b/hphp/runtime/base/apc-handle.cpp @@ -85,28 +85,28 @@ APCHandle::Pair APCHandle::Create(const Variant& source, case KindOfPersistentVec: case KindOfVec: { auto ad = source.getArrayData(); - assert(ad->isVecArray()); + assertx(ad->isVecArray()); return APCArray::MakeSharedVec(ad, level, unserializeObj); } case KindOfPersistentDict: case KindOfDict: { auto ad = source.getArrayData(); - assert(ad->isDict()); + assertx(ad->isDict()); return APCArray::MakeSharedDict(ad, level, unserializeObj); } case KindOfPersistentKeyset: case KindOfKeyset: { auto ad = source.getArrayData(); - assert(ad->isKeyset()); + assertx(ad->isKeyset()); return APCArray::MakeSharedKeyset(ad, level, unserializeObj); } case KindOfPersistentArray: case KindOfArray: { auto ad = source.getArrayData(); - assert(ad->isPHPArray()); + assertx(ad->isPHPArray()); return APCArray::MakeSharedArray(ad, level, unserializeObj); } @@ -157,25 +157,25 @@ Variant APCHandle::toLocalHelper() const { case APCKind::SerializedArray: { auto const serArr = APCString::fromHandle(this)->getStringData(); auto const v = apc_unserialize(serArr->data(), serArr->size()); - assert(v.isPHPArray()); + assertx(v.isPHPArray()); return v; } case APCKind::SerializedVec: { auto const serVec = APCString::fromHandle(this)->getStringData(); auto const v = apc_unserialize(serVec->data(), serVec->size()); - assert(v.isVecArray()); + assertx(v.isVecArray()); return v; } case APCKind::SerializedDict: { auto const serDict = APCString::fromHandle(this)->getStringData(); auto const v = apc_unserialize(serDict->data(), serDict->size()); - assert(v.isDict()); + assertx(v.isDict()); return v; } case APCKind::SerializedKeyset: { auto const serKeyset = APCString::fromHandle(this)->getStringData(); auto const v = apc_unserialize(serKeyset->data(), serKeyset->size()); - assert(v.isKeyset()); + assertx(v.isKeyset()); return v; } case APCKind::SharedArray: @@ -218,7 +218,7 @@ Variant APCHandle::toLocalHelper() const { } void APCHandle::deleteShared() { - assert(checkInvariants()); + assertx(checkInvariants()); switch (m_kind) { case APCKind::Uninit: case APCKind::Null: @@ -267,7 +267,7 @@ void APCHandle::deleteShared() { case APCKind::UncountedDict: case APCKind::UncountedKeyset: case APCKind::UncountedString: - assert(false); + assertx(false); return; } not_reached(); @@ -276,39 +276,39 @@ void APCHandle::deleteShared() { bool APCHandle::checkInvariants() const { switch (m_kind) { case APCKind::Uninit: - assert(m_type == KindOfUninit); + assertx(m_type == KindOfUninit); return true; case APCKind::Null: - assert(m_type == KindOfNull); + assertx(m_type == KindOfNull); return true; case APCKind::Bool: - assert(m_type == KindOfBoolean); + assertx(m_type == KindOfBoolean); return true; case APCKind::Int: - assert(m_type == KindOfInt64); + assertx(m_type == KindOfInt64); return true; case APCKind::Double: - assert(m_type == KindOfDouble); + assertx(m_type == KindOfDouble); return true; case APCKind::StaticString: case APCKind::UncountedString: - assert(m_type == KindOfPersistentString); + assertx(m_type == KindOfPersistentString); return true; case APCKind::StaticArray: case APCKind::UncountedArray: - assert(m_type == KindOfPersistentArray); + assertx(m_type == KindOfPersistentArray); return true; case APCKind::StaticVec: case APCKind::UncountedVec: - assert(m_type == KindOfPersistentVec); + assertx(m_type == KindOfPersistentVec); return true; case APCKind::StaticDict: case APCKind::UncountedDict: - assert(m_type == KindOfPersistentDict); + assertx(m_type == KindOfPersistentDict); return true; case APCKind::StaticKeyset: case APCKind::UncountedKeyset: - assert(m_type == KindOfPersistentKeyset); + assertx(m_type == KindOfPersistentKeyset); return true; case APCKind::SharedVArray: case APCKind::SharedDArray: @@ -326,7 +326,7 @@ bool APCHandle::checkInvariants() const { case APCKind::SerializedDict: case APCKind::SerializedKeyset: case APCKind::SerializedObject: - assert(m_type == kInvalidDataType); + assertx(m_type == kInvalidDataType); return true; } not_reached(); diff --git a/hphp/runtime/base/apc-handle.h b/hphp/runtime/base/apc-handle.h index f4082443fae..d746d64c9c5 100644 --- a/hphp/runtime/base/apc-handle.h +++ b/hphp/runtime/base/apc-handle.h @@ -142,7 +142,7 @@ struct APCHandle { explicit APCHandle(APCKind kind, DataType type = kInvalidDataType) : m_type(type), m_kind(kind) { - assert(checkInvariants()); + assertx(checkInvariants()); } APCHandle(const APCHandle&) = delete; @@ -219,13 +219,13 @@ struct APCHandle { * the thread-safety rule documented above the class. */ bool objAttempted() const { - assert(m_kind == APCKind::SerializedObject || + assertx(m_kind == APCKind::SerializedObject || m_kind == APCKind::SharedObject || m_kind == APCKind::SharedCollection); return m_obj_attempted.load(std::memory_order_relaxed); } void setObjAttempted() { - assert(m_kind == APCKind::SerializedObject || + assertx(m_kind == APCKind::SerializedObject || m_kind == APCKind::SharedObject || m_kind == APCKind::SharedCollection); m_obj_attempted.store(true, std::memory_order_relaxed); diff --git a/hphp/runtime/base/apc-local-array-defs.h b/hphp/runtime/base/apc-local-array-defs.h index 04526ff8822..a48b8e3eeac 100644 --- a/hphp/runtime/base/apc-local-array-defs.h +++ b/hphp/runtime/base/apc-local-array-defs.h @@ -32,7 +32,7 @@ inline APCLocalArray::APCLocalArray(const APCArray* source) source->reference(); tl_heap->addApcArray(this); memset(localCache(), KindOfUninit, m_size * sizeof(TypedValue)); - assert(hasExactlyOneRef()); + assertx(hasExactlyOneRef()); } inline size_t APCLocalArray::heapSize() const { @@ -42,19 +42,19 @@ inline size_t APCLocalArray::heapSize() const { inline APCLocalArray* APCLocalArray::Make(const APCArray* aa) { auto size = sizeof(APCLocalArray) + aa->size() * sizeof(TypedValue); auto local = new (tl_heap->objMalloc(size)) APCLocalArray(aa); - assert(local->heapSize() == size); + assertx(local->heapSize() == size); return local; } ALWAYS_INLINE APCLocalArray* APCLocalArray::asApcArray(ArrayData* ad) { - assert(ad->kind() == kApcKind); + assertx(ad->kind() == kApcKind); return static_cast(ad); } ALWAYS_INLINE const APCLocalArray* APCLocalArray::asApcArray(const ArrayData* ad) { - assert(ad->kind() == kApcKind); + assertx(ad->kind() == kApcKind); return static_cast(ad); } diff --git a/hphp/runtime/base/apc-local-array.cpp b/hphp/runtime/base/apc-local-array.cpp index 22d36ebe1ba..22dfc19850b 100644 --- a/hphp/runtime/base/apc-local-array.cpp +++ b/hphp/runtime/base/apc-local-array.cpp @@ -59,14 +59,14 @@ struct EscalateHelper { ////////////////////////////////////////////////////////////////////// bool APCLocalArray::checkInvariants(const ArrayData* ad) { - assert(ad->isApcArray()); - assert(ad->isNotDVArray()); - assert(ad->checkCount()); + assertx(ad->isApcArray()); + assertx(ad->isNotDVArray()); + assertx(ad->checkCount()); DEBUG_ONLY auto const local = static_cast(ad); DEBUG_ONLY auto p = local->localCache(); for (auto end = p + local->getSize(); p < end; ++p) { // Elements in the local cache must not be KindOfRef. - assert(cellIsPlausible(*p)); + assertx(cellIsPlausible(*p)); } return true; } @@ -84,18 +84,18 @@ void APCLocalArray::sweep() { member_rval::ptr_u APCLocalArray::GetValueRef(const ArrayData* adIn, ssize_t pos) { auto const ad = asApcArray(adIn); - assert(unsigned(pos) < ad->getSize()); + assertx(unsigned(pos) < ad->getSize()); auto const elms = ad->localCache(); auto const tv = &elms[pos]; if (tv->m_type != KindOfUninit) return tv; auto const sv = ad->m_arr->getValue(pos); tvAsVariant(tv) = sv->toLocal(); - assert(tv->m_type != KindOfUninit); + assertx(tv->m_type != KindOfUninit); return tv; } void APCLocalArray::Release(ArrayData* ad) { - assert(ad->hasExactlyOneRef()); + assertx(ad->hasExactlyOneRef()); auto const a = asApcArray(ad); auto size = a->heapSize(); @@ -154,7 +154,7 @@ ArrayData* APCLocalArray::loadElems() const { if (elems->isStatic()) { elems = elems->copy(); } - assert(elems->hasExactlyOneRef()); + assertx(elems->hasExactlyOneRef()); return elems; } @@ -282,8 +282,8 @@ ArrayData* APCLocalArray::Prepend(ArrayData* ad, Cell v, bool /*copy*/) { ArrayData *APCLocalArray::Escalate(const ArrayData* ad) { auto smap = asApcArray(ad); auto ret = smap->loadElems(); - assert(!ret->isStatic()); - assert(ret->hasExactlyOneRef()); + assertx(!ret->isStatic()); + assertx(ret->hasExactlyOneRef()); return ret; } @@ -317,8 +317,8 @@ ArrayData* APCLocalArray::EscalateForSort(ArrayData* ad, SortFunction sf) { if (ret != elems) { elems->release(); } - assert(ret->hasExactlyOneRef()); - assert(!ret->isStatic()); + assertx(ret->hasExactlyOneRef()); + assertx(!ret->isStatic()); return ret; } @@ -369,14 +369,14 @@ ssize_t APCLocalArray::IterAdvance(const ArrayData* ad, ssize_t prev) { ssize_t APCLocalArray::IterRewind(const ArrayData* ad, ssize_t prev) { auto a = asApcArray(ad); - assert(prev >= 0 && prev < a->m_size); + assertx(prev >= 0 && prev < a->m_size); ssize_t next = prev - 1; return next >= 0 ? next : a->m_size; } bool APCLocalArray::ValidMArrayIter(const ArrayData* ad, const MArrayIter& fp) { - assert(fp.getContainer() == ad); + assertx(fp.getContainer() == ad); not_reached(); // we should've escalated } diff --git a/hphp/runtime/base/apc-local-array.h b/hphp/runtime/base/apc-local-array.h index 321ebd9bb90..2bebb815285 100644 --- a/hphp/runtime/base/apc-local-array.h +++ b/hphp/runtime/base/apc-local-array.h @@ -135,7 +135,7 @@ public: using ArrayData::incRefCount; ssize_t iterAdvanceImpl(ssize_t prev) const { - assert(prev >= 0 && prev < m_size); + assertx(prev >= 0 && prev < m_size); ssize_t next = prev + 1; return next < m_size ? next : m_size; } diff --git a/hphp/runtime/base/apc-object.cpp b/hphp/runtime/base/apc-object.cpp index 1f19ab217be..728c60ba45e 100644 --- a/hphp/runtime/base/apc-object.cpp +++ b/hphp/runtime/base/apc-object.cpp @@ -61,7 +61,7 @@ APCObject::APCObject(ClassOrName cls, uint32_t propCount) APCHandle::Pair APCObject::Construct(ObjectData* objectData) { // This function assumes the object and object/array down the tree have no // internal references and do not implement the serializable interface. - assert(!objectData->instanceof(SystemLib::s_SerializableClass)); + assertx(!objectData->instanceof(SystemLib::s_SerializableClass)); auto cls = objectData->getVMClass(); auto clsOrName = make_class(cls); @@ -91,7 +91,7 @@ APCHandle::Pair APCObject::Construct(ObjectData* objectData) { for (unsigned i = 0; i < numRealProps; ++i) { auto const attrs = propInfo[i].attrs; - assert((attrs & AttrStatic) == 0); + assertx((attrs & AttrStatic) == 0); const TypedValue* objProp; if (attrs & AttrBuiltin) { @@ -137,7 +137,7 @@ APCHandle::Pair APCObject::ConstructSlow(ObjectData* objectData, auto prop = apcObj->props(); for (ArrayIter it(odProps); !it.end(); it.next(), ++prop) { Variant key(it.first()); - assert(key.isString()); + assertx(key.isString()); auto const rval = it.secondRval(); if (!isNullType(rval.unboxed().type())) { auto val = APCHandle::Create(VarNR(rval.tv()), false, @@ -171,7 +171,7 @@ APCHandle::Pair APCObject::ConstructSlow(ObjectData* objectData, prop->name = makeStaticString(keySD.get()); } } - assert(prop == apcObj->props() + propCount); + assertx(prop == apcObj->props() + propCount); return {apcObj->getHandle(), size}; } @@ -190,7 +190,7 @@ APCObject::~APCObject() { for (auto i = uint32_t{0}; i < numProps; ++i) { if (props()[i].val) props()[i].val->unreferenceRoot(); - assert(props()[i].name->isStatic()); + assertx(props()[i].name->isStatic()); } } @@ -227,7 +227,7 @@ Variant APCObject::MakeLocalObject(const APCHandle* handle) { Object APCObject::createObject() const { auto cls = m_cls.left(); - assert(cls != nullptr); + assertx(cls != nullptr); auto obj = Object::attach( m_fast_init ? ObjectData::newInstanceNoPropInit(const_cast(cls)) @@ -261,7 +261,7 @@ Object APCObject::createObject() const { if (UNLIKELY(numProps < m_propCount)) { auto dynProps = apcProp[numProps]; - assert(dynProps->kind() == APCKind::StaticArray || + assertx(dynProps->kind() == APCKind::StaticArray || dynProps->kind() == APCKind::UncountedArray || dynProps->kind() == APCKind::SharedArray); obj->setDynPropArray(dynProps->toLocal().asCArrRef()); diff --git a/hphp/runtime/base/apc-object.h b/hphp/runtime/base/apc-object.h index 8d1e80b7a6f..511c8665ae1 100644 --- a/hphp/runtime/base/apc-object.h +++ b/hphp/runtime/base/apc-object.h @@ -57,14 +57,14 @@ struct APCObject { static void Delete(APCHandle* handle); static APCObject* fromHandle(APCHandle* handle) { - assert(handle->checkInvariants() && + assertx(handle->checkInvariants() && handle->kind() == APCKind::SharedObject); static_assert(offsetof(APCObject, m_handle) == 0, ""); return reinterpret_cast(handle); } static const APCObject* fromHandle(const APCHandle* handle) { - assert(handle->checkInvariants() && + assertx(handle->checkInvariants() && handle->kind() == APCKind::SharedObject); static_assert(offsetof(APCObject, m_handle) == 0, ""); return reinterpret_cast(handle); diff --git a/hphp/runtime/base/apc-stats.cpp b/hphp/runtime/base/apc-stats.cpp index e0d2aabdc34..32f80e45596 100644 --- a/hphp/runtime/base/apc-stats.cpp +++ b/hphp/runtime/base/apc-stats.cpp @@ -52,7 +52,7 @@ size_t getMemSize(const TypedValue* tv, bool recurse = true) { if (!isRefcountedType(type)) { return sizeof(Variant); } - assert(!"Unsupported Variant type for getMemSize()"); + assertx(!"Unsupported Variant type for getMemSize()"); return 0; } @@ -113,7 +113,7 @@ size_t getMemSize(const APCHandle* handle) { case APCKind::SharedCollection: return getMemSize(APCObject::fromHandle(handle)); } - assert(!"Unsupported APCHandle Type in getMemSize"); + assertx(!"Unsupported APCHandle Type in getMemSize"); return 0; } @@ -210,7 +210,7 @@ size_t getMemSize(const ArrayData* arr, bool recurse) { case ArrayData::ArrayKind::kEmptyKind: return sizeof(ArrayData); default: - assert(!"Unsupported Array type in getMemSize"); + assertx(!"Unsupported Array type in getMemSize"); } return 0; } diff --git a/hphp/runtime/base/apc-stats.h b/hphp/runtime/base/apc-stats.h index 01bdd6d91fb..70e3ff88b89 100644 --- a/hphp/runtime/base/apc-stats.h +++ b/hphp/runtime/base/apc-stats.h @@ -173,21 +173,21 @@ struct APCStats { // A new key is added. Value is added through addAPCValue() void addKey(size_t len) { - assert(len > 0); + assertx(len > 0); m_entries->increment(); m_keySize->addValue(len); } // A key is removed. Value is removed through removeAPCValue() void removeKey(size_t len) { - assert(len > 0); + assertx(len > 0); m_entries->decrement(); m_keySize->addValue(-len); } // A primed key is added. Implies a key is added as well. void addPrimedKey(size_t len) { - assert(len > 0); + assertx(len > 0); m_primedEntries->increment(); addKey(len); } @@ -195,7 +195,7 @@ struct APCStats { // A value of a certain size was added to the primed set that is mapped // to file void addInFileValue(size_t size) { - assert(size > 0); + assertx(size > 0); m_inFileSize->addValue(size); } @@ -213,7 +213,7 @@ struct APCStats { // an existing value. However the key may exists already a be a primed // mapped to file entry void addAPCValue(APCHandle* handle, size_t size, bool livePrimed) { - assert(handle && size > 0); + assertx(handle && size > 0); m_valueSize->addValue(size); if (handle->isUncounted()) { m_uncountedEntries->increment(); @@ -234,7 +234,7 @@ struct APCStats { size_t oldSize, bool livePrimed, bool expired) { - assert(handle && size > 0 && oldHandle && oldSize > 0); + assertx(handle && size > 0 && oldHandle && oldSize > 0); auto diff = size - oldSize; if (diff != 0) { m_valueSize->addValue(diff); @@ -252,7 +252,7 @@ struct APCStats { APCHandle* handle, bool livePrimed, bool expired) { - assert(size > 0); + assertx(size > 0); m_valueSize->addValue(-size); if (handle->isUncounted()) { m_uncountedEntries->decrement(); diff --git a/hphp/runtime/base/apc-string.cpp b/hphp/runtime/base/apc-string.cpp index 1d335f505f1..68bb676aeff 100644 --- a/hphp/runtime/base/apc-string.cpp +++ b/hphp/runtime/base/apc-string.cpp @@ -32,18 +32,18 @@ APCString::MakeSharedString(APCKind kind, StringData* data) { apcStr->m_str.initHeader(HeaderKind::String, UncountedValue); apcStr->m_str.m_len = len; // don't store hash - assert(apcStr == reinterpret_cast(chars) - 1); + assertx(apcStr == reinterpret_cast(chars) - 1); auto const mcret = memcpy(chars, data->data(), len + 1); apcStr = reinterpret_cast(mcret) - 1; // Recalculating apcStr from mcret avoids a spill. apcStr->m_str.preCompute(); - assert(apcStr->m_str.m_hash != 0); - assert(apcStr->m_str.data()[len] == 0); - assert(apcStr->m_str.isUncounted()); - assert(apcStr->m_str.isFlat()); - assert(apcStr->m_str.checkSane()); + assertx(apcStr->m_str.m_hash != 0); + assertx(apcStr->m_str.data()[len] == 0); + assertx(apcStr->m_str.isUncounted()); + assertx(apcStr->m_str.isFlat()); + assertx(apcStr->m_str.checkSane()); return {&apcStr->m_handle, size}; } diff --git a/hphp/runtime/base/apc-string.h b/hphp/runtime/base/apc-string.h index 7550111d1d1..0a6c634c085 100644 --- a/hphp/runtime/base/apc-string.h +++ b/hphp/runtime/base/apc-string.h @@ -61,8 +61,8 @@ struct APCString { } static APCString* fromHandle(APCHandle* handle) { - assert(handle->checkInvariants()); - assert(handle->kind() == APCKind::SharedString || + assertx(handle->checkInvariants()); + assertx(handle->kind() == APCKind::SharedString || handle->kind() == APCKind::SerializedArray || handle->kind() == APCKind::SerializedVec || handle->kind() == APCKind::SerializedDict || @@ -76,8 +76,8 @@ struct APCString { } static const APCString* fromHandle(const APCHandle* handle) { - assert(handle->checkInvariants()); - assert(handle->kind() == APCKind::SharedString || + assertx(handle->checkInvariants()); + assertx(handle->kind() == APCKind::SharedString || handle->kind() == APCKind::SerializedArray || handle->kind() == APCKind::SerializedVec || handle->kind() == APCKind::SerializedDict || diff --git a/hphp/runtime/base/apc-typed-value.cpp b/hphp/runtime/base/apc-typed-value.cpp index 221998d74e7..9d675f5b89e 100644 --- a/hphp/runtime/base/apc-typed-value.cpp +++ b/hphp/runtime/base/apc-typed-value.cpp @@ -43,46 +43,46 @@ APCTypedValue* APCTypedValue::tvFalse() { } bool APCTypedValue::checkInvariants() const { - assert(m_handle.checkInvariants()); + assertx(m_handle.checkInvariants()); switch (m_handle.kind()) { case APCKind::Uninit: - case APCKind::Null: assert(m_data.num == 0); break; + case APCKind::Null: assertx(m_data.num == 0); break; case APCKind::Bool: case APCKind::Int: case APCKind::Double: break; - case APCKind::StaticString: assert(m_data.str->isStatic()); break; - case APCKind::UncountedString: assert(m_data.str->isUncounted()); break; + case APCKind::StaticString: assertx(m_data.str->isStatic()); break; + case APCKind::UncountedString: assertx(m_data.str->isUncounted()); break; case APCKind::StaticArray: - assert(m_data.arr->isPHPArray()); - assert(m_data.arr->isStatic()); + assertx(m_data.arr->isPHPArray()); + assertx(m_data.arr->isStatic()); break; case APCKind::StaticVec: - assert(m_data.vec->isVecArray()); - assert(m_data.vec->isStatic()); + assertx(m_data.vec->isVecArray()); + assertx(m_data.vec->isStatic()); break; case APCKind::StaticDict: - assert(m_data.dict->isDict()); - assert(m_data.dict->isStatic()); + assertx(m_data.dict->isDict()); + assertx(m_data.dict->isStatic()); break; case APCKind::StaticKeyset: - assert(m_data.keyset->isKeyset()); - assert(m_data.keyset->isStatic()); + assertx(m_data.keyset->isKeyset()); + assertx(m_data.keyset->isStatic()); break; case APCKind::UncountedArray: - assert(m_data.arr->isPHPArray()); - assert(m_data.arr->isUncounted()); + assertx(m_data.arr->isPHPArray()); + assertx(m_data.arr->isUncounted()); break; case APCKind::UncountedVec: - assert(m_data.vec->isVecArray()); - assert(m_data.vec->isUncounted()); + assertx(m_data.vec->isVecArray()); + assertx(m_data.vec->isUncounted()); break; case APCKind::UncountedDict: - assert(m_data.dict->isDict()); - assert(m_data.dict->isUncounted()); + assertx(m_data.dict->isDict()); + assertx(m_data.dict->isUncounted()); break; case APCKind::UncountedKeyset: - assert(m_data.keyset->isKeyset()); - assert(m_data.keyset->isUncounted()); + assertx(m_data.keyset->isKeyset()); + assertx(m_data.keyset->isUncounted()); break; case APCKind::SharedString: case APCKind::SharedArray: @@ -99,7 +99,7 @@ bool APCTypedValue::checkInvariants() const { case APCKind::SerializedVec: case APCKind::SerializedDict: case APCKind::SerializedKeyset: - assert(false); + assertx(false); break; } return true; @@ -108,9 +108,9 @@ bool APCTypedValue::checkInvariants() const { ////////////////////////////////////////////////////////////////////// void APCTypedValue::deleteUncounted() { - assert(m_handle.isUncounted()); + assertx(m_handle.isUncounted()); auto kind = m_handle.kind(); - assert(kind == APCKind::UncountedString || + assertx(kind == APCKind::UncountedString || kind == APCKind::UncountedArray || kind == APCKind::UncountedVec || kind == APCKind::UncountedDict || @@ -127,7 +127,7 @@ void APCTypedValue::deleteUncounted() { auto const arr = [&] { if (kind == APCKind::UncountedArray) { auto const parr = m_data.arr; - assert(parr->isPHPArray()); + assertx(parr->isPHPArray()); if (parr->hasPackedLayout()) { PackedArray::ReleaseUncounted(parr); } else { @@ -137,19 +137,19 @@ void APCTypedValue::deleteUncounted() { } if (kind == APCKind::UncountedVec) { auto const vec = m_data.vec; - assert(vec->isVecArray()); + assertx(vec->isVecArray()); PackedArray::ReleaseUncounted(vec); return vec; } if (kind == APCKind::UncountedDict) { auto const dict = m_data.dict; - assert(dict->isDict()); + assertx(dict->isDict()); MixedArray::ReleaseUncounted(dict); return dict; } assertx(kind == APCKind::UncountedKeyset); auto const keyset = m_data.keyset; - assert(keyset->isKeyset()); + assertx(keyset->isKeyset()); SetArray::ReleaseUncounted(keyset); return keyset; }(); diff --git a/hphp/runtime/base/array-common.cpp b/hphp/runtime/base/array-common.cpp index 1429510e0ba..13900470952 100644 --- a/hphp/runtime/base/array-common.cpp +++ b/hphp/runtime/base/array-common.cpp @@ -35,15 +35,15 @@ ssize_t ArrayCommon::ReturnInvalidIndex(const ArrayData*) { } bool ArrayCommon::ValidMArrayIter(const ArrayData* ad, const MArrayIter& fp) { - assert(fp.getContainer() == ad); + assertx(fp.getContainer() == ad); if (fp.getResetFlag()) return false; if (ad->hasPackedLayout()) { - assert(PackedArray::checkInvariants(ad)); + assertx(PackedArray::checkInvariants(ad)); return fp.m_pos != ad->getSize(); } else if (ad->isKeyset()) { return false; } else { - assert(MixedArray::asMixed(ad)); + assertx(MixedArray::asMixed(ad)); return fp.m_pos != MixedArray::asMixed(ad)->iterLimit(); } } diff --git a/hphp/runtime/base/array-data-defs.h b/hphp/runtime/base/array-data-defs.h index d20fcca80e0..6aa9c8ea751 100644 --- a/hphp/runtime/base/array-data-defs.h +++ b/hphp/runtime/base/array-data-defs.h @@ -64,7 +64,7 @@ inline ArrayData* ArrayData::copy() const { inline ArrayData* ArrayData::copyStatic() const { auto ret = g_array_funcs.copyStatic[kind()](this); - assert(ret != this && ret->isStatic()); + assertx(ret != this && ret->isStatic()); return ret; } @@ -101,7 +101,7 @@ inline bool ArrayData::isVectorData() const { } inline void ArrayData::release() noexcept { - assert(hasExactlyOneRef()); + assertx(hasExactlyOneRef()); g_array_funcs.release[kind()](this); AARCH64_WALKABLE_FRAME(); } @@ -335,17 +335,17 @@ inline void ArrayData::renumber() { namespace detail { inline bool isIntKey(Cell cell) { - assert(isIntType(cell.m_type) || isStringType(cell.m_type)); + assertx(isIntType(cell.m_type) || isStringType(cell.m_type)); return isIntType(cell.m_type); } inline int64_t getIntKey(Cell cell) { - assert(isIntType(cell.m_type)); + assertx(isIntType(cell.m_type)); return cell.m_data.num; } inline StringData* getStringKey(Cell cell) { - assert(isStringType(cell.m_type)); + assertx(isStringType(cell.m_type)); return cell.m_data.pstr; } @@ -355,19 +355,19 @@ inline StringData* getStringKey(Cell cell) { // Element manipulation. inline bool ArrayData::exists(Cell k) const { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return detail::isIntKey(k) ? exists(detail::getIntKey(k)) : exists(detail::getStringKey(k)); } inline member_lval ArrayData::lval(Cell k, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return detail::isIntKey(k) ? lval(detail::getIntKey(k), copy) : lval(detail::getStringKey(k), copy); } inline member_lval ArrayData::lvalRef(Cell k, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return detail::isIntKey(k) ? lvalRef(detail::getIntKey(k), copy) : lvalRef(detail::getStringKey(k), copy); } @@ -383,7 +383,7 @@ inline member_rval ArrayData::get(const StringData* k, bool error) const { } inline member_rval ArrayData::get(Cell k, bool error) const { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return detail::isIntKey(k) ? get(detail::getIntKey(k), error) : get(detail::getStringKey(k), error); } @@ -419,7 +419,7 @@ inline ArrayData* ArrayData::setWithRef(Cell k, TypedValue v, bool copy) { } inline ArrayData* ArrayData::setRef(Cell k, member_lval v, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return detail::isIntKey(k) ? setRef(detail::getIntKey(k), v, copy) : setRef(detail::getStringKey(k), v, copy); } @@ -446,7 +446,7 @@ inline ArrayData* ArrayData::add(Cell k, Cell v, bool copy) { } inline ArrayData* ArrayData::remove(Cell k, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return detail::isIntKey(k) ? remove(detail::getIntKey(k), copy) : remove(detail::getStringKey(k), copy); } @@ -454,7 +454,7 @@ inline ArrayData* ArrayData::remove(Cell k, bool copy) { /////////////////////////////////////////////////////////////////////////////// inline bool ArrayData::exists(const String& k) const { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return exists(k.get()); } @@ -463,7 +463,7 @@ inline bool ArrayData::exists(const Variant& k) const { } inline member_lval ArrayData::lval(const String& k, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return lval(k.get(), copy); } @@ -472,7 +472,7 @@ inline member_lval ArrayData::lval(const Variant& k, bool copy) { } inline member_lval ArrayData::lvalRef(const String& k, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return lvalRef(k.get(), copy); } @@ -481,7 +481,7 @@ inline member_lval ArrayData::lvalRef(const Variant& k, bool copy) { } inline member_rval ArrayData::get(const String& k, bool error) const { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return get(k.get(), error); } @@ -514,7 +514,7 @@ inline ArrayData* ArrayData::setWithRef(const String& k, inline ArrayData* ArrayData::setRef(const String& k, member_lval v, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return setRef(k.get(), v, copy); } @@ -533,7 +533,7 @@ inline ArrayData* ArrayData::setRef(const Variant& k, Variant& v, bool copy) { inline ArrayData* ArrayData::add(const String& k, Cell v, bool copy) { assertx(cellIsPlausible(v)); - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return add(k.get(), v, copy); } @@ -548,7 +548,7 @@ inline ArrayData* ArrayData::add(const Variant& k, const Variant& v, } inline ArrayData* ArrayData::remove(const String& k, bool copy) { - assert(IsValidKey(k)); + assertx(IsValidKey(k)); return remove(k.get(), copy); } diff --git a/hphp/runtime/base/array-data-inl.h b/hphp/runtime/base/array-data-inl.h index 906fa5a2734..5f60c532a16 100644 --- a/hphp/runtime/base/array-data-inl.h +++ b/hphp/runtime/base/array-data-inl.h @@ -30,10 +30,10 @@ inline ArrayData::ArrayData(ArrayKind kind, RefCount initial_count) : m_sizeAndPos(uint32_t(-1)) { initHeader(static_cast(kind), initial_count); - assert(m_size == -1); - assert(m_pos == 0); - assert(m_kind == static_cast(kind)); - assert(dvArraySanityCheck()); + assertx(m_size == -1); + assertx(m_pos == 0); + assertx(m_kind == static_cast(kind)); + assertx(dvArraySanityCheck()); } /////////////////////////////////////////////////////////////////////////////// @@ -98,7 +98,7 @@ ALWAYS_INLINE ArrayData* ArrayData::CreateKeyset() { } ALWAYS_INLINE void ArrayData::decRefAndRelease() { - assert(kindIsValid()); + assertx(kindIsValid()); if (decReleaseCheck()) release(); } @@ -130,7 +130,7 @@ inline bool ArrayData::kindIsValid() const { } inline ArrayData::ArrayKind ArrayData::kind() const { - assert(kindIsValid()); + assertx(kindIsValid()); return static_cast(m_kind); } @@ -207,7 +207,7 @@ inline DataType ArrayData::toDataType() const { if (k < kDictKind) return KindOfArray; if (k == kVecKind) return KindOfVec; if (k == kDictKind) return KindOfDict; - assert(k == kKeysetKind); + assertx(k == kKeysetKind); return KindOfKeyset; } @@ -216,7 +216,7 @@ inline DataType ArrayData::toPersistentDataType() const { if (k < kDictKind) return KindOfPersistentArray; if (k == kVecKind) return KindOfPersistentVec; if (k == kDictKind) return KindOfPersistentDict; - assert(k == kKeysetKind); + assertx(k == kKeysetKind); return KindOfPersistentKeyset; } @@ -228,7 +228,7 @@ inline int32_t ArrayData::getPosition() const { } inline void ArrayData::setPosition(int32_t p) { - assert(m_pos == p || !isStatic()); + assertx(m_pos == p || !isStatic()); m_pos = p; } diff --git a/hphp/runtime/base/array-data.cpp b/hphp/runtime/base/array-data.cpp index f68780bce97..2cde19c7c24 100644 --- a/hphp/runtime/base/array-data.cpp +++ b/hphp/runtime/base/array-data.cpp @@ -202,7 +202,7 @@ void ArrayData::GetScalarArray(ArrayData** parr) { } else { ad = arr->copyStatic(); } - assert(ad->isStatic()); + assertx(ad->isStatic()); s_cachedHash.first = ad; assertx(ScalarHash{}.raw_hash(ad) == s_cachedHash.second); auto const DEBUG_ONLY inserted = s_arrayDataMap.insert(ad).second; @@ -877,8 +877,8 @@ ArrayData* ArrayData::CreateRef(TypedValue name, Variant& value) { ALWAYS_INLINE bool ArrayData::EqualHelper(const ArrayData* ad1, const ArrayData* ad2, bool strict) { - assert(ad1->isPHPArray()); - assert(ad2->isPHPArray()); + assertx(ad1->isPHPArray()); + assertx(ad2->isPHPArray()); if (ad1 == ad2) return true; @@ -894,7 +894,7 @@ bool ArrayData::EqualHelper(const ArrayData* ad1, const ArrayData* ad2, if (strict) { for (ArrayIter iter1{ad1}, iter2{ad2}; iter1; ++iter1, ++iter2) { - assert(iter2); + assertx(iter2); if (!same(iter1.first(), iter2.first()) || !tvSame(iter1.secondVal(), iter2.secondVal())) { return false; @@ -919,8 +919,8 @@ bool ArrayData::EqualHelper(const ArrayData* ad1, const ArrayData* ad2, ALWAYS_INLINE int64_t ArrayData::CompareHelper(const ArrayData* ad1, const ArrayData* ad2) { - assert(ad1->isPHPArray()); - assert(ad2->isPHPArray()); + assertx(ad1->isPHPArray()); + assertx(ad2->isPHPArray()); if (UNLIKELY(RuntimeOption::EvalHackArrCompatDVCmpNotices && !ArrayData::dvArrayEqual(ad1, ad2))) { @@ -992,7 +992,7 @@ int64_t ArrayData::Compare(const ArrayData* ad1, const ArrayData* ad2) { } int ArrayData::compare(const ArrayData* v2) const { - assert(v2); + assertx(v2); if (isPHPArray()) { if (UNLIKELY(!v2->isPHPArray())) { @@ -1028,7 +1028,7 @@ int ArrayData::compare(const ArrayData* v2) const { } bool ArrayData::equal(const ArrayData* v2, bool strict) const { - assert(v2); + assertx(v2); auto const mixed = [&]{ if (UNLIKELY(checkHACCompare() && v2->isHackArray())) { diff --git a/hphp/runtime/base/array-init.cpp b/hphp/runtime/base/array-init.cpp index 9a6ed01932e..14172904821 100644 --- a/hphp/runtime/base/array-init.cpp +++ b/hphp/runtime/base/array-init.cpp @@ -35,7 +35,7 @@ DictInit::DictInit(size_t n, CheckAllocation) check_non_safepoint_surprise(); } m_arr = MixedArray::MakeReserveDict(n); - assert(m_arr->hasExactlyOneRef()); + assertx(m_arr->hasExactlyOneRef()); check_non_safepoint_surprise(); } @@ -53,7 +53,7 @@ KeysetInit::KeysetInit(size_t n, CheckAllocation) check_non_safepoint_surprise(); } m_arr = SetArray::MakeReserveSet(n); - assert(m_arr->hasExactlyOneRef()); + assertx(m_arr->hasExactlyOneRef()); check_non_safepoint_surprise(); } @@ -77,7 +77,7 @@ DArrayInit::DArrayInit(size_t n, CheckAllocation) m_arr = RuntimeOption::EvalHackArrDVArrs ? MixedArray::MakeReserveDict(n) : MixedArray::MakeReserveDArray(n); - assert(m_arr->hasExactlyOneRef()); + assertx(m_arr->hasExactlyOneRef()); check_non_safepoint_surprise(); } diff --git a/hphp/runtime/base/array-init.h b/hphp/runtime/base/array-init.h index 2411c7c3d17..416db8b0c0e 100644 --- a/hphp/runtime/base/array-init.h +++ b/hphp/runtime/base/array-init.h @@ -58,7 +58,7 @@ struct ArrayInitBase { , m_expectedCount(n) #endif { - assert(m_arr->hasExactlyOneRef()); + assertx(m_arr->hasExactlyOneRef()); } ArrayInitBase(ArrayInitBase&& other) noexcept @@ -68,7 +68,7 @@ struct ArrayInitBase { , m_expectedCount(other.m_expectedCount) #endif { - assert(!m_arr || m_arr->toDataType() == DT); + assertx(!m_arr || m_arr->toDataType() == DT); other.m_arr = nullptr; #ifdef DEBUG other.m_expectedCount = 0; @@ -80,7 +80,7 @@ struct ArrayInitBase { ~ArrayInitBase() { // In case an exception interrupts the initialization. - assert(!m_arr || (m_arr->hasExactlyOneRef() && + assertx(!m_arr || (m_arr->hasExactlyOneRef() && m_arr->toDataType() == DT)); if (m_arr) TArray::Release(m_arr); } @@ -93,8 +93,8 @@ struct ArrayInitBase { */ Variant toVariant() { - assert(m_arr->hasExactlyOneRef()); - assert(m_arr->toDataType() == DT); + assertx(m_arr->hasExactlyOneRef()); + assertx(m_arr->toDataType() == DT); auto const ptr = m_arr; m_arr = nullptr; #ifdef DEBUG @@ -104,8 +104,8 @@ struct ArrayInitBase { } Array toArray() { - assert(m_arr->hasExactlyOneRef()); - assert(m_arr->toDataType() == DT); + assertx(m_arr->hasExactlyOneRef()); + assertx(m_arr->toDataType() == DT); auto const ptr = m_arr; m_arr = nullptr; #ifdef DEBUG @@ -115,8 +115,8 @@ struct ArrayInitBase { } ArrayData* create() { - assert(m_arr->hasExactlyOneRef()); - assert(m_arr->toDataType() == DT); + assertx(m_arr->hasExactlyOneRef()); + assertx(m_arr->toDataType() == DT); auto const ptr = m_arr; m_arr = nullptr; #ifdef DEBUG @@ -144,9 +144,9 @@ protected: ALWAYS_INLINE void performOp(Operation oper) { DEBUG_ONLY auto newp = oper(); // Array escalation must not happen during these reserved initializations. - assert(newp == m_arr); + assertx(newp == m_arr); // You cannot add/set more times than you reserved with ArrayInit. - assert(++m_addCount <= m_expectedCount); + assertx(++m_addCount <= m_expectedCount); } protected: @@ -544,7 +544,7 @@ struct DictInit : ArrayInitBase { DictInit& setValidKey(TypedValue name, TypedValue v) { performOp([&]{ auto const k = tvToCell(name); - assert(isIntType(k.m_type) || isStringType(k.m_type)); + assertx(isIntType(k.m_type) || isStringType(k.m_type)); return isIntType(k.m_type) ? MixedArray::SetIntDict(m_arr, k.m_data.num, tvToInitCell(v), false) @@ -579,7 +579,7 @@ struct PackedArrayInitBase : ArrayInitBase { check_non_safepoint_surprise(); } this->m_arr = TArray::MakeReserve(n); - assert(this->m_arr->hasExactlyOneRef()); + assertx(this->m_arr->hasExactlyOneRef()); check_non_safepoint_surprise(); } }; @@ -768,7 +768,7 @@ struct DArrayInit { , m_expectedCount(other.m_expectedCount) #endif { - assert(!m_arr || m_arr->isDictOrDArray()); + assertx(!m_arr || m_arr->isDictOrDArray()); other.m_arr = nullptr; #ifdef DEBUG other.m_expectedCount = 0; @@ -780,7 +780,7 @@ struct DArrayInit { ~DArrayInit() { // In case an exception interrupts the initialization. - assert(!m_arr || (m_arr->hasExactlyOneRef() && + assertx(!m_arr || (m_arr->hasExactlyOneRef() && m_arr->isDictOrDArray())); if (m_arr) m_arr->release(); } @@ -1222,7 +1222,7 @@ MixedPHPArrayInitBase::MixedPHPArrayInitBase(size_t n, check_non_safepoint_surprise(); } this->m_arr = TArray::MakeReserve(n); - assert(this->m_arr->hasExactlyOneRef()); + assertx(this->m_arr->hasExactlyOneRef()); check_non_safepoint_surprise(); } diff --git a/hphp/runtime/base/array-iterator-defs.h b/hphp/runtime/base/array-iterator-defs.h index 2e188dcf3c4..28ca874cbea 100644 --- a/hphp/runtime/base/array-iterator-defs.h +++ b/hphp/runtime/base/array-iterator-defs.h @@ -47,7 +47,7 @@ void for_each_strong_iterator_slow(MIterTable& table, Fn fn) { template void for_each_strong_iterator(Fn fn) { static_assert(MIterTable::ents_size == 7, ""); - assert(strong_iterators_exist()); + assertx(strong_iterators_exist()); auto& table = *tl_miter_table; fn(table.ents[0]); fn(table.ents[1]); diff --git a/hphp/runtime/base/array-iterator.cpp b/hphp/runtime/base/array-iterator.cpp index c606674fc57..80486c6b5d8 100644 --- a/hphp/runtime/base/array-iterator.cpp +++ b/hphp/runtime/base/array-iterator.cpp @@ -86,7 +86,7 @@ ArrayIter::ArrayIter(const ArrayIter& iter) { if (ad) const_cast(ad)->incRefCount(); } else { ObjectData* obj = getObject(); - assert(obj); + assertx(obj); obj->incRefCount(); } } @@ -101,7 +101,7 @@ void ArrayIter::arrInit(const ArrayData* arr) { template void ArrayIter::objInit(ObjectData* obj) { - assert(obj); + assertx(obj); if (LIKELY(obj->isCollection())) { if (auto ad = collections::asArray(obj)) { @@ -140,7 +140,7 @@ void ArrayIter::objInit(ObjectData* obj) { } void ArrayIter::cellInit(const Cell c) { - assert(cellIsPlausible(c)); + assertx(cellIsPlausible(c)); if (LIKELY(isArrayLikeType(c.m_type))) { arrInit(c.m_data.parr); } else if (LIKELY(c.m_type == KindOfObject)) { @@ -166,7 +166,7 @@ void ArrayIter::destruct() { } ObjectData* obj = getObject(); if (debug) m_itype = TypeUndefined; - assert(obj); + assertx(obj); decRefObj(obj); } @@ -181,7 +181,7 @@ ArrayIter& ArrayIter::operator=(const ArrayIter& iter) { if (ad) const_cast(ad)->incRefCount(); } else { ObjectData* obj = getObject(); - assert(obj); + assertx(obj); obj->incRefCount(); } return *this; @@ -215,8 +215,8 @@ Variant ArrayIter::firstHelper() { Variant ArrayIter::second() { if (LIKELY(hasArrayData())) { const ArrayData* ad = getArrayData(); - assert(ad); - assert(m_pos != ad->iter_end()); + assertx(ad); + assertx(m_pos != ad->iter_end()); return ad->getValue(m_pos); } auto obj = getObject(); @@ -227,18 +227,18 @@ member_rval ArrayIter::secondRval() const { if (!hasArrayData()) { raise_fatal_error("taking reference on iterator objects"); } - assert(hasArrayData()); + assertx(hasArrayData()); const ArrayData* ad = getArrayData(); - assert(ad); - assert(m_pos != ad->iter_end()); + assertx(ad); + assertx(m_pos != ad->iter_end()); return ad->rvalPos(m_pos); } member_rval ArrayIter::secondRvalPlus() { if (LIKELY(hasArrayData())) { const ArrayData* ad = getArrayData(); - assert(ad); - assert(m_pos != ad->iter_end()); + assertx(ad); + assertx(m_pos != ad->iter_end()); return ad->rvalPos(m_pos); } throw_param_is_not_container(); @@ -294,18 +294,18 @@ MIterTable::Ent* find_empty_strong_iter() { } void newMArrayIter(MArrayIter* marr, ArrayData* ad) { - assert(!marr->getContainer()); + assertx(!marr->getContainer()); auto const slot = find_empty_strong_iter(); - assert(!slot->array); + assertx(!slot->array); slot->iter = marr; slot->array = ad; marr->setContainer(ad); - assert(strong_iterators_exist()); + assertx(strong_iterators_exist()); } template void free_strong_iterator_impl(Cond cond) { - assert(strong_iterators_exist()); + assertx(strong_iterators_exist()); // We need to maintain the invariant that if there are any strong // iterators bound to arrays, one of the bindings is in slot zero. @@ -368,7 +368,7 @@ void free_strong_iterator_impl(Cond cond) { } void freeMArrayIter(MArrayIter* marr) { - assert(strong_iterators_exist()); + assertx(strong_iterators_exist()); free_strong_iterator_impl( [marr] (const MIterTable::Ent& e) { return e.iter == marr; @@ -402,14 +402,14 @@ MArrayIter::MArrayIter(RefData* ref) { ref->incRefCount(); setRef(ref); - assert(hasRef()); + assertx(hasRef()); escalateCheck(); auto const data = cowCheck(); - assert(data); + assertx(data); data->reset(); data->next(); newMArrayIter(this, data); - assert(getContainer() == data); + assertx(getContainer() == data); } MArrayIter::MArrayIter(ArrayData* data) @@ -419,20 +419,20 @@ MArrayIter::MArrayIter(ArrayData* data) { // this constructor is only used for object iteration, so we always get in a // mixed array with refcount 1 - assert(data); - assert(data->isMixed() && data->hasExactlyOneRef()); + assertx(data); + assertx(data->isMixed() && data->hasExactlyOneRef()); setAd(data); data->reset(); data->next(); newMArrayIter(this, data); - assert(getContainer() == data); + assertx(getContainer() == data); } MArrayIter::~MArrayIter() { auto const container = getContainer(); if (container) { freeMArrayIter(this); - assert(getContainer() == nullptr); + assertx(getContainer() == nullptr); } if (hasRef()) { decRefRef(getRef()); @@ -463,8 +463,8 @@ bool MArrayIter::advance() { return cowCheck()->advanceMArrayIter(*this); } data = reregister(); - assert(data && data == getContainer()); - assert(!getResetFlag()); + assertx(data && data == getContainer()); + assertx(!getResetFlag()); if (!data->validMArrayIter(*this)) return false; // To conform to PHP behavior, we need to set the internal // cursor to point to the next element. @@ -493,7 +493,7 @@ bool MArrayIter::prepare() { } void MArrayIter::escalateCheck() { - assert(hasRef()); + assertx(hasRef()); auto const data = getData(); if (!data) return; auto const esc = data->escalate(); @@ -503,7 +503,7 @@ void MArrayIter::escalateCheck() { } ArrayData* MArrayIter::cowCheck() { - assert(hasRef()); + assertx(hasRef()); auto data = getData(); if (!data) return nullptr; if (!data->cowCheck() || data->noCopyOnWrite()) return data; @@ -519,13 +519,13 @@ ArrayData* MArrayIter::cowCheck() { } ArrayData* MArrayIter::reregister() { - assert(hasRef()); + assertx(hasRef()); ArrayData* container = getContainer(); - assert(getData() != nullptr && container != getData()); + assertx(getData() != nullptr && container != getData()); if (container != nullptr) { freeMArrayIter(this); } - assert(getContainer() == nullptr); + assertx(getContainer() == nullptr); setResetFlag(false); escalateCheck(); ArrayData* data = cowCheck(); @@ -544,7 +544,7 @@ CufIter::~CufIter() { } bool Iter::init(TypedValue* c1) { - assert(c1->m_type != KindOfRef); + assertx(c1->m_type != KindOfRef); bool hasElems = true; if (isArrayLikeType(c1->m_type)) { if (!c1->m_data.parr->empty()) { @@ -592,7 +592,7 @@ bool Iter::init(TypedValue* c1) { } bool Iter::next() { - assert(arr().getIterType() == ArrayIter::TypeArray || + assertx(arr().getIterType() == ArrayIter::TypeArray || arr().getIterType() == ArrayIter::TypeIterator); // The emitter should never generate bytecode where the iterator // is at the end before IterNext is executed. However, even if @@ -612,7 +612,7 @@ bool Iter::next() { } void Iter::free() { - assert(arr().getIterType() == ArrayIter::TypeArray || + assertx(arr().getIterType() == ArrayIter::TypeArray || arr().getIterType() == ArrayIter::TypeIterator); arr().~ArrayIter(); } @@ -634,10 +634,10 @@ void Iter::cfree() { template static inline void iter_value_cell_local_impl(Iter* iter, TypedValue* out) { auto const oldVal = *out; - assert(withRef || oldVal.m_type != KindOfRef); + assertx(withRef || oldVal.m_type != KindOfRef); TRACE(2, "%s: typeArray: %s, I %p, out %p\n", __func__, typeArray ? "true" : "false", iter, out); - assert((typeArray && iter->arr().getIterType() == ArrayIter::TypeArray) || + assertx((typeArray && iter->arr().getIterType() == ArrayIter::TypeArray) || (!typeArray && iter->arr().getIterType() == ArrayIter::TypeIterator)); ArrayIter& arrIter = iter->arr(); if (typeArray) { @@ -653,7 +653,7 @@ static inline void iter_value_cell_local_impl(Iter* iter, TypedValue* out) { } } else { Variant val = arrIter.second(); - assert(val.getRawType() != KindOfRef); + assertx(val.getRawType() != KindOfRef); cellDup(*val.asTypedValue(), *out); } tvDecRefGen(oldVal); @@ -662,9 +662,9 @@ static inline void iter_value_cell_local_impl(Iter* iter, TypedValue* out) { template static inline void iter_key_cell_local_impl(Iter* iter, TypedValue* out) { auto const oldVal = *out; - assert(withRef || oldVal.m_type != KindOfRef); + assertx(withRef || oldVal.m_type != KindOfRef); TRACE(2, "%s: I %p, out %p\n", __func__, iter, out); - assert((typeArray && iter->arr().getIterType() == ArrayIter::TypeArray) || + assertx((typeArray && iter->arr().getIterType() == ArrayIter::TypeArray) || (!typeArray && iter->arr().getIterType() == ArrayIter::TypeIterator)); ArrayIter& arr = iter->arr(); if (typeArray) { @@ -678,8 +678,8 @@ static inline void iter_key_cell_local_impl(Iter* iter, TypedValue* out) { static NEVER_INLINE int64_t iter_next_free_packed(Iter* iter, ArrayData* arr) { - assert(arr->decWillRelease()); - assert(arr->hasPackedLayout()); + assertx(arr->decWillRelease()); + assertx(arr->hasPackedLayout()); // Use non-specialized release call so ArrayTracer can track its destruction arr->release(); if (debug) { @@ -690,8 +690,8 @@ int64_t iter_next_free_packed(Iter* iter, ArrayData* arr) { static NEVER_INLINE int64_t iter_next_free_mixed(Iter* iter, ArrayData* arr) { - assert(arr->hasMixedLayout()); - assert(arr->decWillRelease()); + assertx(arr->hasMixedLayout()); + assertx(arr->decWillRelease()); // Use non-specialized release call so ArrayTracer can track its destruction arr->release(); if (debug) { @@ -702,7 +702,7 @@ int64_t iter_next_free_mixed(Iter* iter, ArrayData* arr) { NEVER_INLINE static int64_t iter_next_free_apc(Iter* iter, APCLocalArray* arr) { - assert(arr->decWillRelease()); + assertx(arr->decWillRelease()); APCLocalArray::Release(arr->asArrayData()); if (debug) { iter->arr().setIterType(ArrayIter::TypeUndefined); @@ -766,8 +766,8 @@ int64_t new_iter_array(Iter* dest, ArrayData* ad, TypedValue* valOut) { aiter.m_pos = 0; aiter.m_itypeAndNextHelperIdx = static_cast(IterNextIndex::ArrayPacked) << 16 | itypeU32; - assert(aiter.m_itype == ArrayIter::TypeArray); - assert(aiter.m_nextHelperIdx == IterNextIndex::ArrayPacked); + assertx(aiter.m_itype == ArrayIter::TypeArray); + assertx(aiter.m_nextHelperIdx == IterNextIndex::ArrayPacked); cellDup(*tvToCell(packedData(ad)), *valOut); return 1; } @@ -777,8 +777,8 @@ int64_t new_iter_array(Iter* dest, ArrayData* ad, TypedValue* valOut) { aiter.m_pos = mixed->getIterBeginNotEmpty(); aiter.m_itypeAndNextHelperIdx = static_cast(IterNextIndex::ArrayMixed) << 16 | itypeU32; - assert(aiter.m_itype == ArrayIter::TypeArray); - assert(aiter.m_nextHelperIdx == IterNextIndex::ArrayMixed); + assertx(aiter.m_itype == ArrayIter::TypeArray); + assertx(aiter.m_nextHelperIdx == IterNextIndex::ArrayMixed); mixed->getArrayElm(aiter.m_pos, valOut); return 1; } @@ -816,8 +816,8 @@ int64_t new_iter_array_key(Iter* dest, aiter.m_pos = 0; aiter.m_itypeAndNextHelperIdx = static_cast(IterNextIndex::ArrayPacked) << 16 | itypeU32; - assert(aiter.m_itype == ArrayIter::TypeArray); - assert(aiter.m_nextHelperIdx == IterNextIndex::ArrayPacked); + assertx(aiter.m_itype == ArrayIter::TypeArray); + assertx(aiter.m_nextHelperIdx == IterNextIndex::ArrayPacked); if (WithRef) { tvDupWithRef(*packedData(ad), *valOut); } else { @@ -833,8 +833,8 @@ int64_t new_iter_array_key(Iter* dest, aiter.m_pos = mixed->getIterBeginNotEmpty(); aiter.m_itypeAndNextHelperIdx = static_cast(IterNextIndex::ArrayMixed) << 16 | itypeU32; - assert(aiter.m_itype == ArrayIter::TypeArray); - assert(aiter.m_nextHelperIdx == IterNextIndex::ArrayMixed); + assertx(aiter.m_itype == ArrayIter::TypeArray); + assertx(aiter.m_nextHelperIdx == IterNextIndex::ArrayMixed); if (WithRef) { mixed->dupArrayElmWithRef(aiter.m_pos, valOut, keyOut); } else { @@ -965,7 +965,7 @@ template NEVER_INLINE int64_t iter_next_cold(Iter* iter, TypedValue* valOut, TypedValue* keyOut) { auto const ai = &iter->arr(); - assert(ai->getIterType() == ArrayIter::TypeArray || + assertx(ai->getIterType() == ArrayIter::TypeArray || ai->getIterType() == ArrayIter::TypeIterator); assertx(ai->hasArrayData() || !ai->getObject()->isCollection()); ai->next(); @@ -993,7 +993,7 @@ static int64_t iter_next_apc_array(Iter* iter, TypedValue* valOut, TypedValue* keyOut, ArrayData* ad) { - assert(ad->kind() == ArrayData::kApcKind); + assertx(ad->kind() == ArrayData::kApcKind); auto const arrIter = &iter->arr(); auto const arr = APCLocalArray::asApcArray(ad); @@ -1012,7 +1012,7 @@ static int64_t iter_next_apc_array(Iter* iter, // Note that APCLocalArray can never return KindOfRefs. auto const rval = APCLocalArray::RvalAtPos(arr->asArrayData(), pos); - assert(rval.type() != KindOfRef); + assertx(rval.type() != KindOfRef); cellSet(rval.tv(), *valOut); if (LIKELY(!keyOut)) return 1; @@ -1026,7 +1026,7 @@ static int64_t iter_next_apc_array(Iter* iter, int64_t witer_next_key(Iter* iter, TypedValue* valOut, TypedValue* keyOut) { TRACE(2, "iter_next_key: I %p\n", iter); - assert(iter->arr().getIterType() == ArrayIter::TypeArray || + assertx(iter->arr().getIterType() == ArrayIter::TypeArray || iter->arr().getIterType() == ArrayIter::TypeIterator); auto const arrIter = &iter->arr(); if (UNLIKELY(!arrIter->hasArrayData())) { @@ -1114,7 +1114,7 @@ int64_t new_miter_array_key(Iter* dest, RefData* v1, TRACE(2, "%s: I %p, ad %p\n", __func__, dest, v1); TypedValue* rtv = v1->tv(); - assert(isArrayLikeType(rtv->m_type)); + assertx(isArrayLikeType(rtv->m_type)); ArrayData* ad = rtv->m_data.parr; if (UNLIKELY(ad->isHackArray())) { @@ -1265,12 +1265,12 @@ template int64_t iter_next_packed_impl(Iter* it, TypedValue* valOut, TypedValue* keyOut) { - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData() && it->arr().getArrayData()->hasPackedLayout()); auto& iter = it->arr(); auto const ad = const_cast(iter.getArrayData()); - assert(PackedArray::checkInvariants(ad)); + assertx(PackedArray::checkInvariants(ad)); ssize_t pos = iter.getPos() + 1; if (LIKELY(pos < ad->getSize())) { @@ -1310,7 +1310,7 @@ int64_t iter_next_packed_impl(Iter* it, int64_t iterNextArrayPacked(Iter* it, TypedValue* valOut) { TRACE(2, "iterNextArrayPacked: I %p\n", it); - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData() && it->arr().getArrayData()->hasPackedLayout()); return iter_next_packed_impl(it, valOut, nullptr); @@ -1320,7 +1320,7 @@ int64_t iterNextKArrayPacked(Iter* it, TypedValue* valOut, TypedValue* keyOut) { TRACE(2, "iterNextKArrayPacked: I %p\n", it); - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData() && it->arr().getArrayData()->hasPackedLayout()); return iter_next_packed_impl(it, valOut, keyOut); @@ -1328,7 +1328,7 @@ int64_t iterNextKArrayPacked(Iter* it, int64_t iterNextArrayMixed(Iter* it, TypedValue* valOut) { TRACE(2, "iterNextArrayMixed: I %p\n", it); - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData() && it->arr().getArrayData()->hasMixedLayout()); return iter_next_mixed_impl(it, valOut, nullptr); @@ -1338,7 +1338,7 @@ int64_t iterNextKArrayMixed(Iter* it, TypedValue* valOut, TypedValue* keyOut) { TRACE(2, "iterNextKArrayMixed: I %p\n", it); - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData() && it->arr().getArrayData()->hasMixedLayout()); return iter_next_mixed_impl(it, valOut, keyOut); @@ -1346,10 +1346,10 @@ int64_t iterNextKArrayMixed(Iter* it, int64_t iterNextArray(Iter* it, TypedValue* valOut) { TRACE(2, "iterNextArray: I %p\n", it); - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData()); - assert(!it->arr().getArrayData()->hasPackedLayout()); - assert(!it->arr().getArrayData()->hasMixedLayout()); + assertx(!it->arr().getArrayData()->hasPackedLayout()); + assertx(!it->arr().getArrayData()->hasMixedLayout()); ArrayIter& iter = it->arr(); auto const ad = const_cast(iter.getArrayData()); @@ -1363,10 +1363,10 @@ int64_t iterNextKArray(Iter* it, TypedValue* valOut, TypedValue* keyOut) { TRACE(2, "iterNextKArray: I %p\n", it); - assert(it->arr().getIterType() == ArrayIter::TypeArray && + assertx(it->arr().getIterType() == ArrayIter::TypeArray && it->arr().hasArrayData()); - assert(!it->arr().getArrayData()->hasMixedLayout()); - assert(!it->arr().getArrayData()->hasPackedLayout()); + assertx(!it->arr().getArrayData()->hasMixedLayout()); + assertx(!it->arr().getArrayData()->hasPackedLayout()); ArrayIter& iter = it->arr(); auto const ad = const_cast(iter.getArrayData()); @@ -1403,7 +1403,7 @@ const IterNextKHelper g_iterNextKHelpers[] = { int64_t iter_next_ind(Iter* iter, TypedValue* valOut) { TRACE(2, "iter_next_ind: I %p\n", iter); - assert(iter->arr().getIterType() == ArrayIter::TypeArray || + assertx(iter->arr().getIterType() == ArrayIter::TypeArray || iter->arr().getIterType() == ArrayIter::TypeIterator); auto const arrIter = &iter->arr(); valOut = tvToCell(valOut); @@ -1414,7 +1414,7 @@ int64_t iter_next_ind(Iter* iter, TypedValue* valOut) { int64_t iter_next_key_ind(Iter* iter, TypedValue* valOut, TypedValue* keyOut) { TRACE(2, "iter_next_key_ind: I %p\n", iter); - assert(iter->arr().getIterType() == ArrayIter::TypeArray || + assertx(iter->arr().getIterType() == ArrayIter::TypeArray || iter->arr().getIterType() == ArrayIter::TypeIterator); auto const arrIter = &iter->arr(); valOut = tvToCell(valOut); diff --git a/hphp/runtime/base/array-iterator.h b/hphp/runtime/base/array-iterator.h index 4aad220fd3f..44e69e2614c 100644 --- a/hphp/runtime/base/array-iterator.h +++ b/hphp/runtime/base/array-iterator.h @@ -132,8 +132,8 @@ struct ArrayIter { void next() { if (LIKELY(hasArrayData())) { const ArrayData* ad = getArrayData(); - assert(ad); - assert(m_pos != ad->iter_end()); + assertx(ad); + assertx(m_pos != ad->iter_end()); m_pos = ad->iter_advance(m_pos); return; } @@ -144,8 +144,8 @@ struct ArrayIter { Variant first() { if (LIKELY(hasArrayData())) { const ArrayData* ad = getArrayData(); - assert(ad); - assert(m_pos != ad->iter_end()); + assertx(ad); + assertx(m_pos != ad->iter_end()); return ad->getKey(m_pos); } return firstHelper(); @@ -154,7 +154,7 @@ struct ArrayIter { TypedValue nvFirst() { auto const ad = getArrayData(); - assert(ad && m_pos != ad->iter_end()); + assertx(ad && m_pos != ad->iter_end()); return ad->nvGetKey(m_pos); } @@ -184,7 +184,7 @@ struct ArrayIter { // Inline version of secondRef. Only for use in iterator helpers. member_rval nvSecond() const { auto const ad = getArrayData(); - assert(ad && m_pos != ad->iter_end()); + assertx(ad && m_pos != ad->iter_end()); return ad->rvalPos(m_pos); } @@ -193,7 +193,7 @@ struct ArrayIter { } const ArrayData* getArrayData() const { - assert(hasArrayData()); + assertx(hasArrayData()); return m_data; } ssize_t getPos() { @@ -220,7 +220,7 @@ struct ArrayIter { } ObjectData* getObject() const { - assert(!hasArrayData()); + assertx(!hasArrayData()); return (ObjectData*)((intptr_t)m_obj & ~1); } @@ -240,7 +240,7 @@ private: void destruct(); void setArrayData(const ArrayData* ad) { - assert((intptr_t(ad) & 1) == 0); + assertx((intptr_t(ad) & 1) == 0); m_data = ad; m_nextHelperIdx = IterNextIndex::ArrayMixed; if (ad != nullptr) { @@ -253,7 +253,7 @@ private: } void setObject(ObjectData* obj) { - assert((intptr_t(obj) & 1) == 0); + assertx((intptr_t(obj) & 1) == 0); m_obj = (ObjectData*)((intptr_t)obj | 1); m_nextHelperIdx = IterNextIndex::Object; } @@ -344,17 +344,17 @@ struct MArrayIter { */ Variant key() { ArrayData* data = getArray(); - assert(data && data == getContainer()); - assert(!getResetFlag() && data->validMArrayIter(*this)); + assertx(data && data == getContainer()); + assertx(!getResetFlag() && data->validMArrayIter(*this)); return data->getKey(m_pos); } Variant& val() { ArrayData* data = getArray(); - assert(data && data == getContainer()); - assert(!data->cowCheck() || data->noCopyOnWrite()); - assert(!getResetFlag()); - assert(data->validMArrayIter(*this)); + assertx(data && data == getContainer()); + assertx(!data->cowCheck() || data->noCopyOnWrite()); + assertx(!getResetFlag()); + assertx(data->validMArrayIter(*this)); // Normally it's not ok to modify the return value of rvalPos, // but the whole point of mutable array iteration is that this is // allowed, so this const_cast is not actually evil. @@ -387,11 +387,11 @@ struct MArrayIter { return bool(intptr_t(m_data) & 1LL); } RefData* getRef() const { - assert(hasRef()); + assertx(hasRef()); return m_ref; } ArrayData* getAd() const { - assert(hasAd()); + assertx(hasAd()); return (ArrayData*)(intptr_t(m_data) & ~1LL); } void setRef(RefData* ref) { @@ -412,7 +412,7 @@ struct MArrayIter { private: ArrayData* getData() const { - assert(hasRef()); + assertx(hasRef()); return isArrayType(m_ref->tv()->m_type) ? m_ref->tv()->m_data.parr : nullptr; @@ -639,7 +639,7 @@ bool IterateV(const TypedValue& it, ArrFn arrFn, PreCollFn preCollFn, ObjFn objFn) { - assert(it.m_type != KindOfRef); + assertx(it.m_type != KindOfRef); ArrayData* adata; if (LIKELY(isArrayLikeType(it.m_type))) { adata = it.m_data.parr; @@ -658,7 +658,7 @@ bool IterateV(const TypedValue& it, if (ArrayData::call_helper(preCollFn, odata)) return true; adata = collections::asArray(odata); if (adata) goto do_array; - assert(odata->collectionType() == CollectionType::Pair); + assertx(odata->collectionType() == CollectionType::Pair); auto tv = make_tv(0); if (!ArrayData::call_helper(arrFn, *collections::at(odata, &tv))) { tv.m_data.num = 1; @@ -727,7 +727,7 @@ bool IterateKV(const TypedValue& it, ArrFn arrFn, PreCollFn preCollFn, ObjFn objFn) { - assert(it.m_type != KindOfRef); + assertx(it.m_type != KindOfRef); ArrayData* adata; if (LIKELY(isArrayLikeType(it.m_type))) { adata = it.m_data.parr; @@ -746,7 +746,7 @@ bool IterateKV(const TypedValue& it, if (ArrayData::call_helper(preCollFn, odata)) return true; adata = collections::asArray(odata); if (adata) goto do_array; - assert(odata->collectionType() == CollectionType::Pair); + assertx(odata->collectionType() == CollectionType::Pair); auto tv = make_tv(0); if (!ArrayData::call_helper(arrFn, tv, *collections::at(odata, &tv))) { tv.m_data.num = 1; diff --git a/hphp/runtime/base/array-sort.cpp b/hphp/runtime/base/array-sort.cpp index e58139fd1dd..064bd053187 100644 --- a/hphp/runtime/base/array-sort.cpp +++ b/hphp/runtime/base/array-sort.cpp @@ -42,7 +42,7 @@ template SortFlavor genericPreSort(ArrayT& arr, const AccessorT& acc, bool checkTypes) { - assert(arr.m_size > 0); + assertx(arr.m_size > 0); if (!checkTypes && arr.m_size == arr.m_used) { // No need to loop over the elements, we're done return GenericSort; @@ -83,7 +83,7 @@ SortFlavor genericPreSort(ArrayT& arr, } done: arr.m_used = start - arr.data(); - assert(arr.m_size == arr.m_used); + assertx(arr.m_size == arr.m_used); if (checkTypes) { return allStrs ? StringSort : allInts ? IntegerSort : GenericSort; } @@ -99,7 +99,7 @@ template SortFlavor SetArray::preSort(const AccessorT& acc, bool checkTypes) { auto const oldUsed UNUSED = m_used; auto flav = genericPreSort(*this, acc, checkTypes); - assert(ClearElms(data() + m_used, oldUsed - m_used)); + assertx(ClearElms(data() + m_used, oldUsed - m_used)); return flav; } @@ -109,7 +109,7 @@ SortFlavor SetArray::preSort(const AccessorT& acc, bool checkTypes) { * renumber the keys 0 thru n-1. */ void MixedArray::postSort(bool resetKeys) { // nothrow guarantee - assert(m_size > 0); + assertx(m_size > 0); auto const ht = initHash(m_scale); auto const mask = this->mask(); if (resetKeys) { @@ -135,14 +135,14 @@ void MixedArray::postSort(bool resetKeys) { // nothrow guarantee * handles rebuilding the hash. */ void SetArray::postSort() { // nothrow guarantee - assert(m_size > 0); + assertx(m_size > 0); auto const ht = initHash(m_scale); auto const mask = this->mask(); auto elms = data(); - assert(m_used == m_size); + assertx(m_used == m_size); for (uint32_t i = 0; i < m_used; ++i) { auto& elm = elms[i]; - assert(!elm.isInvalid()); + assertx(!elm.isInvalid()); *findForNewInsert(ht, mask, elm.hash()) = i; } } @@ -155,7 +155,7 @@ ArrayData* MixedArray::EscalateForSort(ArrayData* ad, SortFunction sf) { // } if (UNLIKELY(hasUserDefinedCmp(sf) || a->cowCheck())) { auto ret = a->copyMixed(); - assert(ret->hasExactlyOneRef()); + assertx(ret->hasExactlyOneRef()); return ret; } return a; @@ -165,7 +165,7 @@ ArrayData* SetArray::EscalateForSort(ArrayData* ad, SortFunction sf) { auto a = asSet(ad); if (UNLIKELY(hasUserDefinedCmp(sf) || a->cowCheck())) { auto ret = a->copySet(); - assert(ret->hasExactlyOneRef()); + assertx(ret->hasExactlyOneRef()); return ret; } return a; @@ -178,7 +178,7 @@ ArrayData* PackedArray::EscalateForSort(ArrayData* ad, SortFunction sf) { if (isSortFamily(sf)) { // sort/rsort/usort if (UNLIKELY(ad->cowCheck())) { auto ret = PackedArray::Copy(ad); - assert(ret->hasExactlyOneRef()); + assertx(ret->hasExactlyOneRef()); return ret; } return ad; @@ -186,16 +186,16 @@ ArrayData* PackedArray::EscalateForSort(ArrayData* ad, SortFunction sf) { if (ad->m_size <= 1) { if (ad->isVecArray()) { auto ret = PackedArray::ToDictVec(ad, ad->cowCheck()); - assert(ret->hasExactlyOneRef()); + assertx(ret->hasExactlyOneRef()); return ret; } return ad; } - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); auto ret = ad->isVecArray() ? PackedArray::ToDictVec(ad, ad->cowCheck()) : ToMixedCopy(ad); - assert(ret->hasExactlyOneRef()); + assertx(ret->hasExactlyOneRef()); return ret; } @@ -291,11 +291,11 @@ void SetArray::Ksort(ArrayData* ad, int sort_flags, bool ascending) { } void PackedArray::Sort(ArrayData* ad, int sort_flags, bool ascending) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); if (ad->m_size <= 1) { return; } - assert(!ad->hasMultipleRefs()); + assertx(!ad->hasMultipleRefs()); auto a = ad; if (UNLIKELY(strong_iterators_exist())) { free_strong_iterators(a); @@ -378,7 +378,7 @@ bool SetArray::Uksort(ArrayData* ad, const Variant& cmp_function) { } SortFlavor PackedArray::preSort(ArrayData* ad) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); auto const data = packedData(ad); TVAccessor acc; uint32_t sz = ad->m_size; @@ -392,11 +392,11 @@ SortFlavor PackedArray::preSort(ArrayData* ad) { } bool PackedArray::Usort(ArrayData* ad, const Variant& cmp_function) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); if (ad->m_size <= 1) { return true; } - assert(!ad->hasMultipleRefs()); + assertx(!ad->hasMultipleRefs()); if (UNLIKELY(strong_iterators_exist())) { free_strong_iterators(ad); } diff --git a/hphp/runtime/base/array-util.cpp b/hphp/runtime/base/array-util.cpp index 055531cd853..fc925f86358 100644 --- a/hphp/runtime/base/array-util.cpp +++ b/hphp/runtime/base/array-util.cpp @@ -502,12 +502,12 @@ void ArrayUtil::Walk(Variant& input, PFUNC_WALK walk_function, const void *data, bool recursive /* = false */, PointerSet *seen /* = NULL */, const Variant& userdata /* = uninit_variant */) { - assert(walk_function); + assertx(walk_function); // The Optional is just to avoid copy constructing MArrayIter. folly::Optional miter; create_miter_for_walk(miter, input); - assert(miter.hasValue()); + assertx(miter.hasValue()); Variant k; Variant v; @@ -515,7 +515,7 @@ void ArrayUtil::Walk(Variant& input, PFUNC_WALK walk_function, k = miter->key(); v.assignRef(miter->val()); if (recursive && v.isArray()) { - assert(seen); + assertx(seen); ArrayData *arr = v.getArrayData(); if (v.isReferenced()) { diff --git a/hphp/runtime/base/atomic-shared-ptr.h b/hphp/runtime/base/atomic-shared-ptr.h index e4426870398..745310ee240 100644 --- a/hphp/runtime/base/atomic-shared-ptr.h +++ b/hphp/runtime/base/atomic-shared-ptr.h @@ -127,7 +127,7 @@ struct AtomicSharedPtrImpl { protected: void overwrite_unsafe(T* ptr) { - assert(!m_px); + assertx(!m_px); m_px = ptr; } diff --git a/hphp/runtime/base/autoload-handler.cpp b/hphp/runtime/base/autoload-handler.cpp index 55d7b8986e1..25e6c38300f 100644 --- a/hphp/runtime/base/autoload-handler.cpp +++ b/hphp/runtime/base/autoload-handler.cpp @@ -78,7 +78,7 @@ Variant vm_call_user_func_cufiter(const CufIter& cufIter, obj = (ObjectData*)cufIter.ctx(); } } - assert(!obj || !cls); + assertx(!obj || !cls); if (invName) { invName->incRefCount(); } @@ -128,9 +128,9 @@ bool vm_decode_function_cufiter(const Variant& function, IMPLEMENT_REQUEST_LOCAL(AutoloadHandler, AutoloadHandler::s_instance); void AutoloadHandler::requestInit() { - assert(m_map.get() == nullptr); - assert(m_map_root.get() == nullptr); - assert(m_loading.get() == nullptr); + assertx(m_map.get() == nullptr); + assertx(m_map_root.get() == nullptr); + assertx(m_loading.get() == nullptr); m_spl_stack_inited = false; new (&m_handlers) req::deque(); m_handlers_valid = true; @@ -236,7 +236,7 @@ AutoloadHandler::loadFromMapImpl(const String& clsName, bool toLower, const T &checkExists, Variant& err) { - assert(!m_map.isNull()); + assertx(!m_map.isNull()); // Always normalize name before autoloading const String& name = normalizeNS(clsName); auto const type_map = m_map.get()->get(kind).unboxed(); @@ -404,7 +404,7 @@ bool AutoloadHandler::autoloadClassPHP5Impl(const String& className, // code below can throw SCOPE_EXIT { DEBUG_ONLY auto const l_className = m_loading.pop().toString(); - assert(l_className == className); + assertx(l_className == className); }; Array params = PackedArrayInit(1).append(className).toArray(); @@ -423,7 +423,7 @@ bool AutoloadHandler::autoloadClassPHP5Impl(const String& className, try { vm_call_user_func_cufiter(*hb.m_cufIter, params); } catch (Object& ex) { - assert(ex.instanceof(SystemLib::s_ThrowableClass)); + assertx(ex.instanceof(SystemLib::s_ThrowableClass)); if (autoloadException.isNull()) { autoloadException = ex; } else { @@ -461,13 +461,13 @@ AutoloadHandler::loadFromMapPartial(const String& className, if (res == Success) { return Success; } - assert(res == Failure); + assertx(res == Failure); if (!err.isNull()) { auto const func = m_map.get()->get(s_failure); if (!isNullType(func.unboxed().type())) { res = invokeFailureCallback(tvAsCVarRef(func.tv_ptr()), kind, className, err); - assert(res != Failure); + assertx(res != Failure); if (checkExists()) { return Success; } @@ -508,7 +508,7 @@ bool AutoloadHandler::autoloadClassOrType(const String& clsName) { // First, call the failure callback for 'class' if we didn't do so // above if (classRes == Failure) { - assert(tryClass); + assertx(tryClass); classRes = invokeFailureCallback(func, s_class, className, classErr); // The failure callback may have defined a class or type alias for // us, in which case we're done. @@ -516,13 +516,13 @@ bool AutoloadHandler::autoloadClassOrType(const String& clsName) { } // Next, call the failure callback for 'type' if we didn't do so above if (typeRes == Failure) { - assert(tryType); + assertx(tryType); typeRes = invokeFailureCallback(func, s_type, className, typeErr); // The failure callback may have defined a class or type alias for // us, in which case we're done. if (cte()) return true; } - assert(classRes != Failure && typeRes != Failure); + assertx(classRes != Failure && typeRes != Failure); tryClass = (classRes == RetryAutoloading); tryType = (typeRes == RetryAutoloading); // If the failure callback requested a retry for 'class' or 'type' diff --git a/hphp/runtime/base/backtrace.cpp b/hphp/runtime/base/backtrace.cpp index cbcbd2ed172..ff61edc0320 100644 --- a/hphp/runtime/base/backtrace.cpp +++ b/hphp/runtime/base/backtrace.cpp @@ -189,7 +189,7 @@ Array createBacktrace(const BacktraceArgs& btArgs) { } else { fp = vmfp(); auto const unit = fp->func()->unit(); - assert(unit); + assertx(unit); pc = unit->offsetOf(vmpc()); } @@ -211,7 +211,7 @@ Array createBacktrace(const BacktraceArgs& btArgs) { } if (curFp) { auto const unit = curFp->func()->unit(); - assert(unit); + assertx(unit); auto const filename = curFp->func()->filename(); ArrayInit frame(btArgs.m_parserFrame ? 4 : 2, ArrayInit::Map{}); @@ -251,7 +251,7 @@ Array createBacktrace(const BacktraceArgs& btArgs) { if (prevFp->func()->originalFilename()) { prevFile = prevFp->func()->originalFilename(); } - assert(prevFile); + assertx(prevFile); frame.set(s_file, Variant{const_cast(prevFile)}); // In the normal method case, the "saved pc" for line number printing is diff --git a/hphp/runtime/base/builtin-functions.cpp b/hphp/runtime/base/builtin-functions.cpp index 3f6e2113555..efa39d50d9e 100644 --- a/hphp/runtime/base/builtin-functions.cpp +++ b/hphp/runtime/base/builtin-functions.cpp @@ -219,7 +219,7 @@ vm_decode_function(const Variant& function, // assign the value at index 1 to name and we use the value at index // 0 to populate cls (if the value is a string) or this_ and cls (if // the value is an object). - assert(function.isArray()); + assertx(function.isArray()); Array arr = function.toArray(); if (!array_is_valid_callback(arr)) { if (flags == DecodeFlags::Warn) { @@ -275,7 +275,7 @@ vm_decode_function(const Variant& function, return nullptr; } } else { - assert(elem0.isObject()); + assertx(elem0.isObject()); this_ = elem0.getObjectData(); cls = this_->getVMClass(); } @@ -346,10 +346,10 @@ vm_decode_function(const Variant& function, } return nullptr; } - assert(f && f->preClass() == nullptr); + assertx(f && f->preClass() == nullptr); return f; } - assert(cls); + assertx(cls); CallType lookupType = this_ ? CallType::ObjMethod : CallType::ClsMethod; auto f = lookupMethodCtx(cc, name.get(), ctx, lookupType); if (f && (f->attrs() & AttrStatic)) { @@ -370,11 +370,11 @@ vm_decode_function(const Variant& function, // If this_ is non-null AND we could not find a method, try // looking up __call in cls's method table f = cls->lookupMethod(s___call.get()); - assert(!f || !(f->attrs() & AttrStatic)); + assertx(!f || !(f->attrs() & AttrStatic)); } if (!f && lookupType == CallType::ClsMethod) { f = cls->lookupMethod(s___callStatic.get()); - assert(!f || (f->attrs() & AttrStatic)); + assertx(!f || (f->attrs() & AttrStatic)); this_ = nullptr; } if (f && (cc == cls || cc->lookupMethod(f->name()))) { @@ -400,10 +400,10 @@ vm_decode_function(const Variant& function, } } - assert(f && f->preClass()); + assertx(f && f->preClass()); // If this_ is non-NULL, then this_ is the current instance and cls is // the class of the current instance. - assert(!this_ || this_->getVMClass() == cls); + assertx(!this_ || this_->getVMClass() == cls); // If we are doing a forwarding call and this_ is null, set cls // appropriately to propagate the current late bound class. if (!this_ && forwarding && ar && ar->func()->cls()) { @@ -824,7 +824,7 @@ void throw_wrong_arguments_nr(const char *fn, int count, int cmin, int cmax, rv->m_data.num = 0LL; rv->m_type = KindOfNull; } - assert(false); + assertx(false); } void throw_bad_type_exception(const char *fmt, ...) { diff --git a/hphp/runtime/base/collections.cpp b/hphp/runtime/base/collections.cpp index ffbc46215b0..d1a23d06ddf 100644 --- a/hphp/runtime/base/collections.cpp +++ b/hphp/runtime/base/collections.cpp @@ -133,7 +133,7 @@ ArrayData* asArray(ObjectData* obj) { // Deep Copy ArrayData* deepCopyArray(ArrayData* arr) { - assert(arr->isPHPArray()); + assertx(arr->isPHPArray()); Array ar(arr); IterateKV( arr, @@ -151,7 +151,7 @@ ArrayData* deepCopyArray(ArrayData* arr) { } ArrayData* deepCopyVecArray(ArrayData* arr) { - assert(arr->isVecArray()); + assertx(arr->isVecArray()); Array ar(arr); PackedArray::IterateKV( arr, @@ -160,7 +160,7 @@ ArrayData* deepCopyVecArray(ArrayData* arr) { Variant value{tvAsCVarRef(&v)}; deepCopy(value.asTypedValue()); if (value.asTypedValue()->m_data.num != v.m_data.num) { - assert(k.m_type == KindOfInt64); + assertx(k.m_type == KindOfInt64); ar.set(k.m_data.num, value); } return false; @@ -170,7 +170,7 @@ ArrayData* deepCopyVecArray(ArrayData* arr) { } ArrayData* deepCopyDict(ArrayData* arr) { - assert(arr->isDict()); + assertx(arr->isDict()); Array ar(arr); MixedArray::IterateKV( MixedArray::asMixed(arr), @@ -281,7 +281,7 @@ void deepCopy(TypedValue* tv) { default: assertx(false); } - assert(obj != tv->m_data.pobj || tv->m_data.pobj->hasMultipleRefs()); + assertx(obj != tv->m_data.pobj || tv->m_data.pobj->hasMultipleRefs()); decRefObj(tv->m_data.pobj); tv->m_data.pobj = obj; return; @@ -295,7 +295,7 @@ void deepCopy(TypedValue* tv) { template static inline TypedValue* atImpl(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); switch (obj->collectionType()) { #define X(type) case CollectionType::type: \ return c_##type::OffsetAt(obj, key); diff --git a/hphp/runtime/base/comparisons.cpp b/hphp/runtime/base/comparisons.cpp index ab48edeee4b..35b30fd75b5 100644 --- a/hphp/runtime/base/comparisons.cpp +++ b/hphp/runtime/base/comparisons.cpp @@ -157,7 +157,7 @@ bool moreEqual(int64_t v1, const StringData *v2) { } int64_t compare(const StringData* v1, int64_t v2) { - assert(v1); + assertx(v1); int64_t lval; double dval; auto ret = v1->isNumericWithVal(lval, dval, 1); diff --git a/hphp/runtime/base/comparisons.h b/hphp/runtime/base/comparisons.h index fd4e5768f50..60279dc6421 100644 --- a/hphp/runtime/base/comparisons.h +++ b/hphp/runtime/base/comparisons.h @@ -220,7 +220,7 @@ inline bool less(bool v1, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool less(bool v1, const Object& v2) { return less(v1,v2.toBoolean()); } @@ -245,7 +245,7 @@ inline bool more(bool v1, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool more(bool v1, const Object& v2) { return more(v1,v2.toBoolean()); } @@ -313,7 +313,7 @@ inline bool less(int /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool less(int v1, const Object& v2) { @@ -336,7 +336,7 @@ inline bool more(int /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool more(int v1, const Object& v2) { @@ -412,7 +412,7 @@ inline bool less(int64_t /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool less(int64_t v1, const Object& v2) { @@ -441,7 +441,7 @@ inline bool more(int64_t /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool more(int64_t v1, const Object& v2) { @@ -522,7 +522,7 @@ inline bool less(double /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool less(double v1, const Object& v2) { @@ -551,7 +551,7 @@ inline bool more(double /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool more(double v1, const Object& v2) { @@ -672,7 +672,7 @@ inline bool less(const StringData *v1, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool less(const StringData *v1, const Object& v2) { @@ -725,7 +725,7 @@ inline bool more(const StringData *v1, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool more(const StringData *v1, const Object& v2) { @@ -755,8 +755,8 @@ inline bool moreEqual(const StringData* v1, int64_t v2) { int64_t compare(const StringData* v1, int64_t v2); inline int64_t compare(const StringData* v1, const StringData* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); // Clamp return values to just -1, 0, 1. auto cmp = v1->compare(v2); return (cmp < 0) ? -1 : ((cmp > 0) ? 1 : 0); @@ -1036,8 +1036,8 @@ inline bool more(const Object& v1, const Variant& v2) { // ObjectData* inline bool equal(const ObjectData* v1, const ObjectData* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); return v1->equal(*v2); } @@ -1046,8 +1046,8 @@ inline bool nequal(const ObjectData* v1, const ObjectData* v2) { } inline bool less(const ObjectData* v1, const ObjectData* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); return v1->less(*v2); } @@ -1056,8 +1056,8 @@ inline bool lessEqual(const ObjectData* v1, const ObjectData* v2) { } inline bool more(const ObjectData* v1, const ObjectData* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); return v1->more(*v2); } @@ -1066,8 +1066,8 @@ inline bool moreEqual(const ObjectData* v1, const ObjectData* v2) { } inline int64_t compare(const ObjectData* v1, const ObjectData* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); return v1->compare(*v2); } @@ -1132,7 +1132,7 @@ inline bool less(const Resource& /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool less(const Resource& /*v1*/, const Object& /*v2*/) { @@ -1157,7 +1157,7 @@ inline bool more(const Resource& /*v1*/, const Array& v2) { } if (v2.isVecArray()) throw_vec_compare_exception(); if (v2.isDict()) throw_dict_compare_exception(); - assert(v2.isKeyset()); + assertx(v2.isKeyset()); throw_keyset_compare_exception(); } inline bool more(const Resource& /*v1*/, const Object& /*v2*/) { @@ -1178,8 +1178,8 @@ inline bool nequal(const ResourceHdr* v1, const ResourceHdr* v2) { } inline bool less(const ResourceHdr* v1, const ResourceHdr* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); return v1->data()->o_toInt64() < v2->data()->o_toInt64(); } @@ -1188,8 +1188,8 @@ inline bool lessEqual(const ResourceHdr* v1, const ResourceHdr* v2) { } inline bool more(const ResourceHdr* v1, const ResourceHdr* v2) { - assert(v1); - assert(v2); + assertx(v1); + assertx(v2); return v1->data()->o_toInt64() > v2->data()->o_toInt64(); } @@ -1198,8 +1198,8 @@ inline bool moreEqual(const ResourceHdr* v1, const ResourceHdr* v2) { } inline int64_t compare(const ResourceHdr* v1, const ResourceHdr* v2) { - assert(v1); - assert(v1); + assertx(v1); + assertx(v1); auto id1 = v1->data()->o_toInt64(); auto id2 = v2->data()->o_toInt64(); return (id1 < id2) ? -1 : ((id1 > id2) ? 1 : 0); diff --git a/hphp/runtime/base/concurrent-shared-store.cpp b/hphp/runtime/base/concurrent-shared-store.cpp index f9972f582ca..1ceb1035ddc 100644 --- a/hphp/runtime/base/concurrent-shared-store.cpp +++ b/hphp/runtime/base/concurrent-shared-store.cpp @@ -223,7 +223,7 @@ struct HotCache { if (sd->isStatic()) return sd->data(); auto const nbytes = sd->size() + 1; auto const dst = malloc_huge(nbytes); - assert((reinterpret_cast(dst) & 7) == 0); + assertx((reinterpret_cast(dst) & 7) == 0); memcpy(dst, sd->data(), nbytes); return reinterpret_cast(dst); } @@ -239,7 +239,7 @@ struct HotCache { } static HotValueRaw makeRawValue(APCHandle* h) { - assert(h != nullptr && supportedKind(h)); + assertx(h != nullptr && supportedKind(h)); HotValue v = [&] { switch (h->kind()) { case APCKind::UncountedArray: @@ -372,7 +372,7 @@ bool HotCache::store(Idx idx, const StringData* key, } idx = p.first.getIndex(); } - assert(idx >= 0); + assertx(idx >= 0); sval->hotIndex.store(idx, std::memory_order_relaxed); m_hotMap->findAt(idx)->second.store(raw, std::memory_order_relaxed); return true; @@ -380,7 +380,7 @@ bool HotCache::store(Idx idx, const StringData* key, bool HotCache::clearValueIdx(Idx idx) { if (idx == StoreValue::kHotCacheUnknown) return false; - assert(idx >= 0); + assertx(idx >= 0); auto it = m_hotMap->findAt(idx); it->second.store(HotValue(nullptr).toOpaque(), std::memory_order_relaxed); return true; @@ -407,7 +407,7 @@ bool ConcurrentTableSharedStore::clear() { } bool ConcurrentTableSharedStore::eraseKey(const String& key) { - assert(!key.isNull()); + assertx(!key.isNull()); return eraseImpl(tagStringData(key.get()), false, 0, nullptr); } @@ -423,7 +423,7 @@ bool ConcurrentTableSharedStore::eraseImpl(const char* key, bool expired, int64_t oldestLive, ExpMap::accessor* expAcc) { - assert(key); + assertx(key); SharedMutex::ReadHolder l(m_lock); Map::accessor acc; @@ -452,7 +452,7 @@ bool ConcurrentTableSharedStore::eraseImpl(const char* key, var->unreferenceRoot(storeVal.dataSize); } } else { - assert(!expired); // primed keys never say true to expired() + assertx(!expired); // primed keys never say true to expired() } FTRACE(2, "Remove {} {}\n", acc->first, show(acc->second)); @@ -559,7 +559,7 @@ bool ConcurrentTableSharedStore::handlePromoteObj(const String& key, APCHandle* ConcurrentTableSharedStore::unserialize(const String& key, StoreValue* sval) { auto const sAddr = sval->data().right(); - assert(sAddr != nullptr); + assertx(sAddr != nullptr); /* This method is special, since another thread T may concurrently attempt to 'get' this entry while we're unserializing it. If T @@ -634,7 +634,7 @@ bool ConcurrentTableSharedStore::get(const String& keyStr, Variant& value) { if (!svar) return false; } } - assert(sval->data().left() == svar); + assertx(sval->data().left() == svar); APCKind kind = sval->getKind(); if (apcExtension::AllowObj && (kind == APCKind::SerializedObject || @@ -696,7 +696,7 @@ int64_t ConcurrentTableSharedStore::inc(const String& key, int64_t step, } // Currently a no-op, since HotCache doesn't store int/double. - assert(sval.hotIndex == StoreValue::kHotCacheUnknown); + assertx(sval.hotIndex == StoreValue::kHotCacheUnknown); s_hotCache.clearValue(sval); auto const ret = oldHandle->toLocal().toInt64() + step; @@ -1163,7 +1163,7 @@ template bool ConcurrentTableSharedStore ::APCMap ::getRandomAPCEntry(std::vector& entries) { - assert(!this->empty()); + assertx(!this->empty()); #if TBB_VERSION_MAJOR >= 4 auto current = this->range(); for (auto rnd = rand(); rnd > 0 && current.is_divisible(); rnd >>= 1) { diff --git a/hphp/runtime/base/concurrent-shared-store.h b/hphp/runtime/base/concurrent-shared-store.h index 59d0a057145..3cd9823bc7c 100644 --- a/hphp/runtime/base/concurrent-shared-store.h +++ b/hphp/runtime/base/concurrent-shared-store.h @@ -78,8 +78,8 @@ struct StoreValue { tagged_data.store(v, std::memory_order_release); } APCKind getKind() const { - assert(data().left()); - assert(data().left()->kind() == kind); + assertx(data().left()); + assertx(data().left()->kind() == kind); return kind; } Variant toLocal() const { @@ -89,12 +89,12 @@ struct StoreValue { bool expired() const; int32_t getSerializedSize() const { - assert(data().right() != nullptr); + assertx(data().right() != nullptr); return abs(dataSize); } bool isSerializedObj() const { - assert(data().right() != nullptr); + assertx(data().right() != nullptr); return dataSize < 0; } @@ -336,7 +336,7 @@ private: } static StringData* getStringData(const char* s) { - assert(reinterpret_cast(s) < 0); + assertx(reinterpret_cast(s) < 0); return reinterpret_cast(-reinterpret_cast(s)); } @@ -347,18 +347,18 @@ private: private: struct CharHashCompare { bool equal(const char* s1, const char* s2) const { - assert(s1 && s2); + assertx(s1 && s2); // tbb implementation call equal with the second pointer being the // value in the table and thus not a StringData*. We are asserting // to make sure that is the case - assert(!isTaggedStringData(s2)); + assertx(!isTaggedStringData(s2)); if (isTaggedStringData(s1)) { s1 = getStringData(s1)->data(); } return strcmp(s1, s2) == 0; } size_t hash(const char* s) const { - assert(s); + assertx(s); return isTaggedStringData(s) ? getStringData(s)->hash() : StringData::hash(s, strlen(s)); } diff --git a/hphp/runtime/base/config.cpp b/hphp/runtime/base/config.cpp index 3ff93804170..72bb1067678 100644 --- a/hphp/runtime/base/config.cpp +++ b/hphp/runtime/base/config.cpp @@ -186,13 +186,13 @@ void Config::SetParsedIni(IniSettingMap &ini, const std::string confStr, bool is_system) { // if we are setting constants, we must be setting system settings if (constants_only) { - assert(is_system); + assertx(is_system); } auto parsed_ini = IniSetting::FromStringAsMap(confStr, filename); for (ArrayIter iter(parsed_ini.toArray()); iter; ++iter) { // most likely a string, but just make sure that we are dealing // with something that can be converted to a string - assert(iter.first().isScalar()); + assertx(iter.first().isScalar()); ini.set(iter.first().toString(), iter.second()); if (constants_only) { IniSetting::FillInConstant(iter.first().toString().toCppString(), diff --git a/hphp/runtime/base/container-functions.h b/hphp/runtime/base/container-functions.h index f4581aec126..2a7addbc490 100644 --- a/hphp/runtime/base/container-functions.h +++ b/hphp/runtime/base/container-functions.h @@ -25,7 +25,7 @@ namespace HPHP { ////////////////////////////////////////////////////////////////////// inline bool isContainer(const Cell c) { - assert(cellIsPlausible(c)); + assertx(cellIsPlausible(c)); return isArrayLikeType(c.m_type) || (c.m_type == KindOfObject && c.m_data.pobj->isCollection()); } @@ -35,7 +35,7 @@ inline bool isContainer(const Variant& v) { } inline bool isContainerOrNull(const Cell c) { - assert(cellIsPlausible(c)); + assertx(cellIsPlausible(c)); return isNullType(c.m_type) || isArrayLikeType(c.m_type) || (c.m_type == KindOfObject && c.m_data.pobj->isCollection()); } @@ -45,7 +45,7 @@ inline bool isContainerOrNull(const Variant& v) { } inline bool isMutableContainer(const Cell c) { - assert(cellIsPlausible(c)); + assertx(cellIsPlausible(c)); return isArrayLikeType(c.m_type) || (c.m_type == KindOfObject && c.m_data.pobj->isMutableCollection()); } @@ -55,11 +55,11 @@ inline bool isMutableContainer(const Variant& v) { } inline size_t getContainerSize(const Cell c) { - assert(isContainer(c)); + assertx(isContainer(c)); if (isArrayLikeType(c.m_type)) { return c.m_data.parr->size(); } - assert(c.m_type == KindOfObject && c.m_data.pobj->isCollection()); + assertx(c.m_type == KindOfObject && c.m_data.pobj->isCollection()); return collections::getSize(c.m_data.pobj); } @@ -68,7 +68,7 @@ inline size_t getContainerSize(const Variant& v) { } inline bool isPackedContainer(const Cell c) { - assert(isContainer(c)); + assertx(isContainer(c)); if (isArrayLikeType(c.m_type)) { return c.m_data.parr->hasPackedLayout(); } diff --git a/hphp/runtime/base/countable.h b/hphp/runtime/base/countable.h index 7012be1c28e..95b9fbec866 100644 --- a/hphp/runtime/base/countable.h +++ b/hphp/runtime/base/countable.h @@ -166,32 +166,32 @@ ALWAYS_INLINE bool Countable::isRefCounted() const { } ALWAYS_INLINE bool MaybeCountable::hasMultipleRefs() const { - assert(checkCount()); + assertx(checkCount()); if (one_bit_refcount) return m_count != OneReference; return uint32_t(m_count) > 1; // treat Static/Uncounted as large counts } ALWAYS_INLINE bool Countable::hasMultipleRefs() const { - assert(checkCount()); + assertx(checkCount()); if (one_bit_refcount) return m_count != OneReference; return m_count > 1; } ALWAYS_INLINE bool MaybeCountable::hasExactlyOneRef() const { - assert(checkCount()); + assertx(checkCount()); return m_count == OneReference; } ALWAYS_INLINE bool Countable::hasExactlyOneRef() const { - assert(checkCount()); + assertx(checkCount()); return m_count == OneReference; } ALWAYS_INLINE void MaybeCountable::incRefCount() const { - assert(!tl_sweeping); - assert(checkCount() || m_count == 0 /* due to static init order */); + assertx(!tl_sweeping); + assertx(checkCount() || m_count == 0 /* due to static init order */); if (one_bit_refcount) { if (m_count == OneReference) m_count = MultiReference; return; @@ -201,8 +201,8 @@ ALWAYS_INLINE void MaybeCountable::incRefCount() const { } ALWAYS_INLINE void Countable::incRefCount() const { - assert(!tl_sweeping); - assert(checkCount() || m_count == 0 /* due to static init order */); + assertx(!tl_sweeping); + assertx(checkCount() || m_count == 0 /* due to static init order */); if (one_bit_refcount) { if (unconditional_one_bit_incref || m_count == OneReference) { m_count = MultiReference; @@ -214,8 +214,8 @@ ALWAYS_INLINE void Countable::incRefCount() const { } ALWAYS_INLINE void MaybeCountable::rawIncRefCount() const { - assert(!tl_sweeping); - assert(isRefCounted()); + assertx(!tl_sweeping); + assertx(isRefCounted()); if (one_bit_refcount) { if (unconditional_one_bit_incref || m_count == OneReference) { m_count = MultiReference; @@ -227,8 +227,8 @@ ALWAYS_INLINE void MaybeCountable::rawIncRefCount() const { } ALWAYS_INLINE void Countable::rawIncRefCount() const { - assert(!tl_sweeping); - assert(isRefCounted()); + assertx(!tl_sweeping); + assertx(isRefCounted()); if (one_bit_refcount) { if (unconditional_one_bit_incref || m_count == OneReference) { m_count = MultiReference; @@ -240,16 +240,16 @@ ALWAYS_INLINE void Countable::rawIncRefCount() const { } ALWAYS_INLINE void MaybeCountable::decRefCount() const { - assert(!tl_sweeping); - assert(checkCount()); + assertx(!tl_sweeping); + assertx(checkCount()); if (one_bit_refcount) return; if (isRefCounted()) --m_count; } ALWAYS_INLINE void Countable::decRefCount() const { - assert(!tl_sweeping); - assert(checkCount()); + assertx(!tl_sweeping); + assertx(checkCount()); if (one_bit_refcount) return; --m_count; @@ -264,8 +264,8 @@ ALWAYS_INLINE bool Countable::decWillRelease() const { } ALWAYS_INLINE bool MaybeCountable::decReleaseCheck() { - assert(!tl_sweeping); - assert(checkCount()); + assertx(!tl_sweeping); + assertx(checkCount()); if (noop_decref) return false; if (one_bit_refcount) return m_count == OneReference; @@ -275,8 +275,8 @@ ALWAYS_INLINE bool MaybeCountable::decReleaseCheck() { } ALWAYS_INLINE bool Countable::decReleaseCheck() { - assert(!tl_sweeping); - assert(checkCount()); + assertx(!tl_sweeping); + assertx(checkCount()); if (noop_decref) return false; if (one_bit_refcount) return m_count == OneReference; @@ -286,23 +286,23 @@ ALWAYS_INLINE bool Countable::decReleaseCheck() { } ALWAYS_INLINE bool MaybeCountable::isStatic() const { - assert(checkCount()); + assertx(checkCount()); return m_count == StaticValue; } ALWAYS_INLINE bool Countable::isStatic() const { - assert(checkCount()); + assertx(checkCount()); return false; } ALWAYS_INLINE bool MaybeCountable::isUncounted() const { - assert(checkCount()); + assertx(checkCount()); return one_bit_refcount ? m_count < 0 && m_count != StaticValue : m_count <= UncountedValue; } ALWAYS_INLINE bool Countable::isUncounted() const { - assert(checkCount()); + assertx(checkCount()); return false; } diff --git a/hphp/runtime/base/data-stream-wrapper.cpp b/hphp/runtime/base/data-stream-wrapper.cpp index 2b49a8ad793..b69820bf3f7 100644 --- a/hphp/runtime/base/data-stream-wrapper.cpp +++ b/hphp/runtime/base/data-stream-wrapper.cpp @@ -89,7 +89,7 @@ DataStreamWrapper::open(const String& filename, const String& /*mode*/, } } - assert(data == comma || data == semi); + assertx(data == comma || data == semi); // eat parameters, and figure out if we have ';base64' while (semi && (data == semi)) { data++; diff --git a/hphp/runtime/base/datetime.cpp b/hphp/runtime/base/datetime.cpp index 944d587c584..f20839a9f79 100644 --- a/hphp/runtime/base/datetime.cpp +++ b/hphp/runtime/base/datetime.cpp @@ -619,7 +619,7 @@ String DateTime::toString(DateFormat format) const { case DateFormat::Cookie: return rfcFormat(DateFormatCookie); case DateFormat::HttpHeader: return rfcFormat(DateFormatHttpHeader); default: - assert(false); + assertx(false); } throw_invalid_argument("format: %d", static_cast(format)); return String(); @@ -1077,7 +1077,7 @@ Variant DateTime::getSunInfo(SunInfoFormat retformat, return String(retstr, CopyString); } - assert(retformat == SunInfoFormat::ReturnDouble); + assertx(retformat == SunInfoFormat::ReturnDouble); return N; } diff --git a/hphp/runtime/base/directory.cpp b/hphp/runtime/base/directory.cpp index 4fdaf5525ae..ed5aae476eb 100644 --- a/hphp/runtime/base/directory.cpp +++ b/hphp/runtime/base/directory.cpp @@ -102,7 +102,7 @@ Variant ArrayDirectory::read() { } auto ret = m_it.second(); - assert(ret.isString()); + assertx(ret.isString()); ++m_it; return Variant(HHVM_FN(basename)(ret.toString())); } @@ -121,12 +121,12 @@ String ArrayDirectory::path() { } auto entry = m_it.second(); - assert(entry.isString()); + assertx(entry.isString()); return HHVM_FN(dirname)(entry.toString()); } CachedDirectory::CachedDirectory(const String& path) { - assert(File::IsVirtualDirectory(path)); + assertx(File::IsVirtualDirectory(path)); m_files = StaticContentCache::TheFileCache->readDirectory(path.c_str()); } diff --git a/hphp/runtime/base/empty-array.cpp b/hphp/runtime/base/empty-array.cpp index 547f3d27265..cdaa86f3da4 100644 --- a/hphp/runtime/base/empty-array.cpp +++ b/hphp/runtime/base/empty-array.cpp @@ -135,12 +135,12 @@ member_lval EmptyArray::MakePackedInl(TypedValue tv) { auto const elem = packedData(ad); *elem = tv; - assert(ad->kind() == ArrayData::kPackedKind); - assert(ad->dvArray() == ArrayData::kNotDVArray); - assert(ad->m_size == 1); - assert(ad->m_pos == 0); - assert(ad->hasExactlyOneRef()); - assert(PackedArray::checkInvariants(ad)); + assertx(ad->kind() == ArrayData::kPackedKind); + assertx(ad->dvArray() == ArrayData::kNotDVArray); + assertx(ad->m_size == 1); + assertx(ad->m_pos == 0); + assertx(ad->hasExactlyOneRef()); + assertx(PackedArray::checkInvariants(ad)); return member_lval { ad, elem }; } @@ -169,13 +169,13 @@ member_lval EmptyArray::MakeMixed(StringData* key, TypedValue val) { elem.m_data = val.m_data; elem.m_type = val.m_type; - assert(ad->m_size == 1); - assert(ad->m_pos == 0); - assert(ad->m_scale == MixedArray::SmallScale); - assert(ad->kind() == ArrayData::kMixedKind); - assert(ad->hasExactlyOneRef()); - assert(ad->m_used == 1); - assert(ad->checkInvariants()); + assertx(ad->m_size == 1); + assertx(ad->m_pos == 0); + assertx(ad->m_scale == MixedArray::SmallScale); + assertx(ad->kind() == ArrayData::kMixedKind); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_used == 1); + assertx(ad->checkInvariants()); return member_lval { ad, &elem }; } @@ -198,13 +198,13 @@ member_lval EmptyArray::MakeMixed(int64_t key, TypedValue val) { elem.m_data = val.m_data; elem.m_type = val.m_type; - assert(ad->kind() == ArrayData::kMixedKind); - assert(ad->m_size == 1); - assert(ad->m_pos == 0); - assert(ad->hasExactlyOneRef()); - assert(ad->m_scale == MixedArray::SmallScale); - assert(ad->m_used == 1); - assert(ad->checkInvariants()); + assertx(ad->kind() == ArrayData::kMixedKind); + assertx(ad->m_size == 1); + assertx(ad->m_pos == 0); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_scale == MixedArray::SmallScale); + assertx(ad->m_used == 1); + assertx(ad->checkInvariants()); return member_lval { ad, &elem }; } @@ -332,14 +332,14 @@ ArrayData* EmptyArray::Merge(ArrayData*, const ArrayData* elems) { // Fast path the common case that elems is mixed. if (elems->isMixed()) { auto const copy = MixedArray::Copy(elems); - assert(copy != elems); + assertx(copy != elems); MixedArray::Renumber(copy); return copy; } } auto copy = const_cast(elems)->toPHPArray(true); copy = copy == elems ? elems->copy() : copy; - assert(copy != elems); + assertx(copy != elems); copy->renumber(); return copy; } diff --git a/hphp/runtime/base/emulate-zend.cpp b/hphp/runtime/base/emulate-zend.cpp index a24d3aca76e..aa1da263595 100644 --- a/hphp/runtime/base/emulate-zend.cpp +++ b/hphp/runtime/base/emulate-zend.cpp @@ -93,7 +93,7 @@ int emulate_zend(int argc, char** argv) { newargv.push_back(argv[cnt++]); continue; } - assert(cnt + 1 < argc); + assertx(cnt + 1 < argc); program = argv[cnt + 1]; need_file = true; cnt += 2; diff --git a/hphp/runtime/base/enum-cache.cpp b/hphp/runtime/base/enum-cache.cpp index c4fdba86a22..40c7c833d1d 100644 --- a/hphp/runtime/base/enum-cache.cpp +++ b/hphp/runtime/base/enum-cache.cpp @@ -46,7 +46,7 @@ const EnumValues* EnumCache::getValues(const Class* klass, } const EnumValues* EnumCache::getValuesBuiltin(const Class* klass) { - assert(isEnum(klass)); + assertx(isEnum(klass)); if (auto values = klass->getEnumValues()) { return values; } @@ -141,7 +141,7 @@ const EnumValues* EnumCache::loadEnumValues(const Class* klass, persist = false; value = klass->clsCnsGet(consts[i].name); } - assert(value.m_type != KindOfUninit); + assertx(value.m_type != KindOfUninit); if (UNLIKELY(!(isIntType(value.m_type) || tvIsString(&value)))) { // only int and string values allowed for enums. std::string msg; diff --git a/hphp/runtime/base/enum-cache.h b/hphp/runtime/base/enum-cache.h index 35d78cdcb9a..b9810b95f01 100644 --- a/hphp/runtime/base/enum-cache.h +++ b/hphp/runtime/base/enum-cache.h @@ -42,14 +42,14 @@ struct EnumCache { // TBB hash and compare struct struct clsCompare { bool equal(intptr_t key1, intptr_t key2) const { - assert(key1 && key2); + assertx(key1 && key2); bool equal = (key1 == key2); - assert(!equal || getClass(key1)->name()->equal(getClass(key2)->name())); + assertx(!equal || getClass(key1)->name()->equal(getClass(key2)->name())); return equal; } size_t hash(intptr_t key) const { - assert(key); + assertx(key); return static_cast(hash_int64(key)); } }; diff --git a/hphp/runtime/base/exceptions.h b/hphp/runtime/base/exceptions.h index 5e8f5e186cd..72064666974 100644 --- a/hphp/runtime/base/exceptions.h +++ b/hphp/runtime/base/exceptions.h @@ -151,7 +151,7 @@ struct PhpFileDoesNotExistException : ExtendedException { explicit PhpFileDoesNotExistException(const char* msg, DEBUG_ONLY bool empty_file) : ExtendedException("%s", msg) { - assert(empty_file); + assertx(empty_file); } EXCEPTION_COMMON_IMPL(PhpFileDoesNotExistException); }; diff --git a/hphp/runtime/base/execution-context.cpp b/hphp/runtime/base/execution-context.cpp index 1218b8ce7ac..f4ba006d5c3 100644 --- a/hphp/runtime/base/execution-context.cpp +++ b/hphp/runtime/base/execution-context.cpp @@ -323,7 +323,7 @@ void ExecutionContext::obClean(int handler_flag) { } bool ExecutionContext::obFlush(bool force /*= false*/) { - assert(m_protectedLevel >= 0); + assertx(m_protectedLevel >= 0); if ((int)m_buffers.size() <= m_protectedLevel) { return false; @@ -393,7 +393,7 @@ void ExecutionContext::obFlushAll() { } bool ExecutionContext::obEnd() { - assert(m_protectedLevel >= 0); + assertx(m_protectedLevel >= 0); if ((int)m_buffers.size() > m_protectedLevel) { m_buffers.pop_back(); resetCurrentBuffer(); @@ -409,7 +409,7 @@ void ExecutionContext::obEndAll() { } int ExecutionContext::obGetLevel() { - assert((int)m_buffers.size() >= m_protectedLevel); + assertx((int)m_buffers.size() >= m_protectedLevel); return m_buffers.size() - m_protectedLevel; } @@ -592,8 +592,8 @@ void ExecutionContext::acceptRequestEventHandlers(bool enable) { std::size_t ExecutionContext::registerRequestEventHandler( RequestEventHandler *handler) { - assert(handler && handler->getInited()); - assert(m_acceptRequestEventHandlers); + assertx(handler && handler->getInited()); + assertx(m_acceptRequestEventHandlers); m_requestEventHandlers.push_back(handler); return m_requestEventHandlers.size()-1; } @@ -601,9 +601,9 @@ std::size_t ExecutionContext::registerRequestEventHandler( void ExecutionContext::unregisterRequestEventHandler( RequestEventHandler* handler, std::size_t index) { - assert(index < m_requestEventHandlers.size() && + assertx(index < m_requestEventHandlers.size() && m_requestEventHandlers[index] == handler); - assert(!handler->getInited()); + assertx(!handler->getInited()); if (index == m_requestEventHandlers.size()-1) { m_requestEventHandlers.pop_back(); } else { @@ -631,7 +631,7 @@ void ExecutionContext::onRequestShutdown() { requestEventHandlerPriorityComp); for (auto* handler : tmp) { if (!handler) continue; - assert(handler->getInited()); + assertx(handler->getInited()); handler->requestShutdown(); handler->setInited(false); } @@ -831,7 +831,7 @@ void ExecutionContext::handleError(const std::string& msg, if (fp->func()->isBuiltin()) { fp = getPrevVMState(fp); } - assert(fp); + assertx(fp); auto id = fp->func()->lookupVarId(s_php_errormsg.get()); if (id != kInvalidId) { auto local = frame_local(fp, id); @@ -1004,7 +1004,7 @@ bool ExecutionContext::onUnhandledException(Object e) { } } } else { - assert(false); + assertx(false); } m_lastError = err; @@ -1153,7 +1153,7 @@ ObjectData* ExecutionContext::getThis() { Class* ExecutionContext::getContextClass() { VMRegAnchor _; ActRec* ar = vmfp(); - assert(ar != nullptr); + assertx(ar != nullptr); if (ar->skipFrame()) ar = getPrevVMStateSkipFrame(ar); return ar ? ar->m_func->cls() : nullptr; } @@ -1172,7 +1172,7 @@ StringData* ExecutionContext::getContainingFileName() { if (ar->skipFrame()) ar = getPrevVMStateSkipFrame(ar); if (ar == nullptr) return staticEmptyString(); Unit* unit = ar->m_func->unit(); - assert(unit->filepath()->isStatic()); + assertx(unit->filepath()->isStatic()); // XXX: const StringData* -> Variant(bool) conversion problem makes this ugly return const_cast(unit->filepath()); } @@ -1259,7 +1259,7 @@ ActRec* ExecutionContext::getFrameAtDepth(int frame) { curOp == Op::CreateCont || curOp == Op::Await)) { return nullptr; } - assert(!fp->magicDispatch()); + assertx(!fp->magicDispatch()); return fp; } @@ -1327,7 +1327,7 @@ void ExecutionContext::syncGdbState() { void ExecutionContext::pushVMState(Cell* savedSP) { if (UNLIKELY(!vmfp())) { // first entry - assert(m_nestedVMs.size() == 0); + assertx(m_nestedVMs.size() == 0); return; } @@ -1365,7 +1365,7 @@ void ExecutionContext::popVMState() { return; } - assert(m_nestedVMs.size() >= 1); + assertx(m_nestedVMs.size() >= 1); VMState &savedVM = m_nestedVMs.back(); vmpc() = savedVM.pc; @@ -1416,7 +1416,7 @@ StaticString s_stdclass("stdclass"); void ExecutionContext::requestInit() { - assert(SystemLib::s_unit); + assertx(SystemLib::s_unit); initBlackHole(); VarEnv::createGlobal(); @@ -1426,7 +1426,7 @@ void ExecutionContext::requestInit() { jit::tc::requestInit(); if (RuntimeOption::EvalJitEnableRenameFunction) { - assert(SystemLib::s_anyNonPersistentBuiltins); + assertx(SystemLib::s_anyNonPersistentBuiltins); } /* @@ -1448,11 +1448,11 @@ void ExecutionContext::requestInit() { if (SystemLib::s_nativeClassUnit) SystemLib::s_nativeClassUnit->merge(); } else { // System units are merge only, and everything is persistent. - assert(SystemLib::s_unit->isEmpty()); - assert(!SystemLib::s_hhas_unit || SystemLib::s_hhas_unit->isEmpty()); - assert(!SystemLib::s_nativeFuncUnit || + assertx(SystemLib::s_unit->isEmpty()); + assertx(!SystemLib::s_hhas_unit || SystemLib::s_hhas_unit->isEmpty()); + assertx(!SystemLib::s_nativeFuncUnit || SystemLib::s_nativeFuncUnit->isEmpty()); - assert(!SystemLib::s_nativeClassUnit || + assertx(!SystemLib::s_nativeClassUnit || SystemLib::s_nativeClassUnit->isEmpty()); } @@ -1462,8 +1462,8 @@ void ExecutionContext::requestInit() { #ifdef DEBUG Class* cls = NamedEntity::get(s_stdclass.get())->clsList(); - assert(cls); - assert(cls == SystemLib::s_stdclassClass); + assertx(cls); + assertx(cls == SystemLib::s_stdclassClass); #endif if (Logger::UseRequestLog) Logger::SetThreadHook(&m_logger_hook); @@ -1521,15 +1521,15 @@ TypedValue ExecutionContext::invokeFuncImpl(const Func* f, FStackCheck doStackCheck, FInitArgs doInitArgs, FEnterVM doEnterVM) { - assert(f); + assertx(f); // If `f' is a regular function, `thiz' and `cls' must be null. - assert(IMPLIES(!f->implCls(), (!thiz && !cls))); + assertx(IMPLIES(!f->implCls(), (!thiz && !cls))); // If `f' is a method, either `thiz' or `cls' must be non-null. - assert(IMPLIES(f->preClass(), thiz || cls)); + assertx(IMPLIES(f->preClass(), thiz || cls)); // If `f' is a static method, thiz must be null. - assert(IMPLIES(f->isStaticInPrologue(), !thiz)); + assertx(IMPLIES(f->isStaticInPrologue(), !thiz)); // invName should only be non-null if we are calling __call or __callStatic. - assert(IMPLIES(invName, f->name()->isame(s___call.get()) || + assertx(IMPLIES(invName, f->name()->isame(s___call.get()) || f->name()->isame(s___callStatic.get()))); VMRegAnchor _; @@ -1610,14 +1610,14 @@ TypedValue ExecutionContext::invokeFuncImpl(const Func* f, */ template static inline void enterVMCustomHandler(ActRec* ar, Action action) { - assert(ar); - assert(!ar->sfp()); - assert(isReturnHelper(reinterpret_cast(ar->m_savedRip))); - assert(ar->m_soff == 0); + assertx(ar); + assertx(!ar->sfp()); + assertx(isReturnHelper(reinterpret_cast(ar->m_savedRip))); + assertx(ar->m_soff == 0); auto ec = &*g_context; DEBUG_ONLY int faultDepth = ec->m_faults.size(); - SCOPE_EXIT { assert(ec->m_faults.size() == faultDepth); }; + SCOPE_EXIT { assertx(ec->m_faults.size() == faultDepth); }; vmFirstAR() = ar; vmJitCalledFrame() = nullptr; @@ -1645,11 +1645,11 @@ TypedValue ExecutionContext::invokeFunc(const Func* f, bool dynamic /* = true */, bool checkRefAnnot /* = false */) { const auto& args = *args_.asCell(); - assert(isContainerOrNull(args)); + assertx(isContainerOrNull(args)); auto const argc = cellIsNull(&args) ? 0 : getContainerSize(args); // If we are inheriting a variable environment, then `args' must be empty. - assert(IMPLIES(varEnv, argc == 0)); + assertx(IMPLIES(varEnv, argc == 0)); auto const doCheckStack = [&](TypedValue& retval) { // We must do a stack overflow check for leaf functions on re-entry, @@ -1669,8 +1669,8 @@ TypedValue ExecutionContext::invokeFunc(const Func* f, // Handle includes of pseudomains. if (flags & InvokePseudoMain) { - assert(f->isPseudoMain()); - assert(cellIsNull(&args) || !getContainerSize(args)); + assertx(f->isPseudoMain()); + assertx(cellIsNull(&args) || !getContainerSize(args)); auto toMerge = f->unit(); toMerge->merge(); @@ -1693,7 +1693,7 @@ TypedValue ExecutionContext::invokeFunc(const Func* f, flags & InvokeCuf, &retval, checkRefAnnot); if (UNLIKELY(!prepResult)) { - assert(KindOfNull == retval.m_type); + assertx(KindOfNull == retval.m_type); return true; } } @@ -1758,22 +1758,22 @@ TypedValue ExecutionContext::invokeFuncFew(const Func* f, } static void prepareAsyncFuncEntry(ActRec* enterFnAr, Resumable* resumable) { - assert(enterFnAr); - assert(enterFnAr->func()->isAsync()); - assert(enterFnAr->resumed()); - assert(resumable); + assertx(enterFnAr); + assertx(enterFnAr->func()->isAsync()); + assertx(enterFnAr->resumed()); + assertx(resumable); vmfp() = enterFnAr; vmpc() = vmfp()->func()->unit()->at(resumable->resumeOffset()); - assert(vmfp()->func()->contains(vmpc())); + assertx(vmfp()->func()->contains(vmpc())); EventHook::FunctionResumeAwait(enterFnAr); } void ExecutionContext::resumeAsyncFunc(Resumable* resumable, ObjectData* freeObj, const Cell awaitResult) { - assert(tl_regState == VMRegState::CLEAN); - SCOPE_EXIT { assert(tl_regState == VMRegState::CLEAN); }; + assertx(tl_regState == VMRegState::CLEAN); + SCOPE_EXIT { assertx(tl_regState == VMRegState::CLEAN); }; auto fp = resumable->actRec(); // We don't need to check for space for the ActRec (unlike generally @@ -1805,10 +1805,10 @@ void ExecutionContext::resumeAsyncFunc(Resumable* resumable, void ExecutionContext::resumeAsyncFuncThrow(Resumable* resumable, ObjectData* freeObj, ObjectData* exception) { - assert(exception); - assert(exception->instanceof(SystemLib::s_ThrowableClass)); - assert(tl_regState == VMRegState::CLEAN); - SCOPE_EXIT { assert(tl_regState == VMRegState::CLEAN); }; + assertx(exception); + assertx(exception->instanceof(SystemLib::s_ThrowableClass)); + assertx(tl_regState == VMRegState::CLEAN); + SCOPE_EXIT { assertx(tl_regState == VMRegState::CLEAN); }; auto fp = resumable->actRec(); checkStack(vmStack(), fp->func(), 0); @@ -1838,7 +1838,7 @@ ActRec* ExecutionContext::getPrevVMState(const ActRec* fp, if (LIKELY(prevFp != nullptr)) { if (prevSp) { if (UNLIKELY(fp->resumed())) { - assert(fp->func()->isGenerator()); + assertx(fp->func()->isGenerator()); *prevSp = (TypedValue*)prevFp - prevFp->func()->numSlotsInFrame(); } else { *prevSp = (TypedValue*)(fp + 1); @@ -1858,8 +1858,8 @@ ActRec* ExecutionContext::getPrevVMState(const ActRec* fp, if (i == -1) return nullptr; const VMState& vmstate = m_nestedVMs[i]; prevFp = vmstate.fp; - assert(prevFp); - assert(prevFp->func()->unit()); + assertx(prevFp); + assertx(prevFp->func()->unit()); if (prevSp) *prevSp = vmstate.sp; if (prevPc) { *prevPc = prevFp->func()->unit()->offsetOf(vmstate.pc); @@ -1888,7 +1888,7 @@ bool ExecutionContext::evalUnit(Unit* unit, PC& pc, int funcType) { ActRec* ar = vmStack().allocA(); auto const cls = vmfp()->func()->cls(); auto const func = unit->getMain(cls); - assert(!func->isCPPBuiltin()); + assertx(!func->isCPPBuiltin()); ar->m_func = func; if (cls) { ar->setThisOrClass(vmfp()->getThisOrClass()); @@ -1897,7 +1897,7 @@ bool ExecutionContext::evalUnit(Unit* unit, PC& pc, int funcType) { ar->trashThis(); } ar->initNumArgs(0); - assert(vmfp()); + assertx(vmfp()); ar->setReturn(vmfp(), pc, jit::tc::ustubs().retHelper); pushFrameSlots(func); @@ -1943,7 +1943,7 @@ Variant ExecutionContext::getEvaledArg(const StringData* val, key + s_semicolon; } Unit* unit = compileEvalString(code.get()); - assert(unit != nullptr); + assertx(unit != nullptr); // Default arg values are not currently allowed to depend on class context. auto v = Variant::attach( g_context->invokeFunc(unit->getMain(nullptr), @@ -1974,7 +1974,7 @@ void ExecutionContext::clearLastError() { } void ExecutionContext::enqueueAPCHandle(APCHandle* handle, size_t size) { - assert(handle->isUncounted()); + assertx(handle->isUncounted()); if (RuntimeOption::EvalGCForAPC) { // Register handle with APCGCManager // And resursively find all allocations belong to handle, register them too @@ -2009,7 +2009,7 @@ private: } void ExecutionContext::manageAPCHandle() { - assert(apcExtension::UseUncounted || m_apcHandles.size() == 0); + assertx(apcExtension::UseUncounted || m_apcHandles.size() == 0); if (m_apcHandles.size() > 0) { std::vector handles; handles.swap(m_apcHandles); @@ -2268,10 +2268,10 @@ void ExecutionContext::enterDebuggerDummyEnv() { static Unit* s_debuggerDummy = compile_string("", 7); // Ensure that the VM stack is completely empty (vmfp() should be null) // and that we're not in a nested VM (reentrancy) - assert(vmfp() == nullptr); - assert(m_nestedVMs.size() == 0); - assert(m_nesting == 0); - assert(vmStack().count() == 0); + assertx(vmfp() == nullptr); + assertx(m_nestedVMs.size() == 0); + assertx(m_nesting == 0); + assertx(vmStack().count() == 0); ActRec* ar = vmStack().allocA(); ar->m_func = s_debuggerDummy->getMain(nullptr); ar->initNumArgs(0); @@ -2285,15 +2285,15 @@ void ExecutionContext::enterDebuggerDummyEnv() { } void ExecutionContext::exitDebuggerDummyEnv() { - assert(m_globalVarEnv); + assertx(m_globalVarEnv); // Ensure that vmfp() is valid - assert(vmfp() != nullptr); + assertx(vmfp() != nullptr); // Ensure that vmfp() points to the only frame on the call stack. // In other words, make sure there are no VM frames directly below // this one and that we are not in a nested VM (reentrancy) - assert(!vmfp()->sfp()); - assert(m_nestedVMs.size() == 0); - assert(m_nesting == 0); + assertx(!vmfp()->sfp()); + assertx(m_nestedVMs.size() == 0); + assertx(m_nesting == 0); // Teardown the frame we erected by enterDebuggerDummyEnv() const Func* func = vmfp()->m_func; try { @@ -2303,7 +2303,7 @@ void ExecutionContext::exitDebuggerDummyEnv() { vmStack().ndiscard(func->numSlotsInFrame()); vmStack().discardAR(); // After tearing down this frame, the VM stack should be completely empty - assert(vmStack().count() == 0); + assertx(vmStack().count() == 0); vmfp() = nullptr; vmpc() = nullptr; } diff --git a/hphp/runtime/base/file-await.cpp b/hphp/runtime/base/file-await.cpp index 710661644cc..d989b0ae4ba 100644 --- a/hphp/runtime/base/file-await.cpp +++ b/hphp/runtime/base/file-await.cpp @@ -22,8 +22,8 @@ void FileEventHandler::handlerReady(uint16_t events) noexcept { ///////////////////////////////////////////////////////////////////////////// FileAwait::FileAwait(int fd, uint16_t events, double timeout) { - assert(fd >= 0); - assert(events & FileEventHandler::READ_WRITE); + assertx(fd >= 0); + assertx(events & FileEventHandler::READ_WRITE); auto asio_event_base = getSingleton(); m_file = std::make_shared(asio_event_base.get(), fd, this); @@ -99,7 +99,7 @@ Object File::await(uint16_t events, double timeout) { try { return Object{ev->getWaitHandle()}; } catch (...) { - assert(false); + assertx(false); ev->abandon(); throw; } diff --git a/hphp/runtime/base/file-util.cpp b/hphp/runtime/base/file-util.cpp index 0f9b2353557..8921d20ce37 100644 --- a/hphp/runtime/base/file-util.cpp +++ b/hphp/runtime/base/file-util.cpp @@ -441,8 +441,8 @@ String FileUtil::relativePath(const std::string& fromDir, } // Ensure the result is null-terminated after the strcpy - assert(to_start - to_file <= toFile.size()); - assert(path_end - path + strlen(to_start) <= ret.capacity()); + assertx(to_start - to_file <= toFile.size()); + assertx(path_end - path + strlen(to_start) <= ret.capacity()); strcpy(path_end, to_start); return ret.setSize(strlen(path)); @@ -474,7 +474,7 @@ String FileUtil::canonicalize(const std::string &path) { String FileUtil::canonicalize(const char *addpath, size_t addlen, bool collapse_slashes /* = true */) { - assert(strlen(addpath) <= addlen); + assertx(strlen(addpath) <= addlen); // 4 for slashes at start, after root, and at end, plus trailing // null size_t maxlen = addlen + 4; diff --git a/hphp/runtime/base/file.cpp b/hphp/runtime/base/file.cpp index 8b5d5b36404..2c78e0a9efa 100644 --- a/hphp/runtime/base/file.cpp +++ b/hphp/runtime/base/file.cpp @@ -98,7 +98,7 @@ String File::TranslatePathKeepRelative(const char* filename, uint32_t size) { // unresolvable paths are all considered as unsafe if (canonicalized.find("..") >= 0) { - assert(canonicalized.find("..") == 0); + assertx(canonicalized.find("..") == 0); return empty_string(); } } @@ -201,7 +201,7 @@ void File::sweep() { // `this` has been request-heap allocated. Note that the derived class' // sweep() is responsible for closing m_fd and any other non-request // resources it might have allocated. - assert(!valid()); + assertx(!valid()); File::closeImpl(); m_data.reset(); m_wrapperType = nullptr; @@ -334,7 +334,7 @@ String File::read(int64_t length) { m_data->m_position += copied; - assert(copied <= allocSize); + assertx(copied <= allocSize); s.shrink(copied); return s; } @@ -424,7 +424,7 @@ bool File::seek(int64_t offset, int whence /* = SEEK_SET */) { } if (offset > 0) { int64_t avail = bufferedLen(); - assert(avail >= 0); + assertx(avail >= 0); if (avail >= offset) { m_data->m_readpos += offset; return true; @@ -487,7 +487,7 @@ bool File::lock(int operation) { } bool File::lock(int operation, bool &wouldblock /* = false */) { - assert(m_data->m_fd >= 0); + assertx(m_data->m_fd >= 0); wouldblock = false; if (flock(m_data->m_fd, operation)) { @@ -657,7 +657,7 @@ String File::readLine(int64_t maxlen /* = 0 */) { } if (total_copied == 0) { - assert(ret == nullptr); + assertx(ret == nullptr); return String(); } @@ -687,7 +687,7 @@ Variant File::readRecord(const String& delimiter, int64_t maxlen /* = 0 */) { } if (avail < maxlen && !eof()) { - assert(m_data->m_writepos + maxlen - avail <= m_data->m_chunkSize * 3); + assertx(m_data->m_writepos + maxlen - avail <= m_data->m_chunkSize * 3); m_data->m_writepos += readImpl(m_data->m_buffer + m_data->m_writepos, maxlen - avail); maxlen = bufferedLen(); @@ -1121,7 +1121,7 @@ String File::applyFilters(const String& buffer, } } - assert(out); + assertx(out); return out->createString(); } diff --git a/hphp/runtime/base/hash-table-inl.h b/hphp/runtime/base/hash-table-inl.h index 4fd6a0d4ebe..a6e5163e041 100644 --- a/hphp/runtime/base/hash-table-inl.h +++ b/hphp/runtime/base/hash-table-inl.h @@ -92,7 +92,7 @@ void HashTableCommon::CopyHash(int32_t* to, } ALWAYS_INLINE bool HashTableCommon::isFull() const { - assert(m_used <= capacity()); + assertx(m_used <= capacity()); return m_used == capacity(); } @@ -100,7 +100,7 @@ template ALWAYS_INLINE ssize_t HashTable::getIterBeginNotEmpty() const { // Expedite no tombstone case. - assert(!array()->empty()); + assertx(!array()->empty()); if (LIKELY(!data()[0].isTombstone())) { return 0; } @@ -132,11 +132,11 @@ ALWAYS_INLINE ssize_t HashTable::getIterEnd() const { template ALWAYS_INLINE ssize_t HashTable::nextElm(Elm* elms, ssize_t ei) const { - assert(-1 <= ei && ei < m_used); + assertx(-1 <= ei && ei < m_used); while (++ei < m_used) { if (LIKELY(!elms[ei].isTombstone())) return ei; } - assert(ei == m_used); + assertx(ei == m_used); return m_used; } @@ -148,7 +148,7 @@ ALWAYS_INLINE ssize_t HashTable::nextElm(ssize_t ei) const { template ALWAYS_INLINE ssize_t HashTable::prevElm(Elm* elms, ssize_t ei) const { - assert(ei < ssize_t(m_used)); + assertx(ei < ssize_t(m_used)); while (--ei >= 0) { if (!elms[ei].isTombstone()) { return ei; @@ -185,7 +185,7 @@ HashTable::iter_advance_helper(ssize_t next_pos) const { return next_pos; } } - assert(next_pos == m_used); + assertx(next_pos == m_used); return next_pos; } @@ -279,8 +279,8 @@ HashTable::NvGetStr(const ArrayData* ad, template Cell HashTable::NvGetKey(const ArrayData* ad, ssize_t pos) { auto a = asArrayType(ad); - assert(pos != a->m_used); - assert(!a->data()[pos].isTombstone()); + assertx(pos != a->m_used); + assertx(!a->data()[pos].isTombstone()); return a->data()[pos].getKey(); } @@ -370,8 +370,8 @@ typename std::conditional< int32_t pos = *ei; if (validPos(pos)) { - assert(0 <= pos); - assert(pos < capacity()); + assertx(0 <= pos); + assertx(pos < capacity()); if (hit(elms[pos])) { if (type == FindType::Remove) { remove(elms[pos]); @@ -383,7 +383,7 @@ typename std::conditional< ); } } else if (pos & 1) { - assert(pos == Empty); + assertx(pos == Empty); return std::get(type)>( std::make_tuple(int32_t(pos), false, Inserter(ei), Inserter(ei), int32_t(pos)) diff --git a/hphp/runtime/base/hash-table.h b/hphp/runtime/base/hash-table.h index a26fc2698bb..59e43e7053f 100644 --- a/hphp/runtime/base/hash-table.h +++ b/hphp/runtime/base/hash-table.h @@ -118,7 +118,7 @@ struct HashTableCommon { static ALWAYS_INLINE bool isValidPos(Inserter e) { - assert(isValidIns(e)); + assertx(isValidIns(e)); return (int32_t)(*e) >= 0; } protected: @@ -283,8 +283,8 @@ struct HashTable : HashTableCommon { ///////////////////////////////////////////////////////////////////////////// protected: ALWAYS_INLINE Elm* allocElm(Inserter ei) { - assert(!isValidPos(ei) && !isFull()); - assert(array()->m_size <= m_used); + assertx(!isValidPos(ei) && !isFull()); + assertx(array()->m_size <= m_used); ++(array()->m_size); size_t i = m_used; (*ei) = i; @@ -302,14 +302,14 @@ protected: static void InitSmallHash(ArrayType* a); static ALWAYS_INLINE bool hitIntKey(const Elm& e, int64_t ki) { - assert(!e.isInvalid()); + assertx(!e.isInvalid()); return e.intKey() == ki && e.hasIntKey(); } static ALWAYS_INLINE bool hitStrKey(const Elm& e, const StringData* ks, hash_t h) { - assert(!e.isInvalid()); + assertx(!e.isInvalid()); /* * We do not have to check e.hasStrKey() because it is * implicitely done by the check on the hash. @@ -496,16 +496,16 @@ protected: private: static ALWAYS_INLINE ArrayType* asArrayType(ArrayData* ad) { - assert(ad->hasMixedLayout() || ad->isKeyset()); + assertx(ad->hasMixedLayout() || ad->isKeyset()); auto a = static_cast(ad); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return a; } static ALWAYS_INLINE const ArrayType* asArrayType(const ArrayData* ad) { - assert(ad->hasMixedLayout() || ad->isKeyset()); + assertx(ad->hasMixedLayout() || ad->isKeyset()); auto a = static_cast(ad); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return a; } diff --git a/hphp/runtime/base/heap-collect.cpp b/hphp/runtime/base/heap-collect.cpp index 4f7fb1f2b04..02466f3dd32 100644 --- a/hphp/runtime/base/heap-collect.cpp +++ b/hphp/runtime/base/heap-collect.cpp @@ -126,7 +126,7 @@ struct Collector { HeapObject* find(const void*); size_t slab_index(const void* h) { - assert((char*)h >= (char*)slabs_range_.ptr && + assertx((char*)h >= (char*)slabs_range_.ptr && (char*)h < (char*)slabs_range_.ptr + slabs_range_.size); return (uintptr_t(h) - uintptr_t(slabs_range_.ptr)) >> kLgSlabSize; } @@ -231,7 +231,7 @@ void Collector::checkedEnqueue(const void* p) { auto& work = willScanConservative(h) ? cwork_ : xwork_; work.push_back(h); max_worklist_ = std::max(max_worklist_, cwork_.size() + xwork_.size()); - assert(checkEnqueuedKind(h)); + assertx(checkEnqueuedKind(h)); } } else if (apcgc) { // If p doesn't belong to any APC data, APCGCManager won't do anything @@ -258,7 +258,7 @@ void Collector::exactEnqueue(const void* p) { ++marked_; xwork_.push_back(h); max_worklist_ = std::max(max_worklist_, xwork_.size()); - assert(checkEnqueuedKind(h)); + assertx(checkEnqueuedKind(h)); } } else if (apcgc) { // If p doesn't belong to any APC data, APCGCManager won't do anything @@ -325,7 +325,7 @@ NEVER_INLINE void Collector::init() { } } else { // put the inner big object in ptrs_ without the BigObj header - assert(h->kind() == HeaderKind::BigObj); + assertx(h->kind() == HeaderKind::BigObj); ptrs_.insert(static_cast(h)+1, size - sizeof(MallocNode)); } }, @@ -410,7 +410,7 @@ NEVER_INLINE void Collector::traceConservative() { template NEVER_INLINE void Collector::traceExact() { auto finish = [&] { - assert(cwork_.empty() && type_scanner_.m_conservative.empty()); + assertx(cwork_.empty() && type_scanner_.m_conservative.empty()); for (auto addr : type_scanner_.m_addrs) { xscanned_ += sizeof(*addr); exactEnqueue(*addr); @@ -484,14 +484,14 @@ NEVER_INLINE void Collector::sweep() { if (RuntimeOption::EvalQuarantine) mm.endQuarantine(std::move(quarantine)); freed_bytes_ = usage0 - mm.currentUsage(); sweep_ns_ = cpu_ns() - t0; - assert(freed_bytes_ >= 0); + assertx(freed_bytes_ >= 0); }; // Clear weak references as needed. for (auto w : type_scanner_.m_weak) { auto wref = static_cast(w); - assert(wref->acquire_count == 0); - assert(wref->wr_data); + assertx(wref->acquire_count == 0); + assertx(wref->wr_data); auto type = wref->wr_data->pointee.m_type; if (type == KindOfObject) { auto h = find(wref->wr_data->pointee.m_data.pobj); @@ -501,7 +501,7 @@ NEVER_INLINE void Collector::sweep() { } continue; } - assert(type == KindOfNull || type == KindOfUninit); + assertx(type == KindOfNull || type == KindOfUninit); } type_scanner_.m_weak.clear(); @@ -761,7 +761,7 @@ void MemoryManager::collect(const char* phase) { } void MemoryManager::setMemoryLimit(size_t limit) { - assert(limit <= (size_t)std::numeric_limits::max()); + assertx(limit <= (size_t)std::numeric_limits::max()); m_usageLimit = limit; updateNextGc(); } diff --git a/hphp/runtime/base/heap-graph.cpp b/hphp/runtime/base/heap-graph.cpp index 55bc67d9dea..dd2beaf578c 100644 --- a/hphp/runtime/base/heap-graph.cpp +++ b/hphp/runtime/base/heap-graph.cpp @@ -172,7 +172,7 @@ HeapGraph makeHeapGraph(bool include_free) { auto h = g.nodes[i].h; scanHeapObject(h, scanner); auto from = blocks.index(h); - assert(from == i); + assertx(from == i); scanner.finish( [&](const void* p, std::size_t size) { conservativeScan(p, size, [&](const void** addr, const void* ptr) { diff --git a/hphp/runtime/base/heap-report.cpp b/hphp/runtime/base/heap-report.cpp index 4559d3f6e04..bf7389a8f40 100644 --- a/hphp/runtime/base/heap-report.cpp +++ b/hphp/runtime/base/heap-report.cpp @@ -225,7 +225,7 @@ bool checkPointers(const HeapGraph& g, const char* phase) { auto& node = g.nodes[n]; if (!haveCount(node.h->kind())) continue; auto count = static_cast(node.h)->count(); - assert(count >= 0); // static things shouldn't be in the heap. + assertx(count >= 0); // static things shouldn't be in the heap. unsigned num_counted{0}, num_ambig{0}; g.eachPred(n, [&](const HeapGraph::Ptr& ptr) { switch (ptr.ptr_kind) { @@ -251,7 +251,7 @@ bool checkPointers(const HeapGraph& g, const char* phase) { traceToRoot(g, n, ""); } } - assert(!found_dangling && "found dangling pointers"); + assertx(!found_dangling && "found dangling pointers"); return true; } diff --git a/hphp/runtime/base/heap-scan.h b/hphp/runtime/base/heap-scan.h index d2436fc415e..5d770e16b23 100644 --- a/hphp/runtime/base/heap-scan.h +++ b/hphp/runtime/base/heap-scan.h @@ -78,7 +78,7 @@ inline void scanNative(const NativeNode* node, type_scan::Scanner& scanner) { } inline void scanAFWH(const c_Awaitable* wh, type_scan::Scanner& scanner) { - assert(!wh->hasNativeData()); + assertx(!wh->hasNativeData()); // scan ResumableHeader before object auto r = Resumable::FromObj(wh); if (!wh->isFinished()) { @@ -178,7 +178,7 @@ inline void c_AwaitAllWaitHandle::scan(type_scan::Scanner& scanner) const { } inline void c_Awaitable::scan(type_scan::Scanner& scanner) const { - assert(kind() != HeaderKind::AwaitAllWH); + assertx(kind() != HeaderKind::AwaitAllWH); auto const size = kind() == HeaderKind::AsyncFuncWH ? sizeof(c_AsyncFunctionWaitHandle) : asio_object_size(this); diff --git a/hphp/runtime/base/hhprof.cpp b/hphp/runtime/base/hhprof.cpp index 2a6416266f5..c9a438eaded 100644 --- a/hphp/runtime/base/hhprof.cpp +++ b/hphp/runtime/base/hhprof.cpp @@ -42,7 +42,7 @@ static std::shared_ptr hhprof() { // Centralize try_get() calls to document that despite the scary name, it // won't fail under any conditions we subject it to. std::shared_ptr h = s_hhprof.try_get(); - assert(h.get() != nullptr); + assertx(h.get() != nullptr); return h; } diff --git a/hphp/runtime/base/ini-setting.cpp b/hphp/runtime/base/ini-setting.cpp index 6089da024ef..0dc2b9c3443 100644 --- a/hphp/runtime/base/ini-setting.cpp +++ b/hphp/runtime/base/ini-setting.cpp @@ -481,7 +481,7 @@ IniSettingMap::IniSettingMap(IniSettingMap&& i) noexcept { } const IniSettingMap IniSettingMap::operator[](const String& key) const { - assert(this->isArray()); + assertx(this->isArray()); return IniSettingMap(m_map.toCArrRef()[key]); } @@ -507,7 +507,7 @@ void mergeSettings(member_lval curval, TypedValue v) { } void IniSettingMap::set(const String& key, const Variant& v) { - assert(this->isArray()); + assertx(this->isArray()); auto const curval = m_map.toArrRef().lvalAt(key); mergeSettings(curval, *v.asTypedValue()); } @@ -564,9 +564,9 @@ void IniSetting::ParserCallback::onPopEntry( void IniSetting::ParserCallback::makeArray(Variant& hash, const std::string& offset, const std::string& value) { - assert(!offset.empty()); + assertx(!offset.empty()); Variant *val = &hash; - assert(val->isArray()); + assertx(val->isArray()); auto start = offset.c_str(); auto p = start; bool last = false; @@ -591,12 +591,12 @@ void IniSetting::ParserCallback::makeSettingSub(const String& key, const std::string& offset, const std::string& value, Variant& cur_settings) { - assert(offset.size() == 1 || + assertx(offset.size() == 1 || (offset.size() >=2 && offset[offset.size()-2] == 0)); auto type = offset.substr(offset.size() - 1); - assert(type == ":" || type == "@"); + assertx(type == ":" || type == "@"); std::vector copy_name_parts = split_brackets(value); - assert(!copy_name_parts.empty()); + assertx(!copy_name_parts.empty()); Variant* base = &cur_settings; bool skip = false; for (auto& part : copy_name_parts) { @@ -632,9 +632,9 @@ void IniSetting::ParserCallback::traverseToSet(const String &key, Variant& value, Variant& cur_settings, const std::string& stopChar) { - assert(stopChar == "@" || stopChar == ":"); - assert(offset != stopChar); - assert(cur_settings.isArray()); + assertx(stopChar == "@" || stopChar == ":"); + assertx(offset != stopChar); + assertx(cur_settings.isArray()); auto isSymlink = stopChar == ":"; auto start = offset.c_str(); auto p = start; @@ -736,7 +736,7 @@ void IniSetting::SectionParserCallback::onPopEntry( void IniSetting::SystemParserCallback::onEntry( const std::string &key, const std::string &value, void *arg) { - assert(!key.empty()); + assertx(!key.empty()); // onConstant will always be called before onEntry, so we can check // here if (IniSetting::s_config_is_a_constant) { @@ -751,7 +751,7 @@ void IniSetting::SystemParserCallback::onPopEntry(const std::string& key, const std::string& value, const std::string& offset, void* arg) { - assert(!key.empty()); + assertx(!key.empty()); if (IniSetting::s_config_is_a_constant) { IniSetting::config_names_that_use_constants.insert(key); IniSetting::s_config_is_a_constant = false; @@ -825,7 +825,7 @@ IniSettingMap IniSetting::FromStringAsMap(const std::string& ini, Variant IniSetting::Unbox(const Variant& boxed, std::set& seen, bool& use_defaults, const String& array_key) { - assert(boxed.isArray()); + assertx(boxed.isArray()); Variant unboxed(Array::Create()); auto ad = boxed.getArrayData(); if (seen.insert(ad).second) { @@ -833,7 +833,7 @@ Variant IniSetting::Unbox(const Variant& boxed, std::set& seen, auto key = it.first(); // asserting here to ensure that key is a scalar type that can be // converted to a string. - assert(key.isScalar()); + assertx(key.isScalar()); auto& elem = tvAsCVarRef(it.secondRval().tv_ptr()); unboxed.asArrRef().set( key, @@ -924,7 +924,7 @@ struct IniSettingExtension final : Extension { // s_saved_defaults should be clear at the beginning of any request void requestInit() override { - assert(!s_saved_defaults->settings.hasValue()); + assertx(!s_saved_defaults->settings.hasValue()); } } s_ini_extension; @@ -936,7 +936,7 @@ void IniSetting::Bind( std::function getCallback, std::function userDataCallback ) { - assert(!name.empty()); + assertx(!name.empty()); /* * WATCH OUT: unlike php5, a Mode is not necessarily a bit mask. @@ -958,7 +958,7 @@ void IniSetting::Bind( ); } else { is_thread_local = (mode == PHP_INI_USER || mode == PHP_INI_ALL); - assert(is_thread_local || !ExtensionRegistry::modulesInitialised() || + assertx(is_thread_local || !ExtensionRegistry::modulesInitialised() || !s_system_settings_are_set); } // @@ -1012,7 +1012,7 @@ void IniSetting::Bind( } void IniSetting::Unbind(const std::string& name) { - assert(!name.empty()); + assertx(!name.empty()); s_user_callbacks->erase(name); } @@ -1095,7 +1095,7 @@ bool IniSetting::FillInConstant(const std::string& name, bool IniSetting::SetSystem(const String& name, const Variant& value) { // Shouldn't be calling this function after the runtime options are loaded. - assert(!s_system_settings_are_set); + assertx(!s_system_settings_are_set); // Since we're going to keep these settings for the lifetime of the program, // we need to make them static. Variant eval_scalar_variant = value; diff --git a/hphp/runtime/base/init-fini-node.h b/hphp/runtime/base/init-fini-node.h index 5491691376a..8f50713f9ba 100644 --- a/hphp/runtime/base/init-fini-node.h +++ b/hphp/runtime/base/init-fini-node.h @@ -96,12 +96,12 @@ struct InitFiniNode { static InitFiniNode*& node(When when) { auto idx = static_cast(when); - assert(idx < NumNodes); + assertx(idx < NumNodes); return s_nodes[idx]; } static IFDispatcher*& dispatcher(When when) { auto idx = static_cast(when); - assert(idx < NumNodes); + assertx(idx < NumNodes); return s_dispatcher[idx]; } void (*func)(); diff --git a/hphp/runtime/base/intercept.cpp b/hphp/runtime/base/intercept.cpp index 722cdbbfad2..a7dd40b1b5c 100644 --- a/hphp/runtime/base/intercept.cpp +++ b/hphp/runtime/base/intercept.cpp @@ -176,7 +176,7 @@ Variant *get_intercept_handler(const String& name, int8_t* flag) { if (handler == nullptr) { return nullptr; } - assert(*flag); + assertx(*flag); return handler; } diff --git a/hphp/runtime/base/libevent-http-client.cpp b/hphp/runtime/base/libevent-http-client.cpp index f1a3bbf9b59..a431b9e1e56 100644 --- a/hphp/runtime/base/libevent-http-client.cpp +++ b/hphp/runtime/base/libevent-http-client.cpp @@ -34,13 +34,13 @@ struct evkeyvalq_ { // static handlers delegating work to instance ones static void on_request_completed(struct evhttp_request *req, void *obj) { - assert(obj); + assertx(obj); ((HPHP::LibEventHttpClient*)obj)->onRequestCompleted(req); } static void on_connection_closed(struct evhttp_connection* /*conn*/, void* obj) { - assert(obj); + assertx(obj); ((HPHP::LibEventHttpClient*)obj)->onConnectionClosed(); } diff --git a/hphp/runtime/base/mem-file.cpp b/hphp/runtime/base/mem-file.cpp index 8cd5c34e3e4..66e4120c3be 100644 --- a/hphp/runtime/base/mem-file.cpp +++ b/hphp/runtime/base/mem-file.cpp @@ -53,7 +53,7 @@ void MemFile::sweep() { } bool MemFile::open(const String& filename, const String& mode) { - assert(m_len == -1); + assertx(m_len == -1); // mem files are read-only const char* mode_str = mode.c_str(); if (strchr(mode_str, '+') || strchr(mode_str, 'a') || strchr(mode_str, 'w')) { @@ -65,9 +65,9 @@ bool MemFile::open(const String& filename, const String& mode) { StaticContentCache::TheFileCache->read(filename.c_str(), len, compressed); // -1: PHP file; -2: directory if (len != INT_MIN && len != -1 && len != -2) { - assert(len >= 0); + assertx(len >= 0); if (compressed) { - assert(RuntimeOption::EnableOnDemandUncompress); + assertx(RuntimeOption::EnableOnDemandUncompress); data = gzdecode(data, len); if (data == nullptr) { raise_fatal_error("cannot unzip compressed data"); @@ -108,8 +108,8 @@ bool MemFile::closeImpl() { /////////////////////////////////////////////////////////////////////////////// int64_t MemFile::readImpl(char *buffer, int64_t length) { - assert(m_len != -1); - assert(length > 0); + assertx(m_len != -1); + assertx(length > 0); int64_t remaining = m_len - m_cursor; if (remaining < length) length = remaining; if (length > 0) { @@ -120,12 +120,12 @@ int64_t MemFile::readImpl(char *buffer, int64_t length) { } int MemFile::getc() { - assert(m_len != -1); + assertx(m_len != -1); return File::getc(); } bool MemFile::seek(int64_t offset, int whence /* = SEEK_SET */) { - assert(m_len != -1); + assertx(m_len != -1); if (whence == SEEK_CUR) { if (offset > 0 && offset < bufferedLen()) { setReadPosition(getReadPosition() + offset); @@ -142,7 +142,7 @@ bool MemFile::seek(int64_t offset, int whence /* = SEEK_SET */) { if (whence == SEEK_SET) { m_cursor = offset; } else { - assert(whence == SEEK_END); + assertx(whence == SEEK_END); m_cursor = m_len + offset; } setPosition(m_cursor); @@ -150,12 +150,12 @@ bool MemFile::seek(int64_t offset, int whence /* = SEEK_SET */) { } int64_t MemFile::tell() { - assert(m_len != -1); + assertx(m_len != -1); return getPosition(); } bool MemFile::eof() { - assert(m_len != -1); + assertx(m_len != -1); int64_t avail = bufferedLen(); if (avail > 0) { return false; @@ -164,7 +164,7 @@ bool MemFile::eof() { } bool MemFile::rewind() { - assert(m_len != -1); + assertx(m_len != -1); m_cursor = 0; setWritePosition(0); setReadPosition(0); @@ -194,9 +194,9 @@ Array MemFile::getMetaData() { /////////////////////////////////////////////////////////////////////////////// void MemFile::unzip() { - assert(m_len != -1); - assert(!m_malloced); - assert(m_cursor == 0); + assertx(m_len != -1); + assertx(!m_malloced); + assertx(m_cursor == 0); int len = m_len; char *data = gzdecode(m_data, len); if (data == nullptr) { diff --git a/hphp/runtime/base/memory-manager-defs.h b/hphp/runtime/base/memory-manager-defs.h index a3576231144..a338f5bff6a 100644 --- a/hphp/runtime/base/memory-manager-defs.h +++ b/hphp/runtime/base/memory-manager-defs.h @@ -97,7 +97,7 @@ struct alignas(kSmallSizeAlign) Slab : HeapObject { HeapObject* find(const void* ptr) const; static Slab* fromHeader(HeapObject* h) { - assert(h->kind() == HeaderKind::Slab); + assertx(h->kind() == HeaderKind::Slab); return reinterpret_cast(h); } @@ -109,7 +109,7 @@ struct alignas(kSmallSizeAlign) Slab : HeapObject { static Slab* fromPtr(const void* p) { static_assert(kSlabAlign == kSlabSize, ""); auto slab = reinterpret_cast(uintptr_t(p) & ~(kSlabAlign - 1)); - assert(slab->kind() == HeaderKind::Slab); + assertx(slab->kind() == HeaderKind::Slab); return slab; } @@ -155,7 +155,7 @@ static_assert(kMaxSmallSize < kSlabSize - sizeof(Slab), "kMaxSmallSize must fit in Slab"); inline const Resumable* resumable(const HeapObject* h) { - assert(h->kind() == HeaderKind::AsyncFuncFrame); + assertx(h->kind() == HeaderKind::AsyncFuncFrame); auto native = static_cast(h); return reinterpret_cast( (const char*)native + native->obj_offset - sizeof(Resumable) @@ -163,7 +163,7 @@ inline const Resumable* resumable(const HeapObject* h) { } inline Resumable* resumable(HeapObject* h) { - assert(h->kind() == HeaderKind::AsyncFuncFrame); + assertx(h->kind() == HeaderKind::AsyncFuncFrame); auto native = static_cast(h); return reinterpret_cast( (char*)native + native->obj_offset - sizeof(Resumable) @@ -171,38 +171,38 @@ inline Resumable* resumable(HeapObject* h) { } inline const c_Awaitable* asyncFuncWH(const HeapObject* h) { - assert(resumable(h)->actRec()->func()->isAsyncFunction()); + assertx(resumable(h)->actRec()->func()->isAsyncFunction()); auto native = static_cast(h); auto obj = reinterpret_cast( (const char*)native + native->obj_offset ); - assert(obj->headerKind() == HeaderKind::AsyncFuncWH); + assertx(obj->headerKind() == HeaderKind::AsyncFuncWH); return obj; } inline c_Awaitable* asyncFuncWH(HeapObject* h) { - assert(resumable(h)->actRec()->func()->isAsyncFunction()); + assertx(resumable(h)->actRec()->func()->isAsyncFunction()); auto native = static_cast(h); auto obj = reinterpret_cast( (char*)native + native->obj_offset ); - assert(obj->headerKind() == HeaderKind::AsyncFuncWH); + assertx(obj->headerKind() == HeaderKind::AsyncFuncWH); return obj; } inline const ObjectData* closureObj(const HeapObject* h) { - assert(h->kind() == HeaderKind::ClosureHdr); + assertx(h->kind() == HeaderKind::ClosureHdr); auto closure_hdr = static_cast(h); auto obj = reinterpret_cast(closure_hdr + 1); - assert(obj->headerKind() == HeaderKind::Closure); + assertx(obj->headerKind() == HeaderKind::Closure); return obj; } inline ObjectData* closureObj(HeapObject* h) { - assert(h->kind() == HeaderKind::ClosureHdr); + assertx(h->kind() == HeaderKind::ClosureHdr); auto closure_hdr = static_cast(h); auto obj = reinterpret_cast(closure_hdr + 1); - assert(obj->headerKind() == HeaderKind::Closure); + assertx(obj->headerKind() == HeaderKind::Closure); return obj; } @@ -368,8 +368,8 @@ inline size_t allocSize(const HeapObject* h) { auto obj = static_cast(h); auto whKind = wait_handle(obj)->getKind(); size = waithandle_sizes[(int)whKind]; - assert(size != 0); // AsyncFuncFrame or AwaitAllWH - assert(size == MemoryManager::sizeClass(size)); + assertx(size != 0); // AsyncFuncFrame or AwaitAllWH + assertx(size == MemoryManager::sizeClass(size)); return size; } case HeaderKind::AwaitAllWH: @@ -405,14 +405,14 @@ inline size_t allocSize(const HeapObject* h) { case HeaderKind::BigObj: // [MallocNode][HeapObject...] case HeaderKind::BigMalloc: // [MallocNode][raw bytes...] size = static_cast(h)->nbytes; - assert(size != 0); + assertx(size != 0); // not rounded up to size class, because we never need to iterate over // more than one allocated block. avoid calling nallocx(). return size; case HeaderKind::Free: case HeaderKind::Hole: size = static_cast(h)->size(); - assert(size != 0); + assertx(size != 0); // Free objects are guaranteed to be already size-class aligned. // Holes are not size-class aligned, so neither need to be rounded up. return size; @@ -490,7 +490,7 @@ inline void Slab::setStarts(const void* start, const void* end, auto const nbits = nbytes / kSmallSizeAlign; if (nbits <= kBitsPerStart && start_bit / kBitsPerStart < end_bit / kBitsPerStart) { - assert(index < kNumMasks); + assertx(index < kNumMasks); auto const mask = masks_[index]; size_t const k = shifts_[index]; // initially n = how much mask should be shifted to line up with start_bit @@ -527,12 +527,12 @@ void SparseHeap::iterate(OnBig onBig, OnSlab onSlab) { while (slab != slabend || big != bigend) { HeapObject* slab_hdr = slab != slabend ? (HeapObject*)slab->ptr : SENTINEL; HeapObject* big_hdr = big != bigend ? *big : SENTINEL; - assert(slab_hdr < SENTINEL || big_hdr < SENTINEL); + assertx(slab_hdr < SENTINEL || big_hdr < SENTINEL); if (slab_hdr < big_hdr) { onSlab(slab_hdr, slab->size); ++slab; } else { - assert(big_hdr < slab_hdr); + assertx(big_hdr < slab_hdr); onBig(big_hdr, allocSize(big_hdr)); ++big; } @@ -549,13 +549,13 @@ template void SparseHeap::iterate(Fn fn) { while (slab != slabend || big != bigend) { HeapObject* slab_hdr = slab != slabend ? (HeapObject*)slab->ptr : SENTINEL; HeapObject* big_hdr = big != bigend ? *big : SENTINEL; - assert(slab_hdr < SENTINEL || big_hdr < SENTINEL); + assertx(slab_hdr < SENTINEL || big_hdr < SENTINEL); HeapObject *h, *end; if (slab_hdr < big_hdr) { h = slab_hdr; end = (HeapObject*)((char*)h + slab->size); ++slab; - assert(end <= big_hdr); // otherwise slab overlaps next big + assertx(end <= big_hdr); // otherwise slab overlaps next big } else { h = big_hdr; end = nullptr; // ensure we don't loop below @@ -566,7 +566,7 @@ template void SparseHeap::iterate(Fn fn) { fn(h, size); h = (HeapObject*)((char*)h + size); } while (h < end); - assert(!end || h == end); // otherwise, last object was truncated + assertx(!end || h == end); // otherwise, last object was truncated } } @@ -577,7 +577,7 @@ template void MemoryManager::iterate(Fn fn) { h = static_cast(h) + 1; allocSize -= sizeof(MallocNode); } else if (h->kind() >= HeaderKind::Hole) { - assert(unsigned(h->kind()) < NumHeaderKinds); + assertx(unsigned(h->kind()) < NumHeaderKinds); // no valid pointer can point here. return; // continue iterating } @@ -619,8 +619,8 @@ template void MemoryManager::sweepApcStrings(Fn fn) { auto& head = getStringList(); for (StringDataNode *next, *n = head.next; n != &head; n = next) { next = n->next; - assert(next && uintptr_t(next) != kSmallFreeWord); - assert(next && uintptr_t(next) != kMallocFreeWord); + assertx(next && uintptr_t(next) != kSmallFreeWord); + assertx(next && uintptr_t(next) != kMallocFreeWord); auto const s = StringData::node2str(n); if (fn(s)) { s->unProxy(); diff --git a/hphp/runtime/base/memory-manager-inl.h b/hphp/runtime/base/memory-manager-inl.h index 69fab655d13..450a8e6fc27 100644 --- a/hphp/runtime/base/memory-manager-inl.h +++ b/hphp/runtime/base/memory-manager-inl.h @@ -145,8 +145,8 @@ inline void MemoryManager::FreeList::push(void* val) { /////////////////////////////////////////////////////////////////////////////// inline size_t MemoryManager::computeSize2Index(size_t size) { - assert(size > 1); - assert(size <= kMaxSizeClass); + assertx(size > 1); + assertx(size <= kMaxSizeClass); // We want to round size up to the nearest size class, and return the index // of that size class. The first 1 << kLgSizeClassesPerDoubling size classes // are denormal; their sizes are (class + 1) << kLgSmallSizeQuantum. @@ -172,20 +172,20 @@ inline size_t MemoryManager::computeSize2Index(size_t size) { size_t exp = nBits - (kLgSizeClassesPerDoubling + kLgSmallSizeQuantum); size_t rawMantissa = size >> (nBits - kLgSizeClassesPerDoubling); size_t index = (exp << kLgSizeClassesPerDoubling) + rawMantissa; - assert(index < kNumSizeClasses); + assertx(index < kNumSizeClasses); return index; } inline size_t MemoryManager::lookupSmallSize2Index(size_t size) { - assert(size > 0); - assert(size <= kMaxSmallSizeLookup); + assertx(size > 0); + assertx(size <= kMaxSmallSizeLookup); auto const index = kSmallSize2Index[(size-1) >> kLgSmallSizeQuantum]; return index; } inline size_t MemoryManager::size2Index(size_t size) { - assert(size > 0); - assert(size <= kMaxSizeClass); + assertx(size > 0); + assertx(size <= kMaxSizeClass); if (LIKELY(size <= kMaxSmallSizeLookup)) { return lookupSmallSize2Index(size); } @@ -197,16 +197,16 @@ inline size_t MemoryManager::sizeIndex2Size(size_t index) { } inline size_t MemoryManager::sizeClass(size_t size) { - assert(size > 1); - assert(size <= kMaxSizeClass); + assertx(size > 1); + assertx(size <= kMaxSizeClass); // Round up to the nearest kLgSizeClassesPerDoubling + 1 significant bits, // or to the nearest kLgSmallSizeQuantum, whichever is greater. ssize_t nInsignificantBits = fls64(--size) - kLgSizeClassesPerDoubling; size_t roundTo = (nInsignificantBits < ssize_t(kLgSmallSizeQuantum)) ? kLgSmallSizeQuantum : nInsignificantBits; size_t ret = ((size >> roundTo) + 1) << roundTo; - assert(ret >= kSmallSizeAlign); - assert(ret <= kMaxSizeClass); + assertx(ret >= kSmallSizeAlign); + assertx(ret <= kMaxSizeClass); return ret; } @@ -215,7 +215,7 @@ inline void* MemoryManager::mallocSmallIndex(size_t index) { } inline void* MemoryManager::mallocSmallIndexSize(size_t index, size_t bytes) { - assert(index < kNumSmallSizes); + assertx(index < kNumSmallSizes); if (debug) requestEagerGC(); m_stats.mm_debt -= bytes; @@ -230,22 +230,22 @@ void* MemoryManager::mallocSmallIndexTail(size_t bytes, size_t index) { if (!p) { p = mallocSmallSizeSlow(bytes, index); } - assert((reinterpret_cast(p) & kSmallSizeAlignMask) == 0); + assertx((reinterpret_cast(p) & kSmallSizeAlignMask) == 0); FTRACE(3, "mallocSmallIndex: {} -> {}\n", bytes, p); return p; } inline void* MemoryManager::mallocSmallSize(size_t bytes) { - assert(bytes > 0); - assert(bytes <= kMaxSmallSize); + assertx(bytes > 0); + assertx(bytes <= kMaxSmallSize); // mallocSmallIndex() converts the size index back to a size to track the // size class's actual size, rather than the requested size. return mallocSmallIndex(size2Index(bytes)); } inline void MemoryManager::freeSmallIndex(void* ptr, size_t index) { - assert(index < kNumSmallSizes); - assert((reinterpret_cast(ptr) & kSmallSizeAlignMask) == 0); + assertx(index < kNumSmallSizes); + assertx((reinterpret_cast(ptr) & kSmallSizeAlignMask) == 0); if (UNLIKELY(m_bypassSlabAlloc)) { --currentSmallAllocs[index]; @@ -293,7 +293,7 @@ void MemoryManager::objFreeIndex(void* ptr, size_t index) { inline int64_t MemoryManager::getAllocated() const { if (use_jemalloc) { - assert(m_allocated); + assertx(m_allocated); return *m_allocated; } return 0; @@ -301,7 +301,7 @@ inline int64_t MemoryManager::getAllocated() const { inline int64_t MemoryManager::getDeallocated() const { if (use_jemalloc) { - assert(m_deallocated); + assertx(m_deallocated); return *m_deallocated; } else { return 0; @@ -335,7 +335,7 @@ inline bool MemoryManager::startStatsInterval() { // negative. Make sure that doesn't occur here. m_stats.peakIntervalUsage = std::max(0, stats.usage()); m_stats.peakIntervalCap = m_stats.capacity(); - assert(m_stats.peakIntervalCap >= 0); + assertx(m_stats.peakIntervalCap >= 0); m_statsIntervalActive = true; return ret; } diff --git a/hphp/runtime/base/memory-manager.cpp b/hphp/runtime/base/memory-manager.cpp index 09cbc78b72f..a346efea95a 100644 --- a/hphp/runtime/base/memory-manager.cpp +++ b/hphp/runtime/base/memory-manager.cpp @@ -200,7 +200,7 @@ void MemoryManager::resetExternalStats() { traceStats("resetExternalStats pre"); // extUsage and totalAlloc are only set by refreshStatsImpl, which we don't // enable until after this has been called. - assert(m_enableStatsSync || + assertx(m_enableStatsSync || (m_stats.extUsage == 0 && m_stats.totalAlloc == 0)); m_enableStatsSync = s_statsEnabled; // false if !use_jemalloc if (s_statsEnabled) { @@ -250,8 +250,8 @@ void MemoryManager::refreshStatsImpl(MemoryUsageStats& stats) { // code may well substantially exceed m_stats.usage. if (m_enableStatsSync) { // We can't currently handle wrapping so make sure this isn't happening. - assert(*m_allocated <= uint64_t(std::numeric_limits::max())); - assert(*m_deallocated <= uint64_t(std::numeric_limits::max())); + assertx(*m_allocated <= uint64_t(std::numeric_limits::max())); + assertx(*m_deallocated <= uint64_t(std::numeric_limits::max())); const int64_t curAllocated = *m_allocated; const int64_t curDeallocated = *m_deallocated; @@ -281,7 +281,7 @@ void MemoryManager::refreshStatsImpl(MemoryUsageStats& stats) { FTRACE(1, "heap-id {} after sync extUsage {} totalAlloc: {}\n", tl_heap_id, stats.extUsage, stats.totalAlloc); } - assert(m_usageLimit > 0); + assertx(m_usageLimit > 0); auto usage = stats.usage(); stats.peakUsage = std::max(stats.peakUsage, usage); if (m_statsIntervalActive) { @@ -319,7 +319,7 @@ void MemoryManager::updateMMDebt() } void MemoryManager::sweep() { - assert(!sweeping()); + assertx(!sweeping()); tl_sweeping = true; DEBUG_ONLY size_t num_sweepables = 0, num_natives = 0; @@ -334,14 +334,14 @@ void MemoryManager::sweep() { } while (!m_natives.empty()) { num_natives++; - assert(m_natives.back()->sweep_index == m_natives.size() - 1); + assertx(m_natives.back()->sweep_index == m_natives.size() - 1); auto node = m_natives.back(); m_natives.pop_back(); auto obj = Native::obj(node); auto ndi = obj->getVMClass()->getNativeDataInfo(); ndi->sweep(obj); // trash the native data but leave the header and object parsable - assert(memset(node+1, kSmallFreeFill, node->obj_offset - sizeof(*node))); + assertx(memset(node+1, kSmallFreeFill, node->obj_offset - sizeof(*node))); } } while (!m_sweepables.empty()); @@ -366,7 +366,7 @@ void MemoryManager::sweep() { } void MemoryManager::resetAllocator() { - assert(m_natives.empty() && m_sweepables.empty() && tl_sweeping); + assertx(m_natives.empty() && m_sweepables.empty() && tl_sweeping); // decref apc strings referenced by this request DEBUG_ONLY auto nstrings = StringData::sweepAll(); FTRACE(1, "heap-id {} resetAllocator: strings {}\n", tl_heap_id, nstrings); @@ -478,7 +478,7 @@ void MemoryManager::reinitFree() { if (debug) { // ensure the freelist tail is already initialized. for (; n; n = n->next) { - assert(n->kind() == HeaderKind::Free && n->size() == size); + assertx(n->kind() == HeaderKind::Free && n->size() == size); } } } @@ -565,7 +565,7 @@ void MemoryManager::checkHeap(const char* phase) { case HeaderKind::BigObj: case HeaderKind::Hole: case HeaderKind::Slab: - assert(false && "forEachHeapObject skips these kinds"); + assertx(false && "forEachHeapObject skips these kinds"); break; } }); @@ -575,17 +575,17 @@ void MemoryManager::checkHeap(const char* phase) { size_t num_free_blocks = 0; for (auto i = 0; i < kNumSmallSizes; i++) { for (auto n = m_freelists[i].head; n; n = n->next) { - assert(free_blocks.isStart(n)); + assertx(free_blocks.isStart(n)); ++num_free_blocks; } } - assert(num_free_blocks == free_blocks.size()); + assertx(num_free_blocks == free_blocks.size()); // check the apc array list - assert(apc_arrays.size() == m_apc_arrays.size()); + assertx(apc_arrays.size() == m_apc_arrays.size()); apc_arrays.prepare(); for (UNUSED auto a : m_apc_arrays) { - assert(apc_arrays.isStart(a)); + assertx(apc_arrays.isStart(a)); } // check the apc string list @@ -594,11 +594,11 @@ void MemoryManager::checkHeap(const char* phase) { for (StringDataNode *next, *n = m_strings.next; n != &m_strings; n = next) { next = n->next; UNUSED auto const s = StringData::node2str(n); - assert(s->isProxy()); - assert(apc_strings.isStart(s)); + assertx(s->isProxy()); + assertx(apc_strings.isStart(s)); ++num_apc_strings; } - assert(num_apc_strings == apc_strings.size()); + assertx(num_apc_strings == apc_strings.size()); // heap check is done. If we are not exiting, check pointers using HeapGraph if (Trace::moduleEnabled(Trace::heapreport)) { @@ -684,8 +684,8 @@ void storeTail(FreelistArray& freelists, void* tail, size_t tailBytes, void* rem = tail; for (auto remBytes = tailBytes; remBytes > 0;) { auto fragBytes = remBytes; - assert(fragBytes >= kSmallSizeAlign); - assert((fragBytes & kSmallSizeAlignMask) == 0); + assertx(fragBytes >= kSmallSizeAlign); + assertx((fragBytes & kSmallSizeAlignMask) == 0); auto fragInd = MemoryManager::size2Index(fragBytes + 1) - 1; auto fragUsable = MemoryManager::sizeIndex2Size(fragInd); auto frag = FreeNode::InitFrom((char*)rem + remBytes - fragUsable, @@ -710,10 +710,10 @@ inline void splitTail(FreelistArray& freelists, void* tail, size_t tailBytes, size_t split_bytes, size_t splitUsable, size_t index, Slab* slab) { - assert(tailBytes >= kSmallSizeAlign); - assert((tailBytes & kSmallSizeAlignMask) == 0); - assert((splitUsable & kSmallSizeAlignMask) == 0); - assert(split_bytes <= tailBytes); + assertx(tailBytes >= kSmallSizeAlign); + assertx((tailBytes & kSmallSizeAlignMask) == 0); + assertx((splitUsable & kSmallSizeAlignMask) == 0); + assertx(split_bytes <= tailBytes); // initialize the free objects, and push them onto the freelist. auto head = freelists[index].head; @@ -732,7 +732,7 @@ void splitTail(FreelistArray& freelists, void* tail, size_t tailBytes, slab->setStarts(tail, rem, splitUsable, index); auto remBytes = tailBytes - split_bytes; - assert(uintptr_t(rem) + remBytes == uintptr_t(tail) + tailBytes); + assertx(uintptr_t(rem) + remBytes == uintptr_t(tail) + tailBytes); storeTail(freelists, rem, remBytes, slab); } } @@ -766,9 +766,9 @@ NEVER_INLINE void* MemoryManager::newSlab(size_t nbytes) { inline void* MemoryManager::slabAlloc(size_t nbytes, size_t index) { FTRACE(3, "slabAlloc({}, {}): m_front={}, m_limit={}\n", nbytes, index, m_front, m_limit); - assert(nbytes == sizeIndex2Size(index)); - assert(nbytes <= kSlabSize); - assert((uintptr_t(m_front) & kSmallSizeAlignMask) == 0); + assertx(nbytes == sizeIndex2Size(index)); + assertx(nbytes <= kSlabSize); + assertx((uintptr_t(m_front) & kSmallSizeAlignMask) == 0); if (UNLIKELY(m_bypassSlabAlloc)) { totalSmallAllocs.resize(kNumSmallSizes, 0); @@ -822,16 +822,16 @@ void* MemoryManager::mallocSmallIndexSlow(size_t bytes, size_t index) { } void* MemoryManager::mallocSmallSizeSlow(size_t nbytes, size_t index) { - assert(nbytes == sizeIndex2Size(index)); - assert(!m_freelists[index].head); // freelist[index] is empty + assertx(nbytes == sizeIndex2Size(index)); + assertx(!m_freelists[index].head); // freelist[index] is empty size_t contigInd = kContigIndexTab[index]; for (auto i = contigInd; i < kNumSmallSizes; ++i) { FTRACE(4, "MemoryManager::mallocSmallSizeSlow({}, {}): contigMin={}, " "contigInd={}, try i={}\n", nbytes, index, kContigTab[index], contigInd, i); if (auto p = m_freelists[i].unlikelyPop()) { - assert(i > index); // because freelist[index] was empty - assert(Slab::fromPtr(p)->isStart(p)); + assertx(i > index); // because freelist[index] was empty + assertx(Slab::fromPtr(p)->isStart(p)); FTRACE(4, "MemoryManager::mallocSmallSizeSlow({}, {}): " "contigMin={}, contigInd={}, use i={}, size={}, p={}\n", nbytes, index, kContigTab[index], contigInd, i, @@ -878,7 +878,7 @@ void* MemoryManager::mallocBigSize( ); void* MemoryManager::resizeBig(MallocNode* n, size_t nbytes) { - assert(n->kind() == HeaderKind::BigMalloc); + assertx(n->kind() == HeaderKind::BigMalloc); auto block = m_heap.resizeBig(n + 1, nbytes, m_stats); updateBigStats(); return block; @@ -912,12 +912,12 @@ static void* allocate(size_t nbytes, type_scan::Index ty) { } void* malloc(size_t nbytes, type_scan::Index tyindex) { - assert(type_scan::isKnownType(tyindex)); + assertx(type_scan::isKnownType(tyindex)); return allocate(nbytes, tyindex); } void* calloc(size_t count, size_t nbytes, type_scan::Index tyindex) { - assert(type_scan::isKnownType(tyindex)); + assertx(type_scan::isKnownType(tyindex)); return allocate(count * nbytes, tyindex); } @@ -938,7 +938,7 @@ void* calloc_untyped(size_t count, size_t bytes) { } void* realloc(void* ptr, size_t nbytes, type_scan::Index tyindex) { - assert(type_scan::isKnownType(tyindex)); + assertx(type_scan::isKnownType(tyindex)); if (!ptr) { return allocate(nbytes, tyindex); } @@ -949,7 +949,7 @@ void* realloc(void* ptr, size_t nbytes, type_scan::Index tyindex) { FTRACE(3, "MemoryManager::realloc: {} to {} [type_index: {}]\n", ptr, nbytes, tyindex); auto const n = static_cast(ptr) - 1; - assert(n->typeIndex() == tyindex); + assertx(n->typeIndex() == tyindex); if (LIKELY(n->kind() == HeaderKind::SmallMalloc) || UNLIKELY(nbytes + sizeof(MallocNode) <= kMaxSmallSize)) { // either the old or new block will be small; force a copy. @@ -975,8 +975,8 @@ void* realloc_untyped(void* ptr, size_t nbytes) { FTRACE(3, "MemoryManager::realloc: {} to {} [type_index: {}]\n", ptr, nbytes, type_scan::kIndexUnknown); auto const n = static_cast(ptr) - 1; - assert(n->kind() == HeaderKind::BigMalloc); - assert(n->typeIndex() == type_scan::kIndexUnknown); + assertx(n->kind() == HeaderKind::BigMalloc); + assertx(n->typeIndex() == type_scan::kIndexUnknown); return tl_heap->resizeBig(n, nbytes); } @@ -999,7 +999,7 @@ void free(void* ptr) { if (n->kind() == HeaderKind::Cpp) { return tl_heap->objFree(n, n->nbytes); } - assert(n->kind() == HeaderKind::BigMalloc); + assertx(n->kind() == HeaderKind::BigMalloc); tl_heap->freeBigSize(ptr); } @@ -1008,14 +1008,14 @@ void free(void* ptr) { ////////////////////////////////////////////////////////////////////// void MemoryManager::addNativeObject(NativeNode* node) { - if (debug) for (DEBUG_ONLY auto n : m_natives) assert(n != node); + if (debug) for (DEBUG_ONLY auto n : m_natives) assertx(n != node); node->sweep_index = m_natives.size(); m_natives.push_back(node); } void MemoryManager::removeNativeObject(NativeNode* node) { - assert(node->sweep_index < m_natives.size()); - assert(m_natives[node->sweep_index] == node); + assertx(node->sweep_index < m_natives.size()); + assertx(m_natives[node->sweep_index] == node); auto index = node->sweep_index; auto last = m_natives.back(); m_natives[index] = last; @@ -1029,8 +1029,8 @@ void MemoryManager::addApcArray(APCLocalArray* a) { } void MemoryManager::removeApcArray(APCLocalArray* a) { - assert(a->m_sweep_index < m_apc_arrays.size()); - assert(m_apc_arrays[a->m_sweep_index] == a); + assertx(a->m_sweep_index < m_apc_arrays.size()); + assertx(m_apc_arrays[a->m_sweep_index] == a); auto index = a->m_sweep_index; auto last = m_apc_arrays.back(); m_apc_arrays[index] = last; @@ -1083,7 +1083,7 @@ void MemoryManager::requestInit() { // Initialize the request-local context from the trigger. auto& profctx = tl_heap->m_profctx; - assert(!profctx.flag); + assertx(!profctx.flag); tl_heap->m_bypassSlabAlloc = true; profctx = *trigger; diff --git a/hphp/runtime/base/mixed-array-defs.h b/hphp/runtime/base/mixed-array-defs.h index 18c558b6c41..39589146089 100644 --- a/hphp/runtime/base/mixed-array-defs.h +++ b/hphp/runtime/base/mixed-array-defs.h @@ -68,7 +68,7 @@ MixedArray::copyElmsNextUnsafe(MixedArray* to, const MixedArray* from, extern int32_t* warnUnbalanced(MixedArray*, size_t n, int32_t* ei); inline bool MixedArray::isTombstone(ssize_t pos) const { - assert(size_t(pos) <= m_used); + assertx(size_t(pos) <= m_used); return isTombstone(data()[pos].data.m_type); } @@ -89,7 +89,7 @@ ALWAYS_INLINE void MixedArray::getArrayElm(ssize_t pos, TypedValue* valOut, TypedValue* keyOut) const { - assert(size_t(pos) < m_used); + assertx(size_t(pos) < m_used); auto& elm = data()[pos]; auto const cur = tvToCell(&elm.data); cellDup(*cur, *valOut); @@ -98,7 +98,7 @@ void MixedArray::getArrayElm(ssize_t pos, ALWAYS_INLINE void MixedArray::getArrayElm(ssize_t pos, TypedValue* valOut) const { - assert(size_t(pos) < m_used); + assertx(size_t(pos) < m_used); auto& elm = data()[pos]; auto const cur = tvToCell(&elm.data); cellDup(*cur, *valOut); @@ -106,7 +106,7 @@ void MixedArray::getArrayElm(ssize_t pos, TypedValue* valOut) const { ALWAYS_INLINE const TypedValue* MixedArray::getArrayElmPtr(ssize_t pos) const { - assert(validPos(pos)); + assertx(validPos(pos)); if (size_t(pos) >= m_used) return nullptr; auto& elm = data()[pos]; return !isTombstone(elm.data.m_type) ? &elm.data : nullptr; @@ -114,7 +114,7 @@ const TypedValue* MixedArray::getArrayElmPtr(ssize_t pos) const { ALWAYS_INLINE TypedValue MixedArray::getArrayElmKey(ssize_t pos) const { - assert(validPos(pos)); + assertx(validPos(pos)); if (size_t(pos) >= m_used) return make_tv(); auto& elm = data()[pos]; if (isTombstone(elm.data.m_type)) return make_tv(); @@ -131,8 +131,8 @@ void MixedArray::dupArrayElmWithRef(ssize_t pos, } inline ArrayData* MixedArray::addVal(int64_t ki, Cell data) { - assert(!exists(ki)); - assert(!isFull()); + assertx(!exists(ki)); + assertx(!isFull()); auto h = hash_int64(ki); auto ei = findForNewInsert(h); auto e = allocElm(ei); @@ -147,8 +147,8 @@ inline ArrayData* MixedArray::addVal(int64_t ki, Cell data) { } inline ArrayData* MixedArray::addVal(StringData* key, Cell data) { - assert(!exists(key)); - assert(!isFull()); + assertx(!exists(key)); + assertx(!isFull()); return addValNoAsserts(key, data); } @@ -173,7 +173,7 @@ inline MixedArray::Elm& MixedArray::addKeyAndGetElem(StringData* key) { template ArrayData* MixedArray::updateWithRef(K k, TypedValue data) { - assert(!isFull()); + assertx(!isFull()); auto p = insert(k); if (p.found) { // TODO(#3888164): We should restructure things so we don't have to check @@ -190,7 +190,7 @@ ArrayData* MixedArray::updateWithRef(K k, TypedValue data) { template ArrayData* MixedArray::updateRef(K k, member_lval data) { - assert(!isFull()); + assertx(!isFull()); auto p = insert(k); @@ -205,7 +205,7 @@ ArrayData* MixedArray::updateRef(K k, member_lval data) { template member_lval MixedArray::addLvalImpl(K k) { - assert(!isFull()); + assertx(!isFull()); auto p = insert(k); if (!p.found) { tvWriteNull(p.tv); @@ -229,7 +229,7 @@ struct MixedArray::ValIter { : m_arr(arr) , m_kind(arr->kind()) { - assert(isMixed(m_kind) || m_kind == kPackedKind || m_kind == kVecKind); + assertx(isMixed(m_kind) || m_kind == kPackedKind || m_kind == kVecKind); if (isMixed(m_kind)) { m_iterMixed = asMixed(arr)->data(); m_stopMixed = m_iterMixed + asMixed(arr)->m_used; @@ -243,15 +243,15 @@ struct MixedArray::ValIter { : m_arr(arr) , m_kind(arr->kind()) { - assert(isMixed(m_kind) || m_kind == kPackedKind || m_kind == kVecKind); + assertx(isMixed(m_kind) || m_kind == kPackedKind || m_kind == kVecKind); if (isMixed(m_kind)) { m_iterMixed = asMixed(arr)->data() + start_pos; m_stopMixed = asMixed(arr)->data() + asMixed(arr)->m_used; - assert(m_iterMixed <= m_stopMixed); + assertx(m_iterMixed <= m_stopMixed); } else { m_iterPacked = reinterpret_cast(arr + 1) + start_pos; m_stopPacked = reinterpret_cast(arr + 1) + arr->m_size; - assert(m_iterPacked <= m_stopPacked); + assertx(m_iterPacked <= m_stopPacked); } } @@ -261,7 +261,7 @@ struct MixedArray::ValIter { } Elm* currentElm() const { - assert(isMixed(m_kind)); + assertx(isMixed(m_kind)); return m_iterMixed; } @@ -354,7 +354,7 @@ void ConvertTvToUncounted(TypedValue* source, PointerMap* seen = nullptr) { // Fall-through. case KindOfPersistentVec: { auto& ad = source->m_data.parr; - assert(ad->isVecArray()); + assertx(ad->isVecArray()); if (handlePersistent(ad)) break; if (ad->empty()) ad = staticEmptyVecArray(); else ad = PackedArray::MakeUncounted(ad, false, seen); @@ -366,7 +366,7 @@ void ConvertTvToUncounted(TypedValue* source, PointerMap* seen = nullptr) { // Fall-through. case KindOfPersistentDict: { auto& ad = source->m_data.parr; - assert(ad->isDict()); + assertx(ad->isDict()); if (handlePersistent(ad)) break; if (ad->empty()) ad = staticEmptyDictArray(); else ad = MixedArray::MakeUncounted(ad, false, seen); @@ -378,7 +378,7 @@ void ConvertTvToUncounted(TypedValue* source, PointerMap* seen = nullptr) { // Fall-through. case KindOfPersistentKeyset: { auto& ad = source->m_data.parr; - assert(ad->isKeyset()); + assertx(ad->isKeyset()); if (handlePersistent(ad)) break; if (ad->empty()) ad = staticEmptyKeysetArray(); else ad = SetArray::MakeUncounted(ad, false, seen); @@ -390,8 +390,8 @@ void ConvertTvToUncounted(TypedValue* source, PointerMap* seen = nullptr) { // Fall-through. case KindOfPersistentArray: { auto& ad = source->m_data.parr; - assert(ad->isPHPArray()); - assert(!RuntimeOption::EvalHackArrDVArrs || ad->isNotDVArray()); + assertx(ad->isPHPArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs || ad->isNotDVArray()); if (handlePersistent(ad)) break; if (ad->empty()) { if (ad->isVArray()) ad = staticEmptyVArray(); @@ -424,7 +424,7 @@ void ConvertTvToUncounted(TypedValue* source, PointerMap* seen = nullptr) { ALWAYS_INLINE void ReleaseUncountedTv(TypedValue& tv) { if (isStringType(tv.m_type)) { - assert(!tv.m_data.pstr->isRefCounted()); + assertx(!tv.m_data.pstr->isRefCounted()); if (tv.m_data.pstr->isUncounted()) { StringData::ReleaseUncounted(tv.m_data.pstr); } @@ -432,7 +432,7 @@ void ReleaseUncountedTv(TypedValue& tv) { } if (isArrayLikeType(tv.m_type)) { auto arr = tv.m_data.parr; - assert(!arr->isRefCounted()); + assertx(!arr->isRefCounted()); if (!arr->isStatic()) { if (arr->hasPackedLayout()) PackedArray::ReleaseUncounted(arr); else if (arr->isKeyset()) SetArray::ReleaseUncounted(arr); diff --git a/hphp/runtime/base/mixed-array.cpp b/hphp/runtime/base/mixed-array.cpp index 27fd491c41f..42b6ee1d7c1 100644 --- a/hphp/runtime/base/mixed-array.cpp +++ b/hphp/runtime/base/mixed-array.cpp @@ -69,7 +69,7 @@ struct MixedArray::Initializer { ad->m_scale_used = 1; ad->m_nextKI = 0; ad->initHeader(HeaderKind::Dict, StaticValue); - assert(ad->checkInvariants()); + assertx(ad->checkInvariants()); } }; MixedArray::Initializer MixedArray::s_initializer; @@ -82,7 +82,7 @@ struct MixedArray::DArrayInitializer { ad->m_scale_used = 1; ad->m_nextKI = 0; ad->initHeader_16(HeaderKind::Mixed, StaticValue, ArrayData::kDArray); - assert(RuntimeOption::EvalHackArrDVArrs || ad->checkInvariants()); + assertx(RuntimeOption::EvalHackArrDVArrs || ad->checkInvariants()); } }; MixedArray::DArrayInitializer MixedArray::s_darr_initializer; @@ -93,10 +93,10 @@ ALWAYS_INLINE ArrayData* MixedArray::MakeReserveImpl(uint32_t size, HeaderKind hk, ArrayData::DVArray dvArray) { - assert(hk == HeaderKind::Mixed || hk == HeaderKind::Dict); - assert(dvArray == ArrayData::kNotDVArray || dvArray == ArrayData::kDArray); - assert(hk != HeaderKind::Dict || dvArray == ArrayData::kNotDVArray); - assert(!RuntimeOption::EvalHackArrDVArrs || + assertx(hk == HeaderKind::Mixed || hk == HeaderKind::Dict); + assertx(dvArray == ArrayData::kNotDVArray || dvArray == ArrayData::kDArray); + assertx(hk != HeaderKind::Dict || dvArray == ArrayData::kNotDVArray); + assertx(!RuntimeOption::EvalHackArrDVArrs || dvArray == ArrayData::kNotDVArray); auto const scale = computeScaleFromSize(size); @@ -111,36 +111,36 @@ ArrayData* MixedArray::MakeReserveImpl(uint32_t size, ad->m_scale_used = scale; // used=0 ad->m_nextKI = 0; - assert(ad->m_kind == hk); - assert(ad->dvArray() == dvArray); - assert(ad->m_size == 0); - assert(ad->m_pos == 0); - assert(ad->hasExactlyOneRef()); - assert(ad->m_used == 0); - assert(ad->m_nextKI == 0); - assert(ad->m_scale == scale); - assert(ad->checkInvariants()); + assertx(ad->m_kind == hk); + assertx(ad->dvArray() == dvArray); + assertx(ad->m_size == 0); + assertx(ad->m_pos == 0); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_used == 0); + assertx(ad->m_nextKI == 0); + assertx(ad->m_scale == scale); + assertx(ad->checkInvariants()); return ad; } ArrayData* MixedArray::MakeReserveMixed(uint32_t size) { auto ad = MakeReserveImpl(size, HeaderKind::Mixed, ArrayData::kNotDVArray); - assert(ad->isMixed()); - assert(ad->isNotDVArray()); + assertx(ad->isMixed()); + assertx(ad->isNotDVArray()); return ad; } ArrayData* MixedArray::MakeReserveDArray(uint32_t size) { - assert(!RuntimeOption::EvalHackArrDVArrs); + assertx(!RuntimeOption::EvalHackArrDVArrs); auto ad = MakeReserveImpl(size, HeaderKind::Mixed, ArrayData::kDArray); - assert(ad->isMixed()); - assert(ad->isDArray()); + assertx(ad->isMixed()); + assertx(ad->isDArray()); return ad; } ArrayData* MixedArray::MakeReserveDict(uint32_t size) { auto ad = MakeReserveImpl(size, HeaderKind::Dict, ArrayData::kNotDVArray); - assert(ad->isDict()); + assertx(ad->isDict()); return ad; } @@ -208,7 +208,7 @@ MixedArray* MixedArray::MakeStructImpl(uint32_t size, // Values are in reverse order since they come from the stack, which // grows down. for (uint32_t i = 0; i < size; i++) { - assert(keys[i]->isStatic()); + assertx(keys[i]->isStatic()); auto k = keys[i]; auto h = k->hash(); data[i].setStaticKey(const_cast(k), h); @@ -250,7 +250,7 @@ MixedArray* MixedArray::MakeStructDict(uint32_t size, MixedArray* MixedArray::MakeStructDArray(uint32_t size, const StringData* const* keys, const TypedValue* values) { - assert(!RuntimeOption::EvalHackArrDVArrs); + assertx(!RuntimeOption::EvalHackArrDVArrs); return MakeStructImpl(size, keys, values, HeaderKind::Mixed, ArrayData::kDArray); @@ -258,7 +258,7 @@ MixedArray* MixedArray::MakeStructDArray(uint32_t size, MixedArray* MixedArray::MakeMixed(uint32_t size, const TypedValue* keysAndValues) { - assert(size > 0); + assertx(size > 0); auto const scale = computeScaleFromSize(size); auto const ad = reqAlloc(scale); @@ -287,7 +287,7 @@ MixedArray* MixedArray::MakeMixed(uint32_t size, data[i].setStrKeyNoIncRef(k, h); *ei = i; } else { - assert(kTv.m_type == KindOfInt64); + assertx(kTv.m_type == KindOfInt64); auto k = kTv.m_data.num; auto h = hash_int64(k); auto ei = ad->findForInsertUpdate(k, h); @@ -305,15 +305,15 @@ MixedArray* MixedArray::MakeMixed(uint32_t size, data[i].data.m_type = tv.m_type; } - assert(ad->m_size == size); - assert(ad->m_pos == 0); - assert(ad->kind() == kMixedKind); - assert(ad->isNotDVArray()); - assert(ad->m_scale == scale); - assert(ad->hasExactlyOneRef()); - assert(ad->m_used == size); - assert(ad->m_nextKI == 0); - assert(ad->checkInvariants()); + assertx(ad->m_size == size); + assertx(ad->m_pos == 0); + assertx(ad->kind() == kMixedKind); + assertx(ad->isNotDVArray()); + assertx(ad->m_scale == scale); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_used == size); + assertx(ad->m_nextKI == 0); + assertx(ad->checkInvariants()); return ad; } @@ -323,9 +323,9 @@ MixedArray* MixedArray::CopyMixed(const MixedArray& other, AllocMode mode, HeaderKind dest_hk, ArrayData::DVArray dvArray) { - assert(dest_hk == HeaderKind::Mixed || dest_hk == HeaderKind::Dict); - assert(dvArray == ArrayData::kNotDVArray || dvArray == ArrayData::kDArray); - assert(dest_hk != HeaderKind::Dict || dvArray == ArrayData::kNotDVArray); + assertx(dest_hk == HeaderKind::Mixed || dest_hk == HeaderKind::Dict); + assertx(dvArray == ArrayData::kNotDVArray || dvArray == ArrayData::kDArray); + assertx(dest_hk != HeaderKind::Dict || dvArray == ArrayData::kNotDVArray); auto const scale = other.m_scale; auto const ad = mode == AllocMode::Request ? reqAlloc(scale) @@ -364,33 +364,33 @@ MixedArray* MixedArray::CopyMixed(const MixedArray& other, ad->m_size = i; ad->m_pos = 0; if (ad->isRefCounted()) Release(ad); - else assert(ad->isStatic()); + else assertx(ad->isStatic()); throwRefInvalidArrayValueException(staticEmptyDictArray()); } } tvIncRefGen(e.data); } - assert(ad->m_used == other.m_used); - assert(ad->m_kind == dest_hk); - assert(ad->dvArray() == dvArray); - assert(ad->m_size == other.m_size); - assert(ad->m_pos == other.m_pos); - assert(mode == AllocMode::Request ? ad->hasExactlyOneRef() : + assertx(ad->m_used == other.m_used); + assertx(ad->m_kind == dest_hk); + assertx(ad->dvArray() == dvArray); + assertx(ad->m_size == other.m_size); + assertx(ad->m_pos == other.m_pos); + assertx(mode == AllocMode::Request ? ad->hasExactlyOneRef() : ad->isStatic()); - assert(ad->m_scale == scale); - assert(ad->checkInvariants()); + assertx(ad->m_scale == scale); + assertx(ad->checkInvariants()); return ad; } NEVER_INLINE ArrayData* MixedArray::CopyStatic(const ArrayData* in) { auto a = asMixed(in); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return CopyMixed(*a, AllocMode::Static, in->m_kind, in->dvArray()); } NEVER_INLINE MixedArray* MixedArray::copyMixed() const { - assert(checkInvariants()); + assertx(checkInvariants()); return CopyMixed(*this, AllocMode::Request, this->m_kind, this->dvArray()); } @@ -410,7 +410,7 @@ ArrayData* MixedArray::MakeUncounted(ArrayData* array, void** seenVal = nullptr; if (seen && array->hasMultipleRefs()) { auto it = seen->find(array); - assert(it != seen->end()); + assertx(it != seen->end()); seenVal = &it->second; if (auto const arr = static_cast(*seenVal)) { if (arr->uncountedIncRef()) { @@ -433,7 +433,7 @@ ArrayData* MixedArray::MakeUncounted(ArrayData* array, // This might overwrite the hash table, but won't go beyond the space // allocated for the MixedArray, assuming `malloc()' always allocates // multiple of 16 bytes and extra is also a multiple of 16. - assert((extra & 0xf) == 0); + assertx((extra & 0xf) == 0); bcopy32_inline(ad, a, sizeof(MixedArray) + sizeof(Elm) * used + 24); ad->m_count = UncountedValue; // after bcopy, update count if (withApcTypedValue) { @@ -476,7 +476,7 @@ ArrayData* MixedArray::MakeUncounted(ArrayData* array, } ArrayData* MixedArray::MakeDictFromAPC(const APCArray* apc) { - assert(apc->isDict()); + assertx(apc->isDict()); auto const apcSize = apc->size(); DictInit init{apcSize}; for (uint32_t i = 0; i < apcSize; ++i) { @@ -486,8 +486,8 @@ ArrayData* MixedArray::MakeDictFromAPC(const APCArray* apc) { } ArrayData* MixedArray::MakeDArrayFromAPC(const APCArray* apc) { - assert(!RuntimeOption::EvalHackArrDVArrs); - assert(apc->isDArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs); + assertx(apc->isDArray()); auto const apcSize = apc->size(); DArrayInit init{apcSize}; for (uint32_t i = 0; i < apcSize; ++i) { @@ -501,8 +501,8 @@ ArrayData* MixedArray::MakeDArrayFromAPC(const APCArray* apc) { NEVER_INLINE void MixedArray::Release(ArrayData* in) { - assert(in->isRefCounted()); - assert(in->hasExactlyOneRef()); + assertx(in->isRefCounted()); + assertx(in->hasExactlyOneRef()); auto const ad = asMixed(in); if (!ad->isZombie()) { @@ -541,7 +541,7 @@ void MixedArray::ReleaseUncounted(ArrayData* in) { for (auto ptr = data; ptr != stop; ++ptr) { if (isTombstone(ptr->data.m_type)) continue; if (ptr->hasStrKey()) { - assert(!ptr->skey->isRefCounted()); + assertx(!ptr->skey->isRefCounted()); if (ptr->skey->isUncounted()) { StringData::ReleaseUncounted(ptr->skey); } @@ -550,7 +550,7 @@ void MixedArray::ReleaseUncounted(ArrayData* in) { } // We better not have strong iterators associated with uncounted arrays. - assert(!has_strong_iterator(ad)); + assertx(!has_strong_iterator(ad)); } auto const extra = ad->hasApcTv() ? sizeof(APCTypedValue) : 0; if (UncountedMixedArrayOnHugePage()) { @@ -614,23 +614,23 @@ bool MixedArray::checkInvariants() const { ); // All arrays: - assert(hasMixedLayout()); - assert(!isMixed() || !isVArray()); - assert(!isDict() || isNotDVArray()); - assert(!RuntimeOption::EvalHackArrDVArrs || isNotDVArray()); - assert(checkCount()); - assert(m_scale >= 1 && (m_scale & (m_scale - 1)) == 0); - assert(MixedArray::HashSize(m_scale) == + assertx(hasMixedLayout()); + assertx(!isMixed() || !isVArray()); + assertx(!isDict() || isNotDVArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs || isNotDVArray()); + assertx(checkCount()); + assertx(m_scale >= 1 && (m_scale & (m_scale - 1)) == 0); + assertx(MixedArray::HashSize(m_scale) == folly::nextPowTwo(capacity())); if (isZombie()) return true; // Non-zombie: - assert(m_size <= m_used); - assert(m_used <= capacity()); + assertx(m_size <= m_used); + assertx(m_used <= capacity()); if (m_pos != m_used) { - assert(size_t(m_pos) < m_used); - assert(!isTombstone(data()[m_pos].data.m_type)); + assertx(size_t(m_pos) < m_used); + assertx(!isTombstone(data()[m_pos].data.m_type)); } return true; @@ -643,10 +643,10 @@ size_t MixedArray::Vsize(const ArrayData*) { not_reached(); } member_rval::ptr_u MixedArray::GetValueRef(const ArrayData* ad, ssize_t pos) { auto a = asMixed(ad); - assert(a->checkInvariants()); - assert(pos != a->m_used); + assertx(a->checkInvariants()); + assertx(pos != a->m_used); auto const& e = a->data()[pos]; - assert(!e.isTombstone()); + assertx(!e.isTombstone()); return &e.data; } @@ -686,7 +686,7 @@ int32_t* warnUnbalanced(MixedArray* a, size_t n, int32_t* ei) { MixedArray::InsertPos MixedArray::insert(int64_t k) // TODO: T26068998 fix signed-integer-overflow undefined behavior FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("signed-integer-overflow") { - assert(!isFull()); + assertx(!isFull()); auto h = hash_int64(k); auto ei = findForInsertUpdate(k, h); if (isValidPos(ei)) { @@ -699,7 +699,7 @@ MixedArray::InsertPos MixedArray::insert(int64_t k) } MixedArray::InsertPos MixedArray::insert(StringData* k) { - assert(!isFull()); + assertx(!isFull()); auto const h = k->hash(); auto ei = findForInsertUpdate(k, h); if (isValidPos(ei)) { @@ -715,7 +715,7 @@ int32_t MixedArray::findForRemove(int64_t ki, inthash_t h, bool updateNext) { // all vector methods should work w/out touching the hashtable return findForRemove(ki, h, [this, ki, updateNext] (Elm& e) { - assert(ki == e.ikey); + assertx(ki == e.ikey); // Conform to PHP5 behavior // Hacky: don't removed the unsigned cast, else g++ can optimize away // the check for == 0x7fff..., since there is no signed int k @@ -798,9 +798,9 @@ MixedArray::InsertCheckUnbalanced(MixedArray* ad, NEVER_INLINE MixedArray* MixedArray::Grow(MixedArray* old, uint32_t newScale, bool copy) { - assert(old->m_size > 0); - assert(MixedArray::Capacity(newScale) >= old->m_size); - assert(newScale >= 1 && (newScale & (newScale - 1)) == 0); + assertx(old->m_size > 0); + assertx(MixedArray::Capacity(newScale) >= old->m_size); + assertx(newScale >= 1 && (newScale & (newScale - 1)) == 0); auto ad = reqAlloc(newScale); auto const oldUsed = old->m_used; @@ -833,7 +833,7 @@ MixedArray::Grow(MixedArray* old, uint32_t newScale, bool copy) { auto iter = ad->data(); auto const stop = iter + oldUsed; - assert(newScale == ad->m_scale); + assertx(newScale == ad->m_scale); auto mask = MixedArray::Mask(newScale); if (UNLIKELY(oldUsed >= 2000)) { @@ -847,20 +847,20 @@ MixedArray::Grow(MixedArray* old, uint32_t newScale, bool copy) { } } - assert(ad->kind() == old->kind()); - assert(ad->dvArray() == old->dvArray()); - assert(ad->m_size == old->m_size); - assert(ad->hasExactlyOneRef()); - assert(ad->m_pos == old->m_pos); - assert(ad->m_used == oldUsed); - assert(ad->m_scale == newScale); - assert(ad->checkInvariants()); + assertx(ad->kind() == old->kind()); + assertx(ad->dvArray() == old->dvArray()); + assertx(ad->m_size == old->m_size); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_pos == old->m_pos); + assertx(ad->m_used == oldUsed); + assertx(ad->m_scale == newScale); + assertx(ad->checkInvariants()); return ad; } ALWAYS_INLINE MixedArray* MixedArray::prepareForInsert(bool copy) { - assert(checkInvariants()); + assertx(checkInvariants()); if (isFull()) return Grow(this, m_scale * 2, copy); if (copy) return copyMixed(); return this; @@ -884,7 +884,7 @@ void MixedArray::compact(bool renumber /* = false */) { // We only need to do this if m_pos is nonzero and is not // the canonical invalid position. updatePosAfterCompact = true; - assert(size_t(m_pos) < m_used); + assertx(size_t(m_pos) < m_used); auto& e = data()[m_pos]; mPos.hash = e.hash(); mPos.skey = e.skey; @@ -918,7 +918,7 @@ void MixedArray::compact(bool renumber /* = false */) { auto const table = initHash(m_scale); for (uint32_t frPos = 0, toPos = 0; toPos < m_size; ++toPos, ++frPos) { while (elms[frPos].isTombstone()) { - assert(frPos + 1 < m_used); + assertx(frPos + 1 < m_used); ++frPos; } auto& toE = elms[toPos]; @@ -936,7 +936,7 @@ void MixedArray::compact(bool renumber /* = false */) { // Update m_pos, now that compaction is complete m_pos = mPos.hash >= 0 ? ssize_t(find(mPos.skey, mPos.hash)) : ssize_t(find(mPos.ikey, mPos.hash)); - assert(m_pos >= 0 && m_pos < m_size); + assertx(m_pos >= 0 && m_pos < m_size); } if (LIKELY(!updateStrongIters)) { @@ -967,7 +967,7 @@ void MixedArray::compact(bool renumber /* = false */) { key++; iter->m_pos = k.hash >= 0 ? ssize_t(find(k.skey, k.hash)) : ssize_t(find(k.ikey, k.hash)); - assert(iter->m_pos >= 0 && iter->m_pos < m_size); + assertx(iter->m_pos >= 0 && iter->m_pos < m_size); } ); // Finally, update m_used and return @@ -975,8 +975,8 @@ void MixedArray::compact(bool renumber /* = false */) { } bool MixedArray::nextInsert(Cell v) { - assert(m_nextKI >= 0); - assert(!isFull()); + assertx(m_nextKI >= 0); + assertx(!isFull()); int64_t ki = m_nextKI; auto h = hash_int64(ki); @@ -984,7 +984,7 @@ bool MixedArray::nextInsert(Cell v) { // know that m_nextKI is not present in the array, so it is safe // to use findForNewInsert() auto ei = findForNewInsert(h); - assert(!isValidPos(ei)); + assertx(!isValidPos(ei)); // Allocate and initialize a new element. auto e = allocElm(ei); e->setIntKey(ki, h); @@ -994,8 +994,8 @@ bool MixedArray::nextInsert(Cell v) { } ArrayData* MixedArray::nextInsertRef(member_lval data) { - assert(!isFull()); - assert(m_nextKI >= 0); + assertx(!isFull()); + assertx(m_nextKI >= 0); int64_t ki = m_nextKI; auto h = hash_int64(ki); @@ -1010,12 +1010,12 @@ ArrayData* MixedArray::nextInsertRef(member_lval data) { } ArrayData* MixedArray::nextInsertWithRef(TypedValue data) { - assert(!isFull()); + assertx(!isFull()); int64_t ki = m_nextKI; auto h = hash_int64(ki); auto ei = findForNewInsert(h); - assert(!isValidPos(ei)); + assertx(!isValidPos(ei)); // Allocate a new element. auto e = allocElm(ei); @@ -1031,7 +1031,7 @@ ArrayData* MixedArray::nextInsertWithRef(const Variant& data) { template ALWAYS_INLINE ArrayData* MixedArray::update(K k, Cell data) { - assert(!isFull()); + assertx(!isFull()); auto p = insert(k); if (p.found) { // TODO(#3888164): we should restructure things so we don't have @@ -1130,7 +1130,7 @@ ArrayData* MixedArray::SetWithRefStr(ArrayData* ad, StringData* k, ArrayData* MixedArray::SetRefInt(ArrayData* ad, int64_t k, member_lval v, bool copy) { auto a = asMixed(ad); - assert(a->isMixed()); + assertx(a->isMixed()); if (checkHACRefBind()) raiseHackArrCompatRefBind(k); return a->prepareForInsert(copy)->updateRef(k, v); } @@ -1138,20 +1138,20 @@ MixedArray::SetRefInt(ArrayData* ad, int64_t k, member_lval v, bool copy) { ArrayData* MixedArray::SetRefStr(ArrayData* ad, StringData* k, member_lval v, bool copy) { auto a = asMixed(ad); - assert(a->isMixed()); + assertx(a->isMixed()); if (checkHACRefBind()) raiseHackArrCompatRefBind(k); return a->prepareForInsert(copy)->updateRef(k, v); } ArrayData* MixedArray::AddInt(ArrayData* ad, int64_t k, Cell v, bool copy) { - assert(!ad->exists(k)); + assertx(!ad->exists(k)); return asMixed(ad)->prepareForInsert(copy)->addVal(k, v); } ArrayData* MixedArray::AddStr(ArrayData* ad, StringData* k, Cell v, bool copy) { - assert(!ad->exists(k)); + assertx(!ad->exists(k)); return asMixed(ad)->prepareForInsert(copy)->addVal(k, v); } @@ -1160,7 +1160,7 @@ MixedArray::AddStr(ArrayData* ad, StringData* k, Cell v, bool copy) { NEVER_INLINE void MixedArray::adjustMArrayIter(ssize_t pos) { - assert(pos >= 0 && pos < m_used); + assertx(pos >= 0 && pos < m_used); ssize_t eIPrev = Tombstone; for_each_strong_iterator([&] (MIterTable::Ent& miEnt) { if (miEnt.array != this) return; @@ -1183,7 +1183,7 @@ void MixedArray::adjustMArrayIter(ssize_t pos) { } void MixedArray::eraseNoCompact(ssize_t pos) { - assert(validPos(pos)); + assertx(validPos(pos)); // move strong iterators to the previous element if (UNLIKELY(strong_iterators_exist())) adjustMArrayIter(pos); @@ -1201,7 +1201,7 @@ void MixedArray::eraseNoCompact(ssize_t pos) { tv->m_type = kInvalidDataType; --m_size; // Mark the hash entry as "deleted". - assert(m_used <= capacity()); + assertx(m_used <= capacity()); // Finally, decref the old value tvDecRefGen(oldTV); @@ -1242,7 +1242,7 @@ ArrayData* MixedArray::Append(ArrayData* ad, Cell v, bool copy) { ArrayData* MixedArray::AppendRef(ArrayData* ad, member_lval v, bool copy) { auto a = asMixed(ad); - assert(a->isMixed()); + assertx(a->isMixed()); if (checkHACRefBind()) raiseHackArrCompatRefNew(); @@ -1258,7 +1258,7 @@ ArrayData* MixedArray::AppendRef(ArrayData* ad, member_lval v, bool copy) { ArrayData* MixedArray::AppendWithRef(ArrayData* ad, TypedValue v, bool copy) { auto a = asMixed(ad); - assert(a->isMixed()); + assertx(a->isMixed()); if (checkHACRefBind() && tvIsReferenced(v)) { raiseHackArrCompatRefNew(); @@ -1297,7 +1297,7 @@ MixedArray* MixedArray::CopyReserve(const MixedArray* src, ElmKey mPos; bool updatePosAfterCopy = src->m_pos != 0 && src->m_pos < src->m_used; if (updatePosAfterCopy) { - assert(size_t(src->m_pos) < src->m_used); + assertx(size_t(src->m_pos) < src->m_used); auto& e = srcElm[src->m_pos]; mPos.hash = e.probe(); mPos.skey = e.skey; @@ -1323,7 +1323,7 @@ MixedArray* MixedArray::CopyReserve(const MixedArray* src, if (updatePosAfterCopy) { ad->m_pos = mPos.hash >= 0 ? ssize_t(ad->find(mPos.skey, mPos.hash)) : ssize_t(ad->find(mPos.ikey, mPos.hash)); - assert(ad->m_pos >=0 && ad->m_pos < ad->m_size); + assertx(ad->m_pos >=0 && ad->m_pos < ad->m_size); } else { // If src->m_pos is equal to src's canonical invalid position, then // set ad->m_pos to ad's canonical invalid position. @@ -1332,18 +1332,18 @@ MixedArray* MixedArray::CopyReserve(const MixedArray* src, } // Set new used value (we've removed any tombstones). - assert(i == dstElm - ad->data()); + assertx(i == dstElm - ad->data()); ad->m_used = i; - assert(ad->kind() == src->kind()); - assert(ad->dvArray() == src->dvArray()); - assert(ad->m_size == src->m_size); - assert(ad->hasExactlyOneRef()); - assert(ad->m_used <= oldUsed); - assert(ad->m_used == dstElm - ad->data()); - assert(ad->m_scale == scale); - assert(ad->m_nextKI == src->m_nextKI); - assert(ad->checkInvariants()); + assertx(ad->kind() == src->kind()); + assertx(ad->dvArray() == src->dvArray()); + assertx(ad->m_size == src->m_size); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_used <= oldUsed); + assertx(ad->m_used == dstElm - ad->data()); + assertx(ad->m_scale == scale); + assertx(ad->m_nextKI == src->m_nextKI); + assertx(ad->checkInvariants()); return ad; } @@ -1352,16 +1352,16 @@ ArrayData* MixedArray::ArrayPlusEqGeneric(ArrayData* ad, MixedArray* ret, const ArrayData* elems, size_t neededSize) { - assert(ad->isPHPArray()); - assert(elems->isPHPArray()); - assert(ret->isMixed()); + assertx(ad->isPHPArray()); + assertx(elems->isPHPArray()); + assertx(ret->isMixed()); for (ArrayIter it(elems); !it.end(); it.next()) { Variant key = it.first(); auto const value = it.secondVal(); if (UNLIKELY(ret->isFull())) { - assert(ret == ad); + assertx(ret == ad); ret = CopyReserve(asMixed(ad), neededSize); } @@ -1403,7 +1403,7 @@ ArrayData* MixedArray::PlusEq(ArrayData* ad, const ArrayData* elems) { if (srcElem->isTombstone()) continue; if (UNLIKELY(ret->isFull())) { - assert(ret == ad); + assertx(ret == ad); ret = CopyReserve(ret, neededSize); } @@ -1448,9 +1448,9 @@ ArrayData* MixedArray::ArrayMergeGeneric(MixedArray* ret, } ArrayData* MixedArray::Merge(ArrayData* ad, const ArrayData* elems) { - assert(asMixed(ad)->checkInvariants()); + assertx(asMixed(ad)->checkInvariants()); auto const ret = CopyReserve(asMixed(ad), ad->size() + elems->size()); - assert(ret->hasExactlyOneRef()); + assertx(ret->hasExactlyOneRef()); // Output is always a non-darray ret->initHeader(HeaderKind::Mixed, OneReference); @@ -1477,7 +1477,7 @@ ArrayData* MixedArray::Merge(ArrayData* ad, const ArrayData* elems) { return ArrayMergeGeneric(ret, elems); } - assert(PackedArray::checkInvariants(elems)); + assertx(PackedArray::checkInvariants(elems)); auto src = packedData(elems); auto const srcStop = src + elems->m_size; for (; src != srcStop; ++src) { @@ -1497,13 +1497,13 @@ ArrayData* MixedArray::Pop(ArrayData* ad, Variant& value) { auto elms = a->data(); if (a->m_size) { ssize_t pos = IterLast(a); - assert(pos >= 0 && pos < a->m_used); + assertx(pos >= 0 && pos < a->m_used); auto& e = elms[pos]; - assert(!isTombstone(e.data.m_type)); + assertx(!isTombstone(e.data.m_type)); value = tvAsCVarRef(&e.data); auto pos2 = e.hasStrKey() ? a->findForRemove(e.skey, e.hash()) : a->findForRemove(e.ikey, e.hash(), true); - assert(pos2 == pos); + assertx(pos2 == pos); a->erase(pos2); } else { value = uninit_null(); @@ -1520,13 +1520,13 @@ ArrayData* MixedArray::Dequeue(ArrayData* adInput, Variant& value) { auto elms = a->data(); if (a->m_size) { ssize_t pos = a->nextElm(elms, -1); - assert(pos >= 0 && pos < a->m_used); + assertx(pos >= 0 && pos < a->m_used); auto& e = elms[pos]; - assert(!isTombstone(e.data.m_type)); + assertx(!isTombstone(e.data.m_type)); value = tvAsCVarRef(&e.data); auto pos2 = e.hasStrKey() ? a->findForRemove(e.skey, e.hash()) : a->findForRemove(e.ikey, e.hash(), false); - assert(pos2 == pos); + assertx(pos2 == pos); a->erase(pos2); } else { value = uninit_null(); @@ -1561,13 +1561,13 @@ ArrayData* MixedArray::Prepend(ArrayData* adInput, Cell v, bool /*copy*/) { ArrayData* MixedArray::ToPHPArray(ArrayData* in, bool copy) { auto adIn = asMixed(in); - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); if (adIn->isNotDVArray()) return adIn; - assert(adIn->isDArray()); + assertx(adIn->isDArray()); if (adIn->getSize() == 0) return staticEmptyArray(); auto ad = copy ? adIn->copyMixed() : adIn; ad->setDVArray(ArrayData::kNotDVArray); - assert(ad->checkInvariants()); + assertx(ad->checkInvariants()); return ad; } @@ -1640,13 +1640,13 @@ ArrayData* MixedArray::ToPHPArrayDict(ArrayData* adIn, bool copy) { ArrayData* MixedArray::ToDArray(ArrayData* in, bool copy) { auto a = asMixed(in); - assert(a->isMixed()); + assertx(a->isMixed()); if (RuntimeOption::EvalHackArrDVArrs) return ToDict(in, copy); if (a->isDArray()) return a; if (a->getSize() == 0) return staticEmptyDArray(); auto out = copy ? a->copyMixed() : a; out->setDVArray(ArrayData::kDArray); - assert(out->checkInvariants()); + assertx(out->checkInvariants()); return out; } @@ -1659,8 +1659,8 @@ ArrayData* MixedArray::ToDArrayDict(ArrayData* in, bool copy) { MixedArray* MixedArray::ToDictInPlace(ArrayData* ad) { auto a = asMixed(ad); - assert(a->isMixed()); - assert(!a->cowCheck()); + assertx(a->isMixed()); + assertx(!a->cowCheck()); a->m_kind = HeaderKind::Dict; a->setDVArray(ArrayData::kNotDVArray); return a; @@ -1668,7 +1668,7 @@ MixedArray* MixedArray::ToDictInPlace(ArrayData* ad) { ArrayData* MixedArray::ToDict(ArrayData* ad, bool copy) { auto a = asMixed(ad); - assert(a->isMixed()); + assertx(a->isMixed()); if (copy) { return CopyMixed(*a, AllocMode::Request, @@ -1688,8 +1688,8 @@ ArrayData* MixedArray::ToDict(ArrayData* ad, bool copy) { } ArrayData* MixedArray::ToDictDict(ArrayData* ad, bool) { - assert(asMixed(ad)->checkInvariants()); - assert(ad->isDict()); + assertx(asMixed(ad)->checkInvariants()); + assertx(ad->isDict()); return ad; } @@ -1736,8 +1736,8 @@ bool MixedArray::AdvanceMArrayIter(ArrayData* ad, MArrayIter& fp) { ////////////////////////////////////////////////////////////////////// member_rval::ptr_u MixedArray::NvTryGetIntDict(const ArrayData* ad, int64_t k) { - assert(asMixed(ad)->checkInvariants()); - assert(ad->isDict()); + assertx(asMixed(ad)->checkInvariants()); + assertx(ad->isDict()); auto const ptr = MixedArray::NvGetInt(ad, k); if (UNLIKELY(!ptr)) throwOOBArrayKeyException(k, ad); return ptr; @@ -1745,8 +1745,8 @@ member_rval::ptr_u MixedArray::NvTryGetIntDict(const ArrayData* ad, int64_t k) { member_rval::ptr_u MixedArray::NvTryGetStrDict(const ArrayData* ad, const StringData* k) { - assert(asMixed(ad)->checkInvariants()); - assert(ad->isDict()); + assertx(asMixed(ad)->checkInvariants()); + assertx(ad->isDict()); auto const ptr = MixedArray::NvGetStr(ad, k); if (UNLIKELY(!ptr)) throwOOBArrayKeyException(k, ad); return ptr; @@ -1765,47 +1765,47 @@ ArrayData* MixedArray::SetWithRefStrDict(ArrayData* ad, StringData* k, } member_lval MixedArray::LvalIntRefDict(ArrayData* adIn, int64_t, bool) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); throwRefInvalidArrayValueException(adIn); } member_lval MixedArray::LvalStrRefDict(ArrayData* adIn, StringData*, bool) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); throwRefInvalidArrayValueException(adIn); } member_lval MixedArray::LvalNewRefDict(ArrayData* adIn, bool) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); throwRefInvalidArrayValueException(adIn); } ArrayData* MixedArray::SetRefIntDict(ArrayData* adIn, int64_t, member_lval, bool) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); throwRefInvalidArrayValueException(adIn); } ArrayData* MixedArray::SetRefStrDict(ArrayData* adIn, StringData*, member_lval, bool) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); throwRefInvalidArrayValueException(adIn); } ArrayData* MixedArray::AppendRefDict(ArrayData* adIn, member_lval, bool) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); throwRefInvalidArrayValueException(adIn); } ArrayData* MixedArray::AppendWithRefDict(ArrayData* adIn, TypedValue v, bool copy) { - assert(asMixed(adIn)->checkInvariants()); - assert(adIn->isDict()); + assertx(asMixed(adIn)->checkInvariants()); + assertx(adIn->isDict()); if (tvIsReferenced(v)) throwRefInvalidArrayValueException(adIn); return Append(adIn, tvToInitCell(v), copy); } @@ -1815,10 +1815,10 @@ MixedArray::AppendWithRefDict(ArrayData* adIn, TypedValue v, bool copy) { ALWAYS_INLINE bool MixedArray::DictEqualHelper(const ArrayData* ad1, const ArrayData* ad2, bool strict) { - assert(asMixed(ad1)->checkInvariants()); - assert(asMixed(ad2)->checkInvariants()); - assert(ad1->isDict()); - assert(ad2->isDict()); + assertx(asMixed(ad1)->checkInvariants()); + assertx(asMixed(ad2)->checkInvariants()); + assertx(ad1->isDict()); + assertx(ad2->isDict()); if (ad1 == ad2) return true; if (ad1->size() != ad2->size()) return false; diff --git a/hphp/runtime/base/mixed-array.h b/hphp/runtime/base/mixed-array.h index 2a292186a2c..43991a14f0f 100644 --- a/hphp/runtime/base/mixed-array.h +++ b/hphp/runtime/base/mixed-array.h @@ -54,7 +54,7 @@ struct MixedArrayElm { TypedValueAux data; void setStaticKey(StringData* k, strhash_t h) { - assert(k->isStatic()); + assertx(k->isStatic()); setStrKeyNoIncRef(k, h); } @@ -72,7 +72,7 @@ struct MixedArrayElm { void setIntKey(int64_t k, inthash_t h) { ikey = k; data.hash() = static_cast(h) | STRHASH_MSB; - assert(hasIntKey()); + assertx(hasIntKey()); static_assert(static_cast(STRHASH_MSB) < 0, "high bit indicates int key"); } @@ -101,7 +101,7 @@ struct MixedArrayElm { } ALWAYS_INLINE StringData* strKey() const { - assert(hasStrKey()); + assertx(hasStrKey()); return skey; } @@ -135,7 +135,7 @@ struct MixedArrayElm { // Elm's data.m_type == kInvalidDataType for deleted slots. ALWAYS_INLINE bool isTombstone() const { - assert(isRealType(data.m_type) || data.m_type == kInvalidDataType); + assertx(isRealType(data.m_type) || data.m_type == kInvalidDataType); return data.m_type < KindOfUninit; static_assert(KindOfUninit == 0 && kInvalidDataType < 0, ""); } @@ -522,7 +522,7 @@ public: bool isTombstone(ssize_t pos) const; // Elm's data.m_type == kInvalidDataType for deleted slots. static bool isTombstone(DataType t) { - assert(isRealType(t) || t == kInvalidDataType); + assertx(isRealType(t) || t == kInvalidDataType); return t < KindOfUninit; static_assert(KindOfUninit == 0 && kInvalidDataType < 0, ""); } @@ -550,22 +550,22 @@ private: public: // Safe downcast helpers static MixedArray* asMixed(ArrayData* ad) { - assert(ad->hasMixedLayout()); + assertx(ad->hasMixedLayout()); auto a = static_cast(ad); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return a; } static const MixedArray* asMixed(const ArrayData* ad) { - assert(ad->hasMixedLayout()); + assertx(ad->hasMixedLayout()); auto a = static_cast(ad); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return a; } // Fast iteration template static void IterateV(const MixedArray* arr, F fn) { - assert(arr->hasMixedLayout()); + assertx(arr->hasMixedLayout()); auto elm = arr->data(); if (inc) arr->incRefCount(); SCOPE_EXIT { if (inc) decRefArr(const_cast(arr)); }; @@ -577,7 +577,7 @@ public: } template static void IterateKV(const MixedArray* arr, F fn) { - assert(arr->hasMixedLayout()); + assertx(arr->hasMixedLayout()); auto elm = arr->data(); if (inc) arr->incRefCount(); SCOPE_EXIT { if (inc) decRefArr(const_cast(arr)); }; @@ -624,7 +624,7 @@ private: static ArrayData* ArrayMergeGeneric(MixedArray*, const ArrayData*); // Assert a bunch of invariants about this array then return true. - // usage: assert(checkInvariants()); + // usage: assertx(checkInvariants()); bool checkInvariants() const; private: diff --git a/hphp/runtime/base/object-data-inl.h b/hphp/runtime/base/object-data-inl.h index fce1029c579..6765c1baf55 100644 --- a/hphp/runtime/base/object-data-inl.h +++ b/hphp/runtime/base/object-data-inl.h @@ -32,9 +32,9 @@ inline ObjectData::ObjectData(Class* cls, uint8_t flags, HeaderKind kind) : m_cls(cls) { initHeader_16(kind, OneReference, flags | cls->getODAttrs()); - assert(isObjectKind(m_kind)); - assert(!cls->needInitialization() || cls->initialized()); - assert(!isCollection()); // collections use NoInit{} + assertx(isObjectKind(m_kind)); + assertx(!cls->needInitialization() || cls->initialized()); + assertx(!isCollection()); // collections use NoInit{} o_id = ++os_max_id; instanceInit(cls); } @@ -44,9 +44,9 @@ inline ObjectData::ObjectData(Class* cls, InitRaw, uint8_t flags, : m_cls(cls) { initHeader_16(kind, OneReference, flags); - assert(isObjectKind(m_kind)); - assert(!cls->needInitialization() || cls->initialized()); - assert(!(cls->getODAttrs() & ~static_cast(flags))); + assertx(isObjectKind(m_kind)); + assertx(!cls->needInitialization() || cls->initialized()); + assertx(!(cls->getODAttrs() & ~static_cast(flags))); o_id = ++os_max_id; } @@ -54,7 +54,7 @@ inline ObjectData::ObjectData(Class* cls, NoInit, uint8_t flags, HeaderKind kind) noexcept : ObjectData(cls, InitRaw{}, flags, kind) { - assert(cls->numDeclProperties() == 0); + assertx(cls->numDeclProperties() == 0); } inline size_t ObjectData::heapSize() const { @@ -74,21 +74,21 @@ inline ObjectData* ObjectData::newInstance(Class* cls) { ObjectData* obj; if (auto const ctor = cls->instanceCtor()) { obj = ctor(cls); - assert(obj->checkCount()); + assertx(obj->checkCount()); assertx(obj->hasInstanceDtor()); } else { size_t nProps = cls->numDeclProperties(); size_t size = sizeForNProps(nProps); auto& mm = *tl_heap; obj = new (mm.objMalloc(size)) ObjectData(cls); - assert(obj->hasExactlyOneRef()); + assertx(obj->hasExactlyOneRef()); assertx(!obj->hasInstanceDtor()); } if (UNLIKELY(cls->needsInitThrowable())) { // may incref obj throwable_init(obj); - assert(obj->checkCount()); + assertx(obj->checkCount()); } return obj; @@ -97,7 +97,7 @@ inline ObjectData* ObjectData::newInstance(Class* cls) { inline ObjectData* ObjectData::newInstanceNoPropInit(Class* cls) { if (cls->needInitialization()) cls->initialize(); - assert(!cls->instanceCtor() && + assertx(!cls->instanceCtor() && !(cls->attrs() & (AttrAbstract | AttrInterface | AttrTrait | AttrEnum))); @@ -105,7 +105,7 @@ inline ObjectData* ObjectData::newInstanceNoPropInit(Class* cls) { size_t size = sizeForNProps(nProps); auto const obj = new (tl_heap->objMalloc(size)) ObjectData(cls, InitRaw{}, cls->getODAttrs()); - assert(obj->hasExactlyOneRef()); + assertx(obj->hasExactlyOneRef()); return obj; } @@ -114,8 +114,8 @@ inline void ObjectData::instanceInit(Class* cls) { if (nProps > 0) { if (cls->pinitVec().size() > 0) { const Class::PropInitVec* propInitVec = m_cls->getPropData(); - assert(propInitVec != nullptr); - assert(nProps == propInitVec->size()); + assertx(propInitVec != nullptr); + assertx(nProps == propInitVec->size()); if (!cls->hasDeepInitProps()) { memcpy16_inline(propVecForConstruct(), &(*propInitVec)[0], nProps * sizeof(TypedValue)); @@ -123,7 +123,7 @@ inline void ObjectData::instanceInit(Class* cls) { deepInitHelper(propVecForConstruct(), &(*propInitVec)[0], nProps); } } else { - assert(nProps == cls->declPropInit().size()); + assertx(nProps == cls->declPropInit().size()); memcpy16_inline(propVecForConstruct(), &cls->declPropInit()[0], nProps * sizeof(TypedValue)); } @@ -131,7 +131,7 @@ inline void ObjectData::instanceInit(Class* cls) { } inline Class* ObjectData::getVMClass() const { - assert(kindIsValid()); + assertx(kindIsValid()); return m_cls; } @@ -168,7 +168,7 @@ inline bool ObjectData::isImmutableCollection() const { } inline CollectionType ObjectData::collectionType() const { - assert(isValidCollection(static_cast(m_kind))); + assertx(isValidCollection(static_cast(m_kind))); return static_cast(m_kind); } diff --git a/hphp/runtime/base/object-data.cpp b/hphp/runtime/base/object-data.cpp index 97c5c64fea6..f74bb2f3c62 100644 --- a/hphp/runtime/base/object-data.cpp +++ b/hphp/runtime/base/object-data.cpp @@ -69,7 +69,7 @@ static Array convert_to_array(const ObjectData* obj, Class* cls) { // We currently do not special case ArrayObjects / ArrayIterators in // reflectionClass. Until, either ArrayObject moves to HNI or a special // case is added to reflection unset should be turned off. - assert(prop.has_val() /* && prop.type() != KindOfUninit */); + assertx(prop.has_val() /* && prop.type() != KindOfUninit */); return tvCastToArrayLike(prop.tv()); } @@ -108,7 +108,7 @@ NEVER_INLINE bool ObjectData::destructImpl() { // Some decref paths call release() when --count == 0 and some call it when // count == 1. This difference only matters for objects that resurrect // themselves in their destructors, so make sure count is consistent here. - assert(m_count == 0 || m_count == 1); + assertx(m_count == 0 || m_count == 1); m_count = static_cast(0); // We raise the refcount around the call to __destruct(). This is to prevent @@ -119,7 +119,7 @@ NEVER_INLINE bool ObjectData::destructImpl() { } void ObjectData::destructForExit() { - assert(RuntimeOption::EnableObjDestructCall); + assertx(RuntimeOption::EnableObjDestructCall); auto const dtor = m_cls->getDtor(); if (dtor) { g_context->m_liveBCObjs.erase(this); @@ -129,8 +129,8 @@ void ObjectData::destructForExit() { setNoDestruct(); // We're exiting, so there should not be any live faults. - assert(g_context->m_faults.empty()); - assert(!g_context->m_unwindingCppException); + assertx(g_context->m_faults.empty()); + assertx(!g_context->m_unwindingCppException); CountableHelper h(this); invoke_destructor(this, dtor); @@ -140,15 +140,15 @@ NEVER_INLINE static void freeDynPropArray(ObjectData* inst) { auto& table = g_context->dynPropTable; auto it = table.find(inst); - assert(it != end(table)); - assert(it->second.arr().isPHPArray()); + assertx(it != end(table)); + assertx(it->second.arr().isPHPArray()); it->second.destroy(); table.erase(it); } NEVER_INLINE void ObjectData::releaseNoObjDestructCheck() noexcept { - assert(kindIsValid()); + assertx(kindIsValid()); // Destructors are unsupported in one-bit reference counting mode. if (!one_bit_refcount && UNLIKELY(!getAttribute(NoDestructor))) { @@ -181,7 +181,7 @@ void ObjectData::releaseNoObjDestructCheck() noexcept { invalidateWeakRef(); auto const size = reinterpret_cast(stop) - reinterpret_cast(this); - assert(size == sizeForNProps(nProps)); + assertx(size == sizeForNProps(nProps)); tl_heap->objFree(this, size); AARCH64_WALKABLE_FRAME(); } @@ -193,7 +193,7 @@ static void tail_call_remove_live_bc_obj(ObjectData* obj) { } void ObjectData::release() noexcept { - assert(kindIsValid()); + assertx(kindIsValid()); if (UNLIKELY(RuntimeOption::EnableObjDestructCall && m_cls->getDtor())) { tail_call_remove_live_bc_obj(this); AARCH64_WALKABLE_FRAME(); @@ -211,7 +211,7 @@ StrNR ObjectData::getClassName() const { } bool ObjectData::instanceof(const String& s) const { - assert(kindIsValid()); + assertx(kindIsValid()); auto const cls = Unit::lookupClass(s.get()); return cls && instanceof(cls); } @@ -235,13 +235,13 @@ bool ObjectData::toBooleanImpl() const noexcept { int64_t ObjectData::toInt64Impl() const noexcept { // SimpleXMLElement is the only class that has proper custom int casting. - assert(instanceof(SimpleXMLElement_classof())); + assertx(instanceof(SimpleXMLElement_classof())); return SimpleXMLElement_objectCast(this, KindOfInt64).toInt64(); } double ObjectData::toDoubleImpl() const noexcept { // SimpleXMLElement is the only class that has custom double casting. - assert(instanceof(SimpleXMLElement_classof())); + assertx(instanceof(SimpleXMLElement_classof())); return SimpleXMLElement_objectCast(this, KindOfDouble).toDouble(); } @@ -252,7 +252,7 @@ const StaticString s_getIterator("getIterator"); Object ObjectData::iterableObject(bool& isIterable, bool mayImplementIterator /* = true */) { - assert(mayImplementIterator || !isIterator()); + assertx(mayImplementIterator || !isIterator()); if (mayImplementIterator && isIterator()) { isIterable = true; return Object(this); @@ -280,9 +280,9 @@ Object ObjectData::iterableObject(bool& isIterable, } Array& ObjectData::dynPropArray() const { - assert(getAttribute(HasDynPropArr)); - assert(g_context->dynPropTable.count(this)); - assert(g_context->dynPropTable[this].arr().isPHPArray()); + assertx(getAttribute(HasDynPropArr)); + assertx(g_context->dynPropTable.count(this)); + assertx(g_context->dynPropTable[this].arr().isPHPArray()); return g_context->dynPropTable[this].arr(); } @@ -296,16 +296,16 @@ Array& ObjectData::reserveProperties(int numDynamic /* = 2 */) { } Array& ObjectData::setDynPropArray(const Array& newArr) { - assert(!g_context->dynPropTable.count(this)); - assert(!getAttribute(HasDynPropArr)); - assert(newArr.isPHPArray()); + assertx(!g_context->dynPropTable.count(this)); + assertx(!getAttribute(HasDynPropArr)); + assertx(newArr.isPHPArray()); if (m_cls->forbidsDynamicProps()) { throw_object_forbids_dynamic_props(getClassName().data()); } auto& arr = g_context->dynPropTable[this].arr(); - assert(arr.isPHPArray()); + assertx(arr.isPHPArray()); arr = newArr; setAttribute(HasDynPropArr); return arr; @@ -319,7 +319,7 @@ TypedValue* ObjectData::makeDynProp(K key, AccessFlags flags) { Variant ObjectData::o_get(const String& propName, bool error /* = true */, const String& context /*= null_string*/) { - assert(kindIsValid()); + assertx(kindIsValid()); // This is not (just) a check for empty string; property names that start // with null are intentionally being rejected here. @@ -357,7 +357,7 @@ Variant ObjectData::o_get(const String& propName, bool error /* = true */, void ObjectData::o_set(const String& propName, const Variant& v, const String& context /* = null_string */) { - assert(kindIsValid()); + assertx(kindIsValid()); // This is not (just) a check for empty string; property names that start // with null are intentionally being rejected here. @@ -425,7 +425,7 @@ void ObjectData::o_setArray(const Array& properties) { } void ObjectData::o_getArray(Array& props, bool pubOnly /* = false */) const { - assert(kindIsValid()); + assertx(kindIsValid()); // Fast path for classes with no declared properties if (!m_cls->numDeclProperties() && getAttribute(HasDynPropArr)) { @@ -470,7 +470,7 @@ const int64_t ARRAYOBJ_STD_PROP_LIST = 1; const StaticString s_flags("flags"); Array ObjectData::toArray(bool pubOnly /* = false */) const { - assert(kindIsValid()); + assertx(kindIsValid()); // We can quickly tell if this object is a collection, which lets us avoid // checking for each class in turn if it's not one. @@ -479,11 +479,11 @@ Array ObjectData::toArray(bool pubOnly /* = false */) const { } else if (UNLIKELY(m_cls->rtAttribute(Class::CallToImpl))) { // If we end up with other classes that need special behavior, turn the // assert into an if and add cases. - assert(instanceof(SimpleXMLElement_classof())); + assertx(instanceof(SimpleXMLElement_classof())); return SimpleXMLElement_objectCast(this, KindOfArray).toArray(); } else if (UNLIKELY(instanceof(SystemLib::s_ArrayObjectClass))) { auto const flags = getProp(SystemLib::s_ArrayObjectClass, s_flags.get()); - assert(flags.has_val()); + assertx(flags.has_val()); if (UNLIKELY(flags.type() == KindOfInt64 && flags.val().num == ARRAYOBJ_STD_PROP_LIST)) { @@ -594,7 +594,7 @@ Array ObjectData::o_toIterArray(const String& context, IterMode mode) { // properties must be dynamic because you can't declare a // property with a non-string name. if (UNLIKELY(!isStringType(key.m_type))) { - assert(key.m_type == KindOfInt64); + assertx(key.m_type == KindOfInt64); switch (mode) { case CreateRefs: { auto& lval = tvAsVariant(dynProps->lvalAt(key.m_data.num).tv_ptr()); @@ -667,7 +667,7 @@ static bool decode_invoke(const String& s, ObjectData* obj, bool fatal, return false; } // We found __call! Stash the original name into invName. - assert(!(ctx.func->attrs() & AttrStatic)); + assertx(!(ctx.func->attrs() & AttrStatic)); ctx.invName = s.get(); ctx.invName->incRefCount(); ctx.dynamic = false; @@ -875,10 +875,10 @@ int64_t ObjectData::compare(const ObjectData& other) const { } Variant ObjectData::offsetGet(Variant key) { - assert(instanceof(SystemLib::s_ArrayAccessClass)); + assertx(instanceof(SystemLib::s_ArrayAccessClass)); auto const method = m_cls->lookupMethod(s_offsetGet.get()); - assert(method); + assertx(method); return g_context->invokeMethodV(this, method, InvokeArgs(key.asCell(), 1), false); @@ -913,14 +913,14 @@ void deepInitHelper(TypedValue* propVec, const TypedValueAux* propData, // called from jit code ObjectData* ObjectData::newInstanceRawSmall(Class* cls, size_t size, size_t index) { - assert(cls->getODAttrs() == DefaultAttrs); - assert(size <= kMaxSmallSize); + assertx(cls->getODAttrs() == DefaultAttrs); + assertx(size <= kMaxSmallSize); auto mem = tl_heap->mallocSmallIndexSize(index, size); return new (mem) ObjectData(cls, InitRaw{}, DefaultAttrs); } ObjectData* ObjectData::newInstanceRawBig(Class* cls, size_t size) { - assert(cls->getODAttrs() == DefaultAttrs); + assertx(cls->getODAttrs() == DefaultAttrs); auto mem = tl_heap->mallocBigSize(size); return new (mem) ObjectData(cls, InitRaw{}, DefaultAttrs); } @@ -929,7 +929,7 @@ ObjectData* ObjectData::newInstanceRawBig(Class* cls, size_t size) { ObjectData* ObjectData::newInstanceRawAttrsSmall(Class* cls, size_t size, size_t index, uint8_t attrs) { - assert(size <= kMaxSmallSize); + assertx(size <= kMaxSmallSize); auto mem = tl_heap->mallocSmallIndexSize(index, size); return new (mem) ObjectData(cls, InitRaw{}, attrs); } @@ -952,7 +952,7 @@ ObjectData::~ObjectData() { } Object ObjectData::FromArray(ArrayData* properties) { - assert(properties->isPHPArray()); + assertx(properties->isPHPArray()); Object retval{SystemLib::s_stdclassClass}; retval->setAttribute(HasDynPropArr); g_context->dynPropTable.emplace(retval.get(), properties); @@ -1454,7 +1454,7 @@ bool ObjectData::propEmpty(const Class* ctx, const StringData* key) { if (UNLIKELY(m_cls->rtAttribute(Class::CallToImpl))) { // We only get here for SimpleXMLElement or collections if (LIKELY(!isCollection())) { - assert(instanceof(SimpleXMLElement_classof())); + assertx(instanceof(SimpleXMLElement_classof())); return SimpleXMLElement_propEmpty(this, key); } } @@ -1596,7 +1596,7 @@ TypedValue* ObjectData::setOpProp(TypedValue& tvRef, // create a new dynamic property. (We know this is a new property, // or it would've hit the visible && accessible case above.) prop = makeDynProp(StrNR(key), AccessFlags::Key); - assert(prop->m_type == KindOfNull); // cannot exist yet + assertx(prop->m_type == KindOfNull); // cannot exist yet setopBody(prop, op, val); return prop; } @@ -1684,7 +1684,7 @@ Cell ObjectData::incDecProp(Class* ctx, IncDecOp op, const StringData* key) { // create a new dynamic property. (We know this is a new property, // or it would've hit the visible && accessible case above.) prop = makeDynProp(StrNR(key), AccessFlags::Key); - assert(prop->m_type == KindOfNull); // cannot exist yet + assertx(prop->m_type == KindOfNull); // cannot exist yet return IncDecBody(op, prop); } @@ -1763,7 +1763,7 @@ void ObjectData::getProp(const Class* klass, } Slot propInd = klass->lookupDeclProp(prop->name()); - assert(propInd != kInvalidSlot); + assertx(propInd != kInvalidSlot); const TypedValue* propVal = &propVec()[propInd]; if ((!pubOnly || (prop->attrs() & AttrPublic)) && @@ -1790,8 +1790,8 @@ void ObjectData::getProps(const Class* klass, bool pubOnly, void ObjectData::getTraitProps(const Class* klass, bool pubOnly, const Class* trait, Array& props, std::vector& inserted) const { - assert(isNormalClass(klass)); - assert(isTrait(trait)); + assertx(isNormalClass(klass)); + assertx(isTrait(trait)); getProps(klass, pubOnly, trait->preClass(), props, inserted); for (auto const& traitCls : trait->usedTraitClasses()) { diff --git a/hphp/runtime/base/object-data.h b/hphp/runtime/base/object-data.h index 06f5d829cf3..7e2b98af2d2 100644 --- a/hphp/runtime/base/object-data.h +++ b/hphp/runtime/base/object-data.h @@ -118,7 +118,7 @@ struct ObjectData : Countable, type_scan::MarkCollectable { public: ALWAYS_INLINE void decRefAndRelease() { - assert(kindIsValid()); + assertx(kindIsValid()); if (decReleaseCheck()) release(); } bool kindIsValid() const { return isObjectKind(headerKind()); } @@ -493,8 +493,8 @@ ALWAYS_INLINE void tvWriteObject(ObjectData* pobj, TypedValue* to) { } inline ObjectData* instanceFromTv(TypedValue* tv) { - assert(tv->m_type == KindOfObject); - assert(dynamic_cast(tv->m_data.pobj)); + assertx(tv->m_type == KindOfObject); + assertx(dynamic_cast(tv->m_data.pobj)); return tv->m_data.pobj; } @@ -524,7 +524,7 @@ typename std::enable_if< (void)type_scan::getIndexForMalloc(); // ensure T* ptrs are interesting try { auto t = new (mem) T(std::forward(args)...); - assert(t->hasExactlyOneRef()); + assertx(t->hasExactlyOneRef()); return req::ptr::attach(t); } catch (...) { tl_heap->objFree(mem, sizeof(T)); diff --git a/hphp/runtime/base/output-file.cpp b/hphp/runtime/base/output-file.cpp index 0dd2bb975a9..f983031f621 100644 --- a/hphp/runtime/base/output-file.cpp +++ b/hphp/runtime/base/output-file.cpp @@ -75,7 +75,7 @@ int OutputFile::getc() { } int64_t OutputFile::writeImpl(const char *buffer, int64_t length) { - assert(length > 0); + assertx(length > 0); if (isClosed()) return 0; g_context->write(buffer, length); return length; diff --git a/hphp/runtime/base/packed-array-defs.h b/hphp/runtime/base/packed-array-defs.h index 6ecf91c38fe..b30213ea717 100644 --- a/hphp/runtime/base/packed-array-defs.h +++ b/hphp/runtime/base/packed-array-defs.h @@ -94,7 +94,7 @@ size_t PackedArray::capacityToSizeIndex(size_t cap) { auto const sizeIndex = MemoryManager::size2Index( sizeof(ArrayData) + cap * sizeof(TypedValue) ); - assert(sizeIndex <= PackedArray::MaxSizeIndex); + assertx(sizeIndex <= PackedArray::MaxSizeIndex); return sizeIndex; } @@ -123,14 +123,14 @@ uint8_t PackedArray::sizeClass(const ArrayData* ad) { } inline void PackedArray::scan(const ArrayData* a, type_scan::Scanner& scanner) { - assert(checkInvariants(a)); + assertx(checkInvariants(a)); auto data = packedData(a); scanner.scan(*data, a->getSize() * sizeof(*data)); } template void PackedArray::IterateV(const ArrayData* arr, F fn) { - assert(checkInvariants(arr)); + assertx(checkInvariants(arr)); auto elm = packedData(arr); if (inc) arr->incRefCount(); SCOPE_EXIT { if (inc) decRefArr(const_cast(arr)); }; @@ -141,7 +141,7 @@ void PackedArray::IterateV(const ArrayData* arr, F fn) { template void PackedArray::IterateKV(const ArrayData* arr, F fn) { - assert(checkInvariants(arr)); + assertx(checkInvariants(arr)); auto elm = packedData(arr); if (inc) arr->incRefCount(); SCOPE_EXIT { if (inc) decRefArr(const_cast(arr)); }; diff --git a/hphp/runtime/base/packed-array.cpp b/hphp/runtime/base/packed-array.cpp index 2f26f99ffb6..3b83f1ca386 100644 --- a/hphp/runtime/base/packed-array.cpp +++ b/hphp/runtime/base/packed-array.cpp @@ -55,7 +55,7 @@ struct PackedArray::VecInitializer { StaticValue, packSizeIndexAndDV(0, ArrayData::kNotDVArray) ); - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); } }; PackedArray::VecInitializer PackedArray::s_vec_initializer; @@ -69,7 +69,7 @@ struct PackedArray::VArrayInitializer { StaticValue, packSizeIndexAndDV(0, ArrayData::kVArray) ); - assert(RuntimeOption::EvalHackArrDVArrs || checkInvariants(ad)); + assertx(RuntimeOption::EvalHackArrDVArrs || checkInvariants(ad)); } }; PackedArray::VArrayInitializer PackedArray::s_varr_initializer; @@ -88,14 +88,14 @@ inline ArrayData* alloc_packed_static(size_t cap) { } bool PackedArray::checkInvariants(const ArrayData* arr) { - assert(arr->hasPackedLayout()); - assert(arr->checkCount()); - assert(arr->m_size <= MixedArray::MaxSize); - assert(arr->m_size <= capacity(arr)); - assert(arr->m_pos >= 0 && arr->m_pos <= arr->m_size); - assert(!arr->isPacked() || !arr->isDArray()); - assert(!arr->isVecArray() || arr->isNotDVArray()); - assert(!RuntimeOption::EvalHackArrDVArrs || arr->isNotDVArray()); + assertx(arr->hasPackedLayout()); + assertx(arr->checkCount()); + assertx(arr->m_size <= MixedArray::MaxSize); + assertx(arr->m_size <= capacity(arr)); + assertx(arr->m_pos >= 0 && arr->m_pos <= arr->m_size); + assertx(!arr->isPacked() || !arr->isDArray()); + assertx(!arr->isVecArray() || arr->isNotDVArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs || arr->isNotDVArray()); static_assert(ArrayData::kPackedKind == 0, ""); // Note that m_pos < m_size is not an invariant, because an array // that grows will only adjust m_size to zero on the old array. @@ -106,9 +106,9 @@ bool PackedArray::checkInvariants(const ArrayData* arr) { auto ptr = packedData(arr); auto const stop = ptr + arr->m_size; for (; ptr != stop; ptr++) { - assert(ptr->m_type != KindOfUninit); - assert(tvIsPlausible(*ptr)); - assert(!arr->isVecArray() || ptr->m_type != KindOfRef); + assertx(ptr->m_type != KindOfUninit); + assertx(tvIsPlausible(*ptr)); + assertx(!arr->isVecArray() || ptr->m_type != KindOfRef); } } return true; @@ -119,7 +119,7 @@ bool PackedArray::checkInvariants(const ArrayData* arr) { ALWAYS_INLINE MixedArray* PackedArray::ToMixedHeader(const ArrayData* old, size_t neededSize) { - assert(checkInvariants(old)); + assertx(checkInvariants(old)); if (UNLIKELY(RuntimeOption::EvalHackArrCompatPromoteNotices) && old->isVArray()) { @@ -138,14 +138,14 @@ MixedArray* PackedArray::ToMixedHeader(const ArrayData* old, ad->m_scale_used = scale | uint64_t{oldSize} << 32; // used=oldSize ad->m_nextKI = oldSize; - assert(ad->m_size == oldSize); - assert(ad->m_pos == old->m_pos); - assert(ad->kind() == ArrayData::kMixedKind); - assert(ad->isDArray() == old->isVArray()); - assert(ad->hasExactlyOneRef()); - assert(ad->m_used == oldSize); - assert(ad->m_scale == scale); - assert(ad->m_nextKI == oldSize); + assertx(ad->m_size == oldSize); + assertx(ad->m_pos == old->m_pos); + assertx(ad->kind() == ArrayData::kMixedKind); + assertx(ad->isDArray() == old->isVArray()); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_used == oldSize); + assertx(ad->m_scale == scale); + assertx(ad->m_nextKI == oldSize); // Can't checkInvariants yet, since we haven't populated the payload. return ad; } @@ -181,9 +181,9 @@ MixedArray* PackedArray::ToMixed(ArrayData* old) { // because copies _are_ supposed to be visible to strong iteration if (UNLIKELY(strong_iterators_exist())) move_strong_iterators(ad, old); - assert(ad->checkInvariants()); - assert(!ad->isFull()); - assert(ad->hasExactlyOneRef()); + assertx(ad->checkInvariants()); + assertx(!ad->isFull()); + assertx(ad->hasExactlyOneRef()); return ad; } @@ -194,7 +194,7 @@ MixedArray* PackedArray::ToMixed(ArrayData* old) { * guaranteed not to be full. */ MixedArray* PackedArray::ToMixedCopy(const ArrayData* old) { - assert(checkInvariants(old)); + assertx(checkInvariants(old)); auto const oldSize = old->m_size; auto const ad = ToMixedHeader(old, oldSize + 1); @@ -211,9 +211,9 @@ MixedArray* PackedArray::ToMixedCopy(const ArrayData* old) { ++dstData; } - assert(ad->checkInvariants()); - assert(!ad->isFull()); - assert(ad->hasExactlyOneRef()); + assertx(ad->checkInvariants()); + assertx(!ad->isFull()); + assertx(ad->hasExactlyOneRef()); return ad; } @@ -224,7 +224,7 @@ MixedArray* PackedArray::ToMixedCopy(const ArrayData* old) { */ MixedArray* PackedArray::ToMixedCopyReserve(const ArrayData* old, size_t neededSize) { - assert(neededSize >= old->m_size); + assertx(neededSize >= old->m_size); auto const ad = ToMixedHeader(old, neededSize); auto const oldSize = old->m_size; auto const mask = ad->mask(); @@ -240,15 +240,15 @@ MixedArray* PackedArray::ToMixedCopyReserve(const ArrayData* old, ++dstData; } - assert(ad->checkInvariants()); - assert(ad->hasExactlyOneRef()); + assertx(ad->checkInvariants()); + assertx(ad->hasExactlyOneRef()); return ad; } NEVER_INLINE ArrayData* PackedArray::Grow(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->m_size == capacity(adIn)); + assertx(checkInvariants(adIn)); + assertx(adIn->m_size == capacity(adIn)); auto const sizeIndex = sizeClass(adIn) + kSizeClassesPerDoubling; if (UNLIKELY(sizeIndex > MaxSizeIndex)) return nullptr; @@ -260,15 +260,15 @@ ArrayData* PackedArray::Grow(ArrayData* adIn, bool copy) { // afterwards is fix the capacity and refcount on the copy; it's easiest // to do that by reinitializing the whole header. auto const DEBUG_ONLY ok = CopyPackedHelper(adIn, ad); - assert(ok); + assertx(ok); ad->initHeader_16( adIn->m_kind, OneReference, packSizeIndexAndDV(sizeIndex, adIn->dvArray()) ); - assert(ad->m_size == adIn->m_size); - assert(ad->m_pos == adIn->m_pos); + assertx(ad->m_size == adIn->m_size); + assertx(ad->m_pos == adIn->m_pos); } else { // Copy everything from `adIn' to `ad', including header and m_sizeAndPos static_assert(sizeof(ArrayData) == 16 && sizeof(TypedValue) == 16, ""); @@ -279,24 +279,24 @@ ArrayData* PackedArray::Grow(ArrayData* adIn, bool copy) { packSizeIndexAndDV(sizeIndex, adIn->dvArray()) ); - assert(ad->m_size == adIn->m_size); - assert(ad->m_pos == adIn->m_pos); + assertx(ad->m_size == adIn->m_size); + assertx(ad->m_pos == adIn->m_pos); adIn->m_sizeAndPos = 0; // old is a zombie now if (UNLIKELY(strong_iterators_exist())) move_strong_iterators(ad, adIn); } - assert(ad->kind() == adIn->kind()); - assert(ad->dvArray() == adIn->dvArray()); - assert(capacity(ad) > capacity(adIn)); - assert(ad->hasExactlyOneRef()); - assert(checkInvariants(ad)); + assertx(ad->kind() == adIn->kind()); + assertx(ad->dvArray() == adIn->dvArray()); + assertx(capacity(ad) > capacity(adIn)); + assertx(ad->hasExactlyOneRef()); + assertx(checkInvariants(ad)); return ad; } ALWAYS_INLINE ArrayData* PackedArray::PrepareForInsert(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); if (adIn->m_size == capacity(adIn)) return Grow(adIn, copy); if (copy) return Copy(adIn); return adIn; @@ -326,7 +326,7 @@ bool PackedArray::CopyPackedHelper(const ArrayData* adIn, ArrayData* ad) { // Copy counted types correctly, especially RefData. for (auto elm = packedData(ad), end = elm + size; elm < end; ++elm) { if (UNLIKELY(elm->m_type == KindOfRef)) { - assert(!adIn->isVecArray()); + assertx(!adIn->isVecArray()); auto ref = elm->m_data.pref; // See also tvDupWithRef() if (!ref->isReferenced() && ref->tv()->m_data.parr != adIn) { @@ -346,7 +346,7 @@ bool PackedArray::CopyPackedHelper(const ArrayData* adIn, ArrayData* ad) { NEVER_INLINE ArrayData* PackedArray::Copy(const ArrayData* adIn) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto ad = static_cast(tl_heap->objMallocIndex(sizeClass(adIn))); @@ -354,20 +354,20 @@ ArrayData* PackedArray::Copy(const ArrayData* adIn) { // m_sizeAndPos; since we pass convertingPackedToVec = false, it can't fail. // All we have to do afterwards is fix the refcount on the copy. auto const DEBUG_ONLY ok = CopyPackedHelper(adIn, ad); - assert(ok); + assertx(ok); ad->m_count = OneReference; - assert(ad->kind() == adIn->kind()); - assert(capacity(ad) == capacity(adIn)); - assert(ad->m_size == adIn->m_size); - assert(ad->m_pos == adIn->m_pos); - assert(ad->hasExactlyOneRef()); - assert(checkInvariants(ad)); + assertx(ad->kind() == adIn->kind()); + assertx(capacity(ad) == capacity(adIn)); + assertx(ad->m_size == adIn->m_size); + assertx(ad->m_pos == adIn->m_pos); + assertx(ad->hasExactlyOneRef()); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::CopyStatic(const ArrayData* adIn) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const sizeIndex = capacityToSizeIndex(adIn->m_size); auto ad = alloc_packed_static(adIn->m_size); @@ -376,27 +376,27 @@ ArrayData* PackedArray::CopyStatic(const ArrayData* adIn) { // is fix the capacity and refcount on the copy; it's easiest to do that by // reinitializing the whole header. auto const DEBUG_ONLY ok = CopyPackedHelper(adIn, ad); - assert(ok); + assertx(ok); ad->initHeader_16( adIn->m_kind, StaticValue, packSizeIndexAndDV(sizeIndex, adIn->dvArray()) ); - assert(ad->kind() == adIn->kind()); - assert(ad->dvArray() == adIn->dvArray()); - assert(capacity(ad) >= adIn->m_size); - assert(ad->m_size == adIn->m_size); - assert(ad->m_pos == adIn->m_pos); - assert(ad->isStatic()); - assert(checkInvariants(ad)); + assertx(ad->kind() == adIn->kind()); + assertx(ad->dvArray() == adIn->dvArray()); + assertx(capacity(ad) >= adIn->m_size); + assertx(ad->m_size == adIn->m_size); + assertx(ad->m_pos == adIn->m_pos); + assertx(ad->isStatic()); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::ConvertStatic(const ArrayData* arr) { - assert(arr->isVectorData()); - assert(!RuntimeOption::EvalHackArrDVArrs || arr->isNotDVArray()); - assert(!arr->isDArray()); + assertx(arr->isVectorData()); + assertx(!RuntimeOption::EvalHackArrDVArrs || arr->isNotDVArray()); + assertx(!arr->isDArray()); auto const sizeIndex = capacityToSizeIndex(arr->m_size); auto ad = alloc_packed_static(arr->m_size); @@ -414,13 +414,13 @@ ArrayData* PackedArray::ConvertStatic(const ArrayData* arr) { tvDupWithRef(arr->atPos(pos), *data, arr); } - assert(ad->isPacked()); - assert(capacity(ad) >= arr->m_size); - assert(ad->dvArray() == arr->dvArray()); - assert(ad->m_size == arr->m_size); - assert(ad->m_pos == arr->m_pos); - assert(ad->isStatic()); - assert(checkInvariants(ad)); + assertx(ad->isPacked()); + assertx(capacity(ad) >= arr->m_size); + assertx(ad->dvArray() == arr->dvArray()); + assertx(ad->m_size == arr->m_size); + assertx(ad->m_pos == arr->m_pos); + assertx(ad->isStatic()); + assertx(checkInvariants(ad)); return ad; } @@ -432,7 +432,7 @@ ALWAYS_INLINE ArrayData* PackedArray::MakeReserveImpl(uint32_t cap, HeaderKind hk, ArrayData::DVArray dvarray) { - assert(!RuntimeOption::EvalHackArrDVArrs || + assertx(!RuntimeOption::EvalHackArrDVArrs || dvarray == ArrayData::kNotDVArray); auto const sizeIndex = capacityToSizeIndex(cap); auto ad = static_cast(tl_heap->objMallocIndex(sizeIndex)); @@ -441,10 +441,10 @@ ArrayData* PackedArray::MakeReserveImpl(uint32_t cap, OneReference, packSizeIndexAndDV(sizeIndex, dvarray) ); - assert(ad->m_kind == hk); - assert(ad->dvArray() == dvarray); - assert(capacity(ad) >= cap); - assert(ad->hasExactlyOneRef()); + assertx(ad->m_kind == hk); + assertx(ad->dvArray() == dvarray); + assertx(capacity(ad) >= cap); + assertx(ad->hasExactlyOneRef()); return ad; } @@ -452,22 +452,22 @@ ArrayData* PackedArray::MakeReserve(uint32_t capacity) { auto ad = MakeReserveImpl(capacity, HeaderKind::Packed, ArrayData::kNotDVArray); ad->m_sizeAndPos = 0; - assert(ad->isPacked()); - assert(ad->isNotDVArray()); - assert(ad->m_size == 0); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->isPacked()); + assertx(ad->isNotDVArray()); + assertx(ad->m_size == 0); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::MakeReserveVArray(uint32_t capacity) { auto ad = MakeReserveImpl(capacity, HeaderKind::Packed, ArrayData::kVArray); ad->m_sizeAndPos = 0; - assert(ad->isPacked()); - assert(ad->isVArray()); - assert(ad->m_size == 0); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->isPacked()); + assertx(ad->isVArray()); + assertx(ad->m_size == 0); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } @@ -475,10 +475,10 @@ ArrayData* PackedArray::MakeReserveVec(uint32_t capacity) { auto ad = MakeReserveImpl(capacity, HeaderKind::VecArray, ArrayData::kNotDVArray); ad->m_sizeAndPos = 0; - assert(ad->isVecArray()); - assert(ad->m_size == 0); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->isVecArray()); + assertx(ad->m_size == 0); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } @@ -488,7 +488,7 @@ ArrayData* PackedArray::MakePackedImpl(uint32_t size, const Cell* values, HeaderKind hk, ArrayData::DVArray dv) { - assert(size > 0); + assertx(size > 0); auto ad = MakeReserveImpl(size, hk, dv); ad->m_sizeAndPos = size; // pos = 0 @@ -507,9 +507,9 @@ ArrayData* PackedArray::MakePackedImpl(uint32_t size, memcpy16_inline(packedData(ad), values, sizeof(Cell) * size); } - assert(ad->m_size == size); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->m_size == size); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } @@ -518,19 +518,19 @@ ArrayData* PackedArray::MakePacked(uint32_t size, const Cell* values) { // grows down. auto ad = MakePackedImpl(size, values, HeaderKind::Packed, ArrayData::kNotDVArray); - assert(ad->isPacked()); - assert(ad->isNotDVArray()); + assertx(ad->isPacked()); + assertx(ad->isNotDVArray()); return ad; } ArrayData* PackedArray::MakeVArray(uint32_t size, const Cell* values) { // Values are in reverse order since they come from the stack, which // grows down. - assert(!RuntimeOption::EvalHackArrDVArrs); + assertx(!RuntimeOption::EvalHackArrDVArrs); auto ad = MakePackedImpl(size, values, HeaderKind::Packed, ArrayData::kVArray); - assert(ad->isPacked()); - assert(ad->isVArray()); + assertx(ad->isPacked()); + assertx(ad->isVArray()); return ad; } @@ -539,53 +539,53 @@ ArrayData* PackedArray::MakeVec(uint32_t size, const Cell* values) { // grows down. auto ad = MakePackedImpl(size, values, HeaderKind::VecArray, ArrayData::kNotDVArray); - assert(ad->isVecArray()); + assertx(ad->isVecArray()); return ad; } ArrayData* PackedArray::MakePackedNatural(uint32_t size, const Cell* values) { auto ad = MakePackedImpl(size, values, HeaderKind::Packed, ArrayData::kNotDVArray); - assert(ad->isPacked()); - assert(ad->isNotDVArray()); + assertx(ad->isPacked()); + assertx(ad->isNotDVArray()); return ad; } ArrayData* PackedArray::MakeUninitialized(uint32_t size) { auto ad = MakeReserveImpl(size, HeaderKind::Packed, ArrayData::kNotDVArray); ad->m_sizeAndPos = size; // pos = 0 - assert(ad->isPacked()); - assert(ad->isNotDVArray()); - assert(ad->m_size == size); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->isPacked()); + assertx(ad->isNotDVArray()); + assertx(ad->m_size == size); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::MakeUninitializedVArray(uint32_t size) { - assert(!RuntimeOption::EvalHackArrDVArrs); + assertx(!RuntimeOption::EvalHackArrDVArrs); auto ad = MakeReserveImpl(size, HeaderKind::Packed, ArrayData::kVArray); ad->m_sizeAndPos = size; // pos = 0 - assert(ad->isPacked()); - assert(ad->isVArray()); - assert(ad->m_size == size); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->isPacked()); + assertx(ad->isVArray()); + assertx(ad->m_size == size); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::MakeUninitializedVec(uint32_t size) { auto ad = MakeReserveImpl(size, HeaderKind::VecArray, ArrayData::kNotDVArray); ad->m_sizeAndPos = size; // pos = 0 - assert(ad->isVecArray()); - assert(ad->m_size == size); - assert(ad->m_pos == 0); - assert(checkInvariants(ad)); + assertx(ad->isVecArray()); + assertx(ad->m_size == size); + assertx(ad->m_pos == 0); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::MakeVecFromAPC(const APCArray* apc) { - assert(apc->isVec()); + assertx(apc->isVec()); auto const apcSize = apc->size(); VecArrayInit init{apcSize}; for (uint32_t i = 0; i < apcSize; ++i) { @@ -595,8 +595,8 @@ ArrayData* PackedArray::MakeVecFromAPC(const APCArray* apc) { } ArrayData* PackedArray::MakeVArrayFromAPC(const APCArray* apc) { - assert(!RuntimeOption::EvalHackArrDVArrs); - assert(apc->isVArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs); + assertx(apc->isVArray()); auto const apcSize = apc->size(); VArrayInit init{apcSize}; for (uint32_t i = 0; i < apcSize; ++i) { @@ -606,9 +606,9 @@ ArrayData* PackedArray::MakeVArrayFromAPC(const APCArray* apc) { } void PackedArray::Release(ArrayData* ad) { - assert(checkInvariants(ad)); - assert(ad->isRefCounted()); - assert(ad->hasExactlyOneRef()); + assertx(checkInvariants(ad)); + assertx(ad->isRefCounted()); + assertx(ad->hasExactlyOneRef()); for (auto elm = packedData(ad), end = elm + ad->m_size; elm < end; ++elm) { tvDecRefGen(elm); @@ -622,7 +622,7 @@ void PackedArray::Release(ArrayData* ad) { NEVER_INLINE void PackedArray::ReleaseUncounted(ArrayData* ad) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); if (!ad->uncountedDecRef()) return; auto const data = packedData(ad); @@ -632,7 +632,7 @@ void PackedArray::ReleaseUncounted(ArrayData* ad) { } // We better not have strong iterators associated with uncounted arrays. - assert(!has_strong_iterator(ad)); + assertx(!has_strong_iterator(ad)); if (APCStats::IsCreated()) { APCStats::getAPCStats().removeAPCUncountedBlock(); } @@ -644,20 +644,20 @@ void PackedArray::ReleaseUncounted(ArrayData* ad) { //////////////////////////////////////////////////////////////////////////////// member_rval::ptr_u PackedArray::NvGetInt(const ArrayData* ad, int64_t ki) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); auto const data = packedData(ad); return LIKELY(size_t(ki) < ad->m_size) ? &data[ki] : nullptr; } member_rval::ptr_u PackedArray::NvGetStr(const ArrayData* ad, const StringData* /*s*/) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return nullptr; } member_rval::ptr_u PackedArray::NvTryGetIntVec(const ArrayData* ad, int64_t k) { - assert(checkInvariants(ad)); - assert(ad->isVecArray()); + assertx(checkInvariants(ad)); + assertx(ad->isVecArray()); auto const data = packedData(ad); if (LIKELY(size_t(k) < ad->m_size)) return &data[k]; throwOOBArrayKeyException(k, ad); @@ -665,14 +665,14 @@ member_rval::ptr_u PackedArray::NvTryGetIntVec(const ArrayData* ad, int64_t k) { member_rval::ptr_u PackedArray::NvTryGetStrVec(const ArrayData* ad, const StringData* s) { - assert(checkInvariants(ad)); - assert(ad->isVecArray()); + assertx(checkInvariants(ad)); + assertx(ad->isVecArray()); throwInvalidArrayKeyException(s, ad); } Cell PackedArray::NvGetKey(const ArrayData* ad, ssize_t pos) { - assert(checkInvariants(ad)); - assert(pos != ad->m_size); + assertx(checkInvariants(ad)); + assertx(pos != ad->m_size); return make_tv(pos); } @@ -682,18 +682,18 @@ size_t PackedArray::Vsize(const ArrayData*) { } member_rval::ptr_u PackedArray::GetValueRef(const ArrayData* ad, ssize_t pos) { - assert(checkInvariants(ad)); - assert(pos != ad->m_size); + assertx(checkInvariants(ad)); + assertx(pos != ad->m_size); return &packedData(ad)[pos]; } bool PackedArray::ExistsInt(const ArrayData* ad, int64_t k) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return size_t(k) < ad->m_size; } bool PackedArray::ExistsStr(const ArrayData* ad, const StringData* /*s*/) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return false; } @@ -704,8 +704,8 @@ namespace { template auto MutableOpInt(ArrayData* adIn, int64_t k, bool copy, FoundFn found, AppendFn append, PromotedFn promoted) { - assert(PackedArray::checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(PackedArray::checkInvariants(adIn)); + assertx(adIn->isPacked()); if (LIKELY(size_t(k) < adIn->getSize())) { auto const ad = copy ? PackedArray::Copy(adIn) : adIn; @@ -728,8 +728,8 @@ auto MutableOpInt(ArrayData* adIn, int64_t k, bool copy, template auto MutableOpStr(ArrayData* adIn, StringData* k, bool copy, PromotedFn promoted) { - assert(PackedArray::checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(PackedArray::checkInvariants(adIn)); + assertx(adIn->isPacked()); auto const mixed = copy ? PackedArray::ToMixedCopy(adIn) : PackedArray::ToMixed(adIn); @@ -738,8 +738,8 @@ auto MutableOpStr(ArrayData* adIn, StringData* k, bool copy, template auto MutableOpIntVec(ArrayData* adIn, int64_t k, bool copy, FoundFn found) { - assert(PackedArray::checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(PackedArray::checkInvariants(adIn)); + assertx(adIn->isVecArray()); if (UNLIKELY(size_t(k) >= adIn->getSize())) { throwOOBArrayKeyException(k, adIn); @@ -771,7 +771,7 @@ member_lval PackedArray::LvalIntVec(ArrayData* adIn, int64_t k, bool copy) { } member_lval PackedArray::LvalSilentInt(ArrayData* adIn, int64_t k, bool copy) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); if (UNLIKELY(size_t(k) >= adIn->m_size)) return {adIn, nullptr}; auto const ad = copy ? Copy(adIn) : adIn; return member_lval { ad, &packedData(ad)[k] }; @@ -792,26 +792,26 @@ PackedArray::LvalStrRef(ArrayData* adIn, StringData* key, bool copy) { member_lval PackedArray::LvalStrVec(ArrayData* adIn, StringData* key, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwInvalidArrayKeyException(key, adIn); } member_lval PackedArray::LvalIntRefVec(ArrayData* adIn, int64_t /*k*/, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwRefInvalidArrayValueException(adIn); } member_lval PackedArray::LvalStrRefVec(ArrayData* adIn, StringData* key, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwInvalidArrayKeyException(key, adIn); } member_lval PackedArray::LvalNew(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const ad = PrepareForInsert(adIn, copy); auto& tv = packedData(ad)[ad->m_size++]; tv.m_type = KindOfNull; @@ -824,8 +824,8 @@ member_lval PackedArray::LvalNewRef(ArrayData* adIn, bool copy) { } member_lval PackedArray::LvalNewRefVec(ArrayData* adIn, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwRefInvalidArrayValueException(adIn); } @@ -852,8 +852,8 @@ ArrayData* PackedArray::SetStr(ArrayData* adIn, StringData* k, Cell v, } ArrayData* PackedArray::SetStrVec(ArrayData* adIn, StringData* k, Cell, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwInvalidArrayKeyException(k, adIn); } @@ -906,8 +906,8 @@ ArrayData* PackedArray::SetWithRefStr(ArrayData* adIn, StringData* k, ArrayData* PackedArray::SetWithRefStrVec(ArrayData* adIn, StringData* k, TypedValue, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwInvalidArrayKeyException(k, adIn); } @@ -929,8 +929,8 @@ ArrayData* PackedArray::SetRefInt(ArrayData* adIn, int64_t k, ArrayData* PackedArray::SetRefIntVec(ArrayData* adIn, int64_t, member_lval, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwRefInvalidArrayValueException(adIn); } @@ -946,8 +946,8 @@ ArrayData* PackedArray::SetRefStr(ArrayData* adIn, StringData* k, ArrayData* PackedArray::SetRefStrVec(ArrayData* adIn, StringData* k, member_lval, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwInvalidArrayKeyException(k, adIn); } @@ -956,7 +956,7 @@ ArrayData* PackedArray::SetRefStrVec(ArrayData* adIn, StringData* k, namespace { void adjustMArrayIterAfterPop(ArrayData* ad) { - assert(ad->hasPackedLayout()); + assertx(ad->hasPackedLayout()); auto const size = ad->getSize(); if (size) { for_each_strong_iterator([&] (MIterTable::Ent& miEnt) { @@ -973,8 +973,8 @@ void adjustMArrayIterAfterPop(ArrayData* ad) { } ArrayData* PackedArray::RemoveInt(ArrayData* adIn, int64_t k, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); if (size_t(k) < adIn->m_size) { // Escalate to mixed for correctness; unset preserves m_nextKI. // @@ -1017,22 +1017,22 @@ PackedArray::RemoveStr(ArrayData* adIn, const StringData*, bool) { } ssize_t PackedArray::IterBegin(const ArrayData* ad) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return 0; } ssize_t PackedArray::IterLast(const ArrayData* ad) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return ad->m_size ? ad->m_size - 1 : 0; } ssize_t PackedArray::IterEnd(const ArrayData* ad) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return ad->m_size; } ssize_t PackedArray::IterAdvance(const ArrayData* ad, ssize_t pos) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); if (pos < ad->m_size) { ++pos; } @@ -1040,7 +1040,7 @@ ssize_t PackedArray::IterAdvance(const ArrayData* ad, ssize_t pos) { } ssize_t PackedArray::IterRewind(const ArrayData* ad, ssize_t pos) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); if (pos > 0) { return pos - 1; } @@ -1048,7 +1048,7 @@ ssize_t PackedArray::IterRewind(const ArrayData* ad, ssize_t pos) { } bool PackedArray::AdvanceMArrayIter(ArrayData* ad, MArrayIter& fp) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); if (fp.getResetFlag()) { fp.setResetFlag(false); fp.m_pos = 0; @@ -1067,7 +1067,7 @@ bool PackedArray::AdvanceMArrayIter(ArrayData* ad, MArrayIter& fp) { } ArrayData* PackedArray::Append(ArrayData* adIn, Cell v, bool copy) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); assertx(v.m_type != KindOfUninit); auto const ad = PrepareForInsert(adIn, copy); cellDup(v, packedData(ad)[ad->m_size++]); @@ -1075,8 +1075,8 @@ ArrayData* PackedArray::Append(ArrayData* adIn, Cell v, bool copy) { } ArrayData* PackedArray::AppendRef(ArrayData* adIn, member_lval v, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); if (checkHACRefBind()) raiseHackArrCompatRefNew(); auto const ad = PrepareForInsert(adIn, copy); auto& dst = packedData(ad)[ad->m_size++]; @@ -1088,15 +1088,15 @@ ArrayData* PackedArray::AppendRef(ArrayData* adIn, member_lval v, bool copy) { } ArrayData* PackedArray::AppendRefVec(ArrayData* adIn, member_lval, bool) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwRefInvalidArrayValueException(adIn); } ArrayData* PackedArray::AppendWithRef(ArrayData* adIn, TypedValue v, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); if (checkHACRefBind() && tvIsReferenced(v)) { raiseHackArrCompatRefNew(); @@ -1111,22 +1111,22 @@ PackedArray::AppendWithRef(ArrayData* adIn, TypedValue v, bool copy) { ArrayData* PackedArray::AppendWithRefVec(ArrayData* adIn, TypedValue v, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); if (tvIsReferenced(v)) throwRefInvalidArrayValueException(adIn); return Append(adIn, tvToInitCell(v), copy); } ArrayData* PackedArray::PlusEq(ArrayData* adIn, const ArrayData* elems) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); if (!elems->isPHPArray()) throwInvalidAdditionException(elems); auto const neededSize = adIn->size() + elems->size(); auto const mixed = ToMixedCopyReserve(adIn, neededSize); try { auto const ret = MixedArray::PlusEq(mixed, elems); - assert(ret == mixed); - assert(mixed->hasExactlyOneRef()); + assertx(ret == mixed); + assertx(mixed->hasExactlyOneRef()); return ret; } catch (...) { MixedArray::Release(mixed); @@ -1135,13 +1135,13 @@ ArrayData* PackedArray::PlusEq(ArrayData* adIn, const ArrayData* elems) { } ArrayData* PackedArray::PlusEqVec(ArrayData* adIn, const ArrayData* /*elems*/) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); throwInvalidAdditionException(adIn); } ArrayData* PackedArray::Merge(ArrayData* adIn, const ArrayData* elems) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const neededSize = adIn->m_size + elems->size(); auto const ret = ToMixedCopyReserve(adIn, neededSize); ret->setDVArray(ArrayData::kNotDVArray); @@ -1149,12 +1149,12 @@ ArrayData* PackedArray::Merge(ArrayData* adIn, const ArrayData* elems) { } ArrayData* PackedArray::Pop(ArrayData* adIn, Variant& value) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const ad = adIn->cowCheck() ? Copy(adIn) : adIn; if (UNLIKELY(ad->m_size == 0)) { - assert(ad->m_pos == 0); + assertx(ad->m_pos == 0); value = uninit_null(); return ad; } @@ -1171,7 +1171,7 @@ ArrayData* PackedArray::Pop(ArrayData* adIn, Variant& value) { } ArrayData* PackedArray::Dequeue(ArrayData* adIn, Variant& value) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const ad = adIn->cowCheck() ? Copy(adIn) : adIn; // To conform to PHP behavior, we invalidate all strong iterators when an @@ -1197,7 +1197,7 @@ ArrayData* PackedArray::Dequeue(ArrayData* adIn, Variant& value) { } ArrayData* PackedArray::Prepend(ArrayData* adIn, Cell v, bool /*copy*/) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const ad = PrepareForInsert(adIn, adIn->cowCheck()); @@ -1217,31 +1217,31 @@ ArrayData* PackedArray::Prepend(ArrayData* adIn, Cell v, bool /*copy*/) { } ArrayData* PackedArray::ToPHPArray(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); if (adIn->isNotDVArray()) return adIn; - assert(adIn->isVArray()); + assertx(adIn->isVArray()); if (adIn->getSize() == 0) return staticEmptyArray(); ArrayData* ad = copy ? Copy(adIn) : adIn; ad->setDVArray(ArrayData::kNotDVArray); - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::ToVArray(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); if (RuntimeOption::EvalHackArrDVArrs) return ToVec(adIn, copy); if (adIn->isVArray()) return adIn; if (adIn->getSize() == 0) return staticEmptyVArray(); ArrayData* ad = copy ? Copy(adIn) : adIn; ad->setDVArray(ArrayData::kVArray); - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::ToDArray(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); + assertx(checkInvariants(adIn)); auto const size = adIn->getSize(); if (size == 0) return staticEmptyDArray(); @@ -1253,30 +1253,30 @@ ArrayData* PackedArray::ToDArray(ArrayData* adIn, bool copy) { } ArrayData* PackedArray::ToPHPArrayVec(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); ArrayData* ad = copy ? Copy(adIn) : adIn; ad->m_kind = HeaderKind::Packed; - assert(ad->isNotDVArray()); - assert(checkInvariants(ad)); + assertx(ad->isNotDVArray()); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::ToVArrayVec(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isVecArray()); + assertx(checkInvariants(adIn)); + assertx(adIn->isVecArray()); if (RuntimeOption::EvalHackArrDVArrs) return adIn; if (adIn->getSize() == 0) return staticEmptyVArray(); ArrayData* ad = copy ? Copy(adIn) : adIn; ad->m_kind = HeaderKind::Packed; ad->setDVArray(ArrayData::kVArray); - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::ToDict(ArrayData* ad, bool copy) { - assert(checkInvariants(ad)); - assert(ad->isPacked()); + assertx(checkInvariants(ad)); + assertx(ad->isPacked()); auto mixed = [&] { switch (ArrayCommon::CheckForRefs(ad)) { @@ -1295,15 +1295,15 @@ ArrayData* PackedArray::ToDict(ArrayData* ad, bool copy) { } ArrayData* PackedArray::ToDictVec(ArrayData* ad, bool copy) { - assert(checkInvariants(ad)); - assert(ad->isVecArray()); + assertx(checkInvariants(ad)); + assertx(ad->isVecArray()); auto mixed = copy ? ToMixedCopy(ad) : ToMixed(ad); return MixedArray::ToDictInPlace(mixed); } ArrayData* PackedArray::ToVec(ArrayData* adIn, bool copy) { - assert(checkInvariants(adIn)); - assert(adIn->isPacked()); + assertx(checkInvariants(adIn)); + assertx(adIn->isPacked()); auto const do_copy = [&] { // CopyPackedHelper will copy the header and m_sizeAndPos; since we pass @@ -1340,23 +1340,23 @@ ArrayData* PackedArray::ToVec(ArrayData* adIn, bool copy) { } } - assert(ad->isVecArray()); - assert(capacity(ad) == capacity(adIn)); - assert(ad->m_size == adIn->m_size); - assert(ad->m_pos == adIn->m_pos); - assert(ad->hasExactlyOneRef()); - assert(checkInvariants(ad)); + assertx(ad->isVecArray()); + assertx(capacity(ad) == capacity(adIn)); + assertx(ad->m_size == adIn->m_size); + assertx(ad->m_pos == adIn->m_pos); + assertx(ad->hasExactlyOneRef()); + assertx(checkInvariants(ad)); return ad; } ArrayData* PackedArray::ToVecVec(ArrayData* ad, bool) { - assert(checkInvariants(ad)); - assert(ad->isVecArray()); + assertx(checkInvariants(ad)); + assertx(ad->isVecArray()); return ad; } void PackedArray::OnSetEvalScalar(ArrayData* ad) { - assert(checkInvariants(ad)); + assertx(checkInvariants(ad)); auto ptr = packedData(ad); auto const stop = ptr + ad->m_size; for (; ptr != stop; ++ptr) { @@ -1365,20 +1365,20 @@ void PackedArray::OnSetEvalScalar(ArrayData* ad) { } void PackedArray::Ksort(ArrayData* ad, int /*flags*/, bool ascending) { - assert(ad->getSize() <= 1 || ascending); + assertx(ad->getSize() <= 1 || ascending); } void PackedArray::Asort(ArrayData* ad, int, bool) { - assert(ad->getSize() <= 1); + assertx(ad->getSize() <= 1); } bool PackedArray::Uksort(ArrayData* ad, const Variant&) { - assert(ad->getSize() <= 1); + assertx(ad->getSize() <= 1); return true; } bool PackedArray::Uasort(ArrayData* ad, const Variant&) { - assert(ad->getSize() <= 1); + assertx(ad->getSize() <= 1); return true; } @@ -1388,7 +1388,7 @@ ArrayData* PackedArray::MakeUncounted(ArrayData* array, void** seenVal = nullptr; if (seen && array->hasMultipleRefs()) { auto it = seen->find(array); - assert(it != seen->end()); + assertx(it != seen->end()); seenVal = &it->second; if (auto const arr = static_cast(*seenVal)) { if (arr->uncountedIncRef()) { @@ -1396,8 +1396,8 @@ ArrayData* PackedArray::MakeUncounted(ArrayData* array, } } } - assert(checkInvariants(array)); - assert(!array->empty()); + assertx(checkInvariants(array)); + assertx(!array->empty()); if (APCStats::IsCreated()) { APCStats::getAPCStats().addAPCUncountedBlock(); } @@ -1426,13 +1426,13 @@ ArrayData* PackedArray::MakeUncounted(ArrayData* array, ConvertTvToUncounted(dst, seen); } - assert(ad->kind() == array->kind()); - assert(ad->dvArray() == array->dvArray()); - assert(capacity(ad) >= size); - assert(ad->m_size == size); - assert(ad->m_pos == array->m_pos); - assert(ad->isUncounted()); - assert(checkInvariants(ad)); + assertx(ad->kind() == array->kind()); + assertx(ad->dvArray() == array->dvArray()); + assertx(capacity(ad) >= size); + assertx(ad->m_size == size); + assertx(ad->m_pos == array->m_pos); + assertx(ad->isUncounted()); + assertx(checkInvariants(ad)); if (seenVal) *seenVal = ad; return ad; } @@ -1440,10 +1440,10 @@ ArrayData* PackedArray::MakeUncounted(ArrayData* array, ALWAYS_INLINE bool PackedArray::VecEqualHelper(const ArrayData* ad1, const ArrayData* ad2, bool strict) { - assert(checkInvariants(ad1)); - assert(checkInvariants(ad2)); - assert(ad1->isVecArray()); - assert(ad2->isVecArray()); + assertx(checkInvariants(ad1)); + assertx(checkInvariants(ad2)); + assertx(ad1->isVecArray()); + assertx(ad2->isVecArray()); if (ad1 == ad2) return true; if (ad1->m_size != ad2->m_size) return false; @@ -1469,10 +1469,10 @@ bool PackedArray::VecEqualHelper(const ArrayData* ad1, const ArrayData* ad2, ALWAYS_INLINE int64_t PackedArray::VecCmpHelper(const ArrayData* ad1, const ArrayData* ad2) { - assert(checkInvariants(ad1)); - assert(checkInvariants(ad2)); - assert(ad1->isVecArray()); - assert(ad2->isVecArray()); + assertx(checkInvariants(ad1)); + assertx(checkInvariants(ad2)); + assertx(ad1->isVecArray()); + assertx(ad2->isVecArray()); auto const size1 = ad1->m_size; auto const size2 = ad2->m_size; diff --git a/hphp/runtime/base/pipe.cpp b/hphp/runtime/base/pipe.cpp index 00b53a23a2b..ef53bf52d23 100644 --- a/hphp/runtime/base/pipe.cpp +++ b/hphp/runtime/base/pipe.cpp @@ -37,8 +37,8 @@ Pipe::~Pipe() { } bool Pipe::open(const String& filename, const String& mode) { - assert(m_stream == nullptr); - assert(getFd() == -1); + assertx(m_stream == nullptr); + assertx(getFd() == -1); #ifdef _MSC_VER auto old_cwd = Process::GetCurrentDirectory(); @@ -66,7 +66,7 @@ bool Pipe::closeImpl() { bool ret = true; s_pcloseRet = 0; if (valid() && !isClosed()) { - assert(m_stream); + assertx(m_stream); #ifdef _MSC_VER int pcloseRet = _pclose(m_stream); #else diff --git a/hphp/runtime/base/plain-file.cpp b/hphp/runtime/base/plain-file.cpp index 594c68d2362..e9394e9b46e 100644 --- a/hphp/runtime/base/plain-file.cpp +++ b/hphp/runtime/base/plain-file.cpp @@ -93,8 +93,8 @@ void PlainFile::sweep() { bool PlainFile::open(const String& filename, const String& mode) { int fd; FILE *f; - assert(m_stream == nullptr); - assert(getFd() == -1); + assertx(m_stream == nullptr); + assertx(getFd() == -1); // For these definded in php fopen but C stream have different modes switch (mode[0]) { @@ -166,8 +166,8 @@ bool PlainFile::closeImpl() { // virtual functions int64_t PlainFile::readImpl(char *buffer, int64_t length) { - assert(valid()); - assert(length > 0); + assertx(valid()); + assertx(length > 0); // use read instead of fread to handle EOL in stdin size_t ret = ::read(getFd(), buffer, length); if (ret == 0 @@ -179,7 +179,7 @@ int64_t PlainFile::readImpl(char *buffer, int64_t length) { } int PlainFile::getc() { - assert(valid()); + assertx(valid()); return File::getc(); } @@ -196,8 +196,8 @@ String PlainFile::read(int64_t length) { } int64_t PlainFile::writeImpl(const char *buffer, int64_t length) { - assert(valid()); - assert(length > 0); + assertx(valid()); + assertx(length > 0); // use write instead of fwrite to be consistent with read // o.w., read-and-write files would not work @@ -206,7 +206,7 @@ int64_t PlainFile::writeImpl(const char *buffer, int64_t length) { } bool PlainFile::seek(int64_t offset, int whence /* = SEEK_SET */) { - assert(valid()); + assertx(valid()); if (whence == SEEK_CUR) { off_t result = lseek(getFd(), 0, SEEK_CUR); @@ -235,12 +235,12 @@ bool PlainFile::seek(int64_t offset, int whence /* = SEEK_SET */) { } int64_t PlainFile::tell() { - assert(valid()); + assertx(valid()); return getPosition(); } bool PlainFile::eof() { - assert(valid()); + assertx(valid()); int64_t avail = bufferedLen(); if (avail > 0) { return false; @@ -249,7 +249,7 @@ bool PlainFile::eof() { } bool PlainFile::rewind() { - assert(valid()); + assertx(valid()); seek(0); setWritePosition(0); setReadPosition(0); @@ -258,7 +258,7 @@ bool PlainFile::rewind() { } bool PlainFile::stat(struct stat *sb) { - assert(valid()); + assertx(valid()); return ::fstat(getFd(), sb) == 0; } @@ -266,13 +266,13 @@ bool PlainFile::flush() { if (m_stream) { return fflush(m_stream) == 0; } - assert(valid()); + assertx(valid()); // No need to flush a file descriptor. return true; } bool PlainFile::truncate(int64_t size) { - assert(valid()); + assertx(valid()); return ftruncate(getFd(), size) == 0; } @@ -333,7 +333,7 @@ const Variant& BuiltinFiles::GetSTDIN() { auto f = req::make(tl_stdin ? tl_stdin : stdin); g_builtin_files->m_stdin = f; f->setId(1); - assert(f->getId() == 1); + assertx(f->getId() == 1); } return g_builtin_files->m_stdin; } @@ -343,7 +343,7 @@ const Variant& BuiltinFiles::GetSTDOUT() { auto f = req::make(tl_stdout ? tl_stdout : stdout); g_builtin_files->m_stdout = f; f->setId(2); - assert(f->getId() == 2); + assertx(f->getId() == 2); } return g_builtin_files->m_stdout; } @@ -353,7 +353,7 @@ const Variant& BuiltinFiles::GetSTDERR() { auto f = req::make(tl_stderr ? tl_stderr : stderr); g_builtin_files->m_stderr = f; f->setId(3); - assert(f->getId() == 3); + assertx(f->getId() == 3); } return g_builtin_files->m_stderr; } diff --git a/hphp/runtime/base/preg.cpp b/hphp/runtime/base/preg.cpp index 15a9e9faa64..b1b29733b44 100644 --- a/hphp/runtime/base/preg.cpp +++ b/hphp/runtime/base/preg.cpp @@ -125,7 +125,7 @@ public: } Accessor& operator=(const pcre_cache_entry* ptr) { - assert(m_kind == Kind::Empty || m_kind == Kind::Ptr); + assertx(m_kind == Kind::Empty || m_kind == Kind::Ptr); m_kind = Kind::Ptr; m_u.ptr = ptr; return *this; @@ -175,7 +175,7 @@ public: } const EntryPtr& entryPtr() const { - assert(m_kind == Kind::SmartPtr); + assertx(m_kind == Kind::SmartPtr); return m_u.smart_ptr; } @@ -422,7 +422,7 @@ bool PCRECache::find(Accessor& accessor, switch (m_kind) { case CacheKind::Static: { - assert(m_staticCache.load()); + assertx(m_staticCache.load()); StaticCache::iterator it; auto cache = m_staticCache.load(std::memory_order_acquire); if ((it = cache->find(regex)) != cache->end()) { @@ -473,7 +473,7 @@ void PCRECache::insert( switch (m_kind) { case CacheKind::Static: { - assert(m_staticCache.load()); + assertx(m_staticCache.load()); // Clear the cache if we haven't refreshed it in a while if (time(nullptr) > m_expire) { clearStatic(); @@ -888,10 +888,10 @@ pcre_get_compiled_regex_cache(PCRECache::Accessor& accessor, std::make_unique(std::move(literal_data)); } - assert((poptions & ~0x1) == 0); + assertx((poptions & ~0x1) == 0); new_entry->preg_options = poptions; - assert((coptions & 0x80000000) == 0); + assertx((coptions & 0x80000000) == 0); new_entry->compile_options = coptions; /* Get pcre full info */ @@ -1665,7 +1665,7 @@ static Variant php_replace_in_subject(const Variant& regex, const Variant& repla callable, limit, replace_count); if (ret.isBoolean()) { - assert(!ret.toBoolean()); + assertx(!ret.toBoolean()); return init_null(); } @@ -1679,7 +1679,7 @@ static Variant php_replace_in_subject(const Variant& regex, const Variant& repla Variant ret = php_pcre_replace(regex_entry, subject, replace, callable, limit, replace_count); if (ret.isBoolean()) { - assert(!ret.toBoolean()); + assertx(!ret.toBoolean()); return init_null(); } if (!ret.isString()) { @@ -1708,7 +1708,7 @@ static Variant php_replace_in_subject(const Variant& regex, const Variant& repla callable, limit, replace_count); if (ret.isBoolean()) { - assert(!ret.toBoolean()); + assertx(!ret.toBoolean()); return init_null(); } if (!ret.isString()) { @@ -1725,7 +1725,7 @@ static Variant php_replace_in_subject(const Variant& regex, const Variant& repla Variant preg_replace_impl(const Variant& pattern, const Variant& replacement, const Variant& subject, int limit, Variant* count, bool is_callable, bool is_filter) { - assert(!(is_callable && is_filter)); + assertx(!(is_callable && is_filter)); if (!is_callable && replacement.isArray() && !pattern.isArray()) { raise_warning("Parameter mismatch, pattern is a string while " diff --git a/hphp/runtime/base/program-functions.cpp b/hphp/runtime/base/program-functions.cpp index 39a66a73cce..c113241f613 100644 --- a/hphp/runtime/base/program-functions.cpp +++ b/hphp/runtime/base/program-functions.cpp @@ -543,7 +543,7 @@ static bool hphp_chdir_file(const std::string& filename) { String s = File::TranslatePath(filename); char *buf = strndup(s.data(), s.size()); char *dir = dirname(buf); - assert(dir); + assertx(dir); if (dir) { if (File::IsVirtualDirectory(dir)) { g_context->setCwd(String(dir, CopyString)); @@ -1962,7 +1962,7 @@ static int execute_program_impl(int argc, char** argv) { ret = 0; while (true) { try { - assert(po.debugger_options.fileName == file); + assertx(po.debugger_options.fileName == file); execute_command_line_begin(new_argc, new_argv, po.xhprofFlags); // Set the proxy for this thread to be the localProxy we just // created. If we're script debugging, this will be the proxy that @@ -2113,7 +2113,7 @@ static void on_timeout(int sig, siginfo_t* info, void* /*context*/) { * Update constants to their real values and sync some runtime options */ static void update_constants_and_options() { - assert(ExtensionRegistry::modulesInitialised()); + assertx(ExtensionRegistry::modulesInitialised()); // If extension constants were used in the ini files (e.g., E_ALL) they // would have come out as 0 in the previous pass until we load and // initialize our extensions, which we do in RuntimeOption::Load() via @@ -2155,7 +2155,7 @@ void hphp_thread_init() { get_server_note(); tl_heap.getCheck()->init(); - assert(ThreadInfo::s_threadInfo.isNull()); + assertx(ThreadInfo::s_threadInfo.isNull()); ThreadInfo::s_threadInfo.getCheck()->init(); HardwareCounter::s_counter.getCheck(); @@ -2304,7 +2304,7 @@ void hphp_process_init() { static void handle_exception(bool& ret, ExecutionContext* context, std::string& errorMsg, ContextOfException where, bool& error, bool richErrorMsg) { - assert(where == ContextOfException::Invoke || + assertx(where == ContextOfException::Invoke || where == ContextOfException::ReqInit); try { handle_exception_helper(ret, context, errorMsg, where, error, richErrorMsg); @@ -2355,7 +2355,7 @@ static bool hphp_warmup(ExecutionContext *context, } void hphp_session_init() { - assert(!s_sessionInitialized); + assertx(!s_sessionInitialized); g_context.getCheck(); AsioSession::Init(); Socket::clearLastError(); @@ -2563,7 +2563,7 @@ void hphp_memory_cleanup() { } void hphp_session_exit(const Transport* transport) { - assert(s_sessionInitialized); + assertx(s_sessionInitialized); // Server note and INI have to live long enough for the access log to fire. // RequestLocal is too early. ServerNote::Reset(); @@ -2590,7 +2590,7 @@ void hphp_session_exit(const Transport* transport) { hphp_memory_cleanup(); } - assert(tl_heap->empty()); + assertx(tl_heap->empty()); s_sessionInitialized = false; s_extra_request_nanoseconds = 0; diff --git a/hphp/runtime/base/property-table.cpp b/hphp/runtime/base/property-table.cpp index 1ed251e6864..caf7bd3e6af 100644 --- a/hphp/runtime/base/property-table.cpp +++ b/hphp/runtime/base/property-table.cpp @@ -32,12 +32,12 @@ PropertyTable::PropertyTable(const PropertyTable& other) , m_base(nullptr) { if (!other.m_base) { - assert(!m_capacity); - assert(!other.m_capacity); + assertx(!m_capacity); + assertx(!other.m_capacity); return; } - assert(m_capacity == other.m_capacity); + assertx(m_capacity == other.m_capacity); m_base = malloc(bytesForCapacity(m_capacity)); memcpy(m_base, other.m_base, bytesForCapacity(m_capacity)); } @@ -48,11 +48,11 @@ PropertyTable::~PropertyTable() { uint32_t PropertyTable::add(const StringData* property) { if (shouldGrow()) grow(); - assert(offsetFor(property) == kInvalidOffset); - assert((m_size + 1) < m_capacity); + assertx(offsetFor(property) == kInvalidOffset); + assertx((m_size + 1) < m_capacity); auto offset = m_nextOffset++; - assert(offset != kInvalidOffset); + assertx(offset != kInvalidOffset); auto bucketIndex = bucketFor(property); offsets()[offset] = bucketIndex; entries()[bucketIndex] = Entry{ property, offset, property->hash() }; @@ -61,10 +61,10 @@ uint32_t PropertyTable::add(const StringData* property) { } void PropertyTable::grow() { - assert(shouldGrow()); + assertx(shouldGrow()); if (!m_capacity) { m_capacity = 2; - assert(!m_base); + assertx(!m_base); m_base = malloc(bytesForCapacity(m_capacity)); memset(m_base, 0, bytesForCapacity(m_capacity)); return; diff --git a/hphp/runtime/base/property-table.h b/hphp/runtime/base/property-table.h index 3ea8f655790..fad68a73cf3 100644 --- a/hphp/runtime/base/property-table.h +++ b/hphp/runtime/base/property-table.h @@ -170,8 +170,8 @@ inline uint32_t PropertyTable::bucketFor( const Entry* entries, size_t capacity ) const { - assert(propType == NotStatic || property->isStatic()); - assert(m_size < m_capacity); + assertx(propType == NotStatic || property->isStatic()); + assertx(m_size < m_capacity); auto hash = property->hash(); auto start = hash & (capacity - 1); auto current = start; diff --git a/hphp/runtime/base/purger.cpp b/hphp/runtime/base/purger.cpp index 37f27399225..7a5980887c0 100644 --- a/hphp/runtime/base/purger.cpp +++ b/hphp/runtime/base/purger.cpp @@ -68,8 +68,8 @@ Purger::Purger() {} void Purger::purge(char* base, char* front) { - assert(uintptr_t(base) % kPageSize == 0); - assert(uintptr_t(front) % kPageSize == 0); + assertx(uintptr_t(base) % kPageSize == 0); + assertx(uintptr_t(front) % kPageSize == 0); size_t size = front - base; dirty_ = std::max(size, dirty_); // If dirty_ exceeds threshold_, purge all the exceeded memory. @@ -114,7 +114,7 @@ void Purger::purge(char* base, char* front) { } void Purger::flush(char* base) { - assert(uintptr_t(base) % kPageSize == 0); + assertx(uintptr_t(base) % kPageSize == 0); if (debug) { auto age = Timer::GetCurrentTimeMicros() - kTime0; VLOG(1) << "flush " << id_ << ": t " << age/bucket_slice_ diff --git a/hphp/runtime/base/rds.cpp b/hphp/runtime/base/rds.cpp index 31a648b50f8..3edba97f015 100644 --- a/hphp/runtime/base/rds.cpp +++ b/hphp/runtime/base/rds.cpp @@ -115,19 +115,19 @@ struct SymbolEq : boost::static_visitor { >::type operator()(const T&, const U&) const { return false; } bool operator()(StaticLocal k1, StaticLocal k2) const { - assert(k1.name->isStatic() && k2.name->isStatic()); + assertx(k1.name->isStatic() && k2.name->isStatic()); return k1.funcId == k2.funcId && k1.name == k2.name; } bool operator()(ClsConstant k1, ClsConstant k2) const { - assert(k1.clsName->isStatic() && k1.cnsName->isStatic()); - assert(k2.clsName->isStatic() && k2.cnsName->isStatic()); + assertx(k1.clsName->isStatic() && k1.cnsName->isStatic()); + assertx(k2.clsName->isStatic() && k2.cnsName->isStatic()); return k1.clsName->isame(k2.clsName) && k1.cnsName == k2.cnsName; } bool operator()(Profile k1, Profile k2) const { - assert(k1.name->isStatic() && k2.name->isStatic()); + assertx(k1.name->isStatic() && k2.name->isStatic()); return k1.transId == k2.transId && k1.bcOff == k2.bcOff && k1.name == k2.name; @@ -139,7 +139,7 @@ struct SymbolEq : boost::static_visitor { std::is_same::value, bool >::type operator()(const T& t1, const T& t2) const { - assert(t1.name->isStatic() && t2.name->isStatic()); + assertx(t1.name->isStatic() && t2.name->isStatic()); return t1.name->isame(t2.name); } @@ -238,7 +238,7 @@ AllocDescriptorList s_local_alloc_descs; * Round base up to align, which must be a power of two. */ size_t roundUp(size_t base, size_t align) { - assert(folly::isPowTwo(align)); + assertx(folly::isPowTwo(align)); --align; return (base + align) & ~align; } @@ -496,9 +496,9 @@ typedef tbb::concurrent_hash_mapcurrentGen; memset(tl_base, 0, sizeof(Header)); @@ -688,7 +688,7 @@ static void initPersistentCache() { } void threadInit(bool shouldRegister) { - assert(tl_base == nullptr); + assertx(tl_base == nullptr); if (!s_tc_fd) { initPersistentCache(); @@ -724,7 +724,7 @@ void threadInit(bool shouldRegister) { if (shouldRegister) { Guard g(s_tlBaseListLock); - assert(std::find(begin(s_tlBaseList), end(s_tlBaseList), tl_base) == + assertx(std::find(begin(s_tlBaseList), end(s_tlBaseList), tl_base) == end(s_tlBaseList)); s_tlBaseList.push_back(tl_base); } diff --git a/hphp/runtime/base/ref-data.h b/hphp/runtime/base/ref-data.h index 1e23412bf5d..49f846a26eb 100644 --- a/hphp/runtime/base/ref-data.h +++ b/hphp/runtime/base/ref-data.h @@ -65,14 +65,14 @@ struct RefData final : Countable, type_scan::MarkScannableCollectable { * Deallocate a RefData. */ void release() noexcept { - assert(kindIsValid()); + assertx(kindIsValid()); this->~RefData(); tl_heap->objFree(this, sizeof(RefData)); AARCH64_WALKABLE_FRAME(); } ALWAYS_INLINE void decRefAndRelease() { - assert(kindIsValid()); + assertx(kindIsValid()); if (decReleaseCheck()) release(); } bool kindIsValid() const { return m_kind == HeaderKind::Ref; } @@ -81,11 +81,11 @@ struct RefData final : Countable, type_scan::MarkScannableCollectable { * Note, despite the name, this can never return a non-Cell. */ const Cell* tv() const { - assert(kindIsValid()); + assertx(kindIsValid()); return &m_tv; } Cell* tv() { - assert(kindIsValid()); + assertx(kindIsValid()); return &m_tv; } @@ -98,10 +98,10 @@ struct RefData final : Countable, type_scan::MarkScannableCollectable { static constexpr int tvOffset() { return offsetof(RefData, m_tv); } - void assertValid() const { assert(kindIsValid()); } + void assertValid() const { assertx(kindIsValid()); } bool isReferenced() const { - assert(kindIsValid()); + assertx(kindIsValid()); return m_count >= 2; } diff --git a/hphp/runtime/base/repo-auth-type-array-inl.h b/hphp/runtime/base/repo-auth-type-array-inl.h index 04b71e4fbac..df64681ab9f 100644 --- a/hphp/runtime/base/repo-auth-type-array-inl.h +++ b/hphp/runtime/base/repo-auth-type-array-inl.h @@ -35,9 +35,9 @@ ArrayTypeTable::serde(SerDe& sd) { decltype(m_arrTypes)(size).swap(m_arrTypes); for (auto i = uint32_t{0}; i < size; ++i) { m_arrTypes[i] = RepoAuthType::Array::deserialize(sd, *this); - assert(m_arrTypes[i] != nullptr); - assert(m_arrTypes[i]->id() == i); - assert(check(m_arrTypes[i])); + assertx(m_arrTypes[i] != nullptr); + assertx(m_arrTypes[i]->id() == i); + assertx(check(m_arrTypes[i])); FTRACE(2, " {} {}\n", i, show(*m_arrTypes[i])); } } diff --git a/hphp/runtime/base/repo-auth-type-array.cpp b/hphp/runtime/base/repo-auth-type-array.cpp index 556bf6b6f3b..cfa21f14532 100644 --- a/hphp/runtime/base/repo-auth-type-array.cpp +++ b/hphp/runtime/base/repo-auth-type-array.cpp @@ -95,7 +95,7 @@ struct repo_auth_array_eq { static ArrayTypeTable s_instance; ArrayTypeTable& globalArrayTypeTable() { - assert(RuntimeOption::RepoAuthoritative); + assertx(RuntimeOption::RepoAuthoritative); return s_instance; } @@ -108,14 +108,14 @@ bool ArrayTypeTable::check(const RepoAuthType::Array* arr) const { case RepoAuthType::Array::Tag::Packed: { for (uint32_t idx = 0; idx < arr->size(); ++idx) { auto rat = arr->packedElem(idx); - assert(rat.resolved()); + assertx(rat.resolved()); if (rat.mayHaveArrData()) check(rat.array()); } break; } case RepoAuthType::Array::Tag::PackedN: { auto rat = arr->elemType(); - assert(rat.resolved()); + assertx(rat.resolved()); if (rat.mayHaveArrData()) check(rat.array()); break; } @@ -156,7 +156,7 @@ Builder::~Builder() {} const RepoAuthType::Array* Builder::packed(RepoAuthType::Array::Empty emptiness, const std::vector& types) { - assert(!types.empty()); + assertx(!types.empty()); auto const size = types.size() * sizeof(RepoAuthType) + sizeof(RepoAuthType::Array); @@ -205,13 +205,13 @@ Builder::packedn(RepoAuthType::Array::Empty emptiness, RepoAuthType elemTy) { // Returns the `cand' if it was successfully inserted; otherwise it's // the callers responsibility to free it. const RepoAuthType::Array* Builder::insert(RepoAuthType::Array* cand) { - assert(cand->id() == -1u); + assertx(cand->id() == -1u); std::lock_guard g(m_impl->mutex); auto ins = m_impl->types.insert(cand); if (ins.second) { cand->m_id = m_impl->nextId++; - assert(*ins.first == cand); - assert((*ins.first)->id() == cand->id()); + assertx(*ins.first == cand); + assertx((*ins.first)->id() == cand->id()); return cand; } return *ins.first; @@ -222,7 +222,7 @@ void ArrayTypeTable::repopulate(const Builder& builder) { m_arrTypes.resize(builder.m_impl->nextId); for (auto& ty : builder.m_impl->types) { - assert(m_arrTypes[ty->id()] == nullptr); + assertx(m_arrTypes[ty->id()] == nullptr); m_arrTypes[ty->id()] = ty; } if (debug) { diff --git a/hphp/runtime/base/repo-auth-type-array.h b/hphp/runtime/base/repo-auth-type-array.h index d696f91aca3..a783444dbc8 100644 --- a/hphp/runtime/base/repo-auth-type-array.h +++ b/hphp/runtime/base/repo-auth-type-array.h @@ -57,7 +57,7 @@ struct ArrayTypeTable { * Find an array type description by id. */ const RepoAuthType::Array* lookup(uint32_t id) const { - assert(id < m_arrTypes.size()); + assertx(id < m_arrTypes.size()); return m_arrTypes[id]; } @@ -154,7 +154,7 @@ struct RepoAuthType::Array { * Pre: tag() == Tag::Packed */ uint32_t size() const { - assert(tag() == Tag::Packed); + assertx(tag() == Tag::Packed); return m_size; } @@ -165,8 +165,8 @@ struct RepoAuthType::Array { * idx < size() */ RepoAuthType packedElem(uint32_t idx) const { - assert(tag() == Tag::Packed); - assert(idx < size()); + assertx(tag() == Tag::Packed); + assertx(idx < size()); return types()[idx]; } @@ -176,7 +176,7 @@ struct RepoAuthType::Array { * Pre: tag() == Tag::PackedN */ RepoAuthType elemType() const { - assert(tag() == Tag::PackedN); + assertx(tag() == Tag::PackedN); return types()[0]; } diff --git a/hphp/runtime/base/repo-auth-type-codec-inl.h b/hphp/runtime/base/repo-auth-type-codec-inl.h index 80d9e234759..3bc89d17e77 100644 --- a/hphp/runtime/base/repo-auth-type-codec-inl.h +++ b/hphp/runtime/base/repo-auth-type-codec-inl.h @@ -63,7 +63,7 @@ size_t encodedRATSize(const unsigned char* pc) { case T::Ref: case T::InitGen: case T::Gen: - assert(!highBitSet); + assertx(!highBitSet); return 1; case T::SArr: case T::OptSArr: @@ -94,7 +94,7 @@ size_t encodedRATSize(const unsigned char* pc) { case T::SubObj: case T::OptExactObj: case T::OptSubObj: - assert(!highBitSet); + assertx(!highBitSet); return 5; } not_reached(); diff --git a/hphp/runtime/base/repo-auth-type-codec.cpp b/hphp/runtime/base/repo-auth-type-codec.cpp index 43c3e57915a..eff8866baee 100644 --- a/hphp/runtime/base/repo-auth-type-codec.cpp +++ b/hphp/runtime/base/repo-auth-type-codec.cpp @@ -61,7 +61,7 @@ RepoAuthType decodeRATImpl(const unsigned char*& pc, LookupStr lookupStr, case T::Ref: case T::InitGen: case T::Gen: - assert(!highBitSet); + assertx(!highBitSet); return RepoAuthType{tag}; case T::SArr: @@ -101,7 +101,7 @@ RepoAuthType decodeRATImpl(const unsigned char*& pc, LookupStr lookupStr, case T::SubObj: case T::OptExactObj: case T::OptSubObj: - assert(!highBitSet); + assertx(!highBitSet); { uint32_t id; std::memcpy(&id, pc, sizeof id); diff --git a/hphp/runtime/base/repo-auth-type.cpp b/hphp/runtime/base/repo-auth-type.cpp index 8a4328052f1..bf9570505d9 100644 --- a/hphp/runtime/base/repo-auth-type.cpp +++ b/hphp/runtime/base/repo-auth-type.cpp @@ -40,7 +40,7 @@ static_assert(sizeof(RepoAuthType) == sizeof(CompactTaggedPtr), ""); namespace { bool tvMatchesArrayType(TypedValue tv, const RepoAuthType::Array* arrTy) { - assert(isArrayLikeType(tv.m_type)); + assertx(isArrayLikeType(tv.m_type)); auto const ad = tv.m_data.parr; using A = RepoAuthType::Array; @@ -91,7 +91,7 @@ void RepoAuthType::resolveArray(const UnitEmitter& ue) { } const uint32_t RepoAuthType::arrayId() const { - assert(mayHaveArrData()); + assertx(mayHaveArrData()); if (resolved()) return m_data.ptr() ? array()->id() : kInvalidArrayId; return reinterpret_cast(m_data.ptr()); @@ -184,7 +184,7 @@ size_t RepoAuthType::hash() const { ////////////////////////////////////////////////////////////////////// bool tvMatchesRepoAuthType(TypedValue tv, RepoAuthType ty) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); bool const initNull = tv.m_type == KindOfNull; diff --git a/hphp/runtime/base/repo-auth-type.h b/hphp/runtime/base/repo-auth-type.h index 86aad752cd9..96905087195 100644 --- a/hphp/runtime/base/repo-auth-type.h +++ b/hphp/runtime/base/repo-auth-type.h @@ -124,7 +124,7 @@ struct RepoAuthType { switch (tag) { case Tag::OptSubObj: case Tag::OptExactObj: case Tag::SubObj: case Tag::ExactObj: - assert(sd != nullptr); + assertx(sd != nullptr); break; default: break; @@ -133,7 +133,7 @@ struct RepoAuthType { explicit RepoAuthType(Tag tag, const Array* ar) { m_data.set(static_cast(tag), ar); - assert(mayHaveArrData()); + assertx(mayHaveArrData()); } Tag tag() const { return toResolvedTag(m_data.tag()); } @@ -147,7 +147,7 @@ struct RepoAuthType { */ const StringData* clsName() const { - assert(hasClassName()); + assertx(hasClassName()); return static_cast(m_data.ptr()); } @@ -167,7 +167,7 @@ struct RepoAuthType { */ const Array* array() const { - assert(resolved()); + assertx(resolved()); return static_cast(m_data.ptr()); } @@ -218,7 +218,7 @@ struct RepoAuthType { // the 0x40 bit for resolved/unresolved Array* should not be visible // to the outside world. - assert(resolved()); + assertx(resolved()); if (mayHaveArrData()) { // serialization @@ -263,7 +263,7 @@ private: if (!mayHaveArrData() || resolved()) return; auto const id = arrayId(); - assert(id != kInvalidArrayId); // this case is handled in deser time. + assertx(id != kInvalidArrayId); // this case is handled in deser time. auto const array = fn(id); m_data.set(static_cast(tag()), array); } diff --git a/hphp/runtime/base/req-ptr.h b/hphp/runtime/base/req-ptr.h index 4fe324be64b..e1b427d63e1 100644 --- a/hphp/runtime/base/req-ptr.h +++ b/hphp/runtime/base/req-ptr.h @@ -49,7 +49,7 @@ template struct ptr final { enum class NonNull {}; explicit ptr(T* px, NonNull) : m_px(px) { - assert(px); + assertx(px); m_px->incRefCount(); } @@ -93,7 +93,7 @@ template struct ptr final { // Move assignment for derived types template ptr& operator=(ptr&& src) { - assert((void*)this != (void*)&src); + assertx((void*)this != (void*)&src); // Update m_px before releasing the goner auto goner = m_px; m_px = src.m_px; @@ -277,7 +277,7 @@ inline bool is_null(const T& p) { template inline bool isa_non_null(const P& p) { - assert(!is_null(p)); + assertx(!is_null(p)); return p->template instanceof(); } diff --git a/hphp/runtime/base/req-root.cpp b/hphp/runtime/base/req-root.cpp index fbfec7c7c63..104159b3ffe 100644 --- a/hphp/runtime/base/req-root.cpp +++ b/hphp/runtime/base/req-root.cpp @@ -34,7 +34,7 @@ uint32_t req::root_handle::addRootHandle() { } uint32_t req::root_handle::stealRootHandle(root_handle* s) { - assert(s->m_id != INVALID); + assertx(s->m_id != INVALID); auto& handles = tl_heap->m_root_handles; auto id = s->m_id; handles[id] = this; diff --git a/hphp/runtime/base/request-injection-data.cpp b/hphp/runtime/base/request-injection-data.cpp index 415f3de3a14..fbb454872a0 100644 --- a/hphp/runtime/base/request-injection-data.cpp +++ b/hphp/runtime/base/request-injection-data.cpp @@ -655,12 +655,12 @@ void RequestInjectionData::updateJit() { } void RequestInjectionData::clearFlag(SurpriseFlag flag) { - assert(flag >= 1ull << 48); + assertx(flag >= 1ull << 48); m_sflagsAndStkPtr->fetch_and(~flag); } void RequestInjectionData::setFlag(SurpriseFlag flag) { - assert(flag >= 1ull << 48); + assertx(flag >= 1ull << 48); m_sflagsAndStkPtr->fetch_or(flag); } diff --git a/hphp/runtime/base/request-local.h b/hphp/runtime/base/request-local.h index f0af192fe8a..bc317ba9c78 100644 --- a/hphp/runtime/base/request-local.h +++ b/hphp/runtime/base/request-local.h @@ -107,7 +107,7 @@ void RequestLocal::create() { m_node.m_on_thread_exit_fn = RequestLocal::OnThreadExit; ThreadLocalManager::PushTop(m_node); } - assert(m_node.m_p == nullptr); + assertx(m_node.m_p == nullptr); m_node.m_p = new T(); } diff --git a/hphp/runtime/base/resource-data.cpp b/hphp/runtime/base/resource-data.cpp index 3a7d19330df..e12a88ca007 100644 --- a/hphp/runtime/base/resource-data.cpp +++ b/hphp/runtime/base/resource-data.cpp @@ -33,7 +33,7 @@ void ResourceHdr::resetMaxId() { } void ResourceHdr::setId(int id) { - assert(id >= 1 && id <= 3); // only for STDIN, STDOUT, STDERR + assertx(id >= 1 && id <= 3); // only for STDIN, STDOUT, STDERR if (m_id != id) { if (m_id == s_max_resource_id) --s_max_resource_id; m_id = id; diff --git a/hphp/runtime/base/resource-data.h b/hphp/runtime/base/resource-data.h index c21066eb675..663963c6748 100644 --- a/hphp/runtime/base/resource-data.h +++ b/hphp/runtime/base/resource-data.h @@ -68,30 +68,30 @@ struct ResourceHdr final : Countable, // aux stores heap size static void resetMaxId(); ALWAYS_INLINE void decRefAndRelease() { - assert(kindIsValid()); + assertx(kindIsValid()); if (decReleaseCheck()) release(); } bool kindIsValid() const { return m_kind == HeaderKind::Resource; } void release() noexcept; void init(uint16_t size, type_scan::Index tyindex) { - assert(type_scan::isKnownType(tyindex)); + assertx(type_scan::isKnownType(tyindex)); initHeader_16(HeaderKind::Resource, OneReference, size); m_type_index = tyindex; } ResourceData* data() { - assert(kindIsValid()); + assertx(kindIsValid()); return reinterpret_cast(this + 1); } const ResourceData* data() const { - assert(kindIsValid()); + assertx(kindIsValid()); return reinterpret_cast(this + 1); } size_t heapSize() const { - assert(kindIsValid()); - assert(m_aux16 != 0); + assertx(kindIsValid()); + assertx(m_aux16 != 0); return m_aux16; } @@ -120,12 +120,12 @@ struct ResourceData : type_scan::MarkCollectable { const ResourceHdr* hdr() const { auto h = reinterpret_cast(this) - 1; - assert(h->kindIsValid()); + assertx(h->kindIsValid()); return h; } ResourceHdr* hdr() { auto h = reinterpret_cast(this) - 1; - assert(h->kindIsValid()); + assertx(h->kindIsValid()); return h; } @@ -162,7 +162,7 @@ struct ResourceData : type_scan::MarkCollectable { }; inline void ResourceHdr::release() noexcept { - assert(kindIsValid()); + assertx(kindIsValid()); delete data(); AARCH64_WALKABLE_FRAME(); } @@ -271,7 +271,7 @@ ALWAYS_INLINE void decRefRes(ResourceHdr* res) { static_assert(std::is_base_of::value, ""); \ constexpr auto size = sizeof(ResourceHdr) + sizeof(T); \ auto h = static_cast(p)->hdr(); \ - assert(h->heapSize() == size); \ + assertx(h->heapSize() == size); \ tl_heap->objFree(h, size); \ } @@ -302,7 +302,7 @@ typename std::enable_if< b->init(size, type_scan::getIndexForMalloc()); try { auto r = new (b->data()) T(std::forward(args)...); - assert(r->hasExactlyOneRef()); + assertx(r->hasExactlyOneRef()); return req::ptr::attach(r); } catch (...) { tl_heap->objFree(b, size); diff --git a/hphp/runtime/base/root-map.h b/hphp/runtime/base/root-map.h index 18883d9bc6f..cc5bde5143c 100644 --- a/hphp/runtime/base/root-map.h +++ b/hphp/runtime/base/root-map.h @@ -34,14 +34,14 @@ template struct RootMap { using Map = req::hash_map>; RootId addRoot(req::ptr&& ptr) { - assert(ptr); + assertx(ptr); const RootId tok = ptr->getId(); getMap().emplace(tok, std::move(ptr)); return tok; } RootId addRoot(const req::ptr& ptr) { - assert(ptr); + assertx(ptr); auto tok = ptr->getId(); getMap()[tok] = ptr; return tok; diff --git a/hphp/runtime/base/runtime-error.cpp b/hphp/runtime/base/runtime-error.cpp index d0bbe43ad7c..8e56645b063 100644 --- a/hphp/runtime/base/runtime-error.cpp +++ b/hphp/runtime/base/runtime-error.cpp @@ -461,7 +461,7 @@ void raise_param_type_warning( } else if (strncmp(func_name, "tg1_", 4) == 0) { func_name += 4; } - assert(param_num > 0); + assertx(param_num > 0); auto msg = folly::sformat( "{}() expects parameter {} to be {}, {} given", func_name, diff --git a/hphp/runtime/base/set-array.cpp b/hphp/runtime/base/set-array.cpp index 5ff183d9d76..6e6d64a607e 100644 --- a/hphp/runtime/base/set-array.cpp +++ b/hphp/runtime/base/set-array.cpp @@ -50,7 +50,7 @@ struct SetArray::Initializer { ad->m_sizeAndPos = 0; ad->m_scale_used = SetArray::SmallScale; ad->initHeader(HeaderKind::Keyset, StaticValue); - assert(ad->checkInvariants()); + assertx(ad->checkInvariants()); } }; SetArray::Initializer SetArray::s_initializer; @@ -58,16 +58,16 @@ SetArray::Initializer SetArray::s_initializer; ////////////////////////////////////////////////////////////////////// SetArray* SetArray::asSet(ArrayData* ad) { - assert(ad->isKeyset()); + assertx(ad->isKeyset()); auto a = static_cast(ad); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return a; } const SetArray* SetArray::asSet(const ArrayData* ad) { - assert(ad->isKeyset()); + assertx(ad->isKeyset()); auto a = static_cast(ad); - assert(a->checkInvariants()); + assertx(a->checkInvariants()); return a; } @@ -84,21 +84,21 @@ ArrayData* SetArray::MakeReserveSet(uint32_t size) { auto const scale = computeScaleFromSize(size); auto const ad = reqAlloc(scale); - assert(ClearElms(Data(ad), Capacity(scale))); + assertx(ClearElms(Data(ad), Capacity(scale))); ad->initHash(scale); ad->initHeader(HeaderKind::Keyset, OneReference); ad->m_sizeAndPos = 0; // size = 0, pos = 0 ad->m_scale_used = scale; // scale = scale, used = 0 - assert(ad->kind() == kKeysetKind); - assert(!ad->isZombie()); - assert(ad->m_size == 0); - assert(ad->m_pos == 0); - assert(ad->hasExactlyOneRef()); - assert(ad->m_scale == scale); - assert(ad->m_used == 0); - assert(ad->checkInvariants()); + assertx(ad->kind() == kKeysetKind); + assertx(!ad->isZombie()); + assertx(ad->m_size == 0); + assertx(ad->m_pos == 0); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_scale == scale); + assertx(ad->m_used == 0); + assertx(ad->checkInvariants()); return ad; } @@ -132,7 +132,7 @@ ArrayData* SetArray::MakeUncounted(ArrayData* array, void** seenVal = nullptr; if (seen && array->hasMultipleRefs()) { auto it = seen->find(array); - assert(it != seen->end()); + assertx(it != seen->end()); seenVal = &it->second; if (auto const arr = static_cast(*seenVal)) { if (arr->uncountedIncRef()) { @@ -149,10 +149,10 @@ ArrayData* SetArray::MakeUncounted(ArrayData* array, static_cast(malloc_huge(extra + computeAllocBytes(scale))); auto const dest = reinterpret_cast(mem + extra); - assert(reinterpret_cast(dest) % 16 == 0); - assert(reinterpret_cast(src) % 16 == 0); + assertx(reinterpret_cast(dest) % 16 == 0); + assertx(reinterpret_cast(src) % 16 == 0); memcpy16_inline(dest, src, sizeof(SetArray) + sizeof(Elm) * used); - assert(ClearElms(Data(dest) + used, Capacity(scale) - used)); + assertx(ClearElms(Data(dest) + used, Capacity(scale) - used)); CopyHash(HashTab(dest, scale), src->hashTab(), scale); dest->initHeader_16(HeaderKind::Keyset, UncountedValue, withApcTypedValue ? ArrayData::kHasApcTv : 0); @@ -162,7 +162,7 @@ ArrayData* SetArray::MakeUncounted(ArrayData* array, for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); if (elm.hasStrKey()) { elm.tv.m_type = KindOfPersistentString; StringData*& skey = elm.tv.m_data.pstr; @@ -201,10 +201,10 @@ SetArray* SetArray::CopySet(const SetArray& other, AllocMode mode) { ? reqAlloc(scale) : staticAlloc(scale); - assert(reinterpret_cast(ad) % 16 == 0); - assert(reinterpret_cast(&other) % 16 == 0); + assertx(reinterpret_cast(ad) % 16 == 0); + assertx(reinterpret_cast(&other) % 16 == 0); memcpy16_inline(ad, &other, sizeof(SetArray) + sizeof(Elm) * used); - assert(ClearElms(Data(ad) + used, Capacity(scale) - used)); + assertx(ClearElms(Data(ad) + used, Capacity(scale) - used)); CopyHash(HashTab(ad, scale), other.hashTab(), scale); auto const count = mode == AllocMode::Request ? OneReference : StaticValue; ad->initHeader(HeaderKind::Keyset, count); @@ -214,23 +214,23 @@ SetArray* SetArray::CopySet(const SetArray& other, AllocMode mode) { for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); tvIncRefGen(elm.tv); } - assert(ad->m_kind == HeaderKind::Keyset); - assert(ad->m_size == other.m_size); - assert(ad->m_pos == other.m_pos); - assert(mode == AllocMode::Request ? + assertx(ad->m_kind == HeaderKind::Keyset); + assertx(ad->m_size == other.m_size); + assertx(ad->m_pos == other.m_pos); + assertx(mode == AllocMode::Request ? ad->hasExactlyOneRef() : ad->isStatic()); - assert(ad->m_scale == scale); - assert(ad->m_used == used); - assert(ad->checkInvariants()); + assertx(ad->m_scale == scale); + assertx(ad->m_used == used); + assertx(ad->checkInvariants()); return ad; } SetArray* SetArray::CopyReserve(const SetArray* src, size_t expectedSize) { - assert(expectedSize >= src->size()); + assertx(expectedSize >= src->size()); auto const ad = asSet(MakeReserveSet(expectedSize)); auto const used = src->m_used; auto const elms = src->data(); @@ -239,7 +239,7 @@ SetArray* SetArray::CopyReserve(const SetArray* src, size_t expectedSize) { for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); auto const loc = ad->findForNewInsert(table, mask, elm.hash()); auto newElm = ad->allocElm(loc); if (elm.hasIntKey()) { @@ -253,16 +253,16 @@ SetArray* SetArray::CopyReserve(const SetArray* src, size_t expectedSize) { } else { ad->m_pos = ad->findElm(elms[src->m_pos]); } - assert(ad->kind() == ArrayKind::kKeysetKind); - assert(ad->m_size == src->m_size); - assert(ad->hasExactlyOneRef()); - assert(ad->m_used == src->m_size); - assert(ad->checkInvariants()); + assertx(ad->kind() == ArrayKind::kKeysetKind); + assertx(ad->m_size == src->m_size); + assertx(ad->hasExactlyOneRef()); + assertx(ad->m_used == src->m_size); + assertx(ad->checkInvariants()); return ad; } ArrayData* SetArray::MakeSetFromAPC(const APCArray* apc) { - assert(apc->isKeyset()); + assertx(apc->isKeyset()); auto const apcSize = apc->size(); KeysetInit init{apcSize}; for (uint32_t i = 0; i < apcSize; ++i) init.add(apc->getValue(i)->toLocal()); @@ -284,8 +284,8 @@ ArrayData* SetArray::AddToSet(ArrayData* ad, StringData* s, bool copy) { ////////////////////////////////////////////////////////////////////// void SetArray::Release(ArrayData* in) { - assert(in->isRefCounted()); - assert(in->hasExactlyOneRef()); + assertx(in->isRefCounted()); + assertx(in->hasExactlyOneRef()); auto const ad = asSet(in); if (!ad->isZombie()) { @@ -294,19 +294,19 @@ void SetArray::Release(ArrayData* in) { for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); tvDecRefGen(&elm.tv); } // We better not have strong iterators associated with keysets. - assert(!has_strong_iterator(ad)); + assertx(!has_strong_iterator(ad)); } tl_heap->objFree(ad, ad->heapSize()); AARCH64_WALKABLE_FRAME(); } void SetArray::ReleaseUncounted(ArrayData* in) { - assert(in->isUncounted()); + assertx(in->isUncounted()); auto const ad = asSet(in); if (!ad->isZombie()) { @@ -315,10 +315,10 @@ void SetArray::ReleaseUncounted(ArrayData* in) { for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); if (elm.hasStrKey()) { auto const skey = elm.strKey(); - assert(!skey->isRefCounted()); + assertx(!skey->isRefCounted()); if (skey->isUncounted()) { StringData::ReleaseUncounted(skey); } @@ -326,7 +326,7 @@ void SetArray::ReleaseUncounted(ArrayData* in) { } // We better not have strong iterators associated with keysets. - assert(!has_strong_iterator(ad)); + assertx(!has_strong_iterator(ad)); } if (APCStats::IsCreated()) { APCStats::getAPCStats().removeAPCUncountedBlock(); @@ -338,14 +338,14 @@ void SetArray::ReleaseUncounted(ArrayData* in) { ////////////////////////////////////////////////////////////////////// ssize_t SetArray::findElm(const Elm& e) const { - assert(!e.isInvalid()); + assertx(!e.isInvalid()); return e.hasIntKey() ? find(e.intKey(), e.hash()) : find(e.strKey(), e.hash()); } void SetArray::insert(int64_t k, inthash_t h) { - assert(!isFull()); + assertx(!isFull()); auto const loc = findForInsert(k, h); if (isValidIns(loc)) { auto elm = allocElm(loc); @@ -355,7 +355,7 @@ void SetArray::insert(int64_t k, inthash_t h) { void SetArray::insert(int64_t k) { return insert(k, hash_int64(k)); } void SetArray::insert(StringData* k, strhash_t h) { - assert(!isFull()); + assertx(!isFull()); auto const loc = findForInsert(k, h); if (isValidIns(loc)) { auto elm = allocElm(loc); @@ -365,8 +365,8 @@ void SetArray::insert(StringData* k, strhash_t h) { void SetArray::insert(StringData* k) { return insert(k, k->hash()); } void SetArray::erase(int32_t pos) { - assert(pos < m_used); - assert(0 <= pos); + assertx(pos < m_used); + assertx(0 <= pos); auto const elms = data(); if (m_pos == pos) { @@ -374,7 +374,7 @@ void SetArray::erase(int32_t pos) { } auto& elm = elms[pos]; - assert(!elm.isInvalid()); + assertx(!elm.isInvalid()); tvDecRefGen(&elm.tv); elm.setTombstone(); --m_size; @@ -390,7 +390,7 @@ void SetArray::erase(int32_t pos) { ////////////////////////////////////////////////////////////////////// Cell SetArray::getElm(ssize_t ei) const { - assert(0 <= ei && ei < m_used); + assertx(0 <= ei && ei < m_used); return data()[ei].getKey(); } @@ -398,21 +398,21 @@ Cell SetArray::getElm(ssize_t ei) const { NEVER_INLINE SetArray* SetArray::grow(bool copy) { - assert(m_size > 0); + assertx(m_size > 0); auto const oldUsed = m_used; auto const newScale = m_scale * 2; - assert(Capacity(newScale) >= m_size); - assert(newScale >= SmallScale && (newScale & (newScale - 1)) == 0); + assertx(Capacity(newScale) >= m_size); + assertx(newScale >= SmallScale && (newScale & (newScale - 1)) == 0); auto ad = reqAlloc(newScale); ad->m_sizeAndPos = m_sizeAndPos; ad->m_scale_used = newScale | (uint64_t{oldUsed} << 32); ad->initHeader(HeaderKind::Keyset, OneReference); - assert(reinterpret_cast(Data(ad)) % 16 == 0); - assert(reinterpret_cast(data()) % 16 == 0); + assertx(reinterpret_cast(Data(ad)) % 16 == 0); + assertx(reinterpret_cast(data()) % 16 == 0); memcpy16_inline(Data(ad), data(), sizeof(Elm) * oldUsed); - assert(ClearElms(Data(ad) + oldUsed, Capacity(newScale) - oldUsed)); + assertx(ClearElms(Data(ad) + oldUsed, Capacity(newScale) - oldUsed)); auto const table = ad->initHash(newScale); auto const mask = ad->mask(); @@ -437,19 +437,19 @@ SetArray* SetArray::grow(bool copy) { setZombie(); } - assert(ad->hasExactlyOneRef()); - assert(ad->kind() == kind()); - assert(ad->m_size == m_size); - assert(ad->m_pos == m_pos); - assert(ad->m_scale == newScale); - assert(ad->m_used == oldUsed); - assert(ad->checkInvariants()); + assertx(ad->hasExactlyOneRef()); + assertx(ad->kind() == kind()); + assertx(ad->m_size == m_size); + assertx(ad->m_pos == m_pos); + assertx(ad->m_scale == newScale); + assertx(ad->m_used == oldUsed); + assertx(ad->checkInvariants()); return ad; } ALWAYS_INLINE SetArray* SetArray::prepareForInsert(bool copy) { - assert(checkInvariants()); + assertx(checkInvariants()); if (isFull()) return grow(copy); if (copy) return copySet(); return this; @@ -469,23 +469,23 @@ void SetArray::compact() { for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (elm.isTombstone()) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); if (j != i) elms[j] = elms[i]; *findForNewInsert(table, mask, elm.hash()) = j; ++j; } - assert(ClearElms(elms + j, m_used - j)); + assertx(ClearElms(elms + j, m_used - j)); if (m_pos == m_used) { m_pos = j; } else { - assert(m_pos < m_used); + assertx(m_pos < m_used); m_pos = findElm(posElm); } m_used = j; - assert(m_size == m_used); - assert(checkInvariants()); + assertx(m_size == m_used); + assertx(checkInvariants()); } ////////////////////////////////////////////////////////////////////// @@ -523,18 +523,18 @@ bool SetArray::checkInvariants() const { static_assert(sizeof(Elm) <= 16, "Don't loose the precious memory gainz!"); // All arrays: - assert(checkCount()); - assert(isNotDVArray()); - assert(m_scale >= 1 && (m_scale & (m_scale - 1)) == 0); - assert(HashSize(m_scale) == folly::nextPowTwo(capacity())); + assertx(checkCount()); + assertx(isNotDVArray()); + assertx(m_scale >= 1 && (m_scale & (m_scale - 1)) == 0); + assertx(HashSize(m_scale) == folly::nextPowTwo(capacity())); if (isZombie()) return true; // Non-zombie: - assert(m_size <= m_used); - assert(m_used <= capacity()); - assert(0 <= m_pos && m_pos <= m_used); - assert(m_pos == m_used || !data()[m_pos].isInvalid()); + assertx(m_size <= m_used); + assertx(m_used <= capacity()); + assertx(0 <= m_pos && m_pos <= m_used); + assertx(m_pos == m_used || !data()[m_pos].isInvalid()); #if 0 /* @@ -545,13 +545,13 @@ bool SetArray::checkInvariants() const { for (uint32_t i = 0; i < capacity(); ++i) { auto& elm = elms[i]; if (i >= m_used) { - assert(elm.isEmpty()); + assertx(elm.isEmpty()); } else { - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); if (!elm.isTombstone()) nonempty++; } } - assert(nonempty == m_size); + assertx(nonempty == m_size); uint32_t nused = 0; nonempty = 0; @@ -560,14 +560,14 @@ bool SetArray::checkInvariants() const { for (uint32_t i = 0; i < HashSize(m_scale); ++i) { if (hash[i] != Empty) { if (hash[i] != Tombstone) { - assert(hash[i] < m_used); + assertx(hash[i] < m_used); nonempty++; } nused++; } } - assert(nused == m_used); - assert(nonempty == m_size); + assertx(nused == m_used); + assertx(nonempty == m_size); #endif return true; @@ -599,7 +599,7 @@ size_t SetArray::Vsize(const ArrayData*) { not_reached(); } member_rval::ptr_u SetArray::GetValueRef(const ArrayData* ad, ssize_t pos) { auto a = asSet(ad); - assert(0 <= pos && pos < a->m_used); + assertx(0 <= pos && pos < a->m_used); return a->tvOfPos(pos); } @@ -787,7 +787,7 @@ ArrayData* SetArray::Pop(ArrayData* ad, Variant& value) { auto loc = a->findForRemove(pelm->hash(), [pelm] (const Elm& e) { return &e == pelm; } ); - assert(loc != Empty); + assertx(loc != Empty); a->erase(loc); } else { value = uninit_null(); @@ -810,7 +810,7 @@ ArrayData* SetArray::Dequeue(ArrayData* ad, Variant& value) { auto loc = a->findForRemove(pelm->hash(), [pelm] (const Elm& e) { return &e == pelm; } ); - assert(loc != Empty); + assertx(loc != Empty); a->erase(loc); } else { value = uninit_null(); @@ -827,7 +827,7 @@ ArrayData* SetArray::Prepend(ArrayData* ad, Cell v, bool copy) { auto a = asSet(ad); if (copy) a = a->copySet(); Elm e; - assert(ClearElms(&e, 1)); + assertx(ClearElms(&e, 1)); if (isIntType(v.m_type)) { e.setIntKey(v.m_data.num, hash_int64(v.m_data.num)); } else if (isStringType(v.m_type)) { @@ -847,7 +847,7 @@ ArrayData* SetArray::Prepend(ArrayData* ad, Cell v, bool copy) { ++a->m_size; elms[0] = e; - assert(!elms[0].isInvalid()); + assertx(!elms[0].isInvalid()); a->compact(); // Rebuild the hash table. return a; } @@ -865,7 +865,7 @@ void SetArray::OnSetEvalScalar(ArrayData* ad) { for (uint32_t i = 0; i < used; ++i) { auto& elm = elms[i]; if (UNLIKELY(elm.isTombstone())) continue; - assert(!elm.isEmpty()); + assertx(!elm.isEmpty()); tvAsVariant(&elm.tv).setEvalScalar(); } } @@ -927,8 +927,8 @@ ArrayData* SetArray::ToKeyset(ArrayData* ad, bool /*copy*/) { ALWAYS_INLINE bool SetArray::EqualHelper(const ArrayData* ad1, const ArrayData* ad2, bool strict) { - assert(asSet(ad1)->checkInvariants()); - assert(asSet(ad2)->checkInvariants()); + assertx(asSet(ad1)->checkInvariants()); + assertx(asSet(ad2)->checkInvariants()); if (ad1 == ad2) return true; if (ad1->size() != ad2->size()) return false; diff --git a/hphp/runtime/base/set-array.h b/hphp/runtime/base/set-array.h index 082a0762de5..17f3a1ccae0 100644 --- a/hphp/runtime/base/set-array.h +++ b/hphp/runtime/base/set-array.h @@ -53,21 +53,21 @@ struct SetArrayElm { static auto constexpr kEmpty = KindOfUninit; void setStrKey(StringData* k, strhash_t h) { - assert(isEmpty()); + assertx(isEmpty()); k->incRefCount(); tv.m_type = KindOfString; tv.m_data.pstr = k; tv.hash() = h; - assert(!isInvalid()); + assertx(!isInvalid()); } void setIntKey(int64_t k, inthash_t h) { - assert(isEmpty()); + assertx(isEmpty()); tv.m_type = KindOfInt64; tv.m_data.num = k; tv.hash() = h | STRHASH_MSB; - assert(!isInvalid()); - assert(hasIntKey()); + assertx(!isInvalid()); + assertx(hasIntKey()); } void setTombstone() { @@ -90,17 +90,17 @@ struct SetArrayElm { * that we don't have to care about the MSB when working * with strhash_t. */ - assert(!isInvalid()); + assertx(!isInvalid()); return tv.hash() >= 0; } ALWAYS_INLINE StringData* strKey() const { - assert(hasStrKey()); + assertx(hasStrKey()); return tv.m_data.pstr; } ALWAYS_INLINE bool hasIntKey() const { - assert(!isInvalid()); + assertx(!isInvalid()); return tv.hash() < 0; } @@ -110,7 +110,7 @@ struct SetArrayElm { ALWAYS_INLINE Cell getKey() const { - assert(!isInvalid()); + assertx(!isInvalid()); Cell out; cellDup(tv, out); return out; diff --git a/hphp/runtime/base/simple-counter.cpp b/hphp/runtime/base/simple-counter.cpp index 0c50459f253..4ced477cd70 100644 --- a/hphp/runtime/base/simple-counter.cpp +++ b/hphp/runtime/base/simple-counter.cpp @@ -74,7 +74,7 @@ void SimpleCounter::Count(const std::string &name) { if (Enabled) { int count = ++s_counter->m_counters[name]; if (SampleStackCount > 0) { - assert(StackTrace::Enabled); + assertx(StackTrace::Enabled); std::vector &stackVec = s_counter->m_stacks[name]; if ((int)stackVec.size() < SampleStackCount || HHVM_FN(rand)(0, count - 1) < SampleStackCount) { diff --git a/hphp/runtime/base/slab-manager.h b/hphp/runtime/base/slab-manager.h index 62d0a2d28c5..900c344bc2f 100644 --- a/hphp/runtime/base/slab-manager.h +++ b/hphp/runtime/base/slab-manager.h @@ -17,10 +17,10 @@ #ifndef incl_HPHP_SLAB_MANAGER_H_ #define incl_HPHP_SLAB_MANAGER_H_ +#include "hphp/util/assertions.h" #include "hphp/util/portability.h" #include -#include #include #include @@ -41,7 +41,7 @@ struct TaggedSlabPtr { /* implicit */ TaggedSlabPtr(std::nullptr_t) noexcept : rep(0) {} TaggedSlabPtr(void* p, uint16_t tag = 0) noexcept : rep(reinterpret_cast(p) | tag) { - assert(ptr() == p); + assertx(ptr() == p); } void* ptr() const { return reinterpret_cast(rep & ~TagMask); @@ -130,7 +130,7 @@ struct SlabManager : TaggedSlabList { // multiple local slabs to the global list in one batch at the end of each // request. void merge(TaggedSlabPtr newHead, void* localTail) { - assert(newHead); + assertx(newHead); // No need to bump the tag here, as it is already bumped when forming the // local list. auto last = reinterpret_cast(localTail); diff --git a/hphp/runtime/base/socket.cpp b/hphp/runtime/base/socket.cpp index 198a05e75c8..f195dd16a34 100644 --- a/hphp/runtime/base/socket.cpp +++ b/hphp/runtime/base/socket.cpp @@ -64,7 +64,7 @@ Socket::Socket(std::shared_ptr data) : File(data), m_data(static_cast(getFileData())) { - assert(data); + assertx(data); inferStreamType(); } @@ -177,8 +177,8 @@ bool Socket::waitForData() { } int64_t Socket::readImpl(char *buffer, int64_t length) { - assert(getFd()); - assert(length > 0); + assertx(getFd()); + assertx(length > 0); IOStatusHelper io("socket::recv", m_data->m_address.c_str(), m_data->m_port); @@ -202,8 +202,8 @@ int64_t Socket::readImpl(char *buffer, int64_t length) { } int64_t Socket::writeImpl(const char *buffer, int64_t length) { - assert(getFd()); - assert(length > 0); + assertx(getFd()); + assertx(length > 0); setEof(false); IOStatusHelper io("socket::send", m_data->m_address.c_str(), m_data->m_port); int64_t ret = send(getFd(), buffer, length, 0); diff --git a/hphp/runtime/base/sort-flags.h b/hphp/runtime/base/sort-flags.h index ae3c40083ef..9cf3d43667c 100644 --- a/hphp/runtime/base/sort-flags.h +++ b/hphp/runtime/base/sort-flags.h @@ -98,7 +98,7 @@ inline bool supportedByPacked(SortFunction s) { } inline SortFunction getSortFunction(SortFunction s, bool ascending = true) { - assert(!hasUserDefinedCmp(s)); + assertx(!hasUserDefinedCmp(s)); // ascending: LSB == 0 return static_cast(s & ~static_cast(ascending)); } diff --git a/hphp/runtime/base/sort-helpers.h b/hphp/runtime/base/sort-helpers.h index bac2f7a0e8e..369e31ad857 100644 --- a/hphp/runtime/base/sort-helpers.h +++ b/hphp/runtime/base/sort-helpers.h @@ -52,7 +52,7 @@ struct AssocKeyAccessorImpl { if (isInt(elm)) { return Self::getInt(elm); } - assert(isStr(elm)); + assertx(isStr(elm)); return Variant{Self::getStr(elm)}; } }; @@ -149,7 +149,7 @@ struct IntElmCompare { (string_natural_cmp(sLeft, lenLeft, sRight, lenRight, 1) > 0) : (string_natural_cmp(sLeft, lenLeft, sRight, lenRight, 1) < 0); } - assert(false); + assertx(false); return true; } }; @@ -198,7 +198,7 @@ struct StrElmCompare { (string_natural_cmp(sLeft, lenLeft, sRight, lenRight, 1) > 0) : (string_natural_cmp(sLeft, lenLeft, sRight, lenRight, 1) < 0); } - assert(false); + assertx(false); return true; } }; @@ -313,7 +313,7 @@ struct ElmCompare { (string_natural_cmp(sLeft, lenLeft, sRight, lenRight, 1) > 0) : (string_natural_cmp(sLeft, lenLeft, sRight, lenRight, 1) < 0); } - assert(false); + assertx(false); return true; } }; diff --git a/hphp/runtime/base/sparse-heap.cpp b/hphp/runtime/base/sparse-heap.cpp index bd511f8b11b..29f97a0143c 100644 --- a/hphp/runtime/base/sparse-heap.cpp +++ b/hphp/runtime/base/sparse-heap.cpp @@ -69,7 +69,7 @@ void SparseHeap::reset() { } void SparseHeap::flush() { - assert(empty()); + assertx(empty()); m_slabs = std::vector{}; m_bigs = std::vector{}; m_pooledBytes = 0; diff --git a/hphp/runtime/base/ssl-socket.cpp b/hphp/runtime/base/ssl-socket.cpp index 9e5754ab7fc..b34d6faea1f 100644 --- a/hphp/runtime/base/ssl-socket.cpp +++ b/hphp/runtime/base/ssl-socket.cpp @@ -56,7 +56,7 @@ int SSLSocket::GetSSLExDataIndex() { if (s_ex_data_index < 0) { s_ex_data_index = SSL_get_ex_new_index(0, (void*)"PHP stream index", nullptr, nullptr, nullptr); - assert(s_ex_data_index >= 0); + assertx(s_ex_data_index >= 0); } return s_ex_data_index; } @@ -294,7 +294,7 @@ bool SSLSocket::onAccept() { m_data->m_method = CryptoMethod::ServerTLS; break; default: - assert(false); + assertx(false); } if (setupCrypto() && enableCrypto()) { diff --git a/hphp/runtime/base/ssl-socket.h b/hphp/runtime/base/ssl-socket.h index ead219d385a..8df4e043e1a 100644 --- a/hphp/runtime/base/ssl-socket.h +++ b/hphp/runtime/base/ssl-socket.h @@ -134,7 +134,7 @@ private: struct Certificate : SweepableResourceData { X509 *m_cert; - explicit Certificate(X509 *cert) : m_cert(cert) { assert(m_cert);} + explicit Certificate(X509 *cert) : m_cert(cert) { assertx(m_cert);} ~Certificate() { if (m_cert) X509_free(m_cert); } diff --git a/hphp/runtime/base/stat-cache.cpp b/hphp/runtime/base/stat-cache.cpp index 4e285bc24bc..9d06f702e2f 100644 --- a/hphp/runtime/base/stat-cache.cpp +++ b/hphp/runtime/base/stat-cache.cpp @@ -397,7 +397,7 @@ void StatCache::Node::insertChild(const std::string& childName, StatCache::NodePtr child, bool follow) { auto& map = follow ? m_children : m_lChildren; if (!map.insert(std::make_pair(childName, child)).second) { - assert(0); // should not already exist in the map here. + assertx(0); // should not already exist in the map here. } } @@ -460,8 +460,8 @@ void StatCache::clear() { m_root->expirePaths(); } m_root = nullptr; - assert(m_path2Node.size() == 0); - assert(m_lpath2Node.size() == 0); + assertx(m_path2Node.size() == 0); + assertx(m_lpath2Node.size() == 0); } void StatCache::reset() { @@ -492,7 +492,7 @@ StatCache::NodePtr StatCache::getNode(const std::string& path, bool follow) { if (!node.get()) { node = new Node(*this, wd); if (!m_watch2Node.insert(std::make_pair(wd, node)).second) { - assert(0); // should not already exist in the map + assertx(0); // should not already exist in the map } TRACE(2, "StatCache: getNode('%s', follow=%s) --> %p (wd=%d)\n", path.c_str(), follow ? "true" : "false", node.get(), wd); @@ -516,7 +516,7 @@ bool StatCache::mergePath(const std::string& path, bool follow) { String canonicalPath = FileUtil::canonicalize(path); std::vector pvec; folly::split('/', canonicalPath.slice(), pvec); - assert((pvec[0].size() == 0)); // path should be absolute. + assertx((pvec[0].size() == 0)); // path should be absolute. // Lazily initialize so that if StatCache never gets used, no kernel // resources are consumed. if (m_ifd == -1 && init()) { @@ -558,7 +558,7 @@ bool StatCache::handleEvent(const struct inotify_event* event) { reset(); return true; } - assert(event->wd != -1); + assertx(event->wd != -1); NodePtr node = folly::get_default(m_watch2Node, event->wd); if (!node.get()) { TRACE(1, "StatCache: inotify event (obsolete) %s\n", @@ -656,7 +656,7 @@ void StatCache::refresh() { int nread = read(m_ifd, m_readBuf, kReadBufSize); if (nread == -1) { // No pending events. - assert(errno == EAGAIN); + assertx(errno == EAGAIN); // Record the last refresh time *after* processing the event queue, in // order to assure that once the event queue has been merged into the // cache state, all cached values have timestamps older than @@ -813,7 +813,7 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/realpath.c,v 1.24 2011/11/04 19:56:34 ed // components. Returns the resolved path on success, or "" on failure, std::string StatCache::realpathImpl(const char* path) { std::string resolved; - assert(path != nullptr); + assertx(path != nullptr); if (path[0] != '/') { return realpathLibc(path); } diff --git a/hphp/runtime/base/static-string-table.cpp b/hphp/runtime/base/static-string-table.cpp index e6950e1fac4..836d619a7b0 100644 --- a/hphp/runtime/base/static-string-table.cpp +++ b/hphp/runtime/base/static-string-table.cpp @@ -50,14 +50,14 @@ bool isMagicKey(StrInternKey k) { } const StringData* to_sdata(StrInternKey key) { - assert(!isMagicKey(key)); + assertx(!isMagicKey(key)); static_assert(std::is_unsigned(), "cast must zero-extend"); return reinterpret_cast(key); } struct strintern_eq { bool operator()(StrInternKey k1, StrInternKey k2) const { - assert(!isMagicKey(k2)); // no magic values on rhs + assertx(!isMagicKey(k2)); // no magic values on rhs return operator()(k1, to_sdata(k2)); } @@ -83,7 +83,7 @@ struct strintern_eq { struct strintern_hash { size_t operator()(StrInternKey k) const { - assert(!isMagicKey(k)); // no magic values get here + assertx(!isMagicKey(k)); // no magic values get here return operator()(to_sdata(k)); } @@ -109,13 +109,13 @@ struct EmbeddedStringMap { explicit operator bool() const { return inited; } StringDataMap* operator->() { - assert(inited); + assertx(inited); return reinterpret_cast(&data); } - StringDataMap& operator*() { assert(inited); return *operator->(); } + StringDataMap& operator*() { assertx(inited); return *operator->(); } void emplace(uint32_t size, const StringDataMap::Config& config) { - assert(!inited); + assertx(!inited); new (&data) StringDataMap(size, config); inited = true; } @@ -139,11 +139,11 @@ EmbeddedStringMap s_stringDataMap; // If a string is static it better be the one in the table. DEBUG_ONLY bool checkStaticStr(const StringData* s) { - assert(s->isStatic()); - assert(s_stringDataMap); + assertx(s->isStatic()); + assertx(s_stringDataMap); auto DEBUG_ONLY const it = s_stringDataMap->find(s); - assert(it != s_stringDataMap->end()); - assert(to_sdata(it->first) == s); + assertx(it != s_stringDataMap->end()); + assertx(to_sdata(it->first) == s); return true; } @@ -158,7 +158,7 @@ StringData** precompute_chars() { } StringData* insertStaticString(StringData* sd) { - assert(sd->isStatic()); + assertx(sd->isStatic()); auto pair = s_stringDataMap->insert( safe_cast(reinterpret_cast(sd)), rds::Link(rds::kUninitHandle) @@ -176,7 +176,7 @@ StringData* insertStaticString(StringData* sd) { static std::atomic signaled{false}; checkAHMSubMaps(*s_stringDataMap, "static string table", signaled); } - assert(to_sdata(pair.first->first) != nullptr); + assertx(to_sdata(pair.first->first) != nullptr); return const_cast(to_sdata(pair.first->first)); } @@ -210,7 +210,7 @@ size_t makeStaticStringCount() { StringData* makeStaticString(const StringData* str) { if (str->isStatic()) { - assert(checkStaticStr(str)); + assertx(checkStaticStr(str)); return const_cast(str); } auto const it = s_stringDataMap->find(str); @@ -229,7 +229,7 @@ StringData* makeStaticString(folly::StringPiece slice) { } StringData* lookupStaticString(const StringData *str) { - assert(s_stringDataMap && !str->isStatic()); + assertx(s_stringDataMap && !str->isStatic()); auto const it = s_stringDataMap->find(str); if (it != s_stringDataMap->end()) { return const_cast(to_sdata(it->first)); @@ -238,17 +238,17 @@ StringData* lookupStaticString(const StringData *str) { } StringData* makeStaticString(const String& str) { - assert(!str.isNull()); + assertx(!str.isNull()); return makeStaticString(str.get()); } StringData* makeStaticString(const char* str, size_t len) { - assert(len <= StringData::MaxSize); + assertx(len <= StringData::MaxSize); return makeStaticString(folly::StringPiece{str, len}); } StringData* makeStaticString(const std::string& str) { - assert(str.size() <= StringData::MaxSize); + assertx(str.size() <= StringData::MaxSize); return makeStaticString(folly::StringPiece{str.c_str(), str.size()}); } @@ -262,7 +262,7 @@ StringData* makeStaticString(char c) { } StringData* makeStaticStringSafe(const char* str, size_t len) { - assert(len <= StringData::MaxSize); + assertx(len <= StringData::MaxSize); if (UNLIKELY(!s_stringDataMap)) { create_string_data_map(); } @@ -277,7 +277,7 @@ StringData* makeStaticStringSafe(const char* str) { } bool bindPersistentCns(const StringData* cnsName, const Cell& value) { - assert(s_stringDataMap); + assertx(s_stringDataMap); auto const it = s_stringDataMap->find(cnsName); assertx(it != s_stringDataMap->end()); it->second.bind( @@ -294,7 +294,7 @@ bool bindPersistentCns(const StringData* cnsName, const Cell& value) { } rds::Handle lookupCnsHandle(const StringData* cnsName) { - assert(s_stringDataMap); + assertx(s_stringDataMap); auto const it = s_stringDataMap->find(cnsName); if (it != s_stringDataMap->end()) { return it->second.maybeHandle(); @@ -312,7 +312,7 @@ rds::Handle makeCnsHandle(const StringData* cnsName) { return rds::kUninitHandle; } auto const it = s_stringDataMap->find(cnsName); - assert(it != s_stringDataMap->end()); + assertx(it != s_stringDataMap->end()); if (!it->second.bound()) { it->second.bind(rds::Mode::Normal); @@ -323,7 +323,7 @@ rds::Handle makeCnsHandle(const StringData* cnsName) { } std::vector lookupDefinedStaticStrings() { - assert(s_stringDataMap); + assertx(s_stringDataMap); std::vector ret; for (auto it = s_stringDataMap->begin(); @@ -339,7 +339,7 @@ const StaticString s_user("user"); const StaticString s_Core("Core"); Array lookupDefinedConstants(bool categorize /*= false */) { - assert(s_stringDataMap); + assertx(s_stringDataMap); Array usr(rds::s_constants()); Array sys; diff --git a/hphp/runtime/base/stats.cpp b/hphp/runtime/base/stats.cpp index 3eb4b3c9127..ff0fc99e853 100644 --- a/hphp/runtime/base/stats.cpp +++ b/hphp/runtime/base/stats.cpp @@ -43,7 +43,7 @@ __thread StatGroupMap* tl_stat_groups = nullptr; void init() { if (!enabledAny()) return; - assert(tl_stat_groups == nullptr); + assertx(tl_stat_groups == nullptr); tl_stat_groups = new StatGroupMap(); } @@ -106,13 +106,13 @@ void clear() { ++epoch; memset(&tl_counters[0], 0, sizeof(tl_counters)); - assert(tl_stat_groups); + assertx(tl_stat_groups); delete tl_stat_groups; tl_stat_groups = nullptr; } void incStatGrouped(const StringData* category, const StringData* name, int n) { - assert(tl_stat_groups); + assertx(tl_stat_groups); (*tl_stat_groups)[category->data()][name->data()] += n; } diff --git a/hphp/runtime/base/stream-wrapper-registry.cpp b/hphp/runtime/base/stream-wrapper-registry.cpp index e0fc644be42..7f08713c521 100644 --- a/hphp/runtime/base/stream-wrapper-registry.cpp +++ b/hphp/runtime/base/stream-wrapper-registry.cpp @@ -64,7 +64,7 @@ static __thread Wrapper* tl_fileHandler; IMPLEMENT_STATIC_REQUEST_LOCAL(RequestWrappers, s_request_wrappers); bool registerWrapper(const std::string &scheme, Wrapper *wrapper) { - assert(s_wrappers.find(scheme) == s_wrappers.end()); + assertx(s_wrappers.find(scheme) == s_wrappers.end()); s_wrappers[scheme] = wrapper; return true; } diff --git a/hphp/runtime/base/string-buffer.cpp b/hphp/runtime/base/string-buffer.cpp index 2ed7cd7921b..f5153bd0fb0 100644 --- a/hphp/runtime/base/string-buffer.cpp +++ b/hphp/runtime/base/string-buffer.cpp @@ -43,8 +43,8 @@ StringBuffer::StringBuffer(uint32_t initialSize /* = SmallStringReserve */) StringBuffer::~StringBuffer() { if (m_str) { - assert(m_str->hasExactlyOneRef()); - assert((m_str->setSize(0), true)); // appease StringData::checkSane() + assertx(m_str->hasExactlyOneRef()); + assertx((m_str->setSize(0), true)); // appease StringData::checkSane() m_str->release(); } } @@ -60,7 +60,7 @@ const char* StringBuffer::data() const { String StringBuffer::detach() { if (m_str && m_len) { - assert(m_str->hasExactlyOneRef()); + assertx(m_str->hasExactlyOneRef()); auto str = String::attach(m_str); str.setSize(m_len); m_str = nullptr; @@ -104,7 +104,7 @@ void StringBuffer::clear() { void StringBuffer::release() { if (m_str) { - assert(m_str->hasExactlyOneRef()); + assertx(m_str->hasExactlyOneRef()); if (debug) { m_str->mutableData()[m_len] = 0; // appease StringData::checkSane() } @@ -115,7 +115,7 @@ void StringBuffer::release() { } void StringBuffer::resize(uint32_t size) { - assert(size <= m_cap); + assertx(size <= m_cap); if (size <= m_cap) { m_len = size; } @@ -128,7 +128,7 @@ char* StringBuffer::appendCursor(int size) { m_str->setSize(m_len); auto const tmp = m_str->reserve(m_len + size); if (UNLIKELY(tmp != m_str)) { - assert(m_str->hasExactlyOneRef()); + assertx(m_str->hasExactlyOneRef()); m_str->release(); m_str = tmp; } @@ -207,8 +207,8 @@ void StringBuffer::appendHelper(char ch) { } void StringBuffer::makeValid(uint32_t minCap) { - assert(!valid()); - assert(!m_len); + assertx(!valid()); + assertx(!m_len); m_str = StringData::Make(std::max(m_initialCap, minCap)); m_cap = m_str->capacity(); } @@ -216,8 +216,8 @@ void StringBuffer::makeValid(uint32_t minCap) { void StringBuffer::appendHelper(const char *s, int len) { if (!valid()) makeValid(len); - assert(s); - assert(len >= 0); + assertx(s); + assertx(len >= 0); if (len <= 0) return; if (len > m_cap - m_len) { @@ -250,8 +250,8 @@ void StringBuffer::printf(const char *format, ...) { } void StringBuffer::read(FILE* in, int page_size /* = 1024 */) { - assert(in); - assert(page_size > 0); + assertx(in); + assertx(page_size > 0); if (!valid()) makeValid(page_size); while (true) { @@ -267,8 +267,8 @@ void StringBuffer::read(FILE* in, int page_size /* = 1024 */) { } void StringBuffer::read(File* in, int page_size /* = 1024 */) { - assert(in); - assert(page_size > 0); + assertx(in); + assertx(page_size > 0); if (!valid()) makeValid(page_size); while (true) { @@ -278,7 +278,7 @@ void StringBuffer::read(File* in, int page_size /* = 1024 */) { buffer_size = m_cap - m_len; } int64_t len = in->readImpl(m_str->mutableData() + m_len, buffer_size); - assert(len >= 0); + assertx(len >= 0); if (len == 0) break; m_len += len; } @@ -310,7 +310,7 @@ void StringBuffer::growBy(int spaceRequired) { m_str->setSize(m_len); auto const tmp = m_str->reserve(new_size); if (UNLIKELY(tmp != m_str)) { - assert(m_str->hasExactlyOneRef()); + assertx(m_str->hasExactlyOneRef()); m_str->release(); m_str = tmp; } @@ -321,7 +321,7 @@ void StringBuffer::growBy(int spaceRequired) { CstrBuffer::CstrBuffer(int cap) : m_buffer((char*)safe_malloc(cap + 1)), m_len(0), m_cap(cap) { - assert(unsigned(cap) <= kMaxCap); + assertx(unsigned(cap) <= kMaxCap); } CstrBuffer::CstrBuffer(const char *filename) @@ -353,7 +353,7 @@ CstrBuffer::CstrBuffer(const char *filename) CstrBuffer::CstrBuffer(char* data, int len) : m_buffer(data), m_len(len), m_cap(len) { - assert(unsigned(len) < kMaxCap); + assertx(unsigned(len) < kMaxCap); } CstrBuffer::~CstrBuffer() { @@ -366,7 +366,7 @@ void CstrBuffer::append(folly::StringPiece slice) { static_assert(std::is_unsigned::value, "len is supposed to be unsigned"); - assert(m_buffer); + assertx(m_buffer); unsigned newlen = m_len + len; if (newlen + 1 > m_cap) { @@ -376,14 +376,14 @@ void CstrBuffer::append(folly::StringPiece slice) { unsigned newcap = folly::nextPowTwo(newlen + 1); m_buffer = (char*)safe_realloc(m_buffer, newcap); m_cap = newcap - 1; - assert(newlen + 1 <= m_cap); + assertx(newlen + 1 <= m_cap); } memcpy(m_buffer + m_len, data, len); m_buffer[m_len = newlen] = 0; } String CstrBuffer::detach() { - assert(m_len <= m_cap); + assertx(m_len <= m_cap); m_buffer[m_len] = 0; String s(m_buffer, m_len, AttachString); m_buffer = 0; diff --git a/hphp/runtime/base/string-buffer.h b/hphp/runtime/base/string-buffer.h index edc017027a3..915ec7c1fcd 100644 --- a/hphp/runtime/base/string-buffer.h +++ b/hphp/runtime/base/string-buffer.h @@ -152,7 +152,7 @@ struct StringBuffer { * Mutate a character in existing buffer. */ void set(uint32_t offset, char c) { - assert(offset < m_len); + assertx(offset < m_len); m_str->mutableData()[offset] = c; } @@ -167,13 +167,13 @@ struct StringBuffer { appendHelper(c); } void append(unsigned char c) { append((char)c);} - void append(const char* s) { assert(s); append(s, strlen(s)); } + void append(const char* s) { assertx(s); append(s, strlen(s)); } void append(const String& s) { append(s.data(), s.size()); } void append(const std::string& s) { append(s.data(), s.size()); } void append(const StringData* s) { append(s->data(), s->size()); } void append(folly::StringPiece s) { append(s.data(), s.size()); } void append(const char* s, int len) { - assert(len >= 0); + assertx(len >= 0); if (m_str && len <= m_cap - m_len) { memcpy(m_str->mutableData() + m_len, s, len); m_len += len; @@ -296,7 +296,7 @@ private: }; inline const char* CstrBuffer::data() const { - assert(m_len <= m_cap); + assertx(m_len <= m_cap); m_buffer[m_len] = 0; return m_buffer; } diff --git a/hphp/runtime/base/string-data-inl.h b/hphp/runtime/base/string-data-inl.h index 7108b453adf..2085b81e2c4 100644 --- a/hphp/runtime/base/string-data-inl.h +++ b/hphp/runtime/base/string-data-inl.h @@ -56,33 +56,33 @@ inline folly::StringPiece StringData::slice() const { } inline folly::MutableStringPiece StringData::bufferSlice() { - assert(!isImmutable()); + assertx(!isImmutable()); return folly::MutableStringPiece{mutableData(), capacity()}; } inline void StringData::invalidateHash() { - assert(!isImmutable()); - assert(!hasMultipleRefs()); + assertx(!isImmutable()); + assertx(!hasMultipleRefs()); m_hash = 0; - assert(checkSane()); + assertx(checkSane()); } inline void StringData::setSize(int len) { - assert(!isImmutable() && !hasMultipleRefs()); - assert(len >= 0 && len <= capacity()); + assertx(!isImmutable() && !hasMultipleRefs()); + assertx(len >= 0 && len <= capacity()); mutableData()[len] = 0; m_lenAndHash = len; - assert(m_hash == 0); - assert(checkSane()); + assertx(m_hash == 0); + assertx(checkSane()); } inline void StringData::checkStack() const { - assert(uintptr_t(this) - s_stackLimit >= s_stackSize); + assertx(uintptr_t(this) - s_stackLimit >= s_stackSize); } inline const char* StringData::data() const { // TODO: t1800106: re-enable this assert - // assert(data()[size()] == 0); // all strings must be null-terminated + // assertx(data()[size()] == 0); // all strings must be null-terminated #ifdef NO_M_DATA return reinterpret_cast(this + 1); #else @@ -91,7 +91,7 @@ inline const char* StringData::data() const { } inline char* StringData::mutableData() const { - assert(!isImmutable()); + assertx(!isImmutable()); return const_cast(data()); } @@ -110,7 +110,7 @@ inline size_t StringData::heapSize() const { } inline size_t StringData::estimateCap(size_t size) { - assert(size <= MaxSize); + assertx(size <= MaxSize); return MemoryManager::sizeClass(size + kStringOverhead); } @@ -133,8 +133,8 @@ inline bool StringData::isZero() const { } inline StringData* StringData::modifyChar(int offset, char c) { - assert(offset >= 0 && offset < size()); - assert(!hasMultipleRefs()); + assertx(offset >= 0 && offset < size()); + assertx(!hasMultipleRefs()); auto const sd = isProxy() ? escalate(size()) : this; sd->mutableData()[offset] = c; @@ -156,17 +156,17 @@ inline strhash_t StringData::hash() const { } inline bool StringData::same(const StringData* s) const { - assert(s); + assertx(s); if (m_len != s->m_len) return false; // The underlying buffer and its length are 8-byte aligned, ensured by // StringData layout, req::malloc, or malloc. So compare words. - assert(uintptr_t(data()) % 8 == 0); - assert(uintptr_t(s->data()) % 8 == 0); + assertx(uintptr_t(data()) % 8 == 0); + assertx(uintptr_t(s->data()) % 8 == 0); return wordsame(data(), s->data(), m_len); } inline bool StringData::isame(const StringData* s) const { - assert(s); + assertx(s); if (m_len != s->m_len) return false; return bstrcaseeq(data(), s->data(), m_len); } @@ -206,7 +206,7 @@ struct string_data_hash { struct string_data_same { bool operator()(const StringData *s1, const StringData *s2) const { - assert(s1 && s2); + assertx(s1 && s2); return s1->same(s2); } }; @@ -219,7 +219,7 @@ struct string_data_eq_same { struct string_data_isame { bool operator()(const StringData *s1, const StringData *s2) const { - assert(s1 && s2); + assertx(s1 && s2); return s1->isame(s2); } }; diff --git a/hphp/runtime/base/string-data.cpp b/hphp/runtime/base/string-data.cpp index ddeaa2a298c..d23596d2edc 100644 --- a/hphp/runtime/base/string-data.cpp +++ b/hphp/runtime/base/string-data.cpp @@ -53,7 +53,7 @@ ALWAYS_INLINE StringData* allocFlat(size_t len) { auto sd = static_cast(tl_heap->objMallocIndex(sizeIndex)); // Refcount initialized to 1. sd->initHeader_16(HeaderKind::String, OneReference, sizeIndex); - assert(sd->capacity() >= len); + assertx(sd->capacity() >= len); #ifndef NO_M_DATA sd->m_data = reinterpret_cast(sd + 1); #endif @@ -107,10 +107,10 @@ StringData* StringData::MakeShared(folly::StringPiece sl) { // Recalculating ret from mcret avoids a spill. ret->preCompute(); // get m_hash right - assert(ret == sd); - assert(ret->isFlat()); - assert(trueStatic ? ret->isStatic() : ret->isUncounted()); - assert(ret->checkSane()); + assertx(ret == sd); + assertx(ret->isFlat()); + assertx(trueStatic ? ret->isStatic() : ret->isUncounted()); + assertx(ret->checkSane()); return ret; } @@ -139,24 +139,24 @@ StringData* StringData::MakeEmpty() { data[0] = 0; sd->preCompute(); - assert(sd->m_len == 0); - assert(sd->capacity() == 0); - assert(sd->m_kind == HeaderKind::String); - assert(sd->isFlat()); - assert(sd->isStatic()); - assert(sd->checkSane()); + assertx(sd->m_len == 0); + assertx(sd->capacity() == 0); + assertx(sd->m_kind == HeaderKind::String); + assertx(sd->isFlat()); + assertx(sd->isStatic()); + assertx(sd->checkSane()); return sd; } void StringData::destructStatic() { - assert(checkSane() && isStatic()); - assert(isFlat()); + assertx(checkSane() && isStatic()); + assertx(isFlat()); low_free_data(this); } void StringData::ReleaseUncounted(const StringData* str) { - assert(str->checkSane()); - assert(str->isFlat()); + assertx(str->checkSane()); + assertx(str->isFlat()); if (!str->uncountedDecRef()) return; if (APCStats::IsCreated()) { @@ -172,12 +172,12 @@ void StringData::ReleaseUncounted(const StringData* str) { ////////////////////////////////////////////////////////////////////// ALWAYS_INLINE void StringData::delist() { - assert(isProxy()); + assertx(isProxy()); auto& payload = *proxy(); auto const next = payload.node.next; auto const prev = payload.node.prev; - assert(uintptr_t(next) != kMallocFreeWord); - assert(uintptr_t(prev) != kMallocFreeWord); + assertx(uintptr_t(next) != kMallocFreeWord); + assertx(uintptr_t(prev) != kMallocFreeWord); next->prev = prev; prev->next = next; } @@ -188,10 +188,10 @@ unsigned StringData::sweepAll() { for (StringDataNode *next, *n = head.next; n != &head; n = next) { count++; next = n->next; - assert(next && uintptr_t(next) != kSmallFreeWord); - assert(next && uintptr_t(next) != kMallocFreeWord); + assertx(next && uintptr_t(next) != kSmallFreeWord); + assertx(next && uintptr_t(next) != kMallocFreeWord); auto const s = node2str(n); - assert(s->isProxy()); + assertx(s->isProxy()); s->proxy()->apcstr->unreference(); } head.next = head.prev = &head; @@ -206,7 +206,7 @@ StringData* StringData::Make(const StringData* s, CopyStringMode) { auto const data = static_cast(sd + 1); *memcpy8(data, s->data(), s->m_len) = 0; - assert(sd->same(s)); + assertx(sd->same(s)); return sd; } @@ -220,12 +220,12 @@ StringData* StringData::Make(folly::StringPiece sl, CopyStringMode) { auto const ret = reinterpret_cast(mcret) - 1; // Recalculating ret from mcret avoids a spill. - assert(ret == sd); - assert(ret->m_len == sl.size()); - assert(ret->hasExactlyOneRef()); - assert(ret->m_hash == 0); - assert(ret->isFlat()); - assert(ret->checkSane()); + assertx(ret == sd); + assertx(ret->m_len == sl.size()); + assertx(ret->hasExactlyOneRef()); + assertx(ret->m_hash == 0); + assertx(ret->isFlat()); + assertx(ret->checkSane()); return ret; } @@ -241,9 +241,9 @@ StringData* StringData::Make(size_t reserveLen) { auto const sd = allocFlat(reserveLen); sd->setSize(0); - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } @@ -259,7 +259,7 @@ StringData* StringData::Make(char* data, size_t len, AttachStringMode) { } auto const sd = Make(folly::StringPiece(data, len), CopyString); free(data); - assert(sd->checkSane()); + assertx(sd->checkSane()); return sd; } @@ -273,9 +273,9 @@ StringData* StringData::Make(folly::StringPiece r1, folly::StringPiece r2) { memcpy(data + r1.size(), r2.data(), r2.size()); data[len] = 0; - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } @@ -290,9 +290,9 @@ StringData* StringData::Make(const StringData* s1, const StringData* s2) { auto const next = memcpy8(data, s1->data(), s1->m_len); *memcpy8(next, s2->data(), s2->m_len) = 0; - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } @@ -312,9 +312,9 @@ StringData* StringData::Make(folly::StringPiece r1, folly::StringPiece r2, p = static_cast(memcpy(p + r2.size(), r3.data(), r3.size())); p[r3.size()] = 0; - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } @@ -331,21 +331,21 @@ StringData* StringData::Make(folly::StringPiece r1, folly::StringPiece r2, p = static_cast(memcpy(p + r3.size(), r4.data(), r4.size())); p[r4.size()] = 0; - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } ////////////////////////////////////////////////////////////////////// ALWAYS_INLINE void StringData::enlist() { - assert(isProxy()); + assertx(isProxy()); auto& head = tl_heap->getStringList(); // insert after head auto const next = head.next; auto& payload = *proxy(); - assert(uintptr_t(next) != kMallocFreeWord); + assertx(uintptr_t(next) != kMallocFreeWord); payload.node.next = next; payload.node.prev = &head; next->prev = head.next = &payload.node; @@ -356,10 +356,10 @@ StringData* StringData::MakeProxy(const APCString* apcstr) { always_assert(false); not_reached(); #else - assert(!apcExtension::UseUncounted); + assertx(!apcExtension::UseUncounted); // No need to check if len > MaxSize, because if it were we'd never // have made the StringData in the APCVariant without throwing. - assert(size_t(apcstr->getStringData()->size()) <= size_t(MaxSize)); + assertx(size_t(apcstr->getStringData()->size()) <= size_t(MaxSize)); auto const sd = static_cast( tl_heap->mallocSmallSize(sizeof(StringData) + sizeof(Proxy)) @@ -372,19 +372,19 @@ StringData* StringData::MakeProxy(const APCString* apcstr) { sd->enlist(); apcstr->reference(); - assert(sd->m_len == data->size()); - assert(sd->m_aux16 == data->m_aux16); - assert(sd->m_kind == HeaderKind::String); - assert(sd->hasExactlyOneRef()); - assert(sd->m_hash == data->m_hash); - assert(sd->isProxy()); - assert(sd->checkSane()); + assertx(sd->m_len == data->size()); + assertx(sd->m_aux16 == data->m_aux16); + assertx(sd->m_kind == HeaderKind::String); + assertx(sd->hasExactlyOneRef()); + assertx(sd->m_hash == data->m_hash); + assertx(sd->isProxy()); + assertx(sd->checkSane()); return sd; #endif } void StringData::unProxy() { - assert(isProxy()); + assertx(isProxy()); proxy()->apcstr->unreference(); delist(); } @@ -396,8 +396,8 @@ void StringData::releaseProxy() { } void StringData::release() noexcept { - assert(isRefCounted()); - assert(checkSane()); + assertx(isRefCounted()); + assertx(checkSane()); if (UNLIKELY(!isFlat())) { releaseProxy(); AARCH64_WALKABLE_FRAME(); @@ -410,12 +410,12 @@ void StringData::release() noexcept { ////////////////////////////////////////////////////////////////////// #define ALIASING_APPEND_ASSERT(ptr, len) \ - assert(uintptr_t(ptr) <= uintptr_t(data()) || \ + assertx(uintptr_t(ptr) <= uintptr_t(data()) || \ uintptr_t(ptr) >= uintptr_t(data() + capacity() + 1)); \ - assert(ptr != data() || len <= m_len); + assertx(ptr != data() || len <= m_len); StringData* StringData::append(folly::StringPiece range) { - assert(!isImmutable() && !hasMultipleRefs()); + assertx(!isImmutable() && !hasMultipleRefs()); auto s = range.data(); auto const len = range.size(); @@ -438,13 +438,13 @@ StringData* StringData::append(folly::StringPiece range) { : reserve(requestLen); memcpy(target->mutableData() + m_len, s, len); target->setSize(newLen); - assert(target->checkSane()); + assertx(target->checkSane()); return target; } StringData* StringData::append(folly::StringPiece r1, folly::StringPiece r2) { - assert(!isImmutable() && !hasMultipleRefs()); + assertx(!isImmutable() && !hasMultipleRefs()); auto const len = r1.size() + r2.size(); @@ -476,7 +476,7 @@ StringData* StringData::append(folly::StringPiece r1, folly::StringPiece r2) { memcpy((char*)p + r1.size(), r2.data(), r2.size()); target->setSize(newLen); - assert(target->checkSane()); + assertx(target->checkSane()); return target; } @@ -484,7 +484,7 @@ StringData* StringData::append(folly::StringPiece r1, folly::StringPiece r2) { StringData* StringData::append(folly::StringPiece r1, folly::StringPiece r2, folly::StringPiece r3) { - assert(!isImmutable() && !hasMultipleRefs()); + assertx(!isImmutable() && !hasMultipleRefs()); auto const len = r1.size() + r2.size() + r3.size(); @@ -518,7 +518,7 @@ StringData* StringData::append(folly::StringPiece r1, memcpy((char*)p + r2.size(), r3.data(), r3.size()); target->setSize(newLen); - assert(target->checkSane()); + assertx(target->checkSane()); return target; } @@ -528,8 +528,8 @@ StringData* StringData::append(folly::StringPiece r1, ////////////////////////////////////////////////////////////////////// StringData* StringData::reserve(size_t cap) { - assert(!isImmutable() && !hasMultipleRefs()); - assert(isFlat()); + assertx(!isImmutable() && !hasMultipleRefs()); + assertx(isFlat()); if (cap <= capacity()) return this; @@ -555,16 +555,16 @@ StringData* StringData::reserve(size_t cap) { assertx(reinterpret_cast(&m_lenAndHash) % 16 == 0); #endif - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } StringData* StringData::shrinkImpl(size_t len) { - assert(!isImmutable() && !hasMultipleRefs()); - assert(isFlat()); - assert(len <= capacity()); + assertx(!isImmutable() && !hasMultipleRefs()); + assertx(isFlat()); + assertx(len <= capacity()); auto const sd = allocFlat(len); sd->m_lenAndHash = len; @@ -572,32 +572,32 @@ StringData* StringData::shrinkImpl(size_t len) { auto const dst = static_cast(sd + 1); *memcpy8(dst, src, len) = 0; - assert(sd->checkSane()); + assertx(sd->checkSane()); return sd; } StringData* StringData::shrink(size_t len) { - assert(!isImmutable() && !hasMultipleRefs()); + assertx(!isImmutable() && !hasMultipleRefs()); if (capacity() - len > kMinShrinkThreshold) { return shrinkImpl(len); } - assert(len < MaxSize); + assertx(len < MaxSize); setSize(len); return this; } // State transition from Mode::Shared to Mode::Flat. StringData* StringData::escalate(size_t cap) { - assert(isProxy() && !isStatic() && cap >= m_len); + assertx(isProxy() && !isStatic() && cap >= m_len); auto const sd = allocFlat(cap); sd->m_lenAndHash = m_lenAndHash; auto const sd_data = reinterpret_cast(sd + 1); *memcpy8(sd_data, data(), m_len) = 0; - assert(sd->hasExactlyOneRef()); - assert(sd->isFlat()); - assert(sd->checkSane()); + assertx(sd->hasExactlyOneRef()); + assertx(sd->isFlat()); + assertx(sd->checkSane()); return sd; } @@ -629,8 +629,8 @@ StringData* StringData::getChar(int offset) const { } StringData* StringData::increment() { - assert(!isImmutable() && !hasMultipleRefs()); - assert(!empty()); + assertx(!isImmutable() && !hasMultipleRefs()); + assertx(!empty()); auto const sd = UNLIKELY(isProxy()) ? escalate(m_len + 1) @@ -703,7 +703,7 @@ void StringData::incrementHelper() { raiseStringLengthExceededError(len + 1); } - assert(len + 1 <= capacity()); + assertx(len + 1 <= capacity()); memmove(s + 1, s, len); s[len + 1] = '\0'; m_len = len + 1; @@ -727,7 +727,7 @@ void StringData::incrementHelper() { void StringData::preCompute() { auto s = slice(); m_hash = hash_string_i_unsafe(s.data(), s.size()); - assert(m_hash >= 0); + assertx(m_hash >= 0); if (s.size() > 0 && (is_numeric_string(s.data(), s.size(), nullptr, nullptr, 1, nullptr) == KindOfNull)) { @@ -739,9 +739,9 @@ void StringData::preCompute() { defined(NO_HWCRC) || !defined(NO_M_DATA) || defined(_MSC_VER) // This function is implemented directly in ASM in string-data-*.S otherwise. NEVER_INLINE strhash_t StringData::hashHelper() const { - assert(!isProxy()); + assertx(!isProxy()); strhash_t h = hash_string_i_unsafe(data(), m_len); - assert(h >= 0); + assertx(h >= 0); m_hash |= h; return h; } @@ -767,7 +767,7 @@ DataType StringData::isNumericWithVal(int64_t &lval, double &dval, if (ret == KindOfNull && allow_errors) { // a proxy string has its hash precomputed - so it can't // suddenly go from being numeric to not-numeric - assert(!isProxy()); + assertx(!isProxy()); m_hash |= STRHASH_MSB; } } @@ -859,7 +859,7 @@ DataType StringData::toNumeric(int64_t &lval, double &dval) const { // comparisons bool StringData::equal(const StringData *s) const { - assert(s); + assertx(s); if (s == this) return true; int ret; @@ -873,7 +873,7 @@ bool StringData::equal(const StringData *s) const { } int StringData::numericCompare(const StringData *v2) const { - assert(v2); + assertx(v2); int oflow1, oflow2; int64_t lval1, lval2; @@ -899,14 +899,14 @@ int StringData::numericCompare(const StringData *v2) const { return -1; } if (ret1 == KindOfDouble) { - assert(ret2 == KindOfInt64); + assertx(ret2 == KindOfInt64); if (oflow1) { return oflow1; } dval2 = (double)lval2; } else { - assert(ret1 == KindOfInt64); - assert(ret2 == KindOfDouble); + assertx(ret1 == KindOfInt64); + assertx(ret2 == KindOfDouble); if (oflow2) { return -oflow2; } @@ -919,7 +919,7 @@ int StringData::numericCompare(const StringData *v2) const { } int StringData::compare(const StringData *v2) const { - assert(v2); + assertx(v2); if (v2 == this) return 0; @@ -947,7 +947,7 @@ StringData::substr(int start, int length /* = StringData::MaxSize */) { length = max_len; } - assert(length > 0); + assertx(length > 0); if (UNLIKELY(length == size())) { incRefCount(); return this; @@ -975,14 +975,14 @@ bool StringData::checkSane() const { static_assert(offsetof(StringData, m_len) == SD_LEN, ""); static_assert(offsetof(StringData, m_hash) == SD_HASH, ""); #endif - assert(kindIsValid()); - assert(uint32_t(size()) <= MaxSize); - assert(size() >= 0); + assertx(kindIsValid()); + assertx(uint32_t(size()) <= MaxSize); + assertx(size() >= 0); if (isImmutable()) { - assert(capacity() == 0); + assertx(capacity() == 0); } else { - assert(size() <= capacity()); - assert(capacity() <= MaxSize); + assertx(size() <= capacity()); + assertx(capacity() <= MaxSize); } // isFlat() and isProxy() both check whether m_data == payload(), // which guarantees by definition that isFlat() != isProxy() diff --git a/hphp/runtime/base/string-data.h b/hphp/runtime/base/string-data.h index d26e8856ccc..cfc45230d35 100644 --- a/hphp/runtime/base/string-data.h +++ b/hphp/runtime/base/string-data.h @@ -219,7 +219,7 @@ struct StringData final : MaybeCountable, * Reference-counting related. */ ALWAYS_INLINE void decRefAndRelease() { - assert(kindIsValid()); + assertx(kindIsValid()); if (decReleaseCheck()) release(); } diff --git a/hphp/runtime/base/string-util.cpp b/hphp/runtime/base/string-util.cpp index af6fa295279..a71a64f1f54 100644 --- a/hphp/runtime/base/string-util.cpp +++ b/hphp/runtime/base/string-util.cpp @@ -131,7 +131,7 @@ String StringUtil::Implode(const Variant& items, const String& delim, len += sitems.back().size() + lenDelim; } len -= lenDelim; // always one delimiter less than count of items - assert(sitems.size() == size); + assertx(sitems.size() == size); String s = String(len, ReserveString); char *buffer = s.mutableData(); @@ -149,7 +149,7 @@ String StringUtil::Implode(const Variant& items, const String& delim, memcpy(p, item.data(), lenItem); p += lenItem; } - assert(p - buffer == len); + assertx(p - buffer == len); s.setSize(len); return s; } @@ -206,7 +206,7 @@ String StringUtil::HtmlEncode(const String& input, const int64_t qsBitmask, const char *charset, bool dEncode, bool htmlEnt) { if (input.empty()) return input; - assert(charset); + assertx(charset); bool utf8 = true; if (strcasecmp(charset, "ISO-8859-1") == 0) { utf8 = false; @@ -248,7 +248,7 @@ String StringUtil::HtmlEncodeExtra(const String& input, QuoteStyle quoteStyle, Array extra) { if (input.empty()) return input; - assert(charset); + assertx(charset); int flags = STRING_HTML_ENCODE_UTF8; if (nbsp) { flags |= STRING_HTML_ENCODE_NBSP; @@ -312,7 +312,7 @@ String StringUtil::HtmlDecode(const String& input, QuoteStyle quoteStyle, const char *charset, bool all) { if (input.empty()) return input; - assert(charset); + assertx(charset); int len = input.size(); char *ret = string_html_decode(input.data(), len, @@ -407,7 +407,7 @@ String StringUtil::DecodeFileUrl(const String& input) { // formatting String StringUtil::MoneyFormat(const char *format, double value) { - assert(format); + assertx(format); return string_money_format(format, value); } diff --git a/hphp/runtime/base/sweepable.h b/hphp/runtime/base/sweepable.h index b3b7dbf80a6..7ab302d6602 100644 --- a/hphp/runtime/base/sweepable.h +++ b/hphp/runtime/base/sweepable.h @@ -54,7 +54,7 @@ struct Sweepable { * List manipulation methods; mainly for use by MemoryManager. */ bool empty() const { - assert((this == m_prev) == (this == m_next)); // both==this or both!=this + assertx((this == m_prev) == (this == m_next)); // both==this or both!=this return this == m_next; } void init() { m_prev = m_next = this; } diff --git a/hphp/runtime/base/temp-file.cpp b/hphp/runtime/base/temp-file.cpp index 1c0c24f4b64..2a9a2144265 100644 --- a/hphp/runtime/base/temp-file.cpp +++ b/hphp/runtime/base/temp-file.cpp @@ -70,7 +70,7 @@ bool TempFile::closeImpl() { bool ret = true; s_pcloseRet = 0; if (!isClosed()) { - assert(valid()); + assertx(valid()); s_pcloseRet = ::fclose(m_stream); ret = (s_pcloseRet == 0); setIsClosed(true); @@ -88,7 +88,7 @@ bool TempFile::closeImpl() { } bool TempFile::seek(int64_t offset, int whence /* = SEEK_SET */) { - assert(valid()); + assertx(valid()); if (whence == SEEK_CUR) { off_t result = lseek(getFd(), 0, SEEK_CUR); @@ -127,13 +127,13 @@ bool TempFile::seek(int64_t offset, int whence /* = SEEK_SET */) { } int64_t TempFile::tell() { - assert(valid()); + assertx(valid()); if (getLength() < 0) return -1; return getPosition(); } bool TempFile::truncate(int64_t size) { - assert(valid()); + assertx(valid()); seek(size, SEEK_SET); return ftruncate(getFd(), size) == 0; } diff --git a/hphp/runtime/base/thread-hooks.cpp b/hphp/runtime/base/thread-hooks.cpp index c741da3b3be..21b0c9f8c7e 100644 --- a/hphp/runtime/base/thread-hooks.cpp +++ b/hphp/runtime/base/thread-hooks.cpp @@ -93,7 +93,7 @@ void* start_routine_wrapper(void *arg) { auto& info = *reinterpret_cast(arg); info.mm = tl_heap.getCheck(); - assert(info.mm); + assertx(info.mm); info.mm->resetExternalStats(); #ifdef __linux__ info.tid = syscall(SYS_gettid); diff --git a/hphp/runtime/base/thread-info.cpp b/hphp/runtime/base/thread-info.cpp index 0dc53f29443..c2f180d95c1 100644 --- a/hphp/runtime/base/thread-info.cpp +++ b/hphp/runtime/base/thread-info.cpp @@ -60,14 +60,14 @@ __thread char* t_stackbase = nullptr; THREAD_LOCAL_NO_CHECK(ThreadInfo, ThreadInfo::s_threadInfo); ThreadInfo::ThreadInfo() { - assert(!t_stackbase); + assertx(!t_stackbase); t_stackbase = static_cast(stack_top_ptr()); m_coverage = new CodeCoverage(); } ThreadInfo::~ThreadInfo() { - assert(t_stackbase); + assertx(t_stackbase); t_stackbase = nullptr; Lock lock(s_thread_info_mutex); diff --git a/hphp/runtime/base/thrift-buffer.h b/hphp/runtime/base/thrift-buffer.h index e76462a3159..9452c645500 100644 --- a/hphp/runtime/base/thrift-buffer.h +++ b/hphp/runtime/base/thrift-buffer.h @@ -261,9 +261,9 @@ protected: private: // disabling copy constructor and assignment -ThriftBuffer(const ThriftBuffer& /*sb*/) { assert(false); } +ThriftBuffer(const ThriftBuffer& /*sb*/) { assertx(false); } ThriftBuffer& operator=(const ThriftBuffer& /*sb*/) { - assert(false); + assertx(false); return *this; } diff --git a/hphp/runtime/base/tv-arith.cpp b/hphp/runtime/base/tv-arith.cpp index 319b03848b8..d99bf946c7e 100644 --- a/hphp/runtime/base/tv-arith.cpp +++ b/hphp/runtime/base/tv-arith.cpp @@ -43,7 +43,7 @@ void throw_bad_array_operand(const ArrayData* ad) { if (ad->isVecArray()) return "vecs"; if (ad->isDict()) return "dicts"; if (ad->isKeyset()) return "keysets"; - assert(ad->isPHPArray()); + assertx(ad->isPHPArray()); return "arrays"; }(); throw ExtendedException( @@ -60,7 +60,7 @@ Cell make_dbl(double d) { return make_tv(d); } // Helper for converting String, Array, Bool, Null or Obj to Dbl|Int. // Other types (i.e. Int and Double) must be handled outside of this. TypedNum numericConvHelper(Cell cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -106,7 +106,7 @@ again: if (c2.m_type == KindOfInt64) return o(c1.m_data.num, c2.m_data.num); if (c2.m_type == KindOfDouble) return o(c1.m_data.num, c2.m_data.dbl); cellCopy(numericConvHelper(c2), c2); - assert(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); + assertx(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); } } @@ -115,7 +115,7 @@ again: if (c2.m_type == KindOfDouble) return o(c1.m_data.dbl, c2.m_data.dbl); if (c2.m_type == KindOfInt64) return o(c1.m_data.dbl, c2.m_data.num); cellCopy(numericConvHelper(c2), c2); - assert(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); + assertx(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); } } @@ -124,7 +124,7 @@ again: } cellCopy(numericConvHelper(c1), c1); - assert(c1.m_type == KindOfInt64 || c1.m_type == KindOfDouble); + assertx(c1.m_type == KindOfInt64 || c1.m_type == KindOfDouble); goto again; } @@ -217,7 +217,7 @@ struct Div { FOLLY_MSVC_DISABLE_WARNING(4723) return make_dbl([](int64_t tVal) { auto v = tVal / 0.0; - assert(std::isnan(v) || std::isinf(v)); + assertx(std::isnan(v) || std::isinf(v)); return v; }(t)); FOLLY_POP_WARNING @@ -273,7 +273,7 @@ again: return; } cellCopy(numericConvHelper(c2), c2); - assert(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); + assertx(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); } } @@ -288,7 +288,7 @@ again: return; } cellCopy(numericConvHelper(c2), c2); - assert(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); + assertx(c2.m_type == KindOfInt64 || c2.m_type == KindOfDouble); } } @@ -304,7 +304,7 @@ again: } cellSet(numericConvHelper(c1), c1); - assert(c1.m_type == KindOfInt64 || c1.m_type == KindOfDouble); + assertx(c1.m_type == KindOfInt64 || c1.m_type == KindOfDouble); goto again; } @@ -374,8 +374,8 @@ StringData* stringBitOp(BitOp bop, SzOp sop, StringData* s1, StringData* s2) { template class BitOp, class StrLenOp> Cell cellBitOp(StrLenOp strLenOp, Cell c1, Cell c2) { - assert(cellIsPlausible(c1)); - assert(cellIsPlausible(c2)); + assertx(cellIsPlausible(c1)); + assertx(cellIsPlausible(c2)); if (isStringType(c1.m_type) && isStringType(c2.m_type)) { return make_tv( @@ -402,7 +402,7 @@ void cellBitOpEq(Op op, Cell& c1, Cell c2) { // Op must implement the interface described for cellIncDecOp. template void stringIncDecOp(Op op, Cell& cell) { - assert(isStringType(cell.m_type)); + assertx(isStringType(cell.m_type)); auto const sd = cell.m_data.pstr; if (sd->empty()) { @@ -424,7 +424,7 @@ void stringIncDecOp(Op op, Cell& cell) { cellCopy(make_dbl(dval), cell); op.dblCase(cell); } else { - assert(dt == KindOfNull); + assertx(dt == KindOfNull); op.nonNumericString(cell); } } @@ -442,7 +442,7 @@ void stringIncDecOp(Op op, Cell& cell) { */ template void cellIncDecOp(Op op, Cell& cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -499,7 +499,7 @@ struct IncBase { auto const tmp = StringData::Make(sd, CopyString); auto const tmp2 = tmp->increment(); if (tmp2 != tmp) { - assert(tmp->hasExactlyOneRef()); + assertx(tmp->hasExactlyOneRef()); tmp->release(); return tmp2; } @@ -682,8 +682,8 @@ void cellSubEqO(Cell& c1, Cell c2) { cellSet(cellSubO(c1, c2), c1); } void cellMulEqO(Cell& c1, Cell c2) { cellSet(cellMulO(c1, c2), c1); } void cellDivEq(Cell& c1, Cell c2) { - assert(cellIsPlausible(c1)); - assert(cellIsPlausible(c2)); + assertx(cellIsPlausible(c1)); + assertx(cellIsPlausible(c2)); if (!isIntType(c1.m_type) && !isDoubleType(c1.m_type)) { cellSet(numericConvHelper(c1), c1); } @@ -719,7 +719,7 @@ void cellDec(Cell& cell) { cellIncDecOp(Dec(), cell); } void cellDecO(Cell& cell) { cellIncDecOp(DecO(), cell); } void cellBitNot(Cell& cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfInt64: @@ -752,7 +752,7 @@ void cellBitNot(Cell& cell) { auto const sd = cell.m_data.pstr; auto const len = sd->size(); auto const data = sd->mutableData(); - assert(sd->hasExactlyOneRef()); + assertx(sd->hasExactlyOneRef()); for (uint32_t i = 0; i < len; ++i) { data[i] = ~data[i]; } diff --git a/hphp/runtime/base/tv-comparisons.cpp b/hphp/runtime/base/tv-comparisons.cpp index 01e41dbc650..b5b10b64175 100644 --- a/hphp/runtime/base/tv-comparisons.cpp +++ b/hphp/runtime/base/tv-comparisons.cpp @@ -66,7 +66,7 @@ typename Op::RetType cellRelOp(Op op, Cell cell, bool val) { template typename Op::RetType cellRelOp(Op op, Cell cell, int64_t val) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -125,7 +125,7 @@ typename Op::RetType cellRelOp(Op op, Cell cell, int64_t val) { template typename Op::RetType cellRelOp(Op op, Cell cell, double val) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -254,9 +254,9 @@ typename Op::RetType cellRelOp(Op op, Cell cell, const StringData* val) { template typename Op::RetType cellRelOp(Op op, Cell cell, const ArrayData* ad) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); - assert(ad->isPHPArray()); + assertx(ad->isPHPArray()); auto const nonArr = [&]{ if (UNLIKELY(op.noticeOnArrNonArr())) { @@ -331,7 +331,7 @@ typename Op::RetType cellRelOp(Op op, Cell cell, const ArrayData* ad) { template typename Op::RetType cellRelOp(Op op, Cell cell, const ObjectData* od) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -393,7 +393,7 @@ typename Op::RetType cellRelOp(Op op, Cell cell, const ObjectData* od) { template typename Op::RetType cellRelOp(Op op, Cell cell, const ResourceData* rd) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -452,8 +452,8 @@ typename Op::RetType cellRelOp(Op op, Cell cell, const ResourceHdr* r) { template typename Op::RetType cellRelOpVec(Op op, Cell cell, const ArrayData* a) { - assert(cellIsPlausible(cell)); - assert(a->isVecArray()); + assertx(cellIsPlausible(cell)); + assertx(a->isVecArray()); if (UNLIKELY(!isVecType(cell.m_type))) { if (isDictType(cell.m_type)) return op.dictVsNonDict(); @@ -468,8 +468,8 @@ typename Op::RetType cellRelOpVec(Op op, Cell cell, const ArrayData* a) { template typename Op::RetType cellRelOpDict(Op op, Cell cell, const ArrayData* a) { - assert(cellIsPlausible(cell)); - assert(a->isDict()); + assertx(cellIsPlausible(cell)); + assertx(a->isDict()); if (UNLIKELY(!isDictType(cell.m_type))) { if (isVecType(cell.m_type)) return op.vecVsNonVec(); @@ -485,8 +485,8 @@ typename Op::RetType cellRelOpDict(Op op, Cell cell, const ArrayData* a) { template typename Op::RetType cellRelOpKeyset(Op op, Cell cell, const ArrayData* a) { - assert(cellIsPlausible(cell)); - assert(a->isKeyset()); + assertx(cellIsPlausible(cell)); + assertx(a->isKeyset()); if (UNLIKELY(!isKeysetType(cell.m_type))) { if (isVecType(cell.m_type)) return op.vecVsNonVec(); @@ -502,8 +502,8 @@ typename Op::RetType cellRelOpKeyset(Op op, Cell cell, const ArrayData* a) { template typename Op::RetType cellRelOp(Op op, Cell c1, Cell c2) { - assert(cellIsPlausible(c1)); - assert(cellIsPlausible(c2)); + assertx(cellIsPlausible(c1)); + assertx(cellIsPlausible(c2)); switch (c2.m_type) { case KindOfUninit: @@ -536,8 +536,8 @@ typename Op::RetType cellRelOp(Op op, Cell c1, Cell c2) { template typename Op::RetType tvRelOp(Op op, TypedValue tv1, TypedValue tv2) { - assert(tvIsPlausible(tv1)); - assert(tvIsPlausible(tv2)); + assertx(tvIsPlausible(tv1)); + assertx(tvIsPlausible(tv2)); return cellRelOp(op, *tvToCell(&tv1), *tvToCell(&tv2)); } @@ -570,14 +570,14 @@ struct Eq { } bool operator()(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isPHPArray()); - assert(ad2->isPHPArray()); + assertx(ad1->isPHPArray()); + assertx(ad2->isPHPArray()); return ArrayData::Equal(ad1, ad2); } bool operator()(const ObjectData* od1, const ObjectData* od2) const { - assert(od1); - assert(od2); + assertx(od1); + assertx(od2); return od1->equal(*od2); } @@ -589,18 +589,18 @@ struct Eq { } bool vec(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isVecArray()); - assert(ad2->isVecArray()); + assertx(ad1->isVecArray()); + assertx(ad2->isVecArray()); return PackedArray::VecEqual(ad1, ad2); } bool dict(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isDict()); - assert(ad2->isDict()); + assertx(ad1->isDict()); + assertx(ad2->isDict()); return MixedArray::DictEqual(ad1, ad2); } bool keyset(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isKeyset()); - assert(ad2->isKeyset()); + assertx(ad1->isKeyset()); + assertx(ad2->isKeyset()); return SetArray::Equal(ad1, ad2); } @@ -630,14 +630,14 @@ struct Lt { } bool operator()(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isPHPArray()); - assert(ad2->isPHPArray()); + assertx(ad1->isPHPArray()); + assertx(ad2->isPHPArray()); return ArrayData::Lt(ad1, ad2); } bool operator()(const ObjectData* od1, const ObjectData* od2) const { - assert(od1); - assert(od2); + assertx(od1); + assertx(od2); return od1->less(*od2); } @@ -649,18 +649,18 @@ struct Lt { } bool vec(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isVecArray()); - assert(ad2->isVecArray()); + assertx(ad1->isVecArray()); + assertx(ad2->isVecArray()); return PackedArray::VecLt(ad1, ad2); } bool dict(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isDict()); - assert(ad2->isDict()); + assertx(ad1->isDict()); + assertx(ad2->isDict()); throw_dict_compare_exception(); } bool keyset(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isKeyset()); - assert(ad2->isKeyset()); + assertx(ad1->isKeyset()); + assertx(ad2->isKeyset()); throw_keyset_compare_exception(); } @@ -700,14 +700,14 @@ struct Gt { } bool operator()(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isPHPArray()); - assert(ad2->isPHPArray()); + assertx(ad1->isPHPArray()); + assertx(ad2->isPHPArray()); return ArrayData::Gt(ad1, ad2); } bool operator()(const ObjectData* od1, const ObjectData* od2) const { - assert(od1); - assert(od2); + assertx(od1); + assertx(od2); return od1->more(*od2); } @@ -719,18 +719,18 @@ struct Gt { } bool vec(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isVecArray()); - assert(ad2->isVecArray()); + assertx(ad1->isVecArray()); + assertx(ad2->isVecArray()); return PackedArray::VecGt(ad1, ad2); } bool dict(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isDict()); - assert(ad2->isDict()); + assertx(ad1->isDict()); + assertx(ad2->isDict()); throw_dict_compare_exception(); } bool keyset(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isKeyset()); - assert(ad2->isKeyset()); + assertx(ad1->isKeyset()); + assertx(ad2->isKeyset()); throw_keyset_compare_exception(); } @@ -774,8 +774,8 @@ struct Cmp { } int64_t operator()(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isPHPArray()); - assert(ad2->isPHPArray()); + assertx(ad1->isPHPArray()); + assertx(ad2->isPHPArray()); return ArrayData::Compare(ad1, ad2); } @@ -791,18 +791,18 @@ struct Cmp { } int64_t vec(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isVecArray()); - assert(ad2->isVecArray()); + assertx(ad1->isVecArray()); + assertx(ad2->isVecArray()); return PackedArray::VecCmp(ad1, ad2); } int64_t dict(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isDict()); - assert(ad2->isDict()); + assertx(ad1->isDict()); + assertx(ad2->isDict()); throw_dict_compare_exception(); } int64_t keyset(const ArrayData* ad1, const ArrayData* ad2) const { - assert(ad1->isKeyset()); - assert(ad2->isKeyset()); + assertx(ad1->isKeyset()); + assertx(ad2->isKeyset()); throw_keyset_compare_exception(); } @@ -832,8 +832,8 @@ struct Cmp { } bool cellSame(Cell c1, Cell c2) { - assert(cellIsPlausible(c1)); - assert(cellIsPlausible(c2)); + assertx(cellIsPlausible(c1)); + assertx(cellIsPlausible(c2)); bool const null1 = isNullType(c1.m_type); bool const null2 = isNullType(c2.m_type); @@ -912,8 +912,8 @@ bool cellSame(Cell c1, Cell c2) { } bool tvSame(TypedValue tv1, TypedValue tv2) { - assert(tvIsPlausible(tv1)); - assert(tvIsPlausible(tv2)); + assertx(tvIsPlausible(tv1)); + assertx(tvIsPlausible(tv2)); return cellSame(*tvToCell(&tv1), *tvToCell(&tv2)); } @@ -1096,8 +1096,8 @@ int64_t tvCompare(TypedValue tv1, TypedValue tv2) { ////////////////////////////////////////////////////////////////////// bool cellLessOrEqual(Cell c1, Cell c2) { - assert(cellIsPlausible(c1)); - assert(cellIsPlausible(c2)); + assertx(cellIsPlausible(c1)); + assertx(cellIsPlausible(c2)); if ((isArrayLikeType(c1.m_type) && isArrayLikeType(c2.m_type)) || (c1.m_type == KindOfObject && c2.m_type == KindOfObject) || @@ -1115,8 +1115,8 @@ bool cellLessOrEqual(Cell c1, Cell c2) { } bool cellGreaterOrEqual(Cell c1, Cell c2) { - assert(cellIsPlausible(c1)); - assert(cellIsPlausible(c2)); + assertx(cellIsPlausible(c1)); + assertx(cellIsPlausible(c2)); if ((isArrayLikeType(c1.m_type) && isArrayLikeType(c2.m_type)) || (c1.m_type == KindOfObject && c2.m_type == KindOfObject) || diff --git a/hphp/runtime/base/tv-conversions-inl.h b/hphp/runtime/base/tv-conversions-inl.h index aee8b24bb86..b289d0dbc7d 100644 --- a/hphp/runtime/base/tv-conversions-inl.h +++ b/hphp/runtime/base/tv-conversions-inl.h @@ -32,7 +32,7 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// inline bool cellToBool(Cell cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: @@ -58,7 +58,7 @@ inline bool cellToBool(Cell cell) { } inline int64_t cellToInt(Cell cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); switch (cell.m_type) { case KindOfUninit: diff --git a/hphp/runtime/base/tv-conversions.cpp b/hphp/runtime/base/tv-conversions.cpp index ce24c984468..120c93087c8 100644 --- a/hphp/runtime/base/tv-conversions.cpp +++ b/hphp/runtime/base/tv-conversions.cpp @@ -51,7 +51,7 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// void tvCastToBooleanInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); bool b; @@ -118,7 +118,7 @@ void tvCastToBooleanInPlace(TypedValue* tv) { } bool tvCastToBoolean(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (tv.m_type == KindOfRef) { tv = *tv.m_data.pref->tv(); } @@ -126,7 +126,7 @@ bool tvCastToBoolean(TypedValue tv) { } void tvCastToDoubleInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); double d; @@ -138,7 +138,7 @@ void tvCastToDoubleInPlace(TypedValue* tv) { continue; case KindOfBoolean: - assert(tv->m_data.num == 0LL || tv->m_data.num == 1LL); + assertx(tv->m_data.num == 0LL || tv->m_data.num == 1LL); // fallthru case KindOfInt64: d = (double)(tv->m_data.num); @@ -192,10 +192,10 @@ void tvCastToDoubleInPlace(TypedValue* tv) { } void tvCastToInt64InPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); int64_t i; do { @@ -205,7 +205,7 @@ void tvCastToInt64InPlace(TypedValue* tv) { tv->m_data.num = 0LL; // fallthru case KindOfBoolean: - assert(tv->m_data.num == 0LL || tv->m_data.num == 1LL); + assertx(tv->m_data.num == 0LL || tv->m_data.num == 1LL); tv->m_type = KindOfInt64; // fallthru case KindOfInt64: @@ -260,7 +260,7 @@ void tvCastToInt64InPlace(TypedValue* tv) { } int64_t tvCastToInt64(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (tv.m_type == KindOfRef) { tv = *tv.m_data.pref->tv(); } @@ -268,7 +268,7 @@ int64_t tvCastToInt64(TypedValue tv) { } double tvCastToDouble(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (tv.m_type == KindOfRef) { tv = *tv.m_data.pref->tv(); } @@ -279,7 +279,7 @@ double tvCastToDouble(TypedValue tv) { return 0; case KindOfBoolean: - assert(tv.m_data.num == 0LL || tv.m_data.num == 1LL); + assertx(tv.m_data.num == 0LL || tv.m_data.num == 1LL); // fallthru case KindOfInt64: return (double)(tv.m_data.num); @@ -318,7 +318,7 @@ const StaticString s_scalar("scalar"); void tvCastToStringInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); auto string = [&](StringData* s) { @@ -326,7 +326,7 @@ void tvCastToStringInPlace(TypedValue* tv) { tv->m_data.pstr = s; }; auto persistentString = [&](StringData* s) { - assert(!s->isRefCounted()); + assertx(!s->isRefCounted()); tv->m_type = KindOfPersistentString; tv->m_data.pstr = s; }; @@ -390,7 +390,7 @@ void tvCastToStringInPlace(TypedValue* tv) { } StringData* tvCastToStringData(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (tv.m_type == KindOfRef) { tv = *tv.m_data.pref->tv(); } @@ -455,7 +455,7 @@ String tvCastToString(TypedValue tv) { } ArrayData* tvCastToArrayLikeData(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (tv.m_type == KindOfRef) { tv = *tv.m_data.pref->tv(); } @@ -503,7 +503,7 @@ Array tvCastToArrayLike(TypedValue tv) { } void tvCastToArrayInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ArrayData* a; @@ -528,15 +528,15 @@ void tvCastToArrayInPlace(TypedValue* tv) { case KindOfPersistentVec: { auto* adIn = tv->m_data.parr; - assert(adIn->isVecArray()); + assertx(adIn->isVecArray()); a = PackedArray::ToPHPArrayVec(adIn, true); - assert(a != adIn); + assertx(a != adIn); continue; } case KindOfVec: { auto* adIn = tv->m_data.parr; - assert(adIn->isVecArray()); + assertx(adIn->isVecArray()); a = PackedArray::ToPHPArrayVec(adIn, adIn->cowCheck()); if (a != adIn) tvDecRefArr(tv); continue; @@ -544,15 +544,15 @@ void tvCastToArrayInPlace(TypedValue* tv) { case KindOfPersistentDict: { auto* adIn = tv->m_data.parr; - assert(adIn->isDict()); + assertx(adIn->isDict()); a = MixedArray::ToPHPArrayDict(adIn, true); - assert(a != adIn); + assertx(a != adIn); continue; } case KindOfDict: { auto* adIn = tv->m_data.parr; - assert(adIn->isDict()); + assertx(adIn->isDict()); a = MixedArray::ToPHPArrayDict(adIn, adIn->cowCheck()); if (a != adIn) tvDecRefArr(tv); continue; @@ -560,15 +560,15 @@ void tvCastToArrayInPlace(TypedValue* tv) { case KindOfPersistentKeyset: { auto* adIn = tv->m_data.parr; - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); a = SetArray::ToPHPArray(adIn, true); - assert(a != adIn); + assertx(a != adIn); continue; } case KindOfKeyset: { auto* adIn = tv->m_data.parr; - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); a = SetArray::ToPHPArray(adIn, adIn->cowCheck()); if (a != adIn) tvDecRefArr(tv); continue; @@ -576,16 +576,16 @@ void tvCastToArrayInPlace(TypedValue* tv) { case KindOfPersistentArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); if (adIn->isNotDVArray()) return; a = adIn->toPHPArray(true); - assert(a != adIn); + assertx(a != adIn); continue; } case KindOfArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); if (adIn->isNotDVArray()) return; a = adIn->toPHPArray(adIn->cowCheck()); if (a != adIn) tvDecRefArr(tv); @@ -608,16 +608,16 @@ void tvCastToArrayInPlace(TypedValue* tv) { not_reached(); } while (0); - assert(a->isPHPArray()); - assert(a->isNotDVArray()); + assertx(a->isPHPArray()); + assertx(a->isNotDVArray()); tv->m_data.parr = a; tv->m_type = KindOfArray; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } void tvCastToVecInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ArrayData* a; @@ -658,9 +658,9 @@ void tvCastToVecInPlace(TypedValue* tv) { case KindOfPersistentDict: case KindOfDict: { auto* adIn = tv->m_data.parr; - assert(adIn->isDict()); + assertx(adIn->isDict()); a = MixedArray::ToVecDict(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -668,9 +668,9 @@ void tvCastToVecInPlace(TypedValue* tv) { case KindOfPersistentKeyset: case KindOfKeyset: { auto* adIn = tv->m_data.parr; - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); a = SetArray::ToVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -678,7 +678,7 @@ void tvCastToVecInPlace(TypedValue* tv) { case KindOfPersistentArray: case KindOfArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); a = adIn->toVec(adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -686,7 +686,7 @@ void tvCastToVecInPlace(TypedValue* tv) { case KindOfPersistentVec: case KindOfVec: - assert(tv->m_data.parr->isVecArray()); + assertx(tv->m_data.parr->isVecArray()); return; case KindOfObject: @@ -703,11 +703,11 @@ void tvCastToVecInPlace(TypedValue* tv) { tv->m_data.parr = a; tv->m_type = KindOfVec; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } void tvCastToDictInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ArrayData* a; @@ -748,9 +748,9 @@ void tvCastToDictInPlace(TypedValue* tv) { case KindOfPersistentVec: case KindOfVec: { auto* adIn = tv->m_data.parr; - assert(adIn->isVecArray()); + assertx(adIn->isVecArray()); a = PackedArray::ToDictVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -758,7 +758,7 @@ void tvCastToDictInPlace(TypedValue* tv) { case KindOfPersistentKeyset: case KindOfKeyset: { auto* adIn = tv->m_data.parr; - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); a = SetArray::ToDict(adIn, adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -767,7 +767,7 @@ void tvCastToDictInPlace(TypedValue* tv) { case KindOfPersistentArray: case KindOfArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); a = adIn->toDict(adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -775,7 +775,7 @@ void tvCastToDictInPlace(TypedValue* tv) { case KindOfPersistentDict: case KindOfDict: - assert(tv->m_data.parr->isDict()); + assertx(tv->m_data.parr->isDict()); return; case KindOfObject: @@ -792,11 +792,11 @@ void tvCastToDictInPlace(TypedValue* tv) { tv->m_data.parr = a; tv->m_type = KindOfDict; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } void tvCastToKeysetInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ArrayData* a; @@ -837,9 +837,9 @@ void tvCastToKeysetInPlace(TypedValue* tv) { case KindOfPersistentVec: case KindOfVec: { auto* adIn = tv->m_data.parr; - assert(adIn->isVecArray()); + assertx(adIn->isVecArray()); a = PackedArray::ToKeysetVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -847,7 +847,7 @@ void tvCastToKeysetInPlace(TypedValue* tv) { case KindOfPersistentDict: case KindOfDict: { auto* adIn = tv->m_data.parr; - assert(adIn->isDict()); + assertx(adIn->isDict()); a = MixedArray::ToKeysetDict(adIn, adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -856,7 +856,7 @@ void tvCastToKeysetInPlace(TypedValue* tv) { case KindOfPersistentArray: case KindOfArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); a = adIn->toKeyset(adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -864,7 +864,7 @@ void tvCastToKeysetInPlace(TypedValue* tv) { case KindOfPersistentKeyset: case KindOfKeyset: - assert(tv->m_data.parr->isKeyset()); + assertx(tv->m_data.parr->isKeyset()); return; case KindOfObject: @@ -881,12 +881,12 @@ void tvCastToKeysetInPlace(TypedValue* tv) { tv->m_data.parr = a; tv->m_type = KindOfKeyset; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } void tvCastToVArrayInPlace(TypedValue* tv) { - assert(!RuntimeOption::EvalHackArrDVArrs); - assert(tvIsPlausible(*tv)); + assertx(!RuntimeOption::EvalHackArrDVArrs); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ArrayData* a; @@ -927,7 +927,7 @@ void tvCastToVArrayInPlace(TypedValue* tv) { case KindOfPersistentVec: case KindOfVec: { auto* adIn = tv->m_data.parr; - assert(adIn->isVecArray()); + assertx(adIn->isVecArray()); a = PackedArray::ToVArrayVec(adIn, adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -936,9 +936,9 @@ void tvCastToVArrayInPlace(TypedValue* tv) { case KindOfPersistentDict: case KindOfDict: { auto* adIn = tv->m_data.parr; - assert(adIn->isDict()); + assertx(adIn->isDict()); a = MixedArray::ToVArrayDict(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -946,9 +946,9 @@ void tvCastToVArrayInPlace(TypedValue* tv) { case KindOfPersistentKeyset: case KindOfKeyset: { auto* adIn = tv->m_data.parr; - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); a = SetArray::ToVArray(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -956,11 +956,11 @@ void tvCastToVArrayInPlace(TypedValue* tv) { case KindOfPersistentArray: case KindOfArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); if (adIn->isVArray()) return; a = adIn->toVArray(adIn->cowCheck()); - assert(a->isPacked()); - assert(a->isVArray()); + assertx(a->isPacked()); + assertx(a->isVArray()); if (a == adIn) return; decRefArr(adIn); continue; @@ -978,17 +978,17 @@ void tvCastToVArrayInPlace(TypedValue* tv) { not_reached(); } while (0); - assert(a->isPacked()); - assert(a->isVArray()); + assertx(a->isPacked()); + assertx(a->isVArray()); tv->m_data.parr = a; tv->m_type = KindOfArray; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } void tvCastToDArrayInPlace(TypedValue* tv) { - assert(!RuntimeOption::EvalHackArrDVArrs); - assert(tvIsPlausible(*tv)); + assertx(!RuntimeOption::EvalHackArrDVArrs); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ArrayData* a; @@ -1029,9 +1029,9 @@ void tvCastToDArrayInPlace(TypedValue* tv) { case KindOfPersistentVec: case KindOfVec: { auto* adIn = tv->m_data.parr; - assert(adIn->isVecArray()); + assertx(adIn->isVecArray()); a = PackedArray::ToDArrayVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -1039,7 +1039,7 @@ void tvCastToDArrayInPlace(TypedValue* tv) { case KindOfPersistentDict: case KindOfDict: { auto* adIn = tv->m_data.parr; - assert(adIn->isDict()); + assertx(adIn->isDict()); a = MixedArray::ToDArrayDict(adIn, adIn->cowCheck()); if (a != adIn) decRefArr(adIn); continue; @@ -1048,9 +1048,9 @@ void tvCastToDArrayInPlace(TypedValue* tv) { case KindOfPersistentKeyset: case KindOfKeyset: { auto* adIn = tv->m_data.parr; - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); a = SetArray::ToDArray(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); continue; } @@ -1058,11 +1058,11 @@ void tvCastToDArrayInPlace(TypedValue* tv) { case KindOfPersistentArray: case KindOfArray: { auto* adIn = tv->m_data.parr; - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); if (adIn->isDArray()) return; a = adIn->toDArray(adIn->cowCheck()); - assert(a->isMixed()); - assert(a->isDArray()); + assertx(a->isMixed()); + assertx(a->isDArray()); if (a == adIn) return; decRefArr(adIn); continue; @@ -1080,16 +1080,16 @@ void tvCastToDArrayInPlace(TypedValue* tv) { not_reached(); } while (0); - assert(a->isMixed()); - assert(a->isDArray()); + assertx(a->isMixed()); + assertx(a->isDArray()); tv->m_data.parr = a; tv->m_type = KindOfArray; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } ObjectData* tvCastToObjectData(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (tv.m_type == KindOfRef) { tv = *tv.m_data.pref->tv(); } @@ -1139,7 +1139,7 @@ Object tvCastToObject(TypedValue tv) { } void tvCastToObjectInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); ObjectData* o; @@ -1194,7 +1194,7 @@ void tvCastToObjectInPlace(TypedValue* tv) { tv->m_data.pobj = o; tv->m_type = KindOfObject; - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } void tvCastToNullableObjectInPlace(TypedValue* tv) { @@ -1212,7 +1212,7 @@ void tvCastToNullableObjectInPlace(TypedValue* tv) { } void tvCastToResourceInPlace(TypedValue* tv) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); do { @@ -1238,12 +1238,12 @@ void tvCastToResourceInPlace(TypedValue* tv) { tv->m_type = KindOfResource; tv->m_data.pres = req::make().detach()->hdr(); - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); } bool tvCoerceParamToBooleanInPlace(TypedValue* tv, bool builtin) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); switch (tv->m_type) { @@ -1331,7 +1331,7 @@ static bool tvCanBeCoercedToNumber(const TypedValue* tv, bool tvCoerceParamToInt64InPlace(TypedValue* tv, bool builtin) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); if (!tvCanBeCoercedToNumber(tv, builtin)) { return false; @@ -1349,7 +1349,7 @@ bool tvCoerceParamToInt64InPlace(TypedValue* tv, bool tvCoerceParamToDoubleInPlace(TypedValue* tv, bool builtin) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); if (!tvCanBeCoercedToNumber(tv, builtin)) { return false; @@ -1360,7 +1360,7 @@ bool tvCoerceParamToDoubleInPlace(TypedValue* tv, bool tvCoerceParamToStringInPlace(TypedValue* tv, bool builtin) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); switch (tv->m_type) { @@ -1407,7 +1407,7 @@ bool tvCoerceParamToStringInPlace(TypedValue* tv, } bool tvCoerceParamToArrayInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); switch (tv->m_type) { @@ -1446,7 +1446,7 @@ bool tvCoerceParamToArrayInPlace(TypedValue* tv, bool /*builtin*/) { } bool tvCoerceParamToVecInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); switch (tv->m_type) { @@ -1478,7 +1478,7 @@ bool tvCoerceParamToVecInPlace(TypedValue* tv, bool /*builtin*/) { } bool tvCoerceParamToDictInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); switch (tv->m_type) { @@ -1510,7 +1510,7 @@ bool tvCoerceParamToDictInPlace(TypedValue* tv, bool /*builtin*/) { } bool tvCoerceParamToKeysetInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); switch (tv->m_type) { @@ -1542,13 +1542,13 @@ bool tvCoerceParamToKeysetInPlace(TypedValue* tv, bool /*builtin*/) { } bool tvCoerceParamToObjectInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); return tv->m_type == KindOfObject; } bool tvCoerceParamToNullableObjectInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); if (isNullType(tv->m_type)) { // See comment in tvCastToNullableObjectInPlace @@ -1559,7 +1559,7 @@ bool tvCoerceParamToNullableObjectInPlace(TypedValue* tv, bool /*builtin*/) { } bool tvCoerceParamToResourceInPlace(TypedValue* tv, bool /*builtin*/) { - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); tvUnboxIfNeeded(*tv); return tv->m_type == KindOfResource; } diff --git a/hphp/runtime/base/tv-helpers.cpp b/hphp/runtime/base/tv-helpers.cpp index ccd08a8d061..c11d4c96dbc 100644 --- a/hphp/runtime/base/tv-helpers.cpp +++ b/hphp/runtime/base/tv-helpers.cpp @@ -29,10 +29,10 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// bool cellIsPlausible(const Cell cell) { - assert(cell.m_type != KindOfRef); + assertx(cell.m_type != KindOfRef); auto assertPtr = [](void* ptr) { - assert(ptr && (uintptr_t(ptr) % sizeof(ptr) == 0)); + assertx(ptr && (uintptr_t(ptr) % sizeof(ptr) == 0)); }; [&] { @@ -41,83 +41,83 @@ bool cellIsPlausible(const Cell cell) { case KindOfNull: return; case KindOfBoolean: - assert(cell.m_data.num == 0 || cell.m_data.num == 1); + assertx(cell.m_data.num == 0 || cell.m_data.num == 1); return; case KindOfInt64: case KindOfDouble: return; case KindOfPersistentString: assertPtr(cell.m_data.pstr); - assert(cell.m_data.pstr->kindIsValid()); - assert(!cell.m_data.pstr->isRefCounted()); + assertx(cell.m_data.pstr->kindIsValid()); + assertx(!cell.m_data.pstr->isRefCounted()); return; case KindOfString: assertPtr(cell.m_data.pstr); - assert(cell.m_data.pstr->kindIsValid()); - assert(cell.m_data.pstr->checkCount()); + assertx(cell.m_data.pstr->kindIsValid()); + assertx(cell.m_data.pstr->checkCount()); return; case KindOfPersistentVec: assertPtr(cell.m_data.parr); - assert(!cell.m_data.parr->isRefCounted()); - assert(cell.m_data.parr->isVecArray()); - assert(cell.m_data.parr->isNotDVArray()); + assertx(!cell.m_data.parr->isRefCounted()); + assertx(cell.m_data.parr->isVecArray()); + assertx(cell.m_data.parr->isNotDVArray()); return; case KindOfVec: assertPtr(cell.m_data.parr); - assert(cell.m_data.parr->checkCount()); - assert(cell.m_data.parr->isVecArray()); - assert(cell.m_data.parr->isNotDVArray()); + assertx(cell.m_data.parr->checkCount()); + assertx(cell.m_data.parr->isVecArray()); + assertx(cell.m_data.parr->isNotDVArray()); return; case KindOfPersistentDict: assertPtr(cell.m_data.parr); - assert(!cell.m_data.parr->isRefCounted()); - assert(cell.m_data.parr->isDict()); - assert(cell.m_data.parr->isNotDVArray()); + assertx(!cell.m_data.parr->isRefCounted()); + assertx(cell.m_data.parr->isDict()); + assertx(cell.m_data.parr->isNotDVArray()); return; case KindOfDict: assertPtr(cell.m_data.parr); - assert(cell.m_data.parr->checkCount()); - assert(cell.m_data.parr->isDict()); - assert(cell.m_data.parr->isNotDVArray()); + assertx(cell.m_data.parr->checkCount()); + assertx(cell.m_data.parr->isDict()); + assertx(cell.m_data.parr->isNotDVArray()); return; case KindOfPersistentKeyset: assertPtr(cell.m_data.parr); - assert(!cell.m_data.parr->isRefCounted()); - assert(cell.m_data.parr->isKeyset()); - assert(cell.m_data.parr->isNotDVArray()); + assertx(!cell.m_data.parr->isRefCounted()); + assertx(cell.m_data.parr->isKeyset()); + assertx(cell.m_data.parr->isNotDVArray()); return; case KindOfKeyset: assertPtr(cell.m_data.parr); - assert(cell.m_data.parr->checkCount()); - assert(cell.m_data.parr->isKeyset()); - assert(cell.m_data.parr->isNotDVArray()); + assertx(cell.m_data.parr->checkCount()); + assertx(cell.m_data.parr->isKeyset()); + assertx(cell.m_data.parr->isNotDVArray()); return; case KindOfPersistentArray: assertPtr(cell.m_data.parr); - assert(cell.m_data.parr->kindIsValid()); - assert(!cell.m_data.parr->isRefCounted()); - assert(cell.m_data.parr->isPHPArray()); - assert(cell.m_data.parr->dvArraySanityCheck()); + assertx(cell.m_data.parr->kindIsValid()); + assertx(!cell.m_data.parr->isRefCounted()); + assertx(cell.m_data.parr->isPHPArray()); + assertx(cell.m_data.parr->dvArraySanityCheck()); return; case KindOfArray: assertPtr(cell.m_data.parr); - assert(cell.m_data.parr->kindIsValid()); - assert(cell.m_data.parr->checkCount()); - assert(cell.m_data.parr->isPHPArray()); - assert(cell.m_data.parr->dvArraySanityCheck()); + assertx(cell.m_data.parr->kindIsValid()); + assertx(cell.m_data.parr->checkCount()); + assertx(cell.m_data.parr->isPHPArray()); + assertx(cell.m_data.parr->dvArraySanityCheck()); return; case KindOfObject: assertPtr(cell.m_data.pobj); - assert(cell.m_data.pobj->kindIsValid()); - assert(cell.m_data.pobj->checkCount()); + assertx(cell.m_data.pobj->kindIsValid()); + assertx(cell.m_data.pobj->checkCount()); return; case KindOfResource: assertPtr(cell.m_data.pres); - assert(cell.m_data.pres->kindIsValid()); - assert(cell.m_data.pres->checkCount()); + assertx(cell.m_data.pres->kindIsValid()); + assertx(cell.m_data.pres->checkCount()); return; case KindOfRef: - assert(!"KindOfRef found in a Cell"); + assertx(!"KindOfRef found in a Cell"); break; } not_reached(); @@ -128,17 +128,17 @@ bool cellIsPlausible(const Cell cell) { bool tvIsPlausible(TypedValue tv) { if (tv.m_type == KindOfRef) { - assert(tv.m_data.pref); - assert(uintptr_t(tv.m_data.pref) % sizeof(void*) == 0); - assert(tv.m_data.pref->kindIsValid()); - assert(tv.m_data.pref->checkCount()); + assertx(tv.m_data.pref); + assertx(uintptr_t(tv.m_data.pref) % sizeof(void*) == 0); + assertx(tv.m_data.pref->kindIsValid()); + assertx(tv.m_data.pref->checkCount()); tv = *tv.m_data.pref->tv(); } return cellIsPlausible(tv); } bool refIsPlausible(const Ref ref) { - assert(ref.m_type == KindOfRef); + assertx(ref.m_type == KindOfRef); return tvIsPlausible(ref); } diff --git a/hphp/runtime/base/tv-mutate.h b/hphp/runtime/base/tv-mutate.h index e7aa9101e56..6438d560b4a 100644 --- a/hphp/runtime/base/tv-mutate.h +++ b/hphp/runtime/base/tv-mutate.h @@ -38,7 +38,7 @@ namespace HPHP { */ template ALWAYS_INLINE enable_if_lval_t tvBox(T&& tv) { - assert(cellIsPlausible(as_tv(tv))); + assertx(cellIsPlausible(as_tv(tv))); val(tv).pref = RefData::Make(as_tv(tv)); type(tv) = KindOfRef; } @@ -58,18 +58,18 @@ enable_if_lval_t tvBoxIfNeeded(T&& tv) { */ template ALWAYS_INLINE enable_if_lval_t tvUnbox(T&& tv) { - assert(refIsPlausible(as_tv(tv))); + assertx(refIsPlausible(as_tv(tv))); auto const r = val(tv).pref; auto const inner = r->tv(); - assert(cellIsPlausible(*inner)); + assertx(cellIsPlausible(*inner)); val(tv).num = inner->m_data.num; type(tv) = inner->m_type; tvIncRefGen(as_tv(tv)); decRefRef(r); - assert(tvIsPlausible(as_tv(tv))); + assertx(tvIsPlausible(as_tv(tv))); } /* @@ -130,15 +130,15 @@ ALWAYS_INLINE Cell tvToInitCell(TypedValue tv) { * Assert that `tv' is a Cell; then just return it. */ ALWAYS_INLINE Cell tvAssertCell(TypedValue tv) { - assert(cellIsPlausible(tv)); + assertx(cellIsPlausible(tv)); return tv; } ALWAYS_INLINE Cell* tvAssertCell(TypedValue* tv) { - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); return tv; } ALWAYS_INLINE const Cell* tvAssertCell(const TypedValue* tv) { - assert(cellIsPlausible(*tv)); + assertx(cellIsPlausible(*tv)); return tv; } @@ -163,7 +163,7 @@ ALWAYS_INLINE const Cell* tvAssertCell(const TypedValue* tv) { */ template ALWAYS_INLINE enable_if_lval_t tvCopy(const TypedValue& fr, T&& to) { - assert(tvIsPlausible(fr)); + assertx(tvIsPlausible(fr)); val(to).num = fr.m_data.num; type(to) = fr.m_type; } @@ -173,12 +173,12 @@ enable_if_lval_t tvCopy(const TypedValue& fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t cellCopy(const Cell fr, C&& to) { - assert(cellIsPlausible(fr)); + assertx(cellIsPlausible(fr)); tvCopy(fr, to); } template ALWAYS_INLINE enable_if_lval_t refCopy(const Ref fr, R&& to) { - assert(refIsPlausible(fr)); + assertx(refIsPlausible(fr)); tvCopy(fr, to); } @@ -199,13 +199,13 @@ enable_if_lval_t tvDup(const TypedValue& fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t cellDup(const Cell fr, C&& to) { - assert(cellIsPlausible(fr)); + assertx(cellIsPlausible(fr)); tvCopy(fr, to); tvIncRefGen(as_tv(to)); } template ALWAYS_INLINE enable_if_lval_t refDup(const Ref fr, R&& to) { - assert(refIsPlausible(fr)); + assertx(refIsPlausible(fr)); type(to) = KindOfRef; val(to).pref = fr.m_data.pref; val(to).pref->incRefCount(); @@ -219,7 +219,7 @@ namespace detail { template enable_if_lval_t tvDupWithRef(const TypedValue& fr, T&& to, Fn should_demote) { - assert(tvIsPlausible(fr)); + assertx(tvIsPlausible(fr)); tvCopy(fr, to); if (!isRefcountedType(fr.m_type)) return; @@ -232,7 +232,7 @@ tvDupWithRef(const TypedValue& fr, T&& to, Fn should_demote) { cellDup(*ref->tv(), to); return; } - assert(type(to) == KindOfRef); + assertx(type(to) == KindOfRef); val(to).pref->incRefCount(); } @@ -264,7 +264,7 @@ tvDupWithRef(const TypedValue& fr, T&& to) { template ALWAYS_INLINE enable_if_lval_t tvDupWithRef(const TypedValue& fr, T&& to, const ArrayData* container) { - assert(container); + assertx(container); detail::tvDupWithRef(fr, to, [&] (RefData* ref) { return !ref->isReferenced() && (!isArrayType(ref->tv()->m_type) || @@ -315,7 +315,7 @@ enable_if_lval_t tvWriteNull(T&& to) { */ template ALWAYS_INLINE enable_if_lval_t tvMove(const Cell fr, T&& to) { - assert(cellIsPlausible(fr)); + assertx(cellIsPlausible(fr)); auto&& cell = tvToCell(to); auto const old = as_tv(cell); cellCopy(fr, cell); @@ -330,7 +330,7 @@ enable_if_lval_t tvMove(const Cell fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t tvMoveIgnoreRef(const Cell fr, T&& to) { - assert(cellIsPlausible(fr)); + assertx(cellIsPlausible(fr)); auto const old = as_tv(to); cellCopy(fr, to); tvDecRefGen(old); @@ -347,8 +347,8 @@ enable_if_lval_t tvMoveIgnoreRef(const Cell fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t cellMove(const Cell fr, C&& to) { - assert(cellIsPlausible(fr)); - assert(cellIsPlausible(as_tv(to))); + assertx(cellIsPlausible(fr)); + assertx(cellIsPlausible(as_tv(to))); tvMoveIgnoreRef(fr, to); } @@ -361,7 +361,7 @@ enable_if_lval_t cellMove(const Cell fr, C&& to) { */ template ALWAYS_INLINE enable_if_lval_t tvSet(const Cell fr, T&& to) { - assert(cellIsPlausible(fr)); + assertx(cellIsPlausible(fr)); auto&& cell = tvToCell(to); auto const old = as_tv(cell); cellDup(fr, cell); @@ -377,7 +377,7 @@ enable_if_lval_t tvSet(const Cell fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t tvSetIgnoreRef(const Cell fr, T&& to) { - assert(cellIsPlausible(fr)); + assertx(cellIsPlausible(fr)); auto const old = as_tv(to); cellDup(fr, to); tvDecRefGen(old); @@ -395,8 +395,8 @@ enable_if_lval_t tvSetIgnoreRef(const Cell fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t cellSet(const Cell fr, C&& to) { - assert(cellIsPlausible(fr)); - assert(cellIsPlausible(as_tv(to))); + assertx(cellIsPlausible(fr)); + assertx(cellIsPlausible(as_tv(to))); tvSetIgnoreRef(fr, to); } @@ -409,11 +409,11 @@ enable_if_lval_t cellSet(const Cell fr, C&& to) { */ template ALWAYS_INLINE enable_if_lval_t tvSetWithRef(const TypedValue fr, T&& to) { - assert(tvIsPlausible(as_tv(to))); + assertx(tvIsPlausible(as_tv(to))); auto const old = as_tv(to); tvDupWithRef(fr, to); tvDecRefGen(old); - assert(tvIsPlausible(as_tv(to))); + assertx(tvIsPlausible(as_tv(to))); } /* @@ -428,7 +428,7 @@ enable_if_lval_t tvSetWithRef(const TypedValue fr, T&& to) { */ template ALWAYS_INLINE enable_if_lval_t tvBind(const TypedValue fr, T&& to) { - assert(fr.m_type == KindOfRef); + assertx(fr.m_type == KindOfRef); auto const old = as_tv(to); refDup(fr, to); tvDecRefGen(old); @@ -531,7 +531,7 @@ ALWAYS_INLINE TypedValue make_array_like_tv(ArrayData* a) { TypedValue ret; ret.m_data.parr = a; ret.m_type = a->toDataType(); - assert(cellIsPlausible(ret)); + assertx(cellIsPlausible(ret)); return ret; } @@ -539,7 +539,7 @@ ALWAYS_INLINE TypedValue make_persistent_array_like_tv(ArrayData* a) { TypedValue ret; ret.m_data.parr = a; ret.m_type = a->toPersistentDataType(); - assert(cellIsPlausible(ret)); + assertx(cellIsPlausible(ret)); return ret; } diff --git a/hphp/runtime/base/tv-refcount.h b/hphp/runtime/base/tv-refcount.h index 333eaaa2dd5..6926e056fac 100644 --- a/hphp/runtime/base/tv-refcount.h +++ b/hphp/runtime/base/tv-refcount.h @@ -70,7 +70,7 @@ ALWAYS_INLINE bool tvDecRefWillRelease(TypedValue tv) { * @requires: isRefcountedType(tv->m_type) */ ALWAYS_INLINE RefCount tvGetCount(TypedValue tv) { - assert(isRefcountedType(tv.m_type)); + assertx(isRefcountedType(tv.m_type)); return tv.m_data.pcnt->count(); } @@ -132,7 +132,7 @@ ALWAYS_INLINE void tvDecRefGenUnlikely(TypedValue tv) { * Decref `tv' without releasing it, if it's refcounted. */ ALWAYS_INLINE void tvDecRefGenNZ(TypedValue tv) { - assert(!tvDecRefWillCallHelper(tv)); + assertx(!tvDecRefWillCallHelper(tv)); if (noop_decref) return; if (isRefcountedType(tv.m_type)) { tv.m_data.pcnt->decRefCount(); @@ -146,12 +146,12 @@ ALWAYS_INLINE void tvDecRefGenNZ(const TypedValue* tv) { * DecRefs for TypedValues of known type. */ ALWAYS_INLINE void tvDecRefStr(const TypedValue* tv) { - assert(tv->m_type == KindOfString); + assertx(tv->m_type == KindOfString); decRefStr(tv->m_data.pstr); } ALWAYS_INLINE void tvDecRefArr(const TypedValue* tv) { - assert(tv->m_type == KindOfArray || + assertx(tv->m_type == KindOfArray || tv->m_type == KindOfVec || tv->m_type == KindOfDict || tv->m_type == KindOfKeyset); @@ -159,17 +159,17 @@ ALWAYS_INLINE void tvDecRefArr(const TypedValue* tv) { } ALWAYS_INLINE void tvDecRefObj(const TypedValue* tv) { - assert(tv->m_type == KindOfObject); + assertx(tv->m_type == KindOfObject); decRefObj(tv->m_data.pobj); } ALWAYS_INLINE void tvDecRefRes(const TypedValue* tv) { - assert(tv->m_type == KindOfResource); + assertx(tv->m_type == KindOfResource); decRefRes(tv->m_data.pres); } ALWAYS_INLINE void tvDecRefRef(const TypedValue* tv) { - assert(tv->m_type == KindOfRef); + assertx(tv->m_type == KindOfRef); decRefRef(tv->m_data.pref); } @@ -181,8 +181,8 @@ ALWAYS_INLINE void tvDecRefRef(const TypedValue* tv) { * @requires: isRefcountedType(tv->m_type) */ ALWAYS_INLINE void tvIncRefCountable(TypedValue tv) { - assert(tvIsPlausible(tv)); - assert(isRefcountedType(tv.m_type)); + assertx(tvIsPlausible(tv)); + assertx(isRefcountedType(tv.m_type)); tv.m_data.pcnt->incRefCount(); } @@ -190,7 +190,7 @@ ALWAYS_INLINE void tvIncRefCountable(TypedValue tv) { * Incref `tv', or do nothing if it's not refcounted. */ ALWAYS_INLINE void tvIncRefGen(TypedValue tv) { - assert(tvIsPlausible(tv)); + assertx(tvIsPlausible(tv)); if (isRefcountedType(tv.m_type)) { tvIncRefCountable(tv); } diff --git a/hphp/runtime/base/tv-type.h b/hphp/runtime/base/tv-type.h index 0548a4cca89..a52c8f49a89 100644 --- a/hphp/runtime/base/tv-type.h +++ b/hphp/runtime/base/tv-type.h @@ -26,7 +26,7 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// ALWAYS_INLINE bool cellIsNull(Cell tv) { - assert(cellIsPlausible(tv)); + assertx(cellIsPlausible(tv)); return isNullType(tv.m_type); } ALWAYS_INLINE bool cellIsNull(const Cell* tv) { diff --git a/hphp/runtime/base/tv-variant.h b/hphp/runtime/base/tv-variant.h index 7058c32f366..f652797084c 100644 --- a/hphp/runtime/base/tv-variant.h +++ b/hphp/runtime/base/tv-variant.h @@ -36,40 +36,40 @@ struct Variant; */ ALWAYS_INLINE Variant& tvAsVariant(TypedValue* tv) { - assert(tv != nullptr); - assert(tvIsPlausible(*tv)); + assertx(tv != nullptr); + assertx(tvIsPlausible(*tv)); return reinterpret_cast(*tv); } ALWAYS_INLINE Variant& tvAsUninitializedVariant(TypedValue* tv) { // A special case, for use when constructing a variant and we don't assume // initialization. - assert(tv != nullptr); + assertx(tv != nullptr); return reinterpret_cast(*tv); } ALWAYS_INLINE const Variant& tvAsCVarRef(const TypedValue* tv) { - assert(tv != nullptr); + assertx(tv != nullptr); return reinterpret_cast(*tv); } ALWAYS_INLINE Variant& cellAsVariant(Cell& cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); return reinterpret_cast(cell); } ALWAYS_INLINE const Variant& cellAsCVarRef(const Cell& cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); return reinterpret_cast(cell); } ALWAYS_INLINE Variant& refAsVariant(Ref& ref) { - assert(refIsPlausible(ref)); + assertx(refIsPlausible(ref)); return reinterpret_cast(ref); } ALWAYS_INLINE const Variant& refAsCVarRef(const Ref& ref) { - assert(refIsPlausible(ref)); + assertx(refIsPlausible(ref)); return reinterpret_cast(ref); } diff --git a/hphp/runtime/base/type-array.cpp b/hphp/runtime/base/type-array.cpp index 74bb05c9a93..6bd5fd19f3a 100644 --- a/hphp/runtime/base/type-array.cpp +++ b/hphp/runtime/base/type-array.cpp @@ -188,9 +188,9 @@ Array Array::diffImpl(const Array& array, bool by_key, bool by_value, bool match const void *key_data, PFUNC_CMP value_cmp_function, const void *value_data) const { - assert(by_key || by_value); - assert(by_key || key_cmp_function == nullptr); - assert(by_value || value_cmp_function == nullptr); + assertx(by_key || by_value); + assertx(by_key || key_cmp_function == nullptr); + assertx(by_value || value_cmp_function == nullptr); PFUNC_CMP value_cmp_as_string_function = value_cmp_function; if (!value_cmp_function) { value_cmp_function = SortStringAscending; @@ -360,7 +360,7 @@ String Array::toString() const { raise_notice("Array to string conversion"); return array_string; } - assert(m_arr->isHackArray()); + assertx(m_arr->isHackArray()); if (m_arr->isVecArray()) { raise_notice("Vec to string conversion"); return vec_string; @@ -369,7 +369,7 @@ String Array::toString() const { raise_notice("Dict to string conversion"); return dict_string; } - assert(m_arr->isKeyset()); + assertx(m_arr->isKeyset()); raise_notice("Keyset to string conversion"); return keyset_string; } @@ -658,7 +658,7 @@ member_lval Array::lvalAtImpl(const T& key, AccessFlags) { if (!m_arr) m_arr = Ptr::attach(ArrayData::Create()); auto const lval = m_arr->lval(key, m_arr->cowCheck()); if (lval.arr_base() != m_arr) m_arr = Ptr::attach(lval.arr_base()); - assert(lval.has_ref()); + assertx(lval.has_ref()); return lval; } @@ -667,7 +667,7 @@ member_lval Array::lvalAtRefImpl(const T& key, AccessFlags) { if (!m_arr) m_arr = Ptr::attach(ArrayData::Create()); auto const lval = m_arr->lvalRef(key, m_arr->cowCheck()); if (lval.arr_base() != m_arr) m_arr = Ptr::attach(lval.arr_base()); - assert(lval.has_ref()); + assertx(lval.has_ref()); return lval; } @@ -900,7 +900,7 @@ member_lval Array::lvalAt() { if (!m_arr) m_arr = Ptr::attach(ArrayData::Create()); auto const lval = m_arr->lvalNew(m_arr->cowCheck()); if (lval.arr_base() != m_arr) m_arr = Ptr::attach(lval.arr_base()); - assert(lval); + assertx(lval); return lval; } @@ -908,7 +908,7 @@ member_lval Array::lvalAtRef() { if (!m_arr) m_arr = Ptr::attach(ArrayData::Create()); auto const lval = m_arr->lvalNewRef(m_arr->cowCheck()); if (lval.arr_base() != m_arr) m_arr = Ptr::attach(lval.arr_base()); - assert(lval); + assertx(lval); return lval; } @@ -1011,7 +1011,7 @@ static int multi_compare_func(const void *n1, const void *n2, const void *op) { void Array::SortImpl(std::vector &indices, const Array& source, Array::SortData &opaque, Array::PFUNC_CMP cmp_func, bool by_key, const void *data /* = NULL */) { - assert(cmp_func); + assertx(cmp_func); int count = source.size(); if (count == 0) { @@ -1054,14 +1054,14 @@ void Array::sort(PFUNC_CMP cmp_func, bool by_key, bool renumber, } bool Array::MultiSort(std::vector &data, bool renumber) { - assert(!data.empty()); + assertx(!data.empty()); int count = -1; for (unsigned int k = 0; k < data.size(); k++) { SortData &opaque = data[k]; - assert(opaque.array); - assert(opaque.cmp_func); + assertx(opaque.array); + assertx(opaque.cmp_func); int size = opaque.array->size(); if (count == -1) { count = size; diff --git a/hphp/runtime/base/type-object.h b/hphp/runtime/base/type-object.h index 470af53b73c..504dd12d38b 100644 --- a/hphp/runtime/base/type-object.h +++ b/hphp/runtime/base/type-object.h @@ -51,59 +51,59 @@ public: explicit Object(ObjectData *data) : m_obj(data) { // The object must have at least two refs here. One pre-existing ref, and // one caused by placing it under m_obj's control. - assert(!data || data->hasMultipleRefs()); + assertx(!data || data->hasMultipleRefs()); } /* implicit */ Object(const Object& src) : m_obj(src.m_obj) { - assert(!m_obj || m_obj->hasMultipleRefs()); + assertx(!m_obj || m_obj->hasMultipleRefs()); } template explicit Object(const req::ptr &ptr) : m_obj(ptr) { - assert(!m_obj || m_obj->hasMultipleRefs()); + assertx(!m_obj || m_obj->hasMultipleRefs()); } template explicit Object(req::ptr&& ptr) : m_obj(std::move(ptr)) { - assert(!m_obj || m_obj->checkCount()); + assertx(!m_obj || m_obj->checkCount()); } explicit Object(Class* cls) : m_obj(ObjectData::newInstance(cls), NoIncRef{}) { // References to the object can escape inside newInstance, so we only know // that the ref-count is at least 1 here. - assert(!m_obj || m_obj->checkCount()); + assertx(!m_obj || m_obj->checkCount()); } // Move ctor Object(Object&& src) noexcept : m_obj(std::move(src.m_obj)) { - assert(!m_obj || m_obj->checkCount()); + assertx(!m_obj || m_obj->checkCount()); } // Regular assign Object& operator=(const Object& src) { m_obj = src.m_obj; - assert(!m_obj || m_obj->hasMultipleRefs()); + assertx(!m_obj || m_obj->hasMultipleRefs()); return *this; } template Object& operator=(const req::ptr& src) { m_obj = src; - assert(!m_obj || m_obj->hasMultipleRefs()); + assertx(!m_obj || m_obj->hasMultipleRefs()); return *this; } // Move assign Object& operator=(Object&& src) { m_obj = std::move(src.m_obj); - assert(!m_obj || m_obj->checkCount()); + assertx(!m_obj || m_obj->checkCount()); return *this; } template Object& operator=(req::ptr&& src) { m_obj = std::move(src); - assert(!m_obj || m_obj->checkCount()); + assertx(!m_obj || m_obj->checkCount()); return *this; } @@ -197,7 +197,7 @@ public: // Take ownership of a reference without touching the ref count static Object attach(ObjectData *object) { - assert(!object || object->checkCount()); + assertx(!object || object->checkCount()); return Object{req::ptr::attach(object)}; } diff --git a/hphp/runtime/base/type-string.cpp b/hphp/runtime/base/type-string.cpp index 68595fc6d8e..b9c91bc71c2 100644 --- a/hphp/runtime/base/type-string.cpp +++ b/hphp/runtime/base/type-string.cpp @@ -90,7 +90,7 @@ StringData* buildStringData(int n) { req::ptr String::buildString(int n) { const StringData* sd = GetIntegerStringData(n); if (sd) { - assert(sd->isStatic()); + assertx(sd->isStatic()); return req::ptr::attach(const_cast(sd)); } return req::ptr::attach(buildStringData(n)); @@ -109,7 +109,7 @@ StringData* buildStringData(int64_t n) { req::ptr String::buildString(int64_t n) { const StringData* sd = GetIntegerStringData(n); if (sd) { - assert(sd->isStatic()); + assertx(sd->isStatic()); return req::ptr::attach(const_cast(sd)); } return req::ptr::attach(buildStringData(n)); @@ -152,7 +152,7 @@ int String::find(char ch, int pos /* = 0 */, int String::find(const char *s, int pos /* = 0 */, bool caseSensitive /* = true */) const { - assert(s); + assertx(s); if (empty()) return -1; if (*s && *(s+1) == 0) { return find(*s, pos, caseSensitive); @@ -180,7 +180,7 @@ int String::rfind(char ch, int pos /* = 0 */, int String::rfind(const char *s, int pos /* = 0 */, bool caseSensitive /* = true */) const { - assert(s); + assertx(s); if (empty()) return -1; if (*s && *(s+1) == 0) { return rfind(*s, pos, caseSensitive); @@ -203,7 +203,7 @@ int String::rfind(const String& s, int pos /* = 0 */, // offset functions: cannot inline these due to dependencies char String::charAt(int pos) const { - assert(pos >= 0 && pos <= size()); + assertx(pos >= 0 && pos <= size()); const char *s = data(); return s[pos]; } diff --git a/hphp/runtime/base/type-string.h b/hphp/runtime/base/type-string.h index f69fbd12937..d83acd2f019 100644 --- a/hphp/runtime/base/type-string.h +++ b/hphp/runtime/base/type-string.h @@ -201,16 +201,16 @@ public: public: const String& setSize(int len) { - assert(m_str); + assertx(m_str); m_str->setSize(len); return *this; } const String& shrink(size_t len) { - assert(m_str && !m_str->isImmutable()); + assertx(m_str && !m_str->isImmutable()); if (m_str->capacity() - len > kMinShrinkThreshold) { m_str = req::ptr::attach(m_str->shrinkImpl(len)); } else { - assert(len < StringData::MaxSize); + assertx(len < StringData::MaxSize); m_str->setSize(len); } return *this; @@ -470,22 +470,22 @@ struct hphp_string_isame { struct StringDataHashCompare { bool equal(const StringData *s1, const StringData *s2) const { - assert(s1 && s2); + assertx(s1 && s2); return s1->same(s2); } size_t hash(const StringData *s) const { - assert(s); + assertx(s); return s->hash(); } }; struct StringDataHashICompare { bool equal(const StringData *s1, const StringData *s2) const { - assert(s1 && s2); + assertx(s1 && s2); return s1->isame(s2); } size_t hash(const StringData *s) const { - assert(s); + assertx(s); return s->hash(); } }; @@ -577,7 +577,7 @@ StaticString getDataTypeString(DataType t); inline String::String(const StaticString& str) : m_str(str.m_str.get(), NoIncRef{}) { - assert(str.m_str->isStatic()); + assertx(str.m_str->isStatic()); } inline String& String::operator=(const StaticString& v) { diff --git a/hphp/runtime/base/type-structure.cpp b/hphp/runtime/base/type-structure.cpp index 8e2cb62cdff..22e6b25363a 100644 --- a/hphp/runtime/base/type-structure.cpp +++ b/hphp/runtime/base/type-structure.cpp @@ -89,10 +89,10 @@ std::string fullName(const Array& arr); void functionTypeName(const Array& arr, std::string& name) { name += "(function ("; - assert(arr.exists(s_return_type)); + assertx(arr.exists(s_return_type)); auto const retType = arr[s_return_type].toCArrRef(); - assert(arr.exists(s_param_types)); + assertx(arr.exists(s_param_types)); auto const params = arr[s_param_types].toCArrRef(); auto sep = ""; @@ -108,11 +108,11 @@ void functionTypeName(const Array& arr, std::string& name) { } void accessTypeName(const Array& arr, std::string& name) { - assert(arr.exists(s_root_name)); + assertx(arr.exists(s_root_name)); auto const rootName = arr[s_root_name].toCStrRef(); name += rootName.toCppString(); - assert(arr.exists(s_access_list)); + assertx(arr.exists(s_access_list)); auto const accessList = arr[s_access_list].toCArrRef(); auto const sz = accessList.size(); for (auto i = 0; i < sz; i++) { @@ -125,7 +125,7 @@ void accessTypeName(const Array& arr, std::string& name) { // xhp names are mangled so we get them back to their original definition // see the mangling in ScannerToken::xhpLabel void xhpTypeName(const Array& arr, std::string& name) { - assert(arr.exists(s_classname)); + assertx(arr.exists(s_classname)); std::string clsName = arr[s_classname].toCStrRef().toCppString(); // remove prefix if any if (clsName.compare(0, sizeof("xhp_") - 1, "xhp_") == 0) { @@ -140,7 +140,7 @@ void xhpTypeName(const Array& arr, std::string& name) { void tupleTypeName(const Array& arr, std::string& name) { name += "("; - assert(arr.exists(s_elem_types)); + assertx(arr.exists(s_elem_types)); auto const elems = arr[s_elem_types].toCArrRef(); auto const sz = elems.size(); auto sep = ""; @@ -155,7 +155,7 @@ void tupleTypeName(const Array& arr, std::string& name) { void genericTypeName(const Array& arr, std::string& name) { name += "<"; - assert(arr.exists(s_generic_types)); + assertx(arr.exists(s_generic_types)); auto const args = arr[s_generic_types].toCArrRef(); auto const sz = args.size(); auto sep = ""; @@ -170,7 +170,7 @@ void genericTypeName(const Array& arr, std::string& name) { void shapeTypeName(const Array& arr, std::string& name) { // works for both resolved and unresolved TypeStructures name += "("; - assert(arr.exists(s_fields)); + assertx(arr.exists(s_fields)); auto const fields = arr[s_fields].toCArrRef(); auto const sz = fields.size(); auto sep = ""; @@ -208,11 +208,11 @@ void shapeTypeName(const Array& arr, std::string& name) { std::string fullName(const Array& arr) { std::string name; if (arr.exists(s_nullable)) { - assert(arr[s_nullable].toBoolean()); + assertx(arr[s_nullable].toBoolean()); name += '?'; } - assert(arr.exists(s_kind)); + assertx(arr.exists(s_kind)); TypeStructure::Kind kind = TypeStructure::Kind(arr[s_kind].toInt64Val()); @@ -288,7 +288,7 @@ std::string fullName(const Array& arr) { } break; case TypeStructure::Kind::T_typevar: - assert(arr.exists(s_name)); + assertx(arr.exists(s_name)); name += arr[s_name].toCStrRef().toCppString(); break; case TypeStructure::Kind::T_typeaccess: @@ -302,7 +302,7 @@ std::string fullName(const Array& arr) { case TypeStructure::Kind::T_trait: case TypeStructure::Kind::T_enum: case TypeStructure::Kind::T_unresolved: - assert(arr.exists(s_classname)); + assertx(arr.exists(s_classname)); name += arr[s_classname].toCStrRef().toCppString(); if (arr.exists(s_generic_types)) genericTypeName(arr, name); break; @@ -402,7 +402,7 @@ const Class* getClass(const String& clsName, auto name = clsName; auto ts = getAlias(name, persistent); while (!ts.empty()) { - assert(ts.exists(s_kind)); + assertx(ts.exists(s_kind)); if (!ts.exists(s_classname)) { // not a class, interface, trait, enum, or alias throw Exception( @@ -433,10 +433,10 @@ Array resolveShape(const Array& arr, const Class* typeCnsCls, const Array& generics, bool& persistent) { - assert(arr.exists(s_kind)); - assert(static_cast(arr[s_kind].toInt64Val()) + assertx(arr.exists(s_kind)); + assertx(static_cast(arr[s_kind].toInt64Val()) == TypeStructure::Kind::T_shape); - assert(arr.exists(s_fields)); + assertx(arr.exists(s_fields)); auto newfields = Array::CreateDArray(); auto const fields = arr[s_fields].toCArrRef(); @@ -464,7 +464,7 @@ Array resolveShape(const Array& arr, clsName.c_str(), cnsName.c_str()); } } - assert(wrapper.exists(s_value)); + assertx(wrapper.exists(s_value)); auto valueArr = wrapper[s_value].toArray(); auto value = resolveTS(valueArr, typeCns, typeCnsCls, generics, persistent); @@ -517,7 +517,7 @@ Array resolveTS(const Array& arr, const Class* typeCnsCls, const Array& generics, bool& persistent) { - assert(arr.exists(s_kind)); + assertx(arr.exists(s_kind)); auto const kind = static_cast( arr[s_kind].toInt64Val()); @@ -531,7 +531,7 @@ Array resolveTS(const Array& arr, switch (kind) { case TypeStructure::Kind::T_tuple: { - assert(arr.exists(s_elem_types)); + assertx(arr.exists(s_elem_types)); auto const elemsArr = arr[s_elem_types].toCArrRef(); auto const elemTypes = resolveList(elemsArr, typeCns, typeCnsCls, generics, persistent); @@ -539,13 +539,13 @@ Array resolveTS(const Array& arr, break; } case TypeStructure::Kind::T_fun: { - assert(arr.exists(s_return_type)); + assertx(arr.exists(s_return_type)); auto const returnArr = arr[s_return_type].toCArrRef(); auto const returnType = resolveTS(returnArr, typeCns, typeCnsCls, generics, persistent); newarr.add(s_return_type, Variant(returnType)); - assert(arr.exists(s_param_types)); + assertx(arr.exists(s_param_types)); auto const paramsArr = arr[s_param_types].toCArrRef(); auto const paramTypes = resolveList(paramsArr, typeCns, typeCnsCls, generics, persistent); @@ -571,7 +571,7 @@ Array resolveTS(const Array& arr, break; } case TypeStructure::Kind::T_unresolved: { - assert(arr.exists(s_classname)); + assertx(arr.exists(s_classname)); auto const clsName = arr[s_classname].toCStrRef(); auto ts = getAlias(clsName, persistent); if (!ts.empty()) { @@ -625,9 +625,9 @@ Array resolveTS(const Array& arr, * type constants, i.e., cls::TC1::TC2::TC3. Each type constant other * than the last one in the chain must refer to a class or an * interface. */ - assert(arr.exists(s_root_name)); + assertx(arr.exists(s_root_name)); auto clsName = arr[s_root_name].toCStrRef(); - assert(arr.exists(s_access_list)); + assertx(arr.exists(s_access_list)); auto const accList = arr[s_access_list].toCArrRef(); auto const sz = accList.size(); Array typeCnsVal; @@ -649,7 +649,7 @@ Array resolveTS(const Array& arr, if (i == sz - 1) break; // if there are more accesses, keep resolving - assert(typeCnsVal.exists(s_kind)); + assertx(typeCnsVal.exists(s_kind)); auto kind = static_cast (typeCnsVal[s_kind].toInt64Val()); if (kind != TypeStructure::Kind::T_class @@ -662,7 +662,7 @@ Array resolveTS(const Array& arr, cnsName.data(), accList[i+1].toCStrRef().data()); } - assert(typeCnsVal.exists(s_classname)); + assertx(typeCnsVal.exists(s_classname)); clsName = typeCnsVal[s_classname].toCStrRef(); } @@ -673,7 +673,7 @@ Array resolveTS(const Array& arr, return typeCnsVal; } case TypeStructure::Kind::T_typevar: { - assert(arr.exists(s_name)); + assertx(arr.exists(s_name)); auto const name = arr[s_name].toCStrRef(); return generics.exists(name) ? generics[name].toDArray() : arr.toDArray(); } @@ -702,10 +702,10 @@ String TypeStructure::toString(const Array& arr) { Array TypeStructure::resolve(const Class::Const& typeCns, const Class* typeCnsCls, bool& persistent) { - assert(typeCns.isType()); - assert(isArrayLikeType(typeCns.val.m_type)); - assert(typeCns.name); - assert(typeCnsCls); + assertx(typeCns.isType()); + assertx(isArrayLikeType(typeCns.val.m_type)); + assertx(typeCns.name); + assertx(typeCnsCls); Array arr(typeCns.val.m_data.parr); return resolveTS(arr, typeCns, typeCnsCls, Array(), persistent); diff --git a/hphp/runtime/base/type-variant.cpp b/hphp/runtime/base/type-variant.cpp index 17ed002028c..c2b6e9fb6cc 100644 --- a/hphp/runtime/base/type-variant.cpp +++ b/hphp/runtime/base/type-variant.cpp @@ -173,7 +173,7 @@ IMPLEMENT_SET(int64_t, m_type = KindOfInt64; m_data.num = v) IMPLEMENT_SET(double, m_type = KindOfDouble; m_data.dbl = v) IMPLEMENT_SET(const StaticString&, StringData* s = v.get(); - assert(s); + assertx(s); m_type = KindOfPersistentString; m_data.pstr = s) @@ -353,7 +353,7 @@ bool Variant::isAllowedAsConstantValue() const { inline DataType Variant::convertToNumeric(int64_t *lval, double *dval) const { StringData *s = getStringData(); - assert(s); + assertx(s); return s->isNumericWithVal(*lval, *dval, 1); } @@ -361,7 +361,7 @@ inline DataType Variant::convertToNumeric(int64_t *lval, double *dval) const { // type conversions bool Variant::toBooleanHelper() const { - assert(m_type > KindOfInt64); + assertx(m_type > KindOfInt64); switch (m_type) { case KindOfUninit: case KindOfNull: @@ -386,7 +386,7 @@ bool Variant::toBooleanHelper() const { } int64_t Variant::toInt64Helper(int base /* = 10 */) const { - assert(m_type > KindOfInt64); + assertx(m_type > KindOfInt64); switch (m_type) { case KindOfUninit: case KindOfNull: @@ -452,7 +452,7 @@ String Variant::toStringHelper() const { case KindOfPersistentString: case KindOfString: - assert(false); // Should be done in caller + assertx(false); // Should be done in caller return String{m_data.pstr}; case KindOfPersistentVec: @@ -634,7 +634,7 @@ void Variant::setEvalScalar() { auto const do_array = [this]{ if (!m_data.parr->isStatic()) { ArrayData::GetScalarArray(&m_data.parr); - assert(m_data.parr->isStatic()); + assertx(m_data.parr->isStatic()); } }; @@ -654,7 +654,7 @@ void Variant::setEvalScalar() { StringData *sd = makeStaticString(pstr); decRefStr(pstr); m_data.pstr = sd; - assert(m_data.pstr->isStatic()); + assertx(m_data.pstr->isStatic()); } return; } diff --git a/hphp/runtime/base/type-variant.h b/hphp/runtime/base/type-variant.h index 0de015bd160..55822a6febc 100644 --- a/hphp/runtime/base/type-variant.h +++ b/hphp/runtime/base/type-variant.h @@ -119,11 +119,11 @@ struct Variant : private TypedValue { /* implicit */ Variant(const std::string &v) { m_type = KindOfString; StringData *s = StringData::Make(v.c_str(), v.size(), CopyString); - assert(s); + assertx(s); m_data.pstr = s; } /* implicit */ Variant(const StaticString &v) noexcept { - assert(v.get() && !v.get()->isRefCounted()); + assertx(v.get() && !v.get()->isRefCounted()); m_type = KindOfPersistentString; m_data.pstr = v.get(); } @@ -187,22 +187,22 @@ struct Variant : private TypedValue { * inc-ref. */ explicit Variant(ArrayData* ad, DataType dt, ArrayInitCtor) noexcept { - assert(ad->toDataType() == dt); + assertx(ad->toDataType() == dt); m_type = dt; m_data.parr = ad; } enum class PersistentArrInit {}; Variant(const ArrayData* ad, DataType dt, PersistentArrInit) noexcept { - assert(ad->toPersistentDataType() == dt); - assert(!ad->isRefCounted()); + assertx(ad->toPersistentDataType() == dt); + assertx(!ad->isRefCounted()); m_data.parr = const_cast(ad); m_type = dt; } enum class PersistentStrInit {}; explicit Variant(const StringData *s, PersistentStrInit) noexcept { - assert(!s->isRefCounted()); + assertx(!s->isRefCounted()); m_data.pstr = const_cast(s); m_type = KindOfPersistentString; } @@ -239,7 +239,7 @@ struct Variant : private TypedValue { } Variant(StrongBind, Variant& v) { - assert(tvIsPlausible(v)); + assertx(tvIsPlausible(v)); tvBoxIfNeeded(*v.asTypedValue()); refDup(*v.asTypedValue(), *asTypedValue()); } @@ -263,7 +263,7 @@ struct Variant : private TypedValue { return; } - assert(this != &v); + assertx(this != &v); if (v.m_type != KindOfUninit) { m_type = v.m_type; m_data = v.m_data; @@ -328,7 +328,7 @@ struct Variant : private TypedValue { * refs and turn uninits to null. */ Variant& operator=(Variant &&rhs) noexcept { - assert(this != &rhs); // we end up as null on a self move-assign. + assertx(this != &rhs); // we end up as null on a self move-assign. if (rhs.m_type == KindOfRef) return *this = *rhs.m_data.pref->var(); Variant& lhs = m_type == KindOfRef ? *m_data.pref->var() : *this; @@ -428,12 +428,12 @@ struct Variant : private TypedValue { // int64 ALWAYS_INLINE int64_t asInt64Val() const { - assert(m_type == KindOfInt64); + assertx(m_type == KindOfInt64); return m_data.num; } ALWAYS_INLINE int64_t toInt64Val() const { - assert(is(KindOfInt64)); + assertx(is(KindOfInt64)); return LIKELY(m_type == KindOfInt64) ? m_data.num : m_data.pref->var()->m_data.num; @@ -443,12 +443,12 @@ struct Variant : private TypedValue { // double ALWAYS_INLINE double asDoubleVal() const { - assert(m_type == KindOfDouble); + assertx(m_type == KindOfDouble); return m_data.dbl; } ALWAYS_INLINE double toDoubleVal() const { - assert(is(KindOfDouble)); + assertx(is(KindOfDouble)); return LIKELY(m_type == KindOfDouble) ? m_data.dbl : m_data.pref->var()->m_data.dbl; @@ -458,12 +458,12 @@ struct Variant : private TypedValue { // boolean ALWAYS_INLINE bool asBooleanVal() const { - assert(m_type == KindOfBoolean); + assertx(m_type == KindOfBoolean); return m_data.num; } ALWAYS_INLINE bool toBooleanVal() const { - assert(is(KindOfBoolean)); + assertx(is(KindOfBoolean)); return LIKELY(m_type == KindOfBoolean) ? m_data.num : m_data.pref->var()->m_data.num; @@ -473,19 +473,21 @@ struct Variant : private TypedValue { // string ALWAYS_INLINE const String& asCStrRef() const { - assert(isStringType(m_type) && m_data.pstr); + assertx(isStringType(m_type) && m_data.pstr); return *reinterpret_cast(&m_data.pstr); } ALWAYS_INLINE const String& toCStrRef() const { - assert(isString()); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.pstr : m_data.pstr); + assertx(isString()); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.pstr + : m_data.pstr); return *reinterpret_cast(LIKELY(isStringType(m_type)) ? &m_data.pstr : &m_data.pref->tv()->m_data.pstr); } ALWAYS_INLINE String& asStrRef() { - assert(isStringType(m_type) && m_data.pstr); + assertx(isStringType(m_type) && m_data.pstr); // The caller is likely going to modify the string, so we have to eagerly // promote KindOfPersistentString -> KindOfString. m_type = KindOfString; @@ -493,8 +495,10 @@ struct Variant : private TypedValue { } ALWAYS_INLINE String& toStrRef() { - assert(isString()); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.pstr : m_data.pstr); + assertx(isString()); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.pstr + : m_data.pstr); // The caller is likely going to modify the string, so we have to eagerly // promote KindOfPersistentString -> KindOfString. auto tv = LIKELY(isStringType(m_type)) ? this : m_data.pref->tv(); @@ -506,26 +510,30 @@ struct Variant : private TypedValue { // array ALWAYS_INLINE const Array& asCArrRef() const { - assert(isArrayLikeType(m_type) && m_data.parr); + assertx(isArrayLikeType(m_type) && m_data.parr); return *reinterpret_cast(&m_data.parr); } ALWAYS_INLINE const Array& toCArrRef() const { - assert(isArray()); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.parr : m_data.parr); + assertx(isArray()); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.parr + : m_data.parr); return *reinterpret_cast(LIKELY(isArrayLikeType(m_type)) ? &m_data.parr : &m_data.pref->tv()->m_data.parr); } ALWAYS_INLINE Array& asArrRef() { - assert(isArrayLikeType(m_type) && m_data.parr); + assertx(isArrayLikeType(m_type) && m_data.parr); m_type = m_data.parr->toDataType(); return *reinterpret_cast(&m_data.parr); } ALWAYS_INLINE Array& toArrRef() { - assert(isArray()); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.parr : m_data.parr); + assertx(isArray()); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.parr + : m_data.parr); auto tv = LIKELY(isArrayLikeType(m_type)) ? this : m_data.pref->tv(); tv->m_type = tv->m_data.parr->toDataType(); return *reinterpret_cast(&tv->m_data.parr); @@ -535,42 +543,48 @@ struct Variant : private TypedValue { // object ALWAYS_INLINE const Object& asCObjRef() const { - assert(m_type == KindOfObject && m_data.pobj); + assertx(m_type == KindOfObject && m_data.pobj); return *reinterpret_cast(&m_data.pobj); } ALWAYS_INLINE const Object& toCObjRef() const { - assert(is(KindOfObject)); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.pobj : m_data.pobj); + assertx(is(KindOfObject)); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.pobj + : m_data.pobj); return *reinterpret_cast(LIKELY(m_type == KindOfObject) ? &m_data.pobj : &m_data.pref->tv()->m_data.pobj); } ALWAYS_INLINE Object & asObjRef() { - assert(m_type == KindOfObject && m_data.pobj); + assertx(m_type == KindOfObject && m_data.pobj); return *reinterpret_cast(&m_data.pobj); } ALWAYS_INLINE const Resource& asCResRef() const { - assert(m_type == KindOfResource && m_data.pres); + assertx(m_type == KindOfResource && m_data.pres); return *reinterpret_cast(&m_data.pres); } ALWAYS_INLINE const Resource& toCResRef() const { - assert(is(KindOfResource)); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.pres : m_data.pres); + assertx(is(KindOfResource)); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.pres + : m_data.pres); return *reinterpret_cast(LIKELY(m_type == KindOfResource) ? &m_data.pres : &m_data.pref->tv()->m_data.pres); } ALWAYS_INLINE Resource & asResRef() { - assert(m_type == KindOfResource && m_data.pres); + assertx(m_type == KindOfResource && m_data.pres); return *reinterpret_cast(&m_data.pres); } ALWAYS_INLINE Object& toObjRef() { - assert(is(KindOfObject)); - assert(m_type == KindOfRef ? m_data.pref->var()->m_data.pobj : m_data.pobj); + assertx(is(KindOfObject)); + assertx(m_type == KindOfRef + ? m_data.pref->var()->m_data.pobj + : m_data.pobj); return *reinterpret_cast(LIKELY(m_type == KindOfObject) ? &m_data.pobj : &m_data.pref->tv()->m_data.pobj); } @@ -677,15 +691,15 @@ struct Variant : private TypedValue { int getRefCount() const noexcept; bool getBoolean() const { - assert(getType() == KindOfBoolean); + assertx(getType() == KindOfBoolean); return m_type == KindOfRef ? m_data.pref->var()->m_data.num : m_data.num; } int64_t getInt64() const { - assert(getType() == KindOfInt64); + assertx(getType() == KindOfInt64); return m_type == KindOfRef ? m_data.pref->var()->m_data.num : m_data.num; } double getDouble() const { - assert(getType() == KindOfDouble); + assertx(getType() == KindOfDouble); return m_type == KindOfRef ? m_data.pref->var()->m_data.dbl : m_data.dbl; } @@ -697,7 +711,7 @@ struct Variant : private TypedValue { return *this; } Variant& assignRef(Variant& v) noexcept { - assert(&v != &uninit_variant); + assertx(&v != &uninit_variant); tvBoxIfNeeded(*v.asTypedValue()); tvBind(*v.asTypedValue(), *asTypedValue()); return *this; @@ -945,56 +959,56 @@ struct Variant : private TypedValue { * Low level access that should be restricted to internal use. */ int64_t *getInt64Data() const { - assert(getType() == KindOfInt64); + assertx(getType() == KindOfInt64); return m_type == KindOfRef ? &m_data.pref->var()->m_data.num : const_cast(&m_data.num); } double *getDoubleData() const { - assert(getType() == KindOfDouble); + assertx(getType() == KindOfDouble); return m_type == KindOfRef ? &m_data.pref->var()->m_data.dbl : const_cast(&m_data.dbl); } StringData *getStringData() const { - assert(isStringType(getType())); + assertx(isStringType(getType())); return m_type == KindOfRef ? m_data.pref->var()->m_data.pstr : m_data.pstr; } StringData *getStringDataOrNull() const { // This is a necessary evil because getStringData() returns // an undefined result if this is a null variant - assert(isNull() || isString()); + assertx(isNull() || isString()); return m_type == KindOfRef ? (m_data.pref->var()->m_type <= KindOfNull ? nullptr : m_data.pref->var()->m_data.pstr) : (m_type <= KindOfNull ? nullptr : m_data.pstr); } ArrayData *getArrayData() const { - assert(isArray()); + assertx(isArray()); return m_type == KindOfRef ? m_data.pref->var()->m_data.parr : m_data.parr; } ArrayData *getArrayDataOrNull() const { // This is a necessary evil because getArrayData() returns // an undefined result if this is a null variant - assert(isNull() || isArray()); + assertx(isNull() || isArray()); return m_type == KindOfRef ? (m_data.pref->var()->m_type <= KindOfNull ? nullptr : m_data.pref->var()->m_data.parr) : (m_type <= KindOfNull ? nullptr : m_data.parr); } ObjectData* getObjectData() const { - assert(is(KindOfObject)); + assertx(is(KindOfObject)); return m_type == KindOfRef ? m_data.pref->var()->m_data.pobj : m_data.pobj; } ObjectData *getObjectDataOrNull() const { // This is a necessary evil because getObjectData() returns // an undefined result if this is a null variant - assert(isNull() || is(KindOfObject)); + assertx(isNull() || is(KindOfObject)); return m_type == KindOfRef ? (m_data.pref->var()->m_type <= KindOfNull ? nullptr : m_data.pref->var()->m_data.pobj) : (m_type <= KindOfNull ? nullptr : m_data.pobj); } Variant *getRefData() const { - assert(m_type == KindOfRef); + assertx(m_type == KindOfRef); return m_data.pref->var(); } @@ -1048,27 +1062,27 @@ struct Variant : private TypedValue { private: ResourceData* getResourceData() const { - assert(is(KindOfResource)); + assertx(is(KindOfResource)); return m_type == KindOfRef ? m_data.pref->var()->m_data.pres->data() : m_data.pres->data(); } ResourceData* detachResourceData() { - assert(is(KindOfResource)); + assertx(is(KindOfResource)); if (UNLIKELY(m_type == KindOfRef)) { tvUnbox(*asTypedValue()); } - assert(m_type == KindOfResource); + assertx(m_type == KindOfResource); m_type = KindOfNull; return m_data.pres->data(); } ObjectData* detachObjectData() { - assert(is(KindOfObject)); + assertx(is(KindOfObject)); if (UNLIKELY(m_type == KindOfRef)) { tvUnbox(*asTypedValue()); } - assert(m_type == KindOfObject); + assertx(m_type == KindOfObject); m_type = KindOfNull; return m_data.pobj; } @@ -1177,7 +1191,7 @@ struct Variant : private TypedValue { bool isPrimitive() const { return !isRefcountedType(m_type); } bool isObjectConvertable() { - assert(m_type != KindOfRef); + assertx(m_type != KindOfRef); return m_type <= KindOfNull || (m_type == KindOfBoolean && !m_data.num) || (isStringType(m_type) && m_data.pstr->empty()); @@ -1231,9 +1245,9 @@ struct Variant : private TypedValue { private: void moveRefHelper(Variant&& v) { - assert(tvIsPlausible(v)); + assertx(tvIsPlausible(v)); - assert(v.m_type == KindOfRef); + assertx(v.m_type == KindOfRef); m_type = v.m_data.pref->tv()->m_type; // Can't be KindOfUninit. m_data = v.m_data.pref->tv()->m_data; tvIncRefGen(*asTypedValue()); @@ -1308,7 +1322,7 @@ struct VRefParamValue { ArrNR toArrNR() const { return m_var.toArrNR(); } RefData* getRefData() const { - assert(isRefData()); + assertx(isRefData()); return m_var.asTypedValue()->m_data.pref; } RefData* getRefDataOrNull() const { @@ -1352,7 +1366,7 @@ struct VarNR : private TypedValueAux { explicit VarNR(double v) { init(KindOfDouble ); m_data.dbl = v;} explicit VarNR(const StaticString &v) { - assert(v.get() && !v.get()->isRefCounted()); + assertx(v.get() && !v.get()->isRefCounted()); init(KindOfPersistentString); m_data.pstr = v.get(); } @@ -1362,7 +1376,7 @@ struct VarNR : private TypedValueAux { explicit VarNR(const Object& v); explicit VarNR(StringData *v); explicit VarNR(const StringData *v) { - assert(v && !v->isRefCounted()); + assertx(v && !v->isRefCounted()); init(KindOfPersistentString); m_data.pstr = const_cast(v); } @@ -1406,28 +1420,28 @@ private: return &tvAsVariant(static_cast(this)); } void checkRefCount() { - assert(isRefcountedType(m_type) ? varNrFlag() == NR_FLAG : true); + assertx(isRefcountedType(m_type) ? varNrFlag() == NR_FLAG : true); switch (m_type) { DT_UNCOUNTED_CASE: return; case KindOfString: - assert(m_data.pstr->checkCount()); + assertx(m_data.pstr->checkCount()); return; case KindOfVec: case KindOfDict: case KindOfKeyset: case KindOfArray: - assert(m_data.parr->checkCount()); + assertx(m_data.parr->checkCount()); return; case KindOfObject: - assert(m_data.pobj->checkCount()); + assertx(m_data.pobj->checkCount()); return; case KindOfResource: - assert(m_data.pres->checkCount()); + assertx(m_data.pres->checkCount()); return; case KindOfRef: - assert(m_data.pref->checkCount()); + assertx(m_data.pref->checkCount()); return; } not_reached(); @@ -1507,7 +1521,7 @@ inline Variant &concat_assign(Variant &v1, const String& s2) { // Defined here for include order reasons. inline RefData::~RefData() { - assert(m_kind == HeaderKind::Ref); + assertx(m_kind == HeaderKind::Ref); tvAsVariant(&m_tv).~Variant(); } diff --git a/hphp/runtime/base/typed-value.h b/hphp/runtime/base/typed-value.h index b2fe948a781..08158b71b1e 100644 --- a/hphp/runtime/base/typed-value.h +++ b/hphp/runtime/base/typed-value.h @@ -176,7 +176,7 @@ using TypedNum = TypedValue; /* * Assertions on Cells and TypedValues. Should usually only happen inside an - * assert(). + * assertx(). */ bool tvIsPlausible(TypedValue); bool cellIsPlausible(Cell); @@ -244,7 +244,7 @@ typename std::enable_if< TypedValue ret; ret.m_data = make_value(val); ret.m_type = DType; - assert(tvIsPlausible(ret)); + assertx(tvIsPlausible(ret)); return ret; } @@ -255,7 +255,7 @@ typename std::enable_if< >::type make_tv() { TypedValue ret; ret.m_type = DType; - assert(tvIsPlausible(ret)); + assertx(tvIsPlausible(ret)); return ret; } @@ -269,8 +269,8 @@ typename std::enable_if< std::is_same::type,double>::value, double >::type unpack_tv(TypedValue *tv) { - assert(DType == tv->m_type); - assert(tvIsPlausible(*tv)); + assertx(DType == tv->m_type); + assertx(tvIsPlausible(*tv)); return tv->m_data.dbl; } @@ -279,8 +279,8 @@ typename std::enable_if< std::is_integral::type>::value, typename DataTypeCPPType::type >::type unpack_tv(TypedValue *tv) { - assert(DType == tv->m_type); - assert(tvIsPlausible(*tv)); + assertx(DType == tv->m_type); + assertx(tvIsPlausible(*tv)); return tv->m_data.num; } @@ -289,13 +289,13 @@ typename std::enable_if< std::is_pointer::type>::value, typename DataTypeCPPType::type >::type unpack_tv(TypedValue *tv) { - assert((DType == tv->m_type) || + assertx((DType == tv->m_type) || (isStringType(DType) && isStringType(tv->m_type)) || (isArrayType(DType) && isArrayType(tv->m_type)) || (isVecType(DType) && isVecType(tv->m_type)) || (isDictType(DType) && isDictType(tv->m_type)) || (isKeysetType(DType) && isKeysetType(tv->m_type))); - assert(tvIsPlausible(*tv)); + assertx(tvIsPlausible(*tv)); return reinterpret_cast::type> (tv->m_data.pstr); } diff --git a/hphp/runtime/base/unit-cache.cpp b/hphp/runtime/base/unit-cache.cpp index 2d043761382..01c30a20dff 100644 --- a/hphp/runtime/base/unit-cache.cpp +++ b/hphp/runtime/base/unit-cache.cpp @@ -373,7 +373,7 @@ CachedUnit loadUnitNonRepoAuth(StringData* requestedPath, Stream::Wrapper* w = nullptr; auto& cache = getNonRepoCache(rpath, w); - assert( + assertx( !w || &cache != &s_nonRepoUnitCache || !RuntimeOption::EvalUnixServerQuarantineUnits ); @@ -492,7 +492,7 @@ bool findFile(const StringData* path, struct stat* s, bool allow_dir, bool findFileWrapper(const String& file, void* ctx) { auto const context = static_cast(ctx); - assert(context->path.isNull()); + assertx(context->path.isNull()); Stream::Wrapper* w = Stream::getWrapperFromURI(file); if (w && !w->isNormalFileStream()) { diff --git a/hphp/runtime/base/url-file.cpp b/hphp/runtime/base/url-file.cpp index 6046e54cb81..3659f411203 100644 --- a/hphp/runtime/base/url-file.cpp +++ b/hphp/runtime/base/url-file.cpp @@ -163,13 +163,13 @@ bool UrlFile::open(const String& input_url, const String& mode) { } int64_t UrlFile::writeImpl(const char* /*buffer*/, int64_t /*length*/) { - assert(m_len != -1); + assertx(m_len != -1); raise_fatal_error((std::string("cannot write a url stream: ") + getName()).c_str()); } bool UrlFile::flush() { - assert(m_len != -1); + assertx(m_len != -1); raise_fatal_error((std::string("cannot flush a url stream: ") + getName()).c_str()); } diff --git a/hphp/runtime/base/url.cpp b/hphp/runtime/base/url.cpp index 38323b28934..a0798c4648c 100644 --- a/hphp/runtime/base/url.cpp +++ b/hphp/runtime/base/url.cpp @@ -21,7 +21,7 @@ namespace HPHP { namespace URL { const char *getServerObject(const char* url) { - assert(url); + assertx(url); int strip = 0; if (strncmp(url, "http://", 7) == 0) { strip = 7; @@ -38,7 +38,7 @@ const char *getServerObject(const char* url) { } std::string getCommand(const char* serverObject) { - assert(serverObject); + assertx(serverObject); if (!*serverObject) { return ""; } diff --git a/hphp/runtime/base/user-file.cpp b/hphp/runtime/base/user-file.cpp index a4190618c46..b2216520cdd 100644 --- a/hphp/runtime/base/user-file.cpp +++ b/hphp/runtime/base/user-file.cpp @@ -276,7 +276,7 @@ int64_t UserFile::writeImpl(const char *buffer, int64_t length) { /////////////////////////////////////////////////////////////////////////////// bool UserFile::seek(int64_t offset, int whence /* = SEEK_SET */) { - assert(seekable()); + assertx(seekable()); // Seek within m_buffer if we can, otherwise kill it and call user stream_seek / stream_tell if (whence == SEEK_CUR && diff --git a/hphp/runtime/base/user-fs-node.cpp b/hphp/runtime/base/user-fs-node.cpp index 6c36f347d2e..35ddfedc8eb 100644 --- a/hphp/runtime/base/user-fs-node.cpp +++ b/hphp/runtime/base/user-fs-node.cpp @@ -107,7 +107,7 @@ Variant UserFSNode::invoke(const Func* func, const String& name, case LookupResult::MethodFoundNoThis: // Should never happen (Attr::Static check in ctor) - assert(false); + assertx(false); raise_error("%s::%s() must not be declared static", m_cls->name()->data(), name.data()); return uninit_null(); diff --git a/hphp/runtime/base/user-stream-wrapper.cpp b/hphp/runtime/base/user-stream-wrapper.cpp index f444de26d4f..bdcdbc10111 100644 --- a/hphp/runtime/base/user-stream-wrapper.cpp +++ b/hphp/runtime/base/user-stream-wrapper.cpp @@ -26,7 +26,7 @@ UserStreamWrapper::UserStreamWrapper(const String& name, : m_name(name) , m_cls(cls) { - assert(m_cls != nullptr); + assertx(m_cls != nullptr); m_isLocal = !(flags & k_STREAM_IS_URL); } diff --git a/hphp/runtime/base/utf8-decode.cpp b/hphp/runtime/base/utf8-decode.cpp index 9a4d472a9b2..bc3a929799c 100644 --- a/hphp/runtime/base/utf8-decode.cpp +++ b/hphp/runtime/base/utf8-decode.cpp @@ -46,7 +46,7 @@ unsigned int UTF8To16Decoder::getNextChar() { int pos = m_cursor; unsigned int this_char = 0; - assert(pos <= m_strlen); + assertx(pos <= m_strlen); if (!CHECK_LEN(pos, 1)) MB_FAILURE(pos, 1); diff --git a/hphp/runtime/base/variable-serializer.cpp b/hphp/runtime/base/variable-serializer.cpp index d6e2b4719b3..f7788c26514 100644 --- a/hphp/runtime/base/variable-serializer.cpp +++ b/hphp/runtime/base/variable-serializer.cpp @@ -100,7 +100,7 @@ VariableSerializer::getKind(const ArrayData* arr) const { if (arr->isDict()) return VariableSerializer::ArrayKind::Dict; if (arr->isVecArray()) return VariableSerializer::ArrayKind::Vec; if (arr->isKeyset()) return VariableSerializer::ArrayKind::Keyset; - assert(arr->isPHPArray()); + assertx(arr->isPHPArray()); if (m_keepDVArrays) { if (arr->isVArray()) return VariableSerializer::ArrayKind::VArray; if (arr->isDArray()) return VariableSerializer::ArrayKind::DArray; @@ -110,7 +110,7 @@ VariableSerializer::getKind(const ArrayData* arr) const { void VariableSerializer::pushObjectInfo(const String& objClass, int objId, char objCode) { - assert(objCode == 'O' || objCode == 'V' || objCode == 'K'); + assertx(objCode == 'O' || objCode == 'V' || objCode == 'K'); m_objectInfos.emplace_back( ObjectInfo { m_objClass, m_objId, m_objCode, m_rsrcName, m_rsrcId } ); @@ -184,7 +184,7 @@ String VariableSerializer::serializeWithLimit(const Variant& v, int limit) { if (m_type == Type::Serialize || m_type == Type::Internal || m_type == Type::JSON || m_type == Type::APCSerialize || m_type == Type::DebuggerSerialize) { - assert(false); + assertx(false); return String(); } StringBuffer buf; @@ -230,7 +230,7 @@ void VariableSerializer::write(bool v) { m_buf->append(v ? "b:1;" : "b:0;"); break; default: - assert(false); + assertx(false); break; } } @@ -267,7 +267,7 @@ void VariableSerializer::write(int64_t v) { m_buf->append(';'); break; default: - assert(false); + assertx(false); break; } } @@ -341,7 +341,7 @@ void VariableSerializer::write(double v) { m_buf->append(';'); break; default: - assert(false); + assertx(false); break; } } @@ -415,7 +415,7 @@ utf8_decode: sb.append("null", 4); break; } - assert(c >= 0); + assertx(c >= 0); unsigned short us = (unsigned short)c; switch (us) { case '"': @@ -593,7 +593,7 @@ void VariableSerializer::write(const char *v, int len /* = -1 */, break; } default: - assert(false); + assertx(false); break; } } @@ -617,7 +617,7 @@ void VariableSerializer::write(const Object& v) { if (!v.isNull() && m_type == Type::JSON) { if (v.instanceof(s_JsonSerializable)) { - assert(!v->isCollection()); + assertx(!v->isCollection()); Variant ret = v->o_invoke_few_args(s_jsonSerialize, 0); // for non objects or when $this is not returned if (!ret.isObject() || (ret.isObject() && !same(ret, v))) { @@ -708,7 +708,7 @@ void VariableSerializer::writeNull() { m_buf->append("null"); break; default: - assert(false); + assertx(false); break; } } @@ -747,7 +747,7 @@ void VariableSerializer::writeOverflow(const TypedValue& tv) { case Type::APCSerialize: { int optId = m_refs[tv].m_id; - assert(optId != NO_ID); + assertx(optId != NO_ID); bool isObject = tv.m_type == KindOfResource || tv.m_type == KindOfObject; if (wasRef) { m_buf->append("R:"); @@ -767,7 +767,7 @@ void VariableSerializer::writeOverflow(const TypedValue& tv) { m_buf->append("null"); break; default: - assert(false); + assertx(false); break; } } @@ -839,7 +839,7 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData, if (m_objCode == 'O') { m_buf->append("::__set_state(array(\n"); } else { - assert(m_objCode == 'V' || m_objCode == 'K'); + assertx(m_objCode == 'V' || m_objCode == 'K'); m_buf->append(" {\n"); } } else if (!m_rsrcName.empty()) { @@ -983,7 +983,7 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData, break; default: - assert(false); + assertx(false); break; } @@ -1002,7 +1002,7 @@ void VariableSerializer::writePropertyKey(const String& prop) { if (!*key && kl) { const char *cls = key + 1; if (*cls == '*') { - assert(key[2] == 0); + assertx(key[2] == 0); m_buf->append(key + 3, kl - 3); const char prot[] = "\":protected"; int o = m_type == Type::PrintR ? 1 : 0; @@ -1125,7 +1125,7 @@ void VariableSerializer::writeArrayKey( break; default: - assert(false); + assertx(false); break; } } @@ -1224,7 +1224,7 @@ void VariableSerializer::writeArrayFooter( if (m_objCode == 'O') { m_buf->append("))"); } else { - assert(m_objCode == 'V' || m_objCode == 'K'); + assertx(m_objCode == 'V' || m_objCode == 'K'); m_buf->append("}"); } } else if (m_rsrcName.empty()) { // for rsrc, only write NULL in arrayHeader @@ -1268,7 +1268,7 @@ void VariableSerializer::writeArrayFooter( } break; default: - assert(false); + assertx(false); break; } @@ -1339,7 +1339,7 @@ bool VariableSerializer::incNestedLevel(const TypedValue& tv) { } break; default: - assert(false); + assertx(false); break; } return false; @@ -1354,7 +1354,7 @@ void VariableSerializer::decNestedLevel(const TypedValue& tv) { } void VariableSerializer::serializeRef(const TypedValue* tv, bool isArrayKey) { - assert(tv->m_type == KindOfRef); + assertx(tv->m_type == KindOfRef); // Ugly, but behavior is different for serialize if (getType() == VariableSerializer::Type::Serialize || getType() == VariableSerializer::Type::Internal || @@ -1382,12 +1382,12 @@ void VariableSerializer::serializeVariant(const Variant& self, switch (tv->m_type) { case KindOfUninit: case KindOfNull: - assert(!isArrayKey); + assertx(!isArrayKey); writeNull(); return; case KindOfBoolean: - assert(!isArrayKey); + assertx(!isArrayKey); write(tv->m_data.num != 0); return; @@ -1407,39 +1407,39 @@ void VariableSerializer::serializeVariant(const Variant& self, case KindOfPersistentVec: case KindOfVec: - assert(!isArrayKey); - assert(tv->m_data.parr->isVecArray()); + assertx(!isArrayKey); + assertx(tv->m_data.parr->isVecArray()); serializeArray(tv->m_data.parr, skipNestCheck); return; case KindOfPersistentDict: case KindOfDict: - assert(!isArrayKey); - assert(tv->m_data.parr->isDict()); + assertx(!isArrayKey); + assertx(tv->m_data.parr->isDict()); serializeArray(tv->m_data.parr, skipNestCheck); return; case KindOfPersistentKeyset: case KindOfKeyset: - assert(!isArrayKey); - assert(tv->m_data.parr->isKeyset()); + assertx(!isArrayKey); + assertx(tv->m_data.parr->isKeyset()); serializeArray(tv->m_data.parr, skipNestCheck); return; case KindOfPersistentArray: case KindOfArray: - assert(!isArrayKey); - assert(tv->m_data.parr->isPHPArray()); + assertx(!isArrayKey); + assertx(tv->m_data.parr->isPHPArray()); serializeArray(tv->m_data.parr, skipNestCheck); return; case KindOfObject: - assert(!isArrayKey); + assertx(!isArrayKey); serializeObject(tv->m_data.pobj); return; case KindOfResource: - assert(!isArrayKey); + assertx(!isArrayKey); serializeResource(tv->m_data.pres->data()); return; @@ -1667,7 +1667,7 @@ void VariableSerializer::serializeObjectImpl(const ObjectData* obj) { type == VariableSerializer::Type::Internal || type == VariableSerializer::Type::APCSerialize)) { if (obj->instanceof(SystemLib::s_SerializableClass)) { - assert(!obj->isCollection()); + assertx(!obj->isCollection()); ret = const_cast(obj)->o_invoke_few_args(s_serialize, 0); if (ret.isString()) { @@ -1714,10 +1714,10 @@ void VariableSerializer::serializeObjectImpl(const ObjectData* obj) { } if (UNLIKELY(handleSleep)) { - assert(!obj->isCollection()); + assertx(!obj->isCollection()); if (ret.isArray()) { Array wanted = Array::Create(); - assert(isArrayType(ret.getRawType())); // can't be KindOfRef + assertx(isArrayType(ret.getRawType())); // can't be KindOfRef const Array &props = ret.asCArrRef(); for (ArrayIter iter(props); iter; ++iter) { String memberName = iter.second().toString(); diff --git a/hphp/runtime/base/variable-unserializer.cpp b/hphp/runtime/base/variable-unserializer.cpp index 9c26a9dc58d..bc81ce4e676 100644 --- a/hphp/runtime/base/variable-unserializer.cpp +++ b/hphp/runtime/base/variable-unserializer.cpp @@ -311,7 +311,7 @@ void VariableUnserializer::add(Variant* v, UnserializeMode mode) { } else if (mode == UnserializeMode::ColValue) { m_refs.emplace_back(RefInfo::makeColValue(v)); } else { - assert(mode == UnserializeMode::ColKey); + assertx(mode == UnserializeMode::ColKey); // We don't currently support using the 'R' encoding to refer to collection // keys. For now we encode collections keys in m_refs using a null pointer. m_refs.emplace_back(RefInfo(nullptr)); @@ -338,7 +338,7 @@ Variant* VariableUnserializer::getByRef(int id) { } else if (info.isVecValue()) { throwVecRefValue(); } else { - assert(info.isDictValue()); + assertx(info.isDictValue()); throwDictRefValue(); } } else if (checkHACRefBind()) { @@ -532,7 +532,7 @@ bool VariableUnserializer::matchString(folly::StringPiece str) { p += ss; if (*p++ != '\"') return false; if (*p++ != ';') return false; - assert(m_buf + total == p); + assertx(m_buf + total == p); m_buf = p; return true; } @@ -542,7 +542,7 @@ bool VariableUnserializer::matchString(folly::StringPiece str) { // remainingProps should include the current property being unserialized. void VariableUnserializer::unserializePropertyValue(Variant& v, int remainingProps) { - assert(remainingProps > 0); + assertx(remainingProps > 0); unserializeVariant(v); if (--remainingProps > 0) { auto lastChar = peekBack(); @@ -864,9 +864,9 @@ void VariableUnserializer::unserializeVariant( case 'S': if (this->type() == VariableUnserializer::Type::APCSerialize) { auto str = readStr(8); - assert(str.size() == 8); + assertx(str.size() == 8); auto sdp = reinterpret_cast(&str[0]); - assert((*sdp)->isStatic()); + assertx((*sdp)->isStatic()); tvMove(make_tv(*sdp), *self.asTypedValue()); } else { throwUnknownType(type); @@ -987,7 +987,7 @@ void VariableUnserializer::unserializeVariant( // without having it initialized completely. if (cls->instanceCtor() && !cls->isCppSerializable() && !cls->isCollectionClass()) { - assert(obj.isNull()); + assertx(obj.isNull()); throw_null_pointer_exception(); } else { if (UNLIKELY(collections::isType(cls, CollectionType::Pair))) { @@ -1007,7 +1007,7 @@ void VariableUnserializer::unserializeVariant( obj->setProp(nullptr, s_PHP_Incomplete_Class_Name.get(), clsName.asCell()); } - assert(!obj.isNull()); + assertx(!obj.isNull()); tvSet(make_tv(obj.get()), *self.asTypedValue()); if (size > 0) { @@ -1104,7 +1104,7 @@ void VariableUnserializer::unserializeVariant( clsName.data()); } } else { - assert(type == 'V' || type == 'K'); + assertx(type == 'V' || type == 'K'); if (!obj->isCollection()) { throwNotCollection(clsName); } @@ -1211,7 +1211,7 @@ Array VariableUnserializer::unserializeArray() { } // for apc, we know the key can't exist, but ignore that optimization - assert(type() != VariableUnserializer::Type::APCSerialize || + assertx(type() != VariableUnserializer::Type::APCSerialize || !arr.exists(key, true)); auto& value = [&]() -> decltype(auto) { @@ -1265,7 +1265,7 @@ Array VariableUnserializer::unserializeDict() { } // for apc, we know the key can't exist, but ignore that optimization - assert(type() != VariableUnserializer::Type::APCSerialize || + assertx(type() != VariableUnserializer::Type::APCSerialize || !arr.exists(key, true)); auto const lval = [&] { @@ -1447,7 +1447,7 @@ Array VariableUnserializer::unserializeDArray() { } // for apc, we know the key can't exist, but ignore that optimization - assert(type() != VariableUnserializer::Type::APCSerialize || + assertx(type() != VariableUnserializer::Type::APCSerialize || !arr.exists(key, true)); auto& value = [&]() -> decltype(auto) { @@ -1703,7 +1703,7 @@ void VariableUnserializer::unserializeSet(ObjectData* obj, int64_t sz, void VariableUnserializer::unserializePair(ObjectData* obj, int64_t sz, char type) { - assert(sz == 2); + assertx(sz == 2); if (type != 'V') throwBadFormat(obj, type); auto pair = static_cast(obj); unserializeVariant(tvAsVariant(pair->at(0)), UnserializeMode::ColValue); @@ -1752,7 +1752,7 @@ void VariableUnserializer::reserialize(StringBuffer& buf) { case 's': { String v = unserializeString(); - assert(!v.isNull()); + assertx(!v.isNull()); if (v.get()->isStatic()) { union { char pointer[8]; diff --git a/hphp/runtime/base/weakref-data.cpp b/hphp/runtime/base/weakref-data.cpp index 82dae3ec6aa..fa739c79a66 100644 --- a/hphp/runtime/base/weakref-data.cpp +++ b/hphp/runtime/base/weakref-data.cpp @@ -54,7 +54,7 @@ req::shared_ptr WeakRefData::forObject(Object obj) { if (!(weakmap->insert( {(uintptr_t)obj.get(), weak_data}).second)) { // Failure. Key should be unique. We just checked. - assert(false); + assertx(false); } } return wr_data; diff --git a/hphp/runtime/base/zend-collator.cpp b/hphp/runtime/base/zend-collator.cpp index 31ff13d3111..b0dbe1b9dd5 100644 --- a/hphp/runtime/base/zend-collator.cpp +++ b/hphp/runtime/base/zend-collator.cpp @@ -426,7 +426,7 @@ static int collator_regular_compare_function(const Variant& v1, const Variant& v num2 = collator_convert_string_to_number_if_possible(str2); } if (same(num1, false) || same(num2, false)) { - assert(data); + assertx(data); int ret = ucol_strcoll((const UCollator *)data, (UChar*)(str1.toString().data()), UCHARS(str1.toString().length()), @@ -517,7 +517,7 @@ static int collator_numeric_compare_descending(const Variant& v1, const Variant& static int collator_string_compare_function(const Variant& v1, const Variant& v2, const void *data, bool ascending) { - assert(data); + assertx(data); String str1; if (v1.isString()) { str1 = v1.toString(); @@ -562,7 +562,7 @@ static int collator_string_compare_descending(const Variant& v1, const Variant& static bool collator_sort_internal(bool renumber, Variant &array, int sort_flags, bool ascending, bool byKey, UCollator *coll, Intl::IntlError *errcode) { - assert(coll); + assertx(coll); errcode->clearError(); Array temp = array.toArray(); Array::PFUNC_CMP cmp_func; @@ -608,7 +608,7 @@ static bool collator_sort_internal(bool renumber, Variant &array, bool collator_sort(Variant &array, int sort_flags, bool ascending, UCollator *coll, Intl::IntlError *errcode) { - assert(coll); + assertx(coll); bool byKey = false; bool ret = collator_sort_internal(true, array, sort_flags, ascending, byKey, coll, errcode); @@ -617,7 +617,7 @@ bool collator_sort(Variant &array, int sort_flags, bool ascending, bool collator_asort(Variant &array, int sort_flags, bool ascending, UCollator *coll, Intl::IntlError *errcode) { - assert(coll); + assertx(coll); bool byKey = false; bool ret = collator_sort_internal(false, array, sort_flags, ascending, byKey, coll, errcode); diff --git a/hphp/runtime/base/zend-string.cpp b/hphp/runtime/base/zend-string.cpp index 98e8c576325..2e7e52157c8 100644 --- a/hphp/runtime/base/zend-string.cpp +++ b/hphp/runtime/base/zend-string.cpp @@ -234,8 +234,8 @@ int string_natural_cmp(char const *a, size_t a_len, /////////////////////////////////////////////////////////////////////////////// void string_to_case(String& s, int (*tocase)(int)) { - assert(!s.isNull()); - assert(tocase); + assertx(!s.isNull()); + assertx(tocase); auto data = s.mutableData(); auto len = s.size(); for (int i = 0; i < len; i++) { @@ -252,7 +252,7 @@ void string_to_case(String& s, int (*tocase)(int)) { String string_pad(const char *input, int len, int pad_length, const char *pad_string, int pad_str_len, int pad_type) { - assert(input); + assertx(input); int num_pad_chars = pad_length - len; /* If resulting string turns out to be shorter than input string, @@ -312,7 +312,7 @@ String string_pad(const char *input, int len, int pad_length, int string_find(const char *input, int len, char ch, int pos, bool case_sensitive) { - assert(input); + assertx(input); if (pos < 0 || pos > len) { return -1; } @@ -330,7 +330,7 @@ int string_find(const char *input, int len, char ch, int pos, int string_rfind(const char *input, int len, char ch, int pos, bool case_sensitive) { - assert(input); + assertx(input); if (pos < -len || pos > len) { return -1; } @@ -356,8 +356,8 @@ int string_rfind(const char *input, int len, char ch, int pos, int string_find(const char *input, int len, const char *s, int s_len, int pos, bool case_sensitive) { - assert(input); - assert(s); + assertx(input); + assertx(s); if (!s_len || pos < 0 || pos > len) { return -1; } @@ -375,8 +375,8 @@ int string_find(const char *input, int len, const char *s, int s_len, int string_rfind(const char *input, int len, const char *s, int s_len, int pos, bool case_sensitive) { - assert(input); - assert(s); + assertx(input); + assertx(s); if (!s_len || pos < -len || pos > len) { return -1; } @@ -422,9 +422,9 @@ const char *string_memnstr(const char *haystack, const char *needle, String string_replace(const char *s, int len, int start, int length, const char *replacement, int len_repl) { - assert(s); - assert(replacement); - assert(len >= 0); + assertx(s); + assertx(replacement); + assertx(len >= 0); // if "start" position is negative, count start position from the end // of the string @@ -480,11 +480,11 @@ String string_replace(const char *input, int len, const char *search, int len_search, const char *replacement, int len_replace, int &count, bool case_sensitive) { - assert(input); - assert(search && len_search); - assert(len >= 0); - assert(len_search >= 0); - assert(len_replace >= 0); + assertx(input); + assertx(search && len_search); + assertx(len >= 0); + assertx(len_search >= 0); + assertx(len_replace >= 0); if (len == 0) { return String(); @@ -696,8 +696,8 @@ String string_strip_tags(const char *s, const int len, int br, i=0, depth=0, in_q = 0; int state = 0, pos; - assert(s); - assert(allow); + assertx(s); + assertx(allow); String retString(s, len, CopyString); rbuf = retString.mutableData(); @@ -709,7 +709,7 @@ String string_strip_tags(const char *s, const int len, rp = rbuf; br = 0; if (allow_len) { - assert(allow); + assertx(allow); allowString = String(allow_len, ReserveString); char *atmp = allowString.mutableData(); @@ -1014,7 +1014,7 @@ String string_quoted_printable_encode(const char *input, int len) { } String string_quoted_printable_decode(const char *input, int len, bool is_q) { - assert(input); + assertx(input); if (len == 0) { return String(); } @@ -1079,7 +1079,7 @@ Variant string_base_to_numeric(const char *s, int len, int base) { int64_t cutoff; int cutlim; - assert(string_validate_base(base)); + assertx(string_validate_base(base)); cutoff = LONG_MAX / base; cutlim = LONG_MAX % base; @@ -1126,7 +1126,7 @@ String string_long_to_base(unsigned long value, int base) { char buf[(sizeof(unsigned long) << 3) + 1]; char *ptr, *end; - assert(string_validate_base(base)); + assertx(string_validate_base(base)); end = ptr = buf + sizeof(buf) - 1; @@ -1141,7 +1141,7 @@ String string_long_to_base(unsigned long value, int base) { String string_numeric_to_base(const Variant& value, int base) { static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz"; - assert(string_validate_base(base)); + assertx(string_validate_base(base)); if ((!value.isInteger() && !value.isDouble())) { return empty_string(); } @@ -1183,8 +1183,8 @@ String string_numeric_to_base(const Variant& value, int base) { (((c) - ' ') & 077) String string_uuencode(const char *src, int src_len) { - assert(src); - assert(src_len); + assertx(src); + assertx(src_len); int len = 45; char *p; @@ -1885,7 +1885,7 @@ String string_number_format(double d, int dec, /* Simple soundex algorithm as described by Knuth in TAOCP, vol 3 */ String string_soundex(const String& str) { - assert(!str.empty()); + assertx(!str.empty()); int _small, code, last; String retString(4, ReserveString); char* soundex = retString.mutableData(); @@ -2578,7 +2578,7 @@ String string_convert_cyrillic_string(const String& input, char from, char to) { String string_convert_hebrew_string(const String& inStr, int /*max_chars_per_line*/, int convert_newlines) { - assert(!inStr.empty()); + assertx(!inStr.empty()); auto str = inStr.data(); auto str_len = inStr.size(); const char *tmp; diff --git a/hphp/runtime/base/zend-url.cpp b/hphp/runtime/base/zend-url.cpp index df7939e2aef..24f887a8d0e 100644 --- a/hphp/runtime/base/zend-url.cpp +++ b/hphp/runtime/base/zend-url.cpp @@ -353,7 +353,7 @@ String url_decode(const char *s, size_t len) { } size_t url_decode_ex(char *value, size_t len) { - assert(value && *value); // check before calling this function + assertx(value && *value); // check before calling this function if (len == 0) return 0; size_t i = 0, o = 0; diff --git a/hphp/runtime/debugger/break_point.cpp b/hphp/runtime/debugger/break_point.cpp index 74ede664e17..216b55de389 100644 --- a/hphp/runtime/debugger/break_point.cpp +++ b/hphp/runtime/debugger/break_point.cpp @@ -131,7 +131,7 @@ void InterruptSite::Initialize(ActRec *fp) { TRACE(2, "InterruptSite::Initialize\n"); #define bail_on(c) if (c) { return; } - assert(fp); + assertx(fp); m_activationRecord = fp; bail_on(!fp->m_func); m_unit = fp->m_func->unit(); @@ -181,7 +181,7 @@ const char *BreakPointInfo::GetInterruptName(InterruptType interrupt) { case RequestEnded: return "end of request or start of psp"; case PSPEnded: return "end of psp"; default: - assert(false); + assertx(false); break; } return nullptr; @@ -215,7 +215,7 @@ BreakPointInfo::BreakPointInfo(bool regex, State state, m_line1(0), m_line2(0), m_regex(regex), m_check(false) { TRACE(2, "BreakPointInfo::BreakPointInfo..const std::string &file)\n"); - assert(m_interruptType != ExceptionHandler); // Server-side only. + assertx(m_interruptType != ExceptionHandler); // Server-side only. if (m_interruptType == ExceptionThrown) { parseExceptionThrown(exp); } else { @@ -337,7 +337,7 @@ void BreakPointInfo::toggle() { case Once: setState(Disabled); break; case Disabled: setState(Always); break; default: - assert(false); + assertx(false); break; } } @@ -434,7 +434,7 @@ std::string BreakPointInfo::state(bool padding) const { case Once: return padding ? "ONCE " : "ONCE" ; case Disabled: return padding ? "DISABLED" : "DISABLED"; default: - assert(false); + assertx(false); break; } return ""; @@ -634,7 +634,7 @@ void mangleXhpName(const std::string &source, std::string &target) { int32_t scanName(const std::string &str, int32_t offset) { auto len = str.length(); - assert(0 <= offset && offset <= len); + assertx(0 <= offset && offset <= len); while (offset < len) { char ch = str[offset]; if (ch == ':' || ch == '\\' || ch == ',' || ch == '(' || ch == '=' || @@ -660,7 +660,7 @@ int32_t scanName(const std::string &str, int32_t offset) { int32_t scanNumber(const std::string &str, int32_t offset, int32_t& value) { value = 0; auto len = str.length(); - assert(0 <= offset && offset < len); + assertx(0 <= offset && offset < len); while (offset < len) { char ch = str[offset]; if (ch < '0' || ch > '9') return offset; @@ -673,7 +673,7 @@ int32_t scanNumber(const std::string &str, int32_t offset, int32_t& value) { int32_t BreakPointInfo::parseFileLocation(const std::string &str, int32_t offset) { auto len = str.length(); - assert(0 <= offset && offset < len); + assertx(0 <= offset && offset < len); auto offset1 = scanNumber(str, offset, m_line1); if (offset1 == offset) return offset; //Did not find a number m_line2 = m_line1; //so that we always have a range @@ -1003,7 +1003,7 @@ bool BreakPointInfo::Match(const char *haystack, int haystack_len, bool BreakPointInfo::checkExceptionOrError(const Variant& e) { TRACE(2, "BreakPointInfo::checkException\n"); - assert(!e.isNull()); + assertx(!e.isNull()); if (e.isObject()) { if (m_regex) { return Match(m_class.c_str(), m_class.size(), @@ -1033,7 +1033,7 @@ bool BreakPointInfo::checkUrl(std::string &url) { bool BreakPointInfo::checkLines(int line) { TRACE(2, "BreakPointInfo::checkLines\n"); if (m_line1) { - assert(m_line2 == -1 || m_line2 >= m_line1); + assertx(m_line2 == -1 || m_line2 >= m_line1); return line >= m_line1 && (m_line2 == -1 || line <= m_line2); } return true; diff --git a/hphp/runtime/debugger/cmd/cmd_break.cpp b/hphp/runtime/debugger/cmd/cmd_break.cpp index e16166319c7..80ab49de7a0 100644 --- a/hphp/runtime/debugger/cmd/cmd_break.cpp +++ b/hphp/runtime/debugger/cmd/cmd_break.cpp @@ -65,7 +65,7 @@ void CmdBreak::sendImpl(DebuggerThriftBuffer& thrift) { // m_breakpoints is initially set to the breakpoints collection of the // client (in validate, which indirectly calls sendImpl). When received // via Thrift, m_breakpoints points to a copy that is placed in m_bps. - assert(m_breakpoints); + assertx(m_breakpoints); DebuggerCommand::sendImpl(thrift); BreakPointInfo::SendImpl(this->m_version, *m_breakpoints, thrift); } @@ -299,7 +299,7 @@ void CmdBreak::processStatusChange(DebuggerClient& client) { action = "updated"; bp->setState(BreakPointInfo::Disabled); } else { - assert(hasToggleArg(client)); + assertx(hasToggleArg(client)); action = "updated"; bp->toggle(); } @@ -335,7 +335,7 @@ void CmdBreak::processStatusChange(DebuggerClient& client) { bpi->setState(BreakPointInfo::Disabled); } else { - assert(hasToggleArg(client)); + assertx(hasToggleArg(client)); bpi->toggle(); } } @@ -386,7 +386,7 @@ void CmdBreak::processStatusChange(DebuggerClient& client) { client.info("Breakpoint %d's state is changed to %s.", bpi->index(), bpi->state(false).c_str()); } else { - assert(hasToggleArg(client)); + assertx(hasToggleArg(client)); bpi->toggle(); updateServer(client); client.info("Breakpoint %d's state is changed to %s.", bpi->index(), @@ -410,7 +410,7 @@ void CmdBreak::updateServer(DebuggerClient& client) { auto& cbreakpoints = *client.getBreakPoints(); auto& sbreakpoints = *serverReply->m_breakpoints; auto const csize = cbreakpoints.size(); - assert(csize == sbreakpoints.size()); + assertx(csize == sbreakpoints.size()); for (size_t i = 0; i < csize; ++i) { cbreakpoints[i]->m_bindState = sbreakpoints[i]->m_bindState; } diff --git a/hphp/runtime/debugger/cmd/cmd_complete.cpp b/hphp/runtime/debugger/cmd/cmd_complete.cpp index 121d634e89e..6dc2e9bbd4d 100644 --- a/hphp/runtime/debugger/cmd/cmd_complete.cpp +++ b/hphp/runtime/debugger/cmd/cmd_complete.cpp @@ -54,7 +54,7 @@ void CmdComplete::onClient(DebuggerClient &client) { } bool CmdComplete::onServer(DebuggerProxy& /*proxy*/) { - assert(false); // this command is processed entirely locally + assertx(false); // this command is processed entirely locally return false; } diff --git a/hphp/runtime/debugger/cmd/cmd_constant.cpp b/hphp/runtime/debugger/cmd/cmd_constant.cpp index 54c0774e3de..ba1cbde7503 100644 --- a/hphp/runtime/debugger/cmd/cmd_constant.cpp +++ b/hphp/runtime/debugger/cmd/cmd_constant.cpp @@ -70,7 +70,7 @@ void CmdConstant::onClient(DebuggerClient &client) { { Variant forSort(cmd->m_constants); HHVM_FN(ksort)(ref(forSort)); - assert(forSort.isArray()); + assertx(forSort.isArray()); m_constants = forSort.asCell()->m_data.parr; } diff --git a/hphp/runtime/debugger/cmd/cmd_continue.cpp b/hphp/runtime/debugger/cmd/cmd_continue.cpp index 1f0aabaac51..2ecfaf71b21 100644 --- a/hphp/runtime/debugger/cmd/cmd_continue.cpp +++ b/hphp/runtime/debugger/cmd/cmd_continue.cpp @@ -37,7 +37,7 @@ void CmdContinue::help(DebuggerClient &client) { void CmdContinue::onSetup(DebuggerProxy& /*proxy*/, CmdInterrupt& /*interrupt*/) { - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. // If there's a remaining count on this cmd then we want it left installed // in the proxy. m_complete = (decCount() == 0); @@ -45,7 +45,7 @@ void CmdContinue::onSetup(DebuggerProxy& /*proxy*/, void CmdContinue::onBeginInterrupt(DebuggerProxy& /*proxy*/, CmdInterrupt& /*interrupt*/) { - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. m_complete = (decCount() == 0); } diff --git a/hphp/runtime/debugger/cmd/cmd_eval.cpp b/hphp/runtime/debugger/cmd/cmd_eval.cpp index a441073614a..5adda3809e5 100644 --- a/hphp/runtime/debugger/cmd/cmd_eval.cpp +++ b/hphp/runtime/debugger/cmd/cmd_eval.cpp @@ -54,7 +54,7 @@ void CmdEval::onClient(DebuggerClient &client) { m_frame = client.getFrame(); m_bypassAccessCheck = client.getDebuggerClientBypassCheck(); auto res = client.xendWithNestedExecution(this); - assert(res->is(DebuggerCommand::KindOfEval)); + assertx(res->is(DebuggerCommand::KindOfEval)); auto eval = std::static_pointer_cast(res); eval->handleReply(client); m_failed = eval->m_failed; diff --git a/hphp/runtime/debugger/cmd/cmd_extended.cpp b/hphp/runtime/debugger/cmd/cmd_extended.cpp index ed0953b935f..3032a32581f 100644 --- a/hphp/runtime/debugger/cmd/cmd_extended.cpp +++ b/hphp/runtime/debugger/cmd/cmd_extended.cpp @@ -168,7 +168,7 @@ bool CmdExtended::invokeClient(DebuggerClient &client, const std::string &cls) { } bool CmdExtended::onServer(DebuggerProxy& /*proxy*/) { - assert(false); + assertx(false); return false; } diff --git a/hphp/runtime/debugger/cmd/cmd_extension.cpp b/hphp/runtime/debugger/cmd/cmd_extension.cpp index 3777cfc3ae0..91c80901144 100644 --- a/hphp/runtime/debugger/cmd/cmd_extension.cpp +++ b/hphp/runtime/debugger/cmd/cmd_extension.cpp @@ -101,7 +101,7 @@ bool CmdExtension::processList(DebuggerProxy &proxy) { } for (auto const& name : names) { auto ext = ExtensionRegistry::get(name); - assert(ext); + assertx(ext); if (ext) { int support = ext->debuggerSupport(); std::string line; diff --git a/hphp/runtime/debugger/cmd/cmd_flow_control.cpp b/hphp/runtime/debugger/cmd/cmd_flow_control.cpp index 947195ee695..d951eda444d 100644 --- a/hphp/runtime/debugger/cmd/cmd_flow_control.cpp +++ b/hphp/runtime/debugger/cmd/cmd_flow_control.cpp @@ -144,7 +144,7 @@ bool CmdFlowControl::atStepOutOffset(Unit* unit, Offset o) { // destination(s) of such instructions. void CmdFlowControl::setupStepOuts() { // Existing step outs should be cleaned up before making new ones. - assert(!hasStepOuts()); + assertx(!hasStepOuts()); auto fp = vmfp(); if (!fp) return; // No place to step out to! Offset returnOffset; @@ -168,7 +168,7 @@ void CmdFlowControl::setupStepOuts() { // We only execute this for opcodes which invoke more PHP, and that does // not include switches. Thus, we'll have at most two destinations. auto const retOp = peek_op(returnPC); - assert(!isSwitch(retOp) && numSuccs(returnPC) <= 2); + assertx(!isSwitch(retOp) && numSuccs(returnPC) <= 2); // Set an internal breakpoint after the instruction if it can fall thru. if (instrAllowsFallThru(retOp)) { Offset nextOffset = returnOffset + instrLen(returnPC); diff --git a/hphp/runtime/debugger/cmd/cmd_flow_control.h b/hphp/runtime/debugger/cmd/cmd_flow_control.h index b9901be7910..4bd55d3dc0a 100644 --- a/hphp/runtime/debugger/cmd/cmd_flow_control.h +++ b/hphp/runtime/debugger/cmd/cmd_flow_control.h @@ -85,12 +85,12 @@ protected: void recvImpl(DebuggerThriftBuffer&) override; int decCount() { - assert(m_count > 0); + assertx(m_count > 0); return --m_count; } int getCount() const { - assert(m_count > 0); + assertx(m_count > 0); return m_count; } diff --git a/hphp/runtime/debugger/cmd/cmd_info.cpp b/hphp/runtime/debugger/cmd/cmd_info.cpp index e282c801e3f..d1b3a5ad060 100644 --- a/hphp/runtime/debugger/cmd/cmd_info.cpp +++ b/hphp/runtime/debugger/cmd/cmd_info.cpp @@ -127,7 +127,7 @@ void CmdInfo::help(DebuggerClient &client) { } bool CmdInfo::parseZeroArg(DebuggerClient &client) { - assert(client.argCount() == 0); + assertx(client.argCount() == 0); BreakPointInfoPtr bpi = client.getCurrentLocation(); if (bpi) { m_symbol = bpi->getClass(); @@ -141,7 +141,7 @@ bool CmdInfo::parseZeroArg(DebuggerClient &client) { } void CmdInfo::parseOneArg(DebuggerClient &client, std::string &subsymbol) { - assert(client.argCount() == 1); + assertx(client.argCount() == 1); string symbol = client.argValue(1); size_t pos = symbol.find("::"); if (pos != string::npos) { diff --git a/hphp/runtime/debugger/cmd/cmd_interrupt.cpp b/hphp/runtime/debugger/cmd/cmd_interrupt.cpp index f05334ed2a7..f36911f94c3 100644 --- a/hphp/runtime/debugger/cmd/cmd_interrupt.cpp +++ b/hphp/runtime/debugger/cmd/cmd_interrupt.cpp @@ -31,7 +31,7 @@ TRACE_SET_MOD(debugger); void CmdInterrupt::sendImpl(DebuggerThriftBuffer &thrift) { DebuggerCommand::sendImpl(thrift); - assert(m_interrupt != ExceptionHandler); // Server-side only. + assertx(m_interrupt != ExceptionHandler); // Server-side only. thrift.write(m_interrupt); thrift.write(m_program); thrift.write(m_errorMsg); @@ -124,7 +124,7 @@ std::string CmdInterrupt::desc() const { case HardBreakPoint: case BreakPointReached: case ExceptionThrown: { - assert(m_site); + assertx(m_site); if (m_site) { return m_site->desc(); } @@ -132,7 +132,7 @@ std::string CmdInterrupt::desc() const { } } - assert(false); + assertx(false); return ""; } @@ -298,7 +298,7 @@ bool CmdInterrupt::shouldBreak(DebuggerProxy &proxy, case ExceptionHandler: return false; // For flow control only at this time. } - assert(false); + assertx(false); return false; } diff --git a/hphp/runtime/debugger/cmd/cmd_list.cpp b/hphp/runtime/debugger/cmd/cmd_list.cpp index 7c1281ed677..7514b790261 100644 --- a/hphp/runtime/debugger/cmd/cmd_list.cpp +++ b/hphp/runtime/debugger/cmd/cmd_list.cpp @@ -125,7 +125,7 @@ void CmdList::getListLocation(DebuggerClient &client, int &lineFocus0, // or give an error message if the debugger is not currently performing // an eval command. void CmdList::listEvalCode(DebuggerClient &client) { - assert(m_file.empty()); + assertx(m_file.empty()); std::string evalCode = client.getCode(); if (evalCode.empty()) { @@ -176,7 +176,7 @@ const StaticString // Returns false if the server was unable to return the information // needed for this command. bool CmdList::listFunctionOrClass(DebuggerClient &client) { - assert(client.argCount() == 1); + assertx(client.argCount() == 1); auto cmdInfo = std::make_shared(); std::string subsymbol; cmdInfo->parseOneArg(client, subsymbol); diff --git a/hphp/runtime/debugger/cmd/cmd_next.cpp b/hphp/runtime/debugger/cmd/cmd_next.cpp index 339f019837b..3810724cc14 100644 --- a/hphp/runtime/debugger/cmd/cmd_next.cpp +++ b/hphp/runtime/debugger/cmd/cmd_next.cpp @@ -43,7 +43,7 @@ void CmdNext::help(DebuggerClient& client) { void CmdNext::onSetup(DebuggerProxy& proxy, CmdInterrupt& interrupt) { TRACE(2, "CmdNext::onSetup\n"); - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. m_stackDepth = proxy.getStackDepth(); m_vmDepth = g_context->m_nesting; m_loc = interrupt.getFileLine(); @@ -59,7 +59,7 @@ void CmdNext::onSetup(DebuggerProxy& proxy, CmdInterrupt& interrupt) { void CmdNext::onBeginInterrupt(DebuggerProxy& proxy, CmdInterrupt& interrupt) { TRACE(2, "CmdNext::onBeginInterrupt\n"); - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. ActRec *fp = vmfp(); if (!fp) { @@ -211,7 +211,7 @@ void CmdNext::stepCurrentLine(CmdInterrupt& interrupt, ActRec* fp, PC pc) { // stepping over an await, we land on the next statement. auto const op = peek_op(pc); if (op == OpAwait) { - assert(fp->func()->isAsync()); + assertx(fp->func()->isAsync()); auto wh = c_Awaitable::fromCell(*vmsp()); if (wh && !wh->isFinished()) { TRACE(2, "CmdNext: encountered blocking await\n"); @@ -223,7 +223,7 @@ void CmdNext::stepCurrentLine(CmdInterrupt& interrupt, ActRec* fp, PC pc) { // functions. We need to step over this opcode, then grab the created // AsyncFunctionWaitHandle and setup stepping like we do for // OpAwait. - assert(fp->func()->isAsyncFunction()); + assertx(fp->func()->isAsyncFunction()); m_skippingAwait = true; m_needsVMInterrupt = true; removeLocationFilter(); @@ -231,15 +231,15 @@ void CmdNext::stepCurrentLine(CmdInterrupt& interrupt, ActRec* fp, PC pc) { return; } } else if (op == OpYield || op == OpYieldK) { - assert(fp->resumed()); - assert(fp->func()->isGenerator()); + assertx(fp->resumed()); + assertx(fp->func()->isGenerator()); TRACE(2, "CmdNext: encountered yield from generator\n"); setupStepOuts(); setupStepSuspend(fp, pc); removeLocationFilter(); return; } else if (op == OpRetC && fp->resumed()) { - assert(fp->func()->isResumable()); + assertx(fp->func()->isResumable()); TRACE(2, "CmdNext: encountered return from resumed resumable\n"); setupStepOuts(); removeLocationFilter(); @@ -264,12 +264,12 @@ bool CmdNext::atStepResumableOffset(Unit* unit, Offset o) { void CmdNext::setupStepSuspend(ActRec* fp, PC pc) { // Yield is followed by the label where execution will continue. auto const op = decode_op(pc); - assert(op == OpAwait || op == OpYield || op == OpYieldK); + assertx(op == OpAwait || op == OpYield || op == OpYieldK); if (op == OpAwait) { decode_iva(pc); } Offset nextInst = fp->func()->unit()->offsetOf(pc); - assert(nextInst != InvalidAbsoluteOffset); + assertx(nextInst != InvalidAbsoluteOffset); m_stepResumableId = fp; TRACE(2, "CmdNext: patch for resumable step at '%s' offset %d\n", fp->m_func->fullName()->data(), nextInst); @@ -284,11 +284,11 @@ void CmdNext::setupStepSuspend(ActRec* fp, PC pc) { // where execution will resume. void CmdNext::stepAfterAwait() { auto topObj = vmsp()->m_data.pobj; - assert(topObj->instanceof(c_AsyncFunctionWaitHandle::classof())); + assertx(topObj->instanceof(c_AsyncFunctionWaitHandle::classof())); auto wh = static_cast(topObj); auto func = wh->actRec()->func(); Offset nextInst = wh->getNextExecutionOffset(); - assert(nextInst != InvalidAbsoluteOffset); + assertx(nextInst != InvalidAbsoluteOffset); m_stepResumableId = wh->actRec(); TRACE(2, "CmdNext: patch for cont step after Await at '%s' offset %d\n", @@ -309,8 +309,8 @@ void CmdNext::cleanupStepResumable() { // resumable, or we'll stop when we get back into it, we know the object // will remain alive. void* CmdNext::getResumableId(ActRec* fp) { - assert(fp->resumed()); - assert(fp->func()->isResumable()); + assertx(fp->resumed()); + assertx(fp->func()->isResumable()); TRACE(2, "CmdNext: resumable tag %p for %s\n", fp, fp->func()->name()->data()); return fp; diff --git a/hphp/runtime/debugger/cmd/cmd_out.cpp b/hphp/runtime/debugger/cmd/cmd_out.cpp index 6157f06f5b4..bb7a6fe57ef 100644 --- a/hphp/runtime/debugger/cmd/cmd_out.cpp +++ b/hphp/runtime/debugger/cmd/cmd_out.cpp @@ -40,7 +40,7 @@ void CmdOut::help(DebuggerClient &client) { void CmdOut::onSetup(DebuggerProxy& proxy, CmdInterrupt& /*interrupt*/) { TRACE(2, "CmdOut::onSetup\n"); - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. m_stackDepth = proxy.getStackDepth(); m_vmDepth = g_context->m_nesting; @@ -50,7 +50,7 @@ void CmdOut::onSetup(DebuggerProxy& proxy, CmdInterrupt& /*interrupt*/) { void CmdOut::onBeginInterrupt(DebuggerProxy &proxy, CmdInterrupt &interrupt) { TRACE(2, "CmdOut::onBeginInterrupt\n"); - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. m_needsVMInterrupt = false; diff --git a/hphp/runtime/debugger/cmd/cmd_print.cpp b/hphp/runtime/debugger/cmd/cmd_print.cpp index 50871e037c3..3962b5b79d1 100644 --- a/hphp/runtime/debugger/cmd/cmd_print.cpp +++ b/hphp/runtime/debugger/cmd/cmd_print.cpp @@ -91,7 +91,7 @@ std::string CmdPrint::FormatResult(const char* format, const Variant& ret) { return sb.data(); } - assert(false); + assertx(false); } String sret = DebuggerClient::FormatVariable(ret); @@ -124,7 +124,7 @@ std::string CmdPrint::FormatResult(const char* format, const Variant& ret) { return String(ts).data(); } - assert(false); + assertx(false); return ""; } @@ -157,7 +157,7 @@ void CmdPrint::recvImpl(DebuggerThriftBuffer &thrift) { thrift.read(sdata); auto const error = DebuggerWireHelpers::WireUnserialize(sdata, m_ret); if (error == DebuggerWireHelpers::ErrorMsg) { - assert(m_ret.isString()); + assertx(m_ret.isString()); m_wireError = m_ret.toCStrRef().data(); } if (error != DebuggerWireHelpers::NoError) { @@ -329,7 +329,7 @@ void CmdPrint::onClient(DebuggerClient &client) { } m_bypassAccessCheck = client.getDebuggerClientBypassCheck(); m_printLevel = client.getDebuggerClientPrintLevel(); - assert(m_printLevel <= 0 || m_printLevel >= DebuggerClient::MinPrintLevel); + assertx(m_printLevel <= 0 || m_printLevel >= DebuggerClient::MinPrintLevel); m_frame = client.getFrame(); auto res = client.xendWithNestedExecution(this); m_output = res->m_output; diff --git a/hphp/runtime/debugger/cmd/cmd_step.cpp b/hphp/runtime/debugger/cmd/cmd_step.cpp index 91e156851d0..30c34fb8718 100644 --- a/hphp/runtime/debugger/cmd/cmd_step.cpp +++ b/hphp/runtime/debugger/cmd/cmd_step.cpp @@ -36,7 +36,7 @@ void CmdStep::help(DebuggerClient &client) { } void CmdStep::onSetup(DebuggerProxy& /*proxy*/, CmdInterrupt& interrupt) { - assert(!m_complete); // Complete cmds should not be asked to do work. + assertx(!m_complete); // Complete cmds should not be asked to do work. installLocationFilterForLine(interrupt.getSite()); m_needsVMInterrupt = true; } diff --git a/hphp/runtime/debugger/cmd/cmd_thread.cpp b/hphp/runtime/debugger/cmd/cmd_thread.cpp index aced3322f3e..a2bec8ec10c 100644 --- a/hphp/runtime/debugger/cmd/cmd_thread.cpp +++ b/hphp/runtime/debugger/cmd/cmd_thread.cpp @@ -222,7 +222,7 @@ bool CmdThread::onServer(DebuggerProxy &proxy) { return true; } - assert(false); + assertx(false); return false; } diff --git a/hphp/runtime/debugger/cmd/cmd_variable.cpp b/hphp/runtime/debugger/cmd/cmd_variable.cpp index 7e01315b098..0ded813082e 100644 --- a/hphp/runtime/debugger/cmd/cmd_variable.cpp +++ b/hphp/runtime/debugger/cmd/cmd_variable.cpp @@ -118,9 +118,9 @@ void CmdVariable::PrintVariable(DebuggerClient &client, const String& varName) { } auto const get_var = [varName] (const CmdVariable& cmd) { - assert(cmd.m_variables.size() == 1); - assert(cmd.m_variables.exists(varName, true /* isKey */)); - assert(cmd.m_variables[varName].isString()); + assertx(cmd.m_variables.size() == 1); + assertx(cmd.m_variables.exists(varName, true /* isKey */)); + assertx(cmd.m_variables[varName].isString()); return cmd.m_variables[varName].toString(); }; @@ -175,7 +175,7 @@ void CmdVariable::PrintVariables(DebuggerClient &client, const Array& variables, cmd.m_version = 2; auto rcmd = client.xend(&cmd); if (!rcmd->m_variables.empty()) { - assert(rcmd->m_variables[name].isString()); + assertx(rcmd->m_variables[name].isString()); value = rcmd->m_variables[name].toString(); found = true; } else if (text.empty()) { @@ -284,7 +284,7 @@ bool CmdVariable::onServer(DebuggerProxy &proxy) { ArrayInit ret(m_variables->size(), ArrayInit::Map{}); Variant v; for (ArrayIter iter(m_variables); iter; ++iter) { - assert(iter.first().isString()); + assertx(iter.first().isString()); ret.add(iter.first().toString(), v); } m_variables = ret.toArray(); diff --git a/hphp/runtime/debugger/debugger.cpp b/hphp/runtime/debugger/debugger.cpp index 054f1bdc538..7cf92bd3e79 100644 --- a/hphp/runtime/debugger/debugger.cpp +++ b/hphp/runtime/debugger/debugger.cpp @@ -245,7 +245,7 @@ void Debugger::InterruptPSPEnded(const char *url) { void Debugger::Interrupt(int type, const char *program, InterruptSite *site /* = NULL */, const char *error /* = NULL */) { - assert(RuntimeOption::EnableHphpdDebugger); + assertx(RuntimeOption::EnableHphpdDebugger); TRACE_RB(2, "Debugger::Interrupt type %d\n", type); DebuggerProxyPtr proxy = GetProxy(); @@ -425,7 +425,7 @@ void Debugger::unregisterSandbox(const StringData* sandboxId) { if (m_sandboxThreadInfoMap.find(acc, sid)) { \ auto const& set = acc->second; \ for (auto ti : set) { \ - assert(ThreadInfo::valid(ti)); \ + assertx(ThreadInfo::valid(ti)); \ #define FOREACH_SANDBOX_THREAD_END() } } } \ @@ -481,7 +481,7 @@ DebuggerProxyPtr Debugger::createProxy(req::ptr socket, bool local) { // dummy sandbox thread needs to interrupt. const StringData* sid = makeStaticString(proxy->getDummyInfo().id()); - assert(sid); + assertx(sid); ProxyMap::accessor acc; m_proxyMap.insert(acc, sid); acc->second = proxy; diff --git a/hphp/runtime/debugger/debugger_client.cpp b/hphp/runtime/debugger/debugger_client.cpp index 377625fa61e..ffeabcf21fe 100644 --- a/hphp/runtime/debugger/debugger_client.cpp +++ b/hphp/runtime/debugger/debugger_client.cpp @@ -445,7 +445,7 @@ String DebuggerClient::FormatVariable( } catch (const StringBufferLimitException& e) { value = "Serialization limit reached"; } catch (...) { - assert(false); + assertx(false); throw; } return value; @@ -456,7 +456,7 @@ String DebuggerClient::FormatVariable( * truncated result, and the number of bytes truncated. */ String DebuggerClient::FormatVariableWithLimit(const Variant& v, int maxlen) { - assert(maxlen >= 0); + assertx(maxlen >= 0); VariableSerializer vs(VariableSerializer::Type::DebuggerDump, 0, 2); auto const value = vs.serializeWithLimit(v, maxlen + 1); @@ -553,7 +553,7 @@ bool DebuggerClient::isLocal() { bool DebuggerClient::connect(const std::string &host, int port) { TRACE(2, "DebuggerClient::connect\n"); - assert((!m_machines.empty() && m_machines[0]->m_name == LocalPrompt)); + assertx((!m_machines.empty() && m_machines[0]->m_name == LocalPrompt)); // First check for an existing connect, and reuse that. for (unsigned int i = 1; i < m_machines.size(); i++) { if (HHVM_FN(gethostbyname)(m_machines[i]->m_name) == @@ -567,9 +567,9 @@ bool DebuggerClient::connect(const std::string &host, int port) { bool DebuggerClient::connectRPC(const std::string &host, int port) { TRACE(2, "DebuggerClient::connectRPC\n"); - assert(!m_machines.empty()); + assertx(!m_machines.empty()); auto local = m_machines[0]; - assert(local->m_name == LocalPrompt); + assertx(local->m_name == LocalPrompt); local->m_rpcHost = host; local->m_rpcPort = port; switchMachine(local); @@ -580,9 +580,9 @@ bool DebuggerClient::connectRPC(const std::string &host, int port) { bool DebuggerClient::disconnect() { TRACE(2, "DebuggerClient::disconnect\n"); - assert(!m_machines.empty()); + assertx(!m_machines.empty()); auto local = m_machines[0]; - assert(local->m_name == LocalPrompt); + assertx(local->m_name == LocalPrompt); local->m_rpcHost.clear(); local->m_rpcPort = 0; switchMachine(local); @@ -624,7 +624,7 @@ req::ptr DebuggerClient::connectLocal() { machine->m_sandboxAttached = true; machine->m_name = LocalPrompt; machine->m_thrift.create(socket1); - assert(m_machines.empty()); + assertx(m_machines.empty()); m_machines.push_back(machine); switchMachine(machine); return socket2; @@ -646,7 +646,7 @@ bool DebuggerClient::connectRemote(const std::string &host, int port) { bool DebuggerClient::reconnect() { TRACE(2, "DebuggerClient::reconnect\n"); - assert(m_machine); + assertx(m_machine); auto& host = m_machine->m_name; int port = m_machine->m_port; if (port <= 0) { @@ -1044,7 +1044,7 @@ char* DebuggerClient::getCompletion(const char* text, int state) { } } } else { - assert(m_inputState == TakingCode); + assertx(m_inputState == TakingCode); if (!*rl_line_buffer) { addCompletion("?>"); // so we tab, we're done } else { @@ -1061,7 +1061,7 @@ char* DebuggerClient::getCompletion(const char* text, int state) { } else if ((int64_t)list >= 0 && (int64_t)list < AutoCompleteCount) { if (m_acLiveListsDirty) { updateLiveLists(); - assert(!m_acLiveListsDirty); + assertx(!m_acLiveListsDirty); } char *p = getCompletion(m_acLiveLists->get(int64_t(list)), text); if (p) return p; @@ -1873,7 +1873,7 @@ bool DebuggerClient::parse(const char *line) { bool DebuggerClient::match(const char *cmd) { TRACE(2, "DebuggerClient::match\n"); - assert(cmd && *cmd); + assertx(cmd && *cmd); return !strncasecmp(m_command.c_str(), cmd, m_command.size()); } @@ -1884,8 +1884,8 @@ bool DebuggerClient::Match(const char *input, const char *cmd) { bool DebuggerClient::arg(int index, const char *s) const { TRACE(2, "DebuggerClient::arg\n"); - assert(s && *s); - assert(index > 0); + assertx(s && *s); + assertx(index > 0); --index; return (int)m_args.size() > index && !strncasecmp(m_args[index].c_str(), s, m_args[index].size()); @@ -1893,7 +1893,7 @@ bool DebuggerClient::arg(int index, const char *s) const { std::string DebuggerClient::argValue(int index) { TRACE(2, "DebuggerClient::argValue\n"); - assert(index > 0); + assertx(index > 0); --index; if (index >= 0 && index < (int)m_args.size()) { return m_args[index]; @@ -1903,7 +1903,7 @@ std::string DebuggerClient::argValue(int index) { std::string DebuggerClient::lineRest(int index) { TRACE(2, "DebuggerClient::lineRest\n"); - assert(index > 0); + assertx(index > 0); return m_line.substr(m_argIdx[index - 1] + 1); } @@ -1950,7 +1950,7 @@ const StaticString s_UNDERSCORE("_"); // and carries out the command. void DebuggerClient::processTakeCode() { TRACE(2, "DebuggerClient::processTakeCode\n"); - assert(m_inputState == TakingCommand); + assertx(m_inputState == TakingCommand); char first = m_line[0]; if (first == '@') { @@ -1999,7 +1999,7 @@ bool DebuggerClient::processEval() { void DebuggerClient::swapHelp() { TRACE(2, "DebuggerClient::swapHelp\n"); - assert(m_args.size() > 0); + assertx(m_args.size() > 0); m_command = m_args[0]; m_args[0] = "help"; } @@ -2024,7 +2024,7 @@ DSandboxInfoPtr DebuggerClient::getSandbox(int index) const { // Update the current sandbox in the current machine. This should always be // called once we're attached to a machine. void DebuggerClient::setSandbox(DSandboxInfoPtr sandbox) { - assert(m_machine != nullptr); + assertx(m_machine != nullptr); m_machine->m_sandbox = sandbox; } @@ -2307,7 +2307,7 @@ bool DebuggerClient::deleteMacro(int index) { void DebuggerClient::record(const char *line) { TRACE(2, "DebuggerClient::record\n"); - assert(line); + assertx(line); if (m_macroRecording && line[0] != '&') { m_macroRecording->m_cmds.push_back(line); } diff --git a/hphp/runtime/debugger/debugger_client.h b/hphp/runtime/debugger/debugger_client.h index 4cc4292d0cc..425713a80b5 100644 --- a/hphp/runtime/debugger/debugger_client.h +++ b/hphp/runtime/debugger/debugger_client.h @@ -123,7 +123,7 @@ public: */ struct LiveLists { LiveList& get(size_t i) { - assert(i < DebuggerClient::AutoCompleteCount); + assertx(i < DebuggerClient::AutoCompleteCount); return lists[i]; } diff --git a/hphp/runtime/debugger/debugger_command.cpp b/hphp/runtime/debugger/debugger_command.cpp index fc606d6ec53..1d29677173e 100644 --- a/hphp/runtime/debugger/debugger_command.cpp +++ b/hphp/runtime/debugger/debugger_command.cpp @@ -149,9 +149,9 @@ bool DebuggerCommand::Receive(DebuggerThriftBuffer& thrift, break; case KindOfExtended: { - assert(!clsname.empty()); + assertx(!clsname.empty()); cmd = CmdExtended::CreateExtendedCommand(clsname); - assert(cmd); + assertx(cmd); break; } @@ -203,7 +203,7 @@ bool DebuggerCommand::displayedHelp(DebuggerClient& client) { // communicate with the client (for commands that do so). bool DebuggerCommand::onServer(DebuggerProxy& /*proxy*/) { TRACE(2, "DebuggerCommand::onServer\n"); - assert(false); + assertx(false); Logger::Error("DebuggerCommand::onServer(): bad cmd type: %d", m_type); return false; } diff --git a/hphp/runtime/debugger/debugger_proxy.cpp b/hphp/runtime/debugger/debugger_proxy.cpp index bfe53ecb874..de63cd59def 100644 --- a/hphp/runtime/debugger/debugger_proxy.cpp +++ b/hphp/runtime/debugger/debugger_proxy.cpp @@ -76,7 +76,7 @@ bool DebuggerProxy::cleanup(int timeout) { TRACE_RB(2, "DebuggerProxy::cleanup starting\n"); // If we're not already marked as stopping then there may be other // threads still attempting to use this object! - assert(m_stopped); + assertx(m_stopped); // No more client operation is possible, so drop the connection. m_thrift.close(); TRACE(2, "Stopping signal thread...\n"); @@ -152,10 +152,10 @@ void DebuggerProxy::getThreads(std::vector &threads) { TRACE(2, "DebuggerProxy::getThreads\n"); Lock lock(this); auto& interrupts = RID().interrupts; - assert(!interrupts.empty()); + assertx(!interrupts.empty()); if (!interrupts.empty()) { CmdInterrupt *tint = (CmdInterrupt*)interrupts.top(); - assert(tint); + assertx(tint); if (tint) { threads.push_back(createThreadInfo(tint->desc())); } @@ -344,7 +344,7 @@ void DebuggerProxy::interrupt(CmdInterrupt &cmd) { throw; } catch (...) { TRACE(2, "Unknown exception from processInterrupt!\n"); - assert(false); // no other exceptions should be seen here + assertx(false); // no other exceptions should be seen here switchThreadMode(Normal); throw; } @@ -810,7 +810,7 @@ DebuggerProxy::ExecutePHP(const std::string &php, String &output, // other threads which may hit interrupts while we're running, // since nested processInterrupt() calls would normally release // other threads on the way out. - assert(m_thread == (int64_t)Process::GetThreadId()); + assertx(m_thread == (int64_t)Process::GetThreadId()); ThreadMode origThreadMode = m_threadMode; switchThreadMode(Sticky, m_thread); if (flags & ExecutePHPFlagsAtInterrupt) enableSignalPolling(); diff --git a/hphp/runtime/debugger/debugger_thrift_buffer.cpp b/hphp/runtime/debugger/debugger_thrift_buffer.cpp index 1f3bbaf33e3..28696ad251c 100644 --- a/hphp/runtime/debugger/debugger_thrift_buffer.cpp +++ b/hphp/runtime/debugger/debugger_thrift_buffer.cpp @@ -24,7 +24,7 @@ TRACE_SET_MOD(debugger); String DebuggerThriftBuffer::readImpl() { TRACE(7, "DebuggerThriftBuffer::readImpl\n"); - assert(m_size <= BUFFER_SIZE); + assertx(m_size <= BUFFER_SIZE); int nread = getSocket()->readImpl(m_buffer, m_size); m_buffer[nread] = '\0'; return String(m_buffer, nread, CopyString); @@ -82,7 +82,7 @@ static inline int unserializeImpl(const String& sdata, Variant& data) { } catch (const Object& o) { // Get the message property from the Exception if we can. Otherwise, use // the class name. - assert(o->instanceof(SystemLib::s_ExceptionClass)); + assertx(o->instanceof(SystemLib::s_ExceptionClass)); auto const info = o->getProp(SystemLib::s_ExceptionClass, s_message.get()); if (info) { diff --git a/hphp/runtime/ext/apc/ext_apc.cpp b/hphp/runtime/ext/apc/ext_apc.cpp index a8b2daec427..81688dc845d 100644 --- a/hphp/runtime/ext/apc/ext_apc.cpp +++ b/hphp/runtime/ext/apc/ext_apc.cpp @@ -734,7 +734,7 @@ void apc_load_impl_compressed k += int_lens[i + 2] + 1; // skip \0 } s.prime(std::move(vars)); - assert((k - keys) == len); + assertx((k - keys) == len); } } { @@ -770,7 +770,7 @@ void apc_load_impl_compressed k += char_lens[i + 2] + 1; // skip \0 } s.prime(std::move(vars)); - assert((k - keys) == len); + assertx((k - keys) == len); } } { @@ -795,7 +795,7 @@ void apc_load_impl_compressed p += string_lens[i + i + 3] + 1; // skip \0 } s.prime(std::move(vars)); - assert((p - decoded) == len); + assertx((p - decoded) == len); } } { @@ -818,7 +818,7 @@ void apc_load_impl_compressed p += object_lens[i + i + 3] + 1; // skip \0 } s.prime(std::move(vars)); - assert((p - decoded) == len); + assertx((p - decoded) == len); } } { @@ -846,7 +846,7 @@ void apc_load_impl_compressed p += thrift_lens[i + i + 3] + 1; // skip \0 } s.prime(std::move(vars)); - assert((p - decoded) == len); + assertx((p - decoded) == len); } } { @@ -876,7 +876,7 @@ void apc_load_impl_compressed p += other_lens[i + i + 3] + 1; // skip \0 } s.prime(std::move(vars)); - assert((p - decoded) == len); + assertx((p - decoded) == len); } } } @@ -922,7 +922,7 @@ int apc_rfc1867_progress(apc_rfc1867_data* rfc1867ApcData, unsigned int event, rfc1867ApcData->update_freq = RuntimeOption::Rfc1867Freq; if (rfc1867ApcData->update_freq < 0) { - assert(false); // TODO: support percentage + assertx(false); // TODO: support percentage // frequency is a percentage, not bytes rfc1867ApcData->update_freq = rfc1867ApcData->content_length * RuntimeOption::Rfc1867Freq / 100; diff --git a/hphp/runtime/ext/apc/snapshot.cpp b/hphp/runtime/ext/apc/snapshot.cpp index 8c45bae1fd0..f1821a7b1d5 100644 --- a/hphp/runtime/ext/apc/snapshot.cpp +++ b/hphp/runtime/ext/apc/snapshot.cpp @@ -161,7 +161,7 @@ void SnapshotLoader::load(ConcurrentTableSharedStore& s) { s.constructPrime(uninit_null(), item); break; default: - assert(false); + assertx(false); break; } } @@ -206,7 +206,7 @@ void SnapshotLoader::load(ConcurrentTableSharedStore& s) { break; } default: - assert(false); + assertx(false); break; } } @@ -222,7 +222,7 @@ void SnapshotLoader::load(ConcurrentTableSharedStore& s) { item.sAddr = const_cast(disk); disk += abs(item.sSize) + 1; // \0 } - assert(disk == m_begin + m_size); + assertx(disk == m_begin + m_size); all.insert(all.end(), items.begin(), items.end()); } // Sort entries by increasing hotness before priming. @@ -247,7 +247,7 @@ void SnapshotLoader::load(ConcurrentTableSharedStore& s) { return hotness[a.key] < hotness[b.key]; }); s.prime(std::move(all)); - assert(m_cur == m_begin + header().diskOffset); + assertx(m_cur == m_begin + header().diskOffset); // Keys have been copied, so don't need that part any more. madvise(const_cast(m_begin), header().diskOffset, MADV_DONTNEED); } @@ -255,11 +255,11 @@ void SnapshotLoader::load(ConcurrentTableSharedStore& s) { void SnapshotLoader::adviseOut() { Timer timer(Timer::WallTime, "advising out apc prime snapshot"); Logger::FInfo("Advising out {} bytes", m_size); - assert(m_begin); + assertx(m_begin); if (madvise(const_cast(m_begin), m_size, MADV_DONTNEED) < 0) { Logger::Error("Failed to madvise"); } - assert(m_fd >= 0); + assertx(m_fd >= 0); if (fadvise_dontneed(m_fd, m_size) < 0) { Logger::Error("Failed to fadvise"); } diff --git a/hphp/runtime/ext/array/ext_array.cpp b/hphp/runtime/ext/array/ext_array.cpp index 25bb26d156b..48e2bca444a 100644 --- a/hphp/runtime/ext/array/ext_array.cpp +++ b/hphp/runtime/ext/array/ext_array.cpp @@ -242,7 +242,7 @@ TypedValue HHVM_FUNCTION(array_fill_keys, "an array or collection"); return make_tv(); } - assert(ai.hasValue()); + assertx(ai.hasValue()); return tvReturn(ai->toVariant()); } @@ -577,13 +577,13 @@ TypedValue HHVM_FUNCTION(array_merge_recursive, Array ret = Array::Create(); PointerSet seen; php_array_merge_recursive(seen, false, ret, arr_array1); - assert(seen.empty()); + assertx(seen.empty()); if (UNLIKELY(numArgs < 2)) return tvReturn(std::move(ret)); getCheckedArray(array2); php_array_merge_recursive(seen, false, ret, arr_array2); - assert(seen.empty()); + assertx(seen.empty()); for (ArrayIter iter(args); iter; ++iter) { Variant v = iter.second(); @@ -593,7 +593,7 @@ TypedValue HHVM_FUNCTION(array_merge_recursive, } const Array& arr_v = v.asCArrRef(); php_array_merge_recursive(seen, false, ret, arr_v); - assert(seen.empty()); + assertx(seen.empty()); } return tvReturn(std::move(ret)); } @@ -679,7 +679,7 @@ TypedValue HHVM_FUNCTION(array_replace_recursive, Array ret = Array::Create(); PointerSet seen; php_array_replace_recursive(seen, false, ret, arr_array1); - assert(seen.empty()); + assertx(seen.empty()); if (UNLIKELY(array2.isNull() && args.empty())) { return tvReturn(std::move(ret)); @@ -687,13 +687,13 @@ TypedValue HHVM_FUNCTION(array_replace_recursive, getCheckedArray(array2); php_array_replace_recursive(seen, false, ret, arr_array2); - assert(seen.empty()); + assertx(seen.empty()); for (ArrayIter iter(args); iter; ++iter) { auto const v = VarNR(iter.secondVal()); getCheckedArray(v); php_array_replace_recursive(seen, false, ret, arr_v); - assert(seen.empty()); + assertx(seen.empty()); } return tvReturn(std::move(ret)); } @@ -734,7 +734,7 @@ TypedValue HHVM_FUNCTION(array_pop, } return make_tv(); } - assert(container->m_type == KindOfObject); + assertx(container->m_type == KindOfObject); return tvReturn(collections::pop(container->m_data.pobj)); } @@ -1151,9 +1151,9 @@ TypedValue HHVM_FUNCTION(array_unshift, return make_tv(ref_array->asArrRef().size()); } // Handle collections - assert(cell_array->m_type == KindOfObject); + assertx(cell_array->m_type == KindOfObject); auto* obj = cell_array->m_data.pobj; - assert(obj->isCollection()); + assertx(obj->isCollection()); switch (obj->collectionType()) { case CollectionType::Vector: { auto* vec = static_cast(obj); @@ -1227,7 +1227,7 @@ Variant array_values(const Variant& input) { return init_null(); } - assert(ai.hasValue()); + assertx(ai.hasValue()); return ai->toVariant(); } @@ -1864,7 +1864,7 @@ TypedValue HHVM_FUNCTION(array_diff_key, if (c.m_type == KindOfInt64) { if (ad2->exists(c.m_data.num)) continue; } else { - assert(isStringType(c.m_type)); + assertx(isStringType(c.m_type)); if (ad2->exists(c.m_data.pstr)) continue; } ret.setWithRef(key, iter.secondValPlus(), true); @@ -1992,9 +1992,9 @@ static inline TypedValue* makeContainerListHelper(const Variant& a, const Array& argv, int count, int smallestPos) { - assert(count == argv.size() + 1); - assert(0 <= smallestPos); - assert(smallestPos < count); + assertx(count == argv.size() + 1); + assertx(0 <= smallestPos); + assertx(smallestPos < count); // Allocate a TypedValue array and copy 'a' and the contents of 'argv' TypedValue* containers = req::make_raw_array(count); tvCopy(*a.asCell(), containers[0]); @@ -2048,7 +2048,7 @@ static inline void updateIntersectMapHelper(const req::ptr& mp, if (c.m_type == KindOfInt64) { auto val = mp->get(c.m_data.num); if (val && val->m_data.num == pos) { - assert(val->m_type == KindOfInt64); + assertx(val->m_type == KindOfInt64); ++val->m_data.num; } } else { @@ -2065,13 +2065,13 @@ static inline void updateIntersectMapHelper(const req::ptr& mp, if (checkHACIntishCast()) raise_intish_index_cast(); auto val = mp->get(n); if (val && val->m_data.num == pos) { - assert(val->m_type == KindOfInt64); + assertx(val->m_type == KindOfInt64); ++val->m_data.num; } } else { auto val = mp->get(s); if (val && val->m_data.num == pos) { - assert(val->m_type == KindOfInt64); + assertx(val->m_type == KindOfInt64); ++val->m_data.num; } } @@ -2081,7 +2081,7 @@ static inline void updateIntersectMapHelper(const req::ptr& mp, static void containerValuesIntersectHelper(const req::ptr& st, TypedValue* containers, int count) { - assert(count >= 2); + assertx(count >= 2); auto mp = req::make(); Variant strHolder(empty_string_variant()); TypedValue* strTv = strHolder.asTypedValue(); @@ -2110,7 +2110,7 @@ static void containerValuesIntersectHelper(const req::ptr& st, // corresponding value is equal to pos exactly (which means it // was present in all of the containers). auto const rval = iter.secondRvalPlus().unboxed(); - assert(rval.type() == KindOfInt64); + assertx(rval.type() == KindOfInt64); if (rval.val().num == count) { st->add(*iter.first().asCell()); } @@ -2120,7 +2120,7 @@ static void containerValuesIntersectHelper(const req::ptr& st, static void containerKeysIntersectHelper(const req::ptr& st, TypedValue* containers, int count) { - assert(count >= 2); + assertx(count >= 2); auto mp = req::make(); Variant strHolder(empty_string_variant()); TypedValue* strTv = strHolder.asTypedValue(); @@ -2148,7 +2148,7 @@ static void containerKeysIntersectHelper(const req::ptr& st, // corresponding value is equal to pos exactly (which means it // was present in all of the containers). auto const rval = iter.secondRvalPlus().unboxed(); - assert(rval.type() == KindOfInt64); + assertx(rval.type() == KindOfInt64); if (rval.val().num == count) { st->add(*iter.first().asCell()); } @@ -2250,7 +2250,7 @@ TypedValue HHVM_FUNCTION(array_intersect_key, if (c.m_type == KindOfInt64) { if (!ad2->exists(c.m_data.num)) continue; } else { - assert(isStringType(c.m_type)); + assertx(isStringType(c.m_type)); if (!ad2->exists(c.m_data.pstr)) continue; } ret.setWithRef(key, iter.secondValPlus(), true); @@ -2459,7 +2459,7 @@ struct Collator final : RequestEventHandler { if (U_FAILURE(error)) { m_errcode.setError(error); } - assert(m_ucoll); + assertx(m_ucoll); } void requestShutdown() override { @@ -2482,7 +2482,7 @@ namespace { struct ArraySortTmp { explicit ArraySortTmp(TypedValue* arr, SortFunction sf) : m_arr(arr) { m_ad = arr->m_data.parr->escalateForSort(sf); - assert(m_ad == arr->m_data.parr || m_ad->hasExactlyOneRef()); + assertx(m_ad == arr->m_data.parr || m_ad->hasExactlyOneRef()); } ~ArraySortTmp() { if (m_ad != m_arr->m_data.parr) { diff --git a/hphp/runtime/ext/array/ext_array.h b/hphp/runtime/ext/array/ext_array.h index d7c98abbb54..a0ed0fd032e 100644 --- a/hphp/runtime/ext/array/ext_array.h +++ b/hphp/runtime/ext/array/ext_array.h @@ -292,7 +292,7 @@ inline int64_t countHelper(TypedValue tv) { } \ Variant var_##input(input); \ tvCastToArrayInPlace(var_##input.asTypedValue()); \ - assert(var_##input.isArray()); \ + assertx(var_##input.isArray()); \ auto arr_##input = var_##input.toArray(); #define getCheckedArray(input) \ diff --git a/hphp/runtime/ext/asio/asio-blockable.cpp b/hphp/runtime/ext/asio/asio-blockable.cpp index df7244f1294..c1518197579 100644 --- a/hphp/runtime/ext/asio/asio-blockable.cpp +++ b/hphp/runtime/ext/asio/asio-blockable.cpp @@ -41,28 +41,28 @@ inline T* getContainingObject(const AsioBlockable* blockable) { inline c_AsyncFunctionWaitHandle::Node* getAsyncFunctionWaitHandleNode( const AsioBlockable* blockable ) { - assert(blockable->getKind() == Kind::AsyncFunctionWaitHandleNode); + assertx(blockable->getKind() == Kind::AsyncFunctionWaitHandleNode); return getContainingObject(blockable); } inline c_AsyncGeneratorWaitHandle* getAsyncGeneratorWaitHandle( const AsioBlockable* blockable ) { - assert(blockable->getKind() == Kind::AsyncGeneratorWaitHandle); + assertx(blockable->getKind() == Kind::AsyncGeneratorWaitHandle); return getContainingObject(blockable); } inline c_AwaitAllWaitHandle::Node* getAwaitAllWaitHandleNode( const AsioBlockable* blockable ) { - assert(blockable->getKind() == Kind::AwaitAllWaitHandleNode); + assertx(blockable->getKind() == Kind::AwaitAllWaitHandleNode); return getContainingObject(blockable); } inline c_ConditionWaitHandle* getConditionWaitHandle( const AsioBlockable* blockable ) { - assert(blockable->getKind() == Kind::ConditionWaitHandle); + assertx(blockable->getKind() == Kind::ConditionWaitHandle); return getContainingObject(blockable); } @@ -70,9 +70,9 @@ inline void exitContextImpl( c_WaitableWaitHandle* waitHandle, context_idx_t ctx_idx ) { - assert(AsioSession::Get()->getContext(ctx_idx)); - assert(!waitHandle->isFinished()); - assert(waitHandle->getContextIdx() <= ctx_idx); + assertx(AsioSession::Get()->getContext(ctx_idx)); + assertx(!waitHandle->isFinished()); + assertx(waitHandle->getContextIdx() <= ctx_idx); // Not in a context being exited. if (waitHandle->getContextIdx() != ctx_idx) { @@ -180,7 +180,7 @@ void AsioBlockableChain::removeFromChain(AsioBlockable* ab) { next = cur->getNextParent(); if (ab == cur) { // Found the AAWH we need to remove - assert(cur->getKind() == Kind::AwaitAllWaitHandleNode); + assertx(cur->getKind() == Kind::AwaitAllWaitHandleNode); if (!prev) { m_firstParent = next; } else { @@ -192,7 +192,7 @@ void AsioBlockableChain::removeFromChain(AsioBlockable* ab) { prev = cur; } // We should always be able to find the parent. - assert(false); + assertx(false); } Array AsioBlockableChain::toArray() { @@ -220,7 +220,7 @@ AsioBlockableChain::firstInContext(context_idx_t ctx_idx) { void AsioBlockableChain::UnblockJitHelper(ActRec* ar, TypedValue* sp, AsioBlockableChain chain) { - assert(tl_regState == VMRegState::DIRTY); + assertx(tl_regState == VMRegState::DIRTY); tl_regState = VMRegState::CLEAN; SCOPE_EXIT { tl_regState = VMRegState::DIRTY; }; @@ -228,7 +228,7 @@ void AsioBlockableChain::UnblockJitHelper(ActRec* ar, const Func* prevF = prevAr->m_func; auto& regs = vmRegs(); regs.stack.top() = sp; - assert(vmStack().isValidAddress((uintptr_t)vmsp())); + assertx(vmStack().isValidAddress((uintptr_t)vmsp())); regs.pc = prevF->unit()->at(prevF->base() + ar->m_soff); regs.fp = prevAr; diff --git a/hphp/runtime/ext/asio/asio-blockable.h b/hphp/runtime/ext/asio/asio-blockable.h index dab59f2b8d4..5867cdd2411 100644 --- a/hphp/runtime/ext/asio/asio-blockable.h +++ b/hphp/runtime/ext/asio/asio-blockable.h @@ -56,14 +56,14 @@ struct AsioBlockable final { c_WaitableWaitHandle* getWaitHandle() const; void setNextParent(AsioBlockable* parent, Kind kind) { - assert(!(reinterpret_cast(parent) & ~kParentMask)); - assert(!(static_cast(kind) & kParentMask)); + assertx(!(reinterpret_cast(parent) & ~kParentMask)); + assertx(!(static_cast(kind) & kParentMask)); m_bits = reinterpret_cast(parent) | static_cast(kind); } // Only update the next parent w/o changing kind. void updateNextParent(AsioBlockable* parent) { - assert(!(reinterpret_cast(parent) & ~kParentMask)); + assertx(!(reinterpret_cast(parent) & ~kParentMask)); m_bits = (m_bits & ~kParentMask) | reinterpret_cast(parent); } diff --git a/hphp/runtime/ext/asio/asio-context-enter-inl.h b/hphp/runtime/ext/asio/asio-context-enter-inl.h index 0edea93cb2a..f7b3dbee6b7 100644 --- a/hphp/runtime/ext/asio/asio-context-enter-inl.h +++ b/hphp/runtime/ext/asio/asio-context-enter-inl.h @@ -23,7 +23,7 @@ namespace HPHP { namespace asio { /////////////////////////////////////////////////////////////////////////////// inline void enter_context(c_WaitableWaitHandle* root, context_idx_t ctx_idx) { - assert(ctx_idx <= AsioSession::Get()->getCurrentContextIdx()); + assertx(ctx_idx <= AsioSession::Get()->getCurrentContextIdx()); // If this wait handle is being finished and there is a parent A that is being // unblocked and a parent B that was not unblocked yet, it is possible that diff --git a/hphp/runtime/ext/asio/asio-context-enter.cpp b/hphp/runtime/ext/asio/asio-context-enter.cpp index a90a14b8532..dfd83879278 100644 --- a/hphp/runtime/ext/asio/asio-context-enter.cpp +++ b/hphp/runtime/ext/asio/asio-context-enter.cpp @@ -65,14 +65,14 @@ namespace { } void discover(c_AwaitAllWaitHandle* node) { - assert(node->getState() == c_AwaitAllWaitHandle::STATE_BLOCKED); + assertx(node->getState() == c_AwaitAllWaitHandle::STATE_BLOCKED); node->forEachChild([this] (c_WaitableWaitHandle* child) { enqueue(child); }); } void discover(c_ConditionWaitHandle* node) { - assert(node->getState() == c_ConditionWaitHandle::STATE_BLOCKED); + assertx(node->getState() == c_ConditionWaitHandle::STATE_BLOCKED); enqueue(node->getChild()); } @@ -111,24 +111,24 @@ namespace { } void enter(c_RescheduleWaitHandle* node) { - assert(node->getState() == c_RescheduleWaitHandle::STATE_SCHEDULED); + assertx(node->getState() == c_RescheduleWaitHandle::STATE_SCHEDULED); node->scheduleInContext(); } void preEnter(c_SleepWaitHandle* node) { - assert(node->getState() == c_SleepWaitHandle::STATE_WAITING); + assertx(node->getState() == c_SleepWaitHandle::STATE_WAITING); if (node->isInContext()) { node->unregisterFromContext(); } } void enter(c_SleepWaitHandle* node) { - assert(node->getState() == c_SleepWaitHandle::STATE_WAITING); + assertx(node->getState() == c_SleepWaitHandle::STATE_WAITING); node->registerToContext(); } void preEnter(c_ExternalThreadEventWaitHandle* node) { - assert(node->getState() == + assertx(node->getState() == c_ExternalThreadEventWaitHandle::STATE_WAITING); if (node->isInContext()) { node->unregisterFromContext(); @@ -136,7 +136,7 @@ namespace { } void enter(c_ExternalThreadEventWaitHandle* node) { - assert(node->getState() == + assertx(node->getState() == c_ExternalThreadEventWaitHandle::STATE_WAITING); node->registerToContext(); } @@ -190,8 +190,8 @@ namespace { } void enter_context_impl(c_WaitableWaitHandle* root, context_idx_t ctx_idx) { - assert(!root->isFinished()); - assert(root->getContextIdx() < ctx_idx); + assertx(!root->isFinished()); + assertx(root->getContextIdx() < ctx_idx); EnterContext ctx(root, ctx_idx); ctx.discover(); diff --git a/hphp/runtime/ext/asio/asio-context-inl.h b/hphp/runtime/ext/asio/asio-context-inl.h index 17a38eacc6f..3326a351bb8 100644 --- a/hphp/runtime/ext/asio/asio-context-inl.h +++ b/hphp/runtime/ext/asio/asio-context-inl.h @@ -32,7 +32,7 @@ uint32_t AsioContext::registerTo(req::vector& vec, template void AsioContext::unregisterFrom(req::vector& vec, uint32_t idx) { - assert(idx < vec.size()); + assertx(idx < vec.size()); if (idx != vec.size() - 1) { vec[idx] = vec.back(); vec[idx]->setContextVectorIndex(idx); diff --git a/hphp/runtime/ext/asio/asio-context.cpp b/hphp/runtime/ext/asio/asio-context.cpp index fc47e453122..192206779d6 100644 --- a/hphp/runtime/ext/asio/asio-context.cpp +++ b/hphp/runtime/ext/asio/asio-context.cpp @@ -88,7 +88,7 @@ namespace { } void AsioContext::exit(context_idx_t ctx_idx) { - assert(AsioSession::Get()->getContext(ctx_idx) == this); + assertx(AsioSession::Get()->getContext(ctx_idx) == this); exitContextVector(ctx_idx, m_runnableQueue); exitContextVector(ctx_idx, m_fastRunnableQueue); @@ -106,8 +106,8 @@ void AsioContext::exit(context_idx_t ctx_idx) { void AsioContext::schedule(c_RescheduleWaitHandle* wait_handle, uint32_t queue, int64_t priority) { - assert(queue == QUEUE_DEFAULT || queue == QUEUE_NO_PENDING_IO); - assert(!(priority < 0)); + assertx(queue == QUEUE_DEFAULT || queue == QUEUE_NO_PENDING_IO); + assertx(!(priority < 0)); auto& dst_queue = queue == QUEUE_DEFAULT ? m_priorityQueueDefault : m_priorityQueueNoPendingIO; @@ -144,8 +144,8 @@ c_AsyncFunctionWaitHandle* AsioContext::maybePopFast() { } void AsioContext::runUntil(c_WaitableWaitHandle* wait_handle) { - assert(wait_handle); - assert(wait_handle->getContext() == this); + assertx(wait_handle); + assertx(wait_handle->getContext() == this); auto session = AsioSession::Get(); auto ete_queue = session->getExternalThreadEventQueue(); @@ -256,7 +256,7 @@ void AsioContext::runUntil(c_WaitableWaitHandle* wait_handle) { // What could it possibly mean? I think we are in a deep sh^H^Hcycle. // But we can't, the cycles are detected and avoided at blockOn() time. // So, looks like it's not cycle, but the word I started typing first. - assert(false); + assertx(false); raise_fatal_error( "Invariant violation: queues are empty, but wait handle did not finish"); } diff --git a/hphp/runtime/ext/asio/asio-external-thread-event-queue.cpp b/hphp/runtime/ext/asio/asio-external-thread-event-queue.cpp index fad08cfc0d6..b7d5e8eb1f7 100644 --- a/hphp/runtime/ext/asio/asio-external-thread-event-queue.cpp +++ b/hphp/runtime/ext/asio/asio-external-thread-event-queue.cpp @@ -36,7 +36,7 @@ AsioExternalThreadEventQueue::AsioExternalThreadEventQueue() * May throw C++ exception that may leave some events unprocessed. */ void AsioExternalThreadEventQueue::processAllReceived() { - assert(m_received); + assertx(m_received); do { auto ete_wh = m_received; m_received = m_received->getNextToProcess(); @@ -50,7 +50,7 @@ void AsioExternalThreadEventQueue::processAllReceived() { * Returns true iff provided wait handle was abandoned. */ bool AsioExternalThreadEventQueue::abandonAllReceived(c_ExternalThreadEventWaitHandle* wait_handle) { - assert(m_received); + assertx(m_received); bool seen = false; do { auto ete_wh = m_received; @@ -67,9 +67,9 @@ bool AsioExternalThreadEventQueue::abandonAllReceived(c_ExternalThreadEventWaitH * Returns true iff at least one event was received. */ bool AsioExternalThreadEventQueue::tryReceiveSome() { - assert(!m_received); + assertx(!m_received); m_received = m_queue.exchange(nullptr); - assert(m_received != K_CONSUMER_WAITING); + assertx(m_received != K_CONSUMER_WAITING); return m_received; } @@ -82,12 +82,12 @@ bool AsioExternalThreadEventQueue::tryReceiveSome() { */ bool AsioExternalThreadEventQueue::receiveSomeUntil( std::chrono::time_point waketime) { - assert(!m_received); + assertx(!m_received); // try receive external thread events without grabbing lock m_received = m_queue.exchange(nullptr); if (m_received) { - assert(m_received != K_CONSUMER_WAITING); + assertx(m_received != K_CONSUMER_WAITING); return true; } @@ -104,7 +104,7 @@ bool AsioExternalThreadEventQueue::receiveSomeUntil( // We timed out without receiving events. Unflag ourselves as // waiting. m_received = m_queue.exchange(nullptr); - assert(m_received); + assertx(m_received); // If we were still waiting on an event, reset our state and return; // otherwise, a send() must have completed, so run with the received @@ -122,8 +122,8 @@ bool AsioExternalThreadEventQueue::receiveSomeUntil( } m_received = m_queue.exchange(nullptr); - assert(m_received); - assert(m_received != K_CONSUMER_WAITING); + assertx(m_received); + assertx(m_received != K_CONSUMER_WAITING); return true; } @@ -133,7 +133,7 @@ bool AsioExternalThreadEventQueue::receiveSomeUntil( */ void AsioExternalThreadEventQueue::receiveSome() { bool received UNUSED = receiveSomeUntil(AsioSession::getLatestWakeTime()); - assert(received); + assertx(received); } /** diff --git a/hphp/runtime/ext/asio/asio-external-thread-event.cpp b/hphp/runtime/ext/asio/asio-external-thread-event.cpp index a7fed7103ab..6555643af45 100644 --- a/hphp/runtime/ext/asio/asio-external-thread-event.cpp +++ b/hphp/runtime/ext/asio/asio-external-thread-event.cpp @@ -31,8 +31,8 @@ AsioExternalThreadEvent::AsioExternalThreadEvent(ObjectData* priv_data) } void AsioExternalThreadEvent::abandon() { - assert(m_state.load() == Waiting); - assert(m_waitHandle->hasExactlyOneRef()); + assertx(m_state.load() == Waiting); + assertx(m_waitHandle->hasExactlyOneRef()); m_state.store(Abandoned); m_waitHandle->abandon(false); } @@ -43,7 +43,7 @@ bool AsioExternalThreadEvent::cancel() { return true; } - assert(expected == Finished); + assertx(expected == Finished); return false; } @@ -55,7 +55,7 @@ void AsioExternalThreadEvent::markAsFinished() { m_queue->send(m_waitHandle); } else { // web request died, destroy object - assert(expected == Canceled); + assertx(expected == Canceled); release(); } } diff --git a/hphp/runtime/ext/asio/asio-external-thread-event.h b/hphp/runtime/ext/asio/asio-external-thread-event.h index 066762fdc0e..414c38bd06c 100644 --- a/hphp/runtime/ext/asio/asio-external-thread-event.h +++ b/hphp/runtime/ext/asio/asio-external-thread-event.h @@ -101,7 +101,7 @@ struct c_ExternalThreadEventWaitHandle; * event->setException(exception); * } catch (...) { * // unknown exception; should be never reached - * assert(false); + * assertx(false); * event->abandon(); * SystemLib::throwInvalidOperationExceptionObject( * "Encountered unexpected exception" @@ -219,7 +219,7 @@ struct AsioExternalThreadEvent { * is eventually called. */ virtual ~AsioExternalThreadEvent() { - assert( + assertx( m_state.load() == Finished || m_state.load() == Canceled || m_state.load() == Abandoned @@ -247,7 +247,7 @@ struct AsioExternalThreadEvent { * called only from the unserialize() implementation. */ ObjectData* getPrivData() const { - assert(m_state.load() == Finished); + assertx(m_state.load() == Finished); return m_waitHandle->getPrivData(); } diff --git a/hphp/runtime/ext/asio/asio-session.cpp b/hphp/runtime/ext/asio/asio-session.cpp index e6b7c45eaaa..5bd1015f35a 100644 --- a/hphp/runtime/ext/asio/asio-session.cpp +++ b/hphp/runtime/ext/asio/asio-session.cpp @@ -58,7 +58,7 @@ namespace { } void runCallback(const Object& function, const Array& params, char* name) { - assert(function.get()); + assertx(function.get()); try { vm_call_user_func(function, params); } catch (const Object&) { @@ -88,12 +88,12 @@ void AsioSession::enterContext(ActRec* savedFP) { m_contexts.push_back(req::make_raw(savedFP)); - assert(static_cast(m_contexts.size()) == m_contexts.size()); - assert(isInContext()); + assertx(static_cast(m_contexts.size()) == m_contexts.size()); + assertx(isInContext()); } void AsioSession::exitContext() { - assert(isInContext()); + assertx(isInContext()); m_contexts.back()->exit(m_contexts.size()); req::destroy_raw(m_contexts.back()); @@ -101,7 +101,7 @@ void AsioSession::exitContext() { } void AsioSession::initAbruptInterruptException() { - assert(!hasAbruptInterruptException()); + assertx(!hasAbruptInterruptException()); m_abruptInterruptException = SystemLib::AllocInvalidOperationExceptionObject( "The request was abruptly interrupted." diff --git a/hphp/runtime/ext/asio/asio-session.h b/hphp/runtime/ext/asio/asio-session.h index 405918bbbcc..aa000de9d22 100644 --- a/hphp/runtime/ext/asio/asio-session.h +++ b/hphp/runtime/ext/asio/asio-session.h @@ -45,17 +45,17 @@ struct AsioSession final { } AsioContext* getContext(context_idx_t ctx_idx) { - assert(ctx_idx <= m_contexts.size()); + assertx(ctx_idx <= m_contexts.size()); return ctx_idx ? m_contexts[ctx_idx - 1] : nullptr; } AsioContext* getCurrentContext() { - assert(isInContext()); + assertx(isInContext()); return m_contexts.back(); } context_idx_t getCurrentContextIdx() { - assert(static_cast(m_contexts.size()) == m_contexts.size()); + assertx(static_cast(m_contexts.size()) == m_contexts.size()); return static_cast(m_contexts.size()); } diff --git a/hphp/runtime/ext/asio/ext_async-function-wait-handle-inl.h b/hphp/runtime/ext/asio/ext_async-function-wait-handle-inl.h index 5f634c432ba..25cefdecf88 100644 --- a/hphp/runtime/ext/asio/ext_async-function-wait-handle-inl.h +++ b/hphp/runtime/ext/asio/ext_async-function-wait-handle-inl.h @@ -24,8 +24,8 @@ namespace HPHP { inline void c_AsyncFunctionWaitHandle::Node::setChild(c_WaitableWaitHandle* child) { - assert(child); - assert(!child->isFinished()); + assertx(child); + assertx(!child->isFinished()); m_child = child; m_child->getParentChain() diff --git a/hphp/runtime/ext/asio/ext_async-function-wait-handle.cpp b/hphp/runtime/ext/asio/ext_async-function-wait-handle.cpp index d04d6116fd2..e6e995c24e2 100644 --- a/hphp/runtime/ext/asio/ext_async-function-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_async-function-wait-handle.cpp @@ -36,7 +36,7 @@ c_AsyncFunctionWaitHandle::~c_AsyncFunctionWaitHandle() { return; } - assert(!isRunning()); + assertx(!isRunning()); frame_free_locals_inl_no_hook(actRec(), actRec()->func()->numLocals()); decRefObj(m_children[0].getChild()); } @@ -52,12 +52,12 @@ c_AsyncFunctionWaitHandle::Create(const ActRec* fp, jit::TCA resumeAddr, Offset resumeOffset, c_WaitableWaitHandle* child) { - assert(fp); - assert(!fp->resumed()); - assert(fp->func()->isAsyncFunction()); - assert(child); - assert(child->instanceof(c_WaitableWaitHandle::classof())); - assert(!child->isFinished()); + assertx(fp); + assertx(!fp->resumed()); + assertx(fp->func()->isAsyncFunction()); + assertx(child); + assertx(child->instanceof(c_WaitableWaitHandle::classof())); + assertx(!child->isFinished()); const size_t frameSize = Resumable::getFrameSize(numSlots); const size_t totalSize = sizeof(NativeNode) + frameSize + sizeof(Resumable) + @@ -69,9 +69,9 @@ c_AsyncFunctionWaitHandle::Create(const ActRec* fp, frameSize, totalSize); auto const waitHandle = new (resumable + 1) c_AsyncFunctionWaitHandle(); - assert(waitHandle->hasExactlyOneRef()); + assertx(waitHandle->hasExactlyOneRef()); waitHandle->actRec()->setReturnVMExit(); - assert(waitHandle->noDestruct()); + assertx(waitHandle->noDestruct()); waitHandle->initialize(child); return waitHandle; } @@ -104,8 +104,8 @@ void c_AsyncFunctionWaitHandle::initialize(c_WaitableWaitHandle* child) { void c_AsyncFunctionWaitHandle::resume() { auto const child = m_children[0].getChild(); - assert(getState() == STATE_READY); - assert(child->isFinished()); + assertx(getState() == STATE_READY); + assertx(child->isFinished()); setState(STATE_RUNNING); if (LIKELY(child->isSucceeded())) { @@ -119,7 +119,7 @@ void c_AsyncFunctionWaitHandle::resume() { } void c_AsyncFunctionWaitHandle::prepareChild(c_WaitableWaitHandle* child) { - assert(!child->isFinished()); + assertx(!child->isFinished()); // import child into the current context, throw on cross-context cycles asio::enter_context(child, getContextIdx()); @@ -155,7 +155,7 @@ void c_AsyncFunctionWaitHandle::await(Offset resumeOffset, } void c_AsyncFunctionWaitHandle::ret(Cell& result) { - assert(isRunning()); + assertx(isRunning()); auto parentChain = getParentChain(); setState(STATE_SUCCEEDED); cellCopy(result, m_resultOrException); @@ -168,9 +168,9 @@ void c_AsyncFunctionWaitHandle::ret(Cell& result) { * - consumes reference of the given Exception object */ void c_AsyncFunctionWaitHandle::fail(ObjectData* exception) { - assert(isRunning()); - assert(exception); - assert(exception->instanceof(SystemLib::s_ThrowableClass)); + assertx(isRunning()); + assertx(exception); + assertx(exception->instanceof(SystemLib::s_ThrowableClass)); AsioSession* session = AsioSession::Get(); if (UNLIKELY(session->hasOnResumableFail())) { @@ -192,7 +192,7 @@ void c_AsyncFunctionWaitHandle::fail(ObjectData* exception) { * Mark the wait handle as failed due to unexpected abrupt interrupt. */ void c_AsyncFunctionWaitHandle::failCpp() { - assert(isRunning()); + assertx(isRunning()); auto const exception = AsioSession::Get()->getAbruptInterruptException(); auto parentChain = getParentChain(); setState(STATE_FAILED); @@ -246,13 +246,13 @@ c_WaitableWaitHandle* c_AsyncFunctionWaitHandle::getChild() { if (getState() == STATE_BLOCKED) { return m_children[0].getChild(); } else { - assert(getState() == STATE_READY || getState() == STATE_RUNNING); + assertx(getState() == STATE_READY || getState() == STATE_RUNNING); return nullptr; } } void c_AsyncFunctionWaitHandle::exitContext(context_idx_t ctx_idx) { - assert(AsioSession::Get()->getContext(ctx_idx)); + assertx(AsioSession::Get()->getContext(ctx_idx)); // stop before corrupting unioned data if (isFinished()) { @@ -261,7 +261,7 @@ void c_AsyncFunctionWaitHandle::exitContext(context_idx_t ctx_idx) { } // not in a context being exited - assert(getContextIdx() <= ctx_idx); + assertx(getContextIdx() <= ctx_idx); if (getContextIdx() != ctx_idx) { decRefObj(this); return; @@ -295,7 +295,7 @@ void c_AsyncFunctionWaitHandle::exitContext(context_idx_t ctx_idx) { break; default: - assert(false); + assertx(false); } } diff --git a/hphp/runtime/ext/asio/ext_async-function-wait-handle.h b/hphp/runtime/ext/asio/ext_async-function-wait-handle.h index 6c71ab15464..bb69d7eedc6 100644 --- a/hphp/runtime/ext/asio/ext_async-function-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_async-function-wait-handle.h @@ -112,7 +112,7 @@ struct c_AsyncFunctionWaitHandle final : c_ResumableWaitHandle { } bool isFastResumable() const { - assert(getState() == STATE_READY); + assertx(getState() == STATE_READY); return (resumable()->resumeAddr() && m_children[0].getChild()->isSucceeded()); } @@ -135,7 +135,7 @@ struct c_AsyncFunctionWaitHandle final : c_ResumableWaitHandle { }; inline c_AsyncFunctionWaitHandle* c_Awaitable::asAsyncFunction() { - assert(getKind() == Kind::AsyncFunction); + assertx(getKind() == Kind::AsyncFunction); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_async-generator-wait-handle.cpp b/hphp/runtime/ext/asio/ext_async-generator-wait-handle.cpp index d87e17b9eba..6b6db7b66c2 100644 --- a/hphp/runtime/ext/asio/ext_async-generator-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_async-generator-wait-handle.cpp @@ -38,7 +38,7 @@ namespace { c_AsyncGeneratorWaitHandle::~c_AsyncGeneratorWaitHandle() { if (LIKELY(isFinished())) return; - assert(!isRunning()); + assertx(!isRunning()); decRefObj(m_child); } @@ -83,8 +83,8 @@ c_AsyncGeneratorWaitHandle::c_AsyncGeneratorWaitHandle(AsyncGenerator* gen, void c_AsyncGeneratorWaitHandle::resume() { // No refcnt: incref by being executed, decref by no longer in runnable queue. - assert(getState() == STATE_READY); - assert(m_child->isFinished()); + assertx(getState() == STATE_READY); + assertx(m_child->isFinished()); setState(STATE_RUNNING); auto generator = Native::data(m_generator); @@ -102,7 +102,7 @@ void c_AsyncGeneratorWaitHandle::resume() { } void c_AsyncGeneratorWaitHandle::prepareChild(c_WaitableWaitHandle* child) { - assert(!child->isFinished()); + assertx(!child->isFinished()); // import child into the current context, throw on cross-context cycles asio::enter_context(child, getContextIdx()); @@ -179,10 +179,10 @@ String c_AsyncGeneratorWaitHandle::getName() { c_WaitableWaitHandle* c_AsyncGeneratorWaitHandle::getChild() { if (getState() == STATE_BLOCKED) { - assert(m_child); + assertx(m_child); return m_child; } else { - assert(getState() == STATE_READY || getState() == STATE_RUNNING); + assertx(getState() == STATE_READY || getState() == STATE_RUNNING); return nullptr; } } @@ -193,7 +193,7 @@ Resumable* c_AsyncGeneratorWaitHandle::resumable() const { } void c_AsyncGeneratorWaitHandle::exitContext(context_idx_t ctx_idx) { - assert(AsioSession::Get()->getContext(ctx_idx)); + assertx(AsioSession::Get()->getContext(ctx_idx)); // stop before corrupting unioned data if (isFinished()) { @@ -202,7 +202,7 @@ void c_AsyncGeneratorWaitHandle::exitContext(context_idx_t ctx_idx) { } // not in a context being exited - assert(getContextIdx() <= ctx_idx); + assertx(getContextIdx() <= ctx_idx); if (getContextIdx() != ctx_idx) { decRefObj(this); return; @@ -233,7 +233,7 @@ void c_AsyncGeneratorWaitHandle::exitContext(context_idx_t ctx_idx) { break; default: - assert(false); + assertx(false); } } diff --git a/hphp/runtime/ext/asio/ext_async-generator-wait-handle.h b/hphp/runtime/ext/asio/ext_async-generator-wait-handle.h index 7f5d5a17918..2e79c19deca 100644 --- a/hphp/runtime/ext/asio/ext_async-generator-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_async-generator-wait-handle.h @@ -98,7 +98,7 @@ struct c_AsyncGeneratorWaitHandle final : c_ResumableWaitHandle { }; inline c_AsyncGeneratorWaitHandle* c_Awaitable::asAsyncGenerator() { - assert(getKind() == Kind::AsyncGenerator); + assertx(getKind() == Kind::AsyncGenerator); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_async-generator.cpp b/hphp/runtime/ext/asio/ext_async-generator.cpp index cce06677158..86bc20d691f 100644 --- a/hphp/runtime/ext/asio/ext_async-generator.cpp +++ b/hphp/runtime/ext/asio/ext_async-generator.cpp @@ -40,7 +40,7 @@ AsyncGenerator::~AsyncGenerator() { return; } - assert(!isRunning()); + assertx(!isRunning()); // Free locals, but don't trigger the EventHook for FunctionReturn since // the generator has already been exited. We don't want redundant calls. @@ -51,9 +51,9 @@ AsyncGenerator::~AsyncGenerator() { ObjectData* AsyncGenerator::Create(const ActRec* fp, size_t numSlots, jit::TCA resumeAddr, Offset resumeOffset) { - assert(fp); - assert(!fp->resumed()); - assert(fp->func()->isAsyncGenerator()); + assertx(fp); + assertx(!fp->resumed()); + assertx(fp->func()->isAsyncGenerator()); const size_t frameSz = Resumable::getFrameSize(numSlots); const size_t genSz = genSize(sizeof(AsyncGenerator), frameSz); auto const obj = BaseGenerator::Alloc(s_class, genSz); @@ -70,7 +70,7 @@ AsyncGenerator::Create(const ActRec* fp, size_t numSlots, c_StaticWaitHandle* AsyncGenerator::yield(Offset resumeOffset, const Cell* key, const Cell value) { - assert(isRunning()); + assertx(isRunning()); resumable()->setResumeAddr(nullptr, resumeOffset); setState(State::Started); @@ -91,7 +91,7 @@ AsyncGenerator::yield(Offset resumeOffset, c_StaticWaitHandle* AsyncGenerator::ret() { - assert(isRunning()); + assertx(isRunning()); setState(State::Done); auto nullTV = make_tv(); @@ -107,7 +107,7 @@ AsyncGenerator::ret() { c_StaticWaitHandle* AsyncGenerator::fail(ObjectData* exception) { - assert(isRunning()); + assertx(isRunning()); setState(State::Done); if (m_waitHandle) { @@ -120,7 +120,7 @@ AsyncGenerator::fail(ObjectData* exception) { } void AsyncGenerator::failCpp() { - assert(isRunning()); + assertx(isRunning()); setState(State::Done); if (m_waitHandle) { @@ -138,7 +138,7 @@ void AsioExtension::initAsyncGenerator() { loadSystemlib("async-generator"); AsyncGenerator::s_class = Unit::lookupClass(AsyncGenerator::s_className.get()); - assert(AsyncGenerator::s_class); + assertx(AsyncGenerator::s_class); } /////////////////////////////////////////////////////////////////////////////// diff --git a/hphp/runtime/ext/asio/ext_async-generator.h b/hphp/runtime/ext/asio/ext_async-generator.h index 1a05d9c3661..06d5cbaa9d0 100644 --- a/hphp/runtime/ext/asio/ext_async-generator.h +++ b/hphp/runtime/ext/asio/ext_async-generator.h @@ -42,7 +42,7 @@ struct AsyncGenerator final : BaseGenerator { static ObjectData* Create(const ActRec* fp, size_t numSlots, jit::TCA resumeAddr, Offset resumeOffset); static Class* getClass() { - assert(s_class); + assertx(s_class); return s_class; } static constexpr ptrdiff_t objectOff() { diff --git a/hphp/runtime/ext/asio/ext_await-all-wait-handle.cpp b/hphp/runtime/ext/asio/ext_await-all-wait-handle.cpp index 966a06bf242..dae73da4393 100644 --- a/hphp/runtime/ext/asio/ext_await-all-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_await-all-wait-handle.cpp @@ -36,7 +36,7 @@ req::ptr c_AwaitAllWaitHandle::Alloc(int32_t cnt) { auto size = c_AwaitAllWaitHandle::heapSize(cnt); auto mem = tl_heap->objMalloc(size); auto handle = new (mem) c_AwaitAllWaitHandle(cnt); - assert(handle->hasExactlyOneRef()); + assertx(handle->hasExactlyOneRef()); return req::ptr::attach(handle); } @@ -77,7 +77,7 @@ namespace { auto const waitHandle = c_Awaitable::fromCell(src); if (UNLIKELY(!waitHandle)) failWaitHandle(); if (waitHandle->isFinished()) return; - assert(isa(waitHandle)); + assertx(isa(waitHandle)); auto const child = static_cast(waitHandle); ctx_idx = std::min(ctx_idx, child->getContextIdx()); ++cnt; @@ -122,7 +122,7 @@ Object c_AwaitAllWaitHandle::Create(Iter iter) { iter([&](TypedValue v) { addChild(toCell(v), next, idx); }); - assert(next == &result->m_children[0]); + assertx(next == &result->m_children[0]); result->initialize(ctx_idx); return Object{std::move(result)}; } @@ -130,7 +130,7 @@ Object c_AwaitAllWaitHandle::Create(Iter iter) { ObjectData* c_AwaitAllWaitHandle::fromFrameNoCheck( uint32_t total, uint32_t cnt, TypedValue* stk ) { - assert(cnt); + assertx(cnt); auto result = Alloc(cnt); auto ctx_idx = std::numeric_limits::max(); @@ -155,7 +155,7 @@ ObjectData* c_AwaitAllWaitHandle::fromFrameNoCheck( if (!idx) break; } - assert(next == &result->m_children[0]); + assertx(next == &result->m_children[0]); result->initialize(ctx_idx); return result.detach(); } @@ -271,8 +271,8 @@ void c_AwaitAllWaitHandle::initialize(context_idx_t ctx_idx) { } void c_AwaitAllWaitHandle::onUnblocked(uint32_t idx) { - assert(idx <= m_unfinished); - assert(getState() == STATE_BLOCKED); + assertx(idx <= m_unfinished); + assertx(getState() == STATE_BLOCKED); if (idx == m_unfinished) { for (uint32_t next = idx - 1; next < idx; --next) { @@ -324,8 +324,8 @@ String c_AwaitAllWaitHandle::getName() { } c_WaitableWaitHandle* c_AwaitAllWaitHandle::getChild() { - assert(getState() == STATE_BLOCKED); - assert(m_unfinished < m_cap); + assertx(getState() == STATE_BLOCKED); + assertx(m_unfinished < m_cap); return m_children[m_unfinished].m_child; } diff --git a/hphp/runtime/ext/asio/ext_await-all-wait-handle.h b/hphp/runtime/ext/asio/ext_await-all-wait-handle.h index ed08b671e25..3ae5a6ddb5a 100644 --- a/hphp/runtime/ext/asio/ext_await-all-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_await-all-wait-handle.h @@ -147,7 +147,7 @@ Object HHVM_STATIC_METHOD(AwaitAllWaitHandle, fromVector, const Variant& dependencies); inline c_AwaitAllWaitHandle* c_Awaitable::asAwaitAll() { - assert(getKind() == Kind::AwaitAll); + assertx(getKind() == Kind::AwaitAll); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_condition-wait-handle.cpp b/hphp/runtime/ext/asio/ext_condition-wait-handle.cpp index e720a137c82..85a8f16a4bb 100644 --- a/hphp/runtime/ext/asio/ext_condition-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_condition-wait-handle.cpp @@ -67,7 +67,7 @@ Object HHVM_STATIC_METHOD(ConditionWaitHandle, create, throwNotNotifiedException(); } - assert(child_wh->instanceof(c_WaitableWaitHandle::classof())); + assertx(child_wh->instanceof(c_WaitableWaitHandle::classof())); auto const child_wwh = static_cast(child_wh); auto wh = req::make(); @@ -81,7 +81,7 @@ void HHVM_METHOD(ConditionWaitHandle, succeed, const Variant& result) { failAlreadyFinished(); } - assert(obj->getState() == c_ConditionWaitHandle::STATE_BLOCKED); + assertx(obj->getState() == c_ConditionWaitHandle::STATE_BLOCKED); auto parentChain = obj->getParentChain(); obj->setState(c_ConditionWaitHandle::STATE_SUCCEEDED); cellDup(*result.asCell(), obj->m_resultOrException); @@ -99,7 +99,7 @@ void HHVM_METHOD(ConditionWaitHandle, fail, const Object& exception) { failAlreadyFinished(); } - assert(obj->getState() == c_ConditionWaitHandle::STATE_BLOCKED); + assertx(obj->getState() == c_ConditionWaitHandle::STATE_BLOCKED); auto parentChain = obj->getParentChain(); obj->setState(c_ConditionWaitHandle::STATE_FAILED); cellDup(make_tv(exception.get()), obj->m_resultOrException); @@ -107,7 +107,7 @@ void HHVM_METHOD(ConditionWaitHandle, fail, const Object& exception) { } void c_ConditionWaitHandle::initialize(c_WaitableWaitHandle* child) { - assert(!child->isFinished()); + assertx(!child->isFinished()); setState(STATE_BLOCKED); setContextIdx(child->getContextIdx()); @@ -148,7 +148,7 @@ String c_ConditionWaitHandle::getName() { } c_WaitableWaitHandle* c_ConditionWaitHandle::getChild() { - assert(getState() == STATE_BLOCKED); + assertx(getState() == STATE_BLOCKED); return m_child; } diff --git a/hphp/runtime/ext/asio/ext_condition-wait-handle.h b/hphp/runtime/ext/asio/ext_condition-wait-handle.h index ff587ce97b8..0de0c916f9c 100644 --- a/hphp/runtime/ext/asio/ext_condition-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_condition-wait-handle.h @@ -77,7 +77,7 @@ void HHVM_METHOD(ConditionWaitHandle, succeed, const Variant& result); void HHVM_METHOD(ConditionWaitHandle, fail, const Object& exception); inline c_ConditionWaitHandle* c_Awaitable::asCondition() { - assert(getKind() == Kind::Condition); + assertx(getKind() == Kind::Condition); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.cpp b/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.cpp index 0265bbe65d1..c21bf9ca93d 100644 --- a/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.cpp @@ -48,7 +48,7 @@ void HHVM_STATIC_METHOD(ExternalThreadEventWaitHandle, setOnFailCallback, } void c_ExternalThreadEventWaitHandle::sweep() { - assert(getState() == STATE_WAITING); + assertx(getState() == STATE_WAITING); if (m_event->cancel()) { // canceled; the processing thread will take care of cleanup @@ -109,8 +109,8 @@ void c_ExternalThreadEventWaitHandle::destroyEvent(bool sweeping /*= false */) { } void c_ExternalThreadEventWaitHandle::abandon(bool sweeping) { - assert(getState() == STATE_WAITING); - assert(hasExactlyOneRef() || sweeping); + assertx(getState() == STATE_WAITING); + assertx(hasExactlyOneRef() || sweeping); if (isInContext()) { unregisterFromContext(); @@ -158,7 +158,7 @@ bool c_ExternalThreadEventWaitHandle::cancel(const Object& exception) { } void c_ExternalThreadEventWaitHandle::process() { - assert(getState() == STATE_WAITING); + assertx(getState() == STATE_WAITING); if (isInContext()) { unregisterFromContext(); @@ -174,7 +174,7 @@ void c_ExternalThreadEventWaitHandle::process() { try { m_event->unserialize(result); } catch (const Object& exception) { - assert(exception->instanceof(SystemLib::s_ThrowableClass)); + assertx(exception->instanceof(SystemLib::s_ThrowableClass)); auto parentChain = getParentChain(); setState(STATE_FAILED); tvWriteObject(exception.get(), &m_resultOrException); @@ -200,7 +200,7 @@ void c_ExternalThreadEventWaitHandle::process() { throw; } - assert(cellIsPlausible(result)); + assertx(cellIsPlausible(result)); auto parentChain = getParentChain(); setState(STATE_SUCCEEDED); cellCopy(result, m_resultOrException); @@ -223,9 +223,9 @@ String c_ExternalThreadEventWaitHandle::getName() { } void c_ExternalThreadEventWaitHandle::exitContext(context_idx_t ctx_idx) { - assert(AsioSession::Get()->getContext(ctx_idx)); - assert(getState() == STATE_WAITING); - assert(getContextIdx() == ctx_idx); + assertx(AsioSession::Get()->getContext(ctx_idx)); + assertx(getState() == STATE_WAITING); + assertx(getContextIdx() == ctx_idx); // Move us to the parent context. setContextIdx(getContextIdx() - 1); diff --git a/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.h b/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.h index 2d024a3e914..9c626369527 100644 --- a/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_external-thread-event-wait-handle.h @@ -46,11 +46,11 @@ struct c_ExternalThreadEventWaitHandle final : c_WaitableWaitHandle { Create(AsioExternalThreadEvent* event, ObjectData* priv_data); c_ExternalThreadEventWaitHandle* getNextToProcess() { - assert(getState() == STATE_WAITING); + assertx(getState() == STATE_WAITING); return m_nextToProcess; } void setNextToProcess(c_ExternalThreadEventWaitHandle* next) { - assert(getState() == STATE_WAITING); + assertx(getState() == STATE_WAITING); m_nextToProcess = next; } ObjectData* getPrivData() { return m_privData.get(); } @@ -96,7 +96,7 @@ void HHVM_STATIC_METHOD(ExternalThreadEventWaitHandle, setOnFailCallback, const Variant& callback); inline c_ExternalThreadEventWaitHandle* c_Awaitable::asExternalThreadEvent() { - assert(getKind() == Kind::ExternalThreadEvent); + assertx(getKind() == Kind::ExternalThreadEvent); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_reschedule-wait-handle.cpp b/hphp/runtime/ext/asio/ext_reschedule-wait-handle.cpp index 7b351621089..74b11ec9b4e 100644 --- a/hphp/runtime/ext/asio/ext_reschedule-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_reschedule-wait-handle.cpp @@ -81,7 +81,7 @@ void c_RescheduleWaitHandle::scheduleInContext() { } void c_RescheduleWaitHandle::exitContext(context_idx_t ctx_idx) { - assert(AsioSession::Get()->getContext(ctx_idx)); + assertx(AsioSession::Get()->getContext(ctx_idx)); // stop before corrupting unioned data if (isFinished()) { @@ -89,7 +89,7 @@ void c_RescheduleWaitHandle::exitContext(context_idx_t ctx_idx) { } // not in a context being exited - assert(getContextIdx() <= ctx_idx); + assertx(getContextIdx() <= ctx_idx); if (getContextIdx() != ctx_idx) { return; } diff --git a/hphp/runtime/ext/asio/ext_reschedule-wait-handle.h b/hphp/runtime/ext/asio/ext_reschedule-wait-handle.h index b76286e19e5..3abcf8ac62e 100644 --- a/hphp/runtime/ext/asio/ext_reschedule-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_reschedule-wait-handle.h @@ -64,7 +64,7 @@ Object HHVM_STATIC_METHOD(RescheduleWaitHandle, create, int64_t queue, int64_t priority); inline c_RescheduleWaitHandle* c_Awaitable::asReschedule() { - assert(getKind() == Kind::Reschedule); + assertx(getKind() == Kind::Reschedule); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_resumable-wait-handle.h b/hphp/runtime/ext/asio/ext_resumable-wait-handle.h index f62eaa9c42f..18fa6cba70b 100644 --- a/hphp/runtime/ext/asio/ext_resumable-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_resumable-wait-handle.h @@ -56,7 +56,8 @@ struct c_ResumableWaitHandle : c_WaitableWaitHandle { }; inline c_ResumableWaitHandle* c_Awaitable::asResumable() { - assert(getKind() == Kind::AsyncFunction || getKind() == Kind::AsyncGenerator); + assertx(getKind() == Kind::AsyncFunction || + getKind() == Kind::AsyncGenerator); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_sleep-wait-handle.cpp b/hphp/runtime/ext/asio/ext_sleep-wait-handle.cpp index ee5f0d37c1b..1a9bdcf0120 100644 --- a/hphp/runtime/ext/asio/ext_sleep-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_sleep-wait-handle.cpp @@ -107,7 +107,7 @@ bool c_SleepWaitHandle::process() { return false; } - assert(getState() == STATE_WAITING); + assertx(getState() == STATE_WAITING); if (isInContext()) { unregisterFromContext(); @@ -136,9 +136,9 @@ String c_SleepWaitHandle::getName() { } void c_SleepWaitHandle::exitContext(context_idx_t ctx_idx) { - assert(AsioSession::Get()->getContext(ctx_idx)); - assert(getState() == STATE_WAITING); - assert(getContextIdx() == ctx_idx); + assertx(AsioSession::Get()->getContext(ctx_idx)); + assertx(getState() == STATE_WAITING); + assertx(getContextIdx() == ctx_idx); // Move us to the parent context. setContextIdx(getContextIdx() - 1); diff --git a/hphp/runtime/ext/asio/ext_sleep-wait-handle.h b/hphp/runtime/ext/asio/ext_sleep-wait-handle.h index b014041cfc3..586271d2789 100644 --- a/hphp/runtime/ext/asio/ext_sleep-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_sleep-wait-handle.h @@ -65,7 +65,7 @@ void HHVM_STATIC_METHOD(SleepWaitHandle, setOnSuccessCallback, Object HHVM_STATIC_METHOD(SleepWaitHandle, create, int64_t usecs); inline c_SleepWaitHandle* c_Awaitable::asSleep() { - assert(getKind() == Kind::Sleep); + assertx(getKind() == Kind::Sleep); return static_cast(this); } diff --git a/hphp/runtime/ext/asio/ext_static-wait-handle.cpp b/hphp/runtime/ext/asio/ext_static-wait-handle.cpp index 709bc9b9b4d..edb3e49ab93 100644 --- a/hphp/runtime/ext/asio/ext_static-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_static-wait-handle.cpp @@ -45,8 +45,8 @@ c_StaticWaitHandle* c_StaticWaitHandle::CreateSucceeded(const Cell result) { * - produces reference for the returned StaticWaitHandle object */ c_StaticWaitHandle* c_StaticWaitHandle::CreateFailed(ObjectData* exception) { - assert(exception); - assert(exception->instanceof(SystemLib::s_ThrowableClass)); + assertx(exception); + assertx(exception->instanceof(SystemLib::s_ThrowableClass)); auto waitHandle = req::make(); waitHandle->setState(STATE_FAILED); diff --git a/hphp/runtime/ext/asio/ext_static-wait-handle.h b/hphp/runtime/ext/asio/ext_static-wait-handle.h index ab9652e05ea..f81f2c6ea7e 100644 --- a/hphp/runtime/ext/asio/ext_static-wait-handle.h +++ b/hphp/runtime/ext/asio/ext_static-wait-handle.h @@ -42,7 +42,7 @@ struct c_StaticWaitHandle final : c_Awaitable { type_scan::getIndexForMalloc()) {} ~c_StaticWaitHandle() { - assert(isFinished()); + assertx(isFinished()); tvDecRefGen(&m_resultOrException); } diff --git a/hphp/runtime/ext/asio/ext_wait-handle.cpp b/hphp/runtime/ext/asio/ext_wait-handle.cpp index 2e423e25dc8..17424d4bafa 100644 --- a/hphp/runtime/ext/asio/ext_wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_wait-handle.cpp @@ -74,7 +74,7 @@ String HHVM_METHOD(Awaitable, getName) { return s_exception; } - assert(obj->instanceof(c_WaitableWaitHandle::classof())); + assertx(obj->instanceof(c_WaitableWaitHandle::classof())); return static_cast(obj)->getName(); } @@ -138,19 +138,19 @@ template typename finish_class() { DEBUG_ONLY auto const wh = c_Awaitable::classof(); auto cls = const_cast(T::classof()); - assert(wh && cls); - assert((cls == wh) || (cls->classof(wh))); - assert(cls->numDeclProperties() == 0); - assert(cls->numStaticProperties() == 0); + assertx(wh && cls); + assertx((cls == wh) || (cls->classof(wh))); + assertx(cls->numDeclProperties() == 0); + assertx(cls->numStaticProperties() == 0); DEBUG_ONLY auto const ctor = cls->getCtor(); - assert(ctor == wh->getCtor()); - assert(ctor->attrs() & AttrPrivate); - assert(ctor->attrs() & AttrFinal); + assertx(ctor == wh->getCtor()); + assertx(ctor->attrs() & AttrPrivate); + assertx(ctor->attrs() & AttrFinal); cls->allocExtraData(); - assert(!cls->m_extra->m_nativeDataInfo); - assert(!cls->m_extra->m_instanceCtor); - assert(!cls->m_extra->m_instanceDtor); + assertx(!cls->m_extra->m_nativeDataInfo); + assertx(!cls->m_extra->m_instanceCtor); + assertx(!cls->m_extra->m_instanceDtor); cls->m_extra.raw()->m_instanceCtor = asioInstanceCtor; cls->m_extra.raw()->m_instanceDtor = T::instanceDtor; } diff --git a/hphp/runtime/ext/asio/ext_wait-handle.h b/hphp/runtime/ext/asio/ext_wait-handle.h index 6f93947ea0b..7a13da63dd2 100644 --- a/hphp/runtime/ext/asio/ext_wait-handle.h +++ b/hphp/runtime/ext/asio/ext_wait-handle.h @@ -83,8 +83,8 @@ struct c_ExternalThreadEventWaitHandle; template T* wait_handle(const ObjectData* obj) { - assert(obj->instanceof(T::classof())); - assert(obj->isWaitHandle()); + assertx(obj->instanceof(T::classof())); + assertx(obj->isWaitHandle()); return static_cast(const_cast(obj)); } @@ -108,7 +108,7 @@ struct c_Awaitable : ObjectData { : ObjectData(cls, NoInit{}, ObjectData::NoDestructor, kind), m_tyindex(tyindex) { - assert(type_scan::isKnownType(tyindex)); + assertx(type_scan::isKnownType(tyindex)); } ~c_Awaitable() @@ -128,26 +128,26 @@ struct c_Awaitable : ObjectData { ) ? static_cast(cell.m_data.pobj) : nullptr; } static c_Awaitable* fromCellAssert(Cell cell) { - assert(cell.m_type == KindOfObject); - assert(cell.m_data.pobj->isWaitHandle()); + assertx(cell.m_type == KindOfObject); + assertx(cell.m_data.pobj->isWaitHandle()); return static_cast(cell.m_data.pobj); } bool isFinished() const { return getState() <= STATE_FAILED; } bool isSucceeded() const { return getState() == STATE_SUCCEEDED; } bool isFailed() const { return getState() == STATE_FAILED; } Cell getResult() const { - assert(isSucceeded()); + assertx(isSucceeded()); return m_resultOrException; } ObjectData* getException() const { - assert(isFailed()); + assertx(isFailed()); return m_resultOrException.m_data.pobj; } Kind getKind() const { return static_cast(m_kind_state >> 4); } uint8_t getState() const { return m_kind_state & 0x0F; } static uint8_t toKindState(Kind kind, uint8_t state) { - assert((uint8_t)kind < 0x10 && state < 0x10); + assertx((uint8_t)kind < 0x10 && state < 0x10); return ((uint8_t)kind << 4) | state; } void setKindState(Kind kind, uint8_t state) { diff --git a/hphp/runtime/ext/asio/ext_waitable-wait-handle-inl.h b/hphp/runtime/ext/asio/ext_waitable-wait-handle-inl.h index 2c499e6ed08..107216b883a 100644 --- a/hphp/runtime/ext/asio/ext_waitable-wait-handle-inl.h +++ b/hphp/runtime/ext/asio/ext_waitable-wait-handle-inl.h @@ -44,12 +44,12 @@ inline c_WaitableWaitHandle::~c_WaitableWaitHandle() { } inline context_idx_t c_WaitableWaitHandle::getContextIdx() const { - assert(!isFinished()); + assertx(!isFinished()); return m_contextIdx; } inline void c_WaitableWaitHandle::setContextIdx(context_idx_t ctx_idx) { - assert(!isFinished()); + assertx(!isFinished()); m_contextIdx = ctx_idx; } @@ -58,12 +58,12 @@ inline bool c_WaitableWaitHandle::isInContext() const { } inline AsioContext* c_WaitableWaitHandle::getContext() const { - assert(isInContext()); + assertx(isInContext()); return AsioSession::Get()->getContext(getContextIdx()); } inline AsioBlockableChain& c_WaitableWaitHandle::getParentChain() { - assert(!isFinished()); + assertx(!isFinished()); return m_parentChain; } diff --git a/hphp/runtime/ext/asio/ext_waitable-wait-handle.cpp b/hphp/runtime/ext/asio/ext_waitable-wait-handle.cpp index 85b5a513524..9a351550523 100644 --- a/hphp/runtime/ext/asio/ext_waitable-wait-handle.cpp +++ b/hphp/runtime/ext/asio/ext_waitable-wait-handle.cpp @@ -39,7 +39,7 @@ void c_WaitableWaitHandle::join() { EagerVMRegAnchor _; auto const savedFP = vmfp(); - assert(!isFinished()); + assertx(!isFinished()); AsioSession* session = AsioSession::Get(); if (UNLIKELY(session->hasOnJoin())) { @@ -56,7 +56,7 @@ void c_WaitableWaitHandle::join() { // run queues until we are finished session->getCurrentContext()->runUntil(this); - assert(isFinished()); + assertx(isFinished()); } String c_WaitableWaitHandle::getName() { @@ -74,7 +74,7 @@ String c_WaitableWaitHandle::getName() { } c_WaitableWaitHandle* c_WaitableWaitHandle::getChild() { - assert(!isFinished()); + assertx(!isFinished()); switch (getKind()) { case Kind::Static: not_reached(); @@ -91,7 +91,7 @@ c_WaitableWaitHandle* c_WaitableWaitHandle::getChild() { bool c_WaitableWaitHandle::isDescendantOf(c_WaitableWaitHandle* wait_handle) const { - assert(wait_handle); + assertx(wait_handle); while (wait_handle != this && wait_handle && !wait_handle->isFinished()) { wait_handle = wait_handle->getChild(); @@ -102,7 +102,7 @@ c_WaitableWaitHandle::isDescendantOf(c_WaitableWaitHandle* wait_handle) const { void c_WaitableWaitHandle::throwCycleException(c_WaitableWaitHandle* child) const { - assert(isDescendantOf(child)); + assertx(isDescendantOf(child)); req::vector exception_msg_items; exception_msg_items.push_back("Encountered dependency cycle.\n"); diff --git a/hphp/runtime/ext/async_mysql/ext_async_mysql.cpp b/hphp/runtime/ext/async_mysql/ext_async_mysql.cpp index ca8d2e28efd..c697c462a72 100644 --- a/hphp/runtime/ext/async_mysql/ext_async_mysql.cpp +++ b/hphp/runtime/ext/async_mysql/ext_async_mysql.cpp @@ -39,7 +39,7 @@ namespace HPHP { Class* cls::getClass() { \ if (s_class == nullptr) { \ s_class = Unit::lookupClass(s_className.get()); \ - assert(s_class); \ + assertx(s_class); \ } \ return s_class; \ } \ @@ -273,7 +273,7 @@ static Object newAsyncMysqlConnectEvent( return Object{event->getWaitHandle()}; } catch (...) { - assert(false); + assertx(false); event->abandon(); return Object{}; } @@ -659,7 +659,7 @@ Object AsyncMysqlConnection::query( } catch (...) { LOG(ERROR) << "Unexpected exception while beginning ConnectOperation"; - assert(false); + assertx(false); event->abandon(); return Object{}; } @@ -783,7 +783,7 @@ static Object HHVM_METHOD( return Object{event->getWaitHandle()}; } catch (...) { - assert(false); + assertx(false); event->abandon(); return Object{}; } @@ -1244,7 +1244,7 @@ void throwAsyncMysqlException(const char* exception_type, auto error = AsyncMysqlErrorResult::newInstance(op, std::move(clientStats)); - assert(op->result() == am::OperationResult::Failed || + assertx(op->result() == am::OperationResult::Failed || op->result() == am::OperationResult::TimedOut || op->result() == am::OperationResult::Cancelled); @@ -1260,7 +1260,7 @@ void throwAsyncMysqlQueryException(const char* exception_type, auto error = AsyncMysqlQueryErrorResult::newInstance( op, std::move(clientStats), res); - assert(op->result() == am::OperationResult::Failed || + assertx(op->result() == am::OperationResult::Failed || op->result() == am::OperationResult::TimedOut || op->result() == am::OperationResult::Cancelled); @@ -1285,7 +1285,7 @@ void AsyncMysqlConnectEvent::unserialize(Cell& result) { void AsyncMysqlQueryEvent::unserialize(Cell& result) { // Retrieve the original conn and return the underlying connection // to it. - assert(getPrivData()->instanceof(AsyncMysqlConnection::getClass())); + assertx(getPrivData()->instanceof(AsyncMysqlConnection::getClass())); auto* conn = Native::data(getPrivData()); conn->setConnection(m_query_op->releaseConnection()); @@ -1307,7 +1307,7 @@ void AsyncMysqlMultiQueryEvent::unserialize(Cell& result) { // Same as unserialize from AsyncMysqlQueryEvent but the result is a // vector of query results if (getPrivData() != nullptr) { - assert(getPrivData()->instanceof(AsyncMysqlConnection::getClass())); + assertx(getPrivData()->instanceof(AsyncMysqlConnection::getClass())); auto* conn = Native::data(getPrivData()); conn->setConnection(m_multi_op->releaseConnection()); } diff --git a/hphp/runtime/ext/bz2/bz2-file.cpp b/hphp/runtime/ext/bz2/bz2-file.cpp index fd83a200a3c..3b180f73038 100644 --- a/hphp/runtime/ext/bz2/bz2-file.cpp +++ b/hphp/runtime/ext/bz2/bz2-file.cpp @@ -41,7 +41,7 @@ void BZ2File::sweep() { } bool BZ2File::open(const String& filename, const String& mode) { - assert(m_bzFile == nullptr); + assertx(m_bzFile == nullptr); return m_innerFile->open(filename, mode) && (m_bzFile = BZ2_bzdopen(dup(m_innerFile->fd()), mode.data())); @@ -53,14 +53,14 @@ bool BZ2File::close() { } int64_t BZ2File::errnu() { - assert(m_bzFile); + assertx(m_bzFile); int errnum = 0; BZ2_bzerror(m_bzFile, &errnum); return errnum; } String BZ2File::errstr() { - assert(m_bzFile); + assertx(m_bzFile); int errnum; return BZ2_bzerror(m_bzFile, &errnum); } @@ -70,7 +70,7 @@ const StaticString s_errstr("errstr"); Array BZ2File::error() { - assert(m_bzFile); + assertx(m_bzFile); int errnum; const char * errstr; errstr = BZ2_bzerror(m_bzFile, &errnum); @@ -78,7 +78,7 @@ Array BZ2File::error() { } bool BZ2File::flush() { - assert(m_bzFile); + assertx(m_bzFile); return BZ2_bzflush(m_bzFile); } @@ -86,7 +86,7 @@ int64_t BZ2File::readImpl(char * buf, int64_t length) { if (length == 0) { return 0; } - assert(m_bzFile); + assertx(m_bzFile); int len = BZ2_bzread(m_bzFile, buf, length); /* Sometimes libbz2 will return fewer bytes than requested, and set bzerror * to BZ_STREAM_END, but it's not actually EOF, and you can keep reading from @@ -102,7 +102,7 @@ int64_t BZ2File::readImpl(char * buf, int64_t length) { } int64_t BZ2File::writeImpl(const char * buf, int64_t length) { - assert(m_bzFile); + assertx(m_bzFile); return BZ2_bzwrite(m_bzFile, (char *)buf, length); } @@ -122,7 +122,7 @@ bool BZ2File::closeImpl() { } bool BZ2File::eof() { - assert(m_bzFile); + assertx(m_bzFile); return getEof(); } diff --git a/hphp/runtime/ext/bz2/ext_bz2.cpp b/hphp/runtime/ext/bz2/ext_bz2.cpp index 2dec6d97def..5ee095fc99a 100644 --- a/hphp/runtime/ext/bz2/ext_bz2.cpp +++ b/hphp/runtime/ext/bz2/ext_bz2.cpp @@ -43,7 +43,7 @@ struct BZ2StreamWrapper final : Stream::Wrapper { static const char cz[] = "compress.bzip2://"; if (strncmp(filename.c_str(), cz, sizeof(cz) - 1)) { - assert(false); + assertx(false); return nullptr; } diff --git a/hphp/runtime/ext/collections/ext_collections-map.cpp b/hphp/runtime/ext/collections/ext_collections-map.cpp index 505c8d3df78..eb0cc9a6a39 100644 --- a/hphp/runtime/ext/collections/ext_collections-map.cpp +++ b/hphp/runtime/ext/collections/ext_collections-map.cpp @@ -146,18 +146,18 @@ void BaseMap::addAllPairs(const Variant& iterable) { Variant BaseMap::firstKey() { if (!m_size) return uninit_variant; auto e = firstElm(); - assert(e != elmLimit()); + assertx(e != elmLimit()); if (e->hasIntKey()) { return e->ikey; } - assert(e->hasStrKey()); + assertx(e->hasStrKey()); return Variant{e->skey}; } Variant BaseMap::firstValue() { if (!m_size) return uninit_variant; auto e = firstElm(); - assert(e != elmLimit()); + assertx(e != elmLimit()); return tvAsCVarRef(&e->data); } @@ -169,13 +169,13 @@ Variant BaseMap::lastKey() { // manual while loop. uint32_t pos = posLimit() - 1; while (isTombstone(pos)) { - assert(pos > 0); + assertx(pos > 0); --pos; } if (data()[pos].hasIntKey()) { return data()[pos].ikey; } - assert(data()[pos].hasStrKey()); + assertx(data()[pos].hasStrKey()); return Variant{data()[pos].skey}; } @@ -187,7 +187,7 @@ Variant BaseMap::lastValue() { // manual while loop. uint32_t pos = posLimit() - 1; while (isTombstone(pos)) { - assert(pos > 0); + assertx(pos > 0); --pos; } return tvAsCVarRef(&data()[pos].data); @@ -216,7 +216,7 @@ Variant BaseMap::pop() { mutate(); auto e = elmLimit() - 1; for (;; --e) { - assert(e >= data()); + assertx(e >= data()); if (!isTombstone(e)) break; } Variant ret = tvAsCVarRef(&e->data); @@ -234,7 +234,7 @@ Variant BaseMap::popFront() { mutate(); auto e = data(); for (;; ++e) { - assert(e != elmLimit()); + assertx(e != elmLimit()); if (!isTombstone(e)) break; } Variant ret = tvAsCVarRef(&e->data); @@ -251,12 +251,12 @@ void BaseMap::setImpl(int64_t k, TypedValue tv) { if (!raw) { mutate(); } - assert(tv.m_type != KindOfRef); - assert(canMutateBuffer()); + assertx(tv.m_type != KindOfRef); + assertx(canMutateBuffer()); auto h = hash_int64(k); retry: auto p = findForInsert(k, h); - assert(MixedArray::isValidIns(p)); + assertx(MixedArray::isValidIns(p)); if (MixedArray::isValidPos(*p)) { auto& e = data()[(int32_t)*p]; auto const old = e.data; @@ -280,12 +280,12 @@ void BaseMap::setImpl(StringData* key, TypedValue tv) { if (!raw) { mutate(); } - assert(tv.m_type != KindOfRef); - assert(canMutateBuffer()); + assertx(tv.m_type != KindOfRef); + assertx(canMutateBuffer()); retry: strhash_t h = key->hash(); auto p = findForInsert(key, h); - assert(MixedArray::isValidIns(p)); + assertx(MixedArray::isValidIns(p)); if (MixedArray::isValidPos(*p)) { auto& e = data()[(int32_t)*p]; auto const old = e.data; @@ -322,7 +322,7 @@ void BaseMap::OffsetSet(ObjectData* obj, const TypedValue* key, } bool BaseMap::OffsetIsset(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto map = static_cast(obj); TypedValue* result; if (key->m_type == KindOfInt64) { @@ -337,7 +337,7 @@ bool BaseMap::OffsetIsset(ObjectData* obj, const TypedValue* key) { } bool BaseMap::OffsetEmpty(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto map = static_cast(obj); TypedValue* result; if (key->m_type == KindOfInt64) { @@ -352,7 +352,7 @@ bool BaseMap::OffsetEmpty(ObjectData* obj, const TypedValue* key) { } bool BaseMap::OffsetContains(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto map = static_cast(obj); if (key->m_type == KindOfInt64) { return map->contains(key->m_data.num); @@ -364,7 +364,7 @@ bool BaseMap::OffsetContains(ObjectData* obj, const TypedValue* key) { } void BaseMap::OffsetUnset(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto map = static_cast(obj); if (key->m_type == KindOfInt64) { map->remove(key->m_data.num); @@ -403,7 +403,7 @@ BaseMap::php_differenceByKey(const Variant& it) { if (e->hasIntKey()) { target->remove((int64_t)e->ikey); } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); target->remove(e->skey); } } @@ -415,7 +415,7 @@ BaseMap::php_differenceByKey(const Variant& it) { if (k.isInteger()) { target->remove(k.toInt64()); } else { - assert(k.isString()); + assertx(k.isString()); target->remove(k.getStringData()); } } @@ -458,7 +458,7 @@ Object BaseMap::php_retain(const Variant& callback) { eraseNoCompact(pp); } - assert(m_size <= size); + assertx(m_size <= size); compactOrShrinkIfDensityTooLow(); return Object{this}; } @@ -485,7 +485,7 @@ BaseMap::php_zip(const Variant& iterable) { if (e.hasIntKey()) { map->setRaw(e.ikey, tv); } else { - assert(e.hasStrKey()); + assertx(e.hasStrKey()); map->setRaw(e.skey, tv); } ++iter; @@ -528,7 +528,7 @@ BaseMap::php_take(const Variant& n) { if (toE.hasIntKey()) { map->updateNextKI(toE.ikey); } else { - assert(toE.hasStrKey()); + assertx(toE.hasStrKey()); } } return Object{std::move(map)}; @@ -556,7 +556,7 @@ BaseMap::php_skip(const Variant& n) { return Object{std::move(map)}; } size_t sz = size_t(m_size) - size_t(len); - assert(sz); + assertx(sz); map->reserve(sz); map->setSize(sz); map->setPosLimit(sz); @@ -571,7 +571,7 @@ BaseMap::php_skip(const Variant& n) { if (toE.hasIntKey()) { map->updateNextKI(toE.ikey); } else { - assert(toE.hasStrKey()); + assertx(toE.hasStrKey()); } } return Object{std::move(map)}; @@ -603,7 +603,7 @@ BaseMap::php_skipWhile(const Variant& fn) { if (e->hasIntKey()) { map->set(e->ikey, e->data); } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); map->set(e->skey, e->data); } } @@ -643,7 +643,7 @@ BaseMap::php_slice(const Variant& start, const Variant& len) { if (toE.hasIntKey()) { map->updateNextKI(toE.ikey); } else { - assert(toE.hasStrKey()); + assertx(toE.hasStrKey()); } } return Object{std::move(map)}; @@ -659,7 +659,7 @@ BaseMap::php_concat(const Variant& iterable) { auto vec = req::make(); uint32_t sz = m_size; vec->reserve((size_t)sz + itSize); - assert(vec->canMutateBuffer()); + assertx(vec->canMutateBuffer()); vec->setSize(sz); uint32_t used = posLimit(); for (uint32_t i = 0, j = 0; i < used; ++i) { @@ -720,7 +720,7 @@ BaseMap::FromArray(const Class*, const Variant& arr) { if (k.isInteger()) { map->setRaw(k.toInt64(), tv); } else { - assert(k.isString()); + assertx(k.isString()); map->setRaw(k.getStringData(), tv); } } @@ -748,9 +748,9 @@ Object c_Map::getImmutableCopy() { m_immCopy = std::move(map); arrayData()->incRefCount(); } - assert(!m_immCopy.isNull()); - assert(data() == static_cast(m_immCopy.get())->data()); - assert(arrayData()->hasMultipleRefs()); + assertx(!m_immCopy.isNull()); + assertx(data() == static_cast(m_immCopy.get())->data()); + assertx(arrayData()->hasMultipleRefs()); return m_immCopy; } diff --git a/hphp/runtime/ext/collections/ext_collections-map.h b/hphp/runtime/ext/collections/ext_collections-map.h index ba853f7125f..30a2a5a7651 100644 --- a/hphp/runtime/ext/collections/ext_collections-map.h +++ b/hphp/runtime/ext/collections/ext_collections-map.h @@ -32,7 +32,7 @@ public: // init(), used by Map::__construct() // expects an iterable of key=>value void init(const Variant& t) { - assert(m_size == 0); + assertx(m_size == 0); addAllImpl(t); } // addAllPairs(), used by Map::addAll() @@ -68,7 +68,7 @@ public: void set(int64_t k, const Variant& v) { set(k, *v.asCell()); } void set(StringData* k, const Variant& v) { set(k, *v.asCell()); } void set(TypedValue k, TypedValue v) { - assert(k.m_type != KindOfRef); + assertx(k.m_type != KindOfRef); if (k.m_type == KindOfInt64) { set(k.m_data.num, v); } else if (isStringType(k.m_type)) { @@ -191,7 +191,7 @@ protected: void setRaw(StringData* k, const Variant& v) { setRaw(k, *v.asCell()); } void setRaw(TypedValue k, TypedValue v) { - assert(k.m_type != KindOfRef); + assertx(k.m_type != KindOfRef); if (k.m_type == KindOfInt64) { setRaw(k.m_data.num, v); } else if (isStringType(k.m_type)) { @@ -257,7 +257,7 @@ protected: auto target = req::make(); int64_t sz = m_size; target->reserve(sz); - assert(target->canMutateBuffer()); + assertx(target->canMutateBuffer()); target->setSize(sz); auto* out = target->data(); auto* eLimit = elmLimit(); @@ -271,7 +271,7 @@ protected: Object php_keys() { auto vec = req::make(); vec->reserve(m_size); - assert(vec->canMutateBuffer()); + assertx(vec->canMutateBuffer()); auto* e = firstElm(); auto* eLimit = elmLimit(); ssize_t j = 0; @@ -280,7 +280,7 @@ protected: vec->data()[j].m_data.num = e->ikey; vec->data()[j].m_type = KindOfInt64; } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); cellDup(make_tv(e->skey), vec->data()[j]); } } diff --git a/hphp/runtime/ext/collections/ext_collections-set.cpp b/hphp/runtime/ext/collections/ext_collections-set.cpp index 157f2cfefe9..acd38817ef6 100644 --- a/hphp/runtime/ext/collections/ext_collections-set.cpp +++ b/hphp/runtime/ext/collections/ext_collections-set.cpp @@ -29,7 +29,7 @@ bool invokeAndCastToBool(const CallCtx& ctx, int argc, // BaseSet void BaseSet::addAllKeysOf(const Cell container) { - assert(isContainer(container)); + assertx(isContainer(container)); decltype(cap()) oldCap = 0; bool ok = @@ -113,7 +113,7 @@ void BaseSet::addImpl(int64_t k) { } auto h = hash_int64(k); auto p = findForInsert(k, h); - assert(MixedArray::isValidIns(p)); + assertx(MixedArray::isValidIns(p)); if (MixedArray::isValidPos(*p)) { // When there is a conflict, the add() API is supposed to replace the // existing element with the new element in place. However since Sets @@ -141,7 +141,7 @@ void BaseSet::addImpl(StringData *key) { } strhash_t h = key->hash(); auto p = findForInsert(key, h); - assert(MixedArray::isValidIns(p)); + assertx(MixedArray::isValidIns(p)); if (MixedArray::isValidPos(*p)) { return; } @@ -176,7 +176,7 @@ void BaseSet::addFront(int64_t k) { mutate(); auto h = hash_int64(k); auto p = findForInsert(k, h); - assert(MixedArray::isValidIns(p)); + assertx(MixedArray::isValidIns(p)); if (MixedArray::isValidPos(*p)) { // When there is a conflict, the addFront() API is supposed to replace // the existing element with the new element in place. However since @@ -200,7 +200,7 @@ void BaseSet::addFront(StringData *key) { mutate(); strhash_t h = key->hash(); auto p = findForInsert(key, h); - assert(MixedArray::isValidIns(p)); + assertx(MixedArray::isValidIns(p)); if (MixedArray::isValidPos(*p)) { return; } @@ -222,7 +222,7 @@ Variant BaseSet::pop() { mutate(); auto e = elmLimit() - 1; for (;; --e) { - assert(e >= data()); + assertx(e >= data()); if (!isTombstone(e)) break; } Variant ret = tvAsCVarRef(&e->data); @@ -240,7 +240,7 @@ Variant BaseSet::popFront() { mutate(); auto e = data(); for (;; ++e) { - assert(e != elmLimit()); + assertx(e != elmLimit()); if (!isTombstone(e)) break; } Variant ret = tvAsCVarRef(&e->data); @@ -254,7 +254,7 @@ Variant BaseSet::popFront() { Variant BaseSet::firstValue() { if (!m_size) return init_null(); auto e = firstElm(); - assert(e != elmLimit()); + assertx(e != elmLimit()); return tvAsCVarRef(&e->data); } @@ -266,7 +266,7 @@ Variant BaseSet::lastValue() { // manual while loop. uint32_t pos = posLimit() - 1; while (isTombstone(pos)) { - assert(pos > 0); + assertx(pos > 0); --pos; } return tvAsCVarRef(&data()[pos].data); @@ -296,9 +296,9 @@ Object c_Set::getImmutableCopy() { m_immCopy = std::move(set); arrayData()->incRefCount(); } - assert(!m_immCopy.isNull()); - assert(data() == static_cast(m_immCopy.get())->data()); - assert(arrayData()->hasMultipleRefs()); + assertx(!m_immCopy.isNull()); + assertx(data() == static_cast(m_immCopy.get())->data()); + assertx(arrayData()->hasMultipleRefs()); return m_immCopy; } @@ -335,7 +335,7 @@ BaseSet::Clone(ObjectData* obj) { } bool BaseSet::OffsetIsset(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto set = static_cast(obj); if (key->m_type == KindOfInt64) { return set->contains(key->m_data.num); @@ -348,7 +348,7 @@ bool BaseSet::OffsetIsset(ObjectData* obj, const TypedValue* key) { } bool BaseSet::OffsetEmpty(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto set = static_cast(obj); if (key->m_type == KindOfInt64) { return set->contains(key->m_data.num) ? !cellToBool(*key) : true; @@ -361,7 +361,7 @@ bool BaseSet::OffsetEmpty(ObjectData* obj, const TypedValue* key) { } bool BaseSet::OffsetContains(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto set = static_cast(obj); if (key->m_type == KindOfInt64) { return set->contains(key->m_data.num); @@ -374,7 +374,7 @@ bool BaseSet::OffsetContains(ObjectData* obj, const TypedValue* key) { } void BaseSet::OffsetUnset(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto set = static_cast(obj); if (key->m_type == KindOfInt64) { set->remove(key->m_data.num); @@ -400,11 +400,11 @@ BaseSet::php_map(const Variant& callback) { } auto set = req::make(); if (!m_size) return Object{std::move(set)}; - assert(posLimit() != 0); - assert(set->arrayData() == staticEmptyDictArrayAsMixed()); + assertx(posLimit() != 0); + assertx(set->arrayData() == staticEmptyDictArrayAsMixed()); auto oldCap = set->cap(); set->reserve(posLimit()); // presume minimum collisions ... - assert(set->canMutateBuffer()); + assertx(set->canMutateBuffer()); constexpr int64_t argc = useKey ? 2 : 1; TypedValue argv[argc]; for (ssize_t pos = iter_begin(); iter_valid(pos); pos = iter_next(pos)) { @@ -452,7 +452,7 @@ BaseSet::php_filter(const Variant& callback) { if (e->hasIntKey()) { set->addRaw(e->data.m_data.num); } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); set->addRaw(e->data.m_data.pstr); } } @@ -501,7 +501,7 @@ Object BaseSet::php_retain(const Variant& callback) { findForRemove(e->skey, h); eraseNoCompact(pp); } - assert(m_size <= size); + assertx(m_size <= size); compactOrShrinkIfDensityTooLow(); return Object{this}; } @@ -540,7 +540,7 @@ BaseSet::php_take(const Variant& n) { if (toE.hasIntKey()) { set->updateNextKI(toE.ikey); } else { - assert(toE.hasStrKey()); + assertx(toE.hasStrKey()); } } return Object{std::move(set)}; @@ -569,7 +569,7 @@ BaseSet::php_takeWhile(const Variant& fn) { if (e->hasIntKey()) { set->addRaw(e->data.m_data.num); } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); set->addRaw(e->data.m_data.pstr); } } @@ -597,7 +597,7 @@ BaseSet::php_skip(const Variant& n) { return Object{std::move(set)}; } size_t sz = size_t(m_size) - size_t(len); - assert(sz); + assertx(sz); set->reserve(sz); set->setSize(sz); set->setPosLimit(sz); @@ -606,7 +606,7 @@ BaseSet::php_skip(const Variant& n) { auto mask = set->tableMask(); for (uint32_t toPos = 0; toPos < sz; ++toPos, ++frPos) { while (isTombstone(frPos)) { - assert(frPos + 1 < posLimit()); + assertx(frPos + 1 < posLimit()); ++frPos; } auto& toE = set->data()[toPos]; @@ -615,7 +615,7 @@ BaseSet::php_skip(const Variant& n) { if (toE.hasIntKey()) { set->updateNextKI(toE.ikey); } else { - assert(toE.hasStrKey()); + assertx(toE.hasStrKey()); } } return Object{std::move(set)}; @@ -649,7 +649,7 @@ BaseSet::php_skipWhile(const Variant& fn) { if (e.hasIntKey()) { set->addRaw(e.data.m_data.num); } else { - assert(e.hasStrKey()); + assertx(e.hasStrKey()); set->addRaw(e.data.m_data.pstr); } } @@ -687,7 +687,7 @@ BaseSet::php_slice(const Variant& start, const Variant& len) { if (toE.hasIntKey()) { set->updateNextKI(toE.ikey); } else { - assert(toE.hasStrKey()); + assertx(toE.hasStrKey()); } } return Object{std::move(set)}; @@ -702,7 +702,7 @@ BaseSet::php_concat(const Variant& iterable) { auto vec = req::make(); uint32_t sz = m_size; vec->reserve((size_t)sz + itSize); - assert(vec->canMutateBuffer()); + assertx(vec->canMutateBuffer()); vec->setSize(sz); uint32_t used = posLimit(); diff --git a/hphp/runtime/ext/collections/ext_collections-set.h b/hphp/runtime/ext/collections/ext_collections-set.h index fbc9d4919e0..90feee32938 100644 --- a/hphp/runtime/ext/collections/ext_collections-set.h +++ b/hphp/runtime/ext/collections/ext_collections-set.h @@ -27,7 +27,7 @@ struct BaseSet : HashCollection { void addAll(const Variant& t); void init(const Variant& t) { - assert(m_size == 0); + assertx(m_size == 0); addAll(t); } @@ -38,7 +38,7 @@ protected: void addRaw(int64_t k); void addRaw(StringData* k); void addRaw(Cell tv) { - assert(tv.m_type != KindOfRef); + assertx(tv.m_type != KindOfRef); if (tv.m_type == KindOfInt64) { addRaw(tv.m_data.num); } else if (isStringType(tv.m_type)) { @@ -56,7 +56,7 @@ public: void add(int64_t k); void add(StringData* k); void add(Cell tv) { - assert(tv.m_type != KindOfRef); + assertx(tv.m_type != KindOfRef); if (tv.m_type == KindOfInt64) { add(tv.m_data.num); } else if (isStringType(tv.m_type)) { @@ -116,7 +116,7 @@ public: if (key->m_type == KindOfInt64) { collections::throwUndef(key->m_data.num); } else { - assert(isStringType(key->m_type)); + assertx(isStringType(key->m_type)); collections::throwUndef(key->m_data.pstr); } } diff --git a/hphp/runtime/ext/collections/ext_collections-vector.cpp b/hphp/runtime/ext/collections/ext_collections-vector.cpp index f69317f8acc..dded8cf9b65 100644 --- a/hphp/runtime/ext/collections/ext_collections-vector.cpp +++ b/hphp/runtime/ext/collections/ext_collections-vector.cpp @@ -384,7 +384,7 @@ BaseVector::php_keys() { } bool BaseVector::OffsetIsset(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto vec = static_cast(obj); TypedValue* result; if (key->m_type == KindOfInt64) { @@ -397,7 +397,7 @@ bool BaseVector::OffsetIsset(ObjectData* obj, const TypedValue* key) { } bool BaseVector::OffsetEmpty(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto vec = static_cast(obj); TypedValue* result; if (key->m_type == KindOfInt64) { @@ -410,7 +410,7 @@ bool BaseVector::OffsetEmpty(ObjectData* obj, const TypedValue* key) { } bool BaseVector::OffsetContains(ObjectData* obj, const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); auto vec = static_cast(obj); if (key->m_type == KindOfInt64) { return vec->contains(key->m_data.num); @@ -427,7 +427,7 @@ bool BaseVector::Equals(const ObjectData* obj1, const ObjectData* obj2) { } void BaseVector::addFront(TypedValue tv) { - assert(tv.m_type != KindOfRef); + assertx(tv.m_type != KindOfRef); dropImmCopy(); auto oldAd = arrayData(); m_arr = PackedArray::PrependVec(oldAd, tv, oldAd->cowCheck()); @@ -456,7 +456,7 @@ void BaseVector::reserveImpl(uint32_t newCap) { m_arr = PackedArray::MakeReserveVec(newCap); arrayData()->m_size = m_size; if (LIKELY(!oldAd->cowCheck())) { - assert(oldAd->isVecArray()); + assertx(oldAd->isVecArray()); if (m_size > 0) { std::memcpy(data(), oldBuf, m_size * sizeof(TypedValue)); // Mark oldAd as having 0 elements so that the array release logic doesn't @@ -473,7 +473,7 @@ void BaseVector::reserveImpl(uint32_t newCap) { cellDup(*from++, *to++); } while (from < end); } - assert(!oldAd->decWillRelease()); + assertx(!oldAd->decWillRelease()); oldAd->decRefCount(); } } @@ -485,7 +485,7 @@ void BaseVector::reserve(uint32_t sz) { } else if (!canMutateBuffer()) { mutateImpl(); } - assert(canMutateBuffer()); + assertx(canMutateBuffer()); } /** @@ -501,7 +501,7 @@ BaseVector::~BaseVector() { void BaseVector::mutateImpl() { auto oldAd = arrayData(); m_arr = PackedArray::CopyVec(oldAd); - assert(!oldAd->decWillRelease()); + assertx(!oldAd->decWillRelease()); oldAd->decRefCount(); } @@ -524,7 +524,7 @@ BaseVector::fromKeysOf(const TypedValue& container) { auto vec = req::make(sz); vec->setSize(sz); ArrayIter iter(container); - assert(iter); + assertx(iter); auto elm = vec->data(); do { cellDup(*iter.first().asCell(), *elm++); @@ -541,10 +541,10 @@ Object BaseVector::getImmutableCopy() { arrayData()->incRefCount(); m_immCopy = std::move(vec); } - assert(!m_immCopy.isNull()); - assert(arrayData() == + assertx(!m_immCopy.isNull()); + assertx(arrayData() == static_cast(m_immCopy.get())->arrayData()); - assert(!canMutateBuffer()); + assertx(!canMutateBuffer()); return m_immCopy; } @@ -655,7 +655,7 @@ void c_Vector::splice(int64_t startPos, int64_t endPos) { // desctuctors may mutate this Vector (and need to see it in the fully // spliced state). The easiest way to do this is to copy the part we're // keeping into a new vec, swap them, and decref the old one. - assert(0 <= startPos && startPos < endPos && endPos <= m_size); + assertx(0 <= startPos && startPos < endPos && endPos <= m_size); uint32_t sz = m_size - (endPos - startPos); dropImmCopy(); auto oldBuf = data(); @@ -745,7 +745,7 @@ Object c_Vector::fromArray(const Class*, const Variant& arr) { auto end = elm + sz; ssize_t pos = ad->iter_begin(); do { - assert(pos != ad->iter_end()); + assertx(pos != ad->iter_end()); cellDup(tvToCell(ad->atPos(pos)), *elm); pos = ad->iter_advance(pos); } while (++elm < end); @@ -773,7 +773,7 @@ using VectorValAccessor = TVAccessor; */ template SortFlavor c_Vector::preSort(const AccessorT& acc) { - assert(m_size > 0); + assertx(m_size > 0); bool allInts = true; bool allStrs = true; auto elm = data(); diff --git a/hphp/runtime/ext/collections/ext_collections-vector.h b/hphp/runtime/ext/collections/ext_collections-vector.h index bea0a8a17de..866561b04a7 100644 --- a/hphp/runtime/ext/collections/ext_collections-vector.h +++ b/hphp/runtime/ext/collections/ext_collections-vector.h @@ -99,33 +99,33 @@ public: php_concat(const Variant& iterable); ArrayData* arrayData() { - assert(m_arr->isVecArray()); + assertx(m_arr->isVecArray()); return m_arr; } const ArrayData* arrayData() const { - assert(m_arr->isVecArray()); + assertx(m_arr->isVecArray()); return m_arr; } void setSize(uint32_t sz) { - assert(canMutateBuffer()); - assert(sz <= PackedArray::capacity(arrayData())); + assertx(canMutateBuffer()); + assertx(sz <= PackedArray::capacity(arrayData())); m_size = sz; arrayData()->m_size = sz; } void incSize() { - assert(canMutateBuffer()); - assert(m_size < PackedArray::capacity(arrayData())); + assertx(canMutateBuffer()); + assertx(m_size < PackedArray::capacity(arrayData())); ++m_size; arrayData()->m_size = m_size; } void decSize() { - assert(canMutateBuffer()); - assert(m_size > 0); + assertx(canMutateBuffer()); + assertx(m_size > 0); --m_size; arrayData()->m_size = m_size; } TypedValue* appendForUnserialize(int64_t k) { - assert(k == m_size); + assertx(k == m_size); incSize(); return &data()[k]; } @@ -183,7 +183,7 @@ public: return &data()[key]; } TypedValue* get(const TypedValue* key) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); if (LIKELY(key->m_type == KindOfInt64)) { return get(key->m_data.num); } @@ -195,7 +195,7 @@ public: } void init(const Variant& it) { - assert(m_size == 0); + assertx(m_size == 0); addAllImpl(it); } @@ -239,7 +239,7 @@ public: set(key, val.asCell()); } void set(const TypedValue* key, const TypedValue* val) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); if (key->m_type != KindOfInt64) { throwBadKeyType(); } @@ -259,8 +259,8 @@ public: * modify this Vector's buffer. */ bool canMutateBuffer() const { - assert(IMPLIES(!arrayData()->hasMultipleRefs(), m_immCopy.isNull())); - assert(m_size == arrayData()->m_size); + assertx(IMPLIES(!arrayData()->hasMultipleRefs(), m_immCopy.isNull())); + assertx(m_size == arrayData()->m_size); return !arrayData()->cowCheck(); } @@ -277,12 +277,12 @@ public: mutateImpl(); } } - assert(canMutateBuffer()); + assertx(canMutateBuffer()); } Object getImmutableCopy(); void dropImmCopy() { - assert(m_immCopy.isNull() || + assertx(m_immCopy.isNull() || (arrayData() == ((BaseVector*)m_immCopy.get())->arrayData() && !canMutateBuffer())); m_immCopy.reset(); @@ -312,10 +312,10 @@ protected: template ALWAYS_INLINE void addImpl(TypedValue tv) { - assert(tv.m_type != KindOfRef); + assertx(tv.m_type != KindOfRef); auto oldAd = arrayData(); if (raw) { - assert(canMutateBuffer()); + assertx(canMutateBuffer()); m_arr = PackedArray::AppendVec(oldAd, tv, false); } else { dropImmCopy(); @@ -337,8 +337,8 @@ protected: // check for an immutable buffer, so it's only safe to use in some cases. // If you're not sure, use set() instead. void setRaw(int64_t key, const TypedValue* val) { - assert(val->m_type != KindOfRef); - assert(canMutateBuffer()); + assertx(val->m_type != KindOfRef); + assertx(canMutateBuffer()); if (UNLIKELY((uint64_t)key >= (uint64_t)m_size)) { collections::throwOOB(key); return; @@ -352,7 +352,7 @@ protected: setRaw(key, val.asCell()); } void setRaw(const TypedValue* key, const TypedValue* val) { - assert(key->m_type != KindOfRef); + assertx(key->m_type != KindOfRef); if (key->m_type != KindOfInt64) { throwBadKeyType(); } diff --git a/hphp/runtime/ext/collections/hash-collection.cpp b/hphp/runtime/ext/collections/hash-collection.cpp index d1cf33370e4..8197590b7cd 100644 --- a/hphp/runtime/ext/collections/hash-collection.cpp +++ b/hphp/runtime/ext/collections/hash-collection.cpp @@ -20,7 +20,7 @@ HashCollection::HashCollection(Class* cls, HeaderKind kind, uint32_t cap) NEVER_INLINE void HashCollection::throwTooLarge() { - assert(getClassName().size() == 6); + assertx(getClassName().size() == 6); auto clsName = getClassName().get()->slice(); String msg(130, ReserveString); auto buf = msg.bufferSlice(); @@ -36,7 +36,7 @@ void HashCollection::throwTooLarge() { NEVER_INLINE void HashCollection::throwReserveTooLarge() { - assert(getClassName().size() == 6); + assertx(getClassName().size() == 6); auto clsName = getClassName().get()->slice(); String msg(80, ReserveString); auto buf = msg.bufferSlice(); @@ -70,7 +70,7 @@ void HashCollection::warnOnStrIntDup() const { if (e->hasIntKey()) { newVal = e->ikey; } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); // isStriclyInteger() puts the int value in newVal as a side effect. if (!e->skey->isStrictlyInteger(newVal)) continue; } @@ -104,8 +104,8 @@ Array HashCollection::toArray() { } auto ad = arrayData()->toPHPArray(true); if (UNLIKELY(ad->size() < m_size)) warnOnStrIntDup(); - assert(m_size); - assert(ad->m_pos == 0); + assertx(m_size); + assertx(ad->m_pos == 0); return Array::attach(ad); } @@ -116,7 +116,7 @@ Array HashCollection::toKeysArray() { if (e->hasIntKey()) { ai.append(int64_t{e->ikey}); } else { - assert(e->hasStrKey()); + assertx(e->hasStrKey()); ai.append(VarNR(e->skey).tv()); } } @@ -149,17 +149,17 @@ void HashCollection::remove(StringData* key) { } void HashCollection::eraseNoCompact(ssize_t pos) { - assert(canMutateBuffer()); - assert(validPos(pos) && !isTombstone(pos)); - assert(m_size > 0); + assertx(canMutateBuffer()); + assertx(validPos(pos) && !isTombstone(pos)); + assertx(m_size > 0); arrayData()->eraseNoCompact(pos); --m_size; } NEVER_INLINE void HashCollection::makeRoom() { - assert(isFull()); - assert(posLimit() == cap()); + assertx(isFull()); + assertx(posLimit() == cap()); if (LIKELY(!isDensityTooLow())) { if (UNLIKELY(cap() == MaxSize)) { throwTooLarge(); @@ -169,14 +169,14 @@ void HashCollection::makeRoom() { } else { compact(); } - assert(canMutateBuffer()); - assert(m_immCopy.isNull()); - assert(!isFull()); + assertx(canMutateBuffer()); + assertx(m_immCopy.isNull()); + assertx(!isFull()); } NEVER_INLINE void HashCollection::reserve(int64_t sz) { - assert(m_size <= posLimit() && posLimit() <= cap()); + assertx(m_size <= posLimit() && posLimit() <= cap()); auto cap = static_cast(this->cap()); if (LIKELY(sz > cap)) { if (UNLIKELY(sz > int64_t(MaxReserveSize))) { @@ -185,7 +185,7 @@ void HashCollection::reserve(int64_t sz) { // Fast path: The requested capacity is greater than the current capacity. // Grow to the smallest allowed capacity that is sufficient. grow(MixedArray::computeScaleFromSize(sz)); - assert(canMutateBuffer()); + assertx(canMutateBuffer()); return; } if (LIKELY(!hasTombstones())) { @@ -201,7 +201,7 @@ void HashCollection::reserve(int64_t sz) { // sz < m_size or there's enough room to add sz-m_size elements, in // which case we do nothing and return. compactOrShrinkIfDensityTooLow(); - assert(sz + int64_t(posLimit() - m_size) <= cap); + assertx(sz + int64_t(posLimit() - m_size) <= cap); mutate(); return; } @@ -209,19 +209,19 @@ void HashCollection::reserve(int64_t sz) { // there is not enough room to add sz-m_size elements. While would could // compact to make room, it's better for Hysteresis if we grow capacity // by 2x instead. - assert(!isDensityTooLow()); - assert(sz + int64_t(posLimit() - m_size) > cap); - assert(cap < MaxSize && tableMask() != 0); + assertx(!isDensityTooLow()); + assertx(sz + int64_t(posLimit() - m_size) > cap); + assertx(cap < MaxSize && tableMask() != 0); auto newScale = scale() * 2; - assert(sz > 0 && MixedArray::Capacity(newScale) >= sz); + assertx(sz > 0 && MixedArray::Capacity(newScale) >= sz); grow(newScale); - assert(canMutateBuffer()); + assertx(canMutateBuffer()); } ALWAYS_INLINE void HashCollection::resizeHelper(uint32_t newCap) { - assert(newCap >= m_size); - assert(m_immCopy.isNull()); + assertx(newCap >= m_size); + assertx(m_immCopy.isNull()); // Allocate a new ArrayData with the specified capacity and dup // all the elements (without copying over tombstones). auto ad = arrayData() == staticEmptyDictArrayAsMixed() ? @@ -229,14 +229,14 @@ void HashCollection::resizeHelper(uint32_t newCap) { MixedArray::CopyReserve(m_arr, newCap); decRefArr(m_arr); m_arr = ad; - assert(canMutateBuffer()); + assertx(canMutateBuffer()); } void HashCollection::grow(uint32_t newScale) { auto newCap = MixedArray::Capacity(newScale); - assert(m_size <= posLimit() && posLimit() <= cap() && cap() <= newCap); - assert(SmallSize <= newCap && newCap <= MaxSize); - assert(m_size <= newCap); + assertx(m_size <= posLimit() && posLimit() <= cap() && cap() <= newCap); + assertx(SmallSize <= newCap && newCap <= MaxSize); + assertx(m_size <= newCap); auto oldAd = arrayData(); dropImmCopy(); if (m_size > 0 && !oldAd->cowCheck()) { @@ -247,12 +247,12 @@ void HashCollection::grow(uint32_t newScale) { // greater than 1, call resizeHelper(). resizeHelper(newCap); } - assert(canMutateBuffer()); - assert(m_immCopy.isNull()); + assertx(canMutateBuffer()); + assertx(m_immCopy.isNull()); } void HashCollection::compact() { - assert(isDensityTooLow()); + assertx(isDensityTooLow()); dropImmCopy(); if (!arrayData()->cowCheck()) { // MixedArray::compact can only handle cases where the buffer's @@ -263,14 +263,14 @@ void HashCollection::compact() { // resizeHelper(). resizeHelper(cap()); } - assert(canMutateBuffer()); - assert(m_immCopy.isNull()); - assert(!isDensityTooLow()); + assertx(canMutateBuffer()); + assertx(m_immCopy.isNull()); + assertx(!isDensityTooLow()); } void HashCollection::shrink(uint32_t oldCap /* = 0 */) { - assert(isCapacityTooHigh() && (oldCap == 0 || oldCap < cap())); - assert(m_size <= posLimit() && posLimit() <= cap()); + assertx(isCapacityTooHigh() && (oldCap == 0 || oldCap < cap())); + assertx(m_size <= posLimit() && posLimit() <= cap()); dropImmCopy(); uint32_t newCap; if (oldCap != 0) { @@ -280,7 +280,7 @@ void HashCollection::shrink(uint32_t oldCap /* = 0 */) { // smallest capacity that is large enough to hold the current number // of elements. for (; newCap < m_size; newCap <<= 1) {} - assert(newCap == computeMaxElms(folly::nextPowTwo(newCap) - 1)); + assertx(newCap == computeMaxElms(folly::nextPowTwo(newCap) - 1)); } else { if (m_size == 0 && nextKI() == 0) { decRefArr(m_arr); @@ -293,8 +293,8 @@ void HashCollection::shrink(uint32_t oldCap /* = 0 */) { uint32_t capThreshold = (doubleSz < size_t(MaxSize)) ? doubleSz : MaxSize; for (newCap = SmallSize * 2; newCap < capThreshold; newCap <<= 1) {} } - assert(SmallSize <= newCap && newCap <= MaxSize); - assert(m_size <= newCap); + assertx(SmallSize <= newCap && newCap <= MaxSize); + assertx(m_size <= newCap); auto* oldAd = arrayData(); if (!oldAd->cowCheck()) { // If the buffer's refcount is 1, we can teleport the elements @@ -321,14 +321,14 @@ void HashCollection::shrink(uint32_t oldCap /* = 0 */) { // resizeHelper() resizeHelper(newCap); } - assert(canMutateBuffer()); - assert(m_immCopy.isNull()); - assert(!isCapacityTooHigh() || newCap == oldCap); + assertx(canMutateBuffer()); + assertx(m_immCopy.isNull()); + assertx(!isCapacityTooHigh() || newCap == oldCap); } HashCollection::Elm& HashCollection::allocElmFront(MixedArray::Inserter ei) { - assert(MixedArray::isValidIns(ei) && !MixedArray::isValidPos(*ei)); - assert(m_size <= posLimit() && posLimit() < cap()); + assertx(MixedArray::isValidIns(ei) && !MixedArray::isValidPos(*ei)); + assertx(m_size <= posLimit() && posLimit() < cap()); // Move the existing elements to make element slot 0 available. memmove(data() + 1, data(), posLimit() * sizeof(Elm)); incPosLimit(); @@ -360,7 +360,7 @@ HashCollection::Elm& HashCollection::allocElmFront(MixedArray::Inserter ei) { */ template SortFlavor HashCollection::preSort(const AccessorT& acc, bool checkTypes) { - assert(m_size > 0); + assertx(m_size > 0); if (!checkTypes && !hasTombstones()) { // No need to loop over the elements, we're done return GenericSort; @@ -406,7 +406,7 @@ SortFlavor HashCollection::preSort(const AccessorT& acc, bool checkTypes) { // garbage by resetting it. The logic above ensures that the first // slot is not a tombstone, so it's safe to set m_pos to 0. arrayData()->m_pos = 0; - assert(!hasTombstones()); + assertx(!hasTombstones()); if (checkTypes) { return allStrs ? StringSort : allInts ? IntegerSort : GenericSort; } else { @@ -515,14 +515,14 @@ bool HashCollection::uksort(const Variant& cmp_function) { #undef USER_SORT_BODY void HashCollection::mutateImpl() { - assert(arrayData()->hasMultipleRefs()); + assertx(arrayData()->hasMultipleRefs()); dropImmCopy(); if (canMutateBuffer()) { return; } auto* oldAd = arrayData(); m_arr = MixedArray::asMixed(MixedArray::Copy(oldAd)); - assert(oldAd->hasMultipleRefs()); + assertx(oldAd->hasMultipleRefs()); oldAd->decRefCount(); } diff --git a/hphp/runtime/ext/collections/hash-collection.h b/hphp/runtime/ext/collections/hash-collection.h index 1d44ea755f9..6d8db1d603c 100644 --- a/hphp/runtime/ext/collections/hash-collection.h +++ b/hphp/runtime/ext/collections/hash-collection.h @@ -73,10 +73,10 @@ struct HashCollection : ObjectData { bool isFull() { return posLimit() == cap(); } bool isDensityTooLow() const { bool b = (m_size < posLimit() / 2); - assert(IMPLIES( + assertx(IMPLIES( arrayData() == staticEmptyDictArrayAsMixed(), !b)); - assert(IMPLIES(cap() == 0, !b)); + assertx(IMPLIES(cap() == 0, !b)); return b; } @@ -85,10 +85,10 @@ struct HashCollection : ObjectData { // if current capacity is at least 8x greater than the minimum capacity bool b = ((uint64_t(cap()) >= uint64_t(m_size) * 8) && (cap() >= HashCollection::SmallSize * 8)); - assert(IMPLIES( + assertx(IMPLIES( arrayData() == staticEmptyDictArrayAsMixed(), !b)); - assert(IMPLIES(cap() == 0, !b)); + assertx(IMPLIES(cap() == 0, !b)); return b; } @@ -138,8 +138,8 @@ struct HashCollection : ObjectData { } HashCollection::Elm& allocElm(MixedArray::Inserter ei) { - assert(canMutateBuffer()); - assert(MixedArray::isValidIns(ei) && !MixedArray::isValidPos(*ei) + assertx(canMutateBuffer()); + assertx(MixedArray::isValidIns(ei) && !MixedArray::isValidPos(*ei) && m_size <= posLimit() && posLimit() < cap()); size_t i = posLimit(); *ei = i; @@ -164,12 +164,12 @@ struct HashCollection : ObjectData { } bool iter_valid(ssize_t pos, ssize_t limit) const { - assert(limit == (ssize_t)posLimit()); + assertx(limit == (ssize_t)posLimit()); return pos < limit; } const Elm* iter_elm(ssize_t pos) const { - assert(iter_valid(pos)); + assertx(iter_valid(pos)); return &(data()[pos]); } @@ -203,7 +203,7 @@ struct HashCollection : ObjectData { } Variant iter_key(ssize_t pos) const { - assert(iter_valid(pos)); + assertx(iter_valid(pos)); auto* e = iter_elm(pos); if (e->hasStrKey()) { return Variant{e->skey}; @@ -212,7 +212,7 @@ struct HashCollection : ObjectData { } const TypedValue* iter_value(ssize_t pos) const { - assert(iter_valid(pos)); + assertx(iter_valid(pos)); return &iter_elm(pos)->data; } @@ -232,12 +232,12 @@ struct HashCollection : ObjectData { uint32_t pos = 0; for (;;) { while (isTombstone(pos)) { - assert(pos + 1 < posLimit()); + assertx(pos + 1 < posLimit()); ++pos; } if (n <= 0) break; --n; - assert(pos + 1 < posLimit()); + assertx(pos + 1 < posLimit()); ++pos; } return pos; @@ -251,19 +251,19 @@ struct HashCollection : ObjectData { * if needed. */ void mutate() { - assert(IMPLIES(!m_immCopy.isNull(), arrayData()->hasMultipleRefs())); + assertx(IMPLIES(!m_immCopy.isNull(), arrayData()->hasMultipleRefs())); if (arrayData()->cowCheck()) { // mutateImpl() does two things for us. First it drops the the // immutable collection held by m_immCopy (if m_immCopy is not // null). Second, it takes care of copying the buffer if needed. mutateImpl(); } - assert(canMutateBuffer()); - assert(m_immCopy.isNull()); + assertx(canMutateBuffer()); + assertx(m_immCopy.isNull()); } void dropImmCopy() { - assert(m_immCopy.isNull() || + assertx(m_immCopy.isNull() || (arrayData() == ((HashCollection*)m_immCopy.get())->arrayData() && arrayData()->hasMultipleRefs())); m_immCopy.reset(); @@ -378,7 +378,7 @@ struct HashCollection : ObjectData { * modify this HashCollection's buffer. */ bool canMutateBuffer() const { - assert(IMPLIES(!arrayData()->cowCheck(), m_immCopy.isNull())); + assertx(IMPLIES(!arrayData()->cowCheck(), m_immCopy.isNull())); return !arrayData()->cowCheck(); } @@ -399,12 +399,12 @@ struct HashCollection : ObjectData { } ssize_t findForRemove(int64_t k, inthash_t h) { - assert(canMutateBuffer()); + assertx(canMutateBuffer()); return m_arr->findForRemove(k, h, false); } ssize_t findForRemove(const StringData* s, strhash_t h) { - assert(canMutateBuffer()); + assertx(canMutateBuffer()); return m_arr->findForRemove(s, h); } @@ -428,7 +428,7 @@ struct HashCollection : ObjectData { } static void dupElm(const Elm& frE, Elm& toE) { - assert(!isTombstoneType(frE.data.m_type)); + assertx(!isTombstoneType(frE.data.m_type)); memcpy(&toE, &frE, sizeof(Elm)); if (toE.hasStrKey()) toE.skey->incRefCount(); tvIncRefGen(toE.data); @@ -447,24 +447,24 @@ struct HashCollection : ObjectData { int32_t* hashTab() const { return m_arr->hashTab(); } void setSize(uint32_t sz) { - assert(sz <= cap()); + assertx(sz <= cap()); if (m_arr == staticEmptyDictArrayAsMixed()) { - assert(sz == 0); + assertx(sz == 0); return; } - assert(!arrayData()->hasMultipleRefs()); + assertx(!arrayData()->hasMultipleRefs()); m_size = sz; arrayData()->m_size = sz; } void incSize() { - assert(m_size + 1 <= cap()); - assert(!arrayData()->hasMultipleRefs()); + assertx(m_size + 1 <= cap()); + assertx(!arrayData()->hasMultipleRefs()); ++m_size; arrayData()->m_size = m_size; } void decSize() { - assert(m_size > 0); - assert(!arrayData()->hasMultipleRefs()); + assertx(m_size > 0); + assertx(!arrayData()->hasMultipleRefs()); --m_size; arrayData()->m_size = m_size; } @@ -481,29 +481,29 @@ struct HashCollection : ObjectData { return arrayData()->m_used; } void incPosLimit() { - assert(!arrayData()->hasMultipleRefs()); - assert(posLimit() + 1 <= cap()); + assertx(!arrayData()->hasMultipleRefs()); + assertx(posLimit() + 1 <= cap()); arrayData()->m_used++; } void setPosLimit(uint32_t limit) { auto* a = arrayData(); if (a == staticEmptyDictArrayAsMixed()) { - assert(limit == 0); + assertx(limit == 0); return; } - assert(!a->hasMultipleRefs()); - assert(limit <= cap()); + assertx(!a->hasMultipleRefs()); + assertx(limit <= cap()); a->m_used = limit; } int64_t nextKI() { return arrayData()->m_nextKI; } void setNextKI(int64_t ki) { - assert(!arrayData()->hasMultipleRefs()); + assertx(!arrayData()->hasMultipleRefs()); arrayData()->m_nextKI = ki; } void updateNextKI(int64_t ki) { - assert(!arrayData()->hasMultipleRefs()); + assertx(!arrayData()->hasMultipleRefs()); auto* a = arrayData(); if (ki >= a->m_nextKI && a->m_nextKI >= 0) { a->m_nextKI = ki + 1; @@ -516,10 +516,10 @@ struct HashCollection : ObjectData { static int32_t skipTombstonesNoBoundsCheck(int32_t pos, int32_t posLimit, const Elm* data) { - assert(pos < posLimit); + assertx(pos < posLimit); while (isTombstone(pos, data)) { ++pos; - assert(pos < posLimit); + assertx(pos < posLimit); } return pos; } @@ -549,7 +549,7 @@ struct HashCollection : ObjectData { } static Elm* nextElm(Elm* e, Elm* eLimit) { - assert(e != eLimit); + assertx(e != eLimit); for (++e; e != eLimit && isTombstone(e); ++e) {} return e; } @@ -558,7 +558,7 @@ struct HashCollection : ObjectData { } static bool isTombstoneType(DataType t) { - assert(isRealType(t) || t == kInvalidDataType); + assertx(isRealType(t) || t == kInvalidDataType); return t < KindOfUninit; static_assert(KindOfUninit == 0 && kInvalidDataType < 0, ""); } @@ -572,7 +572,7 @@ struct HashCollection : ObjectData { } bool isTombstone(ssize_t pos) const { - assert(size_t(pos) <= posLimit()); + assertx(size_t(pos) <= posLimit()); return isTombstone(pos, data()); } diff --git a/hphp/runtime/ext/curl/curl-resource.cpp b/hphp/runtime/ext/curl/curl-resource.cpp index f2ae533bfa8..733c1a6dd8d 100644 --- a/hphp/runtime/ext/curl/curl-resource.cpp +++ b/hphp/runtime/ext/curl/curl-resource.cpp @@ -143,7 +143,7 @@ void CurlResource::closeForSweep() { if (m_cp) { if (m_connPool) { // reuse this curl handle if we're pooling - assert(m_pooledHandle); + assertx(m_pooledHandle); m_connPool->store(m_pooledHandle); m_pooledHandle = nullptr; } else { diff --git a/hphp/runtime/ext/curl/ext_curl.cpp b/hphp/runtime/ext/curl/ext_curl.cpp index a97fe89889d..4f08f081869 100644 --- a/hphp/runtime/ext/curl/ext_curl.cpp +++ b/hphp/runtime/ext/curl/ext_curl.cpp @@ -1477,7 +1477,7 @@ struct CurlExtension final : Extension { HHVM_FE(curl_share_close); Extension* ext = ExtensionRegistry::get("curl"); - assert(ext); + assertx(ext); IniSetting::Bind(ext, IniSetting::PHP_INI_SYSTEM, "curl.namedPools", "", &s_namedPools); diff --git a/hphp/runtime/ext/datetime/ext_datetime.cpp b/hphp/runtime/ext/datetime/ext_datetime.cpp index a6b204e25ec..dab0d0303c7 100644 --- a/hphp/runtime/ext/datetime/ext_datetime.cpp +++ b/hphp/runtime/ext/datetime/ext_datetime.cpp @@ -70,7 +70,7 @@ THREAD_LOCAL(DateGlobals, s_date_globals); Class* cls::getClass() { \ if (s_class == nullptr) { \ s_class = Unit::lookupClass(s_className.get()); \ - assert(s_class); \ + assertx(s_class); \ } \ return s_class; \ } \ @@ -336,7 +336,7 @@ int64_t DateTimeData::getTimestamp(const Object& obj) { if (LIKELY(obj.instanceof(getClass()))) { return Native::data(obj)->getTimestamp(); } - assert(obj->instanceof(SystemLib::s_DateTimeInterfaceClass)); + assertx(obj->instanceof(SystemLib::s_DateTimeInterfaceClass)); Variant result = obj->o_invoke(s_getTimestamp, Array::Create()); return result.toInt64(); } @@ -385,7 +385,7 @@ req::ptr DateTimeData::unwrap(const Object& datetime) { SystemLib::s_DateTimeImmutableClass, s_data.get() ); - assert(rval.has_val() && rval.type() == KindOfObject); + assertx(rval.has_val() && rval.type() == KindOfObject); Object impl(rval.val().pobj); return unwrap(impl); } diff --git a/hphp/runtime/ext/domdocument/ext_domdocument.cpp b/hphp/runtime/ext/domdocument/ext_domdocument.cpp index a33c8b16526..949aa68ae89 100644 --- a/hphp/runtime/ext/domdocument/ext_domdocument.cpp +++ b/hphp/runtime/ext/domdocument/ext_domdocument.cpp @@ -68,7 +68,7 @@ extern xmlNodePtr SimpleXMLElement_exportNode(const Object& sxe); #define IMPLEMENT_GET_CLASS_FUNCTION(CLASS) \ Class* get ## CLASS ## Class() { \ static Class* cls = Unit::lookupClass(s_ ## CLASS.get()); \ - assert(cls); \ + assertx(cls); \ return cls; \ } \ /**/ @@ -147,7 +147,7 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, parser->input->filename, parser->input->line); break; default: - assert(false); + assertx(false); break; } } else { @@ -161,7 +161,7 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, parser->input->line); break; default: - assert(false); + assertx(false); break; } } @@ -174,7 +174,7 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, raise_notice("%s", msg.c_str()); break; default: - assert(false); + assertx(false); break; } } @@ -1173,7 +1173,7 @@ Variant php_dom_create_object(xmlNodePtr obj, if (doc) { if (doc->m_classmap.exists(clsname)) { // or const char * is not safe - assert(doc->m_classmap[clsname].isString()); + assertx(doc->m_classmap[clsname].isString()); clsname = doc->m_classmap[clsname].toString(); } } @@ -1189,7 +1189,7 @@ Variant php_dom_create_object(xmlNodePtr obj, if (!nodeobj->node()) { nodeobj->setNode(node); } - assert(nodeobj->node() == node); + assertx(nodeobj->node() == node); if (doc) { nodeobj->setDoc(std::move(doc)); @@ -2157,7 +2157,7 @@ DOMNode& DOMNode::operator=(const DOMNode& copy) { } if (m_node) { - assert(m_node->getCache() && + assertx(m_node->getCache() && Native::data(m_node->getCache()) == this); m_node->clearCache(); m_node = nullptr; @@ -5699,7 +5699,7 @@ Variant HHVM_METHOD(DOMXPath, registerPHPFunctions, /////////////////////////////////////////////////////////////////////////////// void DOMNodeIterator::reset_iterator() { - assert(m_objmap); + assertx(m_objmap); xmlNodePtr curnode = nullptr; if (m_objmap->m_nodetype != XML_ENTITY_NODE && m_objmap->m_nodetype != XML_NOTATION_NODE) { diff --git a/hphp/runtime/ext/domdocument/ext_domdocument.h b/hphp/runtime/ext/domdocument/ext_domdocument.h index 2d01c7dac6f..fe236b191b0 100644 --- a/hphp/runtime/ext/domdocument/ext_domdocument.h +++ b/hphp/runtime/ext/domdocument/ext_domdocument.h @@ -44,7 +44,7 @@ Object newDOMDocument(bool construct = true); struct DOMNode { ~DOMNode() { if (m_node) { - assert(m_node->getCache() && + assertx(m_node->getCache() && Native::data(m_node->getCache()) == this); m_node->clearCache(); } @@ -60,13 +60,13 @@ struct DOMNode { } void setDoc(req::ptr&& doc) { - assert(m_node); + assertx(m_node); m_node->setDoc(std::move(doc)); } void setNode(XMLNode n) { if (m_node) { - assert(m_node->getCache() && + assertx(m_node->getCache() && Native::data(m_node->getCache()) == this); m_node->clearCache(); } diff --git a/hphp/runtime/ext/extension-registry.cpp b/hphp/runtime/ext/extension-registry.cpp index f5addcabf79..9ca63068e1c 100644 --- a/hphp/runtime/ext/extension-registry.cpp +++ b/hphp/runtime/ext/extension-registry.cpp @@ -90,25 +90,25 @@ void registerExtension(Extension* ext) { s_exts = new ExtensionMap; } const auto& name = ext->getName(); - assert(s_exts->find(name) == s_exts->end()); + assertx(s_exts->find(name) == s_exts->end()); (*s_exts)[name] = ext; } void unregisterExtension(const char* name) { - assert(s_exts); - assert(s_exts->find(name) != s_exts->end()); + assertx(s_exts); + assertx(s_exts->find(name) != s_exts->end()); s_exts->erase(name); } bool isLoaded(const char* name, bool enabled_only /*= true */) { - assert(s_exts); + assertx(s_exts); auto it = s_exts->find(name); return (it != s_exts->end()) && (!enabled_only || it->second->moduleEnabled()); } Extension* get(const char* name, bool enabled_only /*= true */) { - assert(s_exts); + assertx(s_exts); auto it = s_exts->find(name); if ((it != s_exts->end()) && (!enabled_only || it->second->moduleEnabled())) { @@ -118,7 +118,7 @@ Extension* get(const char* name, bool enabled_only /*= true */) { } Array getLoaded(bool enabled_only /*= true */) { - assert(s_exts); + assertx(s_exts); Array ret = Array::Create(); for (auto& kv : (*s_exts)) { if (!enabled_only || kv.second->moduleEnabled()) { @@ -214,7 +214,7 @@ void moduleLoad(const IniSetting::Map& ini, Hdf hdf) { if (extFiles.size() > 0 || !s_sorted) { sortDependencies(); } - assert(s_sorted); + assertx(s_sorted); for (auto& ext : s_ordered) { ext->moduleLoad(ini, hdf); @@ -230,7 +230,7 @@ void moduleInit() { RuntimeOption::EvalDumpBytecode = wasDB; }; SystemLib::s_inited = false; - assert(s_sorted); + assertx(s_sorted); for (auto& ext : s_ordered) { ext->moduleInit(); } @@ -238,8 +238,8 @@ void moduleInit() { } void moduleShutdown() { - assert(s_exts); - assert(s_sorted); + assertx(s_exts); + assertx(s_sorted); for (auto it = s_ordered.rbegin(); it != s_ordered.rend(); ++it) { (*it)->moduleShutdown(); @@ -253,14 +253,14 @@ void moduleShutdown() { void threadInit() { // This can actually happen both before and after LoadModules() if (!s_sorted) sortDependencies(); - assert(s_sorted); + assertx(s_sorted); for (auto& ext : s_ordered) { ext->threadInit(); } } void threadShutdown() { - assert(s_sorted); + assertx(s_sorted); for (auto it = s_ordered.rbegin(); it != s_ordered.rend(); ++it) { (*it)->threadShutdown(); @@ -268,14 +268,14 @@ void threadShutdown() { } void requestInit() { - assert(s_sorted); + assertx(s_sorted); for (auto& ext : s_ordered) { ext->requestInit(); } } void requestShutdown() { - assert(s_sorted); + assertx(s_sorted); for (auto it = s_ordered.rbegin(); it != s_ordered.rend(); ++it) { (*it)->requestShutdown(); @@ -306,7 +306,7 @@ Extension* findResolvedExt(const Extension::DependencySetMap& unresolved, } static void sortDependencies() { - assert(s_exts); + assertx(s_exts); s_ordered.clear(); Extension::DependencySet resolved; @@ -351,7 +351,7 @@ static void sortDependencies() { throw Exception(ss.str()); } - assert(s_ordered.size() == s_exts->size()); + assertx(s_ordered.size() == s_exts->size()); s_sorted = true; } diff --git a/hphp/runtime/ext/extension.h b/hphp/runtime/ext/extension.h index ef2e6e7c47d..01b5986082b 100644 --- a/hphp/runtime/ext/extension.h +++ b/hphp/runtime/ext/extension.h @@ -99,7 +99,7 @@ public: } void registerExtensionFunction(const String& name) { - assert(name.get()->isStatic()); + assertx(name.get()->isStatic()); m_functions.push_back(name.get()); } diff --git a/hphp/runtime/ext/fb/ext_fb.cpp b/hphp/runtime/ext/fb/ext_fb.cpp index c1579a86901..ac4c1215a5e 100644 --- a/hphp/runtime/ext/fb/ext_fb.cpp +++ b/hphp/runtime/ext/fb/ext_fb.cpp @@ -292,7 +292,7 @@ const uint64_t kCodePrefix = 0xf0; static void fb_compact_serialize_code(StringBuffer& sb, FbCompactSerializeCode code) { - assert(code == (code & kCodeMask)); + assertx(code == (code & kCodeMask)); uint8_t v = (kCodePrefix | code); sb.append(reinterpret_cast(&v), 1); } @@ -478,7 +478,7 @@ static int fb_compact_serialize_variant( case KindOfPersistentVec: case KindOfVec: { Array arr = var.toArray(); - assert(arr->isVecArray()); + assertx(arr->isVecArray()); fb_compact_serialize_vec(sb, std::move(arr), depth); return 0; } @@ -486,7 +486,7 @@ static int fb_compact_serialize_variant( case KindOfPersistentDict: case KindOfDict: { Array arr = var.toArray(); - assert(arr->isDict()); + assertx(arr->isDict()); fb_compact_serialize_array_as_map(sb, std::move(arr), depth); return 0; } @@ -494,7 +494,7 @@ static int fb_compact_serialize_variant( case KindOfPersistentKeyset: case KindOfKeyset: { Array arr = var.toArray(); - assert(arr->isKeyset()); + assertx(arr->isKeyset()); fb_compact_serialize_keyset(sb, std::move(arr)); return 0; } @@ -502,7 +502,7 @@ static int fb_compact_serialize_variant( case KindOfPersistentArray: case KindOfArray: { Array arr = var.toArray(); - assert(arr->isPHPArray()); + assertx(arr->isPHPArray()); int64_t index_limit; if (fb_compact_serialize_is_list(arr, index_limit)) { fb_compact_serialize_array_as_list_map( @@ -863,7 +863,7 @@ bool HHVM_FUNCTION(fb_utf8ize, VRefParam input) { // We know that resultBuffer > total possible length. U8_APPEND_UNSAFE(dstBuf, dstPosBytes, curCodePoint); } - assert(dstPosBytes <= dstMaxLenBytes); + assertx(dstPosBytes <= dstMaxLenBytes); input.assignIfRef(dstStr.shrink(dstPosBytes)); return true; } @@ -912,8 +912,8 @@ static String fb_utf8_substr_simple(const String& str, const char* const srcBuf = str.data(); int32_t srcLenBytes = str.size(); // May truncate; checked before use below. - assert(firstCodePoint >= 0); // Wrapper fixes up negative starting positions. - assert(numDesiredCodePoints > 0); // Wrapper fixes up negative/zero length. + assertx(firstCodePoint >= 0); // Wrapper fixes up negative starting positions. + assertx(numDesiredCodePoints > 0); // Wrapper fixes up negative/zero length. if (str.size() <= 0 || str.size() > INT_MAX || firstCodePoint >= srcLenBytes) { @@ -965,7 +965,7 @@ static String fb_utf8_substr_simple(const String& str, } } - assert(dstPosBytes <= dstMaxLenBytes); + assertx(dstPosBytes <= dstMaxLenBytes); if (dstPosBytes > 0) { dstStr.shrink(dstPosBytes); return dstStr; diff --git a/hphp/runtime/ext/filter/logical_filters.cpp b/hphp/runtime/ext/filter/logical_filters.cpp index daea79f818a..698496e6edd 100644 --- a/hphp/runtime/ext/filter/logical_filters.cpp +++ b/hphp/runtime/ext/filter/logical_filters.cpp @@ -184,12 +184,12 @@ Variant php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) { if (allow_hex && (*p == 'x' || *p == 'X')) { p++; len--; if (php_filter_parse_hex(p, len, &ctx_value) < 0) { - assert(ctx_value == 0); + assertx(ctx_value == 0); error = 1; } } else if (allow_octal) { if (php_filter_parse_octal(p, len, &ctx_value) < 0) { - assert(ctx_value == 0); + assertx(ctx_value == 0); error = 1; } } else if (len != 0) { @@ -197,7 +197,7 @@ Variant php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) { } } else { if (php_filter_parse_int(p, len, &ctx_value) < 0) { - assert(ctx_value == 0); + assertx(ctx_value == 0); error = 1; } } diff --git a/hphp/runtime/ext/gd/ext_gd.cpp b/hphp/runtime/ext/gd/ext_gd.cpp index 973ea25145d..aa4f9e2c7cd 100644 --- a/hphp/runtime/ext/gd/ext_gd.cpp +++ b/hphp/runtime/ext/gd/ext_gd.cpp @@ -123,7 +123,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { int n = 1000; if (m_mallocSize) imDump(ptrs, n); #endif - assert(m_mallocSize == 0); + assertx(m_mallocSize == 0); m_mallocSize = 0; } void requestShutdown() override { @@ -131,7 +131,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { void *ptrs[1000]; int n = 1000; if (m_mallocSize) imDump(ptrs, n); - assert(m_mallocSize == 0); + assertx(m_mallocSize == 0); #endif m_mallocSize = 0; } @@ -140,7 +140,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { , int ln #endif ) { - assert(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); + assertx(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); if (m_mallocSize + size < (size_t)RuntimeOption::ImageMemoryMaxBytes) { #ifdef IM_MEMORY_CHECK void *ptr = malloc(sizeof(ln) + sizeof(size) + size); @@ -165,7 +165,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { , int ln #endif ) { - assert(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); + assertx(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); size_t bytes = nmemb * size; if (m_mallocSize + bytes < (size_t)RuntimeOption::ImageMemoryMaxBytes) { #ifdef IM_MEMORY_CHECK @@ -200,11 +200,11 @@ struct ImageMemoryAlloc final : RequestEventHandler { #ifdef IM_MEMORY_CHECK void *lnPtr = (char *)sizePtr - sizeof(ln); int count = m_alloced.erase((char*)sizePtr - sizeof(ln)); - assert(count == 1); // double free on failure - assert(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); + assertx(count == 1); // double free on failure + assertx(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); free(lnPtr); #else - assert(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); + assertx(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); free(sizePtr); #endif } @@ -215,7 +215,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { , int ln #endif ) { - assert(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); + assertx(m_mallocSize < (size_t)RuntimeOption::ImageMemoryMaxBytes); #ifdef IM_MEMORY_CHECK if (!ptr) return imMalloc(size, ln); @@ -241,7 +241,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { if (m_mallocSize + diff > (size_t)RuntimeOption::ImageMemoryMaxBytes || !(tmp = realloc(lnPtr, sizeof(ln) + sizeof(size) + size))) { int count = m_alloced.erase(ptr); - assert(count == 1); // double free on failure + assertx(count == 1); // double free on failure free(lnPtr); return nullptr; } @@ -250,7 +250,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { m_mallocSize += diff; if (tmp != lnPtr) { int count = m_alloced.erase(lnPtr); - assert(count == 1); + assertx(count == 1); m_alloced.insert(tmp); } return ((char *)tmp + sizeof(ln) + sizeof(size)); @@ -272,7 +272,7 @@ struct ImageMemoryAlloc final : RequestEventHandler { for (std::set::iterator iter = m_alloced.begin(); iter != m_alloced.end(); ++i, ++iter) { void *p = *iter; - assert(p); + assertx(p); if (i < n) ptrs[i] = p; int ln; size_t size; @@ -2336,7 +2336,7 @@ static gdImagePtr _php_image_create_from(const String& filename, } else { /* TODO: try and force the stream to be FILE* */ - assert(false); + assertx(false); } if (!im && fp) { diff --git a/hphp/runtime/ext/gd/libgd/gd_gd2.cpp b/hphp/runtime/ext/gd/libgd/gd_gd2.cpp index 31af8a05d09..3bfe71fa7a9 100644 --- a/hphp/runtime/ext/gd/libgd/gd_gd2.cpp +++ b/hphp/runtime/ext/gd/libgd/gd_gd2.cpp @@ -681,7 +681,7 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt) } if (im->trueColor) { fmt += 2; - assert(fmt == GD2_FMT_TRUECOLOR_RAW || + assertx(fmt == GD2_FMT_TRUECOLOR_RAW || fmt == GD2_FMT_TRUECOLOR_COMPRESSED); } /* Make sure chunk size is valid. These are arbitrary values; 64 because it seems diff --git a/hphp/runtime/ext/generator/ext_generator.cpp b/hphp/runtime/ext/generator/ext_generator.cpp index e395de7f3ea..39cefb1fb53 100644 --- a/hphp/runtime/ext/generator/ext_generator.cpp +++ b/hphp/runtime/ext/generator/ext_generator.cpp @@ -43,7 +43,7 @@ Generator::~Generator() { return; } - assert(getState() != State::Running); + assertx(getState() != State::Running); tvDecRefGen(m_key); tvDecRefGen(m_value); tvDecRefGen(m_delegate); @@ -80,9 +80,9 @@ Generator& Generator::operator=(const Generator& other) { ObjectData* Generator::Create(const ActRec* fp, size_t numSlots, jit::TCA resumeAddr, Offset resumeOffset) { - assert(fp); - assert(!fp->resumed()); - assert(fp->func()->isNonAsyncGenerator()); + assertx(fp); + assertx(!fp->resumed()); + assertx(fp->func()->isNonAsyncGenerator()); const size_t frameSz = Resumable::getFrameSize(numSlots); const size_t genSz = genSize(sizeof(Generator), frameSz); auto const obj = BaseGenerator::Alloc(s_class, genSz); @@ -115,14 +115,14 @@ void Generator::copyVars(const ActRec* srcFp) { if (srcFp->hasExtraArgs()) { dstFp->setExtraArgs(srcFp->getExtraArgs()->clone(dstFp)); } else { - assert(srcFp->hasVarEnv()); + assertx(srcFp->hasVarEnv()); dstFp->setVarEnv(srcFp->getVarEnv()->clone(dstFp)); } } void Generator::yield(Offset resumeOffset, const Cell* key, const Cell value) { - assert(isRunning()); + assertx(isRunning()); resumable()->setResumeAddr(nullptr, resumeOffset); if (key) { @@ -142,7 +142,7 @@ void Generator::yield(Offset resumeOffset, } void Generator::done(TypedValue tv) { - assert(isRunning()); + assertx(isRunning()); cellSetNull(m_key); cellSet(*tvToCell(&tv), m_value); setState(State::Done); @@ -168,7 +168,7 @@ String HHVM_METHOD(Generator, getOrigFuncName) { const Func* origFunc = gen->actRec()->func(); auto const origName = origFunc->isClosureBody() ? s__closure_.get() : origFunc->name(); - assert(origName->isStatic()); + assertx(origName->isStatic()); return String(const_cast(origName)); } @@ -199,7 +199,7 @@ struct GeneratorExtension final : Extension { Native::NDIFlags::NO_SWEEP); loadSystemlib("generator"); Generator::s_class = Unit::lookupClass(Generator::s_className.get()); - assert(Generator::s_class); + assertx(Generator::s_class); } }; diff --git a/hphp/runtime/ext/generator/ext_generator.h b/hphp/runtime/ext/generator/ext_generator.h index f9bbfa6db1e..483f70c4a99 100644 --- a/hphp/runtime/ext/generator/ext_generator.h +++ b/hphp/runtime/ext/generator/ext_generator.h @@ -61,7 +61,7 @@ struct BaseGenerator { * Skips CreateCont and PopC opcodes. */ static Offset userBase(const Func* func) { - assert(func->isGenerator()); + assertx(func->isGenerator()); auto base = func->base(); // Skip past VerifyParamType and EntryNoop bytecodes @@ -74,8 +74,8 @@ struct BaseGenerator { auto DEBUG_ONLY op1 = decode_op(pc); auto DEBUG_ONLY op2 = decode_op(pc); - assert(op1 == OpCreateCont); - assert(op2 == OpPopC); + assertx(op1 == OpCreateCont); + assertx(op2 == OpPopC); return func->unit()->offsetOf(pc); } @@ -98,9 +98,9 @@ struct BaseGenerator { node->obj_offset = obj_offset; node->initHeader_32_16(HeaderKind::NativeData, ar_off, tyindex); auto const obj = new (objmem) ObjectData(cls, 0, HeaderKind::NativeObject); - assert((void*)obj == (void*)objmem); - assert(obj->hasExactlyOneRef()); - assert(obj->noDestruct()); + assertx((void*)obj == (void*)objmem); + assertx(obj->hasExactlyOneRef()); + assertx(obj->noDestruct()); return obj; } @@ -176,7 +176,7 @@ struct Generator final : BaseGenerator { static ObjectData* Create(const ActRec* fp, size_t numSlots, jit::TCA resumeAddr, Offset resumeOffset); static Class* getClass() { - assert(s_class); + assertx(s_class); return s_class; } static constexpr ptrdiff_t objectOff() { diff --git a/hphp/runtime/ext/hash/ext_hash.cpp b/hphp/runtime/ext/hash/ext_hash.cpp index b4e42d61398..cf20ca3f83b 100644 --- a/hphp/runtime/ext/hash/ext_hash.cpp +++ b/hphp/runtime/ext/hash/ext_hash.cpp @@ -145,8 +145,8 @@ struct HashContext : SweepableResourceData { } explicit HashContext(req::ptr&& ctx) { - assert(ctx->ops); - assert(ctx->ops->context_size >= 0); + assertx(ctx->ops); + assertx(ctx->ops->context_size >= 0); ops = ctx->ops; context = malloc(ops->context_size); ops->hash_copy(context, ctx->context); @@ -162,7 +162,7 @@ struct HashContext : SweepableResourceData { ~HashContext() { /* Just in case the algo has internally allocated resources */ if (context) { - assert(ops->digest_size >= 0); + assertx(ops->digest_size >= 0); unsigned char* dummy = (unsigned char*)alloca( sizeof(unsigned char) * ops->digest_size); ops->hash_final(dummy, context); diff --git a/hphp/runtime/ext/hash/hash_engine.h b/hphp/runtime/ext/hash/hash_engine.h index d6b18b1f99a..3ab36de39a8 100644 --- a/hphp/runtime/ext/hash/hash_engine.h +++ b/hphp/runtime/ext/hash/hash_engine.h @@ -18,11 +18,12 @@ #ifndef incl_HPHP_EXT_HASH_ENGINE_H_ #define incl_HPHP_EXT_HASH_ENGINE_H_ +#include "hphp/util/assertions.h" + #include #include #include #include -#include namespace HPHP { /////////////////////////////////////////////////////////////////////////////// @@ -40,9 +41,9 @@ struct HashEngine { unsigned int count) = 0; virtual void hash_final(unsigned char *digest, void *context) = 0; virtual void hash_copy(void *new_context, void *old_context) { - assert(new_context != nullptr); - assert(old_context != nullptr); - assert(context_size >= 0); + assertx(new_context != nullptr); + assertx(old_context != nullptr); + assertx(context_size >= 0); memcpy(new_context, old_context, context_size); } diff --git a/hphp/runtime/ext/hash/hash_furc.cpp b/hphp/runtime/ext/hash/hash_furc.cpp index a356ce4de83..8596205e758 100644 --- a/hphp/runtime/ext/hash/hash_furc.cpp +++ b/hphp/runtime/ext/hash/hash_furc.cpp @@ -31,7 +31,8 @@ * additional bits are generated by re-hashing the initial MurmurHash64A. */ -#include +#include "hphp/util/assertions.h" + #include #include #include @@ -99,7 +100,7 @@ uint32_t furc_hash_internal(const char* const key, const size_t len, const uint3 uint64_t hash[FURC_CACHE_SIZE]; int32_t old_ord; - assert(m <= furc_maximum_pool_size()); + assertx(m <= furc_maximum_pool_size()); if (m <= 1) { return 0; diff --git a/hphp/runtime/ext/hash/hash_haval.cpp b/hphp/runtime/ext/hash/hash_haval.cpp index 006df8faf30..36dc08baac3 100644 --- a/hphp/runtime/ext/hash/hash_haval.cpp +++ b/hphp/runtime/ext/hash/hash_haval.cpp @@ -284,7 +284,7 @@ void hash_haval::hash_init(void *context_) { case 4: context->Transform = PHP_4HAVALTransform; break; case 5: context->Transform = PHP_5HAVALTransform; break; default: - assert(false); + assertx(false); } } @@ -543,7 +543,7 @@ void hash_haval::hash_final(unsigned char *digest, void *context) { case 224: PHP_HAVAL224Final(digest, (PHP_HAVAL_CTX *)context); break; case 256: PHP_HAVAL256Final(digest, (PHP_HAVAL_CTX *)context); break; default: - assert(false); + assertx(false); } } diff --git a/hphp/runtime/ext/hash/hash_keccak.cpp b/hphp/runtime/ext/hash/hash_keccak.cpp index 08efc1418df..4ce18cb2ae9 100644 --- a/hphp/runtime/ext/hash/hash_keccak.cpp +++ b/hphp/runtime/ext/hash/hash_keccak.cpp @@ -30,9 +30,9 @@ struct KeccakContext { hash_keccak::hash_keccak(uint32_t capacity, uint32_t digestlen) : HashEngine(digestlen, (1600 - capacity) >> 3, sizeof(KeccakContext)) { - assert(capacity > 0); - assert(capacity < 1600); - assert((capacity % 8) == 0); + assertx(capacity > 0); + assertx(capacity < 1600); + assertx((capacity % 8) == 0); } void hash_keccak::hash_init(void *context) { @@ -166,7 +166,7 @@ void hash_keccak::hash_update(void *context, const unsigned char *buf, auto len = std::min(block_size - ctx->pos, count); count -= len; while (len-- > 0) { - assert(ctx->pos < block_size); + assertx(ctx->pos < block_size); ctx->state[ctx->pos++] ^= *(buf++); } if (ctx->pos >= block_size) { diff --git a/hphp/runtime/ext/hh/ext_hh.cpp b/hphp/runtime/ext/hh/ext_hh.cpp index 3bfffa1a9b4..3d8b736592c 100644 --- a/hphp/runtime/ext/hh/ext_hh.cpp +++ b/hphp/runtime/ext/hh/ext_hh.cpp @@ -134,7 +134,7 @@ const uint64_t kCodePrefix = 0xf0; ALWAYS_INLINE void serialize_memoize_code(StringBuffer& sb, SerializeMemoizeCode code) { - assert(code == (code & kCodeMask)); + assertx(code == (code & kCodeMask)); uint8_t v = (kCodePrefix | code); sb.append(reinterpret_cast(&v), 1); } diff --git a/hphp/runtime/ext/hotprofiler/ext_hotprofiler.cpp b/hphp/runtime/ext/hotprofiler/ext_hotprofiler.cpp index 76b82d3f560..e1062ed9f69 100644 --- a/hphp/runtime/ext/hotprofiler/ext_hotprofiler.cpp +++ b/hphp/runtime/ext/hotprofiler/ext_hotprofiler.cpp @@ -618,7 +618,7 @@ struct TraceWalker { // off. This ensures main() represents the entire run, even if we // run out of log space. if (!m_stack.empty()) { - assert(strcmp(m_stack.back().trace->symbol, "main()") == 0); + assertx(strcmp(m_stack.back().trace->symbol, "main()") == 0); incStats(m_stack.back().trace->symbol, final, m_stack.back(), stats); } if (m_badArcCount > 0) { @@ -749,7 +749,7 @@ struct TraceProfiler final : Profiler { } else { m_maxTraceBuffer = RuntimeOption::ProfilerMaxTraceBuffer; Extension* ext = ExtensionRegistry::get(s_hotprofiler); - assert(ext); + assertx(ext); IniSetting::Bind(ext, IniSetting::PHP_INI_ALL, "profiler.max_trace_buffer", &m_maxTraceBuffer); diff --git a/hphp/runtime/ext/hotprofiler/ext_hotprofiler.h b/hphp/runtime/ext/hotprofiler/ext_hotprofiler.h index 55b49bd3489..0895c4e5fe7 100644 --- a/hphp/runtime/ext/hotprofiler/ext_hotprofiler.h +++ b/hphp/runtime/ext/hotprofiler/ext_hotprofiler.h @@ -234,7 +234,7 @@ struct Profiler { * and doesn't actually perform the free. */ void releaseFrame() { - assert(m_stack); + assertx(m_stack); Frame *p = m_stack; m_stack = p->m_parent; diff --git a/hphp/runtime/ext/icu/ext_icu_break_iterator.h b/hphp/runtime/ext/icu/ext_icu_break_iterator.h index a0afd880191..a755a919972 100644 --- a/hphp/runtime/ext/icu/ext_icu_break_iterator.h +++ b/hphp/runtime/ext/icu/ext_icu_break_iterator.h @@ -39,7 +39,7 @@ struct IntlBreakIterator : IntlError { static Object newInstance(icu::BreakIterator* bi = nullptr) { if (!c_IntlBreakIterator) { c_IntlBreakIterator = Unit::lookupClass(s_IntlBreakIterator.get()); - assert(c_IntlBreakIterator); + assertx(c_IntlBreakIterator); } Object obj{c_IntlBreakIterator}; if (bi) { @@ -52,7 +52,7 @@ struct IntlBreakIterator : IntlError { if (!c_IntlCodePointBreakIterator) { c_IntlCodePointBreakIterator = Unit::lookupClass(s_IntlCodePointBreakIterator.get()); - assert(c_IntlCodePointBreakIterator); + assertx(c_IntlCodePointBreakIterator); } Object obj{c_IntlCodePointBreakIterator}; if (bi) { @@ -77,7 +77,7 @@ struct IntlBreakIterator : IntlError { } bool setText(const String& str) { - assert(isValid()); + assertx(isValid()); m_text = str.toCppString(); UErrorCode error = U_ZERO_ERROR; m_uText = utext_openUTF8(m_uText, m_text.c_str(), m_text.size(), &error); diff --git a/hphp/runtime/ext/icu/ext_icu_calendar.cpp b/hphp/runtime/ext/icu/ext_icu_calendar.cpp index e2f06611427..33d23a96b89 100644 --- a/hphp/runtime/ext/icu/ext_icu_calendar.cpp +++ b/hphp/runtime/ext/icu/ext_icu_calendar.cpp @@ -393,7 +393,7 @@ static bool HHVM_METHOD(IntlCalendar, roll, int64_t field, const Variant& value) // TODO: Switch to AcrRec API once it lands static bool HHVM_METHOD(IntlCalendar, __set_array, const Array& args) { - assert(args.size() == 6); + assertx(args.size() == 6); CAL_FETCH(data, this_, false); // Assume at least two args because of PHP signature @@ -419,7 +419,7 @@ static bool HHVM_METHOD(IntlCalendar, __set_array, const Array& args) { } int32_t intargs[6]; - assert(numargs <= 6); + assertx(numargs <= 6); for (int i = 0; i < numargs; ++i) { int64_t arg = args[i].toInt64(); if ((arg < INT32_MIN) || (arg > INT32_MAX)) { @@ -619,7 +619,7 @@ static bool HHVM_METHOD(IntlCalendar, setSkippedWallTimeOption, static void HHVM_METHOD(IntlGregorianCalendar, __ctor_array, const Array& args) { - assert(args.size() == 6); + assertx(args.size() == 6); int32_t numargs; for (numargs = 0; numargs < 6; ++numargs) { @@ -656,7 +656,7 @@ static void HHVM_METHOD(IntlGregorianCalendar, __ctor_array, } int32_t intarg[6]; - assert(numargs <= 6); + assertx(numargs <= 6); for (int i = 0; i < numargs; ++i) { int64_t arg = args[i].toInt64(); if ((arg < INT32_MIN) || (arg > INT32_MAX)) { diff --git a/hphp/runtime/ext/icu/ext_icu_calendar.h b/hphp/runtime/ext/icu/ext_icu_calendar.h index 87546841f6c..535780a97bf 100644 --- a/hphp/runtime/ext/icu/ext_icu_calendar.h +++ b/hphp/runtime/ext/icu/ext_icu_calendar.h @@ -48,7 +48,7 @@ struct IntlCalendar : IntlError { static Object newInstance(icu::Calendar *cal) { if (!c_IntlCalendar) { c_IntlCalendar = Unit::lookupClass(s_IntlCalendar.get()); - assert(c_IntlCalendar); + assertx(c_IntlCalendar); } Object ret{c_IntlCalendar}; if (cal) { diff --git a/hphp/runtime/ext/icu/ext_icu_collator.cpp b/hphp/runtime/ext/icu/ext_icu_collator.cpp index a18225f3064..dd9aec0c37b 100644 --- a/hphp/runtime/ext/icu/ext_icu_collator.cpp +++ b/hphp/runtime/ext/icu/ext_icu_collator.cpp @@ -257,7 +257,7 @@ static bool HHVM_METHOD(Collator, sortWithSortKeys, VRefParam arr) { strval.getBuffer(), strval.length(), (uint8_t*)(sortKeys + sortKeysOffset), sortKeysLength - sortKeysOffset); - assert(sortkey_len <= (sortKeysLength - sortKeysOffset)); + assertx(sortkey_len <= (sortKeysLength - sortKeysOffset)); } // Check for index buffer overflow diff --git a/hphp/runtime/ext/icu/ext_icu_date_fmt.h b/hphp/runtime/ext/icu/ext_icu_date_fmt.h index 480659a876f..a97d16cf381 100644 --- a/hphp/runtime/ext/icu/ext_icu_date_fmt.h +++ b/hphp/runtime/ext/icu/ext_icu_date_fmt.h @@ -54,7 +54,7 @@ struct IntlDateFormatter : IntlError { static Object newInstance() { if (!c_IntlDateFormatter) { c_IntlDateFormatter = Unit::lookupClass(s_IntlDateFormatter.get()); - assert(c_IntlDateFormatter); + assertx(c_IntlDateFormatter); } return Object{c_IntlDateFormatter}; } diff --git a/hphp/runtime/ext/icu/ext_icu_date_pattern_gen.h b/hphp/runtime/ext/icu/ext_icu_date_pattern_gen.h index 99da64f42a4..86c2476040a 100644 --- a/hphp/runtime/ext/icu/ext_icu_date_pattern_gen.h +++ b/hphp/runtime/ext/icu/ext_icu_date_pattern_gen.h @@ -26,7 +26,7 @@ struct IntlDatePatternGenerator : IntlError { if (!c_IntlDatePatternGenerator) { c_IntlDatePatternGenerator = Unit::lookupClass(s_IntlDatePatternGenerator.get()); - assert(c_IntlDatePatternGenerator); + assertx(c_IntlDatePatternGenerator); } Object ret{c_IntlDatePatternGenerator}; if (generator) { diff --git a/hphp/runtime/ext/icu/ext_icu_iterator.h b/hphp/runtime/ext/icu/ext_icu_iterator.h index cc74bcca41c..b4beda180c0 100644 --- a/hphp/runtime/ext/icu/ext_icu_iterator.h +++ b/hphp/runtime/ext/icu/ext_icu_iterator.h @@ -51,7 +51,7 @@ struct IntlIterator : IntlError { static Object newInstance(icu::StringEnumeration *se = nullptr) { if (!c_IntlIterator) { c_IntlIterator = Unit::lookupClass(s_IntlIterator.get()); - assert(c_IntlIterator); + assertx(c_IntlIterator); } Object obj{c_IntlIterator}; if (se) { diff --git a/hphp/runtime/ext/icu/ext_icu_locale.cpp b/hphp/runtime/ext/icu/ext_icu_locale.cpp index 32f83455fbc..8cc53f6f914 100644 --- a/hphp/runtime/ext/icu/ext_icu_locale.cpp +++ b/hphp/runtime/ext/icu/ext_icu_locale.cpp @@ -180,7 +180,7 @@ static Variant get_icu_value(const String &locale, LocaleTag tag, case LOC_VARIANT: ulocfunc = uloc_getVariant; break; case LOC_CANONICALIZE: ulocfunc = uloc_canonicalize; break; default: - assert(false); + assertx(false); return false; } @@ -241,7 +241,7 @@ static Variant get_icu_display_value(const String& locale, case LOC_VARIANT: ulocfunc = uloc_getDisplayVariant; break; case LOC_DISPLAY: ulocfunc = uloc_getDisplayName; break; default: - assert(false); + assertx(false); return false; } diff --git a/hphp/runtime/ext/icu/ext_icu_msg_fmt.cpp b/hphp/runtime/ext/icu/ext_icu_msg_fmt.cpp index cd3e498451f..d5e1d7662bc 100644 --- a/hphp/runtime/ext/icu/ext_icu_msg_fmt.cpp +++ b/hphp/runtime/ext/icu/ext_icu_msg_fmt.cpp @@ -353,7 +353,7 @@ static Variant HHVM_METHOD(MessageFormatter, format, const Array& args) { !data->mapArgs(arg_types, arg_names, args)) { return false; } - assert(arg_types.size() == arg_names.size()); + assertx(arg_types.size() == arg_names.size()); icu::UnicodeString result; UErrorCode error = U_ZERO_ERROR; diff --git a/hphp/runtime/ext/icu/ext_icu_num_fmt.h b/hphp/runtime/ext/icu/ext_icu_num_fmt.h index 9c5878c3081..a657f7c123a 100644 --- a/hphp/runtime/ext/icu/ext_icu_num_fmt.h +++ b/hphp/runtime/ext/icu/ext_icu_num_fmt.h @@ -52,7 +52,7 @@ struct NumberFormatter : IntlError { static Object newInstance() { if (!c_NumberFormatter) { c_NumberFormatter = Unit::lookupClass(s_NumberFormatter.get()); - assert(c_NumberFormatter); + assertx(c_NumberFormatter); } return Object{c_NumberFormatter}; } diff --git a/hphp/runtime/ext/icu/ext_icu_rsrc_bundle.h b/hphp/runtime/ext/icu/ext_icu_rsrc_bundle.h index 66d9e691696..6cd07fcb2de 100644 --- a/hphp/runtime/ext/icu/ext_icu_rsrc_bundle.h +++ b/hphp/runtime/ext/icu/ext_icu_rsrc_bundle.h @@ -33,7 +33,7 @@ struct ResourceBundle : IntlError { static Object newInstance(icu::ResourceBundle* bundle) { if (!c_ResourceBundle) { c_ResourceBundle = Unit::lookupClass(s_ResourceBundle.get()); - assert(c_ResourceBundle); + assertx(c_ResourceBundle); } Object obj{c_ResourceBundle}; auto data = Native::data(obj); @@ -61,7 +61,7 @@ struct ResourceBundle : IntlError { return true; } icu::ResourceBundle iterCurrent(UErrorCode& error) { - assert(iterValid()); + assertx(iterValid()); return m_rsrc->get(m_iterIndex, error); } Variant iterKey() { diff --git a/hphp/runtime/ext/icu/ext_icu_timezone.h b/hphp/runtime/ext/icu/ext_icu_timezone.h index fe417dd288c..c965605a917 100644 --- a/hphp/runtime/ext/icu/ext_icu_timezone.h +++ b/hphp/runtime/ext/icu/ext_icu_timezone.h @@ -40,7 +40,7 @@ struct IntlTimeZone : IntlError { static Object newInstance(icu::TimeZone *tz = nullptr, bool owned = true) { if (!c_IntlTimeZone) { c_IntlTimeZone = Unit::lookupClass(s_IntlTimeZone.get()); - assert(c_IntlTimeZone); + assertx(c_IntlTimeZone); } Object obj{c_IntlTimeZone}; if (tz) { diff --git a/hphp/runtime/ext/icu/ext_icu_transliterator.h b/hphp/runtime/ext/icu/ext_icu_transliterator.h index db598c350f8..dc5943bae73 100644 --- a/hphp/runtime/ext/icu/ext_icu_transliterator.h +++ b/hphp/runtime/ext/icu/ext_icu_transliterator.h @@ -32,7 +32,7 @@ struct Transliterator : IntlError { static Object newInstance(icu::Transliterator* trans) { if (!c_Transliterator) { c_Transliterator = Unit::lookupClass(s_Transliterator.get()); - assert(c_Transliterator); + assertx(c_Transliterator); } Object obj{c_Transliterator}; auto data = Native::data(obj); diff --git a/hphp/runtime/ext/icu/ext_icu_uconverter.cpp b/hphp/runtime/ext/icu/ext_icu_uconverter.cpp index e6507ecb282..df9ddeb523d 100644 --- a/hphp/runtime/ext/icu/ext_icu_uconverter.cpp +++ b/hphp/runtime/ext/icu/ext_icu_uconverter.cpp @@ -37,7 +37,7 @@ static Class* UConverterClass = nullptr; static Class* getClass() { if (!UConverterClass) { UConverterClass = Unit::lookupClass(s_UConverter.get()); - assert(UConverterClass); + assertx(UConverterClass); } return UConverterClass; } diff --git a/hphp/runtime/ext/icu/ext_icu_ucsdet.h b/hphp/runtime/ext/icu/ext_icu_ucsdet.h index 8b33ef7da74..5424ad032f3 100644 --- a/hphp/runtime/ext/icu/ext_icu_ucsdet.h +++ b/hphp/runtime/ext/icu/ext_icu_ucsdet.h @@ -86,7 +86,7 @@ struct EncodingMatch : IntlError { static Object newInstance(const UCharsetMatch* match) { if (UNLIKELY(!c_EncodingMatch)) { c_EncodingMatch = Unit::lookupClass(s_EncodingMatch.get()); - assert(c_EncodingMatch); + assertx(c_EncodingMatch); } Object ret{c_EncodingMatch}; Native::data(ret)->m_match = diff --git a/hphp/runtime/ext/icu/icu.cpp b/hphp/runtime/ext/icu/icu.cpp index b7f3f14c47e..7e8b0115d3d 100644 --- a/hphp/runtime/ext/icu/icu.cpp +++ b/hphp/runtime/ext/icu/icu.cpp @@ -74,7 +74,7 @@ void IntlError::throwException(const char *format, ...) { static __thread std::string* s_defaultLocale; void IntlExtension::bindIniSettings() { - assert(!s_defaultLocale); + assertx(!s_defaultLocale); s_defaultLocale = new std::string; IniSetting::Bind(this, IniSetting::PHP_INI_ALL, "intl.default_locale", "", @@ -87,7 +87,7 @@ void IntlExtension::threadShutdown() { } const String GetDefaultLocale() { - assert(s_defaultLocale); + assertx(s_defaultLocale); if (s_defaultLocale->empty()) { return String(uloc_getDefault(), CopyString); } @@ -95,7 +95,7 @@ const String GetDefaultLocale() { } bool SetDefaultLocale(const String& locale) { - assert(s_defaultLocale); + assertx(s_defaultLocale); *s_defaultLocale = locale.toCppString(); return true; } diff --git a/hphp/runtime/ext/imagick/ext_imagick.h b/hphp/runtime/ext/imagick/ext_imagick.h index be85c4326d1..cb4cb9cec28 100644 --- a/hphp/runtime/ext/imagick/ext_imagick.h +++ b/hphp/runtime/ext/imagick/ext_imagick.h @@ -243,7 +243,7 @@ req::ptr> getDrawingWandResource(const Object& obj) { ALWAYS_INLINE req::ptr> getPixelWandResource(const Object& obj) { auto ret = getWandResource(s_ImagickPixel, obj); - assert(ret != nullptr && ret->getWand() != nullptr); + assertx(ret != nullptr && ret->getWand() != nullptr); return ret; } diff --git a/hphp/runtime/ext/json/JSON_parser.cpp b/hphp/runtime/ext/json/JSON_parser.cpp index 92a849bce37..833051ec310 100644 --- a/hphp/runtime/ext/json/JSON_parser.cpp +++ b/hphp/runtime/ext/json/JSON_parser.cpp @@ -303,7 +303,7 @@ namespace { NEVER_INLINE static void tvDecRefRange(TypedValue* begin, TypedValue* end) { - assert(begin <= end); + assertx(begin <= end); for (auto tv = begin; tv != end; ++tv) { tvDecRefGen(tv); } @@ -349,7 +349,7 @@ struct SimpleParser { : p(input), top(buffer), array_depth(-kMaxArrayDepth) /* Start negative to simplify check. */ { - assert(input[length] == 0); // Parser relies on sentinel to avoid checks. + assertx(input[length] == 0); // Parser relies on sentinel to avoid checks. } /* @@ -576,17 +576,17 @@ struct UncheckedBuffer { #endif } void append(char c) { - assert(p < end); + assertx(p < end); *p++ = c; } void shrinkBy(int decrease) { p -= decrease; - assert(p >= begin); + assertx(p >= begin); } int size() { return p - begin; } // NUL-terminates the output before returning it, for backward-compatibility. char* data() { - assert(p < end); + assertx(p < end); *p = 0; return begin; } @@ -773,7 +773,7 @@ static void json_create_zval(Variant &z, UncheckedBuffer &buf, int type, case KindOfInt64: { bool bigint = false; const char *p = buf.data(); - assert(p); + assertx(p); if (p == NULL) { z = int64_t(0); return; @@ -1049,7 +1049,7 @@ bool JSON_parser(Variant &z, const char *p, int length, bool const assoc, s_json_parser->error_code = JSON_ERROR_UTF8; return false; } - assert(b >= 0); + assertx(b >= 0); if ((b & 127) == b) { /**/ diff --git a/hphp/runtime/ext/json/ext_json.cpp b/hphp/runtime/ext/json/ext_json.cpp index eb2e7ec69ca..0f21cbcfcc4 100644 --- a/hphp/runtime/ext/json/ext_json.cpp +++ b/hphp/runtime/ext/json/ext_json.cpp @@ -232,7 +232,7 @@ TypedValue HHVM_FUNCTION(json_decode, const String& json, return tvReturn(json.substr(1, json.size() - 2)); } - assert(json_get_last_error_code() != json_error_codes::JSON_ERROR_NONE); + assertx(json_get_last_error_code() != json_error_codes::JSON_ERROR_NONE); return make_tv(); } diff --git a/hphp/runtime/ext/libxml/ext_libxml.cpp b/hphp/runtime/ext/libxml/ext_libxml.cpp index a64db7d03bd..68e3fd96122 100644 --- a/hphp/runtime/ext/libxml/ext_libxml.cpp +++ b/hphp/runtime/ext/libxml/ext_libxml.cpp @@ -142,7 +142,7 @@ const StaticString void XMLNodeData::sweep() { if (m_node) { - assert(this == m_node->_private); + assertx(this == m_node->_private); php_libxml_node_free_resource(m_node); } @@ -150,7 +150,7 @@ void XMLNodeData::sweep() { } void XMLDocumentData::cleanup() { - assert(!m_liveNodes); + assertx(!m_liveNodes); auto docp = (xmlDocPtr)m_node; if (docp->URL) { xmlFree((void*)docp->URL); @@ -211,7 +211,7 @@ int libxml_streams_IO_read(void* context, char* buffer, int len) { Trace::Indent _i; auto stream = getStream(context); - assert(len >= 0); + assertx(len >= 0); if (len > 0) { String str = stream->read(len); if (str.size() <= len) { diff --git a/hphp/runtime/ext/libxml/ext_libxml.h b/hphp/runtime/ext/libxml/ext_libxml.h index b8661ab761e..7f07d0166a9 100644 --- a/hphp/runtime/ext/libxml/ext_libxml.h +++ b/hphp/runtime/ext/libxml/ext_libxml.h @@ -137,7 +137,7 @@ struct XMLDocumentData : XMLNodeData { , m_recover(false) , m_destruct(false) { - assert(p->type == XML_HTML_DOCUMENT_NODE || p->type == XML_DOCUMENT_NODE); + assertx(p->type == XML_HTML_DOCUMENT_NODE || p->type == XML_DOCUMENT_NODE); } void copyProperties(req::ptr data) { @@ -154,7 +154,7 @@ struct XMLDocumentData : XMLNodeData { xmlDocPtr docp() const { return (xmlDocPtr)m_node; } void attachNode() { m_liveNodes++; } void detachNode() { - assert(m_liveNodes); + assertx(m_liveNodes); if (!--m_liveNodes && m_destruct) cleanup(); } @@ -184,7 +184,7 @@ inline XMLNode libxml_register_node(xmlNodePtr p) { if (p->type == XML_HTML_DOCUMENT_NODE || p->type == XML_DOCUMENT_NODE) { - assert(p->doc == (xmlDocPtr)p); + assertx(p->doc == (xmlDocPtr)p); return req::make((xmlDocPtr)p); } @@ -197,7 +197,7 @@ inline XMLNode libxml_register_node(xmlDocPtr p) { inline XMLNodeData::XMLNodeData(xmlNodePtr p) : m_node(p) { - assert(p && !p->_private); + assertx(p && !p->_private); m_node->_private = this; if (p->doc && p != (xmlNodePtr)p->doc) { @@ -208,7 +208,7 @@ inline XMLNodeData::XMLNodeData(xmlNodePtr p) : m_node(p) { inline XMLNodeData::~XMLNodeData() { if (m_node) { - assert(!m_cache && m_node->_private == this); + assertx(!m_cache && m_node->_private == this); m_node->_private = nullptr; php_libxml_node_free_resource(m_node); @@ -231,11 +231,11 @@ inline req::ptr XMLNodeData::doc() { } if (!m_doc) { - assert(!m_node->doc); + assertx(!m_node->doc); return nullptr; } - assert(m_doc.get() == libxml_register_node((xmlNodePtr)m_node->doc).get()); + assertx(m_doc.get() == libxml_register_node((xmlNodePtr)m_node->doc).get()); return m_doc; } diff --git a/hphp/runtime/ext/mailparse/mime.cpp b/hphp/runtime/ext/mailparse/mime.cpp index da828cbecd0..8a1581da938 100644 --- a/hphp/runtime/ext/mailparse/mime.cpp +++ b/hphp/runtime/ext/mailparse/mime.cpp @@ -34,7 +34,7 @@ MimePart::MimeHeader::MimeHeader() MimePart::MimeHeader::MimeHeader(const char *value) : m_empty(false) { - assert(value); + assertx(value); m_attributes = Array::Create(); m_value = String(value, CopyString); } diff --git a/hphp/runtime/ext/mcrouter/ext_mcrouter.cpp b/hphp/runtime/ext/mcrouter/ext_mcrouter.cpp index 05f0ce86f69..6d4ce6ba270 100644 --- a/hphp/runtime/ext/mcrouter/ext_mcrouter.cpp +++ b/hphp/runtime/ext/mcrouter/ext_mcrouter.cpp @@ -47,7 +47,7 @@ static void mcr_throwException(const std::string& message, const std::string& key = "") { if (!c_MCRouterException) { c_MCRouterException = Unit::lookupClass(s_MCRouterException.get()); - assert(c_MCRouterException); + assertx(c_MCRouterException); } Object obj{c_MCRouterException}; @@ -67,7 +67,7 @@ static void mcr_throwOptionException( if (!c_MCRouterOptionException) { c_MCRouterOptionException = Unit::lookupClass(s_MCRouterOptionException.get()); - assert(c_MCRouterOptionException); + assertx(c_MCRouterOptionException); } Array errorArray = Array::Create(); @@ -354,7 +354,7 @@ Object MCRouter::issue(std::unique_ptr request) { try { return Object{ev->getWaitHandle()}; } catch (...) { - assert(false); + assertx(false); ev->abandon(); throw; } diff --git a/hphp/runtime/ext/memcache/ext_memcache.cpp b/hphp/runtime/ext/memcache/ext_memcache.cpp index 5e8bacbefac..34d4f2a2aa9 100644 --- a/hphp/runtime/ext/memcache/ext_memcache.cpp +++ b/hphp/runtime/ext/memcache/ext_memcache.cpp @@ -751,7 +751,7 @@ HHVM_METHOD(Memcache, addserver, const String& host, int port /* = 11211 */, struct MemcacheExtension final : Extension { MemcacheExtension() : Extension("memcache", "3.0.8") {}; void threadInit() override { - assert(!s_memcache_globals); + assertx(!s_memcache_globals); s_memcache_globals = new MEMCACHEGlobals; IniSetting::Bind(this, IniSetting::PHP_INI_ALL, "memcache.hash_strategy", "standard", diff --git a/hphp/runtime/ext/mysql/ext_mysqli.cpp b/hphp/runtime/ext/mysql/ext_mysqli.cpp index 7b7f974f469..64c00cfa802 100644 --- a/hphp/runtime/ext/mysql/ext_mysqli.cpp +++ b/hphp/runtime/ext/mysql/ext_mysqli.cpp @@ -281,7 +281,7 @@ static bool HHVM_METHOD(mysqli, hh_real_connect, const Variant& server, s = s.substr(2); } auto conn = get_connection(Object{this_}); - assert(conn); + assertx(conn); Variant ret = php_mysql_do_connect_on_link( conn, s, username.toString(), password.toString(), dbname.toString(), client_flags.toInt64(), persistent, false, @@ -303,10 +303,10 @@ static Variant HHVM_METHOD(mysqli, hh_real_query, const String& query) { static void HHVM_METHOD(mysqli, hh_update_last_error, const Object& stmt_obj) { auto conn = get_connection(Object{this_}); - assert(conn); + assertx(conn); auto stmt = getStmt(stmt_obj); - assert(stmt); + assertx(stmt); auto s = stmt->get(); auto mysql = conn->get(); diff --git a/hphp/runtime/ext/mysql/mysql_common.cpp b/hphp/runtime/ext/mysql/mysql_common.cpp index 697dfb9bc3e..a6a598d5bec 100644 --- a/hphp/runtime/ext/mysql/mysql_common.cpp +++ b/hphp/runtime/ext/mysql/mysql_common.cpp @@ -83,14 +83,14 @@ int MySQLUtil::set_mysql_timeout(MYSQL *mysql, case MySQLUtil::ConnectTimeout: opt = MYSQL_OPT_CONNECT_TIMEOUT_MS; break; case MySQLUtil::ReadTimeout: opt = MYSQL_OPT_READ_TIMEOUT_MS; break; case MySQLUtil::WriteTimeout: opt = MYSQL_OPT_WRITE_TIMEOUT_MS; break; - default: assert(false); break; + default: assertx(false); break; } #else switch (type) { case MySQLUtil::ConnectTimeout: opt = MYSQL_OPT_CONNECT_TIMEOUT; break; case MySQLUtil::ReadTimeout: opt = MYSQL_OPT_READ_TIMEOUT; break; case MySQLUtil::WriteTimeout: opt = MYSQL_OPT_WRITE_TIMEOUT; break; - default: assert(false); break; + default: assertx(false); break; } ms = (ms + 999) / 1000; #endif @@ -290,7 +290,7 @@ MySQL::MySQL(const char *host, int port, const char *username, } void MySQL::setLastError(const char *func) { - assert(m_conn); + assertx(m_conn); m_last_error_set = true; m_last_errno = mysql_errno(m_conn); const char *error = mysql_error(m_conn); @@ -658,7 +658,7 @@ static void mysql_set_conn_attr(MYSQL* mysql, const String& key, static void mysql_set_conn_attrs( std::shared_ptr mySQL, const Array* conn_attrs) { - assert(mySQL != nullptr && mySQL->get() != nullptr); + assertx(mySQL != nullptr && mySQL->get() != nullptr); for (auto itr = conn_attrs->begin(); !itr.end(); itr.next()) { const auto& key = itr.first(); @@ -857,7 +857,7 @@ void MySQLResult::addField(Variant&& value) { } void MySQLResult::setFieldCount(int64_t fields) { - assert(m_fields.empty()); + assertx(m_fields.empty()); m_fields.resize(fields); } @@ -936,7 +936,7 @@ bool MySQLResult::seekRow(int64_t row) { bool MySQLResult::fetchRow() { // If not localized, use standard mysql functions on m_res - assert(isLocalized()); + assertx(isLocalized()); if (m_current_row != m_rows->end()) m_current_row++; if (m_current_row != m_rows->end()) { m_row_ready = true; @@ -1011,7 +1011,7 @@ MySQLStmtVariables::~MySQLStmtVariables() { } bool MySQLStmtVariables::bind_result(MYSQL_STMT *stmt) { - assert(m_arr.size() == mysql_stmt_field_count(stmt)); + assertx(m_arr.size() == mysql_stmt_field_count(stmt)); MYSQL_RES *res = mysql_stmt_result_metadata(stmt); MYSQL_FIELD *fields = mysql_fetch_fields(res); @@ -1065,7 +1065,7 @@ bool MySQLStmtVariables::bind_result(MYSQL_STMT *stmt) { // There exists some more types in this enum like MYSQL_TYPE_TIMESTAMP2, // MYSQL_TYPE_DATETIME2, MYSQL_TYPE_TIME2 but they are just used on the // server - assert(false); + assertx(false); } if (b->buffer_length > 0) { @@ -1096,7 +1096,7 @@ void MySQLStmtVariables::update_result() { default: // We never ask for anything else than DOUBLE, LONGLONG and STRING // so in the case we get something else back something is really wrong - assert(false); + assertx(false); } } @@ -1105,7 +1105,7 @@ void MySQLStmtVariables::update_result() { } bool MySQLStmtVariables::init_params(MYSQL_STMT *stmt, const String& types) { - assert(m_arr.size() == types.size()); + assertx(m_arr.size() == types.size()); for (int i = 0; i < types.size(); i++) { MYSQL_BIND *b = &m_vars[i]; @@ -1123,7 +1123,7 @@ bool MySQLStmtVariables::init_params(MYSQL_STMT *stmt, const String& types) { b->buffer_type = MYSQL_TYPE_LONG_BLOB; break; default: - assert(false); + assertx(false); } } @@ -1167,7 +1167,7 @@ bool MySQLStmtVariables::bind_params(MYSQL_STMT *stmt) { // anything here break; default: - assert(false); + assertx(false); } } } diff --git a/hphp/runtime/ext/mysql/mysql_common.h b/hphp/runtime/ext/mysql/mysql_common.h index e2c3c641c5c..57e20e425d1 100644 --- a/hphp/runtime/ext/mysql/mysql_common.h +++ b/hphp/runtime/ext/mysql/mysql_common.h @@ -229,7 +229,7 @@ public: struct MySQLResource : SweepableResourceData { explicit MySQLResource(std::shared_ptr mysql) : m_mysql(mysql) { - assert(mysql); + assertx(mysql); } CLASSNAME_IS("mysql link") diff --git a/hphp/runtime/ext/mysql/mysql_stats.cpp b/hphp/runtime/ext/mysql/mysql_stats.cpp index 2037965b3cc..091e5042163 100644 --- a/hphp/runtime/ext/mysql/mysql_stats.cpp +++ b/hphp/runtime/ext/mysql/mysql_stats.cpp @@ -30,7 +30,7 @@ Mutex MySqlStats::s_mutex; MySqlStats::StatsMap MySqlStats::s_stats; void MySqlStats::Init() { - assert(!s_inited); + assertx(!s_inited); s_verbs["t_begin" ] = T_BEGIN; s_verbs["t_commit" ] = T_COMMIT; @@ -146,7 +146,7 @@ std::string MySqlStats::ReportStats() { Stats &stats = *iter->second; for (int i = 0; i < VERB_COUNT; i++) { const char *name = Translate((Verb)i); - assert(name); + assertx(name); out << " <" << name << ">"; out << stats.actions[i]; out << "\n"; diff --git a/hphp/runtime/ext/objprof/ext_heapgraph.cpp b/hphp/runtime/ext/objprof/ext_heapgraph.cpp index 526a01a665e..1acc68ec68a 100644 --- a/hphp/runtime/ext/objprof/ext_heapgraph.cpp +++ b/hphp/runtime/ext/objprof/ext_heapgraph.cpp @@ -177,7 +177,7 @@ const StringData* edgeKindName(HeapGraph::PtrKind kind) { // return metadata about this pointer, in the form of a CapturedPtr CapturedPtr getEdgeInfo(const HeapGraph& g, int ptr) { // Try to drill down and resolve the edge name - assert(g.ptrs[ptr].from != -1 && g.ptrs[ptr].to != -1); + assertx(g.ptrs[ptr].from != -1 && g.ptrs[ptr].to != -1); auto& edge = g.ptrs[ptr]; auto& from = g.nodes[edge.from]; int prop_offset = edge.offset; diff --git a/hphp/runtime/ext/objprof/ext_objprof.cpp b/hphp/runtime/ext/objprof/ext_objprof.cpp index b34a558f09f..877d41cf416 100644 --- a/hphp/runtime/ext/objprof/ext_objprof.cpp +++ b/hphp/runtime/ext/objprof/ext_objprof.cpp @@ -141,7 +141,7 @@ std::pair getObjSize( ); String pathString(ObjprofStack* stack, const char* sep) { - assert(stack->size() < 100000000); + assertx(stack->size() < 100000000); StringBuffer sb; for (size_t i = 0; i < stack->size(); ++i) { if (i != 0) sb.append(sep); @@ -399,7 +399,7 @@ void stringsOfArray( // a gcc-4.9 bug (t16350411); even after t16350411 is fixed, we // can't always_assert(false) here until we stop supporting gcc-4.9 // for open source users, since they may be using an older version - assert(false); + assertx(false); } tvGetStrings(v, metrics, path, pointers, val_stack); @@ -1120,7 +1120,7 @@ Array HHVM_FUNCTION(objprof_get_paths, objsizePair.first, objsizePair.second ); - assert(stack.size() == 0); + assertx(stack.size() == 0); }); NamedEntity::foreach_class([&](Class* cls) { @@ -1180,7 +1180,7 @@ Array HHVM_FUNCTION(objprof_get_paths, aggReferral.sources.insert(cls); } } - assert(stack.size() == 0); + assertx(stack.size() == 0); } }); diff --git a/hphp/runtime/ext/odbc/ext_odbc.cpp b/hphp/runtime/ext/odbc/ext_odbc.cpp index ee60632e5e7..4d0c6ad3f25 100644 --- a/hphp/runtime/ext/odbc/ext_odbc.cpp +++ b/hphp/runtime/ext/odbc/ext_odbc.cpp @@ -371,7 +371,7 @@ bool ODBCCursor::prepare_query(const String& query) for (int i=1; i <= params_size_; i++) { params_.append(Variant(req::make(hdl_stmt_, i))); } - assert(params_.size() == params_size_); + assertx(params_.size() == params_size_); return true; } @@ -473,7 +473,7 @@ bool ODBCCursor::bind_buffer() cursor = (SQLPOINTER)((char*)cursor + column->total_column_size()); } - assert(columns_count_ == columns_.size()); + assertx(columns_count_ == columns_.size()); is_buffer_bound = true; return true; } diff --git a/hphp/runtime/ext/openssl/ext_openssl.cpp b/hphp/runtime/ext/openssl/ext_openssl.cpp index f71aa0fba0e..193813c38ed 100644 --- a/hphp/runtime/ext/openssl/ext_openssl.cpp +++ b/hphp/runtime/ext/openssl/ext_openssl.cpp @@ -93,7 +93,7 @@ static OpenSSLInitializer s_openssl_initializer; struct Key : SweepableResourceData { EVP_PKEY *m_key; - explicit Key(EVP_PKEY *key) : m_key(key) { assert(m_key);} + explicit Key(EVP_PKEY *key) : m_key(key) { assertx(m_key);} ~Key() { if (m_key) EVP_PKEY_free(m_key); } @@ -105,14 +105,14 @@ struct Key : SweepableResourceData { DECLARE_RESOURCE_ALLOCATION(Key) bool isPrivate() { - assert(m_key); + assertx(m_key); switch (EVP_PKEY_id(m_key)) { #ifndef NO_RSA case EVP_PKEY_RSA: case EVP_PKEY_RSA2: { const auto rsa = EVP_PKEY_get0_RSA(m_key); - assert(rsa); + assertx(rsa); const BIGNUM *p, *q; RSA_get0_factors(rsa, &p, &q); if (!p || !q) { @@ -129,7 +129,7 @@ struct Key : SweepableResourceData { case EVP_PKEY_DSA4: { const auto dsa = EVP_PKEY_get0_DSA(m_key); - assert(dsa); + assertx(dsa); const BIGNUM *p, *q, *g, *pub_key, *priv_key; DSA_get0_pqg(dsa, &p, &q, &g); if (!p || !q || !g) { @@ -146,7 +146,7 @@ struct Key : SweepableResourceData { case EVP_PKEY_DH: { const auto dh = EVP_PKEY_get0_DH(m_key); - assert(dh); + assertx(dh); const BIGNUM *p, *q, *g, *pub_key, *priv_key; DH_get0_pqg(dh, &p, &q, &g); if (!p) { @@ -163,7 +163,7 @@ struct Key : SweepableResourceData { case EVP_PKEY_EC: { const auto ec_key = EVP_PKEY_get0_EC_KEY(m_key); - assert(ec_key); + assertx(ec_key); if (EC_KEY_get0_private_key(ec_key) == nullptr) { return false; } @@ -278,7 +278,7 @@ private: public: explicit CSRequest(X509_REQ *csr) : m_csr(csr) { - assert(m_csr); + assertx(m_csr); } X509_REQ *csr() { return m_csr; } @@ -393,7 +393,7 @@ struct php_x509_request { } bool generatePrivateKey() { - assert(priv_key == nullptr); + assertx(priv_key == nullptr); if (priv_key_bits < MIN_KEY_LENGTH) { raise_warning("private key length is too short; it needs to be " @@ -1327,7 +1327,7 @@ openssl_pkcs12_export_impl(const Variant& x509, BIO *bio_out, (char*)(friendly_name.empty() ? nullptr : friendly_name.data()), key, cert, ca, 0, 0, 0, 0, 0); - assert(bio_out); + assertx(bio_out); bool ret = i2d_PKCS12_bio(bio_out, p12); PKCS12_free(p12); sk_X509_free(ca); @@ -1475,8 +1475,8 @@ bool HHVM_FUNCTION(openssl_pkcs7_decrypt, const String& infilename, if (p7 == nullptr) { goto clean_exit; } - assert(okey->m_key); - assert(ocert->m_cert); + assertx(okey->m_key); + assertx(ocert->m_cert); if (PKCS7_decrypt(p7, okey->m_key, ocert->m_cert, out, PKCS7_DETACHED)) { ret = true; } @@ -1693,9 +1693,9 @@ Variant openssl_pkcs7_verify_core( #if (OPENSSL_VERSION_NUMBER >= 0x10000000) // make sure no other callback is specified #if OPENSSL_VERSION_NUMBER >= 0x10100000L - assert(!X509_STORE_get_verify_cb(store)); + assertx(!X509_STORE_get_verify_cb(store)); #else - assert(!store->verify_cb); + assertx(!store->verify_cb); #endif // ignore expired certs X509_STORE_set_verify_cb(store, pkcs7_ignore_expiration); @@ -1787,7 +1787,7 @@ openssl_pkey_export_impl(const Variant& key, BIO *bio_out, } else { cipher = nullptr; } - assert(bio_out); + assertx(bio_out); switch (EVP_PKEY_id(pkey)) { #ifdef HAVE_EVP_PKEY_EC @@ -1905,7 +1905,7 @@ Array HHVM_FUNCTION(openssl_pkey_get_details, const Resource& key) { { ktype = OPENSSL_KEYTYPE_RSA; RSA *rsa = EVP_PKEY_get0_RSA(pkey); - assert(rsa); + assertx(rsa); const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; RSA_get0_key(rsa, &n, &e, &d); RSA_get0_factors(rsa, &p, &q); @@ -1928,7 +1928,7 @@ Array HHVM_FUNCTION(openssl_pkey_get_details, const Resource& key) { { ktype = OPENSSL_KEYTYPE_DSA; DSA *dsa = EVP_PKEY_get0_DSA(pkey); - assert(dsa); + assertx(dsa); const BIGNUM *p, *q, *g, *pub_key, *priv_key; DSA_get0_pqg(dsa, &p, &q, &g); DSA_get0_key(dsa, &pub_key, &priv_key); @@ -1944,7 +1944,7 @@ Array HHVM_FUNCTION(openssl_pkey_get_details, const Resource& key) { { ktype = OPENSSL_KEYTYPE_DH; DH *dh = EVP_PKEY_get0_DH(pkey); - assert(dh); + assertx(dh); const BIGNUM *p, *q, *g, *pub_key, *priv_key; DH_get0_pqg(dh, &p, &q, &g); DH_get0_key(dh, &pub_key, &priv_key); @@ -1960,7 +1960,7 @@ Array HHVM_FUNCTION(openssl_pkey_get_details, const Resource& key) { { ktype = OPENSSL_KEYTYPE_EC; auto const ec = EVP_PKEY_get0_EC_KEY(pkey); - assert(ec); + assertx(ec); auto const ec_group = EC_KEY_get0_group(ec); auto const nid = EC_GROUP_get_curve_name(ec_group); @@ -2470,7 +2470,7 @@ Variant HHVM_FUNCTION(openssl_x509_checkpurpose, const Variant& x509cert, } X509 *cert; cert = ocert->m_cert; - assert(cert); + assertx(cert); ret = check_cert(pcainfo, cert, untrustedchain, purpose); @@ -2492,9 +2492,9 @@ static bool openssl_x509_export_impl(const Variant& x509, BIO *bio_out, return false; } X509 *cert = ocert->m_cert; - assert(cert); + assertx(cert); - assert(bio_out); + assertx(bio_out); if (!notext) { X509_print(bio_out, cert); } @@ -2673,7 +2673,7 @@ Variant HHVM_FUNCTION(openssl_x509_parse, const Variant& x509cert, return false; } X509 *cert = ocert->m_cert; - assert(cert); + assertx(cert); Array ret; const auto sn = X509_get_subject_name(cert); diff --git a/hphp/runtime/ext/pcre/ext_pcre.cpp b/hphp/runtime/ext/pcre/ext_pcre.cpp index 410d371e67f..61adba584f8 100644 --- a/hphp/runtime/ext/pcre/ext_pcre.cpp +++ b/hphp/runtime/ext/pcre/ext_pcre.cpp @@ -95,12 +95,12 @@ static Variant preg_replace_callback_array_impl( auto key = 0; auto total_replacement_count = 0; for (ArrayIter s_iter(subjects); s_iter; ++s_iter) { - assert(s_iter.second().isString()); + assertx(s_iter.second().isString()); auto subj = s_iter.second(); for (ArrayIter pc_iter(patterns_and_callbacks.toArray()); pc_iter; ++pc_iter) { Variant pattern(pc_iter.first()); - assert(pattern.isString()); + assertx(pattern.isString()); Variant callback(pc_iter.second()); subj = HHVM_FN(preg_replace_callback)(pattern, callback, subj, limit, count); diff --git a/hphp/runtime/ext/pdo/ext_pdo.cpp b/hphp/runtime/ext/pdo/ext_pdo.cpp index 4683591f4ca..06b1dbe565f 100644 --- a/hphp/runtime/ext/pdo/ext_pdo.cpp +++ b/hphp/runtime/ext/pdo/ext_pdo.cpp @@ -974,7 +974,7 @@ static void HHVM_METHOD(PDO, __construct, const String& dsn, } } else if (data->m_dbh) { if (is_persistent) { - assert(!shashkey.empty()); + assertx(!shashkey.empty()); s_connections[shashkey] = data->m_dbh->conn(); } @@ -990,7 +990,7 @@ static Variant HHVM_METHOD(PDO, prepare, const String& statement, const Array& options = null_array) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); setPDOErrorNone(data->m_dbh->conn()->error_code); data->m_dbh->query_stmt = nullptr; @@ -1018,7 +1018,7 @@ static Variant HHVM_METHOD(PDO, prepare, const String& statement, if (data->m_dbh->conn()->preparer(statement, &pdostmt->m_stmt, options)) { auto stmt = pdostmt->m_stmt; - assert(stmt); + assertx(stmt); /* unconditionally keep this for later reference */ stmt->query_string = statement; @@ -1053,7 +1053,7 @@ static Variant HHVM_METHOD(PDO, prepare, const String& statement, static bool HHVM_METHOD(PDO, commit) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); if (!data->m_dbh->conn()->in_txn) { throw_pdo_exception(uninit_null(), uninit_null(), "There is no active transaction"); @@ -1069,14 +1069,14 @@ static bool HHVM_METHOD(PDO, commit) { static bool HHVM_METHOD(PDO, intransaction) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); return data->m_dbh->conn()->in_txn; } static bool HHVM_METHOD(PDO, rollback) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); if (!data->m_dbh->conn()->in_txn) { throw_pdo_exception(uninit_null(), uninit_null(), "There is no active transaction"); @@ -1093,7 +1093,7 @@ static bool HHVM_METHOD(PDO, setattribute, int64_t attribute, const Variant& value) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); #define PDO_LONG_PARAM_CHECK \ if (!value.isInteger() && !value.isString() && !value.isBoolean()) { \ @@ -1211,7 +1211,7 @@ static bool HHVM_METHOD(PDO, setattribute, int64_t attribute, static Variant HHVM_METHOD(PDO, getattribute, int64_t attribute) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); setPDOErrorNone(data->m_dbh->conn()->error_code); data->m_dbh->query_stmt = nullptr; @@ -1273,7 +1273,7 @@ static Variant HHVM_METHOD(PDO, exec, const String& query) { return false; } - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); setPDOErrorNone(data->m_dbh->conn()->error_code); data->m_dbh->query_stmt = nullptr; @@ -1289,7 +1289,7 @@ static Variant HHVM_METHOD(PDO, lastinsertid, const String& seqname /* = null_string */) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); setPDOErrorNone(data->m_dbh->conn()->error_code); data->m_dbh->query_stmt = nullptr; @@ -1310,7 +1310,7 @@ static Variant HHVM_METHOD(PDO, lastinsertid, static Variant HHVM_METHOD(PDO, errorcode) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); if (data->m_dbh->query_stmt) { return String(data->m_dbh->query_stmt->error_code, CopyString); } @@ -1329,7 +1329,7 @@ static Variant HHVM_METHOD(PDO, errorcode) { static Array HHVM_METHOD(PDO, errorinfo) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); Array ret; if (data->m_dbh->query_stmt) { @@ -1363,7 +1363,7 @@ static Variant HHVM_METHOD(PDO, query, const String& sql, auto data = Native::data(this_); SYNC_VM_REGS_SCOPED(); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); setPDOErrorNone(data->m_dbh->conn()->error_code); data->m_dbh->query_stmt = nullptr; @@ -1380,7 +1380,7 @@ static Variant HHVM_METHOD(PDO, query, const String& sql, if (data->m_dbh->conn()->preparer(sql, &pdostmt->m_stmt, Array())) { auto stmt = pdostmt->m_stmt; - assert(stmt); + assertx(stmt); /* unconditionally keep this for later reference */ stmt->query_string = sql; @@ -1432,7 +1432,7 @@ static Variant HHVM_METHOD(PDO, quote, const String& str, int64_t paramtype /* = PDO_PARAM_STR */) { auto data = Native::data(this_); - assert(data->m_dbh->conn()->driver); + assertx(data->m_dbh->conn()->driver); setPDOErrorNone(data->m_dbh->conn()->error_code); data->m_dbh->query_stmt = nullptr; @@ -1873,7 +1873,7 @@ static bool do_fetch(sp_PDOStatement stmt, break; default: - assert(false); + assertx(false); return false; } diff --git a/hphp/runtime/ext/pdo/pdo_driver.h b/hphp/runtime/ext/pdo/pdo_driver.h index 9fb96883298..39b0c0af728 100644 --- a/hphp/runtime/ext/pdo/pdo_driver.h +++ b/hphp/runtime/ext/pdo/pdo_driver.h @@ -444,7 +444,7 @@ protected: */ struct PDOResource : SweepableResourceData { explicit PDOResource(sp_PDOConnection conn) : m_conn(conn) { - assert(m_conn); + assertx(m_conn); } virtual ~PDOResource() {} diff --git a/hphp/runtime/ext/pdo_mysql/pdo_mysql.cpp b/hphp/runtime/ext/pdo_mysql/pdo_mysql.cpp index 139b1ffbd5b..2220546df97 100644 --- a/hphp/runtime/ext/pdo_mysql/pdo_mysql.cpp +++ b/hphp/runtime/ext/pdo_mysql/pdo_mysql.cpp @@ -957,7 +957,7 @@ bool PDOMySqlStatement::support(SupportedMethod method) { } int PDOMySqlStatement::handleError(const char *file, int line) { - assert(m_conn); + assertx(m_conn); return m_conn->handleError(file, line, this); } diff --git a/hphp/runtime/ext/pdo_sqlite/pdo_sqlite.cpp b/hphp/runtime/ext/pdo_sqlite/pdo_sqlite.cpp index afd6a0b8f47..992a364886d 100644 --- a/hphp/runtime/ext/pdo_sqlite/pdo_sqlite.cpp +++ b/hphp/runtime/ext/pdo_sqlite/pdo_sqlite.cpp @@ -359,9 +359,9 @@ bool PDOSqliteStatement::support(SupportedMethod method) { int PDOSqliteStatement::handleError(const char *file, int line) { auto rsrc = unsafe_cast(dbh); - assert(rsrc); + assertx(rsrc); auto conn = rsrc->conn(); - assert(conn); + assertx(conn); return conn->handleError(file, line, this); } diff --git a/hphp/runtime/ext/pgsql/pgsql.cpp b/hphp/runtime/ext/pgsql/pgsql.cpp index e6c3a012761..9d6b59bf8f0 100644 --- a/hphp/runtime/ext/pgsql/pgsql.cpp +++ b/hphp/runtime/ext/pgsql/pgsql.cpp @@ -363,7 +363,7 @@ bool PGSQLResult::convertFieldRow(const Variant& row, const Variant& field, Variant actual_field; int actual_row; - assert(out_row && out_field && "Output parameters cannot be null"); + assertx(out_row && out_field && "Output parameters cannot be null"); if (!fn_name) { fn_name = "__internal_pgsql_func"; diff --git a/hphp/runtime/ext/phar/ext_phar.cpp b/hphp/runtime/ext/phar/ext_phar.cpp index f91daa92651..2a131a9ea72 100644 --- a/hphp/runtime/ext/phar/ext_phar.cpp +++ b/hphp/runtime/ext/phar/ext_phar.cpp @@ -62,7 +62,7 @@ static struct PharStreamWrapper final : Stream::Wrapper { int access(const String& path, int /*mode*/) override { Variant ret = callStat(path); if (ret.isBoolean()) { - assert(!ret.toBoolean()); + assertx(!ret.toBoolean()); return -1; } return 0; @@ -71,7 +71,7 @@ static struct PharStreamWrapper final : Stream::Wrapper { int stat(const String& path, struct stat* buf) override { Variant ret = callStat(path); if (ret.isBoolean()) { - assert(!ret.toBoolean()); + assertx(!ret.toBoolean()); return -1; } const Array& stat = ret.toArray(); diff --git a/hphp/runtime/ext/posix/ext_posix.cpp b/hphp/runtime/ext/posix/ext_posix.cpp index d0f8040217e..b890ad7320c 100644 --- a/hphp/runtime/ext/posix/ext_posix.cpp +++ b/hphp/runtime/ext/posix/ext_posix.cpp @@ -189,7 +189,7 @@ const StaticString static Variant php_posix_group_to_array(int gid, const String& gname = uninit_variant.toString()) { // Don't pass a gid *and* a gname to this. - assert((gid < 0) || gname.size() == 0); + assertx((gid < 0) || gname.size() == 0); if ((gid < 0) && (gname.size() == 0)) { return false; @@ -207,7 +207,7 @@ static Variant php_posix_group_to_array(int gid, // If we somehow reach this point and both gname and gid were // passed, then the gid values will override the gname values, // but it will otherwise function just fine. - // The assert() clause above should prevent that, however. + // The assertx() clause above should prevent that, however. if ((gname.size() > 0) && (getgrnam_r(gname.data(), &gr, grbuf.get(), grbuflen, &retgrptr) != 0 || retgrptr == nullptr)) { @@ -289,7 +289,7 @@ int64_t HHVM_FUNCTION(posix_getppid) { static Variant php_posix_passwd_to_array(int uid, const String& name = uninit_variant.toString()) { // Don't pass a uid *and* a name to this. - assert((uid < 0) || name.size() == 0); + assertx((uid < 0) || name.size() == 0); if ((uid < 0) && name.size() == 0) { return false; @@ -307,7 +307,7 @@ static Variant php_posix_passwd_to_array(int uid, // If we somehow reach this point and both name and uid were // passed, then the uid values will override the name values, // but it will otherwise function just fine. - // The assert() clauses above should prevent that, however. + // The assertx() clauses above should prevent that, however. if ((name.size() > 0) && getpwnam_r(name.data(), &pw, pwbuf.get(), pwbuflen, &retpwptr)) { return false; diff --git a/hphp/runtime/ext/reflection/ext_reflection.cpp b/hphp/runtime/ext/reflection/ext_reflection.cpp index 0c0f3e920df..7ad65c8ad98 100644 --- a/hphp/runtime/ext/reflection/ext_reflection.cpp +++ b/hphp/runtime/ext/reflection/ext_reflection.cpp @@ -133,13 +133,13 @@ const Func* get_method_func(const Class* cls, const String& meth_name) { } } } - assert(func == nullptr || func->isMethod()); + assertx(func == nullptr || func->isMethod()); return func; } Variant default_arg_from_php_code(const Func::ParamInfo& fpi, const Func* func, unsigned argIdx) { - assert(fpi.hasDefaultValue()); + assertx(fpi.hasDefaultValue()); if (fpi.hasScalarDefaultValue()) { // Most of the time the default value is scalar, so we can // avoid evaling in the common case @@ -226,7 +226,7 @@ static void set_attrs(Array& ret, int modifiers) { ret.set(s_access, VarNR(s_private).tv()); ret.set(s_accessible, false_varNR.tv()); } else { - assert(false); + assertx(false); } ret.set(s_modifiers, make_tv(modifiers)); if (modifiers & 0x1) { @@ -1034,7 +1034,7 @@ static bool HHVM_METHOD(ReflectionMethod, __init, // caller raises exception return false; } - assert(func->isMethod()); + assertx(func->isMethod()); ReflectionFuncHandle::Get(this_)->setFunc(func); return true; } @@ -1121,15 +1121,15 @@ static bool HHVM_METHOD(ReflectionFunction, __initName, const String& name) { static bool HHVM_METHOD(ReflectionFunction, __initClosure, const Object& closure) { auto const cls = get_cls(closure); - assert(cls); + assertx(cls); if (!cls) { return false; } const Func* func = cls->lookupMethod(s___invoke.get()); if (!func) { // caller raises exception return false; } - assert(func->isClosureBody()); - assert(func->implCls()->isScopedClosure()); + assertx(func->isClosureBody()); + assertx(func->implCls()->isScopedClosure()); ReflectionFuncHandle::Get(this_)->setFunc(func); return true; } @@ -1172,7 +1172,7 @@ static Array HHVM_METHOD(ReflectionFunction, getClosureUseVariables, // with a mangled name. if (prop.name->data()[0] == '8') { static const char prefix[] = "86static_"; - assert(0 == strncmp(prop.name->data(), prefix, sizeof prefix - 1)); + assertx(0 == strncmp(prop.name->data(), prefix, sizeof prefix - 1)); String strippedName(prop.name->data() + sizeof prefix - 1, prop.name->size() - sizeof prefix + 1, CopyString); @@ -1494,7 +1494,7 @@ static void addClassConstantNames(const Class* cls, const req::ptr& st, size_t limit) { - assert(cls && st && (st->size() < limit)); + assertx(cls && st && (st->size() < limit)); auto numConsts = cls->numConstants(); @@ -1529,13 +1529,13 @@ static Array HHVM_METHOD(ReflectionClass, getOrderedConstants) { st->reserve(numConsts); addClassConstantNames(cls, st, numConsts); - assert(st->size() <= numConsts); + assertx(st->size() <= numConsts); ArrayInit ai(numConsts, ArrayInit::Mixed{}); for (ArrayIter iter(st.get()); iter; ++iter) { auto constName = iter.first().getStringData(); Cell value = cls->clsCnsGet(constName); - assert(value.m_type != KindOfUninit); + assertx(value.m_type != KindOfUninit); ai.add(constName, cellAsCVarRef(value)); } return ai.toArray(); @@ -1560,7 +1560,7 @@ static Array HHVM_METHOD(ReflectionClass, getOrderedAbstractConstants) { } } - assert(st->size() <= numConsts); + assertx(st->size() <= numConsts); return st->toArray(); } @@ -1585,7 +1585,7 @@ static Array HHVM_METHOD(ReflectionClass, getOrderedTypeConstants) { } } - assert(st->size() <= numConsts); + assertx(st->size() <= numConsts); return st->toArray(); } @@ -1692,7 +1692,7 @@ static Array HHVM_METHOD(ReflectionClass, getDynamicPropertyInfos, const Object& obj) { auto const cls = ReflectionClassHandle::GetClassFor(this_); auto obj_data = obj.get(); - assert(obj_data->getVMClass() == cls); + assertx(obj_data->getVMClass() == cls); if (!obj_data->hasDynProps()) { return empty_array(); } @@ -1813,9 +1813,9 @@ static String HHVM_METHOD(ReflectionTypeConstant, getAssignedTypeHint) { // the original assigned type text auto const preCls = cls->preClass(); auto typeCns = preCls->lookupConstant(cns->name); - assert(typeCns->isType()); - assert(!typeCns->isAbstract()); - assert(isArrayLikeType(typeCns->val().m_type)); + assertx(typeCns->isType()); + assertx(!typeCns->isAbstract()); + assertx(isArrayLikeType(typeCns->val().m_type)); return TypeStructure::toString(Array::attach(typeCns->val().m_data.parr)); } @@ -1889,7 +1889,7 @@ static void HHVM_METHOD(ReflectionProperty, __construct, // is there a dynamic property? if (cls_or_obj.is(KindOfObject)) { auto obj = cls_or_obj.toCObjRef().get(); - assert(cls == obj->getVMClass()); + assertx(cls == obj->getVMClass()); if (obj->hasDynProps() && obj->dynPropArray().exists(prop_name)) { data->setDynamicProp(); this_->setProp(nullptr, s_class.get(), @@ -2053,7 +2053,7 @@ static TypedValue HHVM_METHOD(ReflectionProperty, getDefaultValue) { // look it up by name. auto lookup = prop->cls->getDeclPropIndex(prop->cls, prop->name); auto propIdx = lookup.prop; - assert(propIdx != kInvalidSlot); + assertx(propIdx != kInvalidSlot); prop->cls->initialize(); auto const& propInitVec = prop->cls->getPropData() ? *prop->cls->getPropData() @@ -2092,7 +2092,7 @@ static String HHVM_METHOD(ReflectionTypeAlias, __init, const String& name) { static Array HHVM_METHOD(ReflectionTypeAlias, getTypeStructure) { auto const req = ReflectionTypeAliasHandle::GetTypeAliasReqFor(this_); - assert(req); + assertx(req); auto const typeStructure = req->typeStructure; assertx(!typeStructure.empty()); assertx(typeStructure.isDictOrDArray()); @@ -2101,7 +2101,7 @@ static Array HHVM_METHOD(ReflectionTypeAlias, getTypeStructure) { static String HHVM_METHOD(ReflectionTypeAlias, getAssignedTypeText) { auto const req = ReflectionTypeAliasHandle::GetTypeAliasReqFor(this_); - assert(req); + assertx(req); auto const typeStructure = req->typeStructure; assertx(!typeStructure.empty()); assertx(typeStructure.isDictOrDArray()); @@ -2110,7 +2110,7 @@ static String HHVM_METHOD(ReflectionTypeAlias, getAssignedTypeText) { static Array HHVM_METHOD(ReflectionTypeAlias, getAttributes) { auto const req = ReflectionTypeAliasHandle::GetTypeAliasReqFor(this_); - assert(req); + assertx(req); auto const userAttrs = req->userAttrs; ArrayInit ai(userAttrs.size(), ArrayInit::Mixed{}); @@ -2122,7 +2122,7 @@ static Array HHVM_METHOD(ReflectionTypeAlias, getAttributes) { static String HHVM_METHOD(ReflectionTypeAlias, getFileName) { auto const req = ReflectionTypeAliasHandle::GetTypeAliasReqFor(this_); - assert(req); + assertx(req); auto file = req->unit->filepath()->data(); if (!file) { file = ""; } if (file[0] != '/') { @@ -2549,7 +2549,7 @@ Array get_class_info(const String& name) { // get_class_constants(), so mimic that behavior if (consts[i].cls == cls) { Cell value = cls->clsCnsGet(consts[i].name); - assert(value.m_type != KindOfUninit); + assertx(value.m_type != KindOfUninit); arr.set(StrNR(consts[i].name), cellAsCVarRef(value)); } } diff --git a/hphp/runtime/ext/reflection/ext_reflection.h b/hphp/runtime/ext/reflection/ext_reflection.h index b9f1ebec0f2..e498578e181 100644 --- a/hphp/runtime/ext/reflection/ext_reflection.h +++ b/hphp/runtime/ext/reflection/ext_reflection.h @@ -70,8 +70,8 @@ struct ReflectionFuncHandle { const Func* getFunc() { return m_func; } void setFunc(const Func* func) { - assert(func != nullptr); - assert(m_func == nullptr); + assertx(func != nullptr); + assertx(m_func == nullptr); m_func = func; } @@ -107,8 +107,8 @@ struct ReflectionClassHandle { const Class* getClass() const { return m_cls; } void setClass(const Class* cls) { - assert(cls != nullptr); - assert(m_cls == nullptr); + assertx(cls != nullptr); + assertx(m_cls == nullptr); m_cls = cls; } @@ -146,14 +146,14 @@ struct ReflectionConstHandle { const Class* getClass() const { return m_cls; } void setConst(const Class::Const* cns) { - assert(cns != nullptr); - assert(m_const == nullptr); + assertx(cns != nullptr); + assertx(m_const == nullptr); m_const = cns; } void setClass(const Class* cls) { - assert(cls != nullptr); - assert(m_cls == nullptr); + assertx(cls != nullptr); + assertx(m_cls == nullptr); m_cls = cls; } @@ -178,21 +178,21 @@ struct ReflectionPropHandle { Type getType() const { return m_type; } const Class::Prop* getProp() const { - assert(m_type == Instance); + assertx(m_type == Instance); return m_prop; } const Class::SProp* getSProp() const { - assert(m_type == Static); + assertx(m_type == Static); return m_sprop; } void setInstanceProp(const Class::Prop* prop) { - assert(prop != nullptr); + assertx(prop != nullptr); m_type = Instance; m_prop = prop; } void setStaticProp(const Class::SProp* sprop) { - assert(sprop != nullptr); + assertx(sprop != nullptr); m_type = Static; m_sprop = sprop; } @@ -225,8 +225,8 @@ struct ReflectionTypeAliasHandle { const TypeAliasReq* getTypeAliasReq() const { return m_req; } void setTypeAliasReq(const TypeAliasReq* req) { - assert(req != nullptr); - assert(m_req == nullptr); + assertx(req != nullptr); + assertx(m_req == nullptr); m_req = req; } diff --git a/hphp/runtime/ext/session/ext_session.cpp b/hphp/runtime/ext/session/ext_session.cpp index 44921c0f556..65d8a81f755 100644 --- a/hphp/runtime/ext/session/ext_session.cpp +++ b/hphp/runtime/ext/session/ext_session.cpp @@ -1688,7 +1688,7 @@ static bool HHVM_FUNCTION(session_start) { /* fallthrough */ } default: - assert(s_session->session_status == Session::None); + assertx(s_session->session_status == Session::None); s_session->define_sid = true; s_session->send_cookie = true; } @@ -1882,10 +1882,10 @@ static struct SessionExtension final : Extension { } void threadInit() override { - assert(s_session.isNull()); + assertx(s_session.isNull()); s_session.getCheck(); Extension* ext = ExtensionRegistry::get(s_session_ext_name); - assert(ext); + assertx(ext); IniSetting::Bind(ext, IniSetting::PHP_INI_ALL, "session.save_path", "", IniSetting::SetAndGet( diff --git a/hphp/runtime/ext/shmop/ext_shmop.cpp b/hphp/runtime/ext/shmop/ext_shmop.cpp index 0fc08aef99c..c51fdd7732b 100644 --- a/hphp/runtime/ext/shmop/ext_shmop.cpp +++ b/hphp/runtime/ext/shmop/ext_shmop.cpp @@ -186,7 +186,7 @@ struct ShmopRequestLocal final : RequestEventHandler { // still valid when we use it but this way it's unique per process (although // it may get reused). int64_t shmid = reinterpret_cast(p.get()); - assert(LIKELY(m_records.find(shmid) == m_records.end())); + assertx(LIKELY(m_records.find(shmid) == m_records.end())); m_records.emplace(shmid, std::move(p)); return shmid; } diff --git a/hphp/runtime/ext/simplexml/ext_simplexml.cpp b/hphp/runtime/ext/simplexml/ext_simplexml.cpp index 417538403d4..7a6c1ad1342 100644 --- a/hphp/runtime/ext/simplexml/ext_simplexml.cpp +++ b/hphp/runtime/ext/simplexml/ext_simplexml.cpp @@ -63,7 +63,7 @@ const Class* SimpleXMLIterator_classof() { struct SimpleXMLElement { SimpleXMLElement() { - assert(Native::object(this)->getVMClass()-> + assertx(Native::object(this)->getVMClass()-> rtAttribute(Class::CallToImpl)); } SimpleXMLElement& operator=(const SimpleXMLElement &src) { @@ -118,12 +118,12 @@ struct SimpleXMLElement { struct SimpleXMLElementIterator { SimpleXMLElement* sxe() { - assert(m_sxe->instanceof(SimpleXMLElement_classof())); + assertx(m_sxe->instanceof(SimpleXMLElement_classof())); return Native::data(m_sxe.get()); } void setSxe(const Object& sxe) { - assert(sxe->instanceof(SimpleXMLElement_classof())); + assertx(sxe->instanceof(SimpleXMLElement_classof())); m_sxe = Object(sxe.get()); } @@ -306,7 +306,7 @@ static void php_sxe_move_forward_iterator(SimpleXMLElement* sxe) { xmlNodePtr node = nullptr; auto data = sxe->iter.data; if (!data.isNull()) { - assert(data->instanceof(SimpleXMLElement_classof())); + assertx(data->instanceof(SimpleXMLElement_classof())); auto intern = Native::data(data.get()); node = intern->nodep(); sxe->iter.data.reset(); @@ -360,7 +360,7 @@ static xmlNodePtr php_sxe_get_first_node(SimpleXMLElement* sxe, php_sxe_reset_iterator(sxe, true); xmlNodePtr retnode = nullptr; if (!sxe->iter.data.isNull()) { - assert(sxe->iter.data->instanceof(SimpleXMLElement_classof())); + assertx(sxe->iter.data->instanceof(SimpleXMLElement_classof())); retnode = Native::data(sxe->iter.data.get())->nodep(); } return retnode; @@ -888,7 +888,7 @@ next_iter: } Variant SimpleXMLElement_objectCast(const ObjectData* obj, int8_t type) { - assert(obj->instanceof(SimpleXMLElement_classof())); + assertx(obj->instanceof(SimpleXMLElement_classof())); auto sxe = Native::data(const_cast(obj)); if (type == KindOfBoolean) { xmlNodePtr node = php_sxe_get_first_node(sxe, nullptr); @@ -1781,7 +1781,7 @@ static Variant HHVM_METHOD(SimpleXMLIterator, key) { return init_null(); } - assert(curobj->instanceof(SimpleXMLElement_classof())); + assertx(curobj->instanceof(SimpleXMLElement_classof())); auto curnode = Native::data(curobj.get())->nodep(); return String((char*)curnode->name); } @@ -1809,7 +1809,7 @@ static Variant HHVM_METHOD(SimpleXMLIterator, getChildren) { if (current.isNull()) { return init_null(); } - assert(current->instanceof(SimpleXMLElement_classof())); + assertx(current->instanceof(SimpleXMLElement_classof())); return HHVM_MN(SimpleXMLElement, children)(current.get()); } @@ -1819,7 +1819,7 @@ static bool HHVM_METHOD(SimpleXMLIterator, hasChildren) { return false; } auto od = children.toObject().get(); - assert(od->instanceof(SimpleXMLElement_classof())); + assertx(od->instanceof(SimpleXMLElement_classof())); return HHVM_MN(SimpleXMLElement, count)(od) > 0; } diff --git a/hphp/runtime/ext/soap/ext_soap.cpp b/hphp/runtime/ext/soap/ext_soap.cpp index d5201a32f81..58ea6562215 100644 --- a/hphp/runtime/ext/soap/ext_soap.cpp +++ b/hphp/runtime/ext/soap/ext_soap.cpp @@ -50,7 +50,7 @@ const StaticString s___dorequest("__dorequest"); Class* cls::getClass() { \ if (s_class == nullptr) { \ s_class = Unit::lookupClass(s_className.get()); \ - assert(s_class); \ + assertx(s_class); \ } \ return s_class; \ } \ @@ -391,7 +391,7 @@ static xmlDocPtr serialize_function_call(SoapClient *client, if (head) { for (ArrayIter iter(soap_headers); iter; ++iter) { Object obj_header = iter.second().toObject(); - assert(obj_header.instanceof(SoapHeader::getClass())); + assertx(obj_header.instanceof(SoapHeader::getClass())); SoapHeader *header = Native::data(obj_header); xmlNodePtr h; diff --git a/hphp/runtime/ext/soap/ext_soap.h b/hphp/runtime/ext/soap/ext_soap.h index 17cf55a24a9..199f71fd05d 100644 --- a/hphp/runtime/ext/soap/ext_soap.h +++ b/hphp/runtime/ext/soap/ext_soap.h @@ -110,7 +110,7 @@ struct SoapVar { if (!enc_type.isInitialized()) { raise_error("Encoding: SoapVar has no 'enc_type' property"); not_reached(); - assert(false); + assertx(false); } return enc_type.toInt64(); } diff --git a/hphp/runtime/ext/soap/packet.cpp b/hphp/runtime/ext/soap/packet.cpp index 86e039605cd..d7ff2d69691 100644 --- a/hphp/runtime/ext/soap/packet.cpp +++ b/hphp/runtime/ext/soap/packet.cpp @@ -42,7 +42,7 @@ bool parse_packet_soap(SoapClient* obj, const char* buffer, int buffer_size, int soap_version = SOAP_1_1; sdlSoapBindingFunctionHeaderMap *hdrs = nullptr; - assert(return_value.asTypedValue()->m_type == KindOfUninit); + assertx(return_value.asTypedValue()->m_type == KindOfUninit); return_value.asTypedValue()->m_type = KindOfNull; /* Response for one-way opearation */ diff --git a/hphp/runtime/ext/sockets/ext_sockets.cpp b/hphp/runtime/ext/sockets/ext_sockets.cpp index 890fe535e67..bca08eb7695 100644 --- a/hphp/runtime/ext/sockets/ext_sockets.cpp +++ b/hphp/runtime/ext/sockets/ext_sockets.cpp @@ -281,7 +281,7 @@ static bool set_sockaddr(sockaddr_storage &sa_storage, req::ptr sock, static void sock_array_to_fd_set(const Array& sockets, pollfd *fds, int &nfds, short flag) { - assert(fds); + assertx(fds); for (ArrayIter iter(sockets); iter; ++iter) { auto sock = cast(iter.second()); int intfd = sock->fd(); @@ -300,12 +300,12 @@ static void sock_array_to_fd_set(const Array& sockets, pollfd *fds, int &nfds, static void sock_array_from_fd_set(Variant &sockets, pollfd *fds, int &nfds, int &count, short flag) { - assert(sockets.isArray()); + assertx(sockets.isArray()); Array sock_array = sockets.toArray(); Array ret = Array::Create(); for (ArrayIter iter(sock_array); iter; ++iter) { const pollfd &fd = fds[nfds++]; - assert(fd.fd == cast(iter.second())->fd()); + assertx(fd.fd == cast(iter.second())->fd()); if (fd.revents & flag) { ret.set(iter.first(), iter.second()); count++; @@ -1504,9 +1504,9 @@ Variant sockopen_impl(const HostURL &hosturl, VRefParam errnum, } if (persistent) { - assert(!key.empty()); + assertx(!key.empty()); s_sockets[key] = cast(socket)->getData(); - assert(s_sockets[key]); + assertx(s_sockets[key]); } return socket; diff --git a/hphp/runtime/ext/sqlite3/ext_sqlite3.cpp b/hphp/runtime/ext/sqlite3/ext_sqlite3.cpp index 2418527fc24..d08134fc80b 100644 --- a/hphp/runtime/ext/sqlite3/ext_sqlite3.cpp +++ b/hphp/runtime/ext/sqlite3/ext_sqlite3.cpp @@ -39,7 +39,7 @@ namespace HPHP { Class *cls::getClass() { \ if (s_class == nullptr) { \ s_class = Unit::lookupClass(s_className.get()); \ - assert(s_class); \ + assertx(s_class); \ } \ return s_class; \ } \ @@ -53,7 +53,7 @@ struct php_sqlite3_agg_context { }; static Variant get_column_value(sqlite3_stmt *stmt, int column) { - assert(stmt); + assertx(stmt); Variant data; switch (sqlite3_column_type(stmt, column)) { case SQLITE_INTEGER: @@ -374,7 +374,7 @@ Variant HHVM_METHOD(SQLite3, query, Variant stmt = HHVM_MN(SQLite3, prepare)(this_, sql); if (!same(stmt, false)) { Object obj_stmt = stmt.toObject(); - assert(obj_stmt.instanceof(SQLite3Stmt::getClass())); + assertx(obj_stmt.instanceof(SQLite3Stmt::getClass())); return HHVM_MN(SQLite3Stmt, execute)(obj_stmt.get()); } } @@ -391,7 +391,7 @@ Variant HHVM_METHOD(SQLite3, querysingle, Variant stmt = HHVM_MN(SQLite3, prepare)(this_, sql); if (!same(stmt, false)) { Object obj_stmt = stmt.toObject(); - assert(obj_stmt.instanceof(SQLite3Stmt::getClass())); + assertx(obj_stmt.instanceof(SQLite3Stmt::getClass())); sqlite3_stmt *pstmt = Native::data(obj_stmt)->m_raw_stmt; switch (sqlite3_step(pstmt)) { @@ -509,7 +509,7 @@ void HHVM_METHOD(SQLite3Stmt, __construct, const String& statement) { auto *data = Native::data(this_); if (!statement.empty()) { - assert(dbobject.instanceof(SQLite3::getClass())); + assertx(dbobject.instanceof(SQLite3::getClass())); const SQLite3 *db = Native::data(dbobject); db->validate(); data->m_db = dbobject; diff --git a/hphp/runtime/ext/std/ext_std_classobj.cpp b/hphp/runtime/ext/std/ext_std_classobj.cpp index b9a3b87d6b2..896b3f5d857 100644 --- a/hphp/runtime/ext/std/ext_std_classobj.cpp +++ b/hphp/runtime/ext/std/ext_std_classobj.cpp @@ -128,7 +128,7 @@ Array HHVM_FUNCTION(get_class_constants, const String& className) { if (value.m_type == KindOfUninit) { value = cls->clsCnsGet(consts[i].name); } - assert(value.m_type != KindOfUninit); + assertx(value.m_type != KindOfUninit); arrayInit.set(name, cellAsCVarRef(value)); } } @@ -157,8 +157,8 @@ Variant HHVM_FUNCTION(get_class_vars, const String& className) { ? cls->getPropData() : &declPropInitVec; - assert(propVals != nullptr); - assert(propVals->size() == numDeclProps); + assertx(propVals != nullptr); + assertx(propVals->size() == numDeclProps); // For visibility checks auto ctx = arGetContextClass(GetCallerFrame()); @@ -168,7 +168,7 @@ Variant HHVM_FUNCTION(get_class_vars, const String& className) { for (size_t i = 0; i < numDeclProps; ++i) { auto const name = const_cast(propInfo[i].name.get()); // Empty names are used for invisible/private parent properties; skip them. - assert(name->size() != 0); + assertx(name->size() != 0); if (Class::IsPropAccessible(propInfo[i], ctx)) { auto const value = &((*propVals)[i]); arr.set(name, tvAsCVarRef(value)); @@ -294,7 +294,7 @@ Variant HHVM_FUNCTION(property_exists, const Variant& class_or_object, if (class_or_object.isObject()) { obj = class_or_object.getObjectData(); cls = obj->getVMClass(); - assert(cls); + assertx(cls); } else if (class_or_object.isString()) { cls = Unit::loadClass(class_or_object.toString().get()); if (!cls) return false; diff --git a/hphp/runtime/ext/std/ext_std_closure.cpp b/hphp/runtime/ext/std/ext_std_closure.cpp index 48c8eace6e7..7750402bdd2 100644 --- a/hphp/runtime/ext/std/ext_std_closure.cpp +++ b/hphp/runtime/ext/std/ext_std_closure.cpp @@ -235,7 +235,7 @@ static Variant HHVM_METHOD(Closure, bindto, // If we are changing either the scope or the attributes of the closure, we // need to re-scope its Closure subclass. if (newscope != curscope || newattrs != curattrs) { - assert(newattrs != AttrNone); + assertx(newattrs != AttrNone); auto newcls = cls->rescope(newscope, newattrs); cloneObj->setVMClass(newcls); diff --git a/hphp/runtime/ext/std/ext_std_file.cpp b/hphp/runtime/ext/std/ext_std_file.cpp index f1a473100eb..36273d82b2a 100644 --- a/hphp/runtime/ext/std/ext_std_file.cpp +++ b/hphp/runtime/ext/std/ext_std_file.cpp @@ -1962,7 +1962,7 @@ bool HHVM_FUNCTION(chroot, struct DirectoryData final : RequestEventHandler { void requestInit() override { - assert(!defaultDirectory); + assertx(!defaultDirectory); } void requestShutdown() override { defaultDirectory = nullptr; diff --git a/hphp/runtime/ext/std/ext_std_misc.cpp b/hphp/runtime/ext/std/ext_std_misc.cpp index 4f30fb75d2b..bae2025785d 100644 --- a/hphp/runtime/ext/std/ext_std_misc.cpp +++ b/hphp/runtime/ext/std/ext_std_misc.cpp @@ -804,7 +804,7 @@ const int MaxUserTokenId = 451; // Marker, not a real user token ID // Converts an internal token ID to a user token ID static int get_user_token_id(int internal_id) { - assert(internal_id >= 0); + assertx(internal_id >= 0); if (internal_id < 256) { return internal_id; } @@ -840,10 +840,10 @@ static String token_get_all_fix_elseif(Array& res, return true; }; - assert(tokText.size() > strlen("elseif")); - assert(!strncasecmp(tokCStr, "else", strlen("else"))); - assert(checkWhitespace(tokCStr + strlen("else"), tokCEnd - strlen("if"))); - assert(!strcasecmp(tokCEnd - strlen("if"), "if")); + assertx(tokText.size() > strlen("elseif")); + assertx(!strncasecmp(tokCStr, "else", strlen("else"))); + assertx(checkWhitespace(tokCStr + strlen("else"), tokCEnd - strlen("if"))); + assertx(!strcasecmp(tokCEnd - strlen("if"), "if")); // Shove in the T_ELSE and T_WHITESPACE, then return the remaining T_IF res.append(make_packed_array( diff --git a/hphp/runtime/ext/std/ext_std_options.cpp b/hphp/runtime/ext/std/ext_std_options.cpp index a0d070d0f66..641047a203d 100644 --- a/hphp/runtime/ext/std/ext_std_options.cpp +++ b/hphp/runtime/ext/std/ext_std_options.cpp @@ -155,7 +155,7 @@ static Variant eval_for_assert(ActRec* const curFP, const String& codeStr) { auto const unit = g_context->compileEvalString(prefixedCode.get()); if (unit == nullptr) { - raise_recoverable_error("Syntax error in assert()"); + raise_recoverable_error("Syntax error in assertx()"); // Failure to compile the eval string doesn't count as an // assertion failure. return Variant(true); @@ -550,7 +550,7 @@ static int php_getopt(int argc, req::vector& argv, } return opts[php_optidx].opt_char; } - assert(false); + assertx(false); return(0); /* never reached */ } @@ -590,7 +590,7 @@ static req::vector parse_opts(const char *opts, int opts_len) { } ++i; } - assert(i == count); + assertx(i == count); return paras; } @@ -624,7 +624,7 @@ static Array HHVM_FUNCTION(getopt, const String& options, opt.opt_char = 0; ++i; } - assert(i == opt_vec.size() - 1); + assertx(i == opt_vec.size() - 1); } else { opt_vec.resize(opt_vec.size() + 1); } @@ -875,7 +875,7 @@ Variant HHVM_FUNCTION(ini_set, static int64_t HHVM_FUNCTION(memory_get_allocation) { auto total = tl_heap->getStatsCopy().totalAlloc; - assert(total >= 0); + assertx(total >= 0); return total; } @@ -884,7 +884,7 @@ static int64_t HHVM_FUNCTION(hphp_memory_get_interval_peak_usage, auto const stats = tl_heap->getStatsCopy(); int64_t ret = real_usage ? stats.peakIntervalUsage : stats.peakIntervalCap; - assert(ret >= 0); + assertx(ret >= 0); return ret; } @@ -892,7 +892,7 @@ static int64_t HHVM_FUNCTION(memory_get_peak_usage, bool real_usage /*=false */) { auto const stats = tl_heap->getStatsCopy(); int64_t ret = real_usage ? stats.peakUsage : stats.peakCap; - assert(ret >= 0); + assertx(ret >= 0); return ret; } @@ -902,7 +902,7 @@ static int64_t HHVM_FUNCTION(memory_get_usage, bool real_usage /*=false */) { // Since we don't always alloc and dealloc a shared structure from the same // thread it is possible that this can go negative when we are tracking // jemalloc stats. - assert((use_jemalloc && real_usage) || ret >= 0); + assertx((use_jemalloc && real_usage) || ret >= 0); return std::max(ret, 0); } diff --git a/hphp/runtime/ext/std/ext_std_process.cpp b/hphp/runtime/ext/std/ext_std_process.cpp index 276620f30b4..ed6b6ce3be4 100644 --- a/hphp/runtime/ext/std/ext_std_process.cpp +++ b/hphp/runtime/ext/std/ext_std_process.cpp @@ -213,7 +213,7 @@ struct ShellExecContext final { } FILE *exec(const String& cmd_string) { - assert(m_proc == nullptr); + assertx(m_proc == nullptr); const auto cmd = cmd_string.c_str(); if (RuntimeOption::WhitelistExec && !check_cmd(cmd)) { return nullptr; @@ -934,7 +934,7 @@ HHVM_FUNCTION(proc_open, const String& cmd, const Array& descriptorspec, child = LightProcess::proc_open(cmd.c_str(), created, intended, scwd.c_str(), envs); - assert(child); + assertx(child); return post_proc_open(cmd, pipes, enva, items, child); } @@ -954,7 +954,7 @@ HHVM_FUNCTION(proc_open, const String& cmd, const Array& descriptorspec, } } - assert(child == 0); + assertx(child == 0); /* this is the child process */ /* close those descriptors that we just opened for the parent stuff, diff --git a/hphp/runtime/ext/std/ext_std_variable.cpp b/hphp/runtime/ext/std/ext_std_variable.cpp index 4a56932efb9..c6081c8655a 100644 --- a/hphp/runtime/ext/std/ext_std_variable.cpp +++ b/hphp/runtime/ext/std/ext_std_variable.cpp @@ -297,7 +297,7 @@ ALWAYS_INLINE String serialize_impl(const Variant& value, bool keepDVArrays) { case KindOfPersistentVec: case KindOfVec: { ArrayData* arr = value.getArrayData(); - assert(arr->isVecArray()); + assertx(arr->isVecArray()); if (arr->empty()) return s_EmptyVecArray; break; } @@ -305,7 +305,7 @@ ALWAYS_INLINE String serialize_impl(const Variant& value, bool keepDVArrays) { case KindOfPersistentDict: case KindOfDict: { ArrayData* arr = value.getArrayData(); - assert(arr->isDict()); + assertx(arr->isDict()); if (arr->empty()) return s_EmptyDictArray; break; } @@ -313,7 +313,7 @@ ALWAYS_INLINE String serialize_impl(const Variant& value, bool keepDVArrays) { case KindOfPersistentKeyset: case KindOfKeyset: { ArrayData* arr = value.getArrayData(); - assert(arr->isKeyset()); + assertx(arr->isKeyset()); if (arr->empty()) return s_EmptyKeysetArray; break; } @@ -321,8 +321,8 @@ ALWAYS_INLINE String serialize_impl(const Variant& value, bool keepDVArrays) { case KindOfPersistentArray: case KindOfArray: { ArrayData *arr = value.getArrayData(); - assert(arr->isPHPArray()); - assert(!RuntimeOption::EvalHackArrDVArrs || arr->isNotDVArray()); + assertx(arr->isPHPArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs || arr->isNotDVArray()); if (arr->empty()) { if (keepDVArrays) { if (arr->isVArray()) return s_EmptyVArray; diff --git a/hphp/runtime/ext/stream/ext_stream.cpp b/hphp/runtime/ext/stream/ext_stream.cpp index cddfab903e3..ac39d63ced2 100644 --- a/hphp/runtime/ext/stream/ext_stream.cpp +++ b/hphp/runtime/ext/stream/ext_stream.cpp @@ -940,7 +940,7 @@ void StreamContext::mergeOptions(const Array& options) { if (!m_options.exists(wrapper)) { m_options.set(wrapper, Array::Create()); } - assert(m_options[wrapper].isArray()); + assertx(m_options[wrapper].isArray()); Array& opts = asArrRef(m_options.lvalAt(wrapper)); Array new_opts = it.second().toArray(); for (ArrayIter it2(new_opts); it2; ++it2) { @@ -958,7 +958,7 @@ void StreamContext::setOption(const String& wrapper, if (!m_options.exists(wrapper)) { m_options.set(wrapper, Array::Create()); } - assert(m_options[wrapper].isArray()); + assertx(m_options[wrapper].isArray()); Array& opts = asArrRef(m_options.lvalAt(wrapper)); opts.set(option, value); } @@ -999,7 +999,7 @@ void StreamContext::mergeParams(const Array& params) { } const String& options_key = String::FromCStr("options"); if (params.exists(options_key)) { - assert(params[options_key].isArray()); + assertx(params[options_key].isArray()); mergeOptions(params[options_key].toArray()); } } diff --git a/hphp/runtime/ext/string/ext_string.cpp b/hphp/runtime/ext/string/ext_string.cpp index 060868d1829..916940fbdd7 100644 --- a/hphp/runtime/ext/string/ext_string.cpp +++ b/hphp/runtime/ext/string/ext_string.cpp @@ -1127,7 +1127,7 @@ TypedValue HHVM_FUNCTION(strstr, bool before_needle /* = false */) { auto const tv = HHVM_FN(strpos)(haystack, needle); auto const& ret = tvAsCVarRef(&tv); - assert(!isRefcountedType(tv.m_type)); + assertx(!isRefcountedType(tv.m_type)); if (same(ret, false)) { return make_tv(false); @@ -1145,7 +1145,7 @@ TypedValue HHVM_FUNCTION(stristr, bool before_needle /* = false */) { auto const tv = HHVM_FN(stripos)(haystack, needle); auto const& ret = tvAsCVarRef(&tv); - assert(!isRefcountedType(tv.m_type)); + assertx(!isRefcountedType(tv.m_type)); if (same(ret, false)) { return make_tv(false); @@ -1163,7 +1163,7 @@ Variant strpbrk_char_list_has_nulls_slow(const String& haystack, auto const charListSz = char_list.size(); auto const charListData = char_list.c_str(); - assert(memchr(charListData, '\0', charListSz) != nullptr); + assertx(memchr(charListData, '\0', charListSz) != nullptr); // in order to use strcspn, remove all null byte(s) from char_list auto charListWithoutNull = (char*) req::malloc_noptrs(charListSz); @@ -1174,7 +1174,7 @@ Variant strpbrk_char_list_has_nulls_slow(const String& haystack, for (auto ptr = charListData; ptr != charListStop; ++ptr) { if (*ptr != '\0') { *copy_ptr++ = *ptr; } } - assert((copy_ptr - charListWithoutNull) < charListSz); + assertx((copy_ptr - charListWithoutNull) < charListSz); // at least one of charListData chars was null, so there must be room: *copy_ptr = '\0'; @@ -1937,7 +1937,7 @@ private: }; uint16_t inline PatAndRepl::hash(int start, int len) const { - assert(pat.size() >= start + len); + assertx(pat.size() >= start + len); return strtr_hash(pat.data() + start, len); }; @@ -1982,7 +1982,7 @@ void WuManberReplacement::initTables() { // init shift tab for (int j = 0; j < max_shift; j++) { uint16_t h2 = patterns[i].hash( j, B ) & SHIFT_TAB_MASK; - assert((long long) m - (long long) j - B >= 0); + assertx((long long) m - (long long) j - B >= 0); shift[h2] = MIN(shift[h2], m - j - B); } // init prefix diff --git a/hphp/runtime/ext/thrift/transport.h b/hphp/runtime/ext/thrift/transport.h index 0ad6b0801e0..76cd297bf4a 100644 --- a/hphp/runtime/ext/thrift/transport.h +++ b/hphp/runtime/ext/thrift/transport.h @@ -264,7 +264,7 @@ struct PHPInputTransport { private: void refill(size_t len) { - assert(buffer_used == 0); + assertx(buffer_used == 0); len = std::max(len, SIZE); buffer = m_transport->o_invoke_few_args(s_read, 1, (int64_t)len).toString(); buffer_used = buffer.size(); diff --git a/hphp/runtime/ext/vsdebug/breakpoint.cpp b/hphp/runtime/ext/vsdebug/breakpoint.cpp index 15e9e3e7a34..0473173a4e9 100644 --- a/hphp/runtime/ext/vsdebug/breakpoint.cpp +++ b/hphp/runtime/ext/vsdebug/breakpoint.cpp @@ -110,7 +110,7 @@ int BreakpointManager::addBreakpoint( } // Add this ID to the set of breakpoints in this file. - assert(it != m_sourceBreakpoints.end()); + assertx(it != m_sourceBreakpoints.end()); std::unordered_set& fileBreakpoints = it->second; fileBreakpoints.emplace(id); diff --git a/hphp/runtime/ext/vsdebug/command.cpp b/hphp/runtime/ext/vsdebug/command.cpp index 2c9882f434c..2f7e763592a 100644 --- a/hphp/runtime/ext/vsdebug/command.cpp +++ b/hphp/runtime/ext/vsdebug/command.cpp @@ -125,7 +125,7 @@ bool VSCommand::parseCommand( folly::dynamic& clientMessage, VSCommand** command ) { - assert(command != nullptr && *command == nullptr); + assertx(command != nullptr && *command == nullptr); // Only VS Code debug protocol messages of type "request" are expected from // the client. @@ -225,7 +225,7 @@ bool VSCommand::parseCommand( } bool VSCommand::execute() { - assert(m_debugger != nullptr); + assertx(m_debugger != nullptr); return m_debugger->executeClientCommand( this, [&](DebuggerSession* session, folly::dynamic& responseMsg) { diff --git a/hphp/runtime/ext/vsdebug/command_queue.cpp b/hphp/runtime/ext/vsdebug/command_queue.cpp index 91ea84112c6..44f9625c04a 100644 --- a/hphp/runtime/ext/vsdebug/command_queue.cpp +++ b/hphp/runtime/ext/vsdebug/command_queue.cpp @@ -39,7 +39,7 @@ void CommandQueue::shutdown() { while (m_threadProcessingCount.load() > 0) { m_waiterLeftCondition.wait(lock); } - assert(m_threadProcessingCount.load() == 0); + assertx(m_threadProcessingCount.load() == 0); } // Free any commands remaining in the queue. @@ -48,7 +48,7 @@ void CommandQueue::shutdown() { it = m_commands.erase(it); } - assert(m_commands.empty()); + assertx(m_commands.empty()); } void CommandQueue::processCommands() { @@ -61,7 +61,7 @@ void CommandQueue::processCommands() { m_threadProcessingCount++; SCOPE_EXIT { - assert(lock.owns_lock()); + assertx(lock.owns_lock()); m_threadProcessingCount--; if (m_terminating) { diff --git a/hphp/runtime/ext/vsdebug/completions_command.cpp b/hphp/runtime/ext/vsdebug/completions_command.cpp index e0ead63d87b..e1668690ea9 100644 --- a/hphp/runtime/ext/vsdebug/completions_command.cpp +++ b/hphp/runtime/ext/vsdebug/completions_command.cpp @@ -278,7 +278,7 @@ bool CompletionsCommand::executeImpl( break; default: - assert(false); + assertx(false); } // Sort results, prefer shorter strings, then alphabatize. diff --git a/hphp/runtime/ext/vsdebug/debugger.cpp b/hphp/runtime/ext/vsdebug/debugger.cpp index 98bc76c3a33..fbe93146b23 100644 --- a/hphp/runtime/ext/vsdebug/debugger.cpp +++ b/hphp/runtime/ext/vsdebug/debugger.cpp @@ -31,7 +31,7 @@ Debugger::Debugger() { } void Debugger::setTransport(DebugTransport* transport) { - assert(m_transport == nullptr); + assertx(m_transport == nullptr); m_transport = transport; setClientConnected(m_transport->clientConnected()); } @@ -72,7 +72,7 @@ void Debugger::setClientConnected(bool connected) { if (connected) { // Create a new debugger session. - assert(m_session == nullptr); + assertx(m_session == nullptr); m_session = new DebuggerSession(this); if (m_session == nullptr) { VSDebugLogger::Log( @@ -152,8 +152,8 @@ void Debugger::setClientConnected(bool connected) { ri->m_breakpointInfo = new RequestBreakpointInfo(); if (ri->m_breakpointInfo != nullptr) { - assert(ri->m_breakpointInfo->m_pendingBreakpoints.empty()); - assert(ri->m_breakpointInfo->m_unresolvedBreakpoints.empty()); + assertx(ri->m_breakpointInfo->m_pendingBreakpoints.empty()); + assertx(ri->m_breakpointInfo->m_unresolvedBreakpoints.empty()); } }, true /* includeDummyRequest */ @@ -225,7 +225,7 @@ void Debugger::cleanupRequestInfo(ThreadInfo* ti, RequestInfo* ri) { delete ri->m_breakpointInfo; } - assert(ri->m_serverObjects.size() == 0); + assertx(ri->m_serverObjects.size() == 0); delete ri; } @@ -249,7 +249,7 @@ void Debugger::cleanupServerObjectsForRequest(RequestInfo* ri) { it = objs.erase(it); } - assert(objs.size() == 0); + assertx(objs.size() == 0); } void Debugger::executeForEachAttachedRequest( @@ -259,7 +259,7 @@ void Debugger::executeForEachAttachedRequest( m_lock.assertOwnedBySelf(); for (auto it = m_requests.begin(); it != m_requests.end(); it++) { - assert(it->second != nullptr); + assertx(it->second != nullptr); callback(it->first, it->second); } @@ -272,7 +272,7 @@ void Debugger::executeForEachAttachedRequest( } void Debugger::getAllThreadInfo(folly::dynamic& threads) { - assert(threads.isArray()); + assertx(threads.isArray()); executeForEachAttachedRequest( [&](ThreadInfo* ti, RequestInfo* ri) { threads.push_back(folly::dynamic::object); @@ -305,7 +305,7 @@ void Debugger::shutdown() { setClientConnected(false); // m_session is deleted and set to nullptr by setClientConnected(false). - assert(m_session == nullptr); + assertx(m_session == nullptr); delete m_transport; m_transport = nullptr; @@ -619,7 +619,7 @@ RequestInfo* Debugger::attachToRequest(ThreadInfo* ti) { if (it == m_requests.end()) { // New request. Insert a request info object into our map. threadId = nextThreadId(); - assert(threadId > 0); + assertx(threadId > 0); requestInfo = createRequestInfo(); if (requestInfo == nullptr) { @@ -633,11 +633,11 @@ RequestInfo* Debugger::attachToRequest(ThreadInfo* ti) { } else { requestInfo = it->second; auto idIt = m_requestInfoMap.find(ti); - assert(idIt != m_requestInfoMap.end()); + assertx(idIt != m_requestInfoMap.end()); threadId = idIt->second; } - assert(requestInfo != nullptr && requestInfo->m_breakpointInfo != nullptr); + assertx(requestInfo != nullptr && requestInfo->m_breakpointInfo != nullptr); // Have the debugger hook update the output hook on next interrupt. requestInfo->m_flags.outputHooked = false; @@ -701,11 +701,11 @@ void Debugger::requestShutdown() { m_requests.erase(it); auto infoItr = m_requestInfoMap.find(threadInfo); - assert(infoItr != m_requestInfoMap.end()); + assertx(infoItr != m_requestInfoMap.end()); threadId = infoItr->second; auto idItr = m_requestIdMap.find(threadId); - assert(idItr != m_requestIdMap.end()); + assertx(idItr != m_requestIdMap.end()); m_requestIdMap.erase(idItr); m_requestInfoMap.erase(infoItr); @@ -921,7 +921,7 @@ Debugger::prepareToPauseTarget(RequestInfo* requestInfo) { break; } } else { - assert(m_state == ProgramState::Running && m_pausedRequestCount > 0); + assertx(m_state == ProgramState::Running && m_pausedRequestCount > 0); // The target is running, but at least one thread is still paused. // This means a resume is in progress, drop the lock and wait for @@ -946,7 +946,7 @@ Debugger::prepareToPauseTarget(RequestInfo* requestInfo) { } m_lock.assertOwnedBySelf(); - assert(requestInfo == nullptr || m_state == ProgramState::Running); + assertx(requestInfo == nullptr || m_state == ProgramState::Running); return clientConnected() ? ReadyToPause : ErrorNoClient; } @@ -1002,7 +1002,7 @@ void Debugger::onClientMessage(folly::dynamic& message) { } if (!VSCommand::parseCommand(this, message, &command)) { - assert(command == nullptr); + assertx(command == nullptr); try { auto cmdName = message["command"]; @@ -1021,7 +1021,7 @@ void Debugger::onClientMessage(folly::dynamic& message) { ); } - assert(command != nullptr); + assertx(command != nullptr); enforceRequiresBreak(command); // Otherwise this is a normal command. Dispatch it to its target. @@ -1045,7 +1045,7 @@ void Debugger::onClientMessage(folly::dynamic& message) { auto it = m_requestIdMap.find(threadId); if (it != m_requestIdMap.end()) { const auto request = m_requests.find(it->second); - assert(request != m_requests.end()); + assertx(request != m_requests.end()); ri = request->second; } } @@ -1070,7 +1070,7 @@ void Debugger::onClientMessage(folly::dynamic& message) { command = nullptr; break; default: - assert(false); + assertx(false); } } catch (DebuggerCommandException e) { reportClientMessageError(message, e.what()); @@ -1096,7 +1096,7 @@ void Debugger::setClientPreferences(ClientPreferences& preferences) { return; } - assert(m_session != nullptr); + assertx(m_session != nullptr); m_session->setClientPreferences(preferences); } @@ -1107,7 +1107,7 @@ ClientPreferences Debugger::getClientPreferences() { return empty; } - assert(m_session != nullptr); + assertx(m_session != nullptr); return m_session->getClientPreferences(); } @@ -1121,7 +1121,7 @@ void Debugger::startDummyRequest( return; } - assert(m_session != nullptr); + assertx(m_session != nullptr); m_session->startDummyRequest(startupDoc, sandboxUser, sandboxName); } @@ -1133,7 +1133,7 @@ void Debugger::setDummyThreadId(int64_t threadId) { void Debugger::onBreakpointAdded(int bpId) { Lock lock(m_lock); - assert(m_session != nullptr); + assertx(m_session != nullptr); // Now to actually install the breakpoints, each request thread needs to // process the bp and set it in some TLS data structures. If the program @@ -1246,7 +1246,7 @@ void Debugger::tryInstallBreakpoints(RequestInfo* ri) { it = pendingBps.erase(it); } - assert(ri->m_breakpointInfo->m_pendingBreakpoints.empty()); + assertx(ri->m_breakpointInfo->m_pendingBreakpoints.empty()); } bool Debugger::tryResolveBreakpoint( @@ -1540,7 +1540,7 @@ void Debugger::onExceptionBreakpointHit( case BreakAll: break; default: - assert(false); + assertx(false); } if (prepareToPauseTarget(ri) != PrepareToPauseResult::ReadyToPause) { @@ -1692,7 +1692,7 @@ std::string Debugger::getStopReasonForBp( void Debugger::interruptAllThreads() { executeForEachAttachedRequest( [&](ThreadInfo* ti, RequestInfo* ri) { - assert(ti != nullptr); + assertx(ti != nullptr); ti->m_reqInjectionData.setDebuggerIntr(true); }, false /* includeDummyRequest */ diff --git a/hphp/runtime/ext/vsdebug/evaluate_command.cpp b/hphp/runtime/ext/vsdebug/evaluate_command.cpp index 8567a409956..2884ad19783 100644 --- a/hphp/runtime/ext/vsdebug/evaluate_command.cpp +++ b/hphp/runtime/ext/vsdebug/evaluate_command.cpp @@ -105,7 +105,7 @@ bool EvaluateCommand::executeImpl( rid.setErrorReportingLevel(0); RequestInfo* ri = m_debugger->getRequestInfo(); - assert(ri->m_evaluateCommandDepth >= 0); + assertx(ri->m_evaluateCommandDepth >= 0); ri->m_evaluateCommandDepth++; // Track if the evaluation command caused any opcode stepping to occur @@ -119,7 +119,7 @@ bool EvaluateCommand::executeImpl( rid.setErrorReportingLevel(previousErrorLevel); ri->m_evaluateCommandDepth--; - assert(ri->m_evaluateCommandDepth >= 0); + assertx(ri->m_evaluateCommandDepth >= 0); if (ri->m_evaluateCommandDepth == 0 && isDummy) { // The dummy request only appears in the client UX while it is @@ -304,7 +304,7 @@ void EvaluateCommand::preparseEvalExpression( StatementPtr statement = (*statements)[0]; // Statement list says we have a single statement, expect one. - assert(statement != nullptr); + assertx(statement != nullptr); if (statement->getKindOf() == Construct::KindOfExpStatement) { interpretExpr = "setTransport(transport); } @@ -146,7 +146,7 @@ void VSDebugExtension::requestInit() { return; } - assert(s_debugger != nullptr); + assertx(s_debugger != nullptr); // If we're in SCRIPT mode and a TCP listen port was specified on the command // line, we need to block starting the script until the debugger client @@ -175,7 +175,7 @@ void VSDebugExtension::requestShutdown() { return; } - assert(s_debugger != nullptr); + assertx(s_debugger != nullptr); s_debugger->requestShutdown(); } diff --git a/hphp/runtime/ext/vsdebug/session.cpp b/hphp/runtime/ext/vsdebug/session.cpp index 5491acd6a7f..12c39f8922b 100644 --- a/hphp/runtime/ext/vsdebug/session.cpp +++ b/hphp/runtime/ext/vsdebug/session.cpp @@ -32,7 +32,7 @@ DebuggerSession::DebuggerSession(Debugger* debugger) : m_dummyStartupDoc(""), m_sourceRootInfo(nullptr) { - assert(m_debugger != nullptr); + assertx(m_debugger != nullptr); } DebuggerSession::~DebuggerSession() { @@ -59,7 +59,7 @@ void DebuggerSession::startDummyRequest( const std::string& sandboxName ) { - assert(m_sourceRootInfo == nullptr); + assertx(m_sourceRootInfo == nullptr); if (!sandboxUser.empty()) { m_sourceRootInfo = new SourceRootInfo(sandboxUser, sandboxName); } @@ -248,7 +248,7 @@ unsigned int DebuggerSession::generateFrameId( const unsigned int objectId = ++s_nextObjectId; FrameObject* frame = new FrameObject(objectId, requestId, frameDepth); - assert(requestId == m_debugger->getCurrentThreadId()); + assertx(requestId == m_debugger->getCurrentThreadId()); registerRequestObject(objectId, frame); return objectId; } @@ -274,7 +274,7 @@ unsigned int DebuggerSession::generateScopeId( const unsigned int objectId = ++s_nextObjectId; ScopeObject* scope = new ScopeObject(objectId, requestId, depth, scopeType); - assert(requestId == m_debugger->getCurrentThreadId()); + assertx(requestId == m_debugger->getCurrentThreadId()); registerRequestObject(objectId, scope); return objectId; } @@ -286,7 +286,7 @@ unsigned int DebuggerSession::generateVariableId( const unsigned int objectId = ++s_nextObjectId; VariableObject* varObj = new VariableObject(objectId, requestId, variable); - assert(requestId == m_debugger->getCurrentThreadId()); + assertx(requestId == m_debugger->getCurrentThreadId()); registerRequestObject(objectId, varObj); return objectId; } diff --git a/hphp/runtime/ext/vsdebug/set_variable_command.cpp b/hphp/runtime/ext/vsdebug/set_variable_command.cpp index 65fe85ec292..7caa7532795 100644 --- a/hphp/runtime/ext/vsdebug/set_variable_command.cpp +++ b/hphp/runtime/ext/vsdebug/set_variable_command.cpp @@ -126,7 +126,7 @@ bool SetVariableCommand::executeImpl( break; default: - assert(false); + assertx(false); } } else if (obj->objectType() == ServerObjectType::Variable) { VariableObject* variable = static_cast(obj); @@ -230,7 +230,7 @@ bool SetVariableCommand::setArrayVariable( VMRegAnchor regAnchor; Variant& var = array->m_variable; - assert(var.isArray()); + assertx(var.isArray()); Array arr = var.toArray(); for (ArrayIter iter(arr); iter; ++iter) { @@ -271,7 +271,7 @@ bool SetVariableCommand::setObjectVariable( folly::dynamic* result ) { Variant& var = object->m_variable; - assert(var.isObject()); + assertx(var.isObject()); HPHP::String key(name); ObjectData* obj = var.getObjectData(); diff --git a/hphp/runtime/ext/vsdebug/socket_transport.cpp b/hphp/runtime/ext/vsdebug/socket_transport.cpp index 94efb6c2a75..12fde7760d3 100644 --- a/hphp/runtime/ext/vsdebug/socket_transport.cpp +++ b/hphp/runtime/ext/vsdebug/socket_transport.cpp @@ -29,7 +29,7 @@ SocketTransport::SocketTransport(Debugger* debugger, int listenPort) : Lock lock(m_lock); - assert(m_abortPipeFd[0] == -1 && m_abortPipeFd[1] == -1); + assertx(m_abortPipeFd[0] == -1 && m_abortPipeFd[1] == -1); // Create a set of pipe file descriptors to use to inform the thread // polling for socket connections that it's time to exit. @@ -73,7 +73,7 @@ void SocketTransport::createAbortPipe() { // This is unexpected and treated as fatal because we won't be able // to stop the polling thread in an orderly fashion at this point. - assert(false); + assertx(false); } } @@ -120,7 +120,7 @@ void SocketTransport::listenForClientConnection() { { Lock lock(m_lock); abortFd = m_abortPipeFd[0]; - assert(abortFd >= 0); + assertx(abortFd >= 0); } struct addrinfo hint; diff --git a/hphp/runtime/ext/vsdebug/transport.cpp b/hphp/runtime/ext/vsdebug/transport.cpp index 106b0f9ad38..3258560a870 100644 --- a/hphp/runtime/ext/vsdebug/transport.cpp +++ b/hphp/runtime/ext/vsdebug/transport.cpp @@ -30,8 +30,8 @@ void DebugTransport::setTransportFd(int fd) { Lock lock(m_mutex); // We shouldn't have a valid transport already. - assert(m_transportFd < 0); - assert(m_abortPipeFd[0] == -1 && m_abortPipeFd[1] == -1); + assertx(m_transportFd < 0); + assertx(m_abortPipeFd[0] == -1 && m_abortPipeFd[1] == -1); // Create a set of pipe file descriptors to use to inform the thread // polling for reads that it's time to exit. @@ -43,7 +43,7 @@ void DebugTransport::setTransportFd(int fd) { // This is unexpected and treated as fatal because we won't be able // to stop the polling threads in an orderly fashion at this point. - assert(false); + assertx(false); } m_transportFd = fd; @@ -370,7 +370,7 @@ bool DebugTransport::tryProcessMessage( bool success = false; const char* bufferPos = buffer + *bufferPosition; - assert(bufferPos <= buffer + bufferSize); + assertx(bufferPos <= buffer + bufferSize); // Advance through the buffer until we locate the NULL separator between // client messages. diff --git a/hphp/runtime/ext/vsdebug/variables_command.cpp b/hphp/runtime/ext/vsdebug/variables_command.cpp index c8b3afd9916..8b12d6418bc 100644 --- a/hphp/runtime/ext/vsdebug/variables_command.cpp +++ b/hphp/runtime/ext/vsdebug/variables_command.cpp @@ -100,7 +100,7 @@ const std::string& VariablesCommand::getUcVariableName( void VariablesCommand::sortVariablesInPlace(folly::dynamic& vars) { constexpr char* ucKey = "uc_name"; - assert(vars.isArray()); + assertx(vars.isArray()); std::sort( vars.begin(), @@ -196,7 +196,7 @@ int VariablesCommand::addScopeVariables( const ScopeObject* scope, folly::dynamic* vars ) { - assert(vars == nullptr || vars->isArray()); + assertx(vars == nullptr || vars->isArray()); switch (scope->m_scopeType) { case ScopeType::Locals: @@ -238,7 +238,7 @@ int VariablesCommand::addScopeVariables( return addSuperglobalVariables(session, requestId, scope, vars); default: - assert(false); + assertx(false); } return 0; @@ -325,7 +325,7 @@ int VariablesCommand::addLocals( const ScopeObject* scope, folly::dynamic* vars ) { - assert(scope->m_scopeType == ScopeType::Locals); + assertx(scope->m_scopeType == ScopeType::Locals); VMRegAnchor regAnchor; int count = 0; @@ -440,7 +440,7 @@ int VariablesCommand::addSuperglobalVariables( const ScopeObject* scope, folly::dynamic* vars ) { - assert(scope->m_scopeType == ScopeType::Superglobals); + assertx(scope->m_scopeType == ScopeType::Superglobals); int cacheCount = getCachedValue( session, @@ -746,7 +746,7 @@ int VariablesCommand::addArrayChildren( ) { Variant& var = variable->m_variable; - assert(var.isArray()); + assertx(var.isArray()); int idx = -1; int added = 0; @@ -1042,7 +1042,7 @@ int VariablesCommand::addClassSubScopes( } break; default: - assert(false); + assertx(false); } return subScopeCount; @@ -1191,7 +1191,7 @@ int VariablesCommand::addObjectChildren( const Variant& var, folly::dynamic* vars ) { - assert(var.isObject()); + assertx(var.isObject()); int propCount = 0; diff --git a/hphp/runtime/ext/wddx/ext_wddx.cpp b/hphp/runtime/ext/wddx/ext_wddx.cpp index 6a0786b0a9d..0acfc8cb00b 100644 --- a/hphp/runtime/ext/wddx/ext_wddx.cpp +++ b/hphp/runtime/ext/wddx/ext_wddx.cpp @@ -91,7 +91,7 @@ bool WddxPacket::recursiveAddVarImpl(const String& varName, varAsArray = varAsObject.toArray(); ptr = varAsObject.get(); } - assert(!ptr.isNull()); + assertx(!ptr.isNull()); if (!seen.emplace(ptr).second) { raise_warning("recursion detected"); return false; diff --git a/hphp/runtime/ext/weakref/ext_weakref.cpp b/hphp/runtime/ext/weakref/ext_weakref.cpp index c31378d666e..42b08c5e944 100644 --- a/hphp/runtime/ext/weakref/ext_weakref.cpp +++ b/hphp/runtime/ext/weakref/ext_weakref.cpp @@ -74,7 +74,7 @@ bool HHVM_METHOD(WeakRef, acquire) { if (wr_data_handle->acquire_count == 1) { tvIncRefCountable(wr_data_handle->wr_data->pointee); } - assert(wr_data_handle->acquire_count > 0); + assertx(wr_data_handle->acquire_count > 0); return true; } return false; diff --git a/hphp/runtime/ext/xdebug/ext_xdebug.cpp b/hphp/runtime/ext/xdebug/ext_xdebug.cpp index 124536ddb69..6c3cdbc6294 100644 --- a/hphp/runtime/ext/xdebug/ext_xdebug.cpp +++ b/hphp/runtime/ext/xdebug/ext_xdebug.cpp @@ -62,12 +62,12 @@ static ActRec* get_call_fp(Offset* off = nullptr) { // We want the frame of our callee's callee VMRegAnchor _; // Ensure consistent state for vmfp auto fp0 = g_context->getPrevVMState(vmfp()); - assert(fp0); + assertx(fp0); auto fp1 = g_context->getPrevVMState(fp0, off); // fp1 should only be NULL if fp0 is the top-level pseudo-main if (!fp1) { - assert(fp0->m_func->isPseudoMain()); + assertx(fp0->m_func->isPseudoMain()); fp1 = nullptr; } return fp1; @@ -85,7 +85,7 @@ const StaticString // "special" characters. They are replaced with _. The string is modified in // place, so there shouldn't be more than one reference to it. static void replace_special_chars(StringData* str) { - assert(!str->hasMultipleRefs()); + assertx(!str->hasMultipleRefs()); auto const len = str->size(); auto data = str->mutableData(); for (int i = 0; i < len; i++) { @@ -240,7 +240,7 @@ DECLARE_EXTERN_REQUEST_LOCAL(ProfilerFactory, s_profiler_factory); // Returns the attached xdebug profiler. Requires one is attached. static inline XDebugProfiler* xdebug_profiler() { - assert(XDEBUG_GLOBAL(ProfilerAttached)); + assertx(XDEBUG_GLOBAL(ProfilerAttached)); return (XDebugProfiler*) s_profiler_factory->getProfiler(); } @@ -298,7 +298,7 @@ static void start_profiling(XDebugProfiler* profiler) { // Attempts to attach the xdebug profiler to the current thread. Assumes it // is not already attached. Raises an error on failure. static void attach_xdebug_profiler() { - assert(!XDEBUG_GLOBAL(ProfilerAttached)); + assertx(!XDEBUG_GLOBAL(ProfilerAttached)); if (s_profiler_factory->start(ProfilerKind::XDebug, 0, false)) { XDEBUG_GLOBAL(ProfilerAttached) = true; // Enable profiling and tracing if we need to @@ -320,14 +320,14 @@ static void attach_xdebug_profiler() { // Detaches the xdebug profiler from the current thread static void detach_xdebug_profiler() { - assert(XDEBUG_GLOBAL(ProfilerAttached)); + assertx(XDEBUG_GLOBAL(ProfilerAttached)); s_profiler_factory->stop(); XDEBUG_GLOBAL(ProfilerAttached) = false; } // Detaches the xdebug profiler if it's no longer needed static void detach_xdebug_profiler_if_needed() { - assert(XDEBUG_GLOBAL(ProfilerAttached)); + assertx(XDEBUG_GLOBAL(ProfilerAttached)); auto profiler = xdebug_profiler(); if (!profiler->isNeeded()) { detach_xdebug_profiler(); @@ -397,7 +397,7 @@ static String HHVM_FUNCTION(xdebug_call_file) { if (fp == nullptr) { VMRegAnchor _; func = g_context->getPrevFunc(vmfp()); - assert(func); + assertx(func); } else { func = fp->func(); } @@ -413,7 +413,7 @@ static int64_t HHVM_FUNCTION(xdebug_call_line) { } auto const unit = fp->m_func->unit(); - assert(unit); + assertx(unit); return unit->getLineNumber(pc); } @@ -514,7 +514,7 @@ static Array HHVM_FUNCTION(xdebug_get_declared_vars) { auto const numNames = func->numNamedLocals(); PackedArrayInit vars(numNames); for (Id i = 0; i < numNames; ++i) { - assert(func->lookupVarId(func->localVarName(i)) == i); + assertx(func->lookupVarId(func->localVarName(i)) == i); String varname(const_cast(func->localVarName(i))); // Skip the internal closure "0Closure" variable if (!s_closure_varname.equal(varname)) { @@ -586,7 +586,7 @@ static bool HHVM_FUNCTION(xdebug_is_enabled) { static int64_t HHVM_FUNCTION(xdebug_memory_usage) { // With jemalloc, the usage can go negative (see memory_get_usage) auto const usage = tl_heap->getStats().usage(); - assert(use_jemalloc || usage >= 0); + assertx(use_jemalloc || usage >= 0); return std::max(usage, 0); } @@ -842,7 +842,7 @@ static void loadEnvConfig(std::map& envCfg) { static std::map config_values; void XDebugExtension::moduleLoad(const IniSetting::Map& ini, Hdf xdebug_hdf) { - assert(config_values.empty()); + assertx(config_values.empty()); auto debugger = xdebug_hdf["Eval"]["Debugger"]; @@ -1016,7 +1016,7 @@ void XDebugExtension::requestInit() { #undef XDEBUG_OPT // Initialize our breakpoint maps. - assert(s_xdebug_breakpoints.isNull()); + assertx(s_xdebug_breakpoints.isNull()); s_xdebug_breakpoints.getCheck(); // Let the server do initialization diff --git a/hphp/runtime/ext/xdebug/php5_xdebug/xdebug_var.cpp b/hphp/runtime/ext/xdebug/php5_xdebug/xdebug_var.cpp index 8a3740ca47c..2f3758f8f41 100644 --- a/hphp/runtime/ext/xdebug/php5_xdebug/xdebug_var.cpp +++ b/hphp/runtime/ext/xdebug/php5_xdebug/xdebug_var.cpp @@ -681,7 +681,7 @@ void xdebug_var_export_text_ansi( if (v.isVecArray()) return "vec"; if (v.isDict()) return "dict"; if (v.isKeyset()) return "keyset"; - assert(v.isArray()); + assertx(v.isArray()); return "array"; }(); @@ -923,7 +923,7 @@ void xdebug_var_export_fancy( if (v.isVecArray()) return "vec"; if (v.isDict()) return "dict"; if (v.isKeyset()) return "keyset"; - assert(v.isArray()); + assertx(v.isArray()); return "array"; }(); diff --git a/hphp/runtime/ext/xdebug/server.cpp b/hphp/runtime/ext/xdebug/server.cpp index 263432b2398..3545bec0d82 100644 --- a/hphp/runtime/ext/xdebug/server.cpp +++ b/hphp/runtime/ext/xdebug/server.cpp @@ -178,7 +178,7 @@ XDebugServer::XDebugServer(Mode mode) fail(); } - assert(status == 0); + assertx(status == 0); // Get the requested handler. log("I: Connected to client. :-)\n"); @@ -512,7 +512,7 @@ bool XDebugServer::isNeeded() { } bool XDebugServer::createServer(Mode mode) { - assert(XDEBUG_GLOBAL(Server) == nullptr); + assertx(XDEBUG_GLOBAL(Server) == nullptr); try { XDEBUG_GLOBAL(Server) = new XDebugServer(mode); if (XDEBUG_GLOBAL(Server) != nullptr) { @@ -551,7 +551,7 @@ bool XDebugServer::attach(Mode mode) { } void XDebugServer::detach() { - assert(XDEBUG_GLOBAL(Server) != nullptr); + assertx(XDEBUG_GLOBAL(Server) != nullptr); XDEBUG_GLOBAL(Server)->deinitDbgp(); delete XDEBUG_GLOBAL(Server); XDEBUG_GLOBAL(Server) = nullptr; @@ -897,7 +897,7 @@ bool XDebugServer::readInput() { auto constexpr INPUT_BUFFER_INIT_SIZE = 1024; auto constexpr INPUT_BUFFER_EXPANSION = 2.0; - assert(m_bufferAvail == 0); + assertx(m_bufferAvail == 0); size_t bytes_read = 0; do { size_t bytes_left = m_bufferSize - bytes_read; @@ -922,7 +922,7 @@ bool XDebugServer::readInput() { } std::shared_ptr XDebugServer::parseCommand() { - assert(m_bufferAvail > 0); + assertx(m_bufferAvail > 0); log("<- %s\n", m_bufferCur); logFlush(); @@ -936,7 +936,7 @@ std::shared_ptr XDebugServer::parseCommand() { // Bump the current buffer pointer forward *before* calling parseInput, so we // don't get stuck in an infinite loop if parseInput throws. auto consumed = strlen(m_bufferCur) + 1; - assert(consumed <= m_bufferAvail); + assertx(consumed <= m_bufferAvail); m_bufferCur += consumed; m_bufferAvail -= consumed; diff --git a/hphp/runtime/ext/xdebug/xdebug_profiler.cpp b/hphp/runtime/ext/xdebug/xdebug_profiler.cpp index 52a53e4b60d..729c3dc0294 100644 --- a/hphp/runtime/ext/xdebug/xdebug_profiler.cpp +++ b/hphp/runtime/ext/xdebug/xdebug_profiler.cpp @@ -121,7 +121,7 @@ void XDebugProfiler::recordFrame(const TypedValue* retVal) { } void XDebugProfiler::beginFrame(const char* /*symbol*/) { - assert(isNeeded()); + assertx(isNeeded()); // Check the stack depth, abort if we've reached the limit m_depth++; @@ -139,7 +139,7 @@ void XDebugProfiler::beginFrame(const char* /*symbol*/) { void XDebugProfiler::endFrame(const TypedValue* retVal, const char* /*symbol*/, bool /*endMain*/ /* = false */) { - assert(isNeeded()); + assertx(isNeeded()); m_depth--; if (isCollecting()) { @@ -157,7 +157,7 @@ void XDebugProfiler::endFrame(const TypedValue* retVal, const char* /*symbol*/, // Tracing void XDebugProfiler::enableTracing(const String& filename, int64_t opts) { - assert(!m_tracingEnabled); + assertx(!m_tracingEnabled); // Attempt to open the passed filename. php5 xdebug doesn't enable tracing // if we cannot open the file, so we need to open it now as opposed to when we @@ -223,7 +223,7 @@ void XDebugProfiler::writeTracingResults() { // iterating until we run out of frames writeTracingResultsHeader(); while (buf_idx < m_nextFrameIdx) { - assert(level >= 0); + assertx(level >= 0); if (!m_frameBuffer[buf_idx].is_func_begin) { buf_idx++; level--; @@ -292,7 +292,7 @@ int64_t XDebugProfiler::writeTracingFrame(int64_t level, const FrameData* parentBegin) { uint64_t id = m_tracingNextFrameId++; FrameData& begin = m_frameBuffer[startIdx]; - assert(begin.is_func_begin); + assertx(begin.is_func_begin); writeTracingLinePrefix(); writeTracingLevel(level); @@ -529,7 +529,7 @@ static const StaticString s_SCRIPT_NAME("SCRIPT_NAME"); void XDebugProfiler::enableProfiling(const String& filename, int64_t opts) { - assert(!m_profilingEnabled); + assertx(!m_profilingEnabled); // Attempt to open the passed filename. php5 xdebug doesn't enable profiling // if we cannot open the file, so we need to open it now as opposed to when we @@ -585,7 +585,7 @@ void XDebugProfiler::writeProfilingResults() { } int64_t XDebugProfiler::writeProfilingFrame(int64_t startIdx) { - assert(m_frameBuffer[startIdx].is_func_begin); + assertx(m_frameBuffer[startIdx].is_func_begin); // We need to store the child calls so we don't have to find // them again in writeCacheGrindFrame. Theoretically, this could be stored diff --git a/hphp/runtime/ext/xml/ext_xml.cpp b/hphp/runtime/ext/xml/ext_xml.cpp index 8940f382e68..ca0fbeb4fb8 100644 --- a/hphp/runtime/ext/xml/ext_xml.cpp +++ b/hphp/runtime/ext/xml/ext_xml.cpp @@ -297,7 +297,7 @@ String xml_utf8_decode(const XML_Char *s, int len, ++newlen; } - assert(newlen <= len); + assertx(newlen <= len); str.shrink(newlen); return str; } @@ -1028,7 +1028,7 @@ String HHVM_FUNCTION(utf8_encode, } } - assert(newlen <= maxSize); + assertx(newlen <= maxSize); str.shrink(newlen); return str; } diff --git a/hphp/runtime/ext/xsl/ext_xsl.cpp b/hphp/runtime/ext/xsl/ext_xsl.cpp index ae1926697d3..8ffcf27008c 100644 --- a/hphp/runtime/ext/xsl/ext_xsl.cpp +++ b/hphp/runtime/ext/xsl/ext_xsl.cpp @@ -195,8 +195,8 @@ xmlDocPtr XSLTProcessorData::apply_stylesheet() { ); for (ArrayIter iter(m_params); iter; ++iter) { - assert(iter.first().isString()); - assert(iter.second().isString()); + assertx(iter.first().isString()); + assertx(iter.second().isString()); xmlChar *value = xslt_string_to_xpathexpr(iter.second().toString().c_str()); if (value) { @@ -214,7 +214,7 @@ xmlDocPtr XSLTProcessorData::apply_stylesheet() { profile = fopen(m_profile.data(), "w"); } - assert(m_usedElements.empty()); + assertx(m_usedElements.empty()); xmlDocPtr res = xsltApplyStylesheetUser(m_stylesheet, doc(), nullptr, @@ -449,7 +449,7 @@ HHVM_METHOD(XSLTProcessor, getParameter, const Variant& /*namespaceURI*/, // namespaceURI argument is unused in PHP5 XSL extension. if (data->m_params.exists(localName)) { - assert(data->m_params[localName].isString()); + assertx(data->m_params[localName].isString()); return data->m_params[localName].toString(); } @@ -505,7 +505,7 @@ HHVM_METHOD(XSLTProcessor, removeParameter, const Variant& /*namespaceURI*/, // namespaceURI argument is unused in PHP5 XSL extension. if (data->m_params.exists(localName)) { - assert(data->m_params[localName].isString()); + assertx(data->m_params[localName].isString()); data->m_params.remove(localName); return true; diff --git a/hphp/runtime/ext/zlib/ext_zlib.cpp b/hphp/runtime/ext/zlib/ext_zlib.cpp index c6d3c246f00..b04ff2bca54 100644 --- a/hphp/runtime/ext/zlib/ext_zlib.cpp +++ b/hphp/runtime/ext/zlib/ext_zlib.cpp @@ -212,7 +212,7 @@ Variant HHVM_FUNCTION(gzencode, const String& data, int level, */ static String hhvm_zlib_inflate_rounds(z_stream *Z, int64_t maxlen, int &status) { - assert(maxlen >= 0); + assertx(maxlen >= 0); size_t retsize = (maxlen && maxlen < Z->avail_in) ? maxlen : Z->avail_in; String ret; size_t retused = 0; @@ -222,7 +222,7 @@ static String hhvm_zlib_inflate_rounds(z_stream *Z, int64_t maxlen, if (UNLIKELY(retsize >= kMaxSmallSize) && UNLIKELY(tl_heap->preAllocOOM(retsize + 1))) { VMRegAnchor _; - assert(checkSurpriseFlags()); + assertx(checkSurpriseFlags()); handle_request_surprise(); } @@ -504,7 +504,7 @@ struct ChunkedInflator { bool HHVM_METHOD(ChunkedInflator, eof) { FETCH_CHUNKED_INFLATOR(data, this_); - assert(data); + assertx(data); return data->eof(); } @@ -512,7 +512,7 @@ String HHVM_METHOD(ChunkedInflator, inflateChunk, const String& chunk) { FETCH_CHUNKED_INFLATOR(data, this_); - assert(data); + assertx(data); return data->inflateChunk(chunk); } diff --git a/hphp/runtime/ext/zlib/zip-file.cpp b/hphp/runtime/ext/zlib/zip-file.cpp index ddf9aabaad1..c9b16e38493 100644 --- a/hphp/runtime/ext/zlib/zip-file.cpp +++ b/hphp/runtime/ext/zlib/zip-file.cpp @@ -39,7 +39,7 @@ void ZipFile::sweep() { } bool ZipFile::open(const String& filename, const String& mode) { - assert(m_gzFile == nullptr); + assertx(m_gzFile == nullptr); if (strchr(mode.c_str(), '+')) { raise_warning("cannot open a zlib stream for reading and writing " @@ -99,7 +99,7 @@ bool ZipFile::closeImpl() { /////////////////////////////////////////////////////////////////////////////// int64_t ZipFile::readImpl(char *buffer, int64_t length) { - assert(m_gzFile); + assertx(m_gzFile); int64_t nread = gzread(m_gzFile, buffer, length); if (nread == 0 || gzeof(m_gzFile)) { setEof(true); @@ -114,12 +114,12 @@ int64_t ZipFile::readImpl(char *buffer, int64_t length) { } int64_t ZipFile::writeImpl(const char *buffer, int64_t length) { - assert(m_gzFile); + assertx(m_gzFile); return gzwrite(m_gzFile, buffer, length); } bool ZipFile::seek(int64_t offset, int whence /* = SEEK_SET */) { - assert(m_gzFile); + assertx(m_gzFile); if (whence == SEEK_CUR) { off_t result = gzseek(m_gzFile, 0, SEEK_CUR); @@ -147,18 +147,18 @@ bool ZipFile::seek(int64_t offset, int whence /* = SEEK_SET */) { } int64_t ZipFile::tell() { - assert(m_gzFile); + assertx(m_gzFile); return getPosition(); } bool ZipFile::eof() { - assert(m_gzFile); + assertx(m_gzFile); int64_t avail = bufferedLen(); return avail > 0 ? false : getEof(); } bool ZipFile::rewind() { - assert(m_gzFile); + assertx(m_gzFile); seek(0); setWritePosition(0); setReadPosition(0); @@ -169,7 +169,7 @@ bool ZipFile::rewind() { } bool ZipFile::flush() { - assert(m_gzFile); + assertx(m_gzFile); return gzflush(m_gzFile, Z_SYNC_FLUSH); } diff --git a/hphp/runtime/server/access-log.cpp b/hphp/runtime/server/access-log.cpp index 908554a4265..00e14d15b63 100644 --- a/hphp/runtime/server/access-log.cpp +++ b/hphp/runtime/server/access-log.cpp @@ -144,7 +144,7 @@ void AccessLog::init(const std::string &format, } void AccessLog::log(Transport *transport, const VirtualHost *vhost) { - assert(transport); + assertx(transport); if (!m_initialized) return; m_defaultWriter->write(transport, vhost); for (auto& file : m_files) file->write(transport, vhost); diff --git a/hphp/runtime/server/admin-request-handler.cpp b/hphp/runtime/server/admin-request-handler.cpp index 2d33b84a407..da6c02dd4e2 100644 --- a/hphp/runtime/server/admin-request-handler.cpp +++ b/hphp/runtime/server/admin-request-handler.cpp @@ -141,7 +141,7 @@ static void malloc_write_cb(void *cbopaque, const char *s) { } if (mw->slen + slen+1 >= mw->smax) { - assert(mw->slen + slen > 0); + assertx(mw->slen + slen > 0); char* ts = (char*)realloc(mw->s, (mw->slen + slen) << 1); if (ts == nullptr) { mw->oom = true; @@ -830,7 +830,7 @@ void AdminRequestHandler::handleRequest(Transport *transport) { #ifdef USE_JEMALLOC if (mallctl) { - assert(mallctlnametomib && mallctlbymib); + assertx(mallctlnametomib && mallctlbymib); if (cmd == "jemalloc-stats") { // Force jemalloc to update stats cached for use by mallctl(). uint32_t error = 0; diff --git a/hphp/runtime/server/cli-server.cpp b/hphp/runtime/server/cli-server.cpp index d30873f967b..d778eaa026e 100644 --- a/hphp/runtime/server/cli-server.cpp +++ b/hphp/runtime/server/cli-server.cpp @@ -1622,7 +1622,7 @@ void init_cli_server(const char* socket_path) { } } - assert(!s_cliServer); + assertx(!s_cliServer); FTRACE(1, "init_cli_server({}): init...\n", socket_path); s_cliServer = new CLIServer(socket_path); } @@ -1647,7 +1647,7 @@ void teardown_cli_server() { ucred* get_cli_ucred() { return tl_ucred; } bool cli_mkstemp(char* buf) { - assert(tl_cliSock >= 0); + assertx(tl_cliSock >= 0); FTRACE(2, "cli_mkstemp({}): fd = {}\n", buf, tl_cliSock); std::string out = buf; cli_write(tl_cliSock, "mkstemp", out); diff --git a/hphp/runtime/server/fastcgi/fastcgi-server-factory.cpp b/hphp/runtime/server/fastcgi/fastcgi-server-factory.cpp index 0ef9b125f39..aa8561cb6c6 100644 --- a/hphp/runtime/server/fastcgi/fastcgi-server-factory.cpp +++ b/hphp/runtime/server/fastcgi/fastcgi-server-factory.cpp @@ -24,7 +24,7 @@ struct FastCGIServerFactory : ServerFactory { ServerPtr createServer(const ServerOptions& options) override { // We currently do not support FastCGIServer with less-than-maximum // initial threads. - assert(options.m_maxThreads == options.m_initThreads); + assertx(options.m_maxThreads == options.m_initThreads); return std::make_unique(options.m_address, options.m_port, options.m_maxThreads, diff --git a/hphp/runtime/server/fastcgi/fastcgi-session.cpp b/hphp/runtime/server/fastcgi/fastcgi-session.cpp index e45d8d76e9b..a8508a874d9 100644 --- a/hphp/runtime/server/fastcgi/fastcgi-session.cpp +++ b/hphp/runtime/server/fastcgi/fastcgi-session.cpp @@ -46,7 +46,7 @@ std::tuple< std::unique_ptr, std::unique_ptr > KVParser::readNext() { - assert(ready()); + assertx(ready()); m_phase = Phase::READ_KEY_LENGTH; auto key = m_keyBuf.move(); @@ -157,9 +157,9 @@ bool KVParser::parseKeyValueContent(Cursor& cursor, std::unique_ptr buf; size_t len = cursor.cloneAtMost(buf, length); queue.append(std::move(buf)); - assert(length >= len); + assertx(length >= len); length -= len; - assert(available >= len); + assertx(available >= len); available -= len; return (length == 0); } @@ -676,7 +676,7 @@ void FastCGISession::writeUnknownType(fcgi::Type record_type) { void FastCGISession::writeStream(fcgi::Type type, std::unique_ptr stream_chain) { - assert(type == fcgi::STDOUT || type == fcgi::STDERR); + assertx(type == fcgi::STDOUT || type == fcgi::STDERR); if (stream_chain == nullptr) { return; // Nothing to do. } diff --git a/hphp/runtime/server/host-health-monitor.cpp b/hphp/runtime/server/host-health-monitor.cpp index 927a4afb185..23560eac132 100644 --- a/hphp/runtime/server/host-health-monitor.cpp +++ b/hphp/runtime/server/host-health-monitor.cpp @@ -47,7 +47,7 @@ folly::Singleton s_health_monitor; } void HostHealthMonitor::addMetric(IHealthMonitorMetric* metric) { - assert(metric != nullptr); + assertx(metric != nullptr); std::lock_guard g(m_lock); m_metrics.push_back(metric); } diff --git a/hphp/runtime/server/host-health-monitor.h b/hphp/runtime/server/host-health-monitor.h index 4c9833fdbdb..63abe9400bb 100644 --- a/hphp/runtime/server/host-health-monitor.h +++ b/hphp/runtime/server/host-health-monitor.h @@ -32,7 +32,7 @@ namespace HPHP { // This class must be used as a singleton. struct HostHealthMonitor { void subscribe(IHostHealthObserver* observer) { - assert(observer != nullptr); + assertx(observer != nullptr); std::lock_guard g(m_lock); m_observers.insert(observer); } diff --git a/hphp/runtime/server/http-protocol.cpp b/hphp/runtime/server/http-protocol.cpp index f63e6526d58..130fa83df71 100644 --- a/hphp/runtime/server/http-protocol.cpp +++ b/hphp/runtime/server/http-protocol.cpp @@ -428,7 +428,7 @@ void HttpProtocol::PreparePostVariables(Array& post, size = 0; } } - assert(!transport->getFiles(files_str)); + assertx(!transport->getFiles(files_str)); } else { needDelete = read_all_post_data(transport, data, size); @@ -641,7 +641,7 @@ static void CopyPathInfo(Array& server, String prefix(transport->isSSL() ? "https://" : "http://"); // Need to append port - assert(server.exists(s_SERVER_PORT)); + assertx(server.exists(s_SERVER_PORT)); std::string serverPort = "80"; if (server.exists(s_SERVER_PORT)) { Variant port = server[s_SERVER_PORT]; @@ -664,7 +664,7 @@ static void CopyPathInfo(Array& server, } String hostName; if (server.exists(s_SERVER_NAME)) { - assert(server[s_SERVER_NAME].isString()); + assertx(server[s_SERVER_NAME].isString()); hostName = server[s_SERVER_NAME].toCStrRef(); } server.set(s_SCRIPT_URI, @@ -713,8 +713,8 @@ static void CopyPathInfo(Array& server, if (r.pathInfo().empty()) { server.set(s_PATH_TRANSLATED, r.absolutePath()); } else { - assert(server.exists(s_DOCUMENT_ROOT)); - assert(server[s_DOCUMENT_ROOT].isString()); + assertx(server.exists(s_DOCUMENT_ROOT)); + assertx(server[s_DOCUMENT_ROOT].isString()); // reset path_translated back to the transport if it has it. auto const& pathTranslated = transport->getPathTranslated(); if (!pathTranslated.empty()) { @@ -857,7 +857,7 @@ void HttpProtocol::DecodeParameters(Array& variables, const char *data, } void HttpProtocol::DecodeCookies(Array& variables, char *data) { - assert(data && *data); + assertx(data && *data); char *strtok_buf = nullptr; char *var = strtok_r(data, ";", &strtok_buf); @@ -993,7 +993,7 @@ bool HttpProtocol::ProxyRequest(Transport *transport, bool force, int &code, std::string &error, StringBuffer &response, HeaderMap *extraHeaders /* = NULL */) { - assert(transport); + assertx(transport); if (transport->headersSent()) { raise_warning("Cannot proxy request - headers already sent"); return false; diff --git a/hphp/runtime/server/http-request-handler.cpp b/hphp/runtime/server/http-request-handler.cpp index 247c96d683a..8d738389659 100644 --- a/hphp/runtime/server/http-request-handler.cpp +++ b/hphp/runtime/server/http-request-handler.cpp @@ -132,9 +132,9 @@ void HttpRequestHandler::sendStaticContent(Transport *transport, bool compressed, const std::string &cmd, const char *ext) { - assert(ext); - assert(cmd.rfind('.') != std::string::npos); - assert(strcmp(ext, cmd.c_str() + cmd.rfind('.') + 1) == 0); + assertx(ext); + assertx(cmd.rfind('.') != std::string::npos); + assertx(strcmp(ext, cmd.c_str() + cmd.rfind('.') + 1) == 0); auto iter = RuntimeOption::StaticFileExtensions.find(ext); if (iter != RuntimeOption::StaticFileExtensions.end()) { @@ -245,7 +245,7 @@ void HttpRequestHandler::handleRequest(Transport *transport) { // resolve virtual host const VirtualHost *vhost = VirtualHost::GetCurrent(); - assert(vhost); + assertx(vhost); if (vhost->disabled() || vhost->isBlocking(transport->getCommand(), transport->getRemoteHost())) { transport->sendString("Not Found", 404); diff --git a/hphp/runtime/server/http-server.cpp b/hphp/runtime/server/http-server.cpp index 38ced4c342c..fd20e08ffb4 100644 --- a/hphp/runtime/server/http-server.cpp +++ b/hphp/runtime/server/http-server.cpp @@ -126,12 +126,12 @@ HttpServer::HttpServer() } if (RuntimeOption::EnableSSL) { - assert(SSLInit::IsInited()); + assertx(SSLInit::IsInited()); m_pageServer->enableSSL(RuntimeOption::SSLPort); } if (RuntimeOption::EnableSSLWithPlainText) { - assert(SSLInit::IsInited()); + assertx(SSLInit::IsInited()); m_pageServer->enableSSLWithPlainText(); } @@ -217,7 +217,7 @@ void HttpServer::takeoverShutdown() { void HttpServer::serverStopped(HPHP::Server* server) { Logger::Info("Page server stopped"); - assert(server == m_pageServer.get()); + assertx(server == m_pageServer.get()); removePid(); auto sockFile = RuntimeOption::ServerFileSocket; @@ -665,7 +665,7 @@ bool HttpServer::CanContinue(const MemInfo& mem, int64_t rssMb, if (mem.freeMb < RuntimeOption::ServerCriticalFreeMb) return false; auto const availableMb = availableMemory(mem, rssMb, cacheFreeFactor); auto const result = (rssMb + availableMb >= rssNeeded); - if (result) assert(CanStep(mem, rssMb, rssNeeded, cacheFreeFactor)); + if (result) assertx(CanStep(mem, rssMb, rssNeeded, cacheFreeFactor)); return result; } @@ -734,7 +734,7 @@ void HttpServer::MarkShutdownStat(ShutdownEvent event) { } #ifndef NDEBUG if (!ShutdownStats.empty()) { - assert(ShutdownStats.back().event <= event); + assertx(ShutdownStats.back().event <= event); } #endif ShutdownStats.push_back({event, time(nullptr), mem, rss, requests}); diff --git a/hphp/runtime/server/ip-block-map.cpp b/hphp/runtime/server/ip-block-map.cpp index f134f363b3a..2989ccc60e0 100644 --- a/hphp/runtime/server/ip-block-map.cpp +++ b/hphp/runtime/server/ip-block-map.cpp @@ -59,7 +59,7 @@ bool IpBlockMap::BinaryPrefixTrie::isAllowedImpl( return m_allow; } - assert(bit_offset < num_bits); + assertx(bit_offset < num_bits); child = m_children[(*search_bytes >> (7 - bit_offset)) & 1]; if (child) { @@ -213,7 +213,7 @@ bool IpBlockMap::isBlocking(const std::string &command, if (!translated) { ReadIPv6Address(ip.c_str(), &address, bits); - assert(bits == 128); + assertx(bits == 128); translated = true; } diff --git a/hphp/runtime/server/log-writer.cpp b/hphp/runtime/server/log-writer.cpp index 13421b36bb9..4158d03a147 100644 --- a/hphp/runtime/server/log-writer.cpp +++ b/hphp/runtime/server/log-writer.cpp @@ -65,7 +65,7 @@ void ClassicWriter::init(const std::string& username, AccessLog::GetThreadDataFunc fn) { m_threadDataFn = fn; if (m_channel == LogChannel::CRONOLOG) { - assert(!m_logdata.file.empty()); + assertx(!m_logdata.file.empty()); m_cronolog = std::make_unique(); if (m_logdata.file.find('%') != std::string::npos) { m_cronolog->m_template = m_logdata.file; @@ -80,7 +80,7 @@ void ClassicWriter::init(const std::string& username, m_cronolog->m_file = fopen(m_logdata.file.c_str(), "a"); } } else if (m_channel == LogChannel::REGULAR) { - assert(!m_logdata.file.empty()); + assertx(!m_logdata.file.empty()); if (m_logdata.file[0] == '|') { std::string plog = m_logdata.file.substr(1); m_filelog = popen(plog.c_str(), "w"); diff --git a/hphp/runtime/server/memory-stats.cpp b/hphp/runtime/server/memory-stats.cpp index 73145c8262c..79089165554 100644 --- a/hphp/runtime/server/memory-stats.cpp +++ b/hphp/runtime/server/memory-stats.cpp @@ -41,7 +41,7 @@ void MemoryStats::ReportMemory(std::string& output, Writer::Format format) { } else if (format == Writer::Format::HTML) { w.reset(new HTMLWriter(out)); } else { - assert(format == Writer::Format::JSON); + assertx(format == Writer::Format::JSON); w.reset(new JSONWriter(out)); } diff --git a/hphp/runtime/server/pagelet-server.cpp b/hphp/runtime/server/pagelet-server.cpp index b827df960e1..bec578082db 100644 --- a/hphp/runtime/server/pagelet-server.cpp +++ b/hphp/runtime/server/pagelet-server.cpp @@ -107,7 +107,7 @@ Transport::Method PageletTransport::getMethod() { } std::string PageletTransport::getHeader(const char *name) { - assert(name && *name); + assertx(name && *name); HeaderMap::const_iterator iter = m_requestHeaders.find(name); if (iter != m_requestHeaders.end()) { return iter->second[0]; @@ -120,13 +120,13 @@ void PageletTransport::getHeaders(HeaderMap &headers) { } void PageletTransport::addHeaderImpl(const char *name, const char *value) { - assert(name && *name); - assert(value); + assertx(name && *name); + assertx(value); m_responseHeaders[name].push_back(value); } void PageletTransport::removeHeaderImpl(const char *name) { - assert(name && *name); + assertx(name && *name); m_responseHeaders.erase(name); } @@ -191,7 +191,7 @@ Array PageletTransport::getAsyncResults(bool allow_empty) { { Lock lock(this); - assert(m_done || !m_pipeline.empty() || allow_empty); + assertx(m_done || !m_pipeline.empty() || allow_empty); while (!m_pipeline.empty()) { std::string &str = m_pipeline.front(); String response(str.c_str(), str.size(), CopyString); @@ -270,7 +270,7 @@ void PageletTransport::incRefCount() { } void PageletTransport::decRefCount() { - assert(m_refCount.load() > 0); + assertx(m_refCount.load() > 0); if (--m_refCount == 0) { delete this; } @@ -464,10 +464,10 @@ Array PageletServer::AsyncTaskResult(const Resource& task) { } void PageletServer::AddToPipeline(const std::string &s) { - assert(!s.empty()); + assertx(!s.empty()); PageletTransport *job = dynamic_cast(g_context->getTransport()); - assert(job); + assertx(job); job->addToPipeline(s); } diff --git a/hphp/runtime/server/proxygen/proxygen-transport.cpp b/hphp/runtime/server/proxygen/proxygen-transport.cpp index 049706b589d..9f5713e3473 100644 --- a/hphp/runtime/server/proxygen/proxygen-transport.cpp +++ b/hphp/runtime/server/proxygen/proxygen-transport.cpp @@ -466,7 +466,7 @@ size_t ProxygenTransport::getRequestSize() const { } std::string ProxygenTransport::getHeader(const char *name) { - assert(name && *name); + assertx(name && *name); HeaderMap::const_iterator iter = m_requestHeaders.find(name); if (iter != m_requestHeaders.end()) { @@ -482,8 +482,8 @@ void ProxygenTransport::getHeaders(HeaderMap &headers) { } void ProxygenTransport::addHeaderImpl(const char *name, const char *value) { - assert(name && *name); - assert(value); + assertx(name && *name); + assertx(value); if (m_sendStarted) { Logger::Error("trying to add header '%s: %s' after 1st chunk", @@ -495,7 +495,7 @@ void ProxygenTransport::addHeaderImpl(const char *name, const char *value) { } void ProxygenTransport::removeHeaderImpl(const char *name) { - assert(name && *name); + assertx(name && *name); if (m_sendStarted) { Logger::Error("trying to remove header '%s' after 1st chunk", name); @@ -507,15 +507,15 @@ void ProxygenTransport::removeHeaderImpl(const char *name) { void ProxygenTransport::addRequestHeaderImpl(const char *name, const char *value) { - assert(name && *name); - assert(value); + assertx(name && *name); + assertx(value); m_request->getHeaders().add(name, value); m_requestHeaders[name].push_back(value); } void ProxygenTransport::removeRequestHeaderImpl(const char *name) { - assert(name && *name); + assertx(name && *name); m_request->getHeaders().remove(name); m_requestHeaders.erase(name); } @@ -660,8 +660,8 @@ void ProxygenTransport::messageAvailable(ResponseMessage&& message) noexcept { void ProxygenTransport::sendImpl(const void *data, int size, int code, bool chunked, bool eom) { - assert(data); - assert(!m_sendStarted || chunked); + assertx(data); + assertx(!m_sendStarted || chunked); if (m_sendEnded) { // This should never happen, but when it does we have to bail out, // since there's no sensible way to send data at this point and diff --git a/hphp/runtime/server/replay-transport.cpp b/hphp/runtime/server/replay-transport.cpp index 1368ecee4fb..f6b110e2dee 100644 --- a/hphp/runtime/server/replay-transport.cpp +++ b/hphp/runtime/server/replay-transport.cpp @@ -28,7 +28,7 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// void ReplayTransport::recordInput(Transport* transport, const char *filename) { - assert(transport); + assertx(transport); Hdf hdf; @@ -115,9 +115,9 @@ Transport::Method ReplayTransport::getMethod() { } std::string ReplayTransport::getHeader(const char *name) { - assert(name); + assertx(name); if (m_requestHeaders.find(name) != m_requestHeaders.end()) { - assert(!m_requestHeaders[name].empty()); + assertx(!m_requestHeaders[name].empty()); return m_requestHeaders[name][0]; } return ""; @@ -128,12 +128,12 @@ void ReplayTransport::getHeaders(HeaderMap &headers) { } void ReplayTransport::addHeaderImpl(const char *name, const char *value) { - assert(name && value); + assertx(name && value); m_responseHeaders[name].push_back(value); } void ReplayTransport::removeHeaderImpl(const char *name) { - assert(name); + assertx(name); m_responseHeaders.erase(name); } diff --git a/hphp/runtime/server/rpc-request-handler.cpp b/hphp/runtime/server/rpc-request-handler.cpp index 0ed5cf265c5..c8fba397eba 100644 --- a/hphp/runtime/server/rpc-request-handler.cpp +++ b/hphp/runtime/server/rpc-request-handler.cpp @@ -188,7 +188,7 @@ void RPCRequestHandler::handleRequest(Transport *transport) { // resolve virtual host const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); - assert(vhost); + assertx(vhost); if (vhost->disabled()) { transport->sendString("Virtual host disabled.", 404); transport->onSendEnd(); @@ -235,7 +235,7 @@ void RPCRequestHandler::abortRequest(Transport *transport) { g_context.getCheck(); GetAccessLog().onNewRequest(); const VirtualHost *vhost = HttpProtocol::GetVirtualHost(transport); - assert(vhost); + assertx(vhost); transport->sendString("Service Unavailable", 503); GetAccessLog().log(transport, vhost); if (!vmStack().isAllocated()) { @@ -379,7 +379,7 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport, String response; switch (output) { case 0: { - assert(returnEncodeType == ReturnEncodeType::Json || + assertx(returnEncodeType == ReturnEncodeType::Json || returnEncodeType == ReturnEncodeType::Serialize); try { response = (returnEncodeType == ReturnEncodeType::Json) diff --git a/hphp/runtime/server/satellite-server.cpp b/hphp/runtime/server/satellite-server.cpp index ba59abd9604..d92286ee813 100644 --- a/hphp/runtime/server/satellite-server.cpp +++ b/hphp/runtime/server/satellite-server.cpp @@ -191,7 +191,7 @@ SatelliteServer::Create(std::shared_ptr info) { satellite.reset(new RPCServer(info)); break; default: - assert(false); + assertx(false); } if (satellite) { satellite->setName(info->getName()); diff --git a/hphp/runtime/server/server-stats.cpp b/hphp/runtime/server/server-stats.cpp index 6a14cebefb6..6134c8de628 100644 --- a/hphp/runtime/server/server-stats.cpp +++ b/hphp/runtime/server/server-stats.cpp @@ -126,7 +126,7 @@ void ServerStats::Filter(list& slots, const std::string& keys, std::map rules; for (unsigned int i = 0; i < rules0.size(); i++) { auto const& rule = rules0[i]; - assert(!rule.empty()); + assertx(!rule.empty()); int len = rule.length(); std::string suffix; if (len > 4) { @@ -439,7 +439,7 @@ void ServerStats::ReportStatus(std::string& output, Writer::Format format) { } else if (format == Writer::Format::HTML) { w = new HTMLWriter(out); } else { - assert(format == Writer::Format::JSON); + assertx(format == Writer::Format::JSON); w = new JSONWriter(out); } @@ -494,7 +494,7 @@ void ServerStats::ReportStatus(std::string& output, Writer::Format format) { case ThreadMode::Processing: mode = "process"; break; case ThreadMode::Writing: mode = "writing"; break; case ThreadMode::PostProcessing: mode = "psp"; break; - default: assert(false); + default: assertx(false); } w->beginObject("thread"); @@ -880,7 +880,7 @@ IOStatusHelper::IOStatusHelper(const char *name, const char *address /* = NULL */, int port /* = 0 */) : m_exeProfiler(ThreadInfo::NetworkIO) { - assert(name && *name); + assertx(name && *name); if (ServerStats::s_profile_network || (RuntimeOption::EnableStats && RuntimeOption::EnableWebStats)) { diff --git a/hphp/runtime/server/server-worker.h b/hphp/runtime/server/server-worker.h index e2e73c9cf0f..e6b92d82e01 100644 --- a/hphp/runtime/server/server-worker.h +++ b/hphp/runtime/server/server-worker.h @@ -64,7 +64,7 @@ struct ServerWorker * Called when thread enters and exits. */ void onThreadEnter() override { - assert(this->m_context); + assertx(this->m_context); m_handler = this->m_context->createRequestHandler(); m_requestsTimedOutOnQueue = ServiceData::createTimeSeries("requests_timed_out_on_queue", @@ -72,7 +72,7 @@ struct ServerWorker } void onThreadExit() override { - assert(this->m_context); + assertx(this->m_context); m_handler.reset(); } diff --git a/hphp/runtime/server/server.h b/hphp/runtime/server/server.h index 2c2039a449f..e8accac6211 100644 --- a/hphp/runtime/server/server.h +++ b/hphp/runtime/server/server.h @@ -323,7 +323,7 @@ struct ServerOptions { m_useFileSocket(false), m_queueToWorkerRatio(1), m_hugeThreads(0) { - assert(m_maxThreads >= 0); + assertx(m_maxThreads >= 0); if (m_initThreads < 0 || m_initThreads > m_maxThreads) { m_initThreads = m_maxThreads; } diff --git a/hphp/runtime/server/source-root-info.cpp b/hphp/runtime/server/source-root-info.cpp index 93c2adaf325..0c683d7ba59 100644 --- a/hphp/runtime/server/source-root-info.cpp +++ b/hphp/runtime/server/source-root-info.cpp @@ -254,7 +254,7 @@ SourceRootInfo::parseSandboxServerVariable(const std::string &format) const { // skip trailing / const char *data = m_path.data(); int n = m_path.size() - 1; - assert(data[n] == '/'); + assertx(data[n] == '/'); res.write(data, n); break; } diff --git a/hphp/runtime/server/takeover-agent.cpp b/hphp/runtime/server/takeover-agent.cpp index 20e031155c1..29115de25b5 100644 --- a/hphp/runtime/server/takeover-agent.cpp +++ b/hphp/runtime/server/takeover-agent.cpp @@ -76,7 +76,7 @@ static int fd_transfer_request_handler(const uint8_t* request, String req((const char*)request, request_length, CopyString); String resp; int fd = agent->afdtRequest(req, &resp); - assert(resp.size() <= (int)*response_length); + assertx(resp.size() <= (int)*response_length); memcpy(response, resp.data(), resp.size()); *response_length = resp.size(); return fd; diff --git a/hphp/runtime/server/transport.cpp b/hphp/runtime/server/transport.cpp index 83161f07c63..695bccb4932 100644 --- a/hphp/runtime/server/transport.cpp +++ b/hphp/runtime/server/transport.cpp @@ -127,7 +127,7 @@ std::string Transport::getCommand() { // copied and re-factored from clearsilver-0.10.5/cgi/cgi.c void Transport::urlUnescape(char *value) { - assert(value && *value); // check before calling this function + assertx(value && *value); // check before calling this function int i = 0, o = 0; unsigned char *s = (unsigned char *)value; @@ -175,7 +175,7 @@ void Transport::parseQuery(char *query, ParamMap ¶ms) { void Transport::parseGetParams() { if (m_url == nullptr) { const char *url = getServerObject(); - assert(url); + assertx(url); const char *p = strchr(url, '?'); if (p) { @@ -190,7 +190,7 @@ void Transport::parseGetParams() { void Transport::parsePostParams() { if (!m_postDataParsed) { - assert(m_postData == nullptr); + assertx(m_postData == nullptr); size_t size; const char *data = (const char *)getPostData(size); if (data && *data && size) { @@ -206,7 +206,7 @@ void Transport::parsePostParams() { bool Transport::paramExists(const char *name, Method method /* = Method::GET */) { - assert(name && *name); + assertx(name && *name); if (method == Method::GET || method == Method::AUTO) { if (m_url == nullptr) { parseGetParams(); @@ -230,7 +230,7 @@ bool Transport::paramExists(const char *name, std::string Transport::getParam(const char *name, Method method /* = Method::GET */) { - assert(name && *name); + assertx(name && *name); if (method == Method::GET || method == Method::AUTO) { if (m_url == nullptr) { @@ -346,8 +346,8 @@ bool Transport::splitHeader(const String& header, String &name, const char *&val } void Transport::addHeaderNoLock(const char *name, const char *value) { - assert(name && *name); - assert(value); + assertx(name && *name); + assertx(value); if (!m_firstHeaderSet) { m_firstHeaderSet = true; @@ -375,8 +375,8 @@ void Transport::addHeaderNoLock(const char *name, const char *value) { } void Transport::addHeader(const char *name, const char *value) { - assert(name && *name); - assert(value); + assertx(name && *name); + assertx(value); addHeaderNoLock(name, value); } @@ -389,8 +389,8 @@ void Transport::addHeader(const String& header) { } void Transport::replaceHeader(const char *name, const char *value) { - assert(name && *name); - assert(value); + assertx(name && *name); + assertx(value); m_responseHeaders[name].clear(); addHeaderNoLock(name, value); } @@ -432,7 +432,7 @@ bool Transport::acceptEncoding(const char *encoding) { // compress;q=0.5, gzip;q=1.0 // For now, we don't care about the qvalue - assert(encoding && *encoding); + assertx(encoding && *encoding); std::string header = getHeader("Accept-Encoding"); // Handle leading and trailing quotes @@ -451,7 +451,7 @@ bool Transport::acceptEncoding(const char *encoding) { auto& cToken = cTokens[i]; std::vector scTokens; folly::split(';', cToken, scTokens); - assert(scTokens.size() > 0); + assertx(scTokens.size() > 0); // lhs contains the encoding // rhs, if it exists, contains the qvalue std::string lhs = boost::trim_copy(scTokens[0]); @@ -463,7 +463,7 @@ bool Transport::acceptEncoding(const char *encoding) { } bool Transport::cookieExists(const char *name) { - assert(name && *name); + assertx(name && *name); std::string header = getHeader("Cookie"); int len = strlen(name); bool hasValue = (strchr(name, '=') != nullptr); @@ -482,7 +482,7 @@ bool Transport::cookieExists(const char *name) { } std::string Transport::getCookie(const std::string &name) { - assert(!name.empty()); + assertx(!name.empty()); std::string header = getHeader("Cookie"); for (size_t pos = header.find(name); pos != std::string::npos; pos = header.find(name, pos + 1)) { @@ -499,7 +499,7 @@ std::string Transport::getCookie(const std::string &name) { } bool Transport::decideCompression() { - assert(m_compressionDecision == CompressionDecision::NotDecidedYet); + assertx(m_compressionDecision == CompressionDecision::NotDecidedYet); if (!RuntimeOption::ForceCompressionURL.empty() && getCommand() == RuntimeOption::ForceCompressionURL) { @@ -787,7 +787,7 @@ void Transport::prepareHeaders(bool compressed, bool chunked, auto const decrypted = HHVM_FN(openssl_decrypt)( encrypted, cipher, key, k_OPENSSL_RAW_DATA, iv ).toString(); - assert(decrypted.get()->same(ip.get())); + assertx(decrypted.get()->same(ip.get())); } addHeaderImpl("X-FB-Debug", output.c_str()); } @@ -856,7 +856,7 @@ StringHolder Transport::prepareResponse(const void* data, StringHolder response((const char*)data, size); // we don't use chunk encoding to send anything pre-compressed - assert(!compressed || !m_chunkedEncoding); + assertx(!compressed || !m_chunkedEncoding); if (m_compressionDecision == CompressionDecision::NotDecidedYet) { decideCompression(); @@ -1032,10 +1032,10 @@ void Transport::sendRaw(void *data, int size, int code /* = 200 */, if (m_chunkedEncoding) { chunked = true; - assert(!compressed); + assertx(!compressed); } else if (chunked) { m_chunkedEncoding = true; - assert(!compressed); + assertx(!compressed); } sendRawInternal(data, size, code, compressed, codeInfo); @@ -1095,7 +1095,7 @@ void Transport::sendRawInternal(const void *data, int size, void Transport::onSendEnd() { bool eomSent = false; if ((m_compressor || m_brotliCompressor) && m_chunkedEncoding) { - assert(m_headerSent); + assertx(m_headerSent); bool compressed = false; StringHolder response = prepareResponse("", 0, compressed, true); sendImpl(response.data(), response.size(), m_responseCode, true, true); diff --git a/hphp/runtime/server/virtual-host.cpp b/hphp/runtime/server/virtual-host.cpp index 6d4f189847c..da5707b1ff2 100644 --- a/hphp/runtime/server/virtual-host.cpp +++ b/hphp/runtime/server/virtual-host.cpp @@ -89,13 +89,13 @@ int64_t VirtualHost::GetLowestMaxPostSize() { int64_t VirtualHost::GetMaxPostSize() { const VirtualHost *vh = GetCurrent(); - assert(vh); + assertx(vh); return vh->getMaxPostSize(); } int64_t VirtualHost::GetUploadMaxFileSize() { const VirtualHost *vh = GetCurrent(); - assert(vh); + assertx(vh); if (vh->m_runtimeOption.uploadMaxFileSize != -1) { return vh->m_runtimeOption.uploadMaxFileSize; } @@ -104,7 +104,7 @@ int64_t VirtualHost::GetUploadMaxFileSize() { void VirtualHost::UpdateSerializationSizeLimit() { const VirtualHost *vh = GetCurrent(); - assert(vh); + assertx(vh); if (vh->m_runtimeOption.serializationSizeLimit != StringData::MaxSize) { VariableSerializer::serializationSizeLimit = vh->m_runtimeOption.serializationSizeLimit; @@ -119,7 +119,7 @@ bool VirtualHost::alwaysDecodePostData(const String& origPath) const { const std::vector &VirtualHost::GetAllowedDirectories() { const VirtualHost *vh = GetCurrent(); - assert(vh); + assertx(vh); if (!vh->m_runtimeOption.allowedDirectories.empty()) { return vh->m_runtimeOption.allowedDirectories; } @@ -191,7 +191,7 @@ void VirtualHost::initRuntimeOption(const IniSetting::Map& ini, const Hdf& vh) { m_documentRoot.pop_back(); // Make sure we've not converted "/" to "" (which is why we're checking // length() > 1 instead of !empty() above) - assert(!m_documentRoot.empty()); + assertx(!m_documentRoot.empty()); } } @@ -366,7 +366,7 @@ bool VirtualHost::match(const String &host) const { } static int get_backref(const char **s) { - assert('0' <= **s && **s <= '9'); + assertx('0' <= **s && **s <= '9'); int val = **s - '0'; *s += 1; if ('0' <= **s && **s <= '9') { @@ -504,7 +504,7 @@ std::string VirtualHost::serverName(const std::string &host) const { // query string filter std::string VirtualHost::filterUrl(const std::string &url) const { - assert(!m_queryStringFilters.empty()); + assertx(!m_queryStringFilters.empty()); for (unsigned int i = 0; i < m_queryStringFilters.size(); i++) { const QueryStringFilter &filter = m_queryStringFilters[i]; diff --git a/hphp/runtime/server/xbox-server.cpp b/hphp/runtime/server/xbox-server.cpp index da4cb7a67ae..9f27817a832 100644 --- a/hphp/runtime/server/xbox-server.cpp +++ b/hphp/runtime/server/xbox-server.cpp @@ -225,7 +225,7 @@ bool XboxServer::SendMessage(const String& message, job = new XboxTransport(message.toCppString()); job->incRefCount(); // paired with worker's decRefCount() job->incRefCount(); // paired with decRefCount() at below - assert(s_dispatcher); + assertx(s_dispatcher); s_dispatcher->enqueue(job); } @@ -309,7 +309,7 @@ bool XboxServer::PostMessage(const String& message, XboxTransport *job = new XboxTransport(message.toCppString()); job->incRefCount(); // paired with worker's decRefCount() - assert(s_dispatcher); + assertx(s_dispatcher); s_dispatcher->enqueue(job); return true; @@ -398,7 +398,7 @@ Resource XboxServer::TaskStart(const String& msg, event->setJob(job); } - assert(s_dispatcher); + assertx(s_dispatcher); s_dispatcher->enqueue(job); return Resource(std::move(task)); @@ -428,7 +428,7 @@ void XboxServer::TaskStartFromNonRequest( XboxTransport *job = new XboxTransport(msg, reqInitDoc); job->incRefCount(); // paired with worker's decRefCount() - assert(s_dispatcher); + assertx(s_dispatcher); s_dispatcher->enqueue(job); return; } diff --git a/hphp/runtime/server/xbox-server.h b/hphp/runtime/server/xbox-server.h index c51debc93ce..82e671986da 100644 --- a/hphp/runtime/server/xbox-server.h +++ b/hphp/runtime/server/xbox-server.h @@ -157,7 +157,7 @@ struct XboxTransport final : Transport, Synchronizable { ++m_refCount; } void decRefCount() { - assert(m_refCount.load()); + assertx(m_refCount.load()); if (--m_refCount == 0) { delete this; } diff --git a/hphp/runtime/vm/act-rec-defs.h b/hphp/runtime/vm/act-rec-defs.h index 6762d43048a..51065efbf96 100644 --- a/hphp/runtime/vm/act-rec-defs.h +++ b/hphp/runtime/vm/act-rec-defs.h @@ -37,7 +37,7 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// inline void ActRec::setReturnVMExit() { - assert(isReturnHelper(jit::tc::ustubs().callToExit)); + assertx(isReturnHelper(jit::tc::ustubs().callToExit)); m_sfp = nullptr; m_savedRip = reinterpret_cast(jit::tc::ustubs().callToExit); m_soff = 0; diff --git a/hphp/runtime/vm/act-rec-inl.h b/hphp/runtime/vm/act-rec-inl.h index 2a2f1acbcf4..c24b7752e46 100644 --- a/hphp/runtime/vm/act-rec-inl.h +++ b/hphp/runtime/vm/act-rec-inl.h @@ -81,8 +81,8 @@ inline bool ActRec::isFCallM() const { } inline uint32_t ActRec::encodeNumArgsAndFlags(uint32_t numArgs, Flags flags) { - assert((numArgs & kFlagsMask) == 0); - assert((uint32_t{flags} & kNumArgsMask) == 0); + assertx((numArgs & kFlagsMask) == 0); + assertx((uint32_t{flags} & kNumArgsMask) == 0); return numArgs | flags; } @@ -111,7 +111,7 @@ inline void ActRec::setFCallM() { } inline void ActRec::setResumed() { - assert((flags() & ~(IsFCallAwait | UseWeakTypes | DynamicCall)) + assertx((flags() & ~(IsFCallAwait | UseWeakTypes | DynamicCall)) == Flags::None); m_numArgsAndFlags = encodeNumArgsAndFlags( numArgs(), @@ -120,7 +120,7 @@ inline void ActRec::setResumed() { } inline void ActRec::setFCallAwait() { - assert((flags() & ~(UseWeakTypes | DynamicCall)) == Flags::None); + assertx((flags() & ~(UseWeakTypes | DynamicCall)) == Flags::None); m_numArgsAndFlags = encodeNumArgsAndFlags( numArgs(), static_cast(IsFCallAwait | (flags() & (UseWeakTypes | DynamicCall))) @@ -134,7 +134,7 @@ inline void ActRec::setMagicDispatch(StringData* invName) { } inline StringData* ActRec::clearMagicDispatch() { - assert(magicDispatch()); + assertx(magicDispatch()); auto const invName = getInvName(); m_numArgsAndFlags = encodeNumArgsAndFlags( numArgs(), @@ -204,12 +204,12 @@ inline ObjectData* ActRec::getThisUnsafe() const { } inline ObjectData* ActRec::getThis() const { - assert(hasThis()); + assertx(hasThis()); return m_thisUnsafe; } inline Class* ActRec::getClass() const { - assert(hasClass()); + assertx(hasClass()); return reinterpret_cast( reinterpret_cast(m_clsUnsafe) - kHasClassBit); } @@ -236,23 +236,23 @@ inline void ActRec::trashVarEnv() { } inline bool ActRec::checkVarEnv() const { - assert(m_varEnv != reinterpret_cast(kTrashedVarEnvSlot)); + assertx(m_varEnv != reinterpret_cast(kTrashedVarEnvSlot)); return true; } inline bool ActRec::hasVarEnv() const { - assert(checkVarEnv()); - assert(!magicDispatch()); + assertx(checkVarEnv()); + assertx(!magicDispatch()); return m_varEnv && !(reinterpret_cast(m_varEnv) & kExtraArgsBit); } inline bool ActRec::hasExtraArgs() const { - assert(checkVarEnv()); + assertx(checkVarEnv()); return reinterpret_cast(m_extraArgs) & kExtraArgsBit; } inline VarEnv* ActRec::getVarEnv() const { - assert(hasVarEnv()); + assertx(hasVarEnv()); return m_varEnv; } @@ -263,8 +263,8 @@ inline ExtraArgs* ActRec::getExtraArgs() const { } inline StringData* ActRec::getInvName() const { - assert(magicDispatch()); - assert(checkVarEnv()); + assertx(magicDispatch()); + assertx(checkVarEnv()); return m_invName; } diff --git a/hphp/runtime/vm/act-rec.cpp b/hphp/runtime/vm/act-rec.cpp index 770144c5d62..aebdae1ee0a 100644 --- a/hphp/runtime/vm/act-rec.cpp +++ b/hphp/runtime/vm/act-rec.cpp @@ -54,8 +54,8 @@ bool isDebuggerReturnHelper(void* address) { /////////////////////////////////////////////////////////////////////////////// void ActRec::setReturn(ActRec* fp, PC pc, void* retAddr) { - assert(fp->func()->contains(pc)); - assert(isReturnHelper(retAddr)); + assertx(fp->func()->contains(pc)); + assertx(isReturnHelper(retAddr)); m_sfp = fp; m_savedRip = reinterpret_cast(retAddr); m_soff = Offset(pc - fp->func()->getEntry()); @@ -74,7 +74,7 @@ bool ActRec::skipFrame() const { /////////////////////////////////////////////////////////////////////////////// TypedValue* ActRec::getExtraArg(unsigned ind) const { - assert(hasExtraArgs() || hasVarEnv()); + assertx(hasExtraArgs() || hasVarEnv()); return hasExtraArgs() ? getExtraArgs()->getExtraArg(ind) : hasVarEnv() ? getVarEnv()->getExtraArg(ind) : static_cast(nullptr); diff --git a/hphp/runtime/vm/as.cpp b/hphp/runtime/vm/as.cpp index 6df6fc58d34..5dfe79168a0 100644 --- a/hphp/runtime/vm/as.cpp +++ b/hphp/runtime/vm/as.cpp @@ -217,7 +217,7 @@ struct Input { (i >= 'A' && i <= 'F'); }; auto hex_val = [&] (int i) -> uint32_t { - assert(is_hex(i)); + assertx(is_hex(i)); return i >= '0' && i <= '9' ? i - '0' : i >= 'a' && i <= 'f' ? i - 'a' + 10 : i - 'A' + 10; }; @@ -472,7 +472,7 @@ struct StackDepth { void addListener(AsmState& as, StackDepth* target); void setBase(AsmState& as, int stackDepth); int absoluteDepth() { - assert(baseValue.hasValue()); + assertx(baseValue.hasValue()); return baseValue.value() + currentOffset; } @@ -657,7 +657,7 @@ struct AsmState { // Base value still unknown, this will need to be updated later. // Store the FPIEnt's index in the FuncEmitter's entry table. - assert(&fe->fpitab[fe->fpitab.size()-1] == &ent); + assertx(&fe->fpitab[fe->fpitab.size()-1] == &ent); fpiToUpdate.emplace_back(fe->fpitab.size() - 1, reg.stackDepth); } @@ -667,7 +667,7 @@ struct AsmState { } void finishClass() { - assert(!fe); + assertx(!fe); ue->addPreClassEmitter(pce); pce = 0; enumTySet = false; @@ -2494,7 +2494,7 @@ void parse_constant(AsmState& as) { * No-op, for backward compat */ void parse_default_ctor(AsmState& as) { - assert(!as.fe && as.pce); + assertx(!as.fe && as.pce); as.in.expectWs(';'); } diff --git a/hphp/runtime/vm/async-flow-stepper.cpp b/hphp/runtime/vm/async-flow-stepper.cpp index 4e3faebeba6..9746fc4004b 100644 --- a/hphp/runtime/vm/async-flow-stepper.cpp +++ b/hphp/runtime/vm/async-flow-stepper.cpp @@ -27,7 +27,7 @@ namespace HPHP { TRACE_SET_MOD(debuggerflow); c_WaitableWaitHandle *objToWaitableWaitHandle(const Object& o) { - assert(o->instanceof(c_WaitableWaitHandle::classof())); + assertx(o->instanceof(c_WaitableWaitHandle::classof())); return static_cast(o.get()); } @@ -208,7 +208,7 @@ void AsyncFlowStepper::handleBlockedAwaitOpcode(PC pc) { // This is required because async frame ActRec's address // is used for m_asyncResumableId. void AsyncFlowStepper::stepOverAwaitOpcode() { - assert(vmfp()->func()->isAsyncFunction()); + assertx(vmfp()->func()->isAsyncFunction()); m_stage = AsyncStepperStage::StepOverAwait; // Request interrupt opcode callback after "await" instruction @@ -227,10 +227,10 @@ void AsyncFlowStepper::captureResumeIdAfterAwait() { // Set guard internal breakpoint at async operation // resume point to continue stepping. void AsyncFlowStepper::setResumeInternalBreakpoint(PC pc) { - assert(decode_op(pc) == Op::Await); + assertx(decode_op(pc) == Op::Await); auto resumeInstPc = pc + instrLen(pc); - assert(vmfp()->func()->unit()->offsetOf(resumeInstPc) + assertx(vmfp()->func()->unit()->offsetOf(resumeInstPc) != InvalidAbsoluteOffset); TRACE(2, "Setup internal breakpoint after await at '%s' offset %d\n", @@ -252,8 +252,8 @@ bool AsyncFlowStepper::didResumeBreakpointTrigger(PC pc) { } const ActRec* AsyncFlowStepper::getAsyncResumableId(const ActRec* fp) { - assert(fp->resumed()); - assert(fp->func()->isResumable()); + assertx(fp->resumed()); + assertx(fp->func()->isResumable()); return fp; } diff --git a/hphp/runtime/vm/bc-pattern.cpp b/hphp/runtime/vm/bc-pattern.cpp index c352473a066..4e61a49c279 100644 --- a/hphp/runtime/vm/bc-pattern.cpp +++ b/hphp/runtime/vm/bc-pattern.cpp @@ -105,7 +105,7 @@ void BCPattern::matchAnchored(const Expr& pattern, if ((pos->op() == Op::JmpZ || pos->op() == Op::JmpNZ)) { // Match the taken block, if there is one. auto off = instrJumpOffset(inst); - assert(off); + assertx(off); auto res = result; matchAnchored(pos->getTaken(), inst + *off, end, res); diff --git a/hphp/runtime/vm/bc-pattern.h b/hphp/runtime/vm/bc-pattern.h index b90a72fa52a..dcc44211c6a 100644 --- a/hphp/runtime/vm/bc-pattern.h +++ b/hphp/runtime/vm/bc-pattern.h @@ -93,7 +93,7 @@ struct BCPattern { } Atom& taken(std::initializer_list pattern) { - assert(m_op == Op::JmpZ || m_op == Op::JmpNZ); + assertx(m_op == Op::JmpZ || m_op == Op::JmpNZ); m_taken = pattern; return *this; diff --git a/hphp/runtime/vm/blob-helper.h b/hphp/runtime/vm/blob-helper.h index aac4e393ca5..624d2e21497 100644 --- a/hphp/runtime/vm/blob-helper.h +++ b/hphp/runtime/vm/blob-helper.h @@ -134,7 +134,7 @@ struct BlobEncoder { void encode(DataType t) { // always encode DataType as int8 even if it's a bigger size. - assert(DataType(int8_t(t)) == t); + assertx(DataType(int8_t(t)) == t); encode(int8_t(t)); } @@ -255,7 +255,7 @@ struct BlobDecoder { {} void assertDone() { - assert(m_p >= m_last); + assertx(m_p >= m_last); } // See encode() in BlobEncoder for why this only allows integral @@ -305,7 +305,7 @@ struct BlobDecoder { tvWriteUninit(tv); String s = decodeString(); - assert(!!s); + assertx(!!s); if (s.empty()) return; tvAsVariant(&tv) = @@ -405,7 +405,7 @@ private: String s = String(sz, ReserveString); char* pch = s.mutableData(); - assert(m_last - m_p >= sz); + assertx(m_last - m_p >= sz); std::copy(m_p, m_p + sz, pch); m_p += sz; s.setSize(sz); diff --git a/hphp/runtime/vm/bytecode.cpp b/hphp/runtime/vm/bytecode.cpp index d07040abf14..efed283de80 100644 --- a/hphp/runtime/vm/bytecode.cpp +++ b/hphp/runtime/vm/bytecode.cpp @@ -260,12 +260,12 @@ static inline ActRec* arFromInstr(PC pc) { // Find the AR for the current FPI region by indexing from sp static inline ActRec* arFromSp(int32_t n) { auto ar = reinterpret_cast(vmStack().top() + n); - assert(ar == arFromInstr(vmpc())); + assertx(ar == arFromInstr(vmpc())); return ar; } ALWAYS_INLINE MOpMode fpass_mode(ActRec* ar, int paramId) { - assert(paramId < ar->numArgs()); + assertx(paramId < ar->numArgs()); return ar->m_func->byRef(paramId) ? MOpMode::Define : MOpMode::Warn; } @@ -313,7 +313,7 @@ template struct imm_array { ALWAYS_INLINE local_var decode_local(PC& pc) { auto la = decode_iva(pc); - assert(la < vmfp()->m_func->numLocals()); + assertx(la < vmfp()->m_func->numLocals()); return local_var{frame_local(vmfp(), la), safe_cast(la)}; } @@ -360,7 +360,7 @@ static inline Class* frameStaticClass(ActRec* fp) { const StaticString s_GLOBALS("GLOBALS"); void VarEnv::createGlobal() { - assert(!g_context->m_globalVarEnv); + assertx(!g_context->m_globalVarEnv); g_context->m_globalVarEnv = req::make_raw(); } @@ -383,7 +383,7 @@ VarEnv::VarEnv(ActRec* fp, ExtraArgs* eArgs) , m_depth(1) , m_global(false) { - assert(fp->func()->attrs() & AttrMayUseVV); + assertx(fp->func()->attrs() & AttrMayUseVV); TRACE(3, "Creating lazily attached VarEnv %p on stack\n", this); } @@ -393,9 +393,9 @@ VarEnv::VarEnv(const VarEnv* varEnv, ActRec* fp) , m_depth(1) , m_global(false) { - assert(varEnv->m_depth == 1); - assert(!varEnv->m_global); - assert(fp->func()->attrs() & AttrMayUseVV); + assertx(varEnv->m_depth == 1); + assertx(!varEnv->m_global); + assertx(fp->func()->attrs() & AttrMayUseVV); TRACE(3, "Cloning VarEnv %p to %p\n", varEnv, this); } @@ -404,7 +404,7 @@ VarEnv::~VarEnv() { TRACE(3, "Destroying VarEnv %p [%s]\n", this, isGlobalScope() ? "global scope" : "local scope"); - assert(isGlobalScope() == (g_context->m_globalVarEnv == this)); + assertx(isGlobalScope() == (g_context->m_globalVarEnv == this)); if (isGlobalScope()) { /* @@ -441,9 +441,9 @@ void VarEnv::enterFP(ActRec* oldFP, ActRec* newFP) { this, isGlobalScope() ? "global scope" : "local scope", int(newFP->m_func->numNamedLocals()), newFP); - assert(newFP); + assertx(newFP); if (oldFP == nullptr) { - assert(isGlobalScope() && m_depth == 0); + assertx(isGlobalScope() && m_depth == 0); } else { assertx(m_depth >= 1); assertx(g_context->getPrevVMStateSkipFrame(newFP) == oldFP); @@ -458,7 +458,7 @@ void VarEnv::enterFP(ActRec* oldFP, ActRec* newFP) { m_nvTable.detach(oldFP); } - assert(newFP->func()->attrs() & AttrMayUseVV); + assertx(newFP->func()->attrs() & AttrMayUseVV); m_nvTable.attach(newFP); m_depth++; } @@ -468,15 +468,15 @@ void VarEnv::exitFP(ActRec* fp) { this, isGlobalScope() ? "global scope" : "local scope", fp); - assert(fp); - assert(m_depth > 0); + assertx(fp); + assertx(m_depth > 0); m_depth--; m_nvTable.detach(fp); if (m_depth == 0) { if (m_extraArgs) { - assert(!isGlobalScope()); + assertx(!isGlobalScope()); const auto numExtra = fp->numArgs() - fp->m_func->numNonVariadicParams(); ExtraArgs::deallocate(m_extraArgs, numExtra); } @@ -549,7 +549,7 @@ Array VarEnv::getDefinedVariables() const { { // Make result independent of the hashtable implementation. ArrayData* sorted = ret->escalateForSort(SORTFUNC_KSORT); - assert(sorted == ret.get() || sorted->hasExactlyOneRef()); + assertx(sorted == ret.get() || sorted->hasExactlyOneRef()); SCOPE_EXIT { if (sorted != ret.get()) { ret = Array::attach(sorted); @@ -570,7 +570,7 @@ ExtraArgs::ExtraArgs() {} ExtraArgs::~ExtraArgs() {} void* ExtraArgs::allocMem(unsigned nargs) { - assert(nargs > 0); + assertx(nargs > 0); return req::malloc( sizeof(TypedValue) * nargs + sizeof(ExtraArgs), type_scan::getIndexForMalloc< @@ -598,7 +598,7 @@ ExtraArgs* ExtraArgs::allocateUninit(unsigned nargs) { } void ExtraArgs::deallocate(ExtraArgs* ea, unsigned nargs) { - assert(nargs > 0); + assertx(nargs > 0); for (unsigned i = 0; i < nargs; ++i) { tvDecRefGen(ea->m_extraArgs + i); } @@ -705,15 +705,15 @@ void Stack::requestInit() { ), std::memory_order_release ); - assert(!(rds::header()->stackLimitAndSurprise.load() & kSurpriseFlagMask)); + assertx(!(rds::header()->stackLimitAndSurprise.load() & kSurpriseFlagMask)); // Because of the surprise page at the bottom of the stack we lose an // additional 256 elements which must be taken into account when checking for // overflow. UNUSED size_t maxelms = RuntimeOption::EvalVMStackElms - sSurprisePageSize / sizeof(TypedValue); - assert(!wouldOverflow(maxelms - 1)); - assert(wouldOverflow(maxelms)); + assertx(!wouldOverflow(maxelms - 1)); + assertx(wouldOverflow(maxelms)); } void Stack::requestExit() { @@ -826,38 +826,38 @@ static std::string toStringElm(const TypedValue* tv) { continue; case KindOfPersistentVec: case KindOfVec: - assert(tv->m_data.parr->isVecArray()); - assert(tv->m_data.parr->checkCount()); + assertx(tv->m_data.parr->isVecArray()); + assertx(tv->m_data.parr->checkCount()); os << tv->m_data.parr; print_count(); os << ":Vec"; continue; case KindOfPersistentDict: case KindOfDict: - assert(tv->m_data.parr->isDict()); - assert(tv->m_data.parr->checkCount()); + assertx(tv->m_data.parr->isDict()); + assertx(tv->m_data.parr->checkCount()); os << tv->m_data.parr; print_count(); os << ":Dict"; continue; case KindOfPersistentKeyset: case KindOfKeyset: - assert(tv->m_data.parr->isKeyset()); - assert(tv->m_data.parr->checkCount()); + assertx(tv->m_data.parr->isKeyset()); + assertx(tv->m_data.parr->checkCount()); os << tv->m_data.parr; print_count(); os << ":Keyset"; continue; case KindOfPersistentArray: case KindOfArray: - assert(tv->m_data.parr->isPHPArray()); - assert(tv->m_data.parr->checkCount()); + assertx(tv->m_data.parr->isPHPArray()); + assertx(tv->m_data.parr->checkCount()); os << tv->m_data.parr; print_count(); os << ":Array"; continue; case KindOfObject: - assert(tv->m_data.pobj->checkCount()); + assertx(tv->m_data.pobj->checkCount()); os << tv->m_data.pobj; print_count(); os << ":Object(" @@ -865,7 +865,7 @@ static std::string toStringElm(const TypedValue* tv) { << ")"; continue; case KindOfResource: - assert(tv->m_data.pres->checkCount()); + assertx(tv->m_data.pres->checkCount()); os << tv->m_data.pres; print_count(); os << ":Resource(" @@ -895,7 +895,7 @@ static std::string toStringIter(const Iter* it, bool itRef) { case ArrayIter::TypeIterator: return "I:Iterator"; } - assert(false); + assertx(false); return "I:?"; } @@ -906,7 +906,7 @@ static std::string toStringIter(const Iter* it, bool itRef) { * was initialized with IterInit*. */ static bool checkIterScope(const Func* f, Offset o, Id iterId, bool& itRef) { - assert(o >= f->base() && o < f->past()); + assertx(o >= f->base() && o < f->past()); for (auto const& eh : f->ehtab()) { if (eh.m_base <= o && o < eh.m_past && eh.m_iterId == iterId) { @@ -920,7 +920,7 @@ static bool checkIterScope(const Func* f, Offset o, Id iterId, bool& itRef) { static void toStringFrame(std::ostream& os, const ActRec* fp, int offset, const TypedValue* ftop, const std::string& prefix, bool isTop = true) { - assert(fp); + assertx(fp); // Use depth-first recursion to output the most deeply nested stack frame // first. @@ -935,7 +935,7 @@ static void toStringFrame(std::ostream& os, const ActRec* fp, os << prefix; const Func* func = fp->m_func; - assert(func); + assertx(func); func->validate(); std::string funcName(func->fullName()->data()); os << "{func:" << funcName @@ -1046,12 +1046,12 @@ TypedValue* Stack::anyFrameStackBase(const ActRec* fp) { } TypedValue* Stack::frameStackBase(const ActRec* fp) { - assert(!fp->resumed()); + assertx(!fp->resumed()); return (TypedValue*)fp - fp->func()->numSlotsInFrame(); } TypedValue* Stack::resumableStackBase(const ActRec* fp) { - assert(fp->resumed()); + assertx(fp->resumed()); auto sfp = fp->sfp(); if (sfp) { // The non-reentrant case occurs when a non-async or async generator is @@ -1059,7 +1059,7 @@ TypedValue* Stack::resumableStackBase(const ActRec* fp) { // value on the stack that becomes part of the generator's stack. So we // find the caller's FP, compensate for its locals and iterators, and then // we've found the base of the generator's stack. - assert(fp->func()->isGenerator()); + assertx(fp->func()->isGenerator()); // Since resumables are stored on the heap, we need to go back in the // callstack a bit to find the base of the stack. Unfortunately, due to @@ -1074,7 +1074,7 @@ TypedValue* Stack::resumableStackBase(const ActRec* fp) { // or async generator. We simply use the top of stack of the previous VM // frame (since the ActRec, locals, and iters for this frame do not reside // on the VM stack). - assert(fp->func()->isAsync()); + assertx(fp->func()->isAsync()); return g_context.getNoCheck()->m_nestedVMs.back().sp; } } @@ -1102,14 +1102,14 @@ Array getDefinedVariables(const ActRec* fp) { NEVER_INLINE static void shuffleExtraStackArgs(ActRec* ar) { const Func* func = ar->m_func; - assert(func); + assertx(func); // the last (variadic) param is included in numParams (since it has a // name), but the arg in that slot should be included as the first // element of the variadic array const auto numArgs = ar->numArgs(); const auto numVarArgs = numArgs - func->numNonVariadicParams(); - assert(numVarArgs > 0); + assertx(numVarArgs > 0); const auto takesVariadicParam = func->hasVariadicCaptureParam(); auto& stack = vmStack(); @@ -1143,7 +1143,7 @@ static void shuffleExtraStackArgs(ActRec* ar) { } // leave ar->numArgs reflecting the actual number of args passed } else { - assert(takesVariadicParam); // called only if extra args are used + assertx(takesVariadicParam); // called only if extra args are used auto tvArgs = reinterpret_cast(ar) - numArgs + numVarArgs - 1; VArrayInit ai{numVarArgs}; for (uint32_t i = 0; i < numVarArgs; ++i) { @@ -1156,13 +1156,13 @@ static void shuffleExtraStackArgs(ActRec* ar) { } else { stack.pushArrayNoRc(ai.create()); } - assert(func->numParams() == (numArgs - numVarArgs + 1)); + assertx(func->numParams() == (numArgs - numVarArgs + 1)); ar->setNumArgs(func->numParams()); } } static void shuffleMagicArgs(ActRec* ar) { - assert(ar->magicDispatch()); + assertx(ar->magicDispatch()); // We need to put this where the first argument is auto const invName = ar->clearMagicDispatch(); @@ -1211,7 +1211,7 @@ static NEVER_INLINE void cleanupParamsAndActRec(Stack& stack, ActRec* ar, ExtraArgs* extraArgs, int* numParams) { - assert(stack.top() + (numParams != nullptr ? (*numParams) : + assertx(stack.top() + (numParams != nullptr ? (*numParams) : extraArgs != nullptr ? ar->m_func->numParams() : ar->numArgs()) == (void*)ar); @@ -1227,13 +1227,13 @@ static NEVER_INLINE void cleanupParamsAndActRec(Stack& stack, static NEVER_INLINE void shuffleMagicArrayArgs(ActRec* ar, const Cell args, Stack& stack, int nregular) { - assert(ar != nullptr && ar->magicDispatch()); - assert(!cellIsNull(&args)); - assert(nregular >= 0); - assert((stack.top() + nregular) == (void*) ar); - assert(isContainer(args)); + assertx(ar != nullptr && ar->magicDispatch()); + assertx(!cellIsNull(&args)); + assertx(nregular >= 0); + assertx((stack.top() + nregular) == (void*) ar); + assertx(isContainer(args)); DEBUG_ONLY const Func* f = ar->m_func; - assert(f && + assertx(f && (f->name()->isame(s___call.get()) || f->name()->isame(s___callStatic.get()))); @@ -1265,7 +1265,7 @@ static NEVER_INLINE void shuffleMagicArrayArgs(ActRec* ar, const Cell args, // Move invName to where the first argument belongs, no need // to incRef/decRef since we are transferring ownership - assert(stack.top() == (void*) ar); + assertx(stack.top() == (void*) ar); stack.pushStringNoRc(invName); // Move argArray to where the second argument belongs. We've already @@ -1280,13 +1280,13 @@ static NEVER_INLINE void shuffleMagicArrayArgs(ActRec* ar, const Cell args, !RuntimeOption::EvalHackArrDVArrs && isArrayType(args.m_type) && args.m_data.parr->isVArray()) { - assert(stack.top() == (void*) ar); + assertx(stack.top() == (void*) ar); stack.pushStringNoRc(invName); stack.pushArray(args.m_data.parr); } else if (nregular == 0 && RuntimeOption::EvalHackArrDVArrs && isVecType(args.m_type)) { - assert(stack.top() == (void*) ar); + assertx(stack.top() == (void*) ar); stack.pushStringNoRc(invName); stack.pushVec(args.m_data.parr); } else { @@ -1301,7 +1301,7 @@ static NEVER_INLINE void shuffleMagicArrayArgs(ActRec* ar, const Cell args, for (int i = 0; i < nregular; ++i) { stack.popTV(); } - assert(stack.top() == (void*) ar); + assertx(stack.top() == (void*) ar); stack.pushStringNoRc(invName); for (ArrayIter iter(args); iter; ++iter) { ai.appendWithRef(iter.secondValPlus()); @@ -1322,7 +1322,7 @@ static void raiseFPassHintWarning(const StringData* fname, uint32_t id, FPassHint hint) { if (!RuntimeOption::EvalWarnOnCallByRefAnnotationMismatch) return; - assert(hint != FPassHint::Any); + assertx(hint != FPassHint::Any); raise_warning( formatParamRefMismatch(fname->data(), id, hint == FPassHint::Cell) ); @@ -1335,13 +1335,13 @@ static void raiseFPassHintWarning(const StringData* fname, uint32_t id, bool prepareArrayArgs(ActRec* ar, const Cell args, Stack& stack, int nregular, bool doCufRefParamChecks, TypedValue* retval, bool checkRefAnnot) { - assert(!cellIsNull(&args)); - assert(nregular >= 0); - assert((stack.top() + nregular) == (void*) ar); + assertx(!cellIsNull(&args)); + assertx(nregular >= 0); + assertx((stack.top() + nregular) == (void*) ar); const Func* const f = ar->m_func; - assert(f); + assertx(f); - assert(isContainer(args)); + assertx(isContainer(args)); int const nargs = nregular + getContainerSize(args); if (UNLIKELY(ar->magicDispatch())) { shuffleMagicArrayArgs(ar, args, stack, nregular); @@ -1415,8 +1415,8 @@ bool prepareArrayArgs(ActRec* ar, const Cell args, Stack& stack, // there are "extra" arguments; passed as standard arguments prior to the // ... unpack operator and/or still remaining in argArray - assert(nargs > nparams); - assert(nextra_regular > 0 || !!iter); + assertx(nargs > nparams); + assertx(nextra_regular > 0 || !!iter); if (LIKELY(f->discardExtraArgs())) { if (UNLIKELY(nextra_regular > 0)) { // if unpacking, any regularly passed arguments on the stack @@ -1464,10 +1464,10 @@ bool prepareArrayArgs(ActRec* ar, const Cell args, Stack& stack, ai.appendWithRef(from); } } - assert(!iter); // iter should now be exhausted + assertx(!iter); // iter should now be exhausted if (hasVarParam) { auto const ad = ai.create(); - assert(ad->hasExactlyOneRef()); + assertx(ad->hasExactlyOneRef()); if (RuntimeOption::EvalHackArrDVArrs) { stack.pushVecNoRc(ad); } else { @@ -1477,7 +1477,7 @@ bool prepareArrayArgs(ActRec* ar, const Cell args, Stack& stack, ar->setNumArgs(nargs); ar->setExtraArgs(extraArgs); } else { - assert(hasVarParam); + assertx(hasVarParam); if (nparams == nregular && !RuntimeOption::EvalHackArrDVArrs && isArrayType(args.m_type) && @@ -1506,9 +1506,9 @@ bool prepareArrayArgs(ActRec* ar, const Cell args, Stack& stack, // eventual decref of arrayArgs. ai.appendWithRef(iter.secondValPlus()); } - assert(!iter); // iter should now be exhausted + assertx(!iter); // iter should now be exhausted auto const ad = ai.create(); - assert(ad->hasExactlyOneRef()); + assertx(ad->hasExactlyOneRef()); if (RuntimeOption::EvalHackArrDVArrs) { stack.pushVecNoRc(ad); } else { @@ -1521,7 +1521,7 @@ bool prepareArrayArgs(ActRec* ar, const Cell args, Stack& stack, } static void prepareFuncEntry(ActRec *ar, PC& pc, StackArgsState stk) { - assert(!ar->resumed()); + assertx(!ar->resumed()); const Func* func = ar->m_func; Offset firstDVInitializer = InvalidAbsoluteOffset; bool raiseMissingArgumentWarnings = false; @@ -1531,7 +1531,7 @@ static void prepareFuncEntry(ActRec *ar, PC& pc, StackArgsState stk) { if (stk == StackArgsState::Trimmed && (ar->func()->attrs() & AttrMayUseVV) && ar->hasExtraArgs()) { - assert(nparams < ar->numArgs()); + assertx(nparams < ar->numArgs()); } else if (UNLIKELY(ar->magicDispatch())) { // shuffleMagicArgs deals with everything. no need for further // argument munging @@ -1547,8 +1547,8 @@ static void prepareFuncEntry(ActRec *ar, PC& pc, StackArgsState stk) { for (int i = nparams; i < nargs; ++i) { stack.popTV(); } ar->setNumArgs(nparams); } else if (stk == StackArgsState::Trimmed) { - assert(nargs == func->numParams()); - assert(((TypedValue*)ar - stack.top()) == func->numParams()); + assertx(nargs == func->numParams()); + assertx(((TypedValue*)ar - stack.top()) == func->numParams()); } else { shuffleExtraStackArgs(ar); } @@ -1616,8 +1616,8 @@ static void prepareFuncEntry(ActRec *ar, PC& pc, StackArgsState stk) { static void dispatch(); void enterVMAtFunc(ActRec* enterFnAr, StackArgsState stk, VarEnv* varEnv) { - assert(enterFnAr); - assert(!enterFnAr->resumed()); + assertx(enterFnAr); + assertx(!enterFnAr->resumed()); Stats::inc(Stats::VMEnter); const bool useJit = RID().getJit() && !RID().getJitFolding(); @@ -1641,7 +1641,7 @@ void enterVMAtFunc(ActRec* enterFnAr, StackArgsState stk, VarEnv* varEnv) { if (UNLIKELY(varEnv != nullptr)) { enterFnAr->setVarEnv(varEnv); - assert(enterFnAr->func()->isPseudoMain()); + assertx(enterFnAr->func()->isPseudoMain()); pushFrameSlots(enterFnAr->func()); auto oldFp = vmfp(); if (UNLIKELY(oldFp && oldFp->skipFrame())) { @@ -1658,7 +1658,7 @@ void enterVMAtFunc(ActRec* enterFnAr, StackArgsState stk, VarEnv* varEnv) { checkStack(vmStack(), enterFnAr->m_func, 0); calleeDynamicCallChecks(enterFnAr); checkForRequiredCallM(enterFnAr); - assert(vmfp()->func()->contains(vmpc())); + assertx(vmfp()->func()->contains(vmpc())); if (useJit) { jit::TCA start = enterFnAr->m_func->getFuncBody(); @@ -1669,9 +1669,9 @@ void enterVMAtFunc(ActRec* enterFnAr, StackArgsState stk, VarEnv* varEnv) { } void enterVMAtCurPC() { - assert(vmfp()); - assert(vmpc()); - assert(vmfp()->func()->contains(vmpc())); + assertx(vmfp()); + assertx(vmpc()); + assertx(vmfp()->func()->contains(vmpc())); Stats::inc(Stats::VMEnter); if (RID().getJit()) { jit::enterTC(); @@ -1706,7 +1706,7 @@ void unwindPreventReturnToTC(ActRec* ar) { auto& ustubs = jit::tc::ustubs(); if (ar->resumed()) { // async functions use callToExit stub - assert(ar->func()->isGenerator()); + assertx(ar->func()->isGenerator()); ar->setJitReturn(ar->func()->isAsync() ? ustubs.asyncGenRetHelper : ustubs.genRetHelper); } else { @@ -1730,7 +1730,7 @@ void debuggerPreventReturnToTC(ActRec* ar) { auto& ustubs = jit::tc::ustubs(); if (ar->resumed()) { // async functions use callToExit stub - assert(ar->func()->isGenerator()); + assertx(ar->func()->isGenerator()); ar->setJitReturn(ar->func()->isAsync() ? ustubs.debuggerAsyncGenRetHelper : ustubs.debuggerGenRetHelper); } else { @@ -1743,7 +1743,7 @@ void debuggerPreventReturnToTC(ActRec* ar) { // return into jitted code and gives the system the proper chance to interpret // blacklisted tracelets. void debuggerPreventReturnsToTC() { - assert(isDebuggerAttached()); + assertx(isDebuggerAttached()); if (!RuntimeOption::EvalJit) return; auto& ec = *g_context; @@ -1766,7 +1766,7 @@ static inline void lookup_var(ActRec* fp, if (id != kInvalidId) { val = frame_local(fp, id); } else { - assert(fp->func()->attrs() & AttrMayUseVV); + assertx(fp->func()->attrs() & AttrMayUseVV); if (fp->hasVarEnv()) { val = fp->m_varEnv->lookup(name); } else { @@ -1785,7 +1785,7 @@ static inline void lookupd_var(ActRec* fp, if (id != kInvalidId) { val = frame_local(fp, id); } else { - assert(func->attrs() & AttrMayUseVV); + assertx(func->attrs() & AttrMayUseVV); if (!fp->hasVarEnv()) { fp->setVarEnv(VarEnv::createLocal(fp)); } @@ -1802,14 +1802,14 @@ static inline void lookupd_var(ActRec* fp, static inline void lookup_gbl(ActRec* /*fp*/, StringData*& name, TypedValue* key, TypedValue*& val) { name = lookup_name(key); - assert(g_context->m_globalVarEnv); + assertx(g_context->m_globalVarEnv); val = g_context->m_globalVarEnv->lookup(name); } static inline void lookupd_gbl(ActRec* /*fp*/, StringData*& name, TypedValue* key, TypedValue*& val) { name = lookup_name(key); - assert(g_context->m_globalVarEnv); + assertx(g_context->m_globalVarEnv); VarEnv* varEnv = g_context->m_globalVarEnv; val = varEnv->lookup(name); if (val == nullptr) { @@ -1885,11 +1885,11 @@ static inline TypedValue* ratchetRefs(TypedValue* result, TypedValue& tvRef, // unconditionally here because we maintain the invariant throughout that // either tvRef is KindOfUninit, or tvRef contains a valid object that // result points to. - assert(result == &tvRef); + assertx(result == &tvRef); return &tvRef2; } - assert(result != &tvRef); + assertx(result != &tvRef); return result; } @@ -1935,7 +1935,7 @@ OPTBLD_INLINE void iopPopU() { } OPTBLD_INLINE void iopPopL(local_var to) { - assert(to.index < vmfp()->m_func->numLocals()); + assertx(to.index < vmfp()->m_func->numLocals()); Cell* fr = vmStack().topC(); if (to->m_type == KindOfRef || vmfp()->m_func->isPseudoMain()) { // Manipulate the ref-counts as if this was a SetL, PopC pair to preserve @@ -1968,7 +1968,7 @@ OPTBLD_INLINE void iopBoxR() { } OPTBLD_INLINE void iopBoxRNop() { - assert(refIsPlausible(*vmStack().topTV())); + assertx(refIsPlausible(*vmStack().topTV())); } OPTBLD_INLINE void iopUnboxR() { @@ -1978,7 +1978,7 @@ OPTBLD_INLINE void iopUnboxR() { } OPTBLD_INLINE void iopUnboxRNop() { - assert(cellIsPlausible(*vmStack().topTV())); + assertx(cellIsPlausible(*vmStack().topTV())); } OPTBLD_INLINE void iopRGetCNop() { @@ -2040,23 +2040,23 @@ OPTBLD_INLINE void iopString(const StringData* s) { } OPTBLD_INLINE void iopArray(const ArrayData* a) { - assert(a->isPHPArray()); - assert(!RuntimeOption::EvalHackArrDVArrs || a->isNotDVArray()); + assertx(a->isPHPArray()); + assertx(!RuntimeOption::EvalHackArrDVArrs || a->isNotDVArray()); vmStack().pushStaticArray(a); } OPTBLD_INLINE void iopDict(const ArrayData* a) { - assert(a->isDict()); + assertx(a->isDict()); vmStack().pushStaticDict(a); } OPTBLD_INLINE void iopKeyset(const ArrayData* a) { - assert(a->isKeyset()); + assertx(a->isKeyset()); vmStack().pushStaticKeyset(a); } OPTBLD_INLINE void iopVec(const ArrayData* a) { - assert(a->isVecArray()); + assertx(a->isVecArray()); vmStack().pushStaticVec(a); } @@ -2108,7 +2108,7 @@ namespace { template ArrayData* newStructArrayImpl(imm_array ids, F f) { auto const n = ids.size; - assert(n > 0 && n <= ArrayData::MaxElemsOnStack); + assertx(n > 0 && n <= ArrayData::MaxElemsOnStack); req::vector names; names.reserve(n); auto unit = vmfp()->m_func->unit(); @@ -2346,7 +2346,7 @@ OPTBLD_FLT_INLINE void iopConcat() { auto const s2 = cellAsVariant(*c2).toString(); auto const s1 = cellAsCVarRef(*c1).toString(); cellAsVariant(*c2) = concat(s2, s1); - assert(c2->m_data.pstr->checkCount()); + assertx(c2->m_data.pstr->checkCount()); vmStack().popC(); } @@ -2358,16 +2358,16 @@ OPTBLD_INLINE void iopConcatN(uint32_t n) { auto const s2 = cellAsVariant(*c2).toString(); auto const s1 = cellAsCVarRef(*c1).toString(); cellAsVariant(*c2) = concat(s2, s1); - assert(c2->m_data.pstr->checkCount()); + assertx(c2->m_data.pstr->checkCount()); } else if (n == 3) { auto const c3 = vmStack().indC(2); auto const s3 = cellAsVariant(*c3).toString(); auto const s2 = cellAsCVarRef(*c2).toString(); auto const s1 = cellAsCVarRef(*c1).toString(); cellAsVariant(*c3) = concat3(s3, s2, s1); - assert(c3->m_data.pstr->checkCount()); + assertx(c3->m_data.pstr->checkCount()); } else { - assert(n == 4); + assertx(n == 4); auto const c3 = vmStack().indC(2); auto const c4 = vmStack().indC(3); auto const s4 = cellAsVariant(*c4).toString(); @@ -2375,7 +2375,7 @@ OPTBLD_INLINE void iopConcatN(uint32_t n) { auto const s2 = cellAsCVarRef(*c2).toString(); auto const s1 = cellAsCVarRef(*c1).toString(); cellAsVariant(*c4) = concat4(s4, s3, s2, s1); - assert(c4->m_data.pstr->checkCount()); + assertx(c4->m_data.pstr->checkCount()); } for (int i = 1; i < n; ++i) { @@ -2590,7 +2590,7 @@ OPTBLD_INLINE void iopCastDArray() { } OPTBLD_INLINE bool cellInstanceOf(TypedValue* tv, const NamedEntity* ne) { - assert(tv->m_type != KindOfRef); + assertx(tv->m_type != KindOfRef); Class* cls = nullptr; switch (tv->m_type) { case KindOfUninit: @@ -2794,7 +2794,7 @@ struct IterBreakElem { OPTBLD_INLINE void iopIterBreak(PC& pc, PC targetpc, imm_array vec) { auto const n = vec.size; - assert(n > 0); + assertx(n > 0); for (auto i = 0; i < n; ++i) { auto e = vec[i]; auto iter = frame_iter(vmfp(), e.iter); @@ -2825,14 +2825,14 @@ OPTBLD_INLINE void iopSwitch(PC origpc, PC& pc, SwitchKind kind, int64_t base, imm_array jmptab) { auto const veclen = jmptab.size; - assert(veclen > 0); + assertx(veclen > 0); TypedValue* val = vmStack().topTV(); if (kind == SwitchKind::Unbounded) { - assert(val->m_type == KindOfInt64); + assertx(val->m_type == KindOfInt64); // Continuation switch: no bounds checking needed int64_t label = val->m_data.num; vmStack().popX(); - assert(label >= 0 && label < veclen); + assertx(label >= 0 && label < veclen); pc = origpc + jmptab[label]; } else { // Generic integer switch @@ -2960,7 +2960,7 @@ void iopSwitch(PC origpc, PC& pc, SwitchKind kind, int64_t base, OPTBLD_INLINE void iopSSwitch(PC origpc, PC& pc, imm_array jmptab) { auto const veclen = jmptab.size; - assert(veclen > 1); + assertx(veclen > 1); unsigned cases = veclen - 1; // the last vector item is the default case Cell* val = tvToCell(vmStack().topTV()); Unit* u = vmfp()->m_func->unit(); @@ -3033,7 +3033,7 @@ OPTBLD_INLINE TCA jitReturnPost(JitReturn retInfo) { // Our return address was smashed by the debugger. Do the work of the // debuggerRetHelper by setting some unwinder RDS info and resuming at // the approprate catch trace. - assert(jit::g_unwind_rds.isInit()); + assertx(jit::g_unwind_rds.isInit()); jit::g_unwind_rds->debuggerReturnSP = vmsp(); jit::g_unwind_rds->debuggerReturnOff = retInfo.soff; return jit::unstashDebuggerCatch(retInfo.fp); @@ -3051,7 +3051,7 @@ OPTBLD_INLINE TCA jitReturnPost(JitReturn retInfo) { // nesting level. The vmJitCalledFrame() check below is only important if // we might throw before returning to the TC, which is guaranteed to not // happen in this situation. - assert(vmfp() == nullptr); + assertx(vmfp() == nullptr); return nullptr; } @@ -3122,28 +3122,28 @@ OPTBLD_INLINE TCA ret(PC& pc) { vmStack().ndiscard(vmfp()->func()->numSlotsInFrame()); vmStack().ret(); *vmStack().topTV() = retval; - assert(vmStack().topTV() == vmfp()->retSlot()); + assertx(vmStack().topTV() == vmfp()->retSlot()); // In case we were called by a jitted FCallAwait, let it know // that we finished eagerly. vmStack().topTV()->m_aux.u_fcallAwaitFlag = 0; } else if (vmfp()->func()->isAsyncFunction()) { // Mark the async function as succeeded and store the return value. - assert(!sfp); + assertx(!sfp); auto wh = frame_afwh(vmfp()); wh->ret(retval); decRefObj(wh); } else if (vmfp()->func()->isAsyncGenerator()) { // Mark the async generator as finished. - assert(isNullType(retval.m_type)); + assertx(isNullType(retval.m_type)); auto const gen = frame_async_generator(vmfp()); auto const eagerResult = gen->ret(); if (eagerResult) { // Eager execution => return StaticWaitHandle. - assert(sfp); + assertx(sfp); vmStack().pushObjectNoRc(eagerResult); } else { // Resumed execution => return control to the scheduler. - assert(!sfp); + assertx(!sfp); } } else if (vmfp()->func()->isNonAsyncGenerator()) { // Mark the generator as finished and store the return value. @@ -3167,8 +3167,8 @@ OPTBLD_INLINE TCA iopRetC(PC& pc) { } OPTBLD_INLINE TCA iopRetV(PC& pc) { - assert(!vmfp()->resumed()); - assert(!vmfp()->func()->isResumable()); + assertx(!vmfp()->resumed()); + assertx(!vmfp()->func()->isResumable()); return ret(pc); } @@ -3223,8 +3223,8 @@ OPTBLD_INLINE TCA iopRetM(PC& pc, uint32_t numRet) { } OPTBLD_INLINE void iopUnwind() { - assert(!g_context->m_faults.empty()); - assert(g_context->m_faults.back().m_raiseOffset != kInvalidOffset); + assertx(!g_context->m_faults.empty()); + assertx(g_context->m_faults.back().m_raiseOffset != kInvalidOffset); throw VMPrepareUnwind(); } @@ -3252,13 +3252,13 @@ OPTBLD_INLINE void iopClsRefGetL(local_var fr, clsref_slot slot) { } static void raise_undefined_local(ActRec* fp, Id pind) { - assert(pind < fp->m_func->numNamedLocals()); + assertx(pind < fp->m_func->numNamedLocals()); raise_notice(Strings::UNDEFINED_VARIABLE, fp->m_func->localVarName(pind)->data()); } static inline void cgetl_inner_body(TypedValue* fr, TypedValue* to) { - assert(fr->m_type != KindOfUninit); + assertx(fr->m_type != KindOfUninit); cellDup(*tvToCell(fr), *to); } @@ -3301,8 +3301,8 @@ OPTBLD_INLINE void iopCGetL2(local_var fr) { } OPTBLD_INLINE void iopPushL(local_var locVal) { - assert(locVal->m_type != KindOfUninit); - assert(locVal->m_type != KindOfRef); + assertx(locVal->m_type != KindOfUninit); + assertx(locVal->m_type != KindOfRef); TypedValue* dest = vmStack().allocTV(); *dest = *locVal; locVal->m_type = KindOfUninit; @@ -3417,7 +3417,7 @@ static inline void baseNGImpl(TypedValue* key, MOpMode mode, SCOPE_EXIT { decRefStr(name); }; if (baseVal == nullptr) { - assert(mode != MOpMode::Define); + assertx(mode != MOpMode::Define); if (mode == MOpMode::Warn) { raise_notice(Strings::UNDEFINED_VARIABLE, name->data()); } @@ -3541,10 +3541,10 @@ static OPTBLD_INLINE void propDispatch(MOpMode mode, TypedValue key, auto result = [&]{ switch (mode) { case MOpMode::None: - assert(!reffy); + assertx(!reffy); return Prop(mstate.tvRef, ctx, mstate.base, key); case MOpMode::Warn: - assert(!reffy); + assertx(!reffy); return Prop(mstate.tvRef, ctx, mstate.base, key); case MOpMode::Define: if (reffy) { @@ -3555,7 +3555,7 @@ static OPTBLD_INLINE void propDispatch(MOpMode mode, TypedValue key, mstate.base, key); } case MOpMode::Unset: - assert(!reffy); + assertx(!reffy); return Prop(mstate.tvRef, ctx, mstate.base, key); case MOpMode::InOut: always_assert_flog(false, "MOpMode::InOut can only occur on Elem"); @@ -3575,7 +3575,7 @@ static OPTBLD_INLINE void propQDispatch(MOpMode mode, TypedValue key, switch (mode) { case MOpMode::None: case MOpMode::Warn: - assert(key.m_type == KindOfPersistentString); + assertx(key.m_type == KindOfPersistentString); result = nullSafeProp(mstate.tvRef, ctx, mstate.base, key.m_data.pstr); break; case MOpMode::Define: @@ -3736,7 +3736,7 @@ void queryMImpl(MemberKey mk, int32_t nDiscard, QueryMOp op) { ? IssetEmptyProp(ctx, mstate.base, key) : IssetEmptyProp(ctx, mstate.base, key); } else { - assert(mcodeIsElem(mk.mcode)); + assertx(mcodeIsElem(mk.mcode)); if (UNLIKELY(checkHACIntishCast())) { result.m_data.num = op == QueryMOp::Empty ? IssetEmptyElem(mstate.base, key) @@ -3770,7 +3770,7 @@ OPTBLD_INLINE void iopVGetM(uint32_t nDiscard, MemberKey mk) { } static void checkFPassHint(ActRec* ar, uint32_t paramId, FPassHint hint) { - assert(paramId < ar->numArgs()); + assertx(paramId < ar->numArgs()); if (!RuntimeOption::EvalWarnOnCallByRefAnnotationMismatch) return; @@ -3884,7 +3884,7 @@ OPTBLD_INLINE void iopUnsetM(uint32_t nDiscard, MemberKey mk) { if (mcodeIsProp(mk.mcode)) { UnsetProp(arGetContextClass(vmfp()), mstate.base, key); } else { - assert(mcodeIsElem(mk.mcode)); + assertx(mcodeIsElem(mk.mcode)); if (UNLIKELY(checkHACIntishCast())) { UnsetElem(mstate.base, key); } else { @@ -3986,7 +3986,7 @@ OPTBLD_INLINE void iopVGetN() { TypedValue* fr = nullptr; lookupd_var(vmfp(), name, to, fr); SCOPE_EXIT { decRefStr(name); }; - assert(fr != nullptr); + assertx(fr != nullptr); tvDecRefGen(to); vgetl_body(fr, to); } @@ -3997,7 +3997,7 @@ OPTBLD_INLINE void iopVGetG() { TypedValue* fr = nullptr; lookupd_gbl(vmfp(), name, to, fr); SCOPE_EXIT { decRefStr(name); }; - assert(fr != nullptr); + assertx(fr != nullptr); tvDecRefGen(to); vgetl_body(fr, to); } @@ -4104,7 +4104,7 @@ OPTBLD_INLINE void iopIsTypeL(local_var loc, IsTypeOp op) { OPTBLD_INLINE void iopIsTypeC(IsTypeOp op) { TypedValue* topTv = vmStack().topTV(); - assert(topTv->m_type != KindOfRef); + assertx(topTv->m_type != KindOfRef); bool ret = isTypeHelper(topTv, op); tvDecRefGen(topTv); topTv->m_data.num = ret; @@ -4347,7 +4347,7 @@ OPTBLD_INLINE void iopArrayIdx() { } OPTBLD_INLINE void iopSetL(local_var to) { - assert(to.index < vmfp()->m_func->numLocals()); + assertx(to.index < vmfp()->m_func->numLocals()); Cell* fr = vmStack().topC(); tvSet(*fr, *to); } @@ -4359,7 +4359,7 @@ OPTBLD_INLINE void iopSetN() { TypedValue* to = nullptr; lookupd_var(vmfp(), name, tv2, to); SCOPE_EXIT { decRefStr(name); }; - assert(to != nullptr); + assertx(to != nullptr); tvSet(*fr, *to); memcpy((void*)tv2, (void*)fr, sizeof(TypedValue)); vmStack().discard(); @@ -4372,7 +4372,7 @@ OPTBLD_INLINE void iopSetG() { TypedValue* to = nullptr; lookupd_gbl(vmfp(), name, tv2, to); SCOPE_EXIT { decRefStr(name); }; - assert(to != nullptr); + assertx(to != nullptr); tvSet(*fr, *to); memcpy((void*)tv2, (void*)fr, sizeof(TypedValue)); vmStack().discard(); @@ -4415,7 +4415,7 @@ OPTBLD_INLINE void iopSetOpN(SetOpOp op) { StringData* name; lookupd_var(vmfp(), name, tv2, to); SCOPE_EXIT { decRefStr(name); }; - assert(to != nullptr); + assertx(to != nullptr); setopBody(tvToCell(to), op, fr); tvDecRefGen(fr); tvDecRefGen(tv2); @@ -4431,7 +4431,7 @@ OPTBLD_INLINE void iopSetOpG(SetOpOp op) { // XXX We're probably not getting warnings totally correct here lookupd_gbl(vmfp(), name, tv2, to); SCOPE_EXIT { decRefStr(name); }; - assert(to != nullptr); + assertx(to != nullptr); setopBody(tvToCell(to), op, fr); tvDecRefGen(fr); tvDecRefGen(tv2); @@ -4483,7 +4483,7 @@ OPTBLD_INLINE void iopIncDecN(IncDecOp op) { decRefStr(name); tvDecRefGen(oldNameCell); }; - assert(local != nullptr); + assertx(local != nullptr); cellCopy(IncDecBody(op, tvToCell(local)), *nameCell); } @@ -4497,7 +4497,7 @@ OPTBLD_INLINE void iopIncDecG(IncDecOp op) { decRefStr(name); tvDecRefGen(oldNameCell); }; - assert(gbl != nullptr); + assertx(gbl != nullptr); cellCopy(IncDecBody(op, tvToCell(gbl)), *nameCell); } @@ -4523,7 +4523,7 @@ OPTBLD_INLINE void iopBindN() { TypedValue* to = nullptr; lookupd_var(vmfp(), name, nameTV, to); SCOPE_EXIT { decRefStr(name); }; - assert(to != nullptr); + assertx(to != nullptr); tvBind(*fr, *to); memcpy((void*)nameTV, (void*)fr, sizeof(TypedValue)); vmStack().discard(); @@ -4536,7 +4536,7 @@ OPTBLD_INLINE void iopBindG() { TypedValue* to = nullptr; lookupd_gbl(vmfp(), name, nameTV, to); SCOPE_EXIT { decRefStr(name); }; - assert(to != nullptr); + assertx(to != nullptr); tvBind(*fr, *to); memcpy((void*)nameTV, (void*)fr, sizeof(TypedValue)); vmStack().discard(); @@ -4584,7 +4584,7 @@ OPTBLD_INLINE void iopUnsetG() { StringData* name = lookup_name(tv1); SCOPE_EXIT { decRefStr(name); }; VarEnv* varEnv = g_context->m_globalVarEnv; - assert(varEnv != nullptr); + assertx(varEnv != nullptr); varEnv->unset(name); vmStack().popC(); } @@ -4601,7 +4601,7 @@ OPTBLD_INLINE ActRec* fPushFuncImpl(const Func* func, int numArgs) { ALWAYS_INLINE std::string concat_arg_list(imm_array args) { auto const n = args.size; - assert(n != 0); + assertx(n != 0); std::string ret; folly::toAppend(args[0], &ret); for (int i = 1; i != n; ++i) folly::toAppend(";", args[i], &ret); @@ -4694,7 +4694,7 @@ OPTBLD_INLINE void iopFPushFunc(uint32_t numArgs, imm_array args) { if (isArrayLikeType(origCell.m_type)) { raise_error("Invalid callable (array)"); } else { - assert(isStringType(origCell.m_type)); + assertx(isStringType(origCell.m_type)); raise_call_to_undefined(origCell.m_data.pstr); } } @@ -4766,14 +4766,14 @@ void fPushObjMethodImpl(StringData* name, decRefObj(obj); throw; } - assert(f); + assertx(f); ActRec* ar = vmStack().allocA(); ar->m_func = f; if (res == LookupResult::MethodFoundNoThis) { decRefObj(obj); ar->setClass(cls); } else { - assert(res == LookupResult::MethodFoundWithThis || + assertx(res == LookupResult::MethodFoundWithThis || res == LookupResult::MagicCallFound); /* Transfer ownership of obj to the ActRec*/ ar->setThis(obj); @@ -4790,7 +4790,7 @@ void fPushObjMethodImpl(StringData* name, } void fPushNullObjMethod(int numArgs) { - assert(SystemLib::s_nullFunc); + assertx(SystemLib::s_nullFunc); ActRec* ar = vmStack().allocA(); ar->m_func = SystemLib::s_nullFunc; ar->trashThis(); @@ -4888,8 +4888,8 @@ void pushClsMethodImpl(Class* cls, } obj = nullptr; } else { - assert(obj); - assert(res == LookupResult::MethodFoundWithThis || + assertx(obj); + assertx(res == LookupResult::MethodFoundWithThis || res == LookupResult::MagicCallFound); obj->incRefCount(); } @@ -4958,7 +4958,7 @@ OPTBLD_INLINE void iopFPushClsMethod(uint32_t numArgs, clsref_slot slot, // pushClsMethodImpl will take care of decReffing name vmStack().ndiscard(1); - assert(cls && name); + assertx(cls && name); pushClsMethodImpl(cls, name, numArgs, false, true); } @@ -5218,7 +5218,7 @@ OPTBLD_INLINE void iopFPassV(ActRec* ar, uint32_t paramId, FPassHint hint) { OPTBLD_INLINE void iopFPassVNop(ActRec* ar, uint32_t paramId, FPassHint hint) { checkFPassHint(ar, paramId, hint); - assert(ar->m_func->byRef(paramId)); + assertx(ar->m_func->byRef(paramId)); } OPTBLD_INLINE void iopFPassR(ActRec* ar, uint32_t paramId, FPassHint hint) { @@ -5301,7 +5301,7 @@ OPTBLD_INLINE void iopFCall(PC& pc, ActRec* ar, uint32_t numArgs) { } else if (!callUsesStrictTypes(vmfp())) { ar->setUseWeakTypes(); } - assert(numArgs == ar->numArgs()); + assertx(numArgs == ar->numArgs()); if (ar->isDynamicCall()) callerDynamicCallChecks(ar->func()); checkStack(vmStack(), ar->m_func, 0); ar->setReturn(vmfp(), pc, jit::tc::ustubs().retHelper); @@ -5317,7 +5317,7 @@ void iopFCallD(PC& pc, ActRec* ar, uint32_t numArgs, (funcName == s_construct.get() && ar->m_func == ar->m_func->cls()->getCtor())); } - assert(numArgs == ar->numArgs()); + assertx(numArgs == ar->numArgs()); if (ar->isDynamicCall()) callerDynamicCallChecks(ar->func()); checkStack(vmStack(), ar->m_func, 0); ar->setReturn(vmfp(), pc, jit::tc::ustubs().retHelper); @@ -5329,9 +5329,9 @@ void iopFCallAwait(PC& pc, ActRec* ar, uint32_t numArgs, const StringData* /*clsName*/, const StringData* funcName) { if (!RuntimeOption::EvalJitEnableRenameFunction && !(ar->m_func->attrs() & AttrInterceptable)) { - assert(ar->m_func->name()->isame(funcName)); + assertx(ar->m_func->name()->isame(funcName)); } - assert(numArgs == ar->numArgs()); + assertx(numArgs == ar->numArgs()); if (ar->isDynamicCall()) callerDynamicCallChecks(ar->func()); checkStack(vmStack(), ar->m_func, 0); ar->setReturn(vmfp(), pc, jit::tc::ustubs().retHelper); @@ -5366,7 +5366,7 @@ void iopFCallBuiltin(uint32_t numArgs, uint32_t numNonDefault, Id id) { if (func->attrs() & AttrParamCoerceModeNull) { ret.m_type = KindOfNull; } else { - assert(func->attrs() & AttrParamCoerceModeFalse); + assertx(func->attrs() & AttrParamCoerceModeFalse); ret.m_type = KindOfBoolean; ret.m_data.num = 0; } @@ -5389,8 +5389,8 @@ enum class CallArrOnInvalidContainer { static bool doFCallArray(PC& pc, ActRec* ar, int numStackValues, CallArrOnInvalidContainer onInvalid, void* ret = nullptr) { - assert(numStackValues >= 1); - assert(ar->numArgs() == numStackValues); + assertx(numStackValues >= 1); + assertx(ar->numArgs() == numStackValues); Cell* c1 = vmStack().topC(); if (UNLIKELY(!isContainer(*c1))) { @@ -5422,7 +5422,7 @@ static bool doFCallArray(PC& pc, ActRec* ar, int numStackValues, SCOPE_EXIT { tvDecRefGen(&args); }; checkStack(vmStack(), func, 0); - assert(!ar->resumed()); + assertx(!ar->resumed()); TRACE(3, "FCallArray: pc %p func %p base %d\n", vmpc(), vmfp()->unit()->entry(), int(vmfp()->m_func->base())); @@ -5455,7 +5455,7 @@ static bool doFCallArray(PC& pc, ActRec* ar, int numStackValues, bool doFCallArrayTC(PC pc, int32_t numArgs, void* retAddr) { assert_native_stack_aligned(); - assert(tl_regState == VMRegState::DIRTY); + assertx(tl_regState == VMRegState::DIRTY); tl_regState = VMRegState::CLEAN; auto onInvalid = CallArrOnInvalidContainer::WarnAndContinue; if (!numArgs) { @@ -5474,7 +5474,7 @@ OPTBLD_INLINE void iopFCallArray(PC& pc, ActRec* ar) { } OPTBLD_INLINE void iopFCallUnpack(PC& pc, ActRec* ar, uint32_t numArgs) { - assert(numArgs == ar->numArgs()); + assertx(numArgs == ar->numArgs()); if (ar->isDynamicCall()) callerDynamicCallChecks(ar->func()); checkStack(vmStack(), ar->m_func, 0); doFCallArray(pc, ar, numArgs, CallArrOnInvalidContainer::WarnAndContinue); @@ -5569,7 +5569,7 @@ inline bool initIteratorM(Iter* it, Ref* r1, TypedValue *val, TypedValue *key) { OPTBLD_INLINE void iopMIterInit(PC& pc, Iter* it, PC targetpc, local_var val) { Ref* r1 = vmStack().topV(); - assert(r1->m_type == KindOfRef); + assertx(r1->m_type == KindOfRef); if (!initIteratorM(it, r1, val.ptr, nullptr)) { pc = targetpc; // nothing to iterate; exit foreach loop. } @@ -5579,7 +5579,7 @@ OPTBLD_INLINE void iopMIterInit(PC& pc, Iter* it, PC targetpc, local_var val) { OPTBLD_INLINE void iopMIterInitK(PC& pc, Iter* it, PC targetpc, local_var val, local_var key) { Ref* r1 = vmStack().topV(); - assert(r1->m_type == KindOfRef); + assertx(r1->m_type == KindOfRef); if (!initIteratorM(it, r1, val.ptr, key.ptr)) { pc = targetpc; // nothing to iterate; exit foreach loop. } @@ -5788,7 +5788,7 @@ OPTBLD_INLINE void iopAliasCls(const StringData* original, const StringData* alias) { TypedValue* aloadTV = vmStack().topTV(); tvCastToBooleanInPlace(aloadTV); - assert(aloadTV->m_type == KindOfBoolean); + assertx(aloadTV->m_type == KindOfBoolean); bool autoload = aloadTV->m_data.num; vmStack().popX(); @@ -5823,7 +5823,7 @@ OPTBLD_INLINE void iopBareThis(BareThisOp bto) { case BareThisOp::Notice: raise_notice(Strings::WARN_NULL_THIS); break; case BareThisOp::NoNotice: break; case BareThisOp::NeverNull: - assert(!"$this cannot be null in BareThis with NeverNull option"); + assertx(!"$this cannot be null in BareThis with NeverNull option"); break; } } @@ -5864,7 +5864,7 @@ OPTBLD_INLINE void iopStaticLocCheck(local_var loc, const StringData* var) { if (val->m_type == KindOfUninit) { return nullptr; } - assert(val->m_type == KindOfRef); + assertx(val->m_type == KindOfRef); return val->m_data.pref; } @@ -5942,11 +5942,11 @@ OPTBLD_INLINE void iopStaticLocInit(local_var loc, const StringData* var) { OPTBLD_INLINE void iopCatch() { auto vm = &*g_context; - assert(vm->m_faults.size() > 0); + assertx(vm->m_faults.size() > 0); Fault fault = vm->m_faults.back(); vm->m_faults.pop_back(); - assert(fault.m_raiseFrame == vmfp()); - assert(fault.m_userException); + assertx(fault.m_raiseFrame == vmfp()); + assertx(fault.m_userException); vmStack().pushObjectNoRc(fault.m_userException); } @@ -5960,10 +5960,10 @@ OPTBLD_INLINE void iopLateBoundCls(clsref_slot slot) { OPTBLD_INLINE void iopVerifyParamType(local_var param) { const Func *func = vmfp()->m_func; - assert(param.index < func->numParams()); - assert(func->numParams() == int(func->params().size())); + assertx(param.index < func->numParams()); + assertx(func->numParams() == int(func->params().size())); const TypeConstraint& tc = func->params()[param.index].typeConstraint; - assert(tc.hasConstraint()); + assertx(tc.hasConstraint()); bool useStrictTypes = func->unit()->isHHFile() || RuntimeOption::EnableHipHopSyntax || !vmfp()->useWeakTypes(); @@ -5974,10 +5974,10 @@ OPTBLD_INLINE void iopVerifyParamType(local_var param) { OPTBLD_INLINE void iopVerifyOutType(uint32_t paramId) { auto const func = vmfp()->m_func; - assert(paramId < func->numParams()); - assert(func->numParams() == int(func->params().size())); + assertx(paramId < func->numParams()); + assertx(func->numParams() == int(func->params().size())); auto const& tc = func->params()[paramId].typeConstraint; - assert(tc.hasConstraint()); + assertx(tc.hasConstraint()); if (!tc.isTypeVar() && !tc.isTypeConstant()) { tc.verifyOutParam(vmStack().topTV(), func, paramId); } @@ -6018,7 +6018,7 @@ OPTBLD_INLINE TCA iopNativeImpl(PC& pc) { auto const jitReturn = jitReturnPre(vmfp()); BuiltinFunction func = vmfp()->func()->builtinFuncPtr(); - assert(func); + assertx(func); // Actually call the native implementation. This will handle freeing the // locals in the normal case. In the case of an exception, the VM unwinder // will take care of it. @@ -6074,7 +6074,7 @@ OPTBLD_INLINE void iopCreateCl(uint32_t numArgs, uint32_t clsIx) { static inline BaseGenerator* this_base_generator(const ActRec* fp) { auto const obj = fp->getThis(); - assert(obj->getVMClass() == AsyncGenerator::getClass() || + assertx(obj->getVMClass() == AsyncGenerator::getClass() || obj->getVMClass() == Generator::getClass()); return obj->getVMClass() == Generator::getClass() ? static_cast(Generator::fromObject(obj)) @@ -6095,8 +6095,8 @@ OPTBLD_INLINE TCA iopCreateCont(PC& pc) { auto const func = fp->func(); auto const numSlots = func->numSlotsInFrame(); auto const resumeOffset = func->unit()->offsetOf(pc); - assert(!fp->resumed()); - assert(func->isGenerator()); + assertx(!fp->resumed()); + assertx(func->isGenerator()); // Create the {Async,}Generator object. Create takes care of copying local // variables and iterators. @@ -6118,7 +6118,7 @@ OPTBLD_INLINE TCA iopCreateCont(PC& pc) { vmStack().ndiscard(numSlots); vmStack().ret(); tvCopy(make_tv(obj), *vmStack().topTV()); - assert(vmStack().topTV() == fp->retSlot()); + assertx(vmStack().topTV() == fp->retSlot()); // Return control to the caller. vmfp() = sfp; @@ -6128,7 +6128,7 @@ OPTBLD_INLINE TCA iopCreateCont(PC& pc) { } OPTBLD_INLINE void moveProgramCounterIntoGenerator(PC &pc, BaseGenerator* gen) { - assert(gen->isRunning()); + assertx(gen->isRunning()); ActRec* genAR = gen->actRec(); genAR->setReturn(vmfp(), pc, genAR->func()->isAsync() ? jit::tc::ustubs().asyncGenRetHelper : @@ -6136,7 +6136,7 @@ OPTBLD_INLINE void moveProgramCounterIntoGenerator(PC &pc, BaseGenerator* gen) { vmfp() = genAR; - assert(genAR->func()->contains(gen->resumable()->resumeOffset())); + assertx(genAR->func()->contains(gen->resumable()->resumeOffset())); pc = genAR->func()->unit()->at(gen->resumable()->resumeOffset()); vmpc() = pc; } @@ -6150,11 +6150,11 @@ template OPTBLD_INLINE void contEnterImpl(PC& pc) { // The stack must have one cell! Or else resumableStackBase() won't work! - assert(vmStack().top() + 1 == + assertx(vmStack().top() + 1 == (TypedValue*)vmfp() - vmfp()->m_func->numSlotsInFrame()); // Do linkage of the generator's AR. - assert(vmfp()->hasThis()); + assertx(vmfp()->hasThis()); // `recursive` determines whether we enter just the top generator or whether // we drop down to the lowest running delegate generator. This is useful for // ContRaise, which should throw from the context of the lowest generator. @@ -6163,7 +6163,7 @@ OPTBLD_INLINE void contEnterImpl(PC& pc) { } else { // TODO(https://github.com/facebook/hhvm/issues/6040) // Implement throwing from delegate generators. - assert(vmfp()->getThis()->getVMClass() == Generator::getClass()); + assertx(vmfp()->getThis()->getVMClass() == Generator::getClass()); auto gen = this_generator(vmfp()); if (gen->m_delegate.m_type != KindOfNull) { SystemLib::throwExceptionObject("Throwing from a delegate generator is " @@ -6197,8 +6197,8 @@ OPTBLD_INLINE TCA yield(PC& pc, const Cell* key, const Cell value) { auto const fp = vmfp(); auto const func = fp->func(); auto const resumeOffset = func->unit()->offsetOf(pc); - assert(fp->resumed()); - assert(func->isGenerator()); + assertx(fp->resumed()); + assertx(func->isGenerator()); EventHook::FunctionSuspendYield(fp); @@ -6207,7 +6207,7 @@ OPTBLD_INLINE TCA yield(PC& pc, const Cell* key, const Cell value) { if (!func->isAsync()) { // Non-async generator. - assert(fp->sfp()); + assertx(fp->sfp()); frame_generator(fp)->yield(resumeOffset, key, value); // Push return value of next()/send()/raise(). @@ -6218,11 +6218,11 @@ OPTBLD_INLINE TCA yield(PC& pc, const Cell* key, const Cell value) { auto const eagerResult = gen->yield(resumeOffset, key, value); if (eagerResult) { // Eager execution => return StaticWaitHandle. - assert(sfp); + assertx(sfp); vmStack().pushObjectNoRc(eagerResult); } else { // Resumed execution => return control to the scheduler. - assert(!sfp); + assertx(!sfp); } } @@ -6323,7 +6323,7 @@ OPTBLD_INLINE TCA yieldFromGenerator(PC& pc, Generator* gen, Offset resumeOffset) { auto fp = vmfp(); - assert(tvIsGenerator(gen->m_delegate)); + assertx(tvIsGenerator(gen->m_delegate)); auto delegate = Generator::fromObject(gen->m_delegate.m_data.pobj); if (delegate->getState() == BaseGenerator::State::Done) { @@ -6342,7 +6342,7 @@ TCA yieldFromGenerator(PC& pc, Generator* gen, Offset resumeOffset) { // key/current are smart enough to dive into our delegate generator, so // really what we want to do is clean up all of the generator metadata // (state, ressume address, etc) and continue on. - assert(gen->isRunning()); + assertx(gen->isRunning()); gen->resumable()->setResumeAddr(nullptr, resumeOffset); gen->setState(BaseGenerator::State::Started); @@ -6481,7 +6481,7 @@ OPTBLD_INLINE void asyncSuspendE(PC& pc) { // Pop the dependency we are blocked on. auto child = wait_handle(*vmStack().topC()); - assert(!child->isFinished()); + assertx(!child->isFinished()); vmStack().discard(); if (!func->isGenerator()) { // Async function. @@ -6504,7 +6504,7 @@ OPTBLD_INLINE void asyncSuspendE(PC& pc) { vmStack().ret(); tvCopy(make_tv(waitHandle), *vmStack().topTV()); vmStack().topTV()->m_aux.u_fcallAwaitFlag = 1; - assert(vmStack().topTV() == fp->retSlot()); + assertx(vmStack().topTV() == fp->retSlot()); // Return control to the caller. pc = LIKELY(sfp != nullptr) ? sfp->func()->getEntry() + soff : nullptr; @@ -6539,7 +6539,7 @@ OPTBLD_INLINE void asyncSuspendR(PC& pc) { // Pop the dependency we are blocked on. auto child = req::ptr::attach( wait_handle(*vmStack().topC())); - assert(!child->isFinished()); + assertx(!child->isFinished()); vmStack().discard(); // Before adjusting the stack or doing anything, check the suspend hook. @@ -6592,8 +6592,8 @@ OPTBLD_INLINE TCA iopAwaitAll(PC& pc, LocalRange locals) { auto obj = Object::attach(c_AwaitAllWaitHandle::fromFrameNoCheck( locals.restCount + 1, cnt, frame_local(vmfp(), locals.first) )); - assert(obj->isWaitHandle()); - assert(!static_cast(obj.get())->isFinished()); + assertx(obj->isWaitHandle()); + assertx(!static_cast(obj.get())->isFinished()); vmStack().pushObjectNoRc(obj.detach()); return suspendStack(pc); @@ -6730,7 +6730,7 @@ OPTBLD_INLINE void iopSilence(local_var loc, SilenceOp subop) { loc.ptr->m_data.num = zero_error_level(); break; case SilenceOp::End: - assert(loc.ptr->m_type == KindOfInt64); + assertx(loc.ptr->m_type == KindOfInt64); restore_error_level(loc.ptr->m_data.num); break; } @@ -6800,20 +6800,20 @@ static __thread int s_prev_line; void recordCodeCoverage(PC /*pc*/) { Unit* unit = vmfp()->m_func->unit(); - assert(unit != nullptr); + assertx(unit != nullptr); if (unit == SystemLib::s_nativeFuncUnit || unit == SystemLib::s_nativeClassUnit || unit == SystemLib::s_hhas_unit) { return; } int line = unit->getLineNumber(pcOff()); - assert(line != -1); + assertx(line != -1); if (unit != s_prev_unit || line != s_prev_line) { s_prev_unit = unit; s_prev_line = line; const StringData* filepath = unit->filepath(); - assert(filepath->isStatic()); + assertx(filepath->isStatic()); TI().m_coverage->Record(filepath->data(), line, line); } } @@ -7051,7 +7051,7 @@ OPCODES PC pc = vmpc(); \ ONTRACE(1, auto offset = vmfp()->m_func->unit()->offsetOf(pc); \ Trace::trace("op"#opcode" offset: %d\n", offset)); \ - assert(peek_op(pc) == Op::opcode); \ + assertx(peek_op(pc) == Op::opcode); \ pc += encoded_op_size(Op::opcode); \ auto const retAddr = iopWrap##opcode(pc); \ vmpc() = pc; \ @@ -7100,8 +7100,8 @@ TCA dispatchImpl() { OPCODES #undef O }; - assert(sizeof(optabDirect) / sizeof(const void *) == Op_count); - assert(sizeof(optabDbg) / sizeof(const void *) == Op_count); + assertx(sizeof(optabDirect) / sizeof(const void *) == Op_count); + assertx(sizeof(optabDbg) / sizeof(const void *) == Op_count); const void **optab = optabDirect; if (collectCoverage) { optab = optabCover; @@ -7163,10 +7163,10 @@ TCA dispatchImpl() { * been returned by jitReturnPost(), whether or not we were called from * the TC. We only actually return callToExit to our caller if that * caller is dispatchBB(). */ \ - assert(retAddr == jit::tc::ustubs().callToExit); \ + assertx(retAddr == jit::tc::ustubs().callToExit); \ return breakOnCtlFlow ? retAddr : nullptr; \ } \ - assert(isCtlFlow || !retAddr); \ + assertx(isCtlFlow || !retAddr); \ DISPATCH(); \ } @@ -7201,7 +7201,7 @@ DispatchSwitch: #undef OPCODE_COVER_BODY #undef OPCODE_MAIN_BODY - assert(retAddr == nullptr); + assertx(retAddr == nullptr); return nullptr; } @@ -7209,7 +7209,7 @@ static void dispatch() { WorkloadStats guard(WorkloadStats::InInterp); DEBUG_ONLY auto const retAddr = dispatchImpl(); - assert(retAddr == nullptr); + assertx(retAddr == nullptr); } // We are about to go back to translated code, check whether we should diff --git a/hphp/runtime/vm/bytecode.h b/hphp/runtime/vm/bytecode.h index 55d8185a76c..b24bdf8bd36 100644 --- a/hphp/runtime/vm/bytecode.h +++ b/hphp/runtime/vm/bytecode.h @@ -54,8 +54,8 @@ struct Resumable; // rhs might be a ref. ALWAYS_INLINE void setopBody(Cell* lhs, SetOpOp op, Cell* rhs) { - assert(cellIsPlausible(*lhs)); - assert(cellIsPlausible(*rhs)); + assertx(cellIsPlausible(*lhs)); + assertx(cellIsPlausible(*rhs)); switch (op) { case SetOpOp::PlusEqual: cellAddEq(*lhs, *rhs); return; @@ -279,7 +279,7 @@ void frame_free_locals_no_hook(ActRec* fp); ([&] { \ TypedValue val_; \ new (&val_) Variant(x); \ - assert(val_.m_type != KindOfRef && val_.m_type != KindOfUninit); \ + assertx(val_.m_type != KindOfRef && val_.m_type != KindOfUninit); \ return val_; \ }()) @@ -418,16 +418,16 @@ public: // for certain that decrementing a refcount is unnecessary. ALWAYS_INLINE void popX() { - assert(m_top != m_base); - assert(!isRefcountedType(m_top->m_type)); + assertx(m_top != m_base); + assertx(!isRefcountedType(m_top->m_type)); tvDebugTrash(m_top); m_top++; } ALWAYS_INLINE void popC() { - assert(m_top != m_base); - assert(cellIsPlausible(*m_top)); + assertx(m_top != m_base); + assertx(cellIsPlausible(*m_top)); tvDecRefGen(m_top); tvDebugTrash(m_top); m_top++; @@ -435,8 +435,8 @@ public: ALWAYS_INLINE void popV() { - assert(m_top != m_base); - assert(refIsPlausible(*m_top)); + assertx(m_top != m_base); + assertx(refIsPlausible(*m_top)); tvDecRefRef(m_top); tvDebugTrash(m_top); m_top++; @@ -444,16 +444,16 @@ public: ALWAYS_INLINE void popU() { - assert(m_top != m_base); - assert(m_top->m_type == KindOfUninit); + assertx(m_top != m_base); + assertx(m_top->m_type == KindOfUninit); tvDebugTrash(m_top); ++m_top; } ALWAYS_INLINE void popTV() { - assert(m_top != m_base); - assert(tvIsPlausible(*m_top)); + assertx(m_top != m_base); + assertx(tvIsPlausible(*m_top)); tvDecRefGen(m_top); tvDebugTrash(m_top); m_top++; @@ -464,7 +464,7 @@ public: // followed by discardAR() or ret(). ALWAYS_INLINE void popAR() { - assert(m_top != m_base); + assertx(m_top != m_base); ActRec* ar = (ActRec*)m_top; if (ar->func()->cls() && ar->hasThis()) decRefObj(ar->getThis()); if (ar->magicDispatch()) { @@ -475,14 +475,14 @@ public: ALWAYS_INLINE void discardAR() { - assert(m_top != m_base); + assertx(m_top != m_base); if (debug) { for (int i = 0; i < kNumActRecCells; ++i) { tvDebugTrash(m_top + i); } } m_top += kNumActRecCells; - assert((uintptr_t)m_top <= (uintptr_t)m_base); + assertx((uintptr_t)m_top <= (uintptr_t)m_base); } ALWAYS_INLINE @@ -495,19 +495,19 @@ public: } } m_top += kNumActRecCells - 1; - assert((uintptr_t)m_top <= (uintptr_t)m_base); + assertx((uintptr_t)m_top <= (uintptr_t)m_base); } ALWAYS_INLINE void discard() { - assert(m_top != m_base); + assertx(m_top != m_base); tvDebugTrash(m_top); m_top++; } ALWAYS_INLINE void ndiscard(size_t n) { - assert((uintptr_t)&m_top[n] <= (uintptr_t)m_base); + assertx((uintptr_t)&m_top[n] <= (uintptr_t)m_base); if (debug) { for (int i = 0; i < n; ++i) { tvDebugTrash(m_top + i); @@ -518,8 +518,8 @@ public: ALWAYS_INLINE void trim(Cell* c) { - assert(c <= m_base); - assert(m_top <= c); + assertx(c <= m_base); + assertx(m_top <= c); if (debug) { while (m_top < c) tvDebugTrash(m_top++); } else { @@ -529,9 +529,9 @@ public: ALWAYS_INLINE void dup() { - assert(m_top != m_base); - assert(m_top != m_elms); - assert(m_top->m_type != KindOfRef); + assertx(m_top != m_base); + assertx(m_top != m_elms); + assertx(m_top->m_type != KindOfRef); Cell* fr = m_top; m_top--; Cell* to = m_top; @@ -540,41 +540,41 @@ public: ALWAYS_INLINE void box() { - assert(m_top != m_base); - assert(m_top->m_type != KindOfRef); + assertx(m_top != m_base); + assertx(m_top->m_type != KindOfRef); tvBox(*m_top); } ALWAYS_INLINE void unbox() { - assert(m_top != m_base); + assertx(m_top != m_base); tvUnbox(*m_top); } ALWAYS_INLINE void pushUninit() { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; tvWriteUninit(*m_top); } ALWAYS_INLINE void pushNull() { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; tvWriteNull(*m_top); } ALWAYS_INLINE void pushNullUninit() { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; m_top->m_data.num = 0; m_top->m_type = KindOfUninit; } template void pushVal(T v) { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(v); } @@ -586,15 +586,15 @@ public: // already adjusted the refcount appropriately ALWAYS_INLINE void pushStringNoRc(StringData* s) { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(s); } ALWAYS_INLINE void pushStaticString(const StringData* s) { - assert(s->isStatic()); // No need to call s->incRefCount(). - assert(m_top != m_elms); + assertx(s->isStatic()); // No need to call s->incRefCount(). + assertx(m_top != m_elms); m_top--; *m_top = make_tv(s); } @@ -603,96 +603,96 @@ public: // already adjusted the refcount appropriately ALWAYS_INLINE void pushArrayNoRc(ArrayData* a) { - assert(a->isPHPArray()); - assert(m_top != m_elms); + assertx(a->isPHPArray()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushVecNoRc(ArrayData* a) { - assert(a->isVecArray()); - assert(m_top != m_elms); + assertx(a->isVecArray()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushDictNoRc(ArrayData* a) { - assert(a->isDict()); - assert(m_top != m_elms); + assertx(a->isDict()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushKeysetNoRc(ArrayData* a) { - assert(a->isKeyset()); - assert(m_top != m_elms); + assertx(a->isKeyset()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushArray(ArrayData* a) { - assert(a); + assertx(a); pushArrayNoRc(a); a->incRefCount(); } ALWAYS_INLINE void pushVec(ArrayData* a) { - assert(a); + assertx(a); pushVecNoRc(a); a->incRefCount(); } ALWAYS_INLINE void pushDict(ArrayData* a) { - assert(a); + assertx(a); pushDictNoRc(a); a->incRefCount(); } ALWAYS_INLINE void pushKeyset(ArrayData* a) { - assert(a); + assertx(a); pushKeysetNoRc(a); a->incRefCount(); } ALWAYS_INLINE void pushStaticArray(const ArrayData* a) { - assert(a->isStatic()); // No need to call a->incRefCount(). - assert(a->isPHPArray()); - assert(m_top != m_elms); + assertx(a->isStatic()); // No need to call a->incRefCount(). + assertx(a->isPHPArray()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushStaticVec(const ArrayData* a) { - assert(a->isStatic()); // No need to call a->incRefCount(). - assert(a->isVecArray()); - assert(m_top != m_elms); + assertx(a->isStatic()); // No need to call a->incRefCount(). + assertx(a->isVecArray()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushStaticDict(const ArrayData* a) { - assert(a->isStatic()); // No need to call a->incRefCount(). - assert(a->isDict()); - assert(m_top != m_elms); + assertx(a->isStatic()); // No need to call a->incRefCount(). + assertx(a->isDict()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } ALWAYS_INLINE void pushStaticKeyset(const ArrayData* a) { - assert(a->isStatic()); // No need to call a->incRefCount(). - assert(a->isKeyset()); - assert(m_top != m_elms); + assertx(a->isStatic()); // No need to call a->incRefCount(). + assertx(a->isKeyset()); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(a); } @@ -701,7 +701,7 @@ public: // already adjusted the refcount appropriately ALWAYS_INLINE void pushObjectNoRc(ObjectData* o) { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; *m_top = make_tv(o); } @@ -714,49 +714,49 @@ public: ALWAYS_INLINE void nalloc(size_t n) { - assert((uintptr_t)(m_top - n) <= (uintptr_t)m_base); + assertx((uintptr_t)(m_top - n) <= (uintptr_t)m_base); m_top -= n; } ALWAYS_INLINE Cell* allocC() { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; return (Cell*)m_top; } ALWAYS_INLINE Ref* allocV() { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; return (Ref*)m_top; } ALWAYS_INLINE TypedValue* allocTV() { - assert(m_top != m_elms); + assertx(m_top != m_elms); m_top--; return m_top; } ALWAYS_INLINE ActRec* allocA() { - assert((uintptr_t)(m_top - kNumActRecCells) >= (uintptr_t)m_elms); - assert(kNumActRecCells * sizeof(Cell) == sizeof(ActRec)); + assertx((uintptr_t)(m_top - kNumActRecCells) >= (uintptr_t)m_elms); + assertx(kNumActRecCells * sizeof(Cell) == sizeof(ActRec)); m_top -= kNumActRecCells; return (ActRec*)m_top; } ALWAYS_INLINE void allocI() { - assert(kNumIterCells * sizeof(Cell) == sizeof(Iter)); - assert((uintptr_t)(m_top - kNumIterCells) >= (uintptr_t)m_elms); + assertx(kNumIterCells * sizeof(Cell) == sizeof(Iter)); + assertx((uintptr_t)(m_top - kNumIterCells) >= (uintptr_t)m_elms); m_top -= kNumIterCells; } ALWAYS_INLINE void allocClsRefSlots(size_t n) { - assert((uintptr_t)(m_top - clsRefCountToCells(n)) >= (uintptr_t)m_elms); + assertx((uintptr_t)(m_top - clsRefCountToCells(n)) >= (uintptr_t)m_elms); m_top -= clsRefCountToCells(n); if (debug) { memset(m_top, kTrashClsRef, clsRefCountToCells(n) * sizeof(Cell)); @@ -765,8 +765,8 @@ public: ALWAYS_INLINE void replaceC(const Cell c) { - assert(m_top != m_base); - assert(m_top->m_type != KindOfRef); + assertx(m_top != m_base); + assertx(m_top->m_type != KindOfRef); tvDecRefGen(m_top); *m_top = c; } @@ -774,8 +774,8 @@ public: template ALWAYS_INLINE void replaceC() { - assert(m_top != m_base); - assert(m_top->m_type != KindOfRef); + assertx(m_top != m_base); + assertx(m_top->m_type != KindOfRef); tvDecRefGen(m_top); *m_top = make_tv
(); } @@ -783,15 +783,15 @@ public: template ALWAYS_INLINE void replaceC(T value) { - assert(m_top != m_base); - assert(m_top->m_type != KindOfRef); + assertx(m_top != m_base); + assertx(m_top->m_type != KindOfRef); tvDecRefGen(m_top); *m_top = make_tv
(value); } ALWAYS_INLINE void replaceTV(const TypedValue& tv) { - assert(m_top != m_base); + assertx(m_top != m_base); tvDecRefGen(m_top); *m_top = tv; } @@ -799,7 +799,7 @@ public: template ALWAYS_INLINE void replaceTV() { - assert(m_top != m_base); + assertx(m_top != m_base); tvDecRefGen(m_top); *m_top = make_tv
(); } @@ -807,40 +807,40 @@ public: template ALWAYS_INLINE void replaceTV(T value) { - assert(m_top != m_base); + assertx(m_top != m_base); tvDecRefGen(m_top); *m_top = make_tv
(value); } ALWAYS_INLINE Cell* topC() { - assert(m_top != m_base); + assertx(m_top != m_base); return tvAssertCell(m_top); } ALWAYS_INLINE Ref* topV() { - assert(m_top != m_base); - assert(m_top->m_type == KindOfRef); + assertx(m_top != m_base); + assertx(m_top->m_type == KindOfRef); return (Ref*)m_top; } ALWAYS_INLINE TypedValue* topTV() { - assert(m_top != m_base); + assertx(m_top != m_base); return m_top; } ALWAYS_INLINE Cell* indC(size_t ind) { - assert(m_top != m_base); - assert(m_top[ind].m_type != KindOfRef); + assertx(m_top != m_base); + assertx(m_top[ind].m_type != KindOfRef); return tvAssertCell(&m_top[ind]); } ALWAYS_INLINE TypedValue* indTV(size_t ind) { - assert(m_top != m_base); + assertx(m_top != m_base); return &m_top[ind]; } }; @@ -868,7 +868,7 @@ visitStackElems(const ActRec* const fp, TVFun tvFun) { const TypedValue* const base = Stack::anyFrameStackBase(fp); auto cursor = stackTop; - assert(cursor <= base); + assertx(cursor <= base); if (auto fe = fp->m_func->findFPI(bcOffset)) { for (;;) { @@ -886,7 +886,7 @@ visitStackElems(const ActRec* const fp, ar = arAtOffset(fakePrevFP, -fe->m_fpOff); } - assert(cursor <= reinterpret_cast(ar)); + assertx(cursor <= reinterpret_cast(ar)); while (cursor < reinterpret_cast(ar)) { tvFun(cursor++); } diff --git a/hphp/runtime/vm/class-inl.h b/hphp/runtime/vm/class-inl.h index 71a968e1af9..677370e045e 100644 --- a/hphp/runtime/vm/class-inl.h +++ b/hphp/runtime/vm/class-inl.h @@ -57,12 +57,12 @@ inline size_t Class::PropInitVec::size() const { } inline TypedValueAux& Class::PropInitVec::operator[](size_t i) { - assert(i < m_size); + assertx(i < m_size); return m_data[i]; } inline const TypedValueAux& Class::PropInitVec::operator[](size_t i) const { - assert(i < m_size); + assertx(i < m_size); return m_data[i]; } @@ -104,7 +104,7 @@ inline Class::veclen_t Class::classVecLen() const { // Ancestry. inline bool Class::classofNonIFace(const Class* cls) const { - assert(!(cls->attrs() & AttrInterface)); + assertx(!(cls->attrs() & AttrInterface)); if (m_classVecLen >= cls->m_classVecLen) { return (m_classVec[cls->m_classVecLen-1] == cls); } @@ -155,7 +155,7 @@ inline StrNR Class::parentStr() const { } inline Attr Class::attrs() const { - assert(Attr(m_attrCopy) == m_preClass->attrs()); + assertx(Attr(m_attrCopy) == m_preClass->attrs()); return Attr(m_attrCopy); } @@ -314,8 +314,8 @@ inline rds::Handle Class::sPropHandle(Slot index) const { } inline rds::Link Class::sPropLink(Slot index) const { - assert(m_sPropCacheInit.bound()); - assert(numStaticProperties() > index); + assertx(m_sPropCacheInit.bound()); + assertx(numStaticProperties() > index); return m_sPropCache[index]; } @@ -407,7 +407,7 @@ inline rds::Handle Class::classHandle() const { } inline void Class::setClassHandle(rds::Link> link) const { - assert(!m_cachedClass.bound()); + assertx(!m_cachedClass.bound()); m_cachedClass = link; } diff --git a/hphp/runtime/vm/class.cpp b/hphp/runtime/vm/class.cpp index aa2374b8cb7..ae0fbc1db70 100644 --- a/hphp/runtime/vm/class.cpp +++ b/hphp/runtime/vm/class.cpp @@ -75,7 +75,7 @@ static FuncIdToClassMap* s_funcIdToClassMap; const Class* getOwningClassForFunc(const Func* f) { // We only populate s_funcIdToClassMap when EvalPerfDataMap is true. - assert(RuntimeOption::EvalPerfDataMap); + assertx(RuntimeOption::EvalPerfDataMap); if (s_funcIdToClassMap) { FuncIdToClassMap::const_accessor acc; @@ -109,7 +109,7 @@ Class::PropInitVec::allocWithReqAllocator(const PropInitVec& src) { const Class::PropInitVec& Class::PropInitVec::operator=(const PropInitVec& piv) { - assert(!reqAllocated()); + assertx(!reqAllocated()); if (this != &piv) { if (UNLIKELY(m_capacity)) { free_huge(m_data); @@ -118,14 +118,14 @@ Class::PropInitVec::operator=(const PropInitVec& piv) { unsigned sz = m_size = m_capacity = piv.size(); if (sz == 0) return *this; m_data = (TypedValueAux*)malloc_huge(sz * sizeof(*m_data)); - assert(m_data); + assertx(m_data); memcpy(m_data, piv.m_data, sz * sizeof(*m_data)); } return *this; } void Class::PropInitVec::push_back(const TypedValue& v) { - assert(!reqAllocated()); + assertx(!reqAllocated()); if (m_size == m_capacity) { unsigned newCap = folly::nextPowTwo(m_size + 1); m_capacity = static_cast(newCap); @@ -135,7 +135,7 @@ void Class::PropInitVec::push_back(const TypedValue& v) { free_huge(m_data); } m_data = reinterpret_cast(newData); - assert(m_data); + assertx(m_data); } cellDup(v, m_data[m_size]); m_data[m_size++].deepInit() = false; @@ -269,8 +269,8 @@ Class* Class::newClass(PreClass* preClass, Class* parent) { } Class* Class::rescope(Class* ctx, Attr attrs /* = AttrNone */) { - assert(parent() == c_Closure::classof()); - assert(m_invoke); + assertx(parent() == c_Closure::classof()); + assertx(m_invoke); bool const is_dynamic = (attrs != AttrNone); @@ -280,8 +280,8 @@ Class* Class::rescope(Class* ctx, Attr attrs /* = AttrNone */) { auto template_cls = is_dynamic ? preClass()->namedEntity()->clsList() : this; auto const invoke = template_cls->m_invoke; - assert(IMPLIES(is_dynamic, m_scoped)); - assert(IMPLIES(is_dynamic, template_cls->m_scoped)); + assertx(IMPLIES(is_dynamic, m_scoped)); + assertx(IMPLIES(is_dynamic, template_cls->m_scoped)); auto const try_template = [&]() -> Class* { bool const ctx_match = invoke->cls() == ctx; @@ -448,8 +448,8 @@ void Class::destroy() { } void Class::atomicRelease() { - assert(!m_cachedClass.bound()); - assert(!getCount()); + assertx(!m_cachedClass.bound()); + assertx(!getCount()); this->~Class(); low_free_data(mallocPtr()); } @@ -599,7 +599,7 @@ Class::Avail Class::avail(Class*& parent, for (size_t i = 0; i < m_numDeclInterfaces; i++) { auto di = m_declInterfaces.get()[i].get(); const StringData* pdi = m_preClass.get()->interfaces()[i]; - assert(pdi->isame(di->name())); + assertx(pdi->isame(di->name())); PreClass *pint = di->m_preClass.get(); Class* interface = Unit::getClass(pint->namedEntity(), pdi, @@ -665,12 +665,12 @@ Class::Avail Class::avail(Class*& parent, // Ancestry. const Class* Class::commonAncestor(const Class* cls) const { - assert(isNormalClass(this) && isNormalClass(cls)); + assertx(isNormalClass(this) && isNormalClass(cls)); // Walk up m_classVec for both classes to look for a common ancestor. auto vecIdx = std::min(m_classVecLen, cls->m_classVecLen) - 1; do { - assert(vecIdx < m_classVecLen && vecIdx < cls->m_classVecLen); + assertx(vecIdx < m_classVecLen && vecIdx < cls->m_classVecLen); if (m_classVec[vecIdx] == cls->m_classVec[vecIdx]) { return m_classVec[vecIdx]; } @@ -697,7 +697,7 @@ const Func* Class::getDeclaredCtor() const { } const Func* Class::getCachedInvoke() const { - assert(IMPLIES(m_invoke, !m_invoke->isStaticInPrologue())); + assertx(IMPLIES(m_invoke, !m_invoke->isStaticInPrologue())); return m_invoke; } @@ -711,7 +711,7 @@ bool Class::hasCall() const { // Builtin classes. bool Class::isCppSerializable() const { - assert(instanceCtor()); // Only call this on CPP classes + assertx(instanceCtor()); // Only call this on CPP classes auto* ndi = m_extra ? m_extra.raw()->m_nativeDataInfo : nullptr; return ndi != nullptr && ndi->isSerializable(); } @@ -745,8 +745,8 @@ bool Class::initialized() const { } void Class::initProps() const { - assert(m_pinitVec.size() > 0); - assert(getPropData() == nullptr); + assertx(m_pinitVec.size() > 0); + assertx(getPropData() == nullptr); // Copy initial values for properties to a new vector that can be used to // complete initialization for non-scalar properties via the iterative // 86pinit() calls below. 86pinit() takes a reference to an array to populate @@ -767,7 +767,7 @@ void Class::initProps() const { *it, init_null_variant, nullptr, const_cast(this), nullptr, nullptr, ExecutionContext::InvokeNormal, false, false ); - assert(retval.m_type == KindOfNull); + assertx(retval.m_type == KindOfNull); } } catch (...) { // Undo the allocation of propVec @@ -802,7 +802,7 @@ bool Class::needsInitSProps() const { } void Class::initSProps() const { - assert(needsInitSProps() || m_sPropCacheInit.isPersistent()); + assertx(needsInitSProps() || m_sPropCacheInit.isPersistent()); const bool hasNonscalarInit = !m_sinitVec.empty(); folly::Optional _; @@ -837,7 +837,7 @@ void Class::initSProps() const { m_sinitVec[i], init_null_variant, nullptr, const_cast(this), nullptr, nullptr, ExecutionContext::InvokeNormal, false, false ); - assert(retval.m_type == KindOfNull); + assertx(retval.m_type == KindOfNull); } } @@ -925,7 +925,7 @@ Class::PropInitVec* Class::getPropData() const { } TypedValue* Class::getSPropData(Slot index) const { - assert(numStaticProperties() > index); + assertx(numStaticProperties() > index); return m_sPropCache[index].bound() ? &m_sPropCache[index].get()->val : nullptr; } @@ -949,7 +949,7 @@ Class::PropLookup Class::getDeclPropIndex( // Fetch the class in the inheritance tree which first declared the // property auto const baseClass = m_declProperties[propInd].cls; - assert(baseClass); + assertx(baseClass); // If ctx == baseClass, we have the right property and we can stop here. if (ctx == baseClass) return PropLookup { propInd, true }; @@ -958,7 +958,7 @@ Class::PropLookup Class::getDeclPropIndex( // we can fail fast here. if (ctx == nullptr) return PropLookup { propInd, false }; - assert(ctx); + assertx(ctx); if (attrs & AttrPrivate) { // ctx != baseClass and the property is private, so it is not // accessible. We need to keep going because ctx may define a private @@ -985,7 +985,7 @@ Class::PropLookup Class::getDeclPropIndex( // keep going because ctx may define a private property with the same // name. accessible = true; - assert(baseClass->classof(ctx)); + assertx(baseClass->classof(ctx)); } } else { // The property is public (or we're in the debugger and we are bypassing @@ -1080,7 +1080,7 @@ Class::PropLookup Class::getSProp( } auto const sProp = getSPropData(lookup.prop); - assert(sProp && sProp->m_type != KindOfUninit && + assertx(sProp && sProp->m_type != KindOfUninit && "Static property initialization failed to initialize a property."); return PropLookup { sProp, lookup.accessible }; } @@ -1109,7 +1109,7 @@ Cell Class::clsCnsGet(const StringData* clsCnsName, bool includeTypeCns) const { if (cns.isType()) { // Type constants with the low bit set are already resolved and can be // returned after masking out that bit. - assert(cnsVal->m_type == + assertx(cnsVal->m_type == (RuntimeOption::EvalHackArrDVArrs ? KindOfPersistentDict : KindOfPersistentArray) @@ -1118,7 +1118,7 @@ Cell Class::clsCnsGet(const StringData* clsCnsName, bool includeTypeCns) const { auto const rawData = reinterpret_cast(typeCns); if (rawData & 0x1) { auto const resolved = reinterpret_cast(rawData ^ 0x1); - assert(resolved->isDictOrDArray()); + assertx(resolved->isDictOrDArray()); return make_persistent_array_like_tv(resolved); } } else { @@ -1193,7 +1193,7 @@ Cell Class::clsCnsGet(const StringData* clsCnsName, bool includeTypeCns) const { auto const ad = ArrayData::GetScalarArray(std::move(resolvedTS)); if (persistent) { auto const rawData = reinterpret_cast(ad); - assert((rawData & 0x7) == 0 && "ArrayData not 8-byte aligned"); + assertx((rawData & 0x7) == 0 && "ArrayData not 8-byte aligned"); auto taggedData = reinterpret_cast(rawData | 0x1); // Multiple threads might create and store the resolved type structure @@ -1255,7 +1255,7 @@ const Cell* Class::cnsNameToTV(const StringData* clsCnsName, return nullptr; } auto const ret = &m_constants[clsCnsInd].val; - assert(m_constants[clsCnsInd].isType() || tvIsPlausible(*ret)); + assertx(m_constants[clsCnsInd].isType() || tvIsPlausible(*ret)); return ret; } @@ -1551,7 +1551,7 @@ inline void checkRefCompat(const char* kind, const Func* self, // Because of name mangling inout functions should only have the same names as // other inout functions. - assert(self->takesInOutParams() == inherit->takesInOutParams()); + assertx(self->takesInOutParams() == inherit->takesInOutParams()); // Inout functions have the parameter offsets of their inout parameters // mangled into their names, so doing this check on them would be meaningless, @@ -1560,7 +1560,7 @@ inline void checkRefCompat(const char* kind, const Func* self, // When reffiness invariance is disabled we cannot create wrappers for ref // functions, as those wrappers would violate our invariance rules for inout // functions. - assert(RuntimeOption::EvalReffinessInvariance || !self->isInOutWrapper()); + assertx(RuntimeOption::EvalReffinessInvariance || !self->isInOutWrapper()); return; } @@ -1659,8 +1659,8 @@ void checkDeclarationCompat(const PreClass* preClass, } } if (ivariadic) { - assert(iparams[iparams.size() - 1].isVariadic()); - assert(params[params.size() - 1].isVariadic()); + assertx(iparams[iparams.size() - 1].isVariadic()); + assertx(params[params.size() - 1].isVariadic()); // reffiness of the variadics must match if (imeth->byRef(iparams.size() - 1) != func->byRef(params.size() - 1)) { @@ -1795,7 +1795,7 @@ void Class::setMethods() { // Copy down the parent's method entries. These may be overridden below. for (Slot i = 0; i < m_parent->m_methods.size(); ++i) { Func* f = m_parent->getMethod(i); - assert(f); + assertx(f); ITRACE(5, " - adding parent method {}\n", f->name()->data()); if ((f->attrs() & AttrClone) || (!(f->attrs() & AttrPrivate) && f->hasStaticLocals())) { @@ -1806,7 +1806,7 @@ void Class::setMethods() { // overridden below. parentMethodsWithStaticLocals.push_back(i); } - assert(builder.size() == i); + assertx(builder.size() == i); builder.add(f->name(), f); } } @@ -1832,7 +1832,7 @@ void Class::setMethods() { if (it2 != builder.end()) { Func* parentMethod = builder[it2->second]; // We should never have null func pointers to deal with - assert(parentMethod); + assertx(parentMethod); // An abstract method that came from a trait doesn't override another // method. if (method->isFromTrait() && (method->attrs() & AttrAbstract)) continue; @@ -1841,7 +1841,7 @@ void Class::setMethods() { Func* f = method->clone(this); f->setNewFuncId(); Class* baseClass; - assert(!(f->attrs() & AttrPrivate) || + assertx(!(f->attrs() & AttrPrivate) || (parentMethod->attrs() & AttrPrivate)); if ((parentMethod->attrs() & AttrPrivate) || (f->attrs() & AttrPrivate)) { baseClass = this; @@ -1896,7 +1896,7 @@ void Class::setMethods() { acc, FuncIdToClassMap::value_type(f->getFuncId(), this))) { // we only just allocated this id, which is supposedly // process unique - assert(false); + assertx(false); } } } @@ -2130,7 +2130,7 @@ void Class::setConstants() { if (cns.isType()) { auto& preConsts = cns.cls->preClass()->constantsMap(); auto const idx = preConsts.findIndex(cns.name.get()); - assert(idx != -1); + assertx(idx != -1); cns.val = preConsts[idx].val(); } } @@ -2286,7 +2286,7 @@ void Class::setProperties() { PropMap::Builder::iterator it2 = curPropMap.find(preProp->name()); if (it2 != curPropMap.end()) { auto& prop = curPropMap[it2->second]; - assert((prop.attrs & (AttrPublic|AttrProtected|AttrPrivate)) == + assertx((prop.attrs & (AttrPublic|AttrProtected|AttrPrivate)) == AttrProtected); prop.cls = this; prop.docComment = preProp->docComment(); @@ -2336,7 +2336,7 @@ void Class::setProperties() { addNewProp(); break; } - default: assert(false); + default: assertx(false); } } else { // Static property. // Prohibit non-static-->static redeclaration. @@ -2524,7 +2524,7 @@ void Class::importTraitStaticProp(Class* /*trait*/, SProp& traitProp, auto const& prevSProps = prevProp.cls->m_staticProperties; auto prevPropInd = prevSProps.findIndex(prevProp.name); - assert(prevPropInd != kInvalidSlot); + assertx(prevPropInd != kInvalidSlot); prevPropVal = prevSProps[prevPropInd].val; } @@ -2703,7 +2703,7 @@ void Class::addInterfacesFromUsedTraits(InterfaceMap::Builder& builder) const { for (auto const& traitName : m_preClass->usedTraits()) { auto const trait = Unit::lookupClass(traitName); - assert(trait->attrs() & AttrTrait); + assertx(trait->attrs() & AttrTrait); int numIfcs = trait->m_interfaces.size(); for (int i = 0; i < numIfcs; i++) { @@ -2767,16 +2767,16 @@ void Class::setInterfaces() { !m_preClass->name()->isame(s_Stringish.get()))) { // Add Stringish Class* stringish = Unit::lookupClass(s_Stringish.get()); - assert(stringish != nullptr); - assert((stringish->attrs() & AttrInterface)); + assertx(stringish != nullptr); + assertx((stringish->attrs() & AttrInterface)); interfacesBuilder.add(stringish->name(), LowPtr(stringish)); if (!m_preClass->name()->isame(s_XHPChild.get()) && !interfacesBuilder.contains(s_XHPChild.get())) { // All Stringish are also XHPChild Class* xhpChild = Unit::lookupClass(s_XHPChild.get()); - assert(xhpChild != nullptr); - assert((xhpChild->attrs() & AttrInterface)); + assertx(xhpChild != nullptr); + assertx((xhpChild->attrs() & AttrInterface)); interfacesBuilder.add(xhpChild->name(), LowPtr(xhpChild)); } } @@ -2888,7 +2888,7 @@ void Class::setRequirements() { // pointless circular dependencies, but if it does, we check // that it's the right kind. for (auto const& req : m_preClass->requirements()) { - assert(req.is_extends()); + assertx(req.is_extends()); auto const reqName = req.name(); auto const reqCls = Unit::lookupClass(reqName); if (reqCls) { @@ -2917,7 +2917,7 @@ void Class::setRequirements() { reqName->data()); } } else { - assert(req.is_implements()); + assertx(req.is_implements()); if (!(reqCls->attrs() & AttrInterface)) { raise_error(Strings::TRAIT_BAD_REQ_IMPLEMENTS, m_preClass->name()->data(), @@ -2979,7 +2979,7 @@ bool Class::hasNativePropHandler() const { } const Native::NativePropHandler* Class::getNativePropHandler() const { - assert(hasNativePropHandler()); + assertx(hasNativePropHandler()); for (auto cls = this; cls; cls = cls->parent()) { auto propHandler = Native::getNativePropHandler(cls->name()); @@ -2992,13 +2992,13 @@ const Native::NativePropHandler* Class::getNativePropHandler() const { } void Class::raiseUnsatisfiedRequirement(const PreClass::ClassRequirement* req) const { - assert(!(attrs() & (AttrInterface | AttrTrait))); + assertx(!(attrs() & (AttrInterface | AttrTrait))); auto const reqName = req->name(); if (req->is_implements()) { // "require implements" is only allowed on traits. - assert(attrs() & AttrNoExpandTrait || + assertx(attrs() & AttrNoExpandTrait || (m_extra && m_extra->m_usedTraits.size() > 0)); for (auto const& traitCls : m_extra->m_usedTraits) { if (traitCls->allRequirements().contains(reqName)) { @@ -3014,8 +3014,8 @@ void Class::raiseUnsatisfiedRequirement(const PreClass::ClassRequirement* req) // contains a requirement. To save space, we don't include the source // trait in the requirement. For details, see // ClassScope::importUsedTraits in the compiler. - assert(!m_extra || m_extra->m_usedTraits.size() == 0); - assert(m_preClass->requirements().size() > 0); + assertx(!m_extra || m_extra->m_usedTraits.size() == 0); + assertx(m_preClass->requirements().size() > 0); raise_error(Strings::TRAIT_REQ_IMPLEMENTS, m_preClass->name()->data(), reqName->data(), @@ -3026,7 +3026,7 @@ void Class::raiseUnsatisfiedRequirement(const PreClass::ClassRequirement* req) return; } - assert(req->is_extends()); + assertx(req->is_extends()); for (auto const& iface : m_interfaces.range()) { if (iface->allRequirements().contains(reqName)) { raise_error("Class '%s' required to extend class '%s'" @@ -3048,8 +3048,8 @@ void Class::raiseUnsatisfiedRequirement(const PreClass::ClassRequirement* req) if (attrs() & AttrNoExpandTrait) { // A result of trait flattening, as with the is_implements case above - assert(!m_extra || m_extra->m_usedTraits.size() == 0); - assert(m_preClass->requirements().size() > 0); + assertx(!m_extra || m_extra->m_usedTraits.size() == 0); + assertx(m_preClass->requirements().size() > 0); raise_error(Strings::TRAIT_REQ_EXTENDS, m_preClass->name()->data(), reqName->data(), @@ -3087,7 +3087,7 @@ void Class::checkRequirementConstraints() const { void Class::setClassVec() { if (m_classVecLen > 1) { - assert(m_parent.get() != nullptr); + assertx(m_parent.get() != nullptr); memcpy(m_classVec, m_parent->m_classVec, (m_classVecLen-1) * sizeof(m_classVec[0])); } @@ -3100,10 +3100,10 @@ void Class::setFuncVec(MethodMapBuilder& builder) { memset(funcVec, 0, m_funcVecLen * sizeof(LowPtr)); funcVec = (LowPtr*)this; - assert(builder.size() <= m_funcVecLen); + assertx(builder.size() <= m_funcVecLen); for (Slot i = 0; i < builder.size(); i++) { - assert(builder[i]->methodSlot() < builder.size()); + assertx(builder[i]->methodSlot() < builder.size()); funcVec[-((int32_t)builder[i]->methodSlot() + 1)] = builder[i]; } } @@ -3275,7 +3275,7 @@ void Class::importTraitMethod(const TMIData::MethodData& mdata, methodOverrideCheck(parentMethod, f); - assert(!(f->attrs() & AttrPrivate) || + assertx(!(f->attrs() & AttrPrivate) || (parentMethod->attrs() & AttrPrivate)); if ((parentMethod->attrs() & AttrPrivate) || (f->attrs() & AttrPrivate)) { baseClass = this; @@ -3313,7 +3313,7 @@ void Class::importTraitMethods(MethodMapBuilder& builder) { if (method->takesInOutParams()) { auto const wrapper = trait->lookupMethod(stripInOutSuffix(methName)); - assert(wrapper); + assertx(wrapper); inoutFunctions.emplace(wrapper, method); continue; // Don't apply any trait rules to the inout function @@ -3330,7 +3330,7 @@ void Class::importTraitMethods(MethodMapBuilder& builder) { auto getSuffix = [] (const StringData* name) { auto start = name->data() + name->size() - sizeof(kInOutSuffix); - for (; *start != '$'; --start) assert(start != name->data()); + for (; *start != '$'; --start) assertx(start != name->data()); return folly::StringPiece(start, name->size() - (start - name->data())); }; diff --git a/hphp/runtime/vm/debug/dwarf.cpp b/hphp/runtime/vm/debug/dwarf.cpp index b4f49c2ac37..6fce829be6b 100644 --- a/hphp/runtime/vm/debug/dwarf.cpp +++ b/hphp/runtime/vm/debug/dwarf.cpp @@ -162,7 +162,7 @@ DwarfChunk* DwarfInfo::addTracelet(TCRange range, if (name) { f->name = *name; } else { - assert(func != nullptr); + assertx(func != nullptr); f->name = lookupFunction(func, exit, inPrologue, true); auto names = func->localNames(); for (int i = 0; i < func->numNamedLocals(); i++) { @@ -188,7 +188,7 @@ DwarfChunk* DwarfInfo::addTracelet(TCRange range, m_functions.erase(it); delete f; f = m_functions[end]; - assert(f->m_chunk != nullptr); + assertx(f->m_chunk != nullptr); f->m_chunk->clearSynced(); f->clearPerfSynced(); } else { diff --git a/hphp/runtime/vm/debug/dwarf.h b/hphp/runtime/vm/debug/dwarf.h index 41b6991c138..f0e30842fef 100644 --- a/hphp/runtime/vm/debug/dwarf.h +++ b/hphp/runtime/vm/debug/dwarf.h @@ -65,7 +65,7 @@ extern int g_dwarfCallback( struct TCRange { TCRange() : m_start(nullptr), m_end(nullptr), m_isAcold(false) { - assert(!isValid()); + assertx(!isValid()); } TCRange(const TCA start, const TCA end, bool isAcold) : m_start(start), m_end(end), m_isAcold(isAcold) { V(); } @@ -79,9 +79,9 @@ struct TCRange { } bool isValid() const { - assert(bool(m_start) == bool(m_end)); - assert(!m_start || m_start < m_end); - assert(!m_start || (m_end - m_start) < (1ll << 32)); + assertx(bool(m_start) == bool(m_end)); + assertx(!m_start || m_start < m_end); + assertx(!m_start || (m_end - m_start) < (1ll << 32)); return bool(m_start); } bool isAcold() const { return m_isAcold; } @@ -90,13 +90,13 @@ struct TCRange { uint32_t size() const { V(); return m_end - m_start; } void extend(const TCA newEnd) { - assert(newEnd >= m_end); + assertx(newEnd >= m_end); m_end = newEnd; V(); } private: - void V() const { assert(isValid()); } + void V() const { assertx(isValid()); } private: TCA m_start, m_end; diff --git a/hphp/runtime/vm/disas.cpp b/hphp/runtime/vm/disas.cpp index 98dba864bbe..951d037e4d6 100644 --- a/hphp/runtime/vm/disas.cpp +++ b/hphp/runtime/vm/disas.cpp @@ -121,7 +121,7 @@ std::string escaped_long(const ArrayData* ad) { } std::string escaped_long(Cell cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); auto const str = internal_serialize(tvAsCVarRef(&cell)); return escaped_long(str.get()); } @@ -370,7 +370,7 @@ void print_instr(Output& out, const FuncInfo& finfo, PC pc) { switch (peek_op(pc)) { OPCODES } #undef O - assert(pc == startPc + instrLen(startPc)); + assertx(pc == startPc + instrLen(startPc)); #undef IMM_NA #undef IMM_ONE @@ -634,7 +634,7 @@ void print_func(Output& out, const Func* func) { } std::string member_tv_initializer(Cell cell) { - assert(cellIsPlausible(cell)); + assertx(cellIsPlausible(cell)); if (cell.m_type == KindOfUninit) return "uninit"; return escaped_long(cell); } diff --git a/hphp/runtime/vm/fixed-string-map-inl.h b/hphp/runtime/vm/fixed-string-map-inl.h index 5a1a793521e..73b333be8fa 100644 --- a/hphp/runtime/vm/fixed-string-map-inl.h +++ b/hphp/runtime/vm/fixed-string-map-inl.h @@ -58,24 +58,24 @@ void FixedStringMap::init(int num, uint32_t numExtraBytes) { capac *= 2; } TRACE_MOD(Trace::runtime, 1, "FixedStringMap::init: %d -> %d\n", num, capac); - assert(!m_table); + assertx(!m_table); auto const allocSize = capac * sizeof(Elm) + numExtraBytes; auto ptr = malloc_huge(allocSize); std::memset(ptr, 0, allocSize); m_table = (Elm*)ptr + capac; - assert(m_table); + assertx(m_table); m_mask = capac - 1; } template NEVER_INLINE void FixedStringMap::add(const StringData* sd, const V& v) { - assert(sd->isStatic()); + assertx(sd->isStatic()); Elm* elm = &m_table[-1 - int32_t(sd->hash() & m_mask)]; UNUSED unsigned numProbes = 0; while (elm->sd) { - assert(numProbes++ < m_mask + 1); + assertx(numProbes++ < m_mask + 1); // Semantics for multiple insertion: new value wins. if (FSM::strEqual(elm->sd, sd)) break; if (UNLIKELY(++elm == m_table)) elm -= m_mask + 1; @@ -90,7 +90,7 @@ V* FixedStringMap::find(const StringData* sd) const { Elm* elm = &m_table[-1 - int32_t(sd->hash() & m_mask)]; UNUSED unsigned numProbes = 0; for(;;) { - assert(numProbes++ < m_mask + 1); + assertx(numProbes++ < m_mask + 1); if (UNLIKELY(nullptr == elm->sd)) return nullptr; if (FSM::strEqual(elm->sd, sd)) return &elm->data; if (UNLIKELY(++elm == m_table)) elm -= m_mask + 1; @@ -102,8 +102,8 @@ V* FixedStringMap::find(const StringData* sd) const { template inline T& FixedStringMapBuilder::operator[](V idx) { - assert(idx >= 0); - assert(size_t(idx) < m_list.size()); + assertx(idx >= 0); + assertx(size_t(idx) < m_list.size()); return m_list[idx]; } @@ -118,7 +118,7 @@ inline void FixedStringMapBuilder::add(const StringData* name, const T& t) { if (m_list.size() >= size_t(std::numeric_limits::max())) { - assert(false && "FixedStringMap::Builder overflowed"); + assertx(false && "FixedStringMap::Builder overflowed"); abort(); } m_map[name] = m_list.size(); diff --git a/hphp/runtime/vm/func-emitter-inl.h b/hphp/runtime/vm/func-emitter-inl.h index bf37b84ff46..a8038d14c7c 100644 --- a/hphp/runtime/vm/func-emitter-inl.h +++ b/hphp/runtime/vm/func-emitter-inl.h @@ -49,7 +49,7 @@ inline int FuncEmitter::sn() const { } inline Id FuncEmitter::id() const { - assert(m_pce == nullptr); + assertx(m_pce == nullptr); return m_id; } @@ -82,7 +82,7 @@ inline Id FuncEmitter::numLiveIterators() const { } inline void FuncEmitter::setNumIterators(Id numIterators) { - assert(m_numIterators == 0); + assertx(m_numIterators == 0); m_numIterators = numIterators; } @@ -91,17 +91,17 @@ inline void FuncEmitter::setNumLiveIterators(Id id) { } inline void FuncEmitter::setNumClsRefSlots(Id num) { - assert(m_numClsRefSlots == 0); + assertx(m_numClsRefSlots == 0); m_numClsRefSlots = num; } inline bool FuncEmitter::hasVar(const StringData* name) const { - assert(name != nullptr); + assertx(name != nullptr); return m_localNames.find(name) != m_localNames.end(); } inline Id FuncEmitter::lookupVarId(const StringData* name) const { - assert(hasVar(name)); + assertx(hasVar(name)); return m_localNames.find(name)->second; } @@ -113,7 +113,7 @@ inline void FuncEmitter::freeUnnamedLocal(Id id) { inline void FuncEmitter::freeIterator(Id id) { --m_nextFreeIterator; - assert(id == m_nextFreeIterator); + assertx(id == m_nextFreeIterator); } inline void FuncEmitter::appendParam(const StringData* name, diff --git a/hphp/runtime/vm/func-emitter.cpp b/hphp/runtime/vm/func-emitter.cpp index 9df6a8f22ea..24efb4a56b5 100644 --- a/hphp/runtime/vm/func-emitter.cpp +++ b/hphp/runtime/vm/func-emitter.cpp @@ -111,7 +111,7 @@ void FuncEmitter::init(int l1, int l2, Offset base_, Attr attrs_, bool top_, if (!isPseudoMain()) { if (!SystemLib::s_inited) { - assert(attrs & AttrBuiltin); + assertx(attrs & AttrBuiltin); } if ((attrs & AttrBuiltin) && !pce()) { attrs |= AttrSkipFrame; @@ -178,7 +178,7 @@ Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { attrs = Attr(attrs & ~AttrPersistent); } } else { - assert(preClass || !(attrs & AttrBuiltin)); + assertx(preClass || !(attrs & AttrBuiltin)); } if (!RuntimeOption::RepoAuthoritative) { // In non-RepoAuthoritative mode, any function could get a VarEnv because @@ -201,7 +201,7 @@ Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { if (!containsCalls) { attrs |= AttrPhpLeafFn; } - assert(!m_pce == !preClass); + assertx(!m_pce == !preClass); auto f = m_ue.newFunc(this, unit, name, attrs, params.size()); f->m_isPreFunc = !!preClass; @@ -299,7 +299,7 @@ Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { int extra = (attrs & AttrNumArgs ? 1 : 0) + (isMethod() ? 1 : 0); - assert(info.sig.args.size() == params.size() + extra); + assertx(info.sig.args.size() == params.size() + extra); for (auto i = params.size(); i--; ) { switch (info.sig.args[extra + i]) { case Native::NativeSig::Type::ObjectArg: @@ -325,19 +325,19 @@ Func* FuncEmitter::create(Unit& unit, PreClass* preClass /* = NULL */) const { // Locals, iterators, and parameters. void FuncEmitter::allocVarId(const StringData* name) { - assert(name != nullptr); + assertx(name != nullptr); // Unnamed locals are segregated (they all come after the named locals). - assert(m_numUnnamedLocals == 0); + assertx(m_numUnnamedLocals == 0); UNUSED Id id; if (m_localNames.find(name) == m_localNames.end()) { id = (m_numLocals++); - assert(id == (int)m_localNames.size()); + assertx(id == (int)m_localNames.size()); m_localNames.add(name, name); } } Id FuncEmitter::allocIterator() { - assert(m_numIterators >= m_nextFreeIterator); + assertx(m_numIterators >= m_nextFreeIterator); Id id = m_nextFreeIterator++; if (m_numIterators < m_nextFreeIterator) { m_numIterators = m_nextFreeIterator; @@ -359,7 +359,7 @@ Id FuncEmitter::allocUnnamedLocal() { // Unit tables. EHEntEmitter& FuncEmitter::addEHEnt() { - assert(!m_ehTabSorted + assertx(!m_ehTabSorted || "should only mark the ehtab as sorted after adding all of them"); ehtab.push_back(EHEntEmitter()); ehtab.back().m_parentIndex = 7777; @@ -407,7 +407,7 @@ void FuncEmitter::sortEHTab() { for (int j = i - 1; j >= 0; j--) { if (ehtab[j].m_past >= ehtab[i].m_past) { // parent EHEnt better enclose this one. - assert(ehtab[j].m_base <= ehtab[i].m_base); + assertx(ehtab[j].m_base <= ehtab[i].m_base); ehtab[i].m_parentIndex = j; break; } @@ -502,9 +502,9 @@ int FuncEmitter::parseNativeAttributes(Attr& attrs_) const { int ret = Native::AttrNone; auto it = userAttributes.find(s_native.get()); - assert(it != userAttributes.end()); + assertx(it != userAttributes.end()); const TypedValue userAttr = it->second; - assert(isArrayType(userAttr.m_type)); + assertx(isArrayType(userAttr.m_type)); for (ArrayIter it(userAttr.m_data.parr); it; ++it) { Variant userAttrVal = it.second(); if (userAttrVal.isString()) { @@ -618,17 +618,17 @@ void FuncRepoProxy::GetFuncsStmt PreClassEmitter* pce = ue.pce(preClassId); fe = ue.newMethodEmitter(name, pce); bool added UNUSED = pce->addMethod(fe); - assert(added); + assertx(added); } - assert(fe->sn() == funcSn); + assertx(fe->sn() == funcSn); fe->top = top; fe->serdeMetaData(extraBlob); if (!SystemLib::s_inited && !fe->isPseudoMain()) { - assert(fe->attrs & AttrBuiltin); + assertx(fe->attrs & AttrBuiltin); if (preClassId < 0) { - assert(fe->attrs & AttrPersistent); - assert(fe->attrs & AttrUnique); - assert(fe->attrs & AttrSkipFrame); + assertx(fe->attrs & AttrPersistent); + assertx(fe->attrs & AttrUnique); + assertx(fe->attrs & AttrSkipFrame); } } fe->setEHTabIsSorted(); diff --git a/hphp/runtime/vm/func-inl.h b/hphp/runtime/vm/func-inl.h index 51545d4a199..807bcb0f8c9 100644 --- a/hphp/runtime/vm/func-inl.h +++ b/hphp/runtime/vm/func-inl.h @@ -79,17 +79,17 @@ inline const void* Func::mallocEnd() const { inline void Func::validate() const { #ifdef DEBUG - assert(m_magic == kMagic); + assertx(m_magic == kMagic); #endif - assert(m_name != nullptr); + assertx(m_name != nullptr); } /////////////////////////////////////////////////////////////////////////////// // FuncId manipulation. inline FuncId Func::getFuncId() const { - assert(m_funcId != InvalidFuncId); - assert(fromFuncId(m_funcId) == this); + assertx(m_funcId != InvalidFuncId); + assertx(fromFuncId(m_funcId) == this); return m_funcId; } @@ -121,12 +121,12 @@ inline Class* Func::implCls() const { } inline const StringData* Func::name() const { - assert(m_name != nullptr); + assertx(m_name != nullptr); return m_name; } inline StrNR Func::nameStr() const { - assert(m_name != nullptr); + assertx(m_name != nullptr); return StrNR(m_name); } @@ -136,7 +136,7 @@ inline const StringData* Func::fullName() const { } inline StrNR Func::fullNameStr() const { - assert(m_fullName != nullptr); + assertx(m_fullName != nullptr); return StrNR(m_fullName); } @@ -150,12 +150,12 @@ inline const StringData* Func::fullDisplayName() const { } inline NamedEntity* Func::getNamedEntity() { - assert(!shared()->m_preClass); + assertx(!shared()->m_preClass); return *reinterpret_cast*>(&m_namedEntity); } inline const NamedEntity* Func::getNamedEntity() const { - assert(!shared()->m_preClass); + assertx(!shared()->m_preClass); return *reinterpret_cast*>(&m_namedEntity); } @@ -180,9 +180,9 @@ inline const StringData* Func::filename() const { // the unit const StringData* name = originalFilename(); if (!name) { - assert(m_unit); + assertx(m_unit); name = m_unit->filepath(); - assert(name); + assertx(name); } return name; } @@ -195,7 +195,7 @@ inline int Func::line2() const { auto const sd = shared(); auto const delta = sd->m_line2Delta; if (UNLIKELY(delta == kSmallDeltaLimit)) { - assert(extShared()); + assertx(extShared()); return static_cast(sd)->m_line2; } return line1() + delta; @@ -220,7 +220,7 @@ inline Offset Func::past() const { auto const sd = shared(); auto const delta = sd->m_pastDelta; if (UNLIKELY(delta == kSmallDeltaLimit)) { - assert(extShared()); + assertx(extShared()); return static_cast(sd)->m_past; } return base() + delta; @@ -274,20 +274,20 @@ inline const Func::ParamInfoVec& Func::params() const { } inline uint32_t Func::numParams() const { - assert(bool(m_attrs & AttrVariadicParam) != bool(m_paramCounts & 1)); - assert((m_paramCounts >> 1) == params().size()); + assertx(bool(m_attrs & AttrVariadicParam) != bool(m_paramCounts & 1)); + assertx((m_paramCounts >> 1) == params().size()); return (m_paramCounts) >> 1; } inline uint32_t Func::numNonVariadicParams() const { - assert(bool(m_attrs & AttrVariadicParam) != bool(m_paramCounts & 1)); - assert((m_paramCounts >> 1) == params().size()); + assertx(bool(m_attrs & AttrVariadicParam) != bool(m_paramCounts & 1)); + assertx((m_paramCounts >> 1) == params().size()); return (m_paramCounts - 1) >> 1; } inline bool Func::hasVariadicCaptureParam() const { #ifdef DEBUG - assert(bool(m_attrs & AttrVariadicParam) == + assertx(bool(m_attrs & AttrVariadicParam) == (numParams() && params()[numParams() - 1].variadic)); #endif return m_attrs & AttrVariadicParam; @@ -327,7 +327,7 @@ inline Id Func::numNamedLocals() const { } inline const StringData* Func::localVarName(Id id) const { - assert(id >= 0); + assertx(id >= 0); return id < numNamedLocals() ? shared()->m_localNames[id] : nullptr; } @@ -500,7 +500,7 @@ inline bool Func::isResumable() const { // Methods. inline Slot Func::methodSlot() const { - assert(isMethod()); + assertx(isMethod()); return m_methodSlot; } @@ -598,12 +598,12 @@ inline const Func::FPIEntVec& Func::fpitab() const { } inline const EHEnt* Func::findEH(Offset o) const { - assert(o >= base() && o < past()); + assertx(o >= base() && o < past()); return findEH(shared()->m_ehtab, o); } inline const EHEnt* Func::findEHbyHandler(Offset o) const { - assert(o >= base() && o < past()); + assertx(o >= base() && o < past()); return findEHbyHandler(shared()->m_ehtab, o); } @@ -701,7 +701,7 @@ inline void Func::setHasPrivateAncestor(bool b) { } inline void Func::setMethodSlot(Slot s) { - assert(isMethod()); + assertx(isMethod()); m_methodSlot = s; } diff --git a/hphp/runtime/vm/func.cpp b/hphp/runtime/vm/func.cpp index 30577063fa9..5164a9fc0e7 100644 --- a/hphp/runtime/vm/func.cpp +++ b/hphp/runtime/vm/func.cpp @@ -139,7 +139,7 @@ void Func::destroy(Func* func) { } DEBUG_ONLY auto oldVal = s_funcVec.exchange(func->m_funcId, nullptr); - assert(oldVal == func); + assertx(oldVal == func); func->m_funcId = InvalidFuncId; if (RuntimeOption::EvalEnableReverseDataMap) { @@ -158,8 +158,8 @@ void Func::destroy(Func* func) { } void Func::freeClone() { - assert(isPreFunc()); - assert(m_cloned.flag.test_and_set()); + assertx(isPreFunc()); + assertx(m_cloned.flag.test_and_set()); if (jit::mcgen::initialized() && RuntimeOption::EvalEnableReusableTC) { // Free TC-space associated with func @@ -170,7 +170,7 @@ void Func::freeClone() { if (m_funcId != InvalidFuncId) { DEBUG_ONLY auto oldVal = s_funcVec.exchange(m_funcId, nullptr); - assert(oldVal == this); + assertx(oldVal == this); m_funcId = InvalidFuncId; } @@ -254,7 +254,7 @@ void Func::init(int numParams) { */ m_attrs = m_attrs | AttrNoInjection; } - assert(m_name); + assertx(m_name); initPrologues(numParams); } @@ -280,7 +280,7 @@ void Func::initPrologues(int numParams) { } void Func::setFullName(int /*numParams*/) { - assert(m_name->isStatic()); + assertx(m_name->isStatic()); if (m_cls) { m_fullName = makeStaticString( std::string(m_cls->name()->data()) + "::" + m_name->data()); @@ -310,7 +310,7 @@ void Func::appendParam(bool ref, const Func::ParamInfo& info, // used int qword = numParams / kBitsPerQword; int bit = numParams % kBitsPerQword; - assert(!info.isVariadic() || (m_attrs & AttrVariadicParam)); + assertx(!info.isVariadic() || (m_attrs & AttrVariadicParam)); uint64_t* refBits = &m_refBitVal; // Grow args, if necessary. if (qword) { @@ -328,7 +328,7 @@ void Func::appendParam(bool ref, const Func::ParamInfo& info, *refBits = (m_attrs & AttrVariadicByRef) ? -1ull : 0; } - assert(!(*refBits & (uint64_t(1) << bit)) == !(m_attrs & AttrVariadicByRef)); + assertx(!(*refBits & (uint64_t(1) << bit)) == !(m_attrs & AttrVariadicByRef)); *refBits &= ~(1ull << bit); *refBits |= uint64_t(ref) << bit; pBuilder.push_back(info); @@ -340,9 +340,9 @@ void Func::appendParam(bool ref, const Func::ParamInfo& info, * is (non)variadic; and the rest of the bits are the number of params. */ void Func::finishedEmittingParams(std::vector& fParams) { - assert(m_paramCounts == 0); + assertx(m_paramCounts == 0); if (!fParams.size()) { - assert(!m_refBitVal && !shared()->m_refBitPtr); + assertx(!m_refBitVal && !shared()->m_refBitPtr); m_refBitVal = attrs() & AttrVariadicByRef ? -1uLL : 0uLL; } @@ -351,7 +351,7 @@ void Func::finishedEmittingParams(std::vector& fParams) { if (!(m_attrs & AttrVariadicParam)) { m_paramCounts |= 1; } - assert(numParams() == fParams.size()); + assertx(numParams() == fParams.size()); } bool Func::isMemoizeImplName(const StringData* name) { @@ -367,12 +367,12 @@ const StringData* Func::genMemoizeImplName(const StringData* origName) { // FuncId manipulation. void Func::setNewFuncId() { - assert(m_funcId == InvalidFuncId); + assertx(m_funcId == InvalidFuncId); m_funcId = s_nextFuncId.fetch_add(1, std::memory_order_relaxed); s_funcVec.ensureSize(m_funcId + 1); DEBUG_ONLY auto oldVal = s_funcVec.exchange(m_funcId, this); - assert(oldVal == nullptr); + assertx(oldVal == nullptr); } FuncId Func::nextFuncId() { @@ -380,7 +380,7 @@ FuncId Func::nextFuncId() { } const Func* Func::fromFuncId(FuncId id) { - assert(id < s_nextFuncId); + assertx(id < s_nextFuncId); auto func = s_funcVec.get(id); func->validate(); return func; @@ -435,7 +435,7 @@ int Func::getDVEntryNumParams(Offset offset) const { } Offset Func::getEntryForNumArgs(int numArgsPassed) const { - assert(numArgsPassed >= 0); + assertx(numArgsPassed >= 0); auto const nparams = numNonVariadicParams(); for (unsigned i = numArgsPassed; i < nparams; i++) { const Func::ParamInfo& pi = params()[i]; @@ -468,7 +468,7 @@ bool Func::anyByRef() const { bool Func::byRef(int32_t arg) const { const uint64_t* ref = &m_refBitVal; - assert(arg >= 0); + assertx(arg >= 0); if (UNLIKELY(arg >= kBitsPerQword)) { // Super special case. A handful of builtins are varargs functions where the // (not formally declared) varargs are pass-by-reference. psychedelic-kitten @@ -518,7 +518,7 @@ bool Func::mustBeRef(int32_t arg) const { // Locals, iterators, and stack. Id Func::lookupVarId(const StringData* name) const { - assert(name != nullptr); + assertx(name != nullptr); return shared()->m_localNames.findIndex(name); } @@ -527,7 +527,7 @@ Id Func::lookupVarId(const StringData* name) const { bool Func::isImmutableFrom(const Class* cls) const { if (!RuntimeOption::RepoAuthoritative) return false; - assert(cls && cls->lookupMethod(name()) == this); + assertx(cls && cls->lookupMethod(name()) == this); if (attrs() & AttrNoOverride) { // Even if the func isn't overridden, we clone it into // any derived classes if it has static locals @@ -577,9 +577,9 @@ const FPIEnt* Func::findFPI(const FPIEnt* b, const FPIEnt* e, Offset o) { } const FPIEnt* Func::findPrecedingFPI(Offset o) const { - assert(o >= base() && o < past()); + assertx(o >= base() && o < past()); const FPIEntVec& fpitab = shared()->m_fpitab; - assert(fpitab.size()); + assertx(fpitab.size()); const FPIEnt* fe = 0; for (unsigned i = 0; i < fpitab.size(); i++) { const FPIEnt* cur = &fpitab[i]; @@ -588,7 +588,7 @@ const FPIEnt* Func::findPrecedingFPI(Offset o) const { fe = cur; } } - assert(fe); + assertx(fe); return fe; } diff --git a/hphp/runtime/vm/globals-array.cpp b/hphp/runtime/vm/globals-array.cpp index 827c0167e97..01d3f353564 100644 --- a/hphp/runtime/vm/globals-array.cpp +++ b/hphp/runtime/vm/globals-array.cpp @@ -53,17 +53,17 @@ GlobalsArray::GlobalsArray(NameValueTable* tab) #undef X g_variables.set(this); - assert(hasExactlyOneRef()); + assertx(hasExactlyOneRef()); } inline GlobalsArray* GlobalsArray::asGlobals(ArrayData* ad) { - assert(ad->kind() == kGlobalsKind); + assertx(ad->kind() == kGlobalsKind); return static_cast(ad); } inline const GlobalsArray* GlobalsArray::asGlobals(const ArrayData* ad) { - assert(ad->kind() == kGlobalsKind); + assertx(ad->kind() == kGlobalsKind); return static_cast(ad); } @@ -254,7 +254,7 @@ ssize_t GlobalsArray::IterRewind(const ArrayData* ad, ssize_t prev) { bool GlobalsArray::ValidMArrayIter(const ArrayData* ad, const MArrayIter & fp) { - assert(fp.getContainer() == ad); + assertx(fp.getContainer() == ad); auto a = asGlobals(ad); if (fp.getResetFlag()) return false; if (fp.m_pos == IterEnd(a)) return false; diff --git a/hphp/runtime/vm/hhbc-codec.h b/hphp/runtime/vm/hhbc-codec.h index 0c3af54105e..4f273a12c35 100644 --- a/hphp/runtime/vm/hhbc-codec.h +++ b/hphp/runtime/vm/hhbc-codec.h @@ -70,7 +70,7 @@ void encode_op(Op op, F write_byte) { write_byte(static_cast(0xff)); rawVal -= 0xff; } - assert(rawVal < 0xff); + assertx(rawVal < 0xff); write_byte(rawVal); } @@ -141,7 +141,7 @@ void encode_member_key(MemberKey mk, UnitEmitter& ue); template void foreachSwitchTarget(PC pc, L func) { auto const op = decode_op(pc); - assert(isSwitch(op)); + assertx(isSwitch(op)); if (op == Op::Switch) { (void)decode_oa(pc); // skip bounded kind (void)decode_raw(pc); // skip base @@ -156,7 +156,7 @@ void foreachSwitchTarget(PC pc, L func) { template void foreachSSwitchString(PC pc, L func) { auto const UNUSED op = decode_op(pc); - assert(op == Op::SSwitch); + assertx(op == Op::SSwitch); int32_t size = decode_raw(pc) - 1; // the last item is the default for (int i = 0; i < size; ++i) { func(decode_raw(pc)); diff --git a/hphp/runtime/vm/hhbc.cpp b/hphp/runtime/vm/hhbc.cpp index 143ef3f9ad3..00a88f50831 100644 --- a/hphp/runtime/vm/hhbc.cpp +++ b/hphp/runtime/vm/hhbc.cpp @@ -34,7 +34,7 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// int numImmediates(Op opcode) { - assert(isValidOpcode(opcode)); + assertx(isValidOpcode(opcode)); static const int8_t values[] = { #define NA 0 #define ONE(...) 1 @@ -54,8 +54,8 @@ int numImmediates(Op opcode) { } ArgType immType(const Op opcode, int idx) { - assert(isValidOpcode(opcode)); - assert(idx >= 0 && idx < numImmediates(opcode)); + assertx(isValidOpcode(opcode)); + assertx(idx >= 0 && idx < numImmediates(opcode)); always_assert(idx < 4); // No opcodes have more than four immediates static const int8_t argTypes[][4] = { #define NA {-1, -1, -1, -1}, @@ -86,7 +86,7 @@ static size_t encoded_iva_size(uint8_t lowByte) { int immSize(PC origPC, int idx) { auto pc = origPC; auto const op = decode_op(pc); - assert(idx >= 0 && idx < numImmediates(op)); + assertx(idx >= 0 && idx < numImmediates(op)); always_assert(idx < 4); // No origPCs have more than four immediates static const int8_t argTypeToSizes[] = { #define ARGTYPE(nm, type) sizeof(type), @@ -157,7 +157,7 @@ int immSize(PC origPC, int idx) { } else if (itype == I32LA) { vecElemSz = sizeof(uint32_t); } else { - assert(itype == SLA); + assertx(itype == SLA); vecElemSz = sizeof(StrVecItem); } return sizeof(int32_t) + vecElemSz * decode_raw(pc); @@ -184,7 +184,7 @@ bool hasImmVector(Op opcode) { ArgUnion getImm(PC const origPC, int idx, const Unit* unit) { auto pc = origPC; auto const UNUSED op = decode_op(pc); - assert(idx >= 0 && idx < numImmediates(op)); + assertx(idx >= 0 && idx < numImmediates(op)); ArgUnion retval; retval.u_NA = 0; int cursor = 0; @@ -198,7 +198,7 @@ ArgUnion getImm(PC const origPC, int idx, const Unit* unit) { type == CAR || type == CAW) { retval.u_IVA = decode_iva(pc); } else if (type == KA) { - assert(unit != nullptr); + assertx(unit != nullptr); retval.u_KA = decode_member_key(pc, unit); } else if (type == LAR) { retval.u_LAR = decodeLocalRange(pc); @@ -213,12 +213,12 @@ ArgUnion getImm(PC const origPC, int idx, const Unit* unit) { ArgUnion* getImmPtr(PC const origPC, int idx) { auto pc = origPC; auto const UNUSED op = decode_op(pc); - assert(immType(op, idx) != IVA); - assert(immType(op, idx) != LA); - assert(immType(op, idx) != IA); - assert(immType(op, idx) != CAR); - assert(immType(op, idx) != CAW); - assert(immType(op, idx) != RATA); + assertx(immType(op, idx) != IVA); + assertx(immType(op, idx) != LA); + assertx(immType(op, idx) != IA); + assertx(immType(op, idx) != CAR); + assertx(immType(op, idx) != CAW); + assertx(immType(op, idx) != RATA); for (int i = 0; i < idx; i++) { pc += immSize(origPC, i); } @@ -299,7 +299,7 @@ Offset* instrJumpOffset(PC const origPC) { auto pc = origPC; auto const op = decode_op(pc); - assert(!isSwitch(op)); // BLA doesn't work here + assertx(!isSwitch(op)); // BLA doesn't work here if (op == OpIterBreak) { // offset is imm number 0 @@ -317,7 +317,7 @@ Offset* instrJumpOffset(PC const origPC) { case 2: immNum = 1; break; case 4: immNum = 2; break; case 8: immNum = 3; break; - default: assert(false); return nullptr; + default: assertx(false); return nullptr; } return &getImmPtr(origPC, immNum)->u_BA; @@ -437,7 +437,7 @@ int instrNumPops(PC pc) { // For instructions with vector immediates, we have to scan the contents of // the vector immediate to determine how many values are popped - assert(n == -1); + assertx(n == -1); ImmVector iv = getImmVector(pc); int k = iv.numStackValues(); return k; @@ -625,7 +625,7 @@ void staticArrayStreamer(const ArrayData* ad, std::string& out) { else if (ad->isDict()) out += "dict("; else if (ad->isKeyset()) out += "keyset("; else { - assert(ad->isPHPArray()); + assertx(ad->isPHPArray()); if (ad->isVArray()) out += "varray("; else if (ad->isDArray()) out += "darray("; else out += "array("; @@ -769,7 +769,7 @@ std::string instrToString(PC it, Either u) { #define READLITSTR(sep) do { \ Id id = decode_raw(it); \ if (id < 0) { \ - assert(op == OpSSwitch); \ + assertx(op == OpSSwitch); \ folly::format(&out, "{}-", sep); \ } else { \ auto const sd = lookupLitstrId(id); \ @@ -893,7 +893,7 @@ OPCODES #undef H_AA #undef H_VSA #undef H_KA - default: assert(false); + default: assertx(false); }; return out; } @@ -1147,9 +1147,9 @@ ImmVector getImmVector(PC opcode) { int instrFpToArDelta(const Func* func, PC opcode) { // This function should only be called for instructions that read the current // FPI - assert(instrReadsCurrentFpi(peek_op(opcode))); + assertx(instrReadsCurrentFpi(peek_op(opcode))); auto const fpi = func->findFPI(func->unit()->offsetOf(opcode)); - assert(fpi != nullptr); + assertx(fpi != nullptr); return fpi->m_fpOff; } diff --git a/hphp/runtime/vm/indexed-string-map.h b/hphp/runtime/vm/indexed-string-map.h index 6c163ac5f59..af36eec6896 100644 --- a/hphp/runtime/vm/indexed-string-map.h +++ b/hphp/runtime/vm/indexed-string-map.h @@ -63,7 +63,7 @@ struct IndexedStringMap { * builder below. */ void create(const Builder& b) { - assert(!size() && "IndexedStringMap::create called more than once"); + assertx(!size() && "IndexedStringMap::create called more than once"); setSize(b.size()); m_map.init(b.size(), size() * sizeof(T)); if (!b.size()) { @@ -109,7 +109,7 @@ struct IndexedStringMap { // Lookup entries by index. Index must be in range or you get // undefined behavior. T& operator[](Index index) { - assert(index < size()); + assertx(index < size()); return mutableAccessList()[index]; } const T& operator[](Index index) const { @@ -179,8 +179,8 @@ public: bool contains(const StringData* key) const { return m_map.count(key); } T& operator[](Index idx) { - assert(idx >= 0); - assert(size_t(idx) < m_list.size()); + assertx(idx >= 0); + assertx(size_t(idx) < m_list.size()); return m_list[idx]; } @@ -194,7 +194,7 @@ public: */ void add(const StringData* name, const T& t) { if (m_list.size() >= size_t(std::numeric_limits::max())) { - assert(false && "IndexedStringMap::Builder overflowed"); + assertx(false && "IndexedStringMap::Builder overflowed"); abort(); } diff --git a/hphp/runtime/vm/instance-bits.cpp b/hphp/runtime/vm/instance-bits.cpp index f00677ddf85..61b38fef54d 100644 --- a/hphp/runtime/vm/instance-bits.cpp +++ b/hphp/runtime/vm/instance-bits.cpp @@ -76,7 +76,7 @@ void profile(const StringData* name) { return; } - assert(name->isStatic()); + assertx(name->isStatic()); unsigned inc = 1; Class* c = Unit::lookupClass(name); if (c && (c->attrs() & AttrInterface)) { @@ -197,19 +197,19 @@ bool initted() { } unsigned lookup(const StringData* name) { - assert(g_initFlag.load(std::memory_order_acquire) || + assertx(g_initFlag.load(std::memory_order_acquire) || pthread_equal(s_initThread.load(std::memory_order_acquire), pthread_self())); if (auto const ptr = folly::get_ptr(s_instanceBitsMap, name)) { - assert(*ptr >= 1 && *ptr < kNumInstanceBits); + assertx(*ptr >= 1 && *ptr < kNumInstanceBits); return *ptr; } return 0; } bool getMask(const StringData* name, int& offset, uint8_t& mask) { - assert(g_initFlag.load(std::memory_order_acquire)); + assertx(g_initFlag.load(std::memory_order_acquire)); unsigned bit = lookup(name); if (!bit) return false; diff --git a/hphp/runtime/vm/jit/align-arm.cpp b/hphp/runtime/vm/jit/align-arm.cpp index 893ee23d6a8..ad70c756b9b 100644 --- a/hphp/runtime/vm/jit/align-arm.cpp +++ b/hphp/runtime/vm/jit/align-arm.cpp @@ -46,7 +46,7 @@ struct AlignImpl { switch (context) { case AlignContext::Live: { - assert(((bytes & 3) == 0) && "alignment must be multiple of 4"); + assertx(((bytes & 3) == 0) && "alignment must be multiple of 4"); for (; bytes > 0; bytes -= 4) { a.Nop(); } diff --git a/hphp/runtime/vm/jit/cfg-clean.cpp b/hphp/runtime/vm/jit/cfg-clean.cpp index b6958b73a2f..03ae0b173cc 100644 --- a/hphp/runtime/vm/jit/cfg-clean.cpp +++ b/hphp/runtime/vm/jit/cfg-clean.cpp @@ -79,7 +79,7 @@ bool convertCondBranchToJmp(IRUnit& unit, Block* block) { } if (isUnconditional) { - assert(takenBlk); + assertx(takenBlk); auto const bcctx = term.bcctx(); term.convertToNop(); // Removes edges to original dests. block->push_back(unit.gen(Jmp, bcctx, takenBlk)); diff --git a/hphp/runtime/vm/jit/code-cache.cpp b/hphp/runtime/vm/jit/code-cache.cpp index e7832e9f228..c3819a24114 100644 --- a/hphp/runtime/vm/jit/code-cache.cpp +++ b/hphp/runtime/vm/jit/code-cache.cpp @@ -99,7 +99,7 @@ CodeCache::CodeCache() auto enhugen = [&](void* base, int numMB) { if (CodeCache::MapTCHuge) { - assert((uintptr_t(base) & (kRoundUp - 1)) == 0); + assertx((uintptr_t(base) & (kRoundUp - 1)) == 0); hintHugeDeleteData((char*)base, numMB << 20, PROT_READ | PROT_WRITE | PROT_EXEC, false /* MAP_SHARED */); @@ -131,7 +131,7 @@ CodeCache::CodeCache() }; if (base != (uint8_t*)-1) { - assert(!(allocationSize & (kRoundUp - 1))); + assertx(!(allocationSize & (kRoundUp - 1))); // Make sure that we have space to round up to the start of a huge page allocationSize += -(uint64_t)base & (kRoundUp - 1); allocationSize += shiftTC(); @@ -157,7 +157,7 @@ CodeCache::CodeCache() } else { low_malloc_skip_huge(base, base + allocationSize - 1); } - assert(base); + assertx(base); base += baseAdjustment; m_base = base; @@ -210,9 +210,9 @@ CodeCache::CodeCache() } m_threadLocalSize = thread_local_size; - assert(base - m_base <= allocationSize); - assert(base - m_base + 2 * kRoundUp > allocationSize); - assert(base - m_base <= (2ul << 30)); + assertx(base - m_base <= allocationSize); + assertx(base - m_base + 2 * kRoundUp > allocationSize); + assertx(base - m_base <= (2ul << 30)); } CodeBlock& CodeCache::blockFor(CodeAddress addr) { diff --git a/hphp/runtime/vm/jit/extra-data.h b/hphp/runtime/vm/jit/extra-data.h index 957c3b58230..683727294bc 100644 --- a/hphp/runtime/vm/jit/extra-data.h +++ b/hphp/runtime/vm/jit/extra-data.h @@ -117,7 +117,7 @@ struct ClassData : IRExtraData { explicit ClassData(const Class* cls) : cls(cls) { - assert(cls != nullptr); + assertx(cls != nullptr); } std::string show() const { @@ -142,7 +142,7 @@ struct ExtendsClassData : IRExtraData { explicit ExtendsClassData(const Class* cls, bool strictLikely = false) : cls(cls), strictLikely(strictLikely) { - assert(cls != nullptr); + assertx(cls != nullptr); } std::string show() const { diff --git a/hphp/runtime/vm/jit/fixup.cpp b/hphp/runtime/vm/jit/fixup.cpp index 8b66ed6e038..f2b90815bb4 100644 --- a/hphp/runtime/vm/jit/fixup.cpp +++ b/hphp/runtime/vm/jit/fixup.cpp @@ -29,11 +29,11 @@ namespace HPHP { bool isVMFrame(const ActRec* ar) { - assert(ar); + assertx(ar); // Determine whether the frame pointer is outside the native stack, cleverly // using a single unsigned comparison to do both halves of the bounds check. bool ret = uintptr_t(ar) - s_stackLimit >= s_stackSize; - assert(!ret || isValidVMStackAddress(ar) || + assertx(!ret || isValidVMStackAddress(ar) || (ar->m_func->validate(), ar->resumed())); return ret; } diff --git a/hphp/runtime/vm/jit/gvn.cpp b/hphp/runtime/vm/jit/gvn.cpp index a219a3ea1a6..dd23914008a 100644 --- a/hphp/runtime/vm/jit/gvn.cpp +++ b/hphp/runtime/vm/jit/gvn.cpp @@ -136,8 +136,8 @@ struct CongruenceComparator { auto idxA = keyA.second; auto idxB = keyB.second; - assert(instA->op() == instB->op()); - assert(instA->is(DefLabel)); + assertx(instA->op() == instB->op()); + assertx(instA->is(DefLabel)); jit::hash_set valuesA; jit::hash_set valuesB; diff --git a/hphp/runtime/vm/jit/ir-unit-inl.h b/hphp/runtime/vm/jit/ir-unit-inl.h index acf51c06640..ab89dd2827d 100644 --- a/hphp/runtime/vm/jit/ir-unit-inl.h +++ b/hphp/runtime/vm/jit/ir-unit-inl.h @@ -266,7 +266,7 @@ inline uint32_t IRUnit::numIds(const IRInstruction*) const { } inline SSATmp* IRUnit::findSSATmp(uint32_t id) const { - assert(id < m_ssaTmps.size()); + assertx(id < m_ssaTmps.size()); return m_ssaTmps[id]; } diff --git a/hphp/runtime/vm/jit/irgen-arith.cpp b/hphp/runtime/vm/jit/irgen-arith.cpp index 88320a172c7..517a085a01c 100644 --- a/hphp/runtime/vm/jit/irgen-arith.cpp +++ b/hphp/runtime/vm/jit/irgen-arith.cpp @@ -491,7 +491,7 @@ SSATmp* emitMixedKeysetCmp(IRGS& env, Op op) { } void implNullCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TNull); + assertx(left->type() <= TNull); auto const rightTy = right->type(); // Left operand is null. @@ -526,7 +526,7 @@ void implNullCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implBoolCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TBool); + assertx(left->type() <= TBool); auto const rightTy = right->type(); if (rightTy <= TVec) { @@ -547,7 +547,7 @@ void implBoolCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implIntCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TInt); + assertx(left->type() <= TInt); auto const rightTy = right->type(); // Left operand is int. @@ -617,7 +617,7 @@ void implIntCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implDblCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TDbl); + assertx(left->type() <= TDbl); auto const rightTy = right->type(); // Left operand is a double. @@ -669,7 +669,7 @@ void implDblCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implArrCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TArr); + assertx(left->type() <= TArr); auto const rightTy = right->type(); // Left operand is an array. @@ -708,7 +708,7 @@ void implArrCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implVecCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TVec); + assertx(left->type() <= TVec); auto const rightTy = right->type(); // Left operand is a vec. @@ -720,7 +720,7 @@ void implVecCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implDictCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TDict); + assertx(left->type() <= TDict); auto const rightTy = right->type(); // Left operand is a dict. @@ -743,7 +743,7 @@ void implDictCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implKeysetCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TKeyset); + assertx(left->type() <= TKeyset); auto const rightTy = right->type(); // Left operand is a keyset. @@ -766,7 +766,7 @@ void implKeysetCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implStrCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TStr); + assertx(left->type() <= TStr); auto const rightTy = right->type(); // Left operand is a string. @@ -844,7 +844,7 @@ void implStrCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implObjCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TObj); + assertx(left->type() <= TObj); auto const rightTy = right->type(); // Left operand is an object. @@ -934,7 +934,7 @@ void implObjCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { } void implResCmp(IRGS& env, Op op, SSATmp* left, SSATmp* right) { - assert(left->type() <= TRes); + assertx(left->type() <= TRes); auto const rightTy = right->type(); // Left operand is a resource. diff --git a/hphp/runtime/vm/jit/irgen-builtin.cpp b/hphp/runtime/vm/jit/irgen-builtin.cpp index 72b5c86c1f8..b717ac4fcff 100644 --- a/hphp/runtime/vm/jit/irgen-builtin.cpp +++ b/hphp/runtime/vm/jit/irgen-builtin.cpp @@ -295,7 +295,7 @@ SSATmp* opt_ini_get(IRGS& env, const ParamPrep& params) { // TC, but for non-system settings, we can optimize them as a load from the // known static address or thread-local address of where the setting lives. // This might be worth doing specifically for the zend.assertions setting, - // for which the emitter emits an ini_get around every call to assert(). + // for which the emitter emits an ini_get around every call to assertx(). auto const settingName = params[0].value->strVal()->toCppString(); IniSetting::Mode mode = IniSetting::PHP_INI_NONE; if (!IniSetting::GetMode(settingName, mode)) { @@ -1143,7 +1143,7 @@ SSATmp* realize_param(IRGS& env, R realize) { if (param.needsConversion) { auto const baseTy = targetTy - TNull; - assert(baseTy.isKnownDataType()); + assertx(baseTy.isKnownDataType()); auto const convertTy = (!callee->isParamCoerceMode() && targetTy == TNullableObj) ? targetTy : baseTy; @@ -1898,7 +1898,7 @@ void implGenericIdx(IRGS& env) { SSATmp* const args[] = { base, key, def }; static auto func = Unit::lookupBuiltin(s_idx.get()); - assert(func && func->numParams() == 3); + assertx(func && func->numParams() == 3); emitDirectCall(env, func, 3, args); } diff --git a/hphp/runtime/vm/jit/irgen-internal.h b/hphp/runtime/vm/jit/irgen-internal.h index ea4825533a8..4eac63d52ce 100644 --- a/hphp/runtime/vm/jit/irgen-internal.h +++ b/hphp/runtime/vm/jit/irgen-internal.h @@ -342,7 +342,7 @@ void ifNonNull(IRGS& env, SSATmp* tmp, Then then) { // Eval stack manipulation inline SSATmp* assertType(SSATmp* tmp, Type type) { - assert(!tmp || tmp->isA(type)); + assertx(!tmp || tmp->isA(type)); return tmp; } @@ -811,7 +811,7 @@ inline void stLocMove(IRGS& env, // of the ref, since it may side-exit. auto const predTy = env.irb->predictedLocalInnerType(id); - assert(ldrefExit); + assertx(ldrefExit); gen(env, CheckRefInner, predTy, ldrefExit, box); auto const innerCell = gen(env, LdRef, predTy, box); diff --git a/hphp/runtime/vm/jit/irgen-interpone.cpp b/hphp/runtime/vm/jit/irgen-interpone.cpp index 81aadd858b8..8753ab308dc 100644 --- a/hphp/runtime/vm/jit/irgen-interpone.cpp +++ b/hphp/runtime/vm/jit/irgen-interpone.cpp @@ -218,7 +218,7 @@ interpOutputLocals(IRGS& env, locals.emplace_back(id, relaxToGuardable(t)); }; auto setImmLocType = [&](uint32_t id, Type t) { - assert(id < 4); + assertx(id < 4); setLocType(inst.imm[id].u_LA, t); }; auto handleBoxiness = [&] (Type testTy, Type useTy) { diff --git a/hphp/runtime/vm/jit/irgen-minstr.cpp b/hphp/runtime/vm/jit/irgen-minstr.cpp index 30191af83b2..385ef41d2bc 100644 --- a/hphp/runtime/vm/jit/irgen-minstr.cpp +++ b/hphp/runtime/vm/jit/irgen-minstr.cpp @@ -2190,7 +2190,7 @@ void emitUnsetM(IRGS& env, uint32_t nDiscard, MemberKey mk) { if (mcodeIsProp(mk.mcode)) { gen(env, UnsetProp, extractBaseIfObj(env), key); } else { - assert(mcodeIsElem(mk.mcode)); + assertx(mcodeIsElem(mk.mcode)); gen(env, UnsetElem, ldMBase(env), key); } diff --git a/hphp/runtime/vm/jit/irgen-resumable.cpp b/hphp/runtime/vm/jit/irgen-resumable.cpp index 240ea571d7c..2fbd1b2ab5b 100644 --- a/hphp/runtime/vm/jit/irgen-resumable.cpp +++ b/hphp/runtime/vm/jit/irgen-resumable.cpp @@ -533,7 +533,7 @@ void emitContValid(IRGS& env) { } void emitContStarted(IRGS& env) { - assert(curClass(env)); + assertx(curClass(env)); auto const cont = ldThis(env); push(env, gen(env, ContStarted, cont)); } diff --git a/hphp/runtime/vm/jit/irgen-types.cpp b/hphp/runtime/vm/jit/irgen-types.cpp index 40cba898213..bece12c9a1c 100644 --- a/hphp/runtime/vm/jit/irgen-types.cpp +++ b/hphp/runtime/vm/jit/irgen-types.cpp @@ -75,14 +75,14 @@ SSATmp* ldClassSafe(IRGS& env, const StringData* className, */ SSATmp* implInstanceCheck(IRGS& env, SSATmp* src, const StringData* className, SSATmp* checkCls) { - assert(src->isA(TObj)); + assertx(src->isA(TObj)); if (s_Awaitable.get()->isame(className)) { return gen(env, IsWaitHandle, src); } auto knownCls = checkCls->hasConstVal(TCls) ? checkCls->clsVal() : nullptr; - assert(IMPLIES(knownCls, classIsUniqueOrCtxParent(env, knownCls))); - assert(IMPLIES(knownCls, knownCls->name()->isame(className))); + assertx(IMPLIES(knownCls, classIsUniqueOrCtxParent(env, knownCls))); + assertx(IMPLIES(knownCls, knownCls->name()->isame(className))); auto const srcType = src->type(); @@ -336,7 +336,7 @@ void verifyTypeImpl(IRGS& env, int32_t const id, bool isReturnType, ); return; } - assert(IMPLIES(tc.isThis(), RuntimeOption::EvalThisTypeHintLevel == 1)); + assertx(IMPLIES(tc.isThis(), RuntimeOption::EvalThisTypeHintLevel == 1)); // If we reach here then valType is Obj and tc is Object, Self, or Parent const StringData* clsName; diff --git a/hphp/runtime/vm/jit/irlower-class-func.cpp b/hphp/runtime/vm/jit/irlower-class-func.cpp index 2fa579918bd..2d4f4057444 100644 --- a/hphp/runtime/vm/jit/irlower-class-func.cpp +++ b/hphp/runtime/vm/jit/irlower-class-func.cpp @@ -155,8 +155,8 @@ void cgCheckInitSProps(IRLS& env, const IRInstruction* inst) { v << jcc{CC_NE, sf, {label(env, inst->next()), label(env, inst->taken())}}; } else { // Always initialized; just fall through to inst->next(). - assert(rds::isPersistentHandle(handle)); - assert(rds::handleToRef(handle)); + assertx(rds::isPersistentHandle(handle)); + assertx(rds::handleToRef(handle)); } } diff --git a/hphp/runtime/vm/jit/irlower-cmp.cpp b/hphp/runtime/vm/jit/irlower-cmp.cpp index ed737355e6e..8aa738298fd 100644 --- a/hphp/runtime/vm/jit/irlower-cmp.cpp +++ b/hphp/runtime/vm/jit/irlower-cmp.cpp @@ -131,8 +131,8 @@ void cgCmpBool(IRLS& env, const IRInstruction* inst) { auto const extended0 = v.makeReg(); auto const extended1 = v.makeReg(); - assert(inst->src(0)->type() <= TBool); - assert(inst->src(1)->type() <= TBool); + assertx(inst->src(0)->type() <= TBool); + assertx(inst->src(1)->type() <= TBool); v << movzbq{s0, extended0}; v << movzbq{s1, extended1}; @@ -149,8 +149,8 @@ void cgCmpInt(IRLS& env, const IRInstruction* inst) { auto const tmp1 = v.makeReg(); auto const tmp2 = v.makeReg(); - assert(inst->src(0)->type() <= TInt); - assert(inst->src(1)->type() <= TInt); + assertx(inst->src(0)->type() <= TInt); + assertx(inst->src(1)->type() <= TInt); v << cmpq{s1, s0, sf}; v << setcc{CC_G, sf, tmp1}; @@ -233,8 +233,8 @@ void cgCmpDbl(IRLS& env, const IRInstruction* inst) { auto const tmp1 = v.makeReg(); auto const tmp2 = v.makeReg(); - assert(inst->src(0)->type() <= TDbl); - assert(inst->src(1)->type() <= TDbl); + assertx(inst->src(0)->type() <= TDbl); + assertx(inst->src(1)->type() <= TDbl); v << ucomisd{s0, s1, sf}; v << cmovq{CC_A, sf, v.cns(-1), v.cns(1), tmp1}; diff --git a/hphp/runtime/vm/jit/irlower-internal-inl.h b/hphp/runtime/vm/jit/irlower-internal-inl.h index 204333075c5..56008cdc2b5 100644 --- a/hphp/runtime/vm/jit/irlower-internal-inl.h +++ b/hphp/runtime/vm/jit/irlower-internal-inl.h @@ -38,8 +38,8 @@ namespace HPHP { namespace jit { namespace irlower { /////////////////////////////////////////////////////////////////////////////// -inline Vout& vmain(IRLS& env) { assert(env.vmain); return *env.vmain; } -inline Vout& vcold(IRLS& env) { assert(env.vcold); return *env.vcold; } +inline Vout& vmain(IRLS& env) { assertx(env.vmain); return *env.vmain; } +inline Vout& vcold(IRLS& env) { assertx(env.vcold); return *env.vcold; } inline Vlabel label(IRLS& env, Block* b) { return env.labels[b]; } diff --git a/hphp/runtime/vm/jit/irlower-refcount.cpp b/hphp/runtime/vm/jit/irlower-refcount.cpp index a6fab708c97..1eb0a117ec8 100644 --- a/hphp/runtime/vm/jit/irlower-refcount.cpp +++ b/hphp/runtime/vm/jit/irlower-refcount.cpp @@ -92,7 +92,7 @@ void ifRefCountedType(Vout& v, Vout& vtaken, Type ty, Vloc loc, Then then) { v << testqi{ActRec::kHasClassBit, loc.reg(0), sf}; cond = CC_E; } else { - assert(ty <= TGen); + assertx(ty <= TGen); emitCmpTVType(v, sf, KindOfRefCountThreshold, loc.reg(1)); } unlikelyIfThen(v, vtaken, cond, sf, then); diff --git a/hphp/runtime/vm/jit/licm.cpp b/hphp/runtime/vm/jit/licm.cpp index 2fc0065928a..384fa9ba299 100644 --- a/hphp/runtime/vm/jit/licm.cpp +++ b/hphp/runtime/vm/jit/licm.cpp @@ -599,7 +599,7 @@ void hoist_invariant(LoopEnv& env) { auto const preh = pre_header(env); FTRACE(1, "moving {} to B{}\n", inst->toString(), preh->id()); inst->block()->erase(inst); - assert(!inst->taken() && !inst->next()); + assertx(!inst->taken() && !inst->next()); preh->insert(std::prev(preh->end()), inst); } } @@ -647,7 +647,7 @@ void hoist_check_instruction(LoopEnv& env, // Note that the current pre_header jump may have arguments. We need to // preserve them in the new pre_header, so we have to keep the same // instruction. - assert(preh->back().is(Jmp)); + assertx(preh->back().is(Jmp)); auto const jmp = &preh->back(); auto const new_preh = env.global.unit.defBlock(linfo(env).numInvocations); preh->erase(jmp); diff --git a/hphp/runtime/vm/jit/load-elim.cpp b/hphp/runtime/vm/jit/load-elim.cpp index 81534034441..6fb5ec84c0d 100644 --- a/hphp/runtime/vm/jit/load-elim.cpp +++ b/hphp/runtime/vm/jit/load-elim.cpp @@ -339,7 +339,7 @@ Flags load(Local& env, auto const meta = env.global.ainfo.find(acls); if (!meta) return FNone{}; - assert(meta->index < kMaxTrackedALocs); + assertx(meta->index < kMaxTrackedALocs); auto& tracked = env.state.tracked[meta->index]; diff --git a/hphp/runtime/vm/jit/mcgen-translate.cpp b/hphp/runtime/vm/jit/mcgen-translate.cpp index b6f142034d4..702f07c1bef 100644 --- a/hphp/runtime/vm/jit/mcgen-translate.cpp +++ b/hphp/runtime/vm/jit/mcgen-translate.cpp @@ -408,7 +408,7 @@ folly::Optional translate(TransArgs args, FPInvOffset spOff, folly::Optional optView) { INC_TPC(translate); - assert(args.kind != TransKind::Invalid); + assertx(args.kind != TransKind::Invalid); if (!tc::shouldTranslate(args.sk.func(), args.kind)) return folly::none; diff --git a/hphp/runtime/vm/jit/minstr-helpers.h b/hphp/runtime/vm/jit/minstr-helpers.h index e06460e4138..34f9590be4a 100644 --- a/hphp/runtime/vm/jit/minstr-helpers.h +++ b/hphp/runtime/vm/jit/minstr-helpers.h @@ -508,7 +508,7 @@ ELEM_HELPER_TABLE(X) template inline member_rval checkedGet(ArrayData* a, StringData* key) { int64_t i; - assert(a->isPHPArray()); + assertx(a->isPHPArray()); if (UNLIKELY(key->isStrictlyInteger(i))) { if (intishWarn) raise_intish_index_cast(); return warn ? a->rvalStrict(i) : a->rval(i); @@ -635,7 +635,7 @@ TypedValue arrayGetImpl(ArrayData* a, key_type key) { raise_inout_undefined_index(key); return make_tv(); } - assert(mode == MOpMode::Warn); + assertx(mode == MOpMode::Warn); return arrayGetNotFound(key); } @@ -848,7 +848,7 @@ inline ArrayData* checkedSet(ArrayData* a, Cell value, bool copy) { int64_t i; - assert(a->isPHPArray()); + assertx(a->isPHPArray()); if (UNLIKELY(key->isStrictlyInteger(i))) { if (intishWarn) raise_intish_index_cast(); return a->set(i, value, copy); diff --git a/hphp/runtime/vm/jit/mutation.cpp b/hphp/runtime/vm/jit/mutation.cpp index e355c9d39ab..627502c2ab1 100644 --- a/hphp/runtime/vm/jit/mutation.cpp +++ b/hphp/runtime/vm/jit/mutation.cpp @@ -291,7 +291,7 @@ void refineTmps(IRUnit& unit, SSATmp* insertPhi(IRUnit& unit, Block* blk, const jit::vector& inputs) { - assert(blk->numPreds() > 1); + assertx(blk->numPreds() > 1); auto label = &blk->front(); if (!label->is(DefLabel)) { label = unit.defLabel(1, label->bcctx()); diff --git a/hphp/runtime/vm/jit/phys-reg.h b/hphp/runtime/vm/jit/phys-reg.h index 613f96ba5df..bf24838e134 100644 --- a/hphp/runtime/vm/jit/phys-reg.h +++ b/hphp/runtime/vm/jit/phys-reg.h @@ -369,7 +369,7 @@ public: auto const go = [&] (uint64_t& bits, off_t off) { while (ffs64(bits, out)) { - assert(0 <= out && out < 64); + assertx(0 <= out && out < 64); bits &= ~(uint64_t{1} << out); f(PhysReg(out + off)); } @@ -389,7 +389,7 @@ public: auto const go = [&] (uint64_t& bits, off_t off) { while (ffs64(bits, out)) { - assert(0 <= out && out < 64); + assertx(0 <= out && out < 64); bits &= ~(uint64_t{1} << out); r[i++] = out + off; if (i > 1) { @@ -412,7 +412,7 @@ public: auto const go = [&] (uint64_t& bits, off_t off) { while (fls64(bits, out)) { - assert(0 <= out && out < 64); + assertx(0 <= out && out < 64); bits &= ~(uint64_t{1} << out); f(PhysReg(out + off)); } @@ -433,7 +433,7 @@ public: auto const go = [&] (uint64_t& bits, off_t off) { while (fls64(bits, out)) { - assert(0 <= out && out < 64); + assertx(0 <= out && out < 64); bits &= ~(uint64_t{1} << out); r[i++] = out + off; if (i > 1) { diff --git a/hphp/runtime/vm/jit/reg-algorithms.cpp b/hphp/runtime/vm/jit/reg-algorithms.cpp index 690bf52e7cf..0ad1139ab71 100644 --- a/hphp/runtime/vm/jit/reg-algorithms.cpp +++ b/hphp/runtime/vm/jit/reg-algorithms.cpp @@ -74,7 +74,7 @@ doVregMoves(Vunit& unit, MovePlan& moves) { // next already visited; check if next is on current path. if (index[next] >= index[reg]) { // found a cycle. - assert(num_cycles < N); + assertx(num_cycles < N); cycles[num_cycles++] = { next, nextIndex - index[next] }; } } @@ -171,7 +171,7 @@ jit::vector doRegMoves(MovePlan& moves, PhysReg rTmp) { // next already visited; check if next is on current path. if (index[next] >= index[reg]) { // found a cycle. - assert(num_cycles < N); + assertx(num_cycles < N); cycles[num_cycles++] = { next, nextIndex - index[next] }; } } diff --git a/hphp/runtime/vm/jit/region-hot-cfg.cpp b/hphp/runtime/vm/jit/region-hot-cfg.cpp index 4a8221d9600..fc55b167c79 100644 --- a/hphp/runtime/vm/jit/region-hot-cfg.cpp +++ b/hphp/runtime/vm/jit/region-hot-cfg.cpp @@ -93,12 +93,12 @@ private: Trace::Indent indent; auto sk = profRegion.blocks().back()->last(); - assert(sk.op() == OpSwitch); + assertx(sk.op() == OpSwitch); TargetProfile profile(tid, TransKind::Optimize, sk.offset(), s_switchProfile.get()); - assert(!profile.profiling()); + assertx(!profile.profiling()); if (!profile.optimizing()) { // We don't have profile data for this Switch, most likely because it saw // some weird input type during profiling. diff --git a/hphp/runtime/vm/jit/region-tracelet.cpp b/hphp/runtime/vm/jit/region-tracelet.cpp index a135aa00f20..da8cec2efb9 100644 --- a/hphp/runtime/vm/jit/region-tracelet.cpp +++ b/hphp/runtime/vm/jit/region-tracelet.cpp @@ -281,7 +281,7 @@ bool traceThroughJmp(Env& env) { // We want to keep profiling translations to basic blocks, inlining shouldn't // happen in profiling translations if (env.profiling) { - assert(!env.inlining); + assertx(!env.inlining); return false; } diff --git a/hphp/runtime/vm/jit/relocation-ppc64.cpp b/hphp/runtime/vm/jit/relocation-ppc64.cpp index 0e0b910d481..77fcb9ba380 100644 --- a/hphp/runtime/vm/jit/relocation-ppc64.cpp +++ b/hphp/runtime/vm/jit/relocation-ppc64.cpp @@ -245,7 +245,7 @@ size_t relocateImpl(RelocationInfo& rel, keep_nops = rel.isSmashableRelocation(dest); } if (!d2.setFarBranchTarget(new_far_target, keep_nops)) { - assert(false && "Far branch target setting failed"); + assertx(false && "Far branch target setting failed"); } if (d2.couldBeNearBranch()) { // target is close enough, convert it to Near branch @@ -400,7 +400,7 @@ void adjustCodeForRelocation(RelocationInfo& rel, CGMeta& fixups) { void findFixups(TCA start, TCA end, CGMeta& meta) { while (start != end) { - assert(start < end); + assertx(start < end); DecodedInstruction di(start); start += di.size(); diff --git a/hphp/runtime/vm/jit/relocation-x64.cpp b/hphp/runtime/vm/jit/relocation-x64.cpp index fbbbbf595e5..2b40098f1c7 100644 --- a/hphp/runtime/vm/jit/relocation-x64.cpp +++ b/hphp/runtime/vm/jit/relocation-x64.cpp @@ -404,7 +404,7 @@ void adjustCodeForRelocation(RelocationInfo& rel, CGMeta& fixups) { void findFixups(TCA start, TCA end, CGMeta& meta) { while (start != end) { - assert(start < end); + assertx(start < end); DecodedInstruction di(start); start += di.size(); diff --git a/hphp/runtime/vm/jit/relocation.cpp b/hphp/runtime/vm/jit/relocation.cpp index cd2f884a713..b738f0a5ca8 100644 --- a/hphp/runtime/vm/jit/relocation.cpp +++ b/hphp/runtime/vm/jit/relocation.cpp @@ -247,11 +247,11 @@ void adjustMetaDataForRelocation(RelocationInfo& rel, ARCH_SWITCH_CALL(adjustMetaDataForRelocation, rel, asmInfo, meta); if (asmInfo) { - assert(asmInfo->validate()); + assertx(asmInfo->validate()); rel.fixupRanges(asmInfo, AreaIndex::Main); rel.fixupRanges(asmInfo, AreaIndex::Cold); rel.fixupRanges(asmInfo, AreaIndex::Frozen); - assert(asmInfo->validate()); + assertx(asmInfo->validate()); } } diff --git a/hphp/runtime/vm/jit/service-request-handlers.cpp b/hphp/runtime/vm/jit/service-request-handlers.cpp index af95f58e9a1..a52b09d371a 100644 --- a/hphp/runtime/vm/jit/service-request-handlers.cpp +++ b/hphp/runtime/vm/jit/service-request-handlers.cpp @@ -334,7 +334,7 @@ TCA handleServiceRequest(ReqInfo& info) noexcept { auto delegate = gen->m_delegate.m_data.pobj; // We only checked that our delegate is an object, but we can't get // into this situation if the object itself isn't a Generator - assert(delegate->getVMClass() == Generator::getClass()); + assertx(delegate->getVMClass() == Generator::getClass()); // Ok so we're in a `yield from` situation, we know our ar is garbage. // The ar that we're looking for is the ar of the delegate generator, // so grab that here. @@ -347,7 +347,7 @@ TCA handleServiceRequest(ReqInfo& info) noexcept { if (ar->isFCallAwait()) { // If there was an interped FCallAwait, and we return via the // jit, we need to deal with the suspend case here. - assert(ar->retSlot()->m_aux.u_fcallAwaitFlag < 2); + assertx(ar->retSlot()->m_aux.u_fcallAwaitFlag < 2); if (ar->retSlot()->m_aux.u_fcallAwaitFlag) { start = tc::ustubs().fcallAwaitSuspendHelper; break; @@ -365,7 +365,7 @@ TCA handleServiceRequest(ReqInfo& info) noexcept { case REQ_POST_DEBUGGER_RET: { auto fp = vmfp(); auto caller = fp->func(); - assert(g_unwind_rds.isInit()); + assertx(g_unwind_rds.isInit()); vmpc() = caller->unit()->at(caller->base() + g_unwind_rds->debuggerReturnOff); FTRACE(3, "REQ_DEBUGGER_RET: pc {} in {}\n", diff --git a/hphp/runtime/vm/jit/service-requests.cpp b/hphp/runtime/vm/jit/service-requests.cpp index 75f3115a007..435e768dc3e 100644 --- a/hphp/runtime/vm/jit/service-requests.cpp +++ b/hphp/runtime/vm/jit/service-requests.cpp @@ -75,7 +75,7 @@ void emit_svcreq(CodeBlock& cb, { CGMeta fixups; - SCOPE_EXIT { assert(fixups.empty()); }; + SCOPE_EXIT { assertx(fixups.empty()); }; Vauto vasm{stub, stub, data, fixups}; auto& v = vasm.main(); @@ -90,7 +90,7 @@ void emit_svcreq(CodeBlock& cb, auto live_out = leave_trace_regs(); - assert(argv.size() <= kMaxArgs); + assertx(argv.size() <= kMaxArgs); // Pick up CondCode arguments first---vasm may optimize immediate loads // into operations which clobber status flags. diff --git a/hphp/runtime/vm/jit/simplify.cpp b/hphp/runtime/vm/jit/simplify.cpp index 98761d2aa4e..675f46b5350 100644 --- a/hphp/runtime/vm/jit/simplify.cpp +++ b/hphp/runtime/vm/jit/simplify.cpp @@ -3374,7 +3374,7 @@ SSATmp* simplifyCallBuiltin(State& env, const IRInstruction* inst) { if (cls->classof(c_Awaitable::classof())) { auto const genState = [&] (Opcode op, int64_t whstate) -> SSATmp* { // these methods all spring from the base class - assert(callee->cls()->name()->isame(s_Awaitable.get())); + assertx(callee->cls()->name()->isame(s_Awaitable.get())); auto const state = gen(env, LdWHState, thiz); return gen(env, op, state, cns(env, whstate)); }; diff --git a/hphp/runtime/vm/jit/smashable-instr-x64.cpp b/hphp/runtime/vm/jit/smashable-instr-x64.cpp index c6ba02d33fd..46c33c5fc1b 100644 --- a/hphp/runtime/vm/jit/smashable-instr-x64.cpp +++ b/hphp/runtime/vm/jit/smashable-instr-x64.cpp @@ -132,7 +132,7 @@ void smashJmp(TCA inst, TCA target) { // we always leave the instruction in a consistent state. auto const imm = safe_cast(target - (inst + 5)); if (inst[0] != 0xe9) { - assert(inst[0] == 0x0f && inst[1] == 0x1f && inst[2] == 0x44); + assertx(inst[0] == 0x0f && inst[1] == 0x1f && inst[2] == 0x44); auto const last = 0xff & (imm >> 24); auto const first = 0xe9 | ((size_t(imm) & 0xffffffULL) << 8); diff --git a/hphp/runtime/vm/jit/srcdb.cpp b/hphp/runtime/vm/jit/srcdb.cpp index de542894399..72381702069 100644 --- a/hphp/runtime/vm/jit/srcdb.cpp +++ b/hphp/runtime/vm/jit/srcdb.cpp @@ -94,17 +94,17 @@ TCA TransLoc::coldStart() const { return tc::offsetToAddr(m_coldOff); } TCA TransLoc::frozenStart() const { return tc::offsetToAddr(m_frozenOff); } void TransLoc::setMainStart(TCA newStart) { - assert(tc::isValidCodeAddress(newStart)); + assertx(tc::isValidCodeAddress(newStart)); m_mainOff = tc::addrToOffset(newStart); } void TransLoc::setColdStart(TCA newStart) { - assert(tc::isValidCodeAddress(newStart)); + assertx(tc::isValidCodeAddress(newStart)); m_coldOff = tc::addrToOffset(newStart); } void TransLoc::setFrozenStart(TCA newStart) { - assert(tc::isValidCodeAddress(newStart)); + assertx(tc::isValidCodeAddress(newStart)); m_frozenOff = tc::addrToOffset(newStart); } diff --git a/hphp/runtime/vm/jit/srcdb.h b/hphp/runtime/vm/jit/srcdb.h index 23b2a812446..04ed12c039a 100644 --- a/hphp/runtime/vm/jit/srcdb.h +++ b/hphp/runtime/vm/jit/srcdb.h @@ -105,7 +105,7 @@ struct TransLoc { void setFrozenStart(TCA newFrozen); void setMainSize(size_t size) { - assert(size < std::numeric_limits::max()); + assertx(size < std::numeric_limits::max()); m_mainLen = (uint32_t)size; } diff --git a/hphp/runtime/vm/jit/store-elim.cpp b/hphp/runtime/vm/jit/store-elim.cpp index 6585c55485b..95df5cb9d54 100644 --- a/hphp/runtime/vm/jit/store-elim.cpp +++ b/hphp/runtime/vm/jit/store-elim.cpp @@ -1153,7 +1153,7 @@ TrackedStore combine_ts(Global& genv, uint32_t id, auto compat = [](TrackedStore store1, TrackedStore store2) { auto i1 = store1.instruction(); auto i2 = store2.instruction(); - assert(i1 && i2); + assertx(i1 && i2); if (i1->op() != i2->op()) return Compat::Bad; if (i1->numSrcs() != i2->numSrcs()) return Compat::Bad; for (auto i = i1->numSrcs(); i--; ) { @@ -1317,7 +1317,7 @@ void compute_available_stores( auto tsNew = succ->numPreds() == 1 ? ts : recompute_ts(genv, i, succ); if (!tsNew.same(tsSucc)) { changed = true; - assert(tsNew >= tsSucc); + assertx(tsNew >= tsSucc); tsSucc = tsNew; if (tsSucc.isBad()) { if (sf) { diff --git a/hphp/runtime/vm/jit/target-cache.cpp b/hphp/runtime/vm/jit/target-cache.cpp index eed4d2d0071..0306c42403f 100644 --- a/hphp/runtime/vm/jit/target-cache.cpp +++ b/hphp/runtime/vm/jit/target-cache.cpp @@ -256,7 +256,7 @@ void lookup(Entry* mce, ActRec* ar, StringData* name, Class* cls, Class* ctx) { return nullFunc(ar, name); } ar->setMagicDispatch(name); - assert(!(func->attrs() & AttrStatic)); + assertx(!(func->attrs() & AttrStatic)); ar->m_func = func; mce->m_key = reinterpret_cast(cls) | 0x1u; mce->m_value = func; diff --git a/hphp/runtime/vm/jit/tc-internal.cpp b/hphp/runtime/vm/jit/tc-internal.cpp index 047e7696033..2f92656ab29 100644 --- a/hphp/runtime/vm/jit/tc-internal.cpp +++ b/hphp/runtime/vm/jit/tc-internal.cpp @@ -221,7 +221,7 @@ void requestInit() { Stats::init(); requestInitProfData(); s_initialTCSize = g_code->totalUsed(); - assert(!g_unwind_rds.isInit()); + assertx(!g_unwind_rds.isInit()); memset(g_unwind_rds.get(), 0, sizeof(UnwindRDS)); g_unwind_rds.markInit(); } diff --git a/hphp/runtime/vm/jit/tc-internal.h b/hphp/runtime/vm/jit/tc-internal.h index d81f2ca1631..ec73dd93157 100644 --- a/hphp/runtime/vm/jit/tc-internal.h +++ b/hphp/runtime/vm/jit/tc-internal.h @@ -194,7 +194,7 @@ bool newTranslation(); */ ALWAYS_INLINE CodeCache& code() { extern CodeCache* g_code; - assert(g_code); + assertx(g_code); return *g_code; } diff --git a/hphp/runtime/vm/jit/tc-record.cpp b/hphp/runtime/vm/jit/tc-record.cpp index c4babd7cf92..85836776a34 100644 --- a/hphp/runtime/vm/jit/tc-record.cpp +++ b/hphp/runtime/vm/jit/tc-record.cpp @@ -130,7 +130,7 @@ static InitFiniNode initCodeSizeCounters([] { }, InitFiniNode::When::PostRuntimeOptions); ServiceData::ExportedTimeSeries* getCodeSizeCounter(const std::string& name) { - assert(!s_counters.empty()); + assertx(!s_counters.empty()); return s_counters.at(name); } diff --git a/hphp/runtime/vm/jit/tc-recycle.cpp b/hphp/runtime/vm/jit/tc-recycle.cpp index 6028f1ec3b8..bbbe03525bd 100644 --- a/hphp/runtime/vm/jit/tc-recycle.cpp +++ b/hphp/runtime/vm/jit/tc-recycle.cpp @@ -288,7 +288,7 @@ void clearRange(TCA start, size_t len, const char* info) { cb.init(start, len, info); CGMeta fixups; - SCOPE_EXIT { assert(fixups.empty()); }; + SCOPE_EXIT { assertx(fixups.empty()); }; DataBlock db; Vauto vasm { cb, cb, db, fixups }; diff --git a/hphp/runtime/vm/jit/tc-relocate.cpp b/hphp/runtime/vm/jit/tc-relocate.cpp index 4439087a710..5c4b42a5599 100644 --- a/hphp/runtime/vm/jit/tc-relocate.cpp +++ b/hphp/runtime/vm/jit/tc-relocate.cpp @@ -94,7 +94,7 @@ struct CodeSmasher { cb.init(e.first, e.second - e.first, "relocated"); CGMeta fixups; - SCOPE_EXIT { assert(fixups.empty()); }; + SCOPE_EXIT { assertx(fixups.empty()); }; DataBlock db; Vauto vasm { cb, cb, db, fixups }; @@ -282,7 +282,7 @@ void readRelocations( } continue; } - assert(pos != std::string::npos && pos > n); + assertx(pos != std::string::npos && pos > n); auto b64 = line.substr(pos + 1); auto decoded = base64_decode(b64.c_str(), b64.size(), true); @@ -323,7 +323,7 @@ void adjustProfiledCallers(RelocationInfo& rel) { void relocate(std::vector& relocs, CodeBlock& dest, CGMeta& fixups) { assertOwnsCodeLock(); - assert(!Func::s_treadmill); + assertx(!Func::s_treadmill); auto newRelocMapName = Debug::DebugInfo::Get()->getRelocMapName() + ".tmp"; auto newRelocMap = fopen(newRelocMapName.c_str(), "w+"); @@ -349,7 +349,7 @@ void relocate(std::vector& relocs, CodeBlock& dest, RelocationInfo rel; size_t num = 0; - assert(fixups.alignments.empty()); + assertx(fixups.alignments.empty()); for (size_t sz = relocs.size(); num < sz; num++) { auto& reloc = relocs[num]; if (ignoreEntry(reloc.sk)) continue; @@ -370,7 +370,7 @@ void relocate(std::vector& relocs, CodeBlock& dest, } } swap_trick(fixups.alignments); - assert(fixups.empty()); + assertx(fixups.empty()); adjustForRelocation(rel); @@ -561,7 +561,7 @@ bool relocateNewTranslation(TransLoc& loc, cb.init(start, end - start, "Dead code"); CGMeta fixups; - SCOPE_EXIT { assert(fixups.empty()); }; + SCOPE_EXIT { assertx(fixups.empty()); }; DataBlock db; Vauto vasm { cb, cb, db, fixups }; @@ -643,7 +643,7 @@ void liveRelocate(int time) { unsigned new_size = g() % ((relocs.size() + 1) >> 1); new_size += (relocs.size() + 3) >> 2; - assert(new_size > 0 && new_size <= relocs.size()); + assertx(new_size > 0 && new_size <= relocs.size()); relocs.resize(new_size); } else { diff --git a/hphp/runtime/vm/jit/translator-runtime.cpp b/hphp/runtime/vm/jit/translator-runtime.cpp index 4f7a0571cfa..3307432ede2 100644 --- a/hphp/runtime/vm/jit/translator-runtime.cpp +++ b/hphp/runtime/vm/jit/translator-runtime.cpp @@ -274,24 +274,24 @@ ArrayData* convKeysetToArrHelper(ArrayData* adIn) { } ArrayData* convArrToVecHelper(ArrayData* adIn) { - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); auto a = adIn->toVec(adIn->cowCheck()); if (a != adIn) decRefArr(adIn); return a; } ArrayData* convDictToVecHelper(ArrayData* adIn) { - assert(adIn->isDict()); + assertx(adIn->isDict()); auto a = MixedArray::ToVecDict(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); return a; } ArrayData* convKeysetToVecHelper(ArrayData* adIn) { - assert(adIn->isKeyset()); + assertx(adIn->isKeyset()); auto a = SetArray::ToVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); return a; } @@ -304,7 +304,7 @@ ArrayData* convObjToVecHelper(ObjectData* obj) { } ArrayData* convArrToDictHelper(ArrayData* adIn) { - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); auto a = adIn->toDict(adIn->cowCheck()); if (a != adIn) decRefArr(adIn); return a; @@ -313,7 +313,7 @@ ArrayData* convArrToDictHelper(ArrayData* adIn) { ArrayData* convVecToDictHelper(ArrayData* adIn) { assertx(adIn->isVecArray()); auto a = PackedArray::ToDictVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); return a; } @@ -333,7 +333,7 @@ ArrayData* convObjToDictHelper(ObjectData* obj) { } ArrayData* convArrToKeysetHelper(ArrayData* adIn) { - assert(adIn->isPHPArray()); + assertx(adIn->isPHPArray()); auto a = adIn->toKeyset(adIn->cowCheck()); if (a != adIn) decRefArr(adIn); return a; @@ -342,13 +342,13 @@ ArrayData* convArrToKeysetHelper(ArrayData* adIn) { ArrayData* convVecToKeysetHelper(ArrayData* adIn) { assertx(adIn->isVecArray()); auto a = PackedArray::ToKeysetVec(adIn, adIn->cowCheck()); - assert(a != adIn); + assertx(a != adIn); decRefArr(adIn); return a; } ArrayData* convDictToKeysetHelper(ArrayData* adIn) { - assert(adIn->isDict()); + assertx(adIn->isDict()); auto a = MixedArray::ToKeysetDict(adIn, adIn->cowCheck()); if (a != adIn) decRefArr(adIn); return a; diff --git a/hphp/runtime/vm/jit/translator.cpp b/hphp/runtime/vm/jit/translator.cpp index 9ca05ff32d8..886e934e9db 100644 --- a/hphp/runtime/vm/jit/translator.cpp +++ b/hphp/runtime/vm/jit/translator.cpp @@ -659,7 +659,7 @@ bool isAlwaysNop(const NormalizedInstruction& ni) { #define FOUR(a, b, c, d) a(0) b(1) c(2) d(3) // Iterator bytecodes have multiple local immediates but not the Local flag, so // they should never flow through this function. -#define LA(n) assert(idx == 0xff); idx = n; +#define LA(n) assertx(idx == 0xff); idx = n; #define MA(n) #define BLA(n) #define SLA(n) @@ -686,7 +686,7 @@ size_t localImmIdx(Op op) { switch (op) { OPCODES } - assert(idx != 0xff); + assertx(idx != 0xff); return idx; } @@ -696,10 +696,10 @@ size_t memberKeyImmIdx(Op op) { #undef LA #undef KA #define LA(n) -#define KA(n) assert(idx == 0xff); idx = n; +#define KA(n) assertx(idx == 0xff); idx = n; OPCODES } - assert(idx != 0xff); + assertx(idx != 0xff); return idx; } diff --git a/hphp/runtime/vm/jit/unwind-itanium.cpp b/hphp/runtime/vm/jit/unwind-itanium.cpp index 7a6873e9a61..422e8ad41a4 100644 --- a/hphp/runtime/vm/jit/unwind-itanium.cpp +++ b/hphp/runtime/vm/jit/unwind-itanium.cpp @@ -174,7 +174,7 @@ bool install_catch_trace(_Unwind_Context* ctx, TCA rip, _Unwind_Exception* exn, // things to the handler using the RDS. This also simplifies the handler code // because it doesn't have to worry about saving its arguments somewhere // while executing the exit trace. - assert(g_unwind_rds.isInit()); + assertx(g_unwind_rds.isInit()); if (do_side_exit) { g_unwind_rds->exn = nullptr; #ifndef _MSC_VER @@ -383,7 +383,7 @@ tc_unwind_personality(int version, } always_assert(!(actions & _UA_HANDLER_FRAME)); - assert(g_unwind_rds.isInit()); + assertx(g_unwind_rds.isInit()); if (ip == stubs.endCatchHelperPast) { FTRACE(1, "rip == endCatchHelperPast, continuing unwind\n"); @@ -449,7 +449,7 @@ TCUnwindInfo tc_unwind_resume(ActRec* fp) { // actually an ActRec, so it's actually required that we skip it above). unwindPreventReturnToTC(fp); - assert(g_unwind_rds.isInit()); + assertx(g_unwind_rds.isInit()); auto catchTrace = lookup_catch_trace(savedRip, g_unwind_rds->exn); if (isDebuggerReturnHelper(savedRip)) { diff --git a/hphp/runtime/vm/jit/vasm-check.cpp b/hphp/runtime/vm/jit/vasm-check.cpp index 282e6ff057c..61c57384b2a 100644 --- a/hphp/runtime/vm/jit/vasm-check.cpp +++ b/hphp/runtime/vm/jit/vasm-check.cpp @@ -167,7 +167,7 @@ struct FlagUseChecker { } void use(VregSF r) { assertx(!cur_sf.isValid() || cur_sf == r); - assert(!r.isValid() || r.isSF() || r.isVirt()); + assertx(!r.isValid() || r.isSF() || r.isVirt()); cur_sf = r; } VregSF& cur_sf; @@ -225,7 +225,7 @@ checkSF(const Vunit& unit, const jit::vector& blocks) { for (auto s : succs(block)) { if (!livein[s].isValid()) continue; assertx(!cur_sf.isValid() || cur_sf == livein[s]); - assert(livein[s].isSF() || livein[s].isVirt()); + assertx(livein[s].isSF() || livein[s].isVirt()); cur_sf = livein[s]; } for (auto i = block.code.end(); i != block.code.begin();) { diff --git a/hphp/runtime/vm/jit/vasm-copy.cpp b/hphp/runtime/vm/jit/vasm-copy.cpp index b9e3c04c47a..d91825b5105 100644 --- a/hphp/runtime/vm/jit/vasm-copy.cpp +++ b/hphp/runtime/vm/jit/vasm-copy.cpp @@ -738,7 +738,7 @@ struct OptVisit { if (arch() == Arch::ARM) { // After lowering, only [base, index lsl #scale] and [base, #imm] // are allowed where the range of #imm is [-256 .. 255] - assert(ptr.base.isValid()); + assertx(ptr.base.isValid()); auto disp = ptr.disp + def.disp; if (ptr.index.isValid()) { if (disp != 0) return; diff --git a/hphp/runtime/vm/jit/vasm-phi.cpp b/hphp/runtime/vm/jit/vasm-phi.cpp index 510a45a2f1e..82921b0c66e 100644 --- a/hphp/runtime/vm/jit/vasm-phi.cpp +++ b/hphp/runtime/vm/jit/vasm-phi.cpp @@ -137,10 +137,10 @@ void optimizePhis(Vunit& unit) { auto i2 = unit.blocks[pred].code.end(); --i2; if (i2->op == Vinstr::phijmp) { - assert(i2->phijmp_.target == label); + assertx(i2->phijmp_.target == label); i2->phijmp_.target = phijmp.target; } else { - assert(i2->op == Vinstr::phijcc); + assertx(i2->op == Vinstr::phijcc); int changes = 0; if (i2->phijcc_.targets[0] == label) { i2->phijcc_.targets[0] = phijmp.target; diff --git a/hphp/runtime/vm/jit/vasm-ppc64.cpp b/hphp/runtime/vm/jit/vasm-ppc64.cpp index 2ffce463a6a..997fecb7f5e 100644 --- a/hphp/runtime/vm/jit/vasm-ppc64.cpp +++ b/hphp/runtime/vm/jit/vasm-ppc64.cpp @@ -1380,7 +1380,7 @@ void lowerForPPC64(const VLS& /*e*/, Vout& v, cmpsd& inst) { std::swap(equal, nequal); break; default: - assert(false && "Invalid ComparisonPred for cmpsd"); + assertx(false && "Invalid ComparisonPred for cmpsd"); } v << cmovq{CC_E, sf, nequal, equal, r64_d}; v << copy{r64_d, inst.d}; // GP -> FP @@ -1514,7 +1514,7 @@ void fixVptr(Vout& v, Vptr& p) { } case AddressModes::Invalid: - assert(false && "Invalid address mode"); + assertx(false && "Invalid address mode"); break; } } diff --git a/hphp/runtime/vm/jit/vasm-reg.h b/hphp/runtime/vm/jit/vasm-reg.h index d51dcc67ca2..9589fc4242b 100644 --- a/hphp/runtime/vm/jit/vasm-reg.h +++ b/hphp/runtime/vm/jit/vasm-reg.h @@ -329,7 +329,7 @@ struct Vptr { bool operator!=(const Vptr&) const; void validate() { - assert((scale == 0x1 || scale == 0x2 || scale == 0x4 || scale == 0x8) && + assertx((scale == 0x1 || scale == 0x2 || scale == 0x4 || scale == 0x8) && "Invalid index register scaling (must be 1,2,4 or 8)."); } diff --git a/hphp/runtime/vm/jit/vasm-simplify.cpp b/hphp/runtime/vm/jit/vasm-simplify.cpp index b2f8ff0a889..5775436529b 100644 --- a/hphp/runtime/vm/jit/vasm-simplify.cpp +++ b/hphp/runtime/vm/jit/vasm-simplify.cpp @@ -396,7 +396,7 @@ int value_width(Env& env, Vreg reg) { Vreg narrow_reg(Env& env, int size, Vreg r, Vlabel b, size_t i, Vout& v) { auto const it = env.unit.regToConst.find(r); if (it != env.unit.regToConst.end()) { - assert(!it->second.isUndef && it->second.kind != Vconst::Double); + assertx(!it->second.isUndef && it->second.kind != Vconst::Double); return r; } diff --git a/hphp/runtime/vm/jit/vm-protect.cpp b/hphp/runtime/vm/jit/vm-protect.cpp index b9a2622a8a4..4d7419e167e 100644 --- a/hphp/runtime/vm/jit/vm-protect.cpp +++ b/hphp/runtime/vm/jit/vm-protect.cpp @@ -61,7 +61,7 @@ void protect() { } void unprotect(void* base, VMRegState state) { - assert(rds::tl_base == s_fakeRdsBase.load(std::memory_order_relaxed)); + assertx(rds::tl_base == s_fakeRdsBase.load(std::memory_order_relaxed)); rds::tl_base = base; tl_regState = state; VMProtect::is_protected = false; diff --git a/hphp/runtime/vm/jit/vtune-jit.cpp b/hphp/runtime/vm/jit/vtune-jit.cpp index cbe72cf7ba3..d0dbc1f4287 100644 --- a/hphp/runtime/vm/jit/vtune-jit.cpp +++ b/hphp/runtime/vm/jit/vtune-jit.cpp @@ -137,7 +137,7 @@ void reportHelperToVtune(const char *name, iJIT_Method_Load methodInfo; memset(&methodInfo, 0, sizeof(methodInfo)); - assert(helperNumber < MIN_METHOD_ID); + assertx(helperNumber < MIN_METHOD_ID); methodInfo.method_id = helperNumber++; methodInfo.method_name = const_cast(name); diff --git a/hphp/runtime/vm/litstr-table-inl.h b/hphp/runtime/vm/litstr-table-inl.h index 9ec98bfff38..826f500b053 100644 --- a/hphp/runtime/vm/litstr-table-inl.h +++ b/hphp/runtime/vm/litstr-table-inl.h @@ -22,12 +22,12 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// inline void LitstrTable::init() { - assert(!LitstrTable::s_litstrTable); + assertx(!LitstrTable::s_litstrTable); LitstrTable::s_litstrTable = new LitstrTable(); } inline void LitstrTable::fini() { - assert(LitstrTable::s_litstrTable); + assertx(LitstrTable::s_litstrTable); delete LitstrTable::s_litstrTable; LitstrTable::s_litstrTable = nullptr; } @@ -40,27 +40,27 @@ inline LitstrTable& LitstrTable::get() { // Main API. inline size_t LitstrTable::numLitstrs() const { - assert(m_safeToRead); + assertx(m_safeToRead); return m_namedInfo.size(); } inline bool LitstrTable::contains(Id id) const { - assert(m_safeToRead); + assertx(m_safeToRead); return m_namedInfo.contains(id); } inline StringData* LitstrTable::lookupLitstrId(Id id) const { - assert(m_safeToRead); + assertx(m_safeToRead); return m_namedInfo.lookupLitstr(id); } inline const NamedEntity* LitstrTable::lookupNamedEntityId(Id id) const { - assert(m_safeToRead); + assertx(m_safeToRead); return m_namedInfo.lookupNamedEntity(id); } inline NamedEntityPair LitstrTable::lookupNamedEntityPairId(Id id) const { - assert(m_safeToRead); + assertx(m_safeToRead); return m_namedInfo.lookupNamedEntityPair(id); } diff --git a/hphp/runtime/vm/litstr-table.cpp b/hphp/runtime/vm/litstr-table.cpp index b047c354639..f40469374c2 100644 --- a/hphp/runtime/vm/litstr-table.cpp +++ b/hphp/runtime/vm/litstr-table.cpp @@ -57,7 +57,7 @@ void LitstrTable::setReading() { void LitstrTable::forEachLitstr( std::function onItem) { - assert(m_safeToRead); + assertx(m_safeToRead); auto i = 0; for (auto s : m_namedInfo) { onItem(i++, s); diff --git a/hphp/runtime/vm/member-key.cpp b/hphp/runtime/vm/member-key.cpp index c786e64e1f7..0e4e18d2023 100644 --- a/hphp/runtime/vm/member-key.cpp +++ b/hphp/runtime/vm/member-key.cpp @@ -40,7 +40,7 @@ const char* memberCodeString(MemberCode mcode) { static_assert( std::is_unsigned::type>::value, "MemberCode is expected to be unsigned."); - assert(mcode < NumMemberCodes); + assertx(mcode < NumMemberCodes); return memberNames[mcode]; } diff --git a/hphp/runtime/vm/member-operations.cpp b/hphp/runtime/vm/member-operations.cpp index 4e1ad5c2c50..86002dd6bdb 100644 --- a/hphp/runtime/vm/member-operations.cpp +++ b/hphp/runtime/vm/member-operations.cpp @@ -44,7 +44,7 @@ void unknownBaseType(const TypedValue* tv) { } void objArrayAccess(ObjectData* base) { - assert(!base->isCollection()); + assertx(!base->isCollection()); if (!base->instanceof(SystemLib::s_ArrayAccessClass)) { raise_error("Object does not implement ArrayAccess"); } @@ -63,7 +63,7 @@ TypedValue objOffsetGet( assertx(offset.m_type != KindOfRef); auto const method = base->methodNamed(s_offsetGet.get()); - assert(method != nullptr); + assertx(method != nullptr); return g_context->invokeMethod(base, method, InvokeArgs(&offset, 1)); } @@ -81,7 +81,7 @@ static OffsetExistsResult objOffsetExists(ObjectData* base, TypedValue offset) { assertx(offset.m_type != KindOfRef); auto const method = base->methodNamed(s_offsetExists.get()); - assert(method != nullptr); + assertx(method != nullptr); auto result = g_context->invokeMethod(base, method, InvokeArgs(&offset, 1)); // In-place cast decrefs the function call result. @@ -112,7 +112,7 @@ bool objOffsetIsset(ObjectData* base, TypedValue offset, // `isset(...)` expressions, so call the method on the base ArrayObject class. auto const cls = SystemLib::s_ArrayObjectClass; auto const method = cls->lookupMethod(s_offsetGet.get()); - assert(method != nullptr); + assertx(method != nullptr); auto result = g_context->invokeMethodV(base, method, InvokeArgs(&offset, 1)); return !result.isNull(); @@ -157,7 +157,7 @@ void objOffsetSet( assertx(offset.m_type != KindOfRef); auto const method = base->methodNamed(s_offsetSet.get()); - assert(method != nullptr); + assertx(method != nullptr); TypedValue args[2] = { offset, *tvToCell(val) }; g_context->invokeMethodV(base, method, folly::range(args)); @@ -170,7 +170,7 @@ void objOffsetUnset(ObjectData* base, TypedValue offset) { assertx(offset.m_type != KindOfRef); auto const method = base->methodNamed(s_offsetUnset.get()); - assert(method != nullptr); + assertx(method != nullptr); g_context->invokeMethodV(base, method, InvokeArgs(&offset, 1)); } @@ -207,7 +207,7 @@ void raise_inout_undefined_index(TypedValue tv) { raise_inout_undefined_index(tv.m_data.num); return; } - assert(isStringType(tv.m_type)); + assertx(isStringType(tv.m_type)); raise_inout_undefined_index(tv.m_data.pstr); } @@ -220,8 +220,8 @@ void raise_inout_undefined_index(const StringData* sd) { } Cell incDecBodySlow(IncDecOp op, Cell* fr) { - assert(cellIsPlausible(*fr)); - assert(fr->m_type != KindOfUninit); + assertx(cellIsPlausible(*fr)); + assertx(fr->m_type != KindOfUninit); auto dup = [&]() { tvIncRefGen(*fr); return *fr; }; diff --git a/hphp/runtime/vm/member-operations.h b/hphp/runtime/vm/member-operations.h index 211a9c3f6ea..062fcffa63e 100644 --- a/hphp/runtime/vm/member-operations.h +++ b/hphp/runtime/vm/member-operations.h @@ -202,7 +202,7 @@ template inline member_rval ElemArrayPre(ArrayData* base, StringData* key) { auto constexpr warn = mode == MOpMode::Warn; int64_t n; - assert(base->isPHPArray()); + assertx(base->isPHPArray()); if (key->isStrictlyInteger(n)) { if (intishWarn) raise_intish_index_cast(); return warn ? base->rvalStrict(n) : base->rval(n); @@ -232,7 +232,7 @@ inline member_rval ElemArrayPre(ArrayData* base, TypedValue key) { */ template inline member_rval ElemArray(ArrayData* base, key_type key) { - assert(base->isPHPArray()); + assertx(base->isPHPArray()); auto result = ElemArrayPre(base, key); @@ -416,7 +416,7 @@ inline member_rval ElemString(TypedValue& tvRef, tvRef = make_tv(staticEmptyString()); } else { tvRef = make_tv(base->m_data.pstr->getChar(offset)); - assert(tvRef.m_data.pstr->isStatic()); + assertx(tvRef.m_data.pstr->isStatic()); } return member_rval { base->m_data.pstr, &tvRef }; } @@ -834,7 +834,7 @@ inline TypedValue* ElemDObject(TypedValue& tvRef, TypedValue* base, auto storage = obj->getPropLval(SystemLib::s_ArrayObjectClass, s_storage.get()); // ArrayObject should always have the 'storage' property... - assert(storage.has_ref()); + assertx(storage.has_ref()); return UNLIKELY(checkHACIntishCast()) ? ElemDArray(storage.tv_ptr(), key) : ElemDArray(storage.tv_ptr(), key); @@ -1538,7 +1538,7 @@ inline ArrayData* SetElemArrayPre(ArrayData* a, Cell* value, bool copy) { int64_t n; - assert(a->isPHPArray()); + assertx(a->isPHPArray()); if (key->isStrictlyInteger(n)) { if (intishWarn) raise_intish_index_cast(); return a->set(n, *value, copy); @@ -1950,7 +1950,7 @@ inline void SetNewElem(TypedValue* base, Cell* value) { */ inline TypedValue* SetOpElemEmptyish(SetOpOp op, Cell* base, TypedValue key, Cell* rhs) { - assert(cellIsPlausible(*base)); + assertx(cellIsPlausible(*base)); detail::checkPromotion(base); @@ -2150,14 +2150,14 @@ inline TypedValue* SetOpNewElem(TypedValue& tvRef, Cell incDecBodySlow(IncDecOp op, Cell* fr); inline Cell IncDecBody(IncDecOp op, Cell* fr) { - assert(cellIsPlausible(*fr)); + assertx(cellIsPlausible(*fr)); if (UNLIKELY(fr->m_type != KindOfInt64)) { return incDecBodySlow(op, fr); } auto copy = [&]() { - assert(cellIsPlausible(*fr)); + assertx(cellIsPlausible(*fr)); return *fr; }; @@ -2219,7 +2219,7 @@ inline Cell IncDecElemEmptyish( raise_notice(Strings::UNDEFINED_INDEX, tvAsCVarRef(&key).toString().data()); } - assert(lval.type() == KindOfNull); + assertx(lval.type() == KindOfNull); return IncDecBody(op, lval.tv_ptr()); } @@ -2297,7 +2297,7 @@ inline Cell IncDecElem( if (LIKELY(base->m_data.pobj->isCollection())) { result = collections::atRw(base->m_data.pobj, &key); - assert(cellIsPlausible(*result)); + assertx(cellIsPlausible(*result)); } else { localTvRef = objOffsetGet(instanceFromTv(base), key); result = tvToCell(&localTvRef); @@ -2322,7 +2322,7 @@ inline Cell IncDecNewElemEmptyish( auto a = Array::Create(); auto result = a.lvalAt().tv_ptr(); tvAsVariant(base) = a; - assert(result->m_type == KindOfNull); + assertx(result->m_type == KindOfNull); return IncDecBody(op, result); } @@ -2375,7 +2375,7 @@ inline Cell IncDecNewElem( case KindOfPersistentArray: case KindOfArray: { TypedValue* result = tvAsVariant(base).asArrRef().lvalAt().tv_ptr(); - assert(result->m_type == KindOfNull); + assertx(result->m_type == KindOfNull); return IncDecBody(op, tvToCell(result)); } @@ -2411,7 +2411,7 @@ template inline ArrayData* UnsetElemArrayPre(ArrayData* a, StringData* key, bool copy) { int64_t n; - assert(a->isPHPArray()); + assertx(a->isPHPArray()); if (key->isStrictlyInteger(n)) { if (intishWarn) raise_intish_index_cast(); return a->remove(n, copy); @@ -2708,7 +2708,7 @@ bool IssetEmptyElemString(TypedValue* base, key_type key) { } auto str = base->m_data.pstr->getChar(x); - assert(str->isStatic()); + assertx(str->isStatic()); return !str->toBoolean(); } @@ -2864,7 +2864,7 @@ inline void promoteToStdClass(TypedValue* base, bool warn, F fun) { if (base->m_type == KindOfString) { decRefStr(base->m_data.pstr); } else { - assert(!isRefcountedType(base->m_type)); + assertx(!isRefcountedType(base->m_type)); } base->m_type = KindOfObject; base->m_data.pobj = obj.get(); @@ -3015,14 +3015,14 @@ inline TypedValue* PropObj(TypedValue& tvRef, const Class* ctx, return instance->propD(&tvRef, ctx, keySD); } } - assert(!reffy); + assertx(!reffy); if (mode == MOpMode::None) { return instance->prop(&tvRef, ctx, keySD); } if (mode == MOpMode::Warn) { return instance->propW(&tvRef, ctx, keySD); } - assert(mode == MOpMode::Unset); + assertx(mode == MOpMode::Unset); return instance->propD(&tvRef, ctx, keySD); } @@ -3233,7 +3233,7 @@ inline Cell IncDecPropStdclass(IncDecOp op, TypedValue* base, tvWriteNull(tv); dest = IncDecBody(op, &tv); obj->setProp(nullptr, keySD, dest); - assert(!isRefcountedType(tv.m_type)); + assertx(!isRefcountedType(tv.m_type)); }); return dest; diff --git a/hphp/runtime/vm/method-lookup.cpp b/hphp/runtime/vm/method-lookup.cpp index 0e6bf489146..ad13cbb3232 100644 --- a/hphp/runtime/vm/method-lookup.cpp +++ b/hphp/runtime/vm/method-lookup.cpp @@ -62,11 +62,11 @@ const Func* lookupMethodCtx(const Class* cls, bool raise) { const Func* method; if (callType == CallType::CtorMethod) { - assert(methodName == nullptr); + assertx(methodName == nullptr); method = cls->getCtor(); } else { - assert(callType == CallType::ObjMethod || callType == CallType::ClsMethod); - assert(methodName != nullptr); + assertx(callType == CallType::ObjMethod || callType == CallType::ClsMethod); + assertx(methodName != nullptr); method = cls->lookupMethod(methodName); while (!method) { if (UNLIKELY(methodName->isame(s___construct.get()))) { @@ -83,14 +83,14 @@ const Func* lookupMethodCtx(const Class* cls, return nullptr; } } - assert(method); + assertx(method); bool accessible = true; // If we found a protected or private method, we need to do some // accessibility checks. if ((method->attrs() & (AttrProtected|AttrPrivate)) && (g_context.isNull() || !g_context->debuggerSettings.bypassCheck)) { Class* baseClass = method->baseCls(); - assert(baseClass); + assertx(baseClass); // If ctx is the class that first declared this method, then we know we // have the right method and we can stop here. if (ctx == baseClass) { @@ -107,7 +107,7 @@ const Func* lookupMethodCtx(const Class* cls, } return nullptr; } - assert(ctx); + assertx(ctx); if (method->attrs() & AttrPrivate) { // ctx is not the class that declared this private method, so this // private method is not accessible. We need to keep going because @@ -138,7 +138,7 @@ const Func* lookupMethodCtx(const Class* cls, } // We now know this protected method is accessible, but we need to // keep going because ctx may define a private method with this name. - assert(accessible && baseClass->classof(ctx)); + assertx(accessible && baseClass->classof(ctx)); } } // If this is an ObjMethod call ("$obj->foo()") AND there is an ancestor @@ -215,15 +215,15 @@ LookupResult lookupClsMethod(const Func*& f, return LookupResult::MethodNotFound; } f->validate(); - assert(f); - assert(f->attrs() & AttrStatic); + assertx(f); + assertx(f->attrs() & AttrStatic); return LookupResult::MagicCallStaticFound; } - assert(f); - assert(obj); + assertx(f); + assertx(obj); // __call cannot be static, this should be enforced by semantic // checks defClass time or earlier - assert(!(f->attrs() & AttrStatic)); + assertx(!(f->attrs() & AttrStatic)); return LookupResult::MagicCallFound; } if (obj && !(f->attrs() & AttrStatic) && obj->instanceof(cls)) { @@ -242,7 +242,7 @@ LookupResult lookupCtorMethod(const Func*& f, if (!f) { // If raise was true than lookupMethodCtx should have thrown, // so we should only be able to get here if raise was false - assert(!raise); + assertx(!raise); return LookupResult::MethodNotFound; } } diff --git a/hphp/runtime/vm/name-value-table.cpp b/hphp/runtime/vm/name-value-table.cpp index 7fe115c39f4..5ea820372a9 100644 --- a/hphp/runtime/vm/name-value-table.cpp +++ b/hphp/runtime/vm/name-value-table.cpp @@ -34,7 +34,7 @@ NameValueTable::NameValueTable() { NameValueTable::NameValueTable(ActRec* fp) : m_fp(fp) { - assert(m_fp); + assertx(m_fp); const auto func = m_fp->m_func; const Id numNames = func->numNamedLocals(); @@ -45,10 +45,10 @@ NameValueTable::NameValueTable(ActRec* fp) reserve(numNames + 1); for (Id i = 0; i < numNames; ++i) { - assert(func->lookupVarId(func->localVarName(i)) == i); + assertx(func->lookupVarId(func->localVarName(i)) == i); auto elm = insert(func->localVarName(i)); - assert(elm && elm->m_tv.m_type == kInvalidDataType); + assertx(elm && elm->m_tv.m_type == kInvalidDataType); elm->m_tv.m_type = kNamedLocalDataType; elm->m_tv.m_data.num = i; } @@ -59,7 +59,7 @@ NameValueTable::NameValueTable(const NameValueTable& nvTable, ActRec* fp) , m_elms(nvTable.m_elms) { allocate(nvTable.m_tabMask + 1); - assert(m_tabMask == nvTable.m_tabMask); + assertx(m_tabMask == nvTable.m_tabMask); for (int i = 0; i <= m_tabMask; ++i) { Elm& src = nvTable.m_table[i]; @@ -92,16 +92,16 @@ NameValueTable::~NameValueTable() { } void NameValueTable::suspend(const ActRec* oldFP, ActRec* newFP) { - assert(m_fp == oldFP); - assert(oldFP->func() == newFP->func()); - assert(!oldFP->resumed()); - assert(newFP->resumed()); + assertx(m_fp == oldFP); + assertx(oldFP->func() == newFP->func()); + assertx(!oldFP->resumed()); + assertx(newFP->resumed()); m_fp = newFP; } void NameValueTable::attach(ActRec* fp) { - assert(m_fp == nullptr); + assertx(m_fp == nullptr); m_fp = fp; const auto func = fp->m_func; @@ -109,12 +109,12 @@ void NameValueTable::attach(ActRec* fp) { TypedValue* loc = frame_local(fp, 0); for (Id i = 0; i < numNames; ++i, --loc) { - assert(func->lookupVarId(func->localVarName(i)) == i); + assertx(func->lookupVarId(func->localVarName(i)) == i); auto elm = insert(func->localVarName(i)); - assert(elm); + assertx(elm); if (elm->m_tv.m_type != kInvalidDataType) { - assert(elm->m_tv.m_type != kNamedLocalDataType); + assertx(elm->m_tv.m_type != kNamedLocalDataType); tvCopy(elm->m_tv, *loc); } @@ -124,7 +124,7 @@ void NameValueTable::attach(ActRec* fp) { } void NameValueTable::detach(ActRec* fp) { - assert(m_fp == fp); + assertx(m_fp == fp); m_fp = nullptr; const auto func = fp->m_func; @@ -132,10 +132,10 @@ void NameValueTable::detach(ActRec* fp) { TypedValue* loc = frame_local(fp, 0); for (Id i = 0; i < numNames; ++i, --loc) { - assert(func->lookupVarId(func->localVarName(i)) == i); + assertx(func->lookupVarId(func->localVarName(i)) == i); auto elm = findElm(func->localVarName(i)); - assert(elm && elm->m_tv.m_type == kNamedLocalDataType); + assertx(elm && elm->m_tv.m_type == kNamedLocalDataType); tvCopy(*loc, elm->m_tv); tvDebugTrash(loc); } @@ -146,7 +146,7 @@ void NameValueTable::leak() { m_tabMask = 0; req::free(m_table); m_table = nullptr; - assert(leaked()); + assertx(leaked()); } TypedValue* NameValueTable::set(const StringData* name, const TypedValue* val) { @@ -202,8 +202,8 @@ void NameValueTable::reserve(size_t desiredSize) { } void NameValueTable::allocate(const size_t newCapac) { - assert(folly::isPowTwo(newCapac)); - assert(newCapac - 1 <= std::numeric_limits::max()); + assertx(folly::isPowTwo(newCapac)); + assertx(newCapac - 1 <= std::numeric_limits::max()); Elm* oldTab = m_table; const size_t oldMask = m_tabMask; @@ -236,7 +236,7 @@ NameValueTable::Elm* NameValueTable::insertImpl(const StringData* name) { Elm* elm = &m_table[name->hash() & m_tabMask]; UNUSED size_t numProbes = 0; for (;;) { - assert(numProbes++ < m_tabMask + 1); + assertx(numProbes++ < m_tabMask + 1); if (nullptr == elm->m_name) { elm->m_name = name; elm->m_tv.m_type = kInvalidDataType; @@ -264,7 +264,7 @@ NameValueTable::Elm* NameValueTable::insert(const StringData* name) { void NameValueTable::rehash(Elm* const oldTab, const size_t oldMask) { for (Elm* srcElm = &oldTab[oldMask]; srcElm != &oldTab[-1]; --srcElm) { if (srcElm->m_name) { - assert(srcElm->m_tv.m_type == kNamedLocalDataType || + assertx(srcElm->m_tv.m_type == kNamedLocalDataType || tvIsPlausible(srcElm->m_tv)); Elm* dstElm = insertImpl(srcElm->m_name); dstElm->m_name = srcElm->m_name; @@ -277,7 +277,7 @@ NameValueTable::Elm* NameValueTable::findElm(const StringData* name) const { Elm* elm = &m_table[name->hash() & m_tabMask]; UNUSED size_t numProbes = 0; for (;;) { - assert(numProbes++ < m_tabMask + 1); + assertx(numProbes++ < m_tabMask + 1); if (UNLIKELY(nullptr == elm->m_name)) { return nullptr; } @@ -318,7 +318,7 @@ NameValueTable::Iterator::Iterator(const NameValueTable* tab, ssize_t pos) : m_tab(tab) , m_idx(pos) { - assert(pos >= 0); + assertx(pos >= 0); if (!valid()) next(); } @@ -340,12 +340,12 @@ bool NameValueTable::Iterator::valid() const { } const StringData* NameValueTable::Iterator::curKey() const { - assert(valid()); + assertx(valid()); return m_tab->m_table[m_idx].m_name; } const TypedValue* NameValueTable::Iterator::curVal() const { - assert(valid()); + assertx(valid()); return m_tab->derefNamedLocal(&m_tab->m_table[m_idx].m_tv); } diff --git a/hphp/runtime/vm/named-entity-pair-table-inl.h b/hphp/runtime/vm/named-entity-pair-table-inl.h index ce89d3ca001..7b1f6e5892a 100644 --- a/hphp/runtime/vm/named-entity-pair-table-inl.h +++ b/hphp/runtime/vm/named-entity-pair-table-inl.h @@ -27,7 +27,7 @@ inline bool NamedEntityPairTable::contains(Id id) const { } inline StringData* NamedEntityPairTable::lookupLitstr(Id id) const { - assert(contains(id)); + assertx(contains(id)); return const_cast((*this)[id].get()); } @@ -38,11 +38,11 @@ NamedEntityPairTable::lookupNamedEntity(Id id) const { inline NamedEntityPair NamedEntityPairTable::lookupNamedEntityPair(Id id) const { - assert(contains(id)); + assertx(contains(id)); auto const name = (*this)[id]; - assert(name); - assert(name->data()[0] != '\\'); + assertx(name); + assertx(name->data()[0] != '\\'); return { name, NamedEntity::get(name) }; } diff --git a/hphp/runtime/vm/named-entity.cpp b/hphp/runtime/vm/named-entity.cpp index 4872addcb56..4780e00dae9 100644 --- a/hphp/runtime/vm/named-entity.cpp +++ b/hphp/runtime/vm/named-entity.cpp @@ -82,7 +82,7 @@ const TypeAliasReq* NamedEntity::getCachedTypeAlias() const { } void NamedEntity::pushClass(Class* cls) { - assert(!cls->m_nextClass); + assertx(!cls->m_nextClass); cls->m_nextClass = m_clsList; m_clsList = cls; } @@ -102,7 +102,7 @@ void NamedEntity::removeClass(Class* goner) { } LowPtr* cls = &head->m_nextClass; while (cls->get() != goner) { - assert(*cls); + assertx(*cls); cls = &(*cls)->m_nextClass; } *cls = goner->m_nextClass; diff --git a/hphp/runtime/vm/named-entity.h b/hphp/runtime/vm/named-entity.h index 9df99bade90..cc153a677b1 100644 --- a/hphp/runtime/vm/named-entity.h +++ b/hphp/runtime/vm/named-entity.h @@ -44,7 +44,7 @@ struct String; */ struct ahm_string_data_isame { bool operator()(const StringData *s1, const StringData *s2) const { - assert(int64_t(s2) > 0); // RHS is never a magic value. + assertx(int64_t(s2) > 0); // RHS is never a magic value. return s1 == s2 || (int64_t(s1) > 0 && s1->isame(s2)); } }; diff --git a/hphp/runtime/vm/native-data.cpp b/hphp/runtime/vm/native-data.cpp index 45b8de198dc..5b3729aad30 100644 --- a/hphp/runtime/vm/native-data.cpp +++ b/hphp/runtime/vm/native-data.cpp @@ -54,8 +54,8 @@ void registerNativeDataInfo(const StringData* name, NativeDataInfo::WakeupFunc wakeup, type_scan::Index tyindex, uint8_t rt_attrs) { - assert(s_nativedatainfo.find(name) == s_nativedatainfo.end()); - assert((sleep == nullptr && wakeup == nullptr) || + assertx(s_nativedatainfo.find(name) == s_nativedatainfo.end()); + assertx((sleep == nullptr && wakeup == nullptr) || (sleep != nullptr && wakeup != nullptr)); NativeDataInfo info; info.sz = sz; @@ -101,11 +101,11 @@ ObjectData* nativeDataInstanceCtor(Class* cls) { tl_heap->objMalloc(size) ); node->obj_offset = nativeDataSize; - assert(type_scan::isKnownType(ndi->tyindex)); + assertx(type_scan::isKnownType(ndi->tyindex)); node->initHeader_32_16(HeaderKind::NativeData, 0, ndi->tyindex); auto obj = new (reinterpret_cast(node) + nativeDataSize) ObjectData(cls, 0, HeaderKind::NativeObject); - assert(obj->hasExactlyOneRef()); + assertx(obj->hasExactlyOneRef()); if (ndi->init) { ndi->init(obj); } @@ -128,12 +128,12 @@ ObjectData* nativeDataInstanceCopyCtor(ObjectData* src, Class* cls, tl_heap->objMalloc(ObjectData::sizeForNProps(nProps) + nativeDataSize) ); node->obj_offset = nativeDataSize; - assert(type_scan::isKnownType(ndi->tyindex)); + assertx(type_scan::isKnownType(ndi->tyindex)); node->initHeader_32_16(HeaderKind::NativeData, 0, ndi->tyindex); auto obj = new (reinterpret_cast(node) + nativeDataSize) ObjectData(cls, ObjectData::InitRaw{}, cls->getODAttrs(), HeaderKind::NativeObject); - assert(obj->hasExactlyOneRef()); + assertx(obj->hasExactlyOneRef()); if (ndi->init) { ndi->init(obj); } @@ -168,15 +168,15 @@ void nativeDataInstanceDtor(ObjectData* obj, const Class* cls) { Variant nativeDataSleep(const ObjectData* obj) { auto ndi = obj->getVMClass()->getNativeDataInfo(); - assert(ndi); - assert(ndi->sleep); + assertx(ndi); + assertx(ndi->sleep); return ndi->sleep(obj); } void nativeDataWakeup(ObjectData* obj, const Variant& data) { auto ndi = obj->getVMClass()->getNativeDataInfo(); - assert(ndi); - assert(ndi->wakeup); + assertx(ndi); + assertx(ndi->wakeup); ndi->wakeup(obj, data); } diff --git a/hphp/runtime/vm/native-data.h b/hphp/runtime/vm/native-data.h index d476950883b..7754879e52d 100644 --- a/hphp/runtime/vm/native-data.h +++ b/hphp/runtime/vm/native-data.h @@ -251,7 +251,7 @@ inline ObjectData* obj(NativeNode* node) { auto obj = reinterpret_cast( reinterpret_cast(node) + node->obj_offset ); - assert(obj->hasNativeData()); + assertx(obj->hasNativeData()); return obj; } @@ -260,7 +260,7 @@ inline const ObjectData* obj(const NativeNode* node) { auto obj = reinterpret_cast( reinterpret_cast(node) + node->obj_offset ); - assert(obj->hasNativeData()); + assertx(obj->hasNativeData()); return obj; } diff --git a/hphp/runtime/vm/native-prop-handler.cpp b/hphp/runtime/vm/native-prop-handler.cpp index d04551b3f67..17730988c97 100644 --- a/hphp/runtime/vm/native-prop-handler.cpp +++ b/hphp/runtime/vm/native-prop-handler.cpp @@ -29,7 +29,7 @@ void registerNativePropHandler(const String& className, NativePropHandler::IssetFunc isset, NativePropHandler::UnsetFunc unset) { - assert(s_nativePropHandlerMap.find(className.get()) == + assertx(s_nativePropHandlerMap.find(className.get()) == s_nativePropHandlerMap.end()); NativePropHandler propHandler; @@ -96,29 +96,29 @@ PropAccessorMap::const_iterator PropAccessorMap::lookupProp( Variant getProp(const Object& obj, const String& name) { auto nph = obj->getVMClass()->getNativePropHandler(); - assert(nph); - assert(nph->get); + assertx(nph); + assertx(nph->get); return nph->get(obj, name); } Variant setProp(const Object& obj, const String& name, const Variant& value) { auto nph = obj->getVMClass()->getNativePropHandler(); - assert(nph); - assert(nph->set); + assertx(nph); + assertx(nph->set); return nph->set(obj, name, value); } Variant issetProp(const Object& obj, const String& name) { auto nph = obj->getVMClass()->getNativePropHandler(); - assert(nph); - assert(nph->isset); + assertx(nph); + assertx(nph->isset); return nph->isset(obj, name); } Variant unsetProp(const Object& obj, const String& name) { auto nph = obj->getVMClass()->getNativePropHandler(); - assert(nph); - assert(nph->unset); + assertx(nph); + assertx(nph->unset); return nph->unset(obj, name); } diff --git a/hphp/runtime/vm/native.cpp b/hphp/runtime/vm/native.cpp index 8ed3395fc2d..6c0bc736c73 100644 --- a/hphp/runtime/vm/native.cpp +++ b/hphp/runtime/vm/native.cpp @@ -62,7 +62,7 @@ static void nativeArgHelper(const Func* func, int i, } } else { GP_args[GP_count++] = val; - assert((GP_count + 1) < kMaxBuiltinArgs); + assertx((GP_count + 1) < kMaxBuiltinArgs); val = arg.m_type; } } @@ -111,7 +111,7 @@ static void populateArgs(const Func* func, GP_args[GP_count++] = args[-i].m_data.num; } } else { - assert((GP_count + 1) < kMaxBuiltinArgs); + assertx((GP_count + 1) < kMaxBuiltinArgs); if (pi.nativeArg) { nativeArgHelper(func, i, type, args[-i], GP_args, GP_count); } else if (!type) { @@ -123,7 +123,7 @@ static void populateArgs(const Func* func, } if ((GP_count == numGP) && ntmp) { // GP regs are now full, bring tmp back to fill the initial stack - assert((GP_count + ntmp) <= kMaxBuiltinArgs); + assertx((GP_count + ntmp) <= kMaxBuiltinArgs); memcpy(GP_args + GP_count, tmp, ntmp * sizeof(int64_t)); GP_count += ntmp; ntmp = 0; @@ -131,7 +131,7 @@ static void populateArgs(const Func* func, } } if (ntmp) { - assert((GP_count + ntmp) <= kMaxBuiltinArgs); + assertx((GP_count + ntmp) <= kMaxBuiltinArgs); // We had more than kNumSIMDRegs doubles, // but less than numGPRegArgs INTs. // Push out the count and leave garbage behind. @@ -147,11 +147,11 @@ static void populateArgs(const Func* func, static void populateArgsNoDoubles(const Func* func, TypedValue* args, int numArgs, int64_t* GP_args, int& GP_count) { - assert(numArgs >= 0); + assertx(numArgs >= 0); for (int i = 0; i < numArgs; ++i) { auto const& pi = func->params()[i]; auto dt = pi.builtinType; - assert(dt != KindOfDouble); + assertx(dt != KindOfDouble); if (pi.nativeArg) { nativeArgHelper(func, i, dt, args[-i], GP_args, GP_count); } else if (!dt) { @@ -238,7 +238,7 @@ void callFunc(const Func* func, void *ctx, case KindOfObject: case KindOfResource: case KindOfRef: { - assert(isBuiltinByRef(ret.m_type)); + assertx(isBuiltinByRef(ret.m_type)); if (func->isReturnByValue()) { auto val = callFuncInt64Impl(f, GP_args, GP_count, SIMD_args, SIMD_count); @@ -287,7 +287,7 @@ void callFunc(const Func* func, void *ctx, bool coerceFCallArgs(TypedValue* args, int32_t numArgs, int32_t numNonDefault, const Func* func, bool useStrictTypes) { - assert(numArgs == func->numParams()); + assertx(numArgs == func->numParams()); bool paramCoerceMode = func->isParamCoerceMode(); @@ -422,7 +422,7 @@ bool nativeWrapperCheckArgs(ActRec* ar) { template TypedValue* functionWrapper(ActRec* ar) { - assert(ar); + assertx(ar); auto func = ar->m_func; auto numArgs = func->numParams(); auto numNonDefault = ar->numArgs(); @@ -440,7 +440,7 @@ TypedValue* functionWrapper(ActRec* ar) { rv.m_data.num = 0; } - assert(rv.m_type != KindOfUninit); + assertx(rv.m_type != KindOfUninit); frame_free_locals_no_this_inl(ar, func->numLocals(), &rv); tvCopy(rv, *ar->retSlot()); return ar->retSlot(); @@ -448,7 +448,7 @@ TypedValue* functionWrapper(ActRec* ar) { template TypedValue* methodWrapper(ActRec* ar) { - assert(ar); + assertx(ar); auto func = ar->m_func; auto numArgs = func->numParams(); auto numNonDefault = ar->numArgs(); @@ -483,7 +483,7 @@ TypedValue* methodWrapper(ActRec* ar) { rv.m_data.num = 0; } - assert(rv.m_type != KindOfUninit); + assertx(rv.m_type != KindOfUninit); if (isStatic) { frame_free_locals_no_this_inl(ar, func->numLocals(), &rv); } else { diff --git a/hphp/runtime/vm/native.h b/hphp/runtime/vm/native.h index 56391fd1f65..409c072a69f 100644 --- a/hphp/runtime/vm/native.h +++ b/hphp/runtime/vm/native.h @@ -538,7 +538,7 @@ extern ConstantMap s_constant_map; inline bool registerConstant(const StringData* cnsName, Cell cns, bool dynamic = false) { - assert(cellIsPlausible(cns) && cns.m_type != KindOfUninit); + assertx(cellIsPlausible(cns) && cns.m_type != KindOfUninit); auto& dst = s_constant_map[cnsName]; *static_cast(&dst) = cns; dst.dynamic() = dynamic; @@ -581,9 +581,9 @@ inline bool registerClassConstant(const StringData *clsName, const StringData *cnsName, Cell cns) { - assert(cellIsPlausible(cns)); + assertx(cellIsPlausible(cns)); auto &cls = s_class_constant_map[clsName]; - assert(cls.find(cnsName) == cls.end()); + assertx(cls.find(cnsName) == cls.end()); *static_cast(&cls[cnsName]) = cns; return true; } diff --git a/hphp/runtime/vm/pc-filter.cpp b/hphp/runtime/vm/pc-filter.cpp index 972a018bea6..2cbff5c8d61 100644 --- a/hphp/runtime/vm/pc-filter.cpp +++ b/hphp/runtime/vm/pc-filter.cpp @@ -37,7 +37,7 @@ void PCFilter::PtrMapNode::clearImpl(unsigned short bits) { // clear all the sub levels and mark all slots NULL if (bits <= PTRMAP_LEVEL_BITS) { - assert(bits == PTRMAP_LEVEL_BITS); + assertx(bits == PTRMAP_LEVEL_BITS); return; } for (int i = 0; i < PTRMAP_LEVEL_ENTRIES; i++) { @@ -56,13 +56,13 @@ static void* MakeNode() { void* PCFilter::PtrMap::getPointerImpl(void* ptr) const { auto current = (PtrMapNode*)&m_root; - assert(current->m_entries); + assertx(current->m_entries); unsigned short cursor = PTRMAP_PTR_SIZE; do { cursor -= PTRMAP_LEVEL_BITS; unsigned long index = ((PTRMAP_LEVEL_MASK << cursor) & (unsigned long)ptr) >> cursor; - assert(index < PTRMAP_LEVEL_ENTRIES); + assertx(index < PTRMAP_LEVEL_ENTRIES); current = (PtrMapNode*)¤t->m_entries[index]; } while (current->m_entries && cursor); return current->m_entries; @@ -74,14 +74,14 @@ void PCFilter::PtrMap::setPointer(void* ptr, void* val) { if (!val) return; m_root = MakeNode(); } - assert(current->m_entries == m_root); + assertx(current->m_entries == m_root); unsigned short cursor = PTRMAP_PTR_SIZE; while (true) { cursor -= PTRMAP_LEVEL_BITS; unsigned long index = ((PTRMAP_LEVEL_MASK << cursor) & (unsigned long)ptr) >> cursor; - assert(index < PTRMAP_LEVEL_ENTRIES); + assertx(index < PTRMAP_LEVEL_ENTRIES); if (!cursor) { current->m_entries[index] = val; break; diff --git a/hphp/runtime/vm/preclass-emitter.cpp b/hphp/runtime/vm/preclass-emitter.cpp index 2419b465ec3..aec8fab0421 100644 --- a/hphp/runtime/vm/preclass-emitter.cpp +++ b/hphp/runtime/vm/preclass-emitter.cpp @@ -121,7 +121,7 @@ bool PreClassEmitter::addMethod(FuncEmitter* method) { void PreClassEmitter::renameMethod(const StringData* oldName, const StringData* newName) { MethodMap::const_iterator it = m_methodMap.find(oldName); - assert(it != m_methodMap.end()); + assertx(it != m_methodMap.end()); it->second->name = newName; m_methodMap[newName] = it->second; m_methodMap.erase(oldName); @@ -145,7 +145,7 @@ bool PreClassEmitter::addProperty(const StringData* n, Attr attrs, const PreClassEmitter::Prop& PreClassEmitter::lookupProp(const StringData* propName) const { PropMap::Builder::const_iterator it = m_propMap.find(propName); - assert(it != m_propMap.end()); + assertx(it != m_propMap.end()); Slot idx = it->second; return m_propMap[idx]; } @@ -176,7 +176,7 @@ bool PreClassEmitter::addConstant(const StringData* n, if (typeconst && !typeStructure.empty()) { assertx(typeStructure.isDictOrDArray()); tvVal = make_persistent_array_like_tv(typeStructure.get()); - assert(tvIsPlausible(tvVal)); + assertx(tvIsPlausible(tvVal)); } else { tvVal = *val; } @@ -226,7 +226,7 @@ PreClass* PreClassEmitter::create(Unit& unit) const { attrs = Attr(attrs & ~AttrPersistent); } - assert(attrs & AttrPersistent || SystemLib::s_inited); + assertx(attrs & AttrPersistent || SystemLib::s_inited); auto pc = std::make_unique( &unit, m_line1, m_line2, m_offset, m_name, @@ -431,10 +431,10 @@ void PreClassRepoProxy::GetPreClassesStmt name, (PreClass::Hoistable)hoistable); pce->serdeMetaData(extraBlob); if (!SystemLib::s_inited) { - assert(pce->attrs() & AttrPersistent); - assert(pce->attrs() & AttrUnique); + assertx(pce->attrs() & AttrPersistent); + assertx(pce->attrs() & AttrUnique); } - assert(pce->id() == preClassId); + assertx(pce->id() == preClassId); } } while (!query.done()); txn.commit(); diff --git a/hphp/runtime/vm/preclass-inl.h b/hphp/runtime/vm/preclass-inl.h index 8f6d49314fa..3db1cfc2bbd 100644 --- a/hphp/runtime/vm/preclass-inl.h +++ b/hphp/runtime/vm/preclass-inl.h @@ -44,20 +44,20 @@ inline bool PreClass::hasProp(const StringData* propName) const { inline const PreClass::Const* PreClass::lookupConstant(const StringData* cnsName) const { Slot s = m_constants.findIndex(cnsName); - assert(s != kInvalidSlot); + assertx(s != kInvalidSlot); return &m_constants[s]; } inline Func* PreClass::lookupMethod(const StringData* methName) const { Func* f = m_methods.lookupDefault(methName, nullptr); - assert(f != nullptr); + assertx(f != nullptr); return f; } inline const PreClass::Prop* PreClass::lookupProp(const StringData* propName) const { Slot s = m_properties.findIndex(propName); - assert(s != kInvalidSlot); + assertx(s != kInvalidSlot); return &m_properties[s]; } diff --git a/hphp/runtime/vm/repo-helpers.cpp b/hphp/runtime/vm/repo-helpers.cpp index 170ba5750c8..d1e4e2fc3d9 100644 --- a/hphp/runtime/vm/repo-helpers.cpp +++ b/hphp/runtime/vm/repo-helpers.cpp @@ -191,8 +191,8 @@ void RepoTxn::exec(RepoQuery& query) { } void RepoTxn::rollback() { - assert(!m_error); - assert(m_pending); + assertx(!m_error); + assertx(m_pending); m_error = true; m_pending = false; m_repo.rollback(); @@ -211,7 +211,7 @@ void RepoQuery::bindBlob(const char* paramName, const void* blob, sqlite3_bind_parameter_index(stmt, paramName), blob, int(size), isStatic ? SQLITE_STATIC : SQLITE_TRANSIENT); - assert(rc == SQLITE_OK); + assertx(rc == SQLITE_OK); } void RepoQuery::bindBlob(const char* paramName, const BlobEncoder& blob, @@ -242,7 +242,7 @@ void RepoQuery::bindText(const char* paramName, const char* text, sqlite3_bind_parameter_index(stmt, paramName), text, int(size), isStatic ? SQLITE_STATIC : SQLITE_TRANSIENT); - assert(rc == SQLITE_OK); + assertx(rc == SQLITE_OK); } void RepoQuery::bindStaticString(const char* paramName, const StringData* sd) { @@ -267,7 +267,7 @@ void RepoQuery::bindDouble(const char* paramName, double val) { sqlite3_bind_double(stmt, sqlite3_bind_parameter_index(stmt, paramName), val); - assert(rc == SQLITE_OK); + assertx(rc == SQLITE_OK); } void RepoQuery::bindInt(const char* paramName, int val) { @@ -276,7 +276,7 @@ void RepoQuery::bindInt(const char* paramName, int val) { sqlite3_bind_int(stmt, sqlite3_bind_parameter_index(stmt, paramName), val); - assert(rc == SQLITE_OK); + assertx(rc == SQLITE_OK); } void RepoQuery::bindId(const char* paramName, Id id) { @@ -301,7 +301,7 @@ void RepoQuery::bindInt64(const char* paramName, int64_t val) { sqlite3_bind_int64(stmt, sqlite3_bind_parameter_index(stmt, paramName), val); - assert(rc == SQLITE_OK); + assertx(rc == SQLITE_OK); } void RepoQuery::bindNull(const char* paramName) { @@ -309,7 +309,7 @@ void RepoQuery::bindNull(const char* paramName) { int rc UNUSED = sqlite3_bind_null(stmt, sqlite3_bind_parameter_index(stmt, paramName)); - assert(rc == SQLITE_OK); + assertx(rc == SQLITE_OK); } void RepoQuery::step() { @@ -426,7 +426,7 @@ void RepoQuery::getTypedValue(int iCol, TypedValue& tv) { v = Array(ArrayData::GetScalarArray(std::move(v))); } else { // Serialized variants and objects shouldn't ever make it into the repo. - assert(!isRefcountedType(v.getType())); + assertx(!isRefcountedType(v.getType())); } tvAsVariant(&tv) = v; } @@ -519,12 +519,12 @@ void RepoQuery::getInt64(int iCol, int64_t& val) { // RepoTxnQuery. void RepoTxnQuery::step() { - assert(!m_txn.error()); + assertx(!m_txn.error()); m_txn.step(*this); } void RepoTxnQuery::exec() { - assert(!m_txn.error()); + assertx(!m_txn.error()); m_txn.exec(*this); } diff --git a/hphp/runtime/vm/repo-helpers.h b/hphp/runtime/vm/repo-helpers.h index 487fede5af7..79bfe3bea78 100644 --- a/hphp/runtime/vm/repo-helpers.h +++ b/hphp/runtime/vm/repo-helpers.h @@ -89,7 +89,7 @@ struct RepoStmt { struct RepoQuery { explicit RepoQuery(RepoStmt& stmt) : m_stmt(stmt), m_row(false), m_done(false) { - assert(m_stmt.prepared()); + assertx(m_stmt.prepared()); } ~RepoQuery() { m_stmt.reset(); } diff --git a/hphp/runtime/vm/repo.cpp b/hphp/runtime/vm/repo.cpp index 475e0beaea1..96218425f69 100644 --- a/hphp/runtime/vm/repo.cpp +++ b/hphp/runtime/vm/repo.cpp @@ -123,8 +123,8 @@ Repo::~Repo() { std::string Repo::s_cliFile; void Repo::setCliFile(const std::string& cliFile) { - assert(s_cliFile.empty()); - assert(t_dh.isNull()); + assertx(s_cliFile.empty()); + assertx(t_dh.isNull()); s_cliFile = cliFile; } @@ -238,7 +238,7 @@ void Repo::loadGlobalData(bool allowFailure /* = false */, } } - assert(Process::IsInMainThread()); + assertx(Process::IsInMainThread()); exit(1); } @@ -473,7 +473,7 @@ void Repo::txPop() { // rollback an inner transaction we eventually end up rolling back the outer // transaction instead (Sqlite doesn't support rolling back partial // transactions). - assert(m_txDepth > 0); + assertx(m_txDepth > 0); if (m_txDepth > 1) { m_txDepth--; return; @@ -534,7 +534,7 @@ void Repo::commitUnit(UnitEmitter* ue, UnitOrigin unitOrigin) { } catch (const std::exception& e) { TRACE(0, "unexpected exception in commitUnit: %s\n", e.what()); - assert(false); + assertx(false); } } @@ -546,7 +546,7 @@ void Repo::connect() { } else if (!RuntimeOption::RepoEvalMode.compare("central")) { m_evalRepoId = RepoIdCentral; } else { - assert(!RuntimeOption::RepoEvalMode.compare("readonly")); + assertx(!RuntimeOption::RepoEvalMode.compare("readonly")); m_evalRepoId = RepoIdInvalid; } TRACE(1, "Repo.Eval.Mode=%s\n", @@ -570,7 +570,7 @@ void Repo::disconnect() { void Repo::initCentral() { std::string error; - assert(m_dbc == nullptr); + assertx(m_dbc == nullptr); auto tryPath = [this, &error](const char* path) { std::string subErr; if (openCentral(path, subErr) == RepoStatus::error) { @@ -854,7 +854,7 @@ void Repo::initLocal() { if (!RuntimeOption::RepoLocalMode.compare("rw")) { isWritable = true; } else { - assert(!RuntimeOption::RepoLocalMode.compare("r-")); + assertx(!RuntimeOption::RepoLocalMode.compare("r-")); isWritable = false; } diff --git a/hphp/runtime/vm/repo.h b/hphp/runtime/vm/repo.h index 385e08b30f6..d7a89329dd4 100644 --- a/hphp/runtime/vm/repo.h +++ b/hphp/runtime/vm/repo.h @@ -64,7 +64,7 @@ struct Repo : RepoProxy { ~Repo(); const char* dbName(int repoId) const { - assert(repoId < RepoIdCount); + assertx(repoId < RepoIdCount); return kDbs[repoId]; } sqlite3* dbc() const { return m_dbc; } @@ -75,7 +75,7 @@ struct Repo : RepoProxy { case UnitOrigin::Eval: return m_evalRepoId; default: - assert(false); + assertx(false); return RepoIdInvalid; } } @@ -125,7 +125,7 @@ struct Repo : RepoProxy { * RuntimeOption::RepoAuthoritative. */ static const GlobalData& global() { - assert(RuntimeOption::RepoAuthoritative); + assertx(RuntimeOption::RepoAuthoritative); return s_globalData; } diff --git a/hphp/runtime/vm/resumable.h b/hphp/runtime/vm/resumable.h index 089c9341390..da6a213487b 100644 --- a/hphp/runtime/vm/resumable.h +++ b/hphp/runtime/vm/resumable.h @@ -133,14 +133,14 @@ struct alignas(16) Resumable { bool mayUseVV = true> void initialize(const ActRec* fp, jit::TCA resumeAddr, Offset resumeOffset, size_t frameSize, size_t totalSize) { - assert(fp); - assert(fp->resumed() == clone); + assertx(fp); + assertx(fp->resumed() == clone); auto const func = fp->func(); - assert(func); - assert(func->isResumable()); - assert(func->contains(resumeOffset)); + assertx(func); + assertx(func->isResumable()); + assertx(func->contains(resumeOffset)); // Check memory alignment - assert((((uintptr_t) actRec()) & (sizeof(Cell) - 1)) == 0); + assertx((((uintptr_t) actRec()) & (sizeof(Cell) - 1)) == 0); if (!clone) { // Copy ActRec, locals and iterators @@ -152,7 +152,7 @@ struct alignas(16) Resumable { actRec()->setResumed(); // Suspend VarEnv if needed - assert(mayUseVV || !(func->attrs() & AttrMayUseVV)); + assertx(mayUseVV || !(func->attrs() & AttrMayUseVV)); if (mayUseVV && UNLIKELY(func->attrs() & AttrMayUseVV) && UNLIKELY(fp->hasVarEnv())) { @@ -184,13 +184,13 @@ struct alignas(16) Resumable { const ActRec* actRec() const { return &m_actRec; } jit::TCA resumeAddr() const { return m_resumeAddr; } Offset resumeOffset() const { - assert(m_actRec.func()->contains(m_resumeOffset)); + assertx(m_actRec.func()->contains(m_resumeOffset)); return m_resumeOffset; } size_t size() const { return m_size; } void setResumeAddr(jit::TCA resumeAddr, Offset resumeOffset) { - assert(m_actRec.func()->contains(resumeOffset)); + assertx(m_actRec.func()->contains(resumeOffset)); m_resumeAddr = resumeAddr; m_resumeOffset = resumeOffset; } diff --git a/hphp/runtime/vm/ringbuffer-print.cpp b/hphp/runtime/vm/ringbuffer-print.cpp index aa1cff61048..1ea332aec3e 100644 --- a/hphp/runtime/vm/ringbuffer-print.cpp +++ b/hphp/runtime/vm/ringbuffer-print.cpp @@ -110,7 +110,7 @@ void dumpRingBufferMasked(int numEntries, uint32_t types, uint32_t threadId) { while (startIdx < 0) { startIdx += kMaxRBEntries; } - assert(startIdx >= 0 && startIdx < kMaxRBEntries); + assertx(startIdx >= 0 && startIdx < kMaxRBEntries); int numDumped = 0; for (int i = 0; i < kMaxRBEntries && numDumped < numEntries; i++) { RingBufferEntry* rb = &g_ring_ptr[(startIdx + i) % kMaxRBEntries]; diff --git a/hphp/runtime/vm/runtime.cpp b/hphp/runtime/vm/runtime.cpp index 3601eca971c..6fe27b595aa 100644 --- a/hphp/runtime/vm/runtime.cpp +++ b/hphp/runtime/vm/runtime.cpp @@ -74,7 +74,7 @@ StringData* concat_ss(StringData* v1, StringData* v2) { auto const ret = v1->append(v2->slice()); if (UNLIKELY(ret != v1)) { - assert(v1->hasExactlyOneRef()); + assertx(v1->hasExactlyOneRef()); v1->release(); } return ret; @@ -108,7 +108,7 @@ StringData* concat_si(StringData* v1, int64_t v2) { auto const ret = v1->append(s2); if (UNLIKELY(ret != v1)) { - assert(v1->hasExactlyOneRef()); + assertx(v1->hasExactlyOneRef()); v1->release(); } return ret; @@ -126,7 +126,7 @@ StringData* concat_s3(StringData* v1, StringData* v2, StringData* v3) { auto const ret = v1->append(v2->slice(), v3->slice()); if (UNLIKELY(ret != v1)) { - assert(v1->hasExactlyOneRef()); + assertx(v1->hasExactlyOneRef()); v1->release(); } return ret; @@ -145,7 +145,7 @@ StringData* concat_s4(StringData* v1, StringData* v2, auto const ret = v1->append(v2->slice(), v3->slice(), v4->slice()); if (UNLIKELY(ret != v1)) { - assert(v1->hasExactlyOneRef()); + assertx(v1->hasExactlyOneRef()); v1->release(); } return ret; diff --git a/hphp/runtime/vm/runtime.h b/hphp/runtime/vm/runtime.h index 4915695f3a9..9dcc438943b 100644 --- a/hphp/runtime/vm/runtime.h +++ b/hphp/runtime/vm/runtime.h @@ -82,30 +82,30 @@ frame_local(const ActRec* fp, int n) { inline Resumable* frame_resumable(const ActRec* fp) { - assert(fp->resumed()); + assertx(fp->resumed()); return (Resumable*)((char*)fp - Resumable::arOff()); } inline c_AsyncFunctionWaitHandle* frame_afwh(const ActRec* fp) { - assert(fp->func()->isAsyncFunction()); + assertx(fp->func()->isAsyncFunction()); auto resumable = frame_resumable(fp); auto arOffset = c_AsyncFunctionWaitHandle::arOff(); auto waitHandle = (c_AsyncFunctionWaitHandle*)((char*)resumable - arOffset); - assert(waitHandle->getVMClass() == c_AsyncFunctionWaitHandle::classof()); + assertx(waitHandle->getVMClass() == c_AsyncFunctionWaitHandle::classof()); return waitHandle; } inline Generator* frame_generator(const ActRec* fp) { - assert(fp->func()->isNonAsyncGenerator()); + assertx(fp->func()->isNonAsyncGenerator()); auto resumable = frame_resumable(fp); return (Generator*)((char*)resumable - Generator::resumableOff()); } inline AsyncGenerator* frame_async_generator(const ActRec* fp) { - assert(fp->func()->isAsyncGenerator()); + assertx(fp->func()->isAsyncGenerator()); auto resumable = frame_resumable(fp); return (AsyncGenerator*)((char*)resumable - AsyncGenerator::resumableOff()); @@ -113,7 +113,7 @@ frame_async_generator(const ActRec* fp) { void ALWAYS_INLINE frame_free_locals_helper_inl(ActRec* fp, int numLocals) { - assert(numLocals == fp->m_func->numLocals()); + assertx(numLocals == fp->m_func->numLocals()); // Check if the frame has a VarEnv or if it has extraArgs if (UNLIKELY(fp->func()->attrs() & AttrMayUseVV) && UNLIKELY(fp->m_varEnv != nullptr)) { @@ -124,7 +124,7 @@ frame_free_locals_helper_inl(ActRec* fp, int numLocals) { return; } // Free extra args - assert(fp->hasExtraArgs()); + assertx(fp->hasExtraArgs()); ExtraArgs* ea = fp->getExtraArgs(); int numExtra = fp->numArgs() - fp->m_func->numNonVariadicParams(); ExtraArgs::deallocate(ea, numExtra); @@ -154,9 +154,9 @@ frame_free_locals_inl(ActRec* fp, int numLocals, TypedValue* rv) { void ALWAYS_INLINE frame_free_inl(ActRec* fp, TypedValue* rv) { // For frames with no locals - assert(0 == fp->m_func->numLocals()); - assert(fp->m_varEnv == nullptr); - assert(fp->hasThis()); + assertx(0 == fp->m_func->numLocals()); + assertx(fp->m_varEnv == nullptr); + assertx(fp->hasThis()); decRefObj(fp->getThis()); EventHook::FunctionReturn(fp, *rv); } @@ -198,9 +198,9 @@ Unit* build_native_class_unit(const HhbcExtClassInfo* builtinClasses, // necessary. The initial ref-count of the instance will be greater than zero. inline ObjectData* newInstance(Class* cls) { - assert(cls); + assertx(cls); auto* inst = ObjectData::newInstance(cls); - assert(inst->checkCount()); + assertx(inst->checkCount()); Stats::inc(cls->getDtor() ? Stats::ObjectData_new_dtor_yes : Stats::ObjectData_new_dtor_no); diff --git a/hphp/runtime/vm/srckey-inl.h b/hphp/runtime/vm/srckey-inl.h index ced7d3b8933..2927a94b889 100644 --- a/hphp/runtime/vm/srckey-inl.h +++ b/hphp/runtime/vm/srckey-inl.h @@ -34,7 +34,7 @@ inline SrcKey::SrcKey(const Func* f, Offset off, ResumeMode resumeMode, , m_hasThis{hasThis} , m_resumeModeAndPrologue{encodeResumeMode(resumeMode)} { - assert((uint32_t)off >> 31 == 0); + assertx((uint32_t)off >> 31 == 0); } inline SrcKey::SrcKey(const Func* f, PC pc, ResumeMode resumeMode, bool hasThis) @@ -43,7 +43,7 @@ inline SrcKey::SrcKey(const Func* f, PC pc, ResumeMode resumeMode, bool hasThis) , m_hasThis{hasThis} , m_resumeModeAndPrologue{encodeResumeMode(resumeMode)} { - assert((uint32_t)f->unit()->offsetOf(pc) >> 31 == 0); + assertx((uint32_t)f->unit()->offsetOf(pc) >> 31 == 0); } inline SrcKey::SrcKey(FuncId funcId, Offset off, ResumeMode resumeMode, @@ -53,7 +53,7 @@ inline SrcKey::SrcKey(FuncId funcId, Offset off, ResumeMode resumeMode, , m_hasThis{hasThis} , m_resumeModeAndPrologue{encodeResumeMode(resumeMode)} { - assert((uint32_t)off >> 31 == 0); + assertx((uint32_t)off >> 31 == 0); } inline SrcKey::SrcKey(const Func* f, Offset off, PrologueTag) @@ -62,7 +62,7 @@ inline SrcKey::SrcKey(const Func* f, Offset off, PrologueTag) , m_hasThis{false} , m_resumeModeAndPrologue{encodePrologue()} { - assert((uint32_t)off >> 31 == 0); + assertx((uint32_t)off >> 31 == 0); } inline SrcKey::SrcKey(const Func* f, PC pc, PrologueTag) @@ -71,7 +71,7 @@ inline SrcKey::SrcKey(const Func* f, PC pc, PrologueTag) , m_hasThis{false} , m_resumeModeAndPrologue{encodePrologue()} { - assert((uint32_t)f->unit()->offsetOf(pc) >> 31 == 0); + assertx((uint32_t)f->unit()->offsetOf(pc) >> 31 == 0); } inline SrcKey::SrcKey(FuncId funcId, Offset off, PrologueTag) @@ -80,7 +80,7 @@ inline SrcKey::SrcKey(FuncId funcId, Offset off, PrologueTag) , m_hasThis{false} , m_resumeModeAndPrologue{encodePrologue()} { - assert((uint32_t)off >> 31 == 0); + assertx((uint32_t)off >> 31 == 0); } inline SrcKey::SrcKey(SrcKey other, Offset off) @@ -89,7 +89,7 @@ inline SrcKey::SrcKey(SrcKey other, Offset off) , m_hasThis{other.hasThis()} , m_resumeModeAndPrologue{other.m_resumeModeAndPrologue} { - assert((uint32_t)off >> 31 == 0); + assertx((uint32_t)off >> 31 == 0); } inline SrcKey::SrcKey(AtomicInt in) @@ -111,7 +111,7 @@ inline SrcKey::AtomicInt SrcKey::toAtomicInt() const { } inline FuncId SrcKey::funcID() const { - assert(m_funcID != InvalidFuncId); + assertx(m_funcID != InvalidFuncId); return m_funcID; } @@ -159,7 +159,7 @@ inline PC SrcKey::pc() const { /////////////////////////////////////////////////////////////////////////////// inline void SrcKey::setOffset(Offset o) { - assert((uint32_t)o >> 31 == 0); + assertx((uint32_t)o >> 31 == 0); m_offset = (uint32_t)o; } diff --git a/hphp/runtime/vm/trait-method-import-data-inl.h b/hphp/runtime/vm/trait-method-import-data-inl.h index 328dbf8cd40..2a62e7e4d07 100644 --- a/hphp/runtime/vm/trait-method-import-data-inl.h +++ b/hphp/runtime/vm/trait-method-import-data-inl.h @@ -47,7 +47,7 @@ TraitMethodImportData add(tm, aliasedName); - assert(m_dataForName.count(origName)); + assertx(m_dataForName.count(origName)); m_dataForName[origName].aliases.push_back(aliasedName); } diff --git a/hphp/runtime/vm/tread-hash-map.h b/hphp/runtime/vm/tread-hash-map.h index cdd44486490..4ec5de41790 100644 --- a/hphp/runtime/vm/tread-hash-map.h +++ b/hphp/runtime/vm/tread-hash-map.h @@ -168,15 +168,16 @@ public: } Val* insert(Key key, Val val) { - assert(key != 0); + assertx(key != 0); return insertImpl(acquireAndGrowIfNeeded(), key, val); } Val* find(Key key) const { - assert(key != 0); + assertx(key != 0); + auto tab = m_table.load(std::memory_order_consume); if (tab->size == 0) return nullptr; // empty - assert(tab->capac > tab->size); + assertx(tab->capac > tab->size); auto idx = project(tab, key); for (;;) { auto& entry = tab->entries[idx]; @@ -190,14 +191,14 @@ public: private: Val* insertImpl(Table* const tab, Key newKey, Val newValue) { auto probe = &tab->entries[project(tab, newKey)]; - assert(size_t(probe - tab->entries) < tab->capac); + assertx(size_t(probe - tab->entries) < tab->capac); // Since we're the only thread allowed to write, we're allowed to // do a relaxed load here. (No need for an acquire/release // handshake with ourselves.) while (Key currentProbe = probe->first) { - assert(currentProbe != newKey); // insertions must be unique - assert(probe <= (tab->entries + tab->capac)); + assertx(currentProbe != newKey); // insertions must be unique + assertx(probe <= (tab->entries + tab->capac)); // can't loop forever; acquireAndGrowIfNeeded ensures there's // some slack. (void)currentProbe; @@ -239,13 +240,13 @@ private: } Treadmill::enqueue([this, old] { freeTable(old); }); } - assert(newTable->size == old->size); // only one writer thread + assertx(newTable->size == old->size); // only one writer thread m_table.store(newTable, std::memory_order_release); return newTable; } size_t project(Table* tab, Key key) const { - assert(folly::isPowTwo(tab->capac)); + assertx(folly::isPowTwo(tab->capac)); return m_hash(key) & (tab->capac - 1); } diff --git a/hphp/runtime/vm/treadmill.cpp b/hphp/runtime/vm/treadmill.cpp index 7404e80a8d1..b683c98b7b0 100644 --- a/hphp/runtime/vm/treadmill.cpp +++ b/hphp/runtime/vm/treadmill.cpp @@ -179,7 +179,7 @@ void startRequest() { if (threadIdx >= s_inflightRequests.size()) { s_inflightRequests.resize(threadIdx + 1, {kIdleGenCount, 0}); } else { - assert(s_inflightRequests[threadIdx].startTime == kIdleGenCount); + assertx(s_inflightRequests[threadIdx].startTime == kIdleGenCount); } s_inflightRequests[threadIdx].startTime = correctTime(startTime); s_inflightRequests[threadIdx].pthreadId = Process::GetThreadId(); @@ -198,12 +198,12 @@ void startRequest() { void finishRequest() { auto const threadIdx = Treadmill::threadIdx(); - assert(threadIdx != -1); + assertx(threadIdx != -1); FTRACE(1, "tid {} finish\n", threadIdx); std::vector> toFire; { GenCountGuard g; - assert(s_inflightRequests[threadIdx].startTime != kIdleGenCount); + assertx(s_inflightRequests[threadIdx].startTime != kIdleGenCount); GenCount finishedRequest = s_inflightRequests[threadIdx].startTime; s_inflightRequests[threadIdx].startTime = kIdleGenCount; @@ -257,7 +257,7 @@ void finishRequest() { break; } } - assert(i < limit); + assertx(i < limit); if (i == limit) { Logger::Warning("Treadmill fails to set global GC status into Idle"); } diff --git a/hphp/runtime/vm/type-alias-inl.h b/hphp/runtime/vm/type-alias-inl.h index a809d302672..c41a67aa41b 100644 --- a/hphp/runtime/vm/type-alias-inl.h +++ b/hphp/runtime/vm/type-alias-inl.h @@ -40,7 +40,7 @@ inline TypeAliasReq TypeAliasReq::Invalid(Unit* unit) { } inline TypeAliasReq TypeAliasReq::From(Unit* unit, const TypeAlias& alias) { - assert(alias.type != AnnotType::Object); + assertx(alias.type != AnnotType::Object); assertx(unit); TypeAliasReq req; @@ -56,7 +56,7 @@ inline TypeAliasReq TypeAliasReq::From(Unit* unit, const TypeAlias& alias) { inline TypeAliasReq TypeAliasReq::From(Unit* unit, TypeAliasReq req, const TypeAlias& alias) { - assert(alias.type == AnnotType::Object); + assertx(alias.type == AnnotType::Object); assertx(unit); req.unit = unit; diff --git a/hphp/runtime/vm/type-alias.h b/hphp/runtime/vm/type-alias.h index 9ec3c61bfb6..9ff62a5f92f 100644 --- a/hphp/runtime/vm/type-alias.h +++ b/hphp/runtime/vm/type-alias.h @@ -85,8 +85,8 @@ struct TypeAlias { TypedValue tv; sd(tv); - assert(tvIsPlausible(tv)); - assert( + assertx(tvIsPlausible(tv)); + assertx( RuntimeOption::EvalHackArrDVArrs ? isDictType(tv.m_type) : isArrayType(tv.m_type) diff --git a/hphp/runtime/vm/type-constraint.cpp b/hphp/runtime/vm/type-constraint.cpp index 45b900863af..443d1bf8d42 100644 --- a/hphp/runtime/vm/type-constraint.cpp +++ b/hphp/runtime/vm/type-constraint.cpp @@ -62,9 +62,9 @@ void TypeConstraint::init() { auto const mptr = nameToAnnotType(m_typeName); if (mptr) { m_type = *mptr; - assert(getAnnotDataType(m_type) != KindOfPersistentString); + assertx(getAnnotDataType(m_type) != KindOfPersistentString); if (RuntimeOption::EvalHackArrDVArrs) { - assert(m_type != AnnotType::VArray && + assertx(m_type != AnnotType::VArray && m_type != AnnotType::DArray && m_type != AnnotType::VArrOrDArr); if (m_typeName->isame(s_varray.get())) { @@ -267,15 +267,15 @@ std::pair getTypeAliasOrClassWithAutoload( } } - assert(!def || !klass); + assertx(!def || !klass); return std::make_pair(def, klass); } } MaybeDataType TypeConstraint::underlyingDataTypeResolved() const { - assert(!isSelf() && !isParent() && !isCallable()); - assert(IMPLIES( + assertx(!isSelf() && !isParent() && !isCallable()); + assertx(IMPLIES( !hasConstraint() || isTypeVar() || isTypeConstant(), isMixed())); @@ -285,12 +285,12 @@ MaybeDataType TypeConstraint::underlyingDataTypeResolved() const { } auto t = underlyingDataType(); - assert(t); + assertx(t); // If we aren't a class or type alias, nothing special to do. if (!isObject()) return t; - assert(t == KindOfObject); + assertx(t == KindOfObject); auto p = getTypeAliasOrClassWithAutoload(m_namedEntity, m_typeName); auto td = p.first; auto c = p.second; @@ -321,8 +321,8 @@ MaybeDataType TypeConstraint::underlyingDataTypeResolved() const { } bool TypeConstraint::checkTypeAliasNonObj(const TypedValue* tv) const { - assert(tv->m_type != KindOfObject); - assert(isObject()); + assertx(tv->m_type != KindOfObject); + assertx(isObject()); auto p = getTypeAliasOrClassWithAutoload(m_namedEntity, m_typeName); auto td = p.first; @@ -340,20 +340,20 @@ bool TypeConstraint::checkTypeAliasNonObj(const TypedValue* tv) const { return is_callable(tvAsCVarRef(tv)); case AnnotAction::ObjectCheck: break; case AnnotAction::VArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return tv->m_data.parr->isVArray(); case AnnotAction::DArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return tv->m_data.parr->isDArray(); case AnnotAction::VArrayOrDArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return !tv->m_data.parr->isNotDVArray(); case AnnotAction::NonVArrayOrDArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return tv->m_data.parr->isNotDVArray(); } - assert(result == AnnotAction::ObjectCheck); - assert(td->type == AnnotType::Object); + assertx(result == AnnotAction::ObjectCheck); + assertx(td->type == AnnotType::Object); // Fall through to the check below, since this could be a type // alias to an enum type c = td->klass; @@ -377,7 +377,7 @@ bool TypeConstraint::checkTypeAliasNonObj(const TypedValue* tv) const { } bool TypeConstraint::checkTypeAliasObj(const Class* cls) const { - assert(isObject() && m_namedEntity && m_typeName); + assertx(isObject() && m_namedEntity && m_typeName); // Look up the type alias (autoloading if necessary) // and fail if we can't find it auto const td = getTypeAliasWithAutoload(m_namedEntity, m_typeName); @@ -429,7 +429,7 @@ void TypeConstraint::verifyReturnNonNull(TypedValue* tv, const Func* func, } bool TypeConstraint::check(TypedValue* tv, const Func* func) const { - assert(hasConstraint() && !isTypeVar() && !isMixed() && !isTypeConstant()); + assertx(hasConstraint() && !isTypeVar() && !isMixed() && !isTypeConstant()); // This is part of the interpreter runtime; perf matters. if (tv->m_type == KindOfRef) { @@ -450,7 +450,7 @@ bool TypeConstraint::check(TypedValue* tv, const Func* func) const { } // We can't save the Class* since it moves around from request // to request. - assert(m_namedEntity); + assertx(m_namedEntity); c = Unit::lookupClass(m_namedEntity); } else { switch (metaType()) { @@ -507,19 +507,19 @@ bool TypeConstraint::check(TypedValue* tv, const Func* func) const { case AnnotAction::CallableCheck: return is_callable(tvAsCVarRef(tv)); case AnnotAction::ObjectCheck: - assert(isObject()); + assertx(isObject()); return checkTypeAliasNonObj(tv); case AnnotAction::VArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return tv->m_data.parr->isVArray(); case AnnotAction::DArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return tv->m_data.parr->isDArray(); case AnnotAction::VArrayOrDArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return !tv->m_data.parr->isNotDVArray(); case AnnotAction::NonVArrayOrDArrayCheck: - assert(tvIsArray(tv)); + assertx(tvIsArray(tv)); return tv->m_data.parr->isNotDVArray(); } not_reached(); @@ -862,7 +862,7 @@ MemoKeyConstraint memoKeyConstraintFromTC(const TypeConstraint& tc) { switch (tc.metaType()) { case AnnotMetaType::Precise: { auto const dt = tc.underlyingDataType(); - assert(dt.hasValue()); + assertx(dt.hasValue()); switch (*dt) { case KindOfNull: return MK::Null; case KindOfBoolean: diff --git a/hphp/runtime/vm/type-constraint.h b/hphp/runtime/vm/type-constraint.h index 8c024dac7f7..81f252a3e38 100644 --- a/hphp/runtime/vm/type-constraint.h +++ b/hphp/runtime/vm/type-constraint.h @@ -126,7 +126,7 @@ struct TypeConstraint { , m_typeName(typeName) , m_namedEntity(nullptr) { - assert(!(flags & Flags::Resolved)); + assertx(!(flags & Flags::Resolved)); init(); } @@ -147,8 +147,8 @@ struct TypeConstraint { TypeConstraint& operator=(const TypeConstraint&) = default; void resolveType(AnnotType t, bool nullable) { - assert(m_type == AnnotType::Object); - assert(t != AnnotType::Object); + assertx(m_type == AnnotType::Object); + assertx(t != AnnotType::Object); auto flags = m_flags | Flags::Resolved; if (nullable) flags |= Flags::Nullable; m_flags = static_cast(flags); diff --git a/hphp/runtime/vm/unit-emitter-inl.h b/hphp/runtime/vm/unit-emitter-inl.h index 69c6180229d..0e0ac9b9fff 100644 --- a/hphp/runtime/vm/unit-emitter-inl.h +++ b/hphp/runtime/vm/unit-emitter-inl.h @@ -112,7 +112,7 @@ void UnitEmitter::emitIVA(T n) { if (LIKELY((n & 0x7f) == n)) { emitByte((unsigned char)n); } else { - assert((n & 0x7fffffff) == n); + assertx((n & 0x7fffffff) == n); emitInt32((n & 0x7fffff80) << 1 | 0x80 | (n & 0x7f)); } } @@ -129,7 +129,7 @@ void UnitEmitter::emitImpl(T n, int64_t pos) { memcpy(&m_bc[m_bclen], c, sizeof(T)); m_bclen += sizeof(T); } else { - assert(pos + sizeof(T) <= m_bclen); + assertx(pos + sizeof(T) <= m_bclen); for (uint32_t i = 0; i < sizeof(T); ++i) { m_bc[pos + i] = c[i]; } diff --git a/hphp/runtime/vm/unit-emitter.cpp b/hphp/runtime/vm/unit-emitter.cpp index b6dd89262a1..29ec113ea9a 100644 --- a/hphp/runtime/vm/unit-emitter.cpp +++ b/hphp/runtime/vm/unit-emitter.cpp @@ -125,12 +125,12 @@ const StringData* UnitEmitter::lookupLitstr(Id id) const { if (isGlobalLitstrId(id)) { return LitstrTable::get().lookupLitstrId(decodeGlobalLitstrId(id)); } - assert(id < m_litstrs.size()); + assertx(id < m_litstrs.size()); return m_litstrs[id]; } const ArrayData* UnitEmitter::lookupArray(Id id) const { - assert(id < m_arrays.size()); + assertx(id < m_arrays.size()); return m_arrays[id]; } @@ -179,7 +179,7 @@ Id UnitEmitter::mergeArray(const ArrayData* a) { // FuncEmitters. void UnitEmitter::initMain(int line1, int line2) { - assert(m_fes.size() == 0); + assertx(m_fes.size() == 0); StringData* name = staticEmptyString(); FuncEmitter* pseudomain = newFuncEmitter(name); Attr attrs = AttrMayUseVV; @@ -205,7 +205,7 @@ void UnitEmitter::addTrivialPseudoMain() { FuncEmitter* UnitEmitter::newFuncEmitter(const StringData* name) { // The pseudomain comes first. - assert(m_fes.size() > 0 || !strcmp(name->data(), "")); + assertx(m_fes.size() > 0 || !strcmp(name->data(), "")); FuncEmitter* fe = new FuncEmitter(*this, m_nextFuncSn++, m_fes.size(), name); m_fes.push_back(fe); @@ -348,16 +348,16 @@ void UnitEmitter::recordSourceLocation(const Location::Range& sLoc, if (!m_sourceLocTab.empty()) { if (m_sourceLocTab.back().second == newLoc) { // Combine into the interval already at the back of the vector. - assert(start >= m_sourceLocTab.back().first); + assertx(start >= m_sourceLocTab.back().first); return; } - assert(m_sourceLocTab.back().first < start && + assertx(m_sourceLocTab.back().first < start && "source location offsets must be added to UnitEmitter in " "increasing order"); } else { // First record added should be for bytecode offset zero or very rarely one // when the source starts with a label and a Nop is inserted. - assert(start == 0 || start == 1); + assertx(start == 0 || start == 1); } m_sourceLocTab.push_back(std::make_pair(start, newLoc)); } @@ -378,7 +378,7 @@ void UnitEmitter::pushMergeableInclude(Unit::MergeKind kind, } void UnitEmitter::insertMergeableInclude(int ix, Unit::MergeKind kind, Id id) { - assert(size_t(ix) <= m_mergeableStmts.size()); + assertx(size_t(ix) <= m_mergeableStmts.size()); m_mergeableStmts.insert(m_mergeableStmts.begin() + ix, std::make_pair(kind, id)); m_allClassesHoistable = false; @@ -394,7 +394,7 @@ void UnitEmitter::pushMergeableDef(Unit::MergeKind kind, void UnitEmitter::insertMergeableDef(int ix, Unit::MergeKind kind, Id id, const TypedValue& tv) { - assert(size_t(ix) <= m_mergeableStmts.size()); + assertx(size_t(ix) <= m_mergeableStmts.size()); m_mergeableStmts.insert(m_mergeableStmts.begin() + ix, std::make_pair(kind, m_mergeableValues.size())); m_mergeableValues.push_back(std::make_pair(id, tv)); @@ -408,7 +408,7 @@ void UnitEmitter::pushMergeableTypeAlias(Unit::MergeKind kind, const Id id) { void UnitEmitter::insertMergeableTypeAlias(int ix, Unit::MergeKind kind, const Id id) { - assert(size_t(ix) <= m_mergeableStmts.size()); + assertx(size_t(ix) <= m_mergeableStmts.size()); m_mergeableStmts.insert(m_mergeableStmts.begin() + ix, std::make_pair(kind, id)); m_allClassesHoistable = false; @@ -601,17 +601,17 @@ std::unique_ptr UnitEmitter::create(bool saveLineTable) { mi->m_firstHoistableFunc = ix; } } else { - assert(!mi->m_firstHoistableFunc); + assertx(!mi->m_firstHoistableFunc); } - assert(ix == fe->id()); + assertx(ix == fe->id()); mi->mergeableObj(ix++) = func; } - assert(u->getMain(nullptr)->isPseudoMain()); + assertx(u->getMain(nullptr)->isPseudoMain()); if (!mi->m_firstHoistableFunc) { mi->m_firstHoistableFunc = ix; } mi->m_firstHoistablePreClass = ix; - assert(m_fes.size()); + assertx(m_fes.size()); for (auto& id : m_hoistablePceIdList) { mi->mergeableObj(ix++) = u->m_preClasses[id].get(); } @@ -627,14 +627,14 @@ std::unique_ptr UnitEmitter::create(bool saveLineTable) { (void*)((intptr_t(mergeable.second) << 3) + (int)mergeable.first); break; case MergeKind::ReqDoc: { - assert(RuntimeOption::RepoAuthoritative); + assertx(RuntimeOption::RepoAuthoritative); void* name = u->lookupLitstrId(mergeable.second); mi->mergeableObj(ix++) = (char*)name + (int)mergeable.first; break; } case MergeKind::Define: case MergeKind::Global: - assert(RuntimeOption::RepoAuthoritative); + assertx(RuntimeOption::RepoAuthoritative); case MergeKind::PersistentDefine: { void* name = u->lookupLitstrId (m_mergeableValues[mergeable.second].first); @@ -645,7 +645,7 @@ std::unique_ptr UnitEmitter::create(bool saveLineTable) { tva->m_type = tv.m_type; // leave tva->m_aux uninitialized ix += sizeof(*tva) / sizeof(void*); - assert(sizeof(*tva) % sizeof(void*) == 0); + assertx(sizeof(*tva) % sizeof(void*) == 0); break; } case MergeKind::Done: @@ -654,7 +654,7 @@ std::unique_ptr UnitEmitter::create(bool saveLineTable) { } } } - assert(ix == mi->m_mergeablesSize); + assertx(ix == mi->m_mergeablesSize); mi->mergeableObj(ix) = (void*)MergeKind::Done; /* @@ -690,7 +690,7 @@ std::unique_ptr UnitEmitter::create(bool saveLineTable) { ux->m_arrayTypeTable = m_arrayTypeTable; for (auto const fe : m_feTab) { - assert(m_fMap.find(fe) != m_fMap.end()); + assertx(m_fMap.find(fe) != m_fMap.end()); auto const func = m_fMap.find(fe)->second; ux->m_funcTable.push_back(func); } @@ -1021,7 +1021,7 @@ void UnitRepoProxy::GetUnitLitstrsStmt Id litstrId; /**/ query.getId(0, litstrId); StringData* litstr; /**/ query.getStaticString(1, litstr); Id id UNUSED = ue.mergeUnitLitstr(litstr); - assert(id == litstrId); + assertx(id == litstrId); } } while (!query.done()); txn.commit(); @@ -1059,12 +1059,12 @@ void UnitRepoProxy::GetUnitArrayTypeTableStmt query.bindInt64("@unitSn", ue.m_sn); query.step(); - assert(query.row()); + assertx(query.row()); BlobDecoder dataBlob = query.getBlob(1); dataBlob(ue.m_arrayTypeTable); dataBlob.assertDone(); query.step(); - assert(query.done()); + assertx(query.done()); txn.commit(); } @@ -1108,7 +1108,7 @@ void UnitRepoProxy::GetUnitArraysStmt VariableUnserializer::Type::Internal ); Id id DEBUG_ONLY = ue.mergeArray(ArrayData::GetScalarArray(std::move(v))); - assert(id == arrayId); + assertx(id == arrayId); } } while (!query.done()); txn.commit(); @@ -1132,12 +1132,12 @@ void UnitRepoProxy::InsertUnitMergeableStmt query.bindInt("@mergeableKind", (int)kind); query.bindId("@mergeableId", id); if (value) { - assert(kind == MergeKind::Define || + assertx(kind == MergeKind::Define || kind == MergeKind::PersistentDefine || kind == MergeKind::Global); query.bindTypedValue("@mergeableValue", *value); } else { - assert(kind == MergeKind::ReqDoc || kind == MergeKind::TypeAlias); + assertx(kind == MergeKind::ReqDoc || kind == MergeKind::TypeAlias); query.bindNull("@mergeableValue"); } query.exec(); diff --git a/hphp/runtime/vm/unit-inl.h b/hphp/runtime/vm/unit-inl.h index 9ac914beab2..a0cc1eb962c 100644 --- a/hphp/runtime/vm/unit-inl.h +++ b/hphp/runtime/vm/unit-inl.h @@ -150,12 +150,12 @@ inline MD5 Unit::md5() const { } inline const StringData* Unit::filepath() const { - assert(m_filepath); + assertx(m_filepath); return m_filepath; } inline const StringData* Unit::dirpath() const { - assert(m_dirpath); + assertx(m_dirpath); return m_dirpath; } @@ -171,12 +171,12 @@ inline Offset Unit::bclen() const { } inline PC Unit::at(Offset off) const { - assert(off >= 0 && off <= Offset(m_bclen)); + assertx(off >= 0 && off <= Offset(m_bclen)); return m_bc + off; } inline Offset Unit::offsetOf(PC pc) const { - assert(contains(pc)); + assertx(contains(pc)); return pc - m_bc; } @@ -185,7 +185,7 @@ inline bool Unit::contains(PC pc) const { } inline Op Unit::getOp(Offset instrOffset) const { - assert(instrOffset < m_bclen); + assertx(instrOffset < m_bclen); return peek_op(m_bc + instrOffset); } @@ -233,7 +233,7 @@ inline size_t Unit::numArrays() const { } inline const ArrayData* Unit::lookupArrayId(Id id) const { - assert(id < m_arrays.size()); + assertx(id < m_arrays.size()); return m_arrays[id]; } @@ -247,12 +247,12 @@ inline const RepoAuthType::Array* Unit::lookupArrayTypeId(Id id) const { // Funcs and PreClasses. inline Func* Unit::lookupFuncId(Id id) const { - assert(id < Id(mergeInfo()->m_firstHoistablePreClass)); + assertx(id < Id(mergeInfo()->m_firstHoistablePreClass)); return mergeInfo()->funcBegin()[id]; } inline PreClass* Unit::lookupPreClassId(Id id) const { - assert(id < Id(m_preClasses.size())); + assertx(id < Id(m_preClasses.size())); return m_preClasses[id].get(); } @@ -350,7 +350,7 @@ inline bool Unit::isEmpty() const { } inline const TypedValue* Unit::getMainReturn() const { - assert(isMergeOnly()); + assertx(isMergeOnly()); return &m_mainReturn; } diff --git a/hphp/runtime/vm/unit-util.h b/hphp/runtime/vm/unit-util.h index 269999eb803..aa289b9f7c7 100644 --- a/hphp/runtime/vm/unit-util.h +++ b/hphp/runtime/vm/unit-util.h @@ -62,7 +62,7 @@ inline bool needsStripInOut(const StringData* name) { */ inline const StringData* normalizeNS(const StringData* name) { if (needsNSNormalization(name)) { - assert(name->size() != 0); + assertx(name->size() != 0); auto const size = static_cast(name->size() - 1); auto const piece = folly::StringPiece{name->data() + 1, size}; return makeStaticString(piece); @@ -79,10 +79,10 @@ inline String normalizeNS(const String& name) { inline const StringData* stripInOutSuffix(const StringData* name) { if (UNLIKELY(needsStripInOut(name))) { - assert(name->size() > sizeof(kInOutSuffix)); + assertx(name->size() > sizeof(kInOutSuffix)); auto const s = name->data(); size_t len = name->size() - sizeof(kInOutSuffix); - for (; s[len] != '$'; --len) assert(len != 0); + for (; s[len] != '$'; --len) assertx(len != 0); return makeStaticString(folly::StringPiece(name->data(), len)); } return name; diff --git a/hphp/runtime/vm/unit.cpp b/hphp/runtime/vm/unit.cpp index 5b54a23591a..41e1c1f485b 100644 --- a/hphp/runtime/vm/unit.cpp +++ b/hphp/runtime/vm/unit.cpp @@ -467,7 +467,7 @@ int getLineNumber(const LineTable& table, Offset pc) { auto const key = LineEntry(pc, -1); auto it = std::upper_bound(begin(table), end(table), key); if (it != end(table)) { - assert(pc < it->pastOffset()); + assertx(pc < it->pastOffset()); return it->val(); } return -1; @@ -536,7 +536,7 @@ bool getSourceLoc(const SourceLocTable& table, Offset pc, SourceLoc& sLoc) { SourceLocEntry key(pc, sLoc); auto it = std::upper_bound(table.begin(), table.end(), key); if (it != table.end()) { - assert(pc < it->pastOffset()); + assertx(pc < it->pastOffset()); sLoc = it->val(); return true; } @@ -563,7 +563,7 @@ bool Unit::getOffsetRange(Offset pc, OffsetRange& range) const { } bool Unit::getOffsetRanges(int line, OffsetRangeVec& offsets) const { - assert(offsets.size() == 0); + assertx(offsets.size() == 0); auto map = getLineToOffsetRangeVecMap(this); auto it = map.find(line); if (it == map.end()) return false; @@ -585,7 +585,7 @@ const Func* Unit::getFunc(Offset pc) const { return pc < b->past(); }); if (it != table.end()) { - assert(pc < (*it)->past()); + assertx(pc < (*it)->past()); return *it; } return nullptr; @@ -631,12 +631,12 @@ void Unit::renameFunc(const StringData* oldName, const StringData* newName) { // func with a given name; in practice this is okay because the units created // by create_function() will always have the function being renamed at the // beginning - assert(oldName && oldName->isStatic()); - assert(newName && newName->isStatic()); + assertx(oldName && oldName->isStatic()); + assertx(newName && newName->isStatic()); for (auto& func : mergeInfo()->hoistableFuncs()) { auto const name = func->name(); - assert(name); + assertx(name); if (name->same(oldName)) { func->rename(newName); break; @@ -649,7 +649,7 @@ void Unit::renameFunc(const StringData* oldName, const StringData* newName) { // Func lookup. void Unit::defFunc(Func* func, bool debugger) { - assert(!func->isMethod()); + assertx(!func->isMethod()); auto const handle = func->funcHandle(); auto& funcAddr = rds::handleToRef>(handle); @@ -715,7 +715,7 @@ Func* Unit::loadFunc(const StringData* name) { } void Unit::bindFunc(Func *func) { - assert(!func->isMethod()); + assertx(!func->isMethod()); auto const ne = func->getNamedEntity(); ne->m_cachedFunc.bind( [&] { @@ -893,7 +893,7 @@ Class* Unit::defClass(const PreClass* preClass, } return nullptr; } - assert(avail == Class::Avail::False); + assertx(avail == Class::Avail::False); } // Create a new class. @@ -1052,7 +1052,7 @@ const Cell* Unit::lookupCns(const StringData* cnsName) { auto const callback = reinterpret_cast(tv.m_data.pref); const Cell* tvRet = callback().asTypedValue(); - assert(cellIsPlausible(*tvRet)); + assertx(cellIsPlausible(*tvRet)); if (LIKELY(tvRet->m_type != KindOfUninit)) { return tvRet; } @@ -1070,7 +1070,7 @@ const Cell* Unit::lookupPersistentCns(const StringData* cnsName) { return nullptr; } auto const ret = &rds::handleToRef(handle); - assert(cellIsPlausible(*ret)); + assertx(cellIsPlausible(*ret)); return ret; } @@ -1261,7 +1261,7 @@ const TypeAliasReq* Unit::loadTypeAlias(const StringData* name, } bool Unit::defTypeAlias(Id id) { - assert(id < m_typeAliases.size()); + assertx(id < m_typeAliases.size()); auto thisType = &m_typeAliases[id]; auto nameList = NamedEntity::get(thisType->name); const StringData* typeName = thisType->value; @@ -1521,12 +1521,12 @@ static size_t compactMergeInfo(Unit::MergeInfo* in, Unit::MergeInfo* out, end = in->m_firstMergeablePreClass; for (; ix < end; ++ix) { void* obj = in->mergeableObj(ix); - assert((uintptr_t(obj) & 1) == 0); + assertx((uintptr_t(obj) & 1) == 0); PreClass* pre = (PreClass*)obj; if (pre->attrs() & AttrUnique) { Class* cls = pre->namedEntity()->clsList(); - assert(cls && !cls->m_nextClass); - assert(cls->preClass() == pre); + assertx(cls && !cls->m_nextClass); + assertx(cls->preClass() == pre); if (rds::isPersistentHandle(cls->classHandle())) { delta++; } else if (out) { @@ -1550,8 +1550,8 @@ static size_t compactMergeInfo(Unit::MergeInfo* in, Unit::MergeInfo* out, PreClass* pre = (PreClass*)obj; if (pre->attrs() & AttrUnique) { Class* cls = pre->namedEntity()->clsList(); - assert(cls && !cls->m_nextClass); - assert(cls->preClass() == pre); + assertx(cls && !cls->m_nextClass); + assertx(cls->preClass() == pre); if (rds::isPersistentHandle(cls->classHandle())) { delta++; } else if (out) { @@ -1625,7 +1625,7 @@ static size_t compactMergeInfo(Unit::MergeInfo* in, Unit::MergeInfo* out, template void Unit::mergeImpl(void* tcbase, MergeInfo* mi) { - assert(m_mergeState.load(std::memory_order_relaxed) & MergeState::Merged); + assertx(m_mergeState.load(std::memory_order_relaxed) & MergeState::Merged); autoTypecheck(this); @@ -1770,7 +1770,7 @@ void Unit::mergeImpl(void* tcbase, MergeInfo* mi) { if (UNLIKELY(avail == Class::Avail::Fail)) { raise_error("unknown class %s", other->name()->data()); } - assert(avail == Class::Avail::True); + assertx(avail == Class::Avail::True); auto const handle = cls->classHandle(); getDataRef>(tcbase, handle) = cls; if (rds::isNormalHandle(handle)) rds::initHandle(handle); @@ -1804,7 +1804,7 @@ void Unit::mergeImpl(void* tcbase, MergeInfo* mi) { auto const name = (StringData*)((char*)obj - (int)k); auto const v = (TypedValueAux*)mi->mergeableData(ix + 1); - assert(v->m_type != KindOfUninit); + assertx(v->m_type != KindOfUninit); auto const handle = v->rdsHandle(); assertx(rds::isNormalHandle(handle)); @@ -1884,7 +1884,7 @@ void Unit::mergeImpl(void* tcbase, MergeInfo* mi) { } while (k == MergeKind::TypeAlias); continue; case MergeKind::Done: - assert((unsigned)ix == mi->m_mergeablesSize); + assertx((unsigned)ix == mi->m_mergeablesSize); if (UNLIKELY(m_mergeState.load(std::memory_order_relaxed) & MergeState::NeedsCompact)) { SimpleLock lock(unitInitLock); @@ -1925,7 +1925,8 @@ void Unit::mergeImpl(void* tcbase, MergeInfo* mi) { std::memory_order_relaxed); } } - assert(newMi->m_firstMergeablePreClass == newMi->m_mergeablesSize || + assertx(newMi->m_firstMergeablePreClass + == newMi->m_mergeablesSize || isMergeOnly()); } m_mergeState.fetch_and(~MergeState::NeedsCompact, @@ -2022,7 +2023,7 @@ void Unit::prettyPrint(std::ostream& out, PrintOpts opts) const { int prevLineNum = -1; while (it < &m_bc[stopOffset]) { if (opts.showFuncs) { - assert(funcIt == funcMap.end() || funcIt->first >= offsetOf(it)); + assertx(funcIt == funcMap.end() || funcIt->first >= offsetOf(it)); if (funcIt != funcMap.end() && funcIt->first == offsetOf(it)) { out.put('\n'); diff --git a/hphp/runtime/vm/unwind-inl.h b/hphp/runtime/vm/unwind-inl.h index 5a709a0fe98..026a9558bcb 100644 --- a/hphp/runtime/vm/unwind-inl.h +++ b/hphp/runtime/vm/unwind-inl.h @@ -57,7 +57,7 @@ inline void exception_handler(Action action) { return; } - assert(!vmpc()); + assertx(!vmpc()); // o will be destroyed at the end of the catch block // so we have to make sure the vm state is valid in // case a __destruct method needs to run. @@ -106,7 +106,7 @@ inline void exception_handler(Action action) { vmpc() = outer->func()->unit()->at(fe->m_fpiEndOff); assertx(isFCallStar(peek_op(vmpc()))); vmfp() = outer; - assert(vmsp() == reinterpret_cast(fp) - fp->numArgs()); + assertx(vmsp() == reinterpret_cast(fp) - fp->numArgs()); } else { vmsp() = reinterpret_cast(fp + 1); } diff --git a/hphp/runtime/vm/unwind.cpp b/hphp/runtime/vm/unwind.cpp index c78fed61212..17a92d215eb 100644 --- a/hphp/runtime/vm/unwind.cpp +++ b/hphp/runtime/vm/unwind.cpp @@ -81,11 +81,11 @@ void discardStackTemps(const ActRec* const fp, visitStackElems( fp, stack.top(), bcOffset, [&] (ActRec* ar, Offset pushOff) { - assert(ar == reinterpret_cast(stack.top())); + assertx(ar == reinterpret_cast(stack.top())); // ar is a pre-live ActRec in fp's scope, and pushOff // is the offset of the corresponding FPush* opcode. if (isFPushCtor(fp->func()->unit()->getOp(pushOff))) { - assert(ar->hasThis()); + assertx(ar->hasThis()); ar->getThis()->setNoDestruct(); } ITRACE(2, " unwind pop AR : {}\n", @@ -93,7 +93,7 @@ void discardStackTemps(const ActRec* const fp, stack.popAR(); }, [&] (TypedValue* tv) { - assert(tv == stack.top()); + assertx(tv == stack.top()); ITRACE(2, " unwind pop TV : {}\n", implicit_cast(stack.top())); stack.popTV(); @@ -257,7 +257,7 @@ ObjectData* tearDownFrame(ActRec*& fp, Stack& stack, PC& pc, phpException = nullptr; stack.ndiscard(func->numSlotsInFrame()); stack.ret(); - assert(stack.topTV() == fp->retSlot()); + assertx(stack.topTV() == fp->retSlot()); cellCopy(make_tv(waitHandle), *fp->retSlot()); } else { // Free ActRec. @@ -313,7 +313,7 @@ ObjectData* tearDownFrame(ActRec*& fp, Stack& stack, PC& pc, return phpException; } - assert(stack.isValidAddress(reinterpret_cast(prevFp)) || + assertx(stack.isValidAddress(reinterpret_cast(prevFp)) || prevFp->resumed()); auto const prevOff = soff + prevFp->func()->base(); pc = prevFp->func()->unit()->at(prevOff); @@ -362,7 +362,7 @@ void chainFaultObjects(ObjectData* top, ObjectData* prev) { } foundLval = head->propLvalAtOffset(s_previousIdx); - assert(foundLval.type() != KindOfUninit); + assertx(foundLval.type() != KindOfUninit); head = foundLval.val().pobj; } while (foundLval.type() == KindOfObject && foundLval.val().pobj->instanceof(SystemLib::s_ThrowableClass)); @@ -433,7 +433,7 @@ const StaticString s_xdebug_start_code_coverage("xdebug_start_code_coverage"); * reallocate due to nested exception handling. */ void unwindPhp() { - assert(!g_context->m_faults.empty()); + assertx(!g_context->m_faults.empty()); auto& fp = vmfp(); auto& stack = vmStack(); auto& pc = vmpc(); @@ -474,9 +474,9 @@ void unwindPhp() { fault.m_raiseOffset, implicit_cast(fp)); - assert(fault.m_raiseNesting != kInvalidNesting); - assert(fault.m_raiseFrame != nullptr); - assert(fault.m_raiseOffset != kInvalidOffset); + assertx(fault.m_raiseNesting != kInvalidNesting); + assertx(fault.m_raiseFrame != nullptr); + assertx(fault.m_raiseOffset != kInvalidOffset); /* * If the handledCount is non-zero, we've already seen this fault once @@ -578,12 +578,12 @@ void unwindCpp(Exception* exception) { auto& stack = vmStack(); auto& pc = vmpc(); - assert(!g_context->m_unwindingCppException); + assertx(!g_context->m_unwindingCppException); g_context->m_unwindingCppException = true; ITRACE(1, "entering unwinder for C++ exception: {}\n", implicit_cast(exception)); SCOPE_EXIT { - assert(g_context->m_unwindingCppException); + assertx(g_context->m_unwindingCppException); g_context->m_unwindingCppException = false; ITRACE(1, "leaving unwinder for C++ exception: {}\n", implicit_cast(exception)); @@ -613,7 +613,7 @@ void unwindCpp(Exception* exception) { // Discard the frame DEBUG_ONLY auto const phpException = tearDownFrame(fp, stack, pc, nullptr); - assert(phpException == nullptr); + assertx(phpException == nullptr); } while (fp); // Propagate the C++ exception to the outer VM nesting @@ -624,7 +624,7 @@ void unwindBuiltinFrame() { auto& stack = vmStack(); auto& fp = vmfp(); - assert(fp->m_func->name()->isame(s_hphpd_break.get()) || + assertx(fp->m_func->name()->isame(s_hphpd_break.get()) || fp->m_func->name()->isame(s_fb_enable_code_coverage.get()) || fp->m_func->name()->isame(s_xdebug_start_code_coverage.get())); @@ -644,7 +644,7 @@ void unwindBuiltinFrame() { // Tear down the frame Offset pc = -1; ActRec* sfp = g_context->getPrevVMState(fp, &pc); - assert(pc != -1); + assertx(pc != -1); fp = sfp; vmpc() = fp->m_func->unit()->at(pc); stack.ndiscard(numSlots); diff --git a/hphp/runtime/vm/verifier/cfg.cpp b/hphp/runtime/vm/verifier/cfg.cpp index 609e27faade..d595d6cbcbd 100644 --- a/hphp/runtime/vm/verifier/cfg.cpp +++ b/hphp/runtime/vm/verifier/cfg.cpp @@ -25,7 +25,7 @@ namespace Verifier { * Create all blocks and edges for one Func. */ Graph* GraphBuilder::build() { - assert(!funcInstrs(m_func).empty()); + assertx(!funcInstrs(m_func).empty()); m_graph = new (m_arena) Graph(); createBlocks(); createExBlocks(); @@ -50,7 +50,7 @@ void GraphBuilder::createBlocks() { createBlock(param.funcletOff); } // main entry point - assert(dv_index == m_graph->param_count); + assertx(dv_index == m_graph->param_count); m_graph->entries[dv_index] = createBlock(m_func->base()); // ordinary basic block boundaries for (InstrRange i = funcInstrs(m_func); !i.empty(); ) { @@ -85,7 +85,7 @@ void GraphBuilder::linkBlocks() { } else { Offset target = instrJumpTarget(bc, pc - bc); if (target != InvalidAbsoluteOffset) { - assert(numSuccBlocks(block) > 0); + assertx(numSuccBlocks(block) > 0); succs(block)[numSuccBlocks(block) - 1] = at(target); } } @@ -103,7 +103,7 @@ void GraphBuilder::linkBlocks() { block->next_linear = next; block->end = next_pc; if (!isTF(pc)) { - assert(numSuccBlocks(block) > 0); + assertx(numSuccBlocks(block) > 0); succs(block)[0] = next; } block = next; @@ -153,11 +153,12 @@ void GraphBuilder::linkExBlocks() { // For every block, add edges to reachable fault and catch handlers. for (LinearBlocks i = linearBlocks(m_graph); !i.empty(); ) { Block* b = i.popFront(); - assert(m_func->findEH(offset(b->start)) == m_func->findEH(offset(b->last))); + assertx(m_func->findEH(offset(b->start)) == + m_func->findEH(offset(b->last))); Offset off = offset(b->start); const EHEnt* eh = m_func->findEH(off); if (eh != nullptr) { - assert(eh->m_base <= off && off < eh->m_past); + assertx(eh->m_base <= off && off < eh->m_past); // the innermost exception handler is reachable from b b->exn = at(eh->m_handler); } diff --git a/hphp/runtime/vm/verifier/cfg.h b/hphp/runtime/vm/verifier/cfg.h index 7e675790784..dfc2bd02069 100644 --- a/hphp/runtime/vm/verifier/cfg.h +++ b/hphp/runtime/vm/verifier/cfg.h @@ -179,7 +179,7 @@ struct LinearBlocks { LinearBlocks(Block* first, Block* end) : b(first), end(end) { } bool empty() const { return b == end; } - Block* front() const { assert(!empty()); return b; } + Block* front() const { assertx(!empty()); return b; } Block* popFront() { Block* f = front(); b = b->next_linear; return f; } private: Block *b; // The current block. @@ -195,8 +195,8 @@ struct BlockPtrRange { trimBack(); } bool empty() const { return i >= end; } - Block* front() const { assert(!empty()); return i[0]; } - Block* back() const { assert(!empty()); return end[-1]; } + Block* front() const { assertx(!empty()); return i[0]; } + Block* back() const { assertx(!empty()); return end[-1]; } Block* popFront() { Block* b = front(); ++i; trimFront(); @@ -225,7 +225,7 @@ struct InstrRange { return pc >= end; } PC front() const { - assert(!empty()); + assertx(!empty()); return pc; } PC popFront() { diff --git a/hphp/runtime/vm/verifier/check-func.cpp b/hphp/runtime/vm/verifier/check-func.cpp index 6fe1fda0dec..166b5e3e73c 100644 --- a/hphp/runtime/vm/verifier/check-func.cpp +++ b/hphp/runtime/vm/verifier/check-func.cpp @@ -257,7 +257,7 @@ using SectionMap = std::map; * ensure that off is at least within the entire func's bytecode region. */ Offset findSection(SectionMap& sections, Offset off) { - assert(!sections.empty()); + assertx(!sections.empty()); SectionMap::iterator i = sections.upper_bound(off); --i; return i->first; @@ -270,7 +270,7 @@ Offset findSection(SectionMap& sections, Offset off) { */ bool FuncChecker::checkOffsets() { bool ok = true; - assert(unit()->bclen() >= 0); + assertx(unit()->bclen() >= 0); PC bc = unit()->entry(); Offset base = m_func->base(); Offset past = m_func->past(); @@ -575,7 +575,7 @@ bool FuncChecker::checkImmRATA(PC& pc, PC const /*instr*/) { bool FuncChecker::checkImmBA(PC& pc, PC const instr) { // we check branch offsets in checkSection(). ignore here. - assert(instrJumpTarget(unit()->entry(), offset(instr)) != + assertx(instrJumpTarget(unit()->entry(), offset(instr)) != InvalidAbsoluteOffset); pc += sizeof(Offset); return true; @@ -1050,7 +1050,7 @@ bool FuncChecker::checkFpi(State* cur, PC pc, Block* /*b*/) { // it must not already be initialized; for *IterNext and *IterFree, it must // be initialized. bool FuncChecker::checkIter(State* cur, PC const pc) { - assert(isIter(pc)); + assertx(isIter(pc)); int id = getImmIva(pc); bool ok = true; auto op = peek_op(pc); @@ -1656,7 +1656,7 @@ void FuncChecker::initState(State* s) { } void FuncChecker::copyState(State* to, const State* from) { - assert(from->stk); + assertx(from->stk); if (!to->stk) initState(to); memcpy(to->stk, from->stk, from->stklen * sizeof(*to->stk)); memcpy(to->fpi, from->fpi, from->fpilen * sizeof(*to->fpi)); @@ -1959,7 +1959,7 @@ void FuncChecker::reportEscapeEdge(Block* b, Block* s) { bool FuncChecker::checkOffset(const char* name, Offset off, const char* regionName, Offset base, Offset past, bool check_instrs) { - assert(past >= base); + assertx(past >= base); if (off < base || off >= past) { error("Offset %s %d is outside region %s %d:%d\n", name, off, regionName, base, past); @@ -1980,7 +1980,7 @@ bool FuncChecker::checkOffset(const char* name, Offset off, bool FuncChecker::checkRegion(const char* name, Offset b, Offset p, const char* regionName, Offset base, Offset past, bool check_instrs) { - assert(past >= base); + assertx(past >= base); if (p < b) { error("region %s %d:%d has negative length\n", name, b, p); diff --git a/hphp/runtime/vm/vm-regs.cpp b/hphp/runtime/vm/vm-regs.cpp index 7b79531b791..a259eb782ad 100644 --- a/hphp/runtime/vm/vm-regs.cpp +++ b/hphp/runtime/vm/vm-regs.cpp @@ -35,15 +35,15 @@ VMRegAnchor::VMRegAnchor() VMRegAnchor::VMRegAnchor(ActRec* ar) : m_old(tl_regState) { - assert(tl_regState == VMRegState::DIRTY); + assertx(tl_regState == VMRegState::DIRTY); tl_regState = VMRegState::CLEAN; auto prevAr = g_context->getOuterVMFrame(ar); const Func* prevF = prevAr->m_func; - assert(!ar->resumed()); + assertx(!ar->resumed()); auto& regs = vmRegs(); regs.stack.top() = (TypedValue*)ar - ar->numArgs(); - assert(vmStack().isValidAddress((uintptr_t)vmsp())); + assertx(vmStack().isValidAddress((uintptr_t)vmsp())); regs.pc = prevF->unit()->at(prevF->base() + ar->m_soff); regs.fp = prevAr; } diff --git a/hphp/runtime/vm/vm-regs.h b/hphp/runtime/vm/vm-regs.h index f3bd2bf2926..cdd304dfeb9 100644 --- a/hphp/runtime/vm/vm-regs.h +++ b/hphp/runtime/vm/vm-regs.h @@ -70,11 +70,11 @@ enum VMRegState : uintptr_t { extern __thread VMRegState tl_regState; inline void checkVMRegState() { - assert(tl_regState == VMRegState::CLEAN); + assertx(tl_regState == VMRegState::CLEAN); } inline void checkVMRegStateGuarded() { - assert(tl_regState != VMRegState::DIRTY); + assertx(tl_regState != VMRegState::DIRTY); } inline VMRegs& vmRegsUnsafe() { @@ -126,12 +126,12 @@ inline ActRec*& vmJitCalledFrame() { inline void assert_native_stack_aligned() { #ifndef _MSC_VER - assert(reinterpret_cast(__builtin_frame_address(0)) % 16 == 0); + assertx(reinterpret_cast(__builtin_frame_address(0)) % 16 == 0); #endif } inline void interp_set_regs(ActRec* ar, Cell* sp, Offset pcOff) { - assert(tl_regState == VMRegState::DIRTY); + assertx(tl_regState == VMRegState::DIRTY); tl_regState = VMRegState::CLEAN; vmfp() = ar; vmsp() = sp; @@ -197,11 +197,11 @@ struct EagerVMRegAnchor { DEBUG_ONLY auto const sp = regs.stack.top(); DEBUG_ONLY auto const pc = regs.pc; VMRegAnchor _; - assert(regs.fp == fp); - assert(regs.stack.top() == sp); - assert(regs.pc == pc); + assertx(regs.fp == fp); + assertx(regs.stack.top() == sp); + assertx(regs.pc == pc); } - assert(tl_regState < VMRegState::GUARDED_THRESHOLD); + assertx(tl_regState < VMRegState::GUARDED_THRESHOLD); m_old = tl_regState; tl_regState = VMRegState::CLEAN; } -- 2.11.4.GIT