Attention is currently required from: Stephen Adams.
Mayank Patke would like Stephen Adams to review this change.
[dart2js] Add a 'FALSE' JS_GET_FLAG.
There are a few places in our runtime libraries where we have some code
guarded by `if (false)`. This is to ensure that the guarded code is
marked as used and compiled, but not emitted unless rewritten during
SSA. This pattern is somewhat brittle - a kernel
optimization/transformation which eliminates dead code may discard the
code.
Instead, we can write `if (JS_GET_FLAG('FALSE'))`, which will only be
written to `if (false)` and then discarded during SSA.
Change-Id: I8edc2b24e5fbeece1f042ff3d0c87d58e939bf84
---
M pkg/compiler/lib/src/ssa/builder.dart
M sdk/lib/_internal/js_runtime/lib/interceptors.dart
M sdk/lib/_internal/js_runtime/lib/js_number.dart
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index c3e3796..eb50233 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -368,6 +368,8 @@
/// concrete SSA builder reports an error.
bool _getFlagValue(String flagName) {
switch (flagName) {
+ case 'FALSE':
+ return false;
case 'DEV_COMPILER':
return false;
case 'MINIFIED':
diff --git a/sdk/lib/_internal/js_runtime/lib/interceptors.dart b/sdk/lib/_internal/js_runtime/lib/interceptors.dart
index bda0ac3..f15041c 100644
--- a/sdk/lib/_internal/js_runtime/lib/interceptors.dart
+++ b/sdk/lib/_internal/js_runtime/lib/interceptors.dart
@@ -8,6 +8,7 @@
show DISPATCH_PROPERTY_NAME, TYPE_TO_INTERCEPTOR_MAP;
import 'dart:collection' hide LinkedList, LinkedListEntry;
+import 'dart:_foreign_helper' show JS_GET_FLAG;
import 'dart:_internal' hide Symbol;
import "dart:_internal" as _symbol_dev show Symbol;
import 'dart:_js_helper'
diff --git a/sdk/lib/_internal/js_runtime/lib/js_number.dart b/sdk/lib/_internal/js_runtime/lib/js_number.dart
index 356a4c0..209a45a 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_number.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_number.dart
@@ -340,7 +340,7 @@
int operator ~/(num other) {
if (other is! num) throw argumentErrorValue(other);
- if (false) _tdivFast(other); // Ensure resolution.
+ if (JS_GET_FLAG('FALSE')) _tdivFast(other); // Ensure resolution.
if (_isInt32(this)) {
if (other >= 1 || other < -1) {
return JS('int', r'(# / #) | 0', this, other);
@@ -400,7 +400,7 @@
num operator >>(num other) {
if (other is! num) throw argumentErrorValue(other);
if (other < 0) throw argumentErrorValue(other);
- if (false) _shrReceiverPositive(other);
+ if (JS_GET_FLAG('FALSE')) _shrReceiverPositive(other);
return _shrOtherPositive(other);
}
To view, visit change 271800. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Stephen Adams.
Patch set 3:Commit-Queue +1
Attention is currently required from: Mayank Patke.
Patch set 3:Code-Review +1
Commit Queue submitted this change.
3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
[dart2js] Add a 'FALSE' JS_GET_FLAG.
There are a few places in our runtime libraries where we have some code
guarded by `if (false)`. This is to ensure that the guarded code is
marked as used and compiled, but not emitted unless rewritten during
SSA. This pattern is somewhat brittle - a kernel
optimization/transformation which eliminates dead code may discard the
code.
Instead, we can write `if (JS_GET_FLAG('FALSE'))`, which will only be
written to `if (false)` and then discarded during SSA.
Change-Id: I8edc2b24e5fbeece1f042ff3d0c87d58e939bf84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271800
Reviewed-by: Stephen Adams <s...@google.com>
---
M pkg/compiler/lib/src/ssa/builder.dart
M sdk/lib/_internal/js_runtime/lib/interceptors.dart
M sdk/lib/_internal/js_runtime/lib/js_number.dart
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 9706ced..b134c1d 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -369,6 +369,8 @@
/// concrete SSA builder reports an error.
bool? _getFlagValue(String flagName) {
switch (flagName) {
+ case 'FALSE':
+ return false;
case 'DEV_COMPILER':
return false;
case 'MINIFIED':
diff --git a/sdk/lib/_internal/js_runtime/lib/interceptors.dart b/sdk/lib/_internal/js_runtime/lib/interceptors.dart
index becd8b6..5065757 100644
To view, visit change 271800. To unsubscribe, or for help writing mail filters, visit settings.
go/dart-cbuild result: SUCCESS
Details: https://goto.google.com/dart-cbuild/find/b028da6407c0921fd21fc65e7b18197e77dba684