@triniwiz/nativescript-masonkit 1.0.0-alpha.5 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/common.d.ts +7 -9
  2. package/common.js +277 -552
  3. package/common.js.map +1 -1
  4. package/helpers.d.ts +32 -10
  5. package/helpers.js +772 -286
  6. package/helpers.js.map +1 -1
  7. package/index.android.d.ts +6 -2
  8. package/index.android.js +21 -3
  9. package/index.android.js.map +1 -1
  10. package/index.d.ts +64 -7
  11. package/index.ios.d.ts +9 -6
  12. package/index.ios.js +39 -25
  13. package/index.ios.js.map +1 -1
  14. package/package.json +1 -1
  15. package/platforms/android/include.gradle +18 -1
  16. package/platforms/android/masonkit-release.aar +0 -0
  17. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/Mason-Swift.h +108 -64
  18. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/mason_native.h +47 -20
  19. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Info.plist +0 -0
  20. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
  21. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  22. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +7002 -1194
  23. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.private.swiftinterface +58 -21
  24. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  25. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftinterface +58 -21
  26. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  27. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/Mason-Swift.h +216 -128
  28. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/mason_native.h +47 -20
  29. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Info.plist +0 -0
  30. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  31. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  32. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  33. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +7002 -1194
  34. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +58 -21
  35. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  36. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftinterface +58 -21
  37. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +7002 -1194
  38. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +58 -21
  39. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  40. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +58 -21
  41. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +43 -43
  42. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  43. package/platforms/ios/build.xcconfig +1 -2
  44. package/platforms/ios/src/MasonV8Module.h +583 -0
  45. package/platforms/ios/src/MasonV8Module.mm +1005 -0
  46. package/platforms/ios/src/{include → cpp/include}/mason_native.h +47 -20
  47. package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
  48. package/platforms/ios/src/module.modulemap +2 -2
  49. package/platforms/new_native_src/cpp/Caches.cpp +36 -0
  50. package/platforms/new_native_src/cpp/Caches.h +42 -0
  51. package/platforms/new_native_src/cpp/Common.h +34 -0
  52. package/platforms/new_native_src/cpp/ConcurrentMap.h +57 -0
  53. package/platforms/new_native_src/cpp/Helpers.cpp +101 -0
  54. package/platforms/new_native_src/cpp/Helpers.h +364 -0
  55. package/platforms/new_native_src/cpp/MasonImpl.cpp +68 -0
  56. package/platforms/new_native_src/cpp/MasonImpl.h +40 -0
  57. package/platforms/new_native_src/cpp/MasonNodeImpl.cpp +89 -0
  58. package/platforms/new_native_src/cpp/MasonNodeImpl.h +47 -0
  59. package/platforms/new_native_src/cpp/MasonStyleImpl.cpp +2181 -0
  60. package/platforms/new_native_src/cpp/MasonStyleImpl.h +420 -0
  61. package/platforms/{ios/Mason.xcframework/ios-arm64/Mason.framework/PrivateHeaders → new_native_src/cpp/include}/mason_native.h +464 -168
  62. package/platforms/new_native_src/cpp/include/robin_hood.h +2544 -0
  63. package/pods/Headers/include/APIDesign.md +72 -0
  64. package/pods/Headers/include/DEPS +10 -0
  65. package/pods/Headers/include/DIR_METADATA +11 -0
  66. package/pods/Headers/include/OWNERS +23 -0
  67. package/pods/Headers/include/cppgc/DEPS +8 -0
  68. package/pods/Headers/include/cppgc/OWNERS +2 -0
  69. package/pods/Headers/include/cppgc/README.md +133 -0
  70. package/pods/Headers/include/cppgc/allocation.h +310 -0
  71. package/pods/Headers/include/cppgc/common.h +29 -0
  72. package/pods/Headers/include/cppgc/cross-thread-persistent.h +465 -0
  73. package/pods/Headers/include/cppgc/custom-space.h +97 -0
  74. package/pods/Headers/include/cppgc/default-platform.h +67 -0
  75. package/pods/Headers/include/cppgc/ephemeron-pair.h +30 -0
  76. package/pods/Headers/include/cppgc/explicit-management.h +100 -0
  77. package/pods/Headers/include/cppgc/garbage-collected.h +106 -0
  78. package/pods/Headers/include/cppgc/heap-consistency.h +266 -0
  79. package/pods/Headers/include/cppgc/heap-state.h +82 -0
  80. package/pods/Headers/include/cppgc/heap-statistics.h +120 -0
  81. package/pods/Headers/include/cppgc/heap.h +206 -0
  82. package/pods/Headers/include/cppgc/internal/api-constants.h +55 -0
  83. package/pods/Headers/include/cppgc/internal/atomic-entry-flag.h +48 -0
  84. package/pods/Headers/include/cppgc/internal/caged-heap-local-data.h +79 -0
  85. package/pods/Headers/include/cppgc/internal/compiler-specific.h +38 -0
  86. package/pods/Headers/include/cppgc/internal/finalizer-trait.h +93 -0
  87. package/pods/Headers/include/cppgc/internal/gc-info.h +156 -0
  88. package/pods/Headers/include/cppgc/internal/logging.h +50 -0
  89. package/pods/Headers/include/cppgc/internal/name-trait.h +122 -0
  90. package/pods/Headers/include/cppgc/internal/persistent-node.h +216 -0
  91. package/pods/Headers/include/cppgc/internal/pointer-policies.h +186 -0
  92. package/pods/Headers/include/cppgc/internal/write-barrier.h +435 -0
  93. package/pods/Headers/include/cppgc/liveness-broker.h +77 -0
  94. package/pods/Headers/include/cppgc/macros.h +26 -0
  95. package/pods/Headers/include/cppgc/member.h +291 -0
  96. package/pods/Headers/include/cppgc/name-provider.h +65 -0
  97. package/pods/Headers/include/cppgc/object-size-trait.h +58 -0
  98. package/pods/Headers/include/cppgc/persistent.h +370 -0
  99. package/pods/Headers/include/cppgc/platform.h +156 -0
  100. package/pods/Headers/include/cppgc/prefinalizer.h +75 -0
  101. package/pods/Headers/include/cppgc/process-heap-statistics.h +36 -0
  102. package/pods/Headers/include/cppgc/sentinel-pointer.h +32 -0
  103. package/pods/Headers/include/cppgc/source-location.h +92 -0
  104. package/pods/Headers/include/cppgc/testing.h +106 -0
  105. package/pods/Headers/include/cppgc/trace-trait.h +116 -0
  106. package/pods/Headers/include/cppgc/type-traits.h +240 -0
  107. package/pods/Headers/include/cppgc/visitor.h +379 -0
  108. package/pods/Headers/include/js_protocol-1.2.json +936 -0
  109. package/pods/Headers/include/js_protocol-1.3.json +1112 -0
  110. package/pods/Headers/include/js_protocol.pdl +1709 -0
  111. package/pods/Headers/include/libffi/arm64/ffi.h +524 -0
  112. package/pods/Headers/include/libffi/arm64/ffitarget.h +92 -0
  113. package/pods/Headers/include/libffi/x86_64/ffi.h +524 -0
  114. package/pods/Headers/include/libffi/x86_64/ffitarget.h +147 -0
  115. package/pods/Headers/include/libffi.h +12 -0
  116. package/pods/Headers/include/libplatform/DEPS +9 -0
  117. package/pods/Headers/include/libplatform/libplatform-export.h +29 -0
  118. package/pods/Headers/include/libplatform/libplatform.h +106 -0
  119. package/pods/Headers/include/libplatform/v8-tracing.h +333 -0
  120. package/pods/Headers/include/v8-array-buffer.h +433 -0
  121. package/pods/Headers/include/v8-callbacks.h +397 -0
  122. package/pods/Headers/include/v8-container.h +129 -0
  123. package/pods/Headers/include/v8-context.h +407 -0
  124. package/pods/Headers/include/v8-cppgc.h +215 -0
  125. package/pods/Headers/include/v8-data.h +80 -0
  126. package/pods/Headers/include/v8-date.h +43 -0
  127. package/pods/Headers/include/v8-debug.h +168 -0
  128. package/pods/Headers/include/v8-embedder-heap.h +218 -0
  129. package/pods/Headers/include/v8-embedder-state-scope.h +51 -0
  130. package/pods/Headers/include/v8-exception.h +217 -0
  131. package/pods/Headers/include/v8-extension.h +62 -0
  132. package/pods/Headers/include/v8-external.h +37 -0
  133. package/pods/Headers/include/v8-fast-api-calls.h +939 -0
  134. package/pods/Headers/include/v8-forward.h +81 -0
  135. package/pods/Headers/include/v8-function-callback.h +475 -0
  136. package/pods/Headers/include/v8-function.h +125 -0
  137. package/pods/Headers/include/v8-initialization.h +315 -0
  138. package/pods/Headers/include/v8-inspector-protocol.h +13 -0
  139. package/pods/Headers/include/v8-inspector.h +376 -0
  140. package/pods/Headers/include/v8-internal.h +661 -0
  141. package/pods/Headers/include/v8-isolate.h +1709 -0
  142. package/pods/Headers/include/v8-json.h +47 -0
  143. package/pods/Headers/include/v8-local-handle.h +455 -0
  144. package/pods/Headers/include/v8-locker.h +149 -0
  145. package/pods/Headers/include/v8-maybe.h +137 -0
  146. package/pods/Headers/include/v8-memory-span.h +43 -0
  147. package/pods/Headers/include/v8-message.h +216 -0
  148. package/pods/Headers/include/v8-metrics.h +255 -0
  149. package/pods/Headers/include/v8-microtask-queue.h +152 -0
  150. package/pods/Headers/include/v8-microtask.h +28 -0
  151. package/pods/Headers/include/v8-object.h +775 -0
  152. package/pods/Headers/include/v8-persistent-handle.h +590 -0
  153. package/pods/Headers/include/v8-platform.h +1092 -0
  154. package/pods/Headers/include/v8-primitive-object.h +118 -0
  155. package/pods/Headers/include/v8-primitive.h +866 -0
  156. package/pods/Headers/include/v8-profiler.h +1198 -0
  157. package/pods/Headers/include/v8-promise.h +174 -0
  158. package/pods/Headers/include/v8-proxy.h +50 -0
  159. package/pods/Headers/include/v8-regexp.h +105 -0
  160. package/pods/Headers/include/v8-script.h +748 -0
  161. package/pods/Headers/include/v8-snapshot.h +196 -0
  162. package/pods/Headers/include/v8-statistics.h +217 -0
  163. package/pods/Headers/include/v8-template.h +1079 -0
  164. package/pods/Headers/include/v8-traced-handle.h +420 -0
  165. package/pods/Headers/include/v8-typed-array.h +282 -0
  166. package/pods/Headers/include/v8-unwinder-state.h +31 -0
  167. package/pods/Headers/include/v8-unwinder.h +132 -0
  168. package/pods/Headers/include/v8-util.h +658 -0
  169. package/pods/Headers/include/v8-value-serializer-version.h +24 -0
  170. package/pods/Headers/include/v8-value-serializer.h +279 -0
  171. package/pods/Headers/include/v8-value.h +526 -0
  172. package/pods/Headers/include/v8-version-string.h +38 -0
  173. package/pods/Headers/include/v8-version.h +20 -0
  174. package/pods/Headers/include/v8-wasm-trap-handler-posix.h +31 -0
  175. package/pods/Headers/include/v8-wasm-trap-handler-win.h +28 -0
  176. package/pods/Headers/include/v8-wasm.h +257 -0
  177. package/pods/Headers/include/v8-weak-callback-info.h +86 -0
  178. package/pods/Headers/include/v8.h +88 -0
  179. package/pods/Headers/include/v8config.h +605 -0
  180. package/pods/Headers/inspector/InspectorServer.h +20 -0
  181. package/pods/Headers/inspector/JsV8InspectorClient.h +66 -0
  182. package/pods/Headers/inspector/base/trace_event/common/trace_event_common.h +1123 -0
  183. package/pods/Headers/inspector/base64.h +9 -0
  184. package/pods/Headers/inspector/src/base/address-region.h +95 -0
  185. package/pods/Headers/inspector/src/base/atomic-utils.h +219 -0
  186. package/pods/Headers/inspector/src/base/atomicops.h +332 -0
  187. package/pods/Headers/inspector/src/base/atomicops_internals_atomicword_compat.h +89 -0
  188. package/pods/Headers/inspector/src/base/base-export.h +31 -0
  189. package/pods/Headers/inspector/src/base/bits.h +343 -0
  190. package/pods/Headers/inspector/src/base/build_config.h +234 -0
  191. package/pods/Headers/inspector/src/base/compiler-specific.h +136 -0
  192. package/pods/Headers/inspector/src/base/export-template.h +163 -0
  193. package/pods/Headers/inspector/src/base/flags.h +130 -0
  194. package/pods/Headers/inspector/src/base/immediate-crash.h +162 -0
  195. package/pods/Headers/inspector/src/base/lazy-instance.h +258 -0
  196. package/pods/Headers/inspector/src/base/logging.h +417 -0
  197. package/pods/Headers/inspector/src/base/macros.h +423 -0
  198. package/pods/Headers/inspector/src/base/memory.h +89 -0
  199. package/pods/Headers/inspector/src/base/once.h +108 -0
  200. package/pods/Headers/inspector/src/base/optional.h +882 -0
  201. package/pods/Headers/inspector/src/base/platform/mutex.h +370 -0
  202. package/pods/Headers/inspector/src/base/platform/platform.h +476 -0
  203. package/pods/Headers/inspector/src/base/platform/semaphore.h +108 -0
  204. package/pods/Headers/inspector/src/base/platform/v8-time.h +513 -0
  205. package/pods/Headers/inspector/src/base/platform/wrappers.h +73 -0
  206. package/pods/Headers/inspector/src/base/safe_conversions.h +389 -0
  207. package/pods/Headers/inspector/src/base/safe_conversions_impl.h +822 -0
  208. package/pods/Headers/inspector/src/base/template-utils.h +113 -0
  209. package/pods/Headers/inspector/src/base/v8-fallthrough.h +21 -0
  210. package/pods/Headers/inspector/src/common/checks.h +38 -0
  211. package/pods/Headers/inspector/src/common/globals.h +1842 -0
  212. package/pods/Headers/inspector/src/debug/debug-interface.h +667 -0
  213. package/pods/Headers/inspector/src/debug/interface-types.h +175 -0
  214. package/pods/Headers/inspector/src/init/v8.h +52 -0
  215. package/pods/Headers/inspector/src/inspector/custom-preview.h +24 -0
  216. package/pods/Headers/inspector/src/inspector/injected-script.h +251 -0
  217. package/pods/Headers/inspector/src/inspector/inspected-context.h +79 -0
  218. package/pods/Headers/inspector/src/inspector/protocol/CSS.h +2148 -0
  219. package/pods/Headers/inspector/src/inspector/protocol/Console.h +211 -0
  220. package/pods/Headers/inspector/src/inspector/protocol/DOM.h +1008 -0
  221. package/pods/Headers/inspector/src/inspector/protocol/Debugger.h +892 -0
  222. package/pods/Headers/inspector/src/inspector/protocol/Forward.h +75 -0
  223. package/pods/Headers/inspector/src/inspector/protocol/HeapProfiler.h +346 -0
  224. package/pods/Headers/inspector/src/inspector/protocol/Log.h +342 -0
  225. package/pods/Headers/inspector/src/inspector/protocol/Network.h +2528 -0
  226. package/pods/Headers/inspector/src/inspector/protocol/Overlay.h +281 -0
  227. package/pods/Headers/inspector/src/inspector/protocol/Page.h +1189 -0
  228. package/pods/Headers/inspector/src/inspector/protocol/Profiler.h +1001 -0
  229. package/pods/Headers/inspector/src/inspector/protocol/Protocol.h +617 -0
  230. package/pods/Headers/inspector/src/inspector/protocol/Runtime.h +1696 -0
  231. package/pods/Headers/inspector/src/inspector/protocol/Schema.h +146 -0
  232. package/pods/Headers/inspector/src/inspector/protocol/Security.h +793 -0
  233. package/pods/Headers/inspector/src/inspector/remote-object-id.h +54 -0
  234. package/pods/Headers/inspector/src/inspector/search-util.h +26 -0
  235. package/pods/Headers/inspector/src/inspector/string-16.h +180 -0
  236. package/pods/Headers/inspector/src/inspector/string-util.h +128 -0
  237. package/pods/Headers/inspector/src/inspector/v8-console-agent-impl.h +48 -0
  238. package/pods/Headers/inspector/src/inspector/v8-console-message.h +147 -0
  239. package/pods/Headers/inspector/src/inspector/v8-console.h +173 -0
  240. package/pods/Headers/inspector/src/inspector/v8-css-agent-impl.h +62 -0
  241. package/pods/Headers/inspector/src/inspector/v8-debugger-agent-impl.h +248 -0
  242. package/pods/Headers/inspector/src/inspector/v8-debugger-id.h +44 -0
  243. package/pods/Headers/inspector/src/inspector/v8-debugger-script.h +123 -0
  244. package/pods/Headers/inspector/src/inspector/v8-debugger.h +257 -0
  245. package/pods/Headers/inspector/src/inspector/v8-dom-agent-impl.h +91 -0
  246. package/pods/Headers/inspector/src/inspector/v8-heap-profiler-agent-impl.h +80 -0
  247. package/pods/Headers/inspector/src/inspector/v8-inspector-impl.h +191 -0
  248. package/pods/Headers/inspector/src/inspector/v8-inspector-session-impl.h +156 -0
  249. package/pods/Headers/inspector/src/inspector/v8-log-agent-impl.h +34 -0
  250. package/pods/Headers/inspector/src/inspector/v8-network-agent-impl.h +71 -0
  251. package/pods/Headers/inspector/src/inspector/v8-ns-debugger-agent-impl.h +24 -0
  252. package/pods/Headers/inspector/src/inspector/v8-overlay-agent-impl.h +70 -0
  253. package/pods/Headers/inspector/src/inspector/v8-page-agent-impl.h +88 -0
  254. package/pods/Headers/inspector/src/inspector/v8-profiler-agent-impl.h +104 -0
  255. package/pods/Headers/inspector/src/inspector/v8-regex.h +38 -0
  256. package/pods/Headers/inspector/src/inspector/v8-runtime-agent-impl.h +157 -0
  257. package/pods/Headers/inspector/src/inspector/v8-schema-agent-impl.h +38 -0
  258. package/pods/Headers/inspector/src/inspector/v8-stack-trace-impl.h +164 -0
  259. package/pods/Headers/inspector/src/inspector/v8-string-conversions.h +17 -0
  260. package/pods/Headers/inspector/src/inspector/v8-value-utils.h +23 -0
  261. package/pods/Headers/inspector/src/inspector/value-mirror.h +87 -0
  262. package/pods/Headers/inspector/src/libplatform/default-platform.h +92 -0
  263. package/pods/Headers/inspector/src/logging/tracing-flags.h +50 -0
  264. package/pods/Headers/inspector/src/numbers/conversions.h +183 -0
  265. package/pods/Headers/inspector/src/tracing/trace-event.h +664 -0
  266. package/pods/Headers/inspector/src/utils/allocation.h +367 -0
  267. package/pods/Headers/inspector/src/utils/vector.h +324 -0
  268. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/cbor.h +305 -0
  269. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/dispatch.h +314 -0
  270. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/error_support.h +62 -0
  271. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/export.h +6 -0
  272. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/find_by_first.h +58 -0
  273. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/frontend_channel.h +47 -0
  274. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/glue.h +80 -0
  275. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/json.h +52 -0
  276. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/json_platform.h +26 -0
  277. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/maybe.h +104 -0
  278. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/parser_handler.h +39 -0
  279. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/protocol_core.h +406 -0
  280. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/serializable.h +32 -0
  281. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/serializer_traits.h +158 -0
  282. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/span.h +99 -0
  283. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/status.h +139 -0
  284. package/pods/Headers/inspector/utils.h +32 -0
  285. package/pods/Headers/inspector/v8-inspector-platform.h +44 -0
  286. package/pods/Headers/jsi/decorator.h +762 -0
  287. package/pods/Headers/jsi/instrumentation.h +117 -0
  288. package/pods/Headers/jsi/jsi-inl.h +322 -0
  289. package/pods/Headers/jsi/jsi.h +1387 -0
  290. package/pods/Headers/jsi/jsilib.h +59 -0
  291. package/pods/Headers/jsi/threadsafe.h +79 -0
  292. package/pods/Headers/runtime/ArgConverter.h +61 -0
  293. package/pods/Headers/runtime/ArrayAdapter.h +13 -0
  294. package/pods/Headers/runtime/Caches.h +98 -0
  295. package/pods/Headers/runtime/ClassBuilder.h +61 -0
  296. package/pods/Headers/runtime/Common.h +9 -0
  297. package/pods/Headers/runtime/ConcurrentMap.h +55 -0
  298. package/pods/Headers/runtime/ConcurrentQueue.h +28 -0
  299. package/pods/Headers/runtime/Console.h +27 -0
  300. package/pods/Headers/runtime/Constants.h +15 -0
  301. package/pods/Headers/runtime/DataWrapper.h +671 -0
  302. package/pods/Headers/runtime/DictionaryAdapter.h +13 -0
  303. package/pods/Headers/runtime/ExtVector.h +21 -0
  304. package/pods/Headers/runtime/FFICall.h +105 -0
  305. package/pods/Headers/runtime/FastEnumerationAdapter.h +13 -0
  306. package/pods/Headers/runtime/FunctionReference.h +18 -0
  307. package/pods/Headers/runtime/Helpers.h +84 -0
  308. package/pods/Headers/runtime/InlineFunctions.h +16 -0
  309. package/pods/Headers/runtime/Interop.h +202 -0
  310. package/pods/Headers/runtime/KnownUnknownClassPair.h +35 -0
  311. package/pods/Headers/runtime/Metadata.h +981 -0
  312. package/pods/Headers/runtime/MetadataBuilder.h +72 -0
  313. package/pods/Headers/runtime/MetadataInlines.h +157 -0
  314. package/pods/Headers/runtime/ModuleInternal.h +59 -0
  315. package/pods/Headers/runtime/NSDataAdapter.h +13 -0
  316. package/pods/Headers/runtime/NativeScriptException.h +27 -0
  317. package/pods/Headers/runtime/ObjectManager.h +31 -0
  318. package/pods/Headers/runtime/OneByteStringResource.h +21 -0
  319. package/pods/Headers/runtime/Pointer.h +26 -0
  320. package/pods/Headers/runtime/PromiseProxy.h +15 -0
  321. package/pods/Headers/runtime/Reference.h +38 -0
  322. package/pods/Headers/runtime/Runtime.h +67 -0
  323. package/pods/Headers/runtime/RuntimeConfig.h +17 -0
  324. package/pods/Headers/runtime/SetTimeout.h +34 -0
  325. package/pods/Headers/runtime/SimpleAllocator.h +23 -0
  326. package/pods/Headers/runtime/StringHasher.h +315 -0
  327. package/pods/Headers/runtime/SymbolIterator.h +18 -0
  328. package/pods/Headers/runtime/SymbolLoader.h +27 -0
  329. package/pods/Headers/runtime/TNSDerivedClass.h +8 -0
  330. package/pods/Headers/runtime/TSHelpers.h +15 -0
  331. package/pods/Headers/runtime/Tasks.h +19 -0
  332. package/pods/Headers/runtime/UnmanagedType.h +21 -0
  333. package/pods/Headers/runtime/WeakRef.h +15 -0
  334. package/pods/Headers/runtime/Worker.h +26 -0
  335. package/pods/Headers/runtime/robin_hood.h +2184 -0
  336. package/pods/Headers/v8runtime/HostProxy.h +71 -0
  337. package/pods/Headers/v8runtime/JSIV8ValueConverter.h +70 -0
  338. package/pods/Headers/v8runtime/V8PointerValue.h +44 -0
  339. package/pods/Headers/v8runtime/V8Runtime.h +215 -0
  340. package/pods/Headers/v8runtime/V8RuntimeConfig.h +26 -0
  341. package/pods/Headers/v8runtime/V8RuntimeFactory.h +21 -0
  342. package/pods/NativeScript.podspec +68 -0
  343. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/PrivateHeaders/mason_native.h +0 -676
  344. package/platforms/ios/src/JSIModule.h +0 -217
  345. package/platforms/ios/src/JSIModule.mm +0 -2788
@@ -0,0 +1,72 @@
1
+ # The V8 public C++ API
2
+
3
+ # Overview
4
+
5
+ The V8 public C++ API aims to support four use cases:
6
+
7
+ 1. Enable applications that embed V8 (called the embedder) to configure and run
8
+ one or more instances of V8.
9
+ 2. Expose ECMAScript-like capabilities to the embedder.
10
+ 3. Enable the embedder to interact with ECMAScript by exposing API objects.
11
+ 4. Provide access to the V8 debugger (inspector).
12
+
13
+ # Configuring and running an instance of V8
14
+
15
+ V8 requires access to certain OS-level primitives such as the ability to
16
+ schedule work on threads, or allocate memory.
17
+
18
+ The embedder can define how to access those primitives via the v8::Platform
19
+ interface. While V8 bundles a basic implementation, embedders are highly
20
+ encouraged to implement v8::Platform themselves.
21
+
22
+ Currently, the v8::ArrayBuffer::Allocator is passed to the v8::Isolate factory
23
+ method, however, conceptually it should also be part of the v8::Platform since
24
+ all instances of V8 should share one allocator.
25
+
26
+ Once the v8::Platform is configured, an v8::Isolate can be created. All
27
+ further interactions with V8 should explicitly reference the v8::Isolate they
28
+ refer to. All API methods should eventually take an v8::Isolate parameter.
29
+
30
+ When a given instance of V8 is no longer needed, it can be destroyed by
31
+ disposing the respective v8::Isolate. If the embedder wishes to free all memory
32
+ associated with the v8::Isolate, it has to first clear all global handles
33
+ associated with that v8::Isolate.
34
+
35
+ # ECMAScript-like capabilities
36
+
37
+ In general, the C++ API shouldn't enable capabilities that aren't available to
38
+ scripts running in V8. Experience has shown that it's not possible to maintain
39
+ such API methods in the long term. However, capabilities also available to
40
+ scripts, i.e., ones that are defined in the ECMAScript standard are there to
41
+ stay, and we can safely expose them to embedders.
42
+
43
+ The C++ API should also be pleasant to use, and not require learning new
44
+ paradigms. Similarly to how the API exposed to scripts aims to provide good
45
+ ergonomics, we should aim to provide a reasonable developer experience for this
46
+ API surface.
47
+
48
+ ECMAScript makes heavy use of exceptions, however, V8's C++ code doesn't use
49
+ C++ exceptions. Therefore, all API methods that can throw exceptions should
50
+ indicate so by returning a v8::Maybe<> or v8::MaybeLocal<> result,
51
+ and by taking a v8::Local<v8::Context> parameter that indicates in which
52
+ context a possible exception should be thrown.
53
+
54
+ # API objects
55
+
56
+ V8 allows embedders to define special objects that expose additional
57
+ capabilities and APIs to scripts. The most prominent example is exposing the
58
+ HTML DOM in Blink. Other examples are e.g. node.js. It is less clear what kind
59
+ of capabilities we want to expose via this API surface. As a rule of thumb, we
60
+ want to expose operations as defined in the WebIDL and HTML spec: we
61
+ assume that those requirements are somewhat stable, and that they are a
62
+ superset of the requirements of other embedders including node.js.
63
+
64
+ Ideally, the API surfaces defined in those specs hook into the ECMAScript spec
65
+ which in turn guarantees long-term stability of the API.
66
+
67
+ # The V8 inspector
68
+
69
+ All debugging capabilities of V8 should be exposed via the inspector protocol.
70
+ The exception to this are profiling features exposed via v8-profiler.h.
71
+ Changes to the inspector protocol need to ensure backwards compatibility and
72
+ commitment to maintain.
@@ -0,0 +1,10 @@
1
+ include_rules = [
2
+ # v8-inspector-protocol.h depends on generated files under include/inspector.
3
+ "+inspector",
4
+ "+cppgc/common.h",
5
+ # Used by v8-cppgc.h to bridge to cppgc.
6
+ "+cppgc/custom-space.h",
7
+ "+cppgc/heap-statistics.h",
8
+ "+cppgc/internal/write-barrier.h",
9
+ "+cppgc/visitor.h",
10
+ ]
@@ -0,0 +1,11 @@
1
+ # Metadata information for this directory.
2
+ #
3
+ # For more information on DIR_METADATA files, see:
4
+ # https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/README.md
5
+ #
6
+ # For the schema of this file, see Metadata message:
7
+ # https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/proto/dir_metadata.proto
8
+
9
+ monorail {
10
+ component: "Blink>JavaScript>API"
11
+ }
@@ -0,0 +1,23 @@
1
+ adamk@chromium.org
2
+ cbruni@chromium.org
3
+ leszeks@chromium.org
4
+ mlippautz@chromium.org
5
+ verwaest@chromium.org
6
+ yangguo@chromium.org
7
+
8
+ per-file *DEPS=file:../COMMON_OWNERS
9
+ per-file v8-internal.h=file:../COMMON_OWNERS
10
+
11
+ per-file v8-debug.h=file:../src/debug/OWNERS
12
+
13
+ per-file js_protocol.pdl=file:../src/inspector/OWNERS
14
+ per-file v8-inspector*=file:../src/inspector/OWNERS
15
+ per-file v8-inspector*=file:../src/inspector/OWNERS
16
+
17
+ # Needed by the auto_tag builder
18
+ per-file v8-version.h=v8-ci-autoroll-builder@chops-service-accounts.iam.gserviceaccount.com
19
+
20
+ # For branch updates:
21
+ per-file v8-version.h=file:../INFRA_OWNERS
22
+ per-file v8-version.h=hablich@chromium.org
23
+ per-file v8-version.h=vahl@chromium.org
@@ -0,0 +1,8 @@
1
+ include_rules = [
2
+ "-include",
3
+ "+v8config.h",
4
+ "+v8-platform.h",
5
+ "+cppgc",
6
+ "-src",
7
+ "+libplatform/libplatform.h",
8
+ ]
@@ -0,0 +1,2 @@
1
+ bikineev@chromium.org
2
+ omerkatz@chromium.org
@@ -0,0 +1,133 @@
1
+ # Oilpan: C++ Garbage Collection
2
+
3
+ Oilpan is an open-source garbage collection library for C++ that can be used stand-alone or in collaboration with V8's JavaScript garbage collector.
4
+ Oilpan implements mark-and-sweep garbage collection (GC) with limited compaction (for a subset of objects).
5
+
6
+ **Key properties**
7
+
8
+ - Trace-based garbage collection;
9
+ - Incremental and concurrent marking;
10
+ - Incremental and concurrent sweeping;
11
+ - Precise on-heap memory layout;
12
+ - Conservative on-stack memory layout;
13
+ - Allows for collection with and without considering stack;
14
+ - Non-incremental and non-concurrent compaction for selected spaces;
15
+
16
+ See the [Hello World](https://chromium.googlesource.com/v8/v8/+/main/samples/cppgc/hello-world.cc) example on how to get started using Oilpan to manage C++ code.
17
+
18
+ Oilpan follows V8's project organization, see e.g. on how we accept [contributions](https://v8.dev/docs/contribute) and [provide a stable API](https://v8.dev/docs/api).
19
+
20
+ ## Threading model
21
+
22
+ Oilpan features thread-local garbage collection and assumes heaps are not shared among threads.
23
+ In other words, objects are accessed and ultimately reclaimed by the garbage collector on the same thread that allocates them.
24
+ This allows Oilpan to run garbage collection in parallel with mutators running in other threads.
25
+
26
+ References to objects belonging to another thread's heap are modeled using cross-thread roots.
27
+ This is even true for on-heap to on-heap references.
28
+
29
+ ## Heap partitioning
30
+
31
+ Oilpan's heaps are partitioned into spaces.
32
+ The space for an object is chosen depending on a number of criteria, e.g.:
33
+
34
+ - Objects over 64KiB are allocated in a large object space
35
+ - Objects can be assigned to a dedicated custom space.
36
+ Custom spaces can also be marked as compactable.
37
+ - Other objects are allocated in one of the normal page spaces bucketed depending on their size.
38
+
39
+ ## Precise and conservative garbage collection
40
+
41
+ Oilpan supports two kinds of GCs:
42
+
43
+ 1. **Conservative GC.**
44
+ A GC is called conservative when it is executed while the regular native stack is not empty.
45
+ In this case, the native stack might contain references to objects in Oilpan's heap, which should be kept alive.
46
+ The GC scans the native stack and treats the pointers discovered via the native stack as part of the root set.
47
+ This kind of GC is considered imprecise because values on stack other than references may accidentally appear as references to on-heap object, which means these objects will be kept alive despite being in practice unreachable from the application as an actual reference.
48
+
49
+ 2. **Precise GC.**
50
+ A precise GC is triggered at the end of an event loop, which is controlled by an embedder via a platform.
51
+ At this point, it is guaranteed that there are no on-stack references pointing to Oilpan's heap.
52
+ This means there is no risk of confusing other value types with references.
53
+ Oilpan has precise knowledge of on-heap object layouts, and so it knows exactly where pointers lie in memory.
54
+ Oilpan can just start marking from the regular root set and collect all garbage precisely.
55
+
56
+ ## Atomic, incremental and concurrent garbage collection
57
+
58
+ Oilpan has three modes of operation:
59
+
60
+ 1. **Atomic GC.**
61
+ The entire GC cycle, including all its phases (e.g. see [Marking](#Marking-phase) and [Sweeping](#Sweeping-phase)), are executed back to back in a single pause.
62
+ This mode of operation is also known as Stop-The-World (STW) garbage collection.
63
+ It results in the most jank (due to a single long pause), but is overall the most efficient (e.g. no need for write barriers).
64
+
65
+ 2. **Incremental GC.**
66
+ Garbage collection work is split up into multiple steps which are interleaved with the mutator, i.e. user code chunked into tasks.
67
+ Each step is a small chunk of work that is executed either as dedicated tasks between mutator tasks or, as needed, during mutator tasks.
68
+ Using incremental GC introduces the need for write barriers that record changes to the object graph so that a consistent state is observed and no objects are accidentally considered dead and reclaimed.
69
+ The incremental steps are followed by a smaller atomic pause to finalize garbage collection.
70
+ The smaller pause times, due to smaller chunks of work, helps with reducing jank.
71
+
72
+ 3. **Concurrent GC.**
73
+ This is the most common type of GC.
74
+ It builds on top of incremental GC and offloads much of the garbage collection work away from the mutator thread and on to background threads.
75
+ Using concurrent GC allows the mutator thread to spend less time on GC and more on the actual mutator.
76
+
77
+ ## Marking phase
78
+
79
+ The marking phase consists of the following steps:
80
+
81
+ 1. Mark all objects in the root set.
82
+
83
+ 2. Mark all objects transitively reachable from the root set by calling `Trace()` methods defined on each object.
84
+
85
+ 3. Clear out all weak handles to unreachable objects and run weak callbacks.
86
+
87
+ The marking phase can be executed atomically in a stop-the-world manner, in which all 3 steps are executed one after the other.
88
+
89
+ Alternatively, it can also be executed incrementally/concurrently.
90
+ With incremental/concurrent marking, step 1 is executed in a short pause after which the mutator regains control.
91
+ Step 2 is repeatedly executed in an interleaved manner with the mutator.
92
+ When the GC is ready to finalize, i.e. step 2 is (almost) finished, another short pause is triggered in which step 2 is finished and step 3 is performed.
93
+
94
+ To prevent a user-after-free (UAF) issues it is required for Oilpan to know about all edges in the object graph.
95
+ This means that all pointers except on-stack pointers must be wrapped with Oilpan's handles (i.e., Persistent<>, Member<>, WeakMember<>).
96
+ Raw pointers to on-heap objects create an edge that Oilpan cannot observe and cause UAF issues
97
+ Thus, raw pointers shall not be used to reference on-heap objects (except for raw pointers on native stacks).
98
+
99
+ ## Sweeping phase
100
+
101
+ The sweeping phase consists of the following steps:
102
+
103
+ 1. Invoke pre-finalizers.
104
+ At this point, no destructors have been invoked and no memory has been reclaimed.
105
+ Pre-finalizers are allowed to access any other on-heap objects, even those that may get destructed.
106
+
107
+ 2. Sweeping invokes destructors of the dead (unreachable) objects and reclaims memory to be reused by future allocations.
108
+
109
+ Assumptions should not be made about the order and the timing of their execution.
110
+ There is no guarantee on the order in which the destructors are invoked.
111
+ That's why destructors must not access any other on-heap objects (which might have already been destructed).
112
+ If some destructor unavoidably needs to access other on-heap objects, it will have to be converted to a pre-finalizer.
113
+ The pre-finalizer is allowed to access other on-heap objects.
114
+
115
+ The mutator is resumed before all destructors have ran.
116
+ For example, imagine a case where X is a client of Y, and Y holds a list of clients.
117
+ If the code relies on X's destructor removing X from the list, there is a risk that Y iterates the list and calls some method of X which may touch other on-heap objects.
118
+ This causes a use-after-free.
119
+ Care must be taken to make sure that X is explicitly removed from the list before the mutator resumes its execution in a way that doesn't rely on X's destructor (e.g. a pre-finalizer).
120
+
121
+ Similar to marking, sweeping can be executed in either an atomic stop-the-world manner or incrementally/concurrently.
122
+ With incremental/concurrent sweeping, step 2 is interleaved with mutator.
123
+ Incremental/concurrent sweeping can be atomically finalized in case it is needed to trigger another GC cycle.
124
+ Even with concurrent sweeping, destructors are guaranteed to run on the thread the object has been allocated on to preserve C++ semantics.
125
+
126
+ Notes:
127
+
128
+ - Weak processing runs only when the holder object of the WeakMember outlives the pointed object.
129
+ If the holder object and the pointed object die at the same time, weak processing doesn't run.
130
+ It is wrong to write code assuming that the weak processing always runs.
131
+
132
+ - Pre-finalizers are heavy because the thread needs to scan all pre-finalizers at each sweeping phase to determine which pre-finalizers should be invoked (the thread needs to invoke pre-finalizers of dead objects).
133
+ Adding pre-finalizers to frequently created objects should be avoided.
@@ -0,0 +1,310 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_ALLOCATION_H_
6
+ #define INCLUDE_CPPGC_ALLOCATION_H_
7
+
8
+ #include <atomic>
9
+ #include <cstddef>
10
+ #include <cstdint>
11
+ #include <new>
12
+ #include <type_traits>
13
+ #include <utility>
14
+
15
+ #include "cppgc/custom-space.h"
16
+ #include "cppgc/internal/api-constants.h"
17
+ #include "cppgc/internal/gc-info.h"
18
+ #include "cppgc/type-traits.h"
19
+ #include "v8config.h" // NOLINT(build/include_directory)
20
+
21
+ #if defined(__has_attribute)
22
+ #if __has_attribute(assume_aligned)
23
+ #define CPPGC_DEFAULT_ALIGNED \
24
+ __attribute__((assume_aligned(api_constants::kDefaultAlignment)))
25
+ #define CPPGC_DOUBLE_WORD_ALIGNED \
26
+ __attribute__((assume_aligned(2 * api_constants::kDefaultAlignment)))
27
+ #endif // __has_attribute(assume_aligned)
28
+ #endif // defined(__has_attribute)
29
+
30
+ #if !defined(CPPGC_DEFAULT_ALIGNED)
31
+ #define CPPGC_DEFAULT_ALIGNED
32
+ #endif
33
+
34
+ #if !defined(CPPGC_DOUBLE_WORD_ALIGNED)
35
+ #define CPPGC_DOUBLE_WORD_ALIGNED
36
+ #endif
37
+
38
+ namespace cppgc {
39
+
40
+ /**
41
+ * AllocationHandle is used to allocate garbage-collected objects.
42
+ */
43
+ class AllocationHandle;
44
+
45
+ namespace internal {
46
+
47
+ // Similar to C++17 std::align_val_t;
48
+ enum class AlignVal : size_t {};
49
+
50
+ class V8_EXPORT MakeGarbageCollectedTraitInternal {
51
+ protected:
52
+ static inline void MarkObjectAsFullyConstructed(const void* payload) {
53
+ // See api_constants for an explanation of the constants.
54
+ std::atomic<uint16_t>* atomic_mutable_bitfield =
55
+ reinterpret_cast<std::atomic<uint16_t>*>(
56
+ const_cast<uint16_t*>(reinterpret_cast<const uint16_t*>(
57
+ reinterpret_cast<const uint8_t*>(payload) -
58
+ api_constants::kFullyConstructedBitFieldOffsetFromPayload)));
59
+ // It's safe to split use load+store here (instead of a read-modify-write
60
+ // operation), since it's guaranteed that this 16-bit bitfield is only
61
+ // modified by a single thread. This is cheaper in terms of code bloat (on
62
+ // ARM) and performance.
63
+ uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed);
64
+ value |= api_constants::kFullyConstructedBitMask;
65
+ atomic_mutable_bitfield->store(value, std::memory_order_release);
66
+ }
67
+
68
+ // Dispatch based on compile-time information.
69
+ //
70
+ // Default implementation is for a custom space with >`kDefaultAlignment` byte
71
+ // alignment.
72
+ template <typename GCInfoType, typename CustomSpace, size_t alignment>
73
+ struct AllocationDispatcher final {
74
+ static void* Invoke(AllocationHandle& handle, size_t size) {
75
+ static_assert(std::is_base_of<CustomSpaceBase, CustomSpace>::value,
76
+ "Custom space must inherit from CustomSpaceBase.");
77
+ static_assert(
78
+ !CustomSpace::kSupportsCompaction,
79
+ "Custom spaces that support compaction do not support allocating "
80
+ "objects with non-default (i.e. word-sized) alignment.");
81
+ return MakeGarbageCollectedTraitInternal::Allocate(
82
+ handle, size, static_cast<AlignVal>(alignment),
83
+ internal::GCInfoTrait<GCInfoType>::Index(), CustomSpace::kSpaceIndex);
84
+ }
85
+ };
86
+
87
+ // Fast path for regular allocations for the default space with
88
+ // `kDefaultAlignment` byte alignment.
89
+ template <typename GCInfoType>
90
+ struct AllocationDispatcher<GCInfoType, void,
91
+ api_constants::kDefaultAlignment>
92
+ final {
93
+ static void* Invoke(AllocationHandle& handle, size_t size) {
94
+ return MakeGarbageCollectedTraitInternal::Allocate(
95
+ handle, size, internal::GCInfoTrait<GCInfoType>::Index());
96
+ }
97
+ };
98
+
99
+ // Default space with >`kDefaultAlignment` byte alignment.
100
+ template <typename GCInfoType, size_t alignment>
101
+ struct AllocationDispatcher<GCInfoType, void, alignment> final {
102
+ static void* Invoke(AllocationHandle& handle, size_t size) {
103
+ return MakeGarbageCollectedTraitInternal::Allocate(
104
+ handle, size, static_cast<AlignVal>(alignment),
105
+ internal::GCInfoTrait<GCInfoType>::Index());
106
+ }
107
+ };
108
+
109
+ // Custom space with `kDefaultAlignment` byte alignment.
110
+ template <typename GCInfoType, typename CustomSpace>
111
+ struct AllocationDispatcher<GCInfoType, CustomSpace,
112
+ api_constants::kDefaultAlignment>
113
+ final {
114
+ static void* Invoke(AllocationHandle& handle, size_t size) {
115
+ static_assert(std::is_base_of<CustomSpaceBase, CustomSpace>::value,
116
+ "Custom space must inherit from CustomSpaceBase.");
117
+ return MakeGarbageCollectedTraitInternal::Allocate(
118
+ handle, size, internal::GCInfoTrait<GCInfoType>::Index(),
119
+ CustomSpace::kSpaceIndex);
120
+ }
121
+ };
122
+
123
+ private:
124
+ static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t,
125
+ GCInfoIndex);
126
+ static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&,
127
+ size_t, AlignVal,
128
+ GCInfoIndex);
129
+ static void* CPPGC_DEFAULT_ALIGNED Allocate(cppgc::AllocationHandle&, size_t,
130
+ GCInfoIndex, CustomSpaceIndex);
131
+ static void* CPPGC_DOUBLE_WORD_ALIGNED Allocate(cppgc::AllocationHandle&,
132
+ size_t, AlignVal, GCInfoIndex,
133
+ CustomSpaceIndex);
134
+
135
+ friend class HeapObjectHeader;
136
+ };
137
+
138
+ } // namespace internal
139
+
140
+ /**
141
+ * Base trait that provides utilities for advancers users that have custom
142
+ * allocation needs (e.g., overriding size). It's expected that users override
143
+ * MakeGarbageCollectedTrait (see below) and inherit from
144
+ * MakeGarbageCollectedTraitBase and make use of the low-level primitives
145
+ * offered to allocate and construct an object.
146
+ */
147
+ template <typename T>
148
+ class MakeGarbageCollectedTraitBase
149
+ : private internal::MakeGarbageCollectedTraitInternal {
150
+ private:
151
+ static_assert(internal::IsGarbageCollectedType<T>::value,
152
+ "T needs to be a garbage collected object");
153
+ static_assert(!IsGarbageCollectedWithMixinTypeV<T> ||
154
+ sizeof(T) <=
155
+ internal::api_constants::kLargeObjectSizeThreshold,
156
+ "GarbageCollectedMixin may not be a large object");
157
+
158
+ protected:
159
+ /**
160
+ * Allocates memory for an object of type T.
161
+ *
162
+ * \param handle AllocationHandle identifying the heap to allocate the object
163
+ * on.
164
+ * \param size The size that should be reserved for the object.
165
+ * \returns the memory to construct an object of type T on.
166
+ */
167
+ V8_INLINE static void* Allocate(AllocationHandle& handle, size_t size) {
168
+ static_assert(
169
+ std::is_base_of<typename T::ParentMostGarbageCollectedType, T>::value,
170
+ "U of GarbageCollected<U> must be a base of T. Check "
171
+ "GarbageCollected<T> base class inheritance.");
172
+ static constexpr size_t kWantedAlignment =
173
+ alignof(T) < internal::api_constants::kDefaultAlignment
174
+ ? internal::api_constants::kDefaultAlignment
175
+ : alignof(T);
176
+ static_assert(
177
+ kWantedAlignment <= internal::api_constants::kMaxSupportedAlignment,
178
+ "Requested alignment larger than alignof(std::max_align_t) bytes. "
179
+ "Please file a bug to possibly get this restriction lifted.");
180
+ return AllocationDispatcher<
181
+ typename internal::GCInfoFolding<
182
+ T, typename T::ParentMostGarbageCollectedType>::ResultType,
183
+ typename SpaceTrait<T>::Space, kWantedAlignment>::Invoke(handle, size);
184
+ }
185
+
186
+ /**
187
+ * Marks an object as fully constructed, resulting in precise handling by the
188
+ * garbage collector.
189
+ *
190
+ * \param payload The base pointer the object is allocated at.
191
+ */
192
+ V8_INLINE static void MarkObjectAsFullyConstructed(const void* payload) {
193
+ internal::MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed(
194
+ payload);
195
+ }
196
+ };
197
+
198
+ /**
199
+ * Passed to MakeGarbageCollected to specify how many bytes should be appended
200
+ * to the allocated object.
201
+ *
202
+ * Example:
203
+ * \code
204
+ * class InlinedArray final : public GarbageCollected<InlinedArray> {
205
+ * public:
206
+ * explicit InlinedArray(size_t bytes) : size(bytes), byte_array(this + 1) {}
207
+ * void Trace(Visitor*) const {}
208
+
209
+ * size_t size;
210
+ * char* byte_array;
211
+ * };
212
+ *
213
+ * auto* inlined_array = MakeGarbageCollected<InlinedArray(
214
+ * GetAllocationHandle(), AdditionalBytes(4), 4);
215
+ * for (size_t i = 0; i < 4; i++) {
216
+ * Process(inlined_array->byte_array[i]);
217
+ * }
218
+ * \endcode
219
+ */
220
+ struct AdditionalBytes {
221
+ constexpr explicit AdditionalBytes(size_t bytes) : value(bytes) {}
222
+ const size_t value;
223
+ };
224
+
225
+ /**
226
+ * Default trait class that specifies how to construct an object of type T.
227
+ * Advanced users may override how an object is constructed using the utilities
228
+ * that are provided through MakeGarbageCollectedTraitBase.
229
+ *
230
+ * Any trait overriding construction must
231
+ * - allocate through `MakeGarbageCollectedTraitBase<T>::Allocate`;
232
+ * - mark the object as fully constructed using
233
+ * `MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed`;
234
+ */
235
+ template <typename T>
236
+ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
237
+ public:
238
+ template <typename... Args>
239
+ static T* Call(AllocationHandle& handle, Args&&... args) {
240
+ void* memory =
241
+ MakeGarbageCollectedTraitBase<T>::Allocate(handle, sizeof(T));
242
+ T* object = ::new (memory) T(std::forward<Args>(args)...);
243
+ MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed(object);
244
+ return object;
245
+ }
246
+
247
+ template <typename... Args>
248
+ static T* Call(AllocationHandle& handle, AdditionalBytes additional_bytes,
249
+ Args&&... args) {
250
+ void* memory = MakeGarbageCollectedTraitBase<T>::Allocate(
251
+ handle, sizeof(T) + additional_bytes.value);
252
+ T* object = ::new (memory) T(std::forward<Args>(args)...);
253
+ MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed(object);
254
+ return object;
255
+ }
256
+ };
257
+
258
+ /**
259
+ * Allows users to specify a post-construction callback for specific types. The
260
+ * callback is invoked on the instance of type T right after it has been
261
+ * constructed. This can be useful when the callback requires a
262
+ * fully-constructed object to be able to dispatch to virtual methods.
263
+ */
264
+ template <typename T, typename = void>
265
+ struct PostConstructionCallbackTrait {
266
+ static void Call(T*) {}
267
+ };
268
+
269
+ /**
270
+ * Constructs a managed object of type T where T transitively inherits from
271
+ * GarbageCollected.
272
+ *
273
+ * \param args List of arguments with which an instance of T will be
274
+ * constructed.
275
+ * \returns an instance of type T.
276
+ */
277
+ template <typename T, typename... Args>
278
+ V8_INLINE T* MakeGarbageCollected(AllocationHandle& handle, Args&&... args) {
279
+ T* object =
280
+ MakeGarbageCollectedTrait<T>::Call(handle, std::forward<Args>(args)...);
281
+ PostConstructionCallbackTrait<T>::Call(object);
282
+ return object;
283
+ }
284
+
285
+ /**
286
+ * Constructs a managed object of type T where T transitively inherits from
287
+ * GarbageCollected. Created objects will have additional bytes appended to
288
+ * it. Allocated memory would suffice for `sizeof(T) + additional_bytes`.
289
+ *
290
+ * \param additional_bytes Denotes how many bytes to append to T.
291
+ * \param args List of arguments with which an instance of T will be
292
+ * constructed.
293
+ * \returns an instance of type T.
294
+ */
295
+ template <typename T, typename... Args>
296
+ V8_INLINE T* MakeGarbageCollected(AllocationHandle& handle,
297
+ AdditionalBytes additional_bytes,
298
+ Args&&... args) {
299
+ T* object = MakeGarbageCollectedTrait<T>::Call(handle, additional_bytes,
300
+ std::forward<Args>(args)...);
301
+ PostConstructionCallbackTrait<T>::Call(object);
302
+ return object;
303
+ }
304
+
305
+ } // namespace cppgc
306
+
307
+ #undef CPPGC_DEFAULT_ALIGNED
308
+ #undef CPPGC_DOUBLE_WORD_ALIGNED
309
+
310
+ #endif // INCLUDE_CPPGC_ALLOCATION_H_
@@ -0,0 +1,29 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_COMMON_H_
6
+ #define INCLUDE_CPPGC_COMMON_H_
7
+
8
+ // TODO(chromium:1056170): Remove dependency on v8.
9
+ #include "v8config.h" // NOLINT(build/include_directory)
10
+
11
+ namespace cppgc {
12
+
13
+ /**
14
+ * Indicator for the stack state of the embedder.
15
+ */
16
+ enum class EmbedderStackState {
17
+ /**
18
+ * Stack may contain interesting heap pointers.
19
+ */
20
+ kMayContainHeapPointers,
21
+ /**
22
+ * Stack does not contain any interesting heap pointers.
23
+ */
24
+ kNoHeapPointers,
25
+ };
26
+
27
+ } // namespace cppgc
28
+
29
+ #endif // INCLUDE_CPPGC_COMMON_H_