commit | 86d1261dff279acf84bc699c6c116189955b0076 | [log] [tgz] |
---|---|---|
author | Tess Strickland <sstrickl@google.com> | Wed Jul 12 07:37:16 2023 +0000 |
committer | Commit Queue <dart-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Jul 12 07:37:16 2023 +0000 |
tree | da7a9068331297a66a2f0cf581c5859c39de92b6 | |
parent | 23f414520647df3719da1a94f19237955a0f5fc2 [diff] |
[vm] Clean up New() methods of Dart classes. Goals of this CL, a followup to 2f63acea22: * Ensure that X::New() depends on the initialization guarantees of Object::Allocate<X>(...): * Ptr fields are guaranteed to be initialized to Object::null(). * Non-Ptr fields are guaranteed to be zero-initialized. In cases where the only uses of the allocated object before return was to perform unnecessary field assignments, X::New() just simply returns the result of Object::Allocate<X>(...). Otherwise, the old now-unnecessary assignments have been changed into ASSERTs so that they will be checked in DEBUG mode. * Ensure that NoSafepointScopes are entered in X::New() only when necessary (e.g., to ensure fields used to calculate to(...) are properly set before being seen by pointer visitors as the GC may run when outside a NoSafepointScope). In particular, the often occurring pattern: auto& result = X::Handle(); { auto raw = Object::Allocate<X>(...); NoSafepointScope no_safepoint; result = raw; } ... has been replaced with: const auto& result = X::Handle(Object::Allocate<X>(...)); * If a handle was allocated, the only uses of that handle before returning must be performed under a NoSafepointScope, and the same operations can be done directly on the object pointer, then do so and remove the unnecessary handle allocation. Notable changes outside the above: * Swapped ObjectPool::EntryType::{kImmediate,kTaggedObject} so that kImmediate has value 0, since Object::Allocate<ObjectPool>(len) zero-initializes the payload and without this change, ObjectPool::New() must set the entry types manually. * Removed the old static ArrayPtr cached_array_ field on SubtypeTestCache as well as SubtypeTestCache::{Init,Cleanup} and instead added Object::empty_subtype_test_cache_array(). * Removed the no-arg Closure::New() method, which is never used. * Inlined the no-arg Script::New() method into its only caller, one of the other Script::New() overloads. TEST=ci Issue: https://github.com/dart-lang/sdk/issues/52876 Change-Id: I079b4c9f73c7d2c0146c30cf2cd570b91a1ecf36 Cq-Include-Trybots: luci.dart.try:vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-release-x64-try,vm-aot-linux-product-x64-try,vm-aot-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-ffi-qemu-linux-release-riscv64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313120 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
Dart is:
Optimized for UI: Develop with a programming language specialized around the needs of user interface creation.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app.
Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents on our wiki.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.