{"action":"opened","issue":{"url":"https://api.github.com/repos/dart-lang/angular/issues/1396","repository_url":"https://api.github.com/repos/dart-lang/angular","labels_url":"https://api.github.com/repos/dart-lang/angular/issues/1396/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/angular/issues/1396/comments","events_url":"https://api.github.com/repos/dart-lang/angular/issues/1396/events","html_url":"https://github.com/dart-lang/angular/issues/1396","id":331366436,"node_id":"MDU6SXNzdWUzMzEzNjY0MzY=","number":1396,"title":"Blocked on removing debug mode","user":{"login":"leonsenft","id":1916163,"node_id":"MDQ6VXNlcjE5MTYxNjM=","avatar_url":"https://avatars0.githubusercontent.com/u/1916163?v=4","gravatar_id":"","url":"https://api.github.com/users/leonsenft","html_url":"https://github.com/leonsenft","followers_url":"https://api.github.com/users/leonsenft/followers","following_url":"https://api.github.com/users/leonsenft/following{/other_user}","gists_url":"https://api.github.com/users/leonsenft/gists{/gist_id}","starred_url":"https://api.github.com/users/leonsenft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonsenft/subscriptions","organizations_url":"https://api.github.com/users/leonsenft/orgs","repos_url":"https://api.github.com/users/leonsenft/repos","events_url":"https://api.github.com/users/leonsenft/events{/privacy}","received_events_url":"https://api.github.com/users/leonsenft/received_events","type":"User","site_admin":false},"labels":[{"id":623409255,"node_id":"MDU6TGFiZWw2MjM0MDkyNTU=","url":"https://api.github.com/repos/dart-lang/angular/labels/area:%20runtime","name":"area: runtime","color":"fad8c7","default":false},{"id":453015967,"node_id":"MDU6TGFiZWw0NTMwMTU5Njc=","url":"https://api.github.com/repos/dart-lang/angular/labels/%E2%9B%94%20state:%20blocked","name":"⛔ state: blocked","color":"e99695","default":false},{"id":830468817,"node_id":"MDU6TGFiZWw4MzA0Njg4MTc=","url":"https://api.github.com/repos/dart-lang/angular/labels/%E2%9C%8D%EF%B8%8F%20%20needs%20review","name":"✍️  needs review","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-11T22:02:02Z","updated_at":"2018-06-11T22:02:02Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"See https://github.com/dart-lang/angular/issues/952 for context.\r\n\r\nToday we conditionally generate debug code based on the compilation mode: debug or release. For example, a simple check for changes in release mode\r\n\r\n```dart\r\nif (!identical(_expr_0, currVal_0) {\r\n```\r\n\r\nis instead generated as\r\n\r\n```dart\r\nif (checkBinding(_expr_0, currVal_0)) {\r\n```\r\n\r\nin debug mode. This is not an exhaustive list of differences, it's merely one example.\r\n\r\nThe intent is to remove the debug mode altogether, and instead generate code that relies on dart2js optimizations. For example, we make use of \r\n\r\nhttps://github.com/dart-lang/angular/blob/1ba3746c60597b92aebfb6edbadcba9754f04ddb/angular/lib/src/runtime/optimizations.dart#L23\r\n\r\nto guard debug code. The Angular compiler will emit this code unconditionally, and rely on constant-propagation and dead-code elimination in dart2js to optimize away statements guarded by `isDevMode` (which to dart2js with assertions disabled, is false throughout the lifetime of the program).\r\n\r\nThe goal is to avoid regressing the code generated for release mode. With the new single compilation mode using `isDevMode`, we've managed to retain identical dart2js output in all but one place: the original example above. We now always emit\r\n\r\n```dart\r\nif (checkBinding(_expr_0, currVal_0)) {\r\n```\r\n\r\nin place of\r\n\r\n```dart\r\nif (!identical(_expr_0, currVal_0) {\r\n```\r\n\r\nand rely on `isDevMode` internally to call `!identical()` for release mode. Initially we noticed `checkBinding()` is too long to inline, which we fixed with [@dart2js.tryInline](https://pub.dartlang.org/documentation/meta/latest/meta_dart2js/tryInline-constant.html). We confirmed this is due to dart2js performing inlining *before* dead-code elimination.\r\n\r\nThis led to the issue that is unresolved today. The optimized `checkBinding()` call yields slightly more JavaScript than `!identical()`.\r\n\r\n```diff\r\n<         if (this._feed_component_template$_expr_0 !== currVal_0) {\r\n---\r\n>         t1 = this._feed_component_template$_expr_0;\r\n>         if (t1 !== currVal_0) {\r\n```\r\n\r\nThis is again likely due to the order in which dart2js performs optimizations; at an earlier phase before code was eliminated it probably made sense to perform the assignment to `t1`, but in the final result it seems pointless (`t1` is immediately reassigned to something else inside the `if`-block).\r\n\r\nUntil we resolve this regression (or accept it), we won't be able to remove the distinct compilation modes.\r\n\r\n"}}
{"actor":{"display_login":"leonsenft"}}