dart-sdk/tests/language/constructor
Jess Lally 3c4d4ad450 Reland "[dart2wasm] Replace struct.new_default with struct.new for object allocation."
This reverts commit 67f0d4daf0, and further optimises constructor contexts by preventing empty contexts.

Reason for revert: Includes fix for Flutter engine unit test failures.

Fixes https://github.com/dart-lang/sdk/issues/53506

Original change's description:
[dart2wasm] Replace `struct.new_default` with `struct.new` for object allocation.

When using the `struct.new_default` instruction for object allocation,
fields are always nullable and mutable. By using the `struct.new`
instruction instead, class fields can now have the same mutability and
nullability in Wasm as declared in Dart. In addition, the class ID and
type parameters (which are also stored in an object's struct), can now
be immutable and nonnullable as well.

To do this, object construction is now split into three functions:
(1) Initializer: evaluates initializers for instance fields and
constructor initializers (this constructor before super constructor).
(2) Constructor body: executes the constructor body (super constructor
before this constructor), with `this` pointed to the constructed object.
(3) Constructor allocator: which calls (1), allocates the object using
`struct.new`, then calls (2).

Because fields now have the correct mutability and nullability in Wasm,
this removes unnecessary null checks for nonnullable fields, and may
allow for better optimisations by Binaryen.

Fixes https://github.com/dart-lang/sdk/issues/51492

Change-Id: I13499bdc412f474bc76473115b6e63d6954f4d23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326080
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jess Lally <jessicalally@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-09-26 10:07:42 +00:00
..
bad_constructor_runtime_1_test.dart
bad_constructor_runtime_test.dart
bad_constructor_test.dart
bad_named_constructor_runtime_test.dart
bad_named_constructor_test.dart
body_test.dart
bodyless_wrong_arg_runtime_test.dart
bodyless_wrong_arg_test.dart [analyzer] Initial refactor of _InstanceCreationEvaluator to return Constant value. 2023-07-25 19:23:02 +00:00
call_as_function_test.dart
call_wrong_argument_count_runtime_test.dart
call_wrong_argument_count_test.dart [analyzer] NOT_ENOUGH_POSITIONAL_ARGUMENTS 2022-10-11 17:56:11 +00:00
constructor2_test.dart
constructor3_test.dart
constructor4_test.dart
constructor5_test.dart Remove uses of : as default value separator in some tests/ directories. 2022-09-07 14:49:17 +00:00
constructor6_test.dart
constructor7_test.dart
constructor8_test.dart
constructor9_runtime_test.dart
constructor9_test.dart Move errors from StaticWarningCode to CompileTimeErrorCode. 2020-07-26 04:19:25 +00:00
constructor10_runtime_test.dart
constructor10_test.dart
constructor11_test.dart
constructor12_lib.dart [tests] Break test into weak and strong versions 2020-04-24 01:03:52 +00:00
constructor12_strong_test.dart [tests] Break test into weak and strong versions 2020-04-24 01:03:52 +00:00
constructor12_test.dart [tests] Break test into weak and strong versions 2020-04-24 01:03:52 +00:00
constructor12_weak_test.dart [tests] Break test into weak and strong versions 2020-04-24 01:03:52 +00:00
constructor13_runtime_test.dart
constructor13_test.dart [analyzer] NOT_ENOUGH_POSITIONAL_ARGUMENTS 2022-10-11 17:56:11 +00:00
constructor_contexts_test.dart Reland "[dart2wasm] Replace struct.new_default with struct.new for object allocation." 2023-09-26 10:07:42 +00:00
constructor_test.dart
cyclic_constructor_test.dart
cyclic_runtime_test.dart
default_class_implicit_constructor_test.dart
default_factory2_runtime_test.dart
default_factory2_test.dart [cfe] Create normal bodies for redirecting factories 2021-08-04 17:51:07 +00:00
default_factory3_test.dart
default_factory_library.dart
default_factory_library_test.dart
default_factory_runtime_test.dart
default_factory_test.dart Move errors from StaticWarningCode to CompileTimeErrorCode. 2020-07-26 04:19:25 +00:00
default_test.dart
duplicate_final_test.dart
duplicate_initializers_runtime_test.dart
duplicate_initializers_test.dart Unify duplicate_field_formal_parameter and final_initialized_multiple_times 2021-04-27 17:32:18 +00:00
duplicate_runtime_test.dart
duplicate_test.dart
evaluation_redirecting_constructor_test.dart
example_constructor_test.dart
explicit_instantiation_syntax_test.dart [tests] Remove obsolete Dart 3.0 experiments from language tests 2023-06-15 08:26:27 +00:00
external_constructor_test.dart [vm] Throw error from external functions even if they have a body 2022-09-09 14:18:34 +00:00
forwarding_factory_constructor_default_values_test.dart Remove uses of : as default value separator in some tests/ directories. 2022-09-07 14:49:17 +00:00
implicit_super_constructor_call_test.dart Remove uses of : as default value separator in some tests/ directories. 2022-09-07 14:49:17 +00:00
implicit_super_constructor_test.dart
inference_super_constructor_call_test.dart
initializer_test.dart
missing_const_constructor_test.dart
missing_initializer_test.dart Clean up a number of 2.19 opt outs in language tests. 2023-03-17 16:17:50 +00:00
multiple_field_assignment_constructor_test.dart [test] Replace non-implemented @DontInline() annotations 2021-07-26 13:22:31 +00:00
name_clash_lib.dart
name_clash_test.dart
name_test.dart
named_arguments_test.dart Remove uses of : as default value separator in some tests/ directories. 2022-09-07 14:49:17 +00:00
named_constructor_test.dart Fix analyzerCode corresponding to CFE error ConstructorWithTypeArguments. 2021-09-17 10:48:59 +00:00
named_lib.dart
named_runtime_test.dart
no_such_constructor_runtime_test.dart
no_such_constructor_test.dart [Analyzer] Report EXTRA_POSITIONAL_ARGUMENTS and EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED against first unmatched argument 2021-01-11 18:46:26 +00:00
non_const_constructor_without_body_test.dart
non_parameterized_factory2_test.dart
non_parameterized_factory_test.dart
patch_tear_off_test.dart [cfe] Handle tear-offs of patched constructors 2022-04-25 15:50:47 +00:00
redirect2_runtime_test.dart
redirect2_test.dart [cfe] Add more compiler-time errors for incorrect enum constructors 2022-01-28 15:07:02 +00:00
redirect_cycle_runtime_test.dart
redirect_cycle_test.dart
redirect_indirect_cycle_runtime_test.dart
redirect_indirect_cycle_test.dart
redirect_runtime_test.dart
redirect_test.dart
reference_runtime_1_test.dart
reference_runtime_2_test.dart
reference_runtime_3_test.dart
reference_runtime_4_test.dart
reference_runtime_5_test.dart
reference_runtime_6_test.dart
reference_runtime_7_test.dart
reference_runtime_8_test.dart
reference_runtime_9_test.dart
reference_runtime_10_test.dart
reference_runtime_11_test.dart
reference_runtime_12_test.dart
reference_runtime_test.dart
reference_test.dart [cfe] Check for misplaced type arguments on implicit creation expression 2021-10-28 19:21:39 +00:00
return_runtime_test.dart
return_test.dart
setter_test.dart Migrate "c" directory language tests off @compile-error. 2023-04-20 19:10:58 +00:00
tear_off_test.dart Fixed various typos in a lot of files 2022-07-25 12:21:59 +00:00
type_parameter_runtime_test.dart
type_parameter_test.dart
unnamed_new_error_test.dart Remove references to constructor-tearoff experiment. 2021-11-11 14:04:43 +00:00
unnamed_new_test.dart Remove references to constructor-tearoff experiment. 2021-11-11 14:04:43 +00:00
unresolved_default_constructor_test.dart [cfe] Add UnresolvedKind for fine grained unresolved reporting 2021-08-25 09:51:54 +00:00
unresolved_default_runtime_test.dart
unresolved_in_factory_test.dart Migrate "c" directory language tests off @compile-error. 2023-04-20 19:10:58 +00:00
with_mixin_test.dart Clean up a number of 2.19 opt outs in language tests. 2023-03-17 16:17:50 +00:00
with_type_parameters_test.dart