From af5c53b087859a80af2ae3a9d028a71a8afe576e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 14 Dec 2022 13:38:27 +0000 Subject: [PATCH] [dart2wasm] Mark static variables initialized on assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New passing tests: - co19/LibTest/core/Stopwatch/stop_A01_t01 - language/getter/setter_getters_setters_test - language/identifier/naming_test - language/lazy/static3_test - language/lazy/static7_test - language/lazy/static_test - language/loop/for_in2_test - language/new/statement_test - language/nnbd/inference/variables_initialized_to_null_test - language/operator/operator_test - language/setter/setter0_test - language/setter/setter1_test - language/super/call2_test - language/unsorted/inv_cse_licm_test Change-Id: Id7dd53228f1476190dffe3b22ba91d04ed4c2a14 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275320 Reviewed-by: Aske Simon Christensen Commit-Queue: Ömer Ağacan --- pkg/dart2wasm/lib/code_generator.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/dart2wasm/lib/code_generator.dart b/pkg/dart2wasm/lib/code_generator.dart index adc9a1515fc..e71af515488 100644 --- a/pkg/dart2wasm/lib/code_generator.dart +++ b/pkg/dart2wasm/lib/code_generator.dart @@ -1805,8 +1805,13 @@ class CodeGenerator extends ExpressionVisitor1 Member target = node.target; if (target is Field) { w.Global global = translator.globals.getGlobal(target); + w.Global? flag = translator.globals.getGlobalInitializedFlag(target); wrap(node.value, global.type.type); b.global_set(global); + if (flag != null) { + b.i32_const(1); // true + b.global_set(flag); + } if (preserved) { b.global_get(global); return global.type.type;