Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 218993003: Emit read-modify-write of fields as assignment op. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add test Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen_helpers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 1669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 Element element = node.element; 1680 Element element = node.element;
1681 world.registerFieldSetter(element); 1681 world.registerFieldSetter(element);
1682 String name = backend.namer.instanceFieldPropertyName(element); 1682 String name = backend.namer.instanceFieldPropertyName(element);
1683 use(node.receiver); 1683 use(node.receiver);
1684 js.Expression receiver = pop(); 1684 js.Expression receiver = pop();
1685 use(node.value); 1685 use(node.value);
1686 push(new js.Assignment(new js.PropertyAccess.field(receiver, name), pop()), 1686 push(new js.Assignment(new js.PropertyAccess.field(receiver, name), pop()),
1687 node); 1687 node);
1688 } 1688 }
1689 1689
1690 visitReadModifyWrite(HReadModifyWrite node) {
1691 Element element = node.element;
1692 world.registerFieldSetter(element);
1693 String name = backend.namer.instanceFieldPropertyName(element);
1694 use(node.receiver);
1695 js.Expression fieldReference = new js.PropertyAccess.field(pop(), name);
1696 if (node.isPreOp) {
1697 push(new js.Prefix(node.jsOp, fieldReference), node);
1698 } else if (node.isPostOp) {
1699 push(new js.Postfix(node.jsOp, fieldReference), node);
1700 } else {
1701 use(node.value);
1702 push(new js.Assignment.compound(fieldReference, node.jsOp, pop()), node);
1703 }
1704 }
1705
1690 visitLocalGet(HLocalGet node) { 1706 visitLocalGet(HLocalGet node) {
1691 use(node.receiver); 1707 use(node.receiver);
1692 } 1708 }
1693 1709
1694 visitLocalSet(HLocalSet node) { 1710 visitLocalSet(HLocalSet node) {
1695 use(node.value); 1711 use(node.value);
1696 assignVariable(variableNames.getName(node.receiver), pop()); 1712 assignVariable(variableNames.getName(node.receiver), pop());
1697 } 1713 }
1698 1714
1699 void registerForeignTypes(HForeign node) { 1715 void registerForeignTypes(HForeign node) {
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 js.PropertyAccess accessHelper(String name) { 2685 js.PropertyAccess accessHelper(String name) {
2670 Element helper = compiler.findHelper(name); 2686 Element helper = compiler.findHelper(name);
2671 if (helper == null) { 2687 if (helper == null) {
2672 // For mocked-up tests. 2688 // For mocked-up tests.
2673 return js.js('(void 0).$name'); 2689 return js.js('(void 0).$name');
2674 } 2690 }
2675 world.registerStaticUse(helper); 2691 world.registerStaticUse(helper);
2676 return backend.namer.elementAccess(helper); 2692 return backend.namer.elementAccess(helper);
2677 } 2693 }
2678 } 2694 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698