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

Side by Side Diff: lib/compiler/implementation/ssa/nodes.dart

Issue 10831154: Make field-get/set work without elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
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 interface HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBailoutTarget(HBailoutTarget node); 7 R visitBailoutTarget(HBailoutTarget node);
8 R visitBitAnd(HBitAnd node); 8 R visitBitAnd(HBitAnd node);
9 R visitBitNot(HBitNot node); 9 R visitBitNot(HBitNot node);
10 R visitBitOr(HBitOr node); 10 R visitBitOr(HBitOr node);
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 1301
1302 int typeCode() => 4; 1302 int typeCode() => 4;
1303 bool typeEquals(other) => other is HInvokeInterceptor; 1303 bool typeEquals(other) => other is HInvokeInterceptor;
1304 bool dataEquals(HInvokeInterceptor other) { 1304 bool dataEquals(HInvokeInterceptor other) {
1305 return getter == other.getter && name == other.name; 1305 return getter == other.getter && name == other.name;
1306 } 1306 }
1307 } 1307 }
1308 1308
1309 abstract class HFieldAccess extends HInstruction { 1309 abstract class HFieldAccess extends HInstruction {
1310 final Element element; 1310 final Element element;
1311 final SourceString fieldName;
1312 final LibraryElement libraryElement;
kasperl 2012/08/07 08:14:20 Maybe shorten this to library?
floitsch 2012/08/07 12:20:16 Done.
1311 1313
1312 HFieldAccess(this.element, List<HInstruction> inputs) : super(inputs); 1314 HFieldAccess(this.fieldName, this.libraryElement, List<HInstruction> inputs)
1315 : element = null, super(inputs);
1316
1317 HFieldAccess.withElement(Element element, List<HInstruction> inputs)
1318 : this.element = element,
1319 fieldName = element.name,
1320 libraryElement = element.getLibrary(),
1321 super(inputs);
1313 } 1322 }
1314 1323
1315 class HFieldGet extends HFieldAccess { 1324 class HFieldGet extends HFieldAccess {
1316 final bool isFinalOrConst; 1325 final bool isFinalOrConst;
1317 1326
1318 HFieldGet(Element element, HInstruction receiver, 1327 HFieldGet(SourceString name, LibraryElement library, HInstruction receiver,
1319 [this.isFinalOrConst = false]) 1328 [this.isFinalOrConst = false])
1320 : super(element, <HInstruction>[receiver]); 1329 : super(name, library, <HInstruction>[receiver]);
1330
1331 HFieldGet.withElement(Element element, HInstruction receiver,
1332 [this.isFinalOrConst = false])
1333 : super.withElement(element, <HInstruction>[receiver]);
1321 1334
1322 HInstruction get receiver() => inputs[0]; 1335 HInstruction get receiver() => inputs[0];
1323 1336
1324 accept(HVisitor visitor) => visitor.visitFieldGet(this); 1337 accept(HVisitor visitor) => visitor.visitFieldGet(this);
1325 1338
1326 void prepareGvn() { 1339 void prepareGvn() {
1327 setUseGvn(); 1340 setUseGvn();
1328 clearAllSideEffects(); 1341 clearAllSideEffects();
1329 if (!isFinalOrConst) setDependsOnSomething(); 1342 if (!isFinalOrConst) setDependsOnSomething();
1330 } 1343 }
1331 1344
1332 int typeCode() => 27; 1345 int typeCode() => 27;
1333 bool typeEquals(other) => other is HFieldGet; 1346 bool typeEquals(other) => other is HFieldGet;
1334 bool dataEquals(HFieldGet other) => element == other.element; 1347 bool dataEquals(HFieldGet other) => element == other.element;
1335 String toString() => "FieldGet $element"; 1348 String toString() => "FieldGet ${element == null ? fieldName : element}";
1336 } 1349 }
1337 1350
1338 class HFieldSet extends HFieldAccess { 1351 class HFieldSet extends HFieldAccess {
1339 HFieldSet(Element element, HInstruction receiver, HInstruction value) 1352 HFieldSet(SourceString name,
1340 : super(element, <HInstruction>[receiver, value]); 1353 LibraryElement library,
1354 HInstruction receiver,
1355 HInstruction value)
1356 : super(name, library, <HInstruction>[receiver, value]);
1357
1358 HFieldSet.withElement(Element element,
1359 HInstruction receiver,
1360 HInstruction value)
1361 : super.withElement(element, <HInstruction>[receiver, value]);
1341 1362
1342 HInstruction get receiver() => inputs[0]; 1363 HInstruction get receiver() => inputs[0];
1343 HInstruction get value() => inputs[1]; 1364 HInstruction get value() => inputs[1];
1344 accept(HVisitor visitor) => visitor.visitFieldSet(this); 1365 accept(HVisitor visitor) => visitor.visitFieldSet(this);
1345 1366
1346 void prepareGvn() { 1367 void prepareGvn() {
1347 // TODO(ngeoffray): implement more fine grained side effects. 1368 // TODO(ngeoffray): implement more fine grained side effects.
1348 setAllSideEffects(); 1369 setAllSideEffects();
1349 } 1370 }
1350 1371
1351 final bool isStatement = true; 1372 final bool isStatement = true;
1352 String toString() => "FieldSet $element"; 1373 String toString() => "FieldSet ${element == null ? fieldName : element}";
1353 } 1374 }
1354 1375
1355 class HLocalGet extends HFieldGet { 1376 class HLocalGet extends HFieldGet {
1356 HLocalGet(Element element, HLocalValue local) : super(element, local); 1377 HLocalGet(Element element, HLocalValue local)
1378 : super.withElement(element, local);
1357 1379
1358 accept(HVisitor visitor) => visitor.visitLocalGet(this); 1380 accept(HVisitor visitor) => visitor.visitLocalGet(this);
1359 1381
1360 HLocalValue get local() => inputs[0]; 1382 HLocalValue get local() => inputs[0];
1361 1383
1362 void prepareGvn() { 1384 void prepareGvn() {
1363 setUseGvn(); 1385 setUseGvn();
1364 // TODO(floitsch): if the variable is not captured then it only depends 1386 // TODO(floitsch): if the variable is not captured then it only depends
1365 // on assignments to the same variable. Otherwise we need to see if the 1387 // on assignments to the same variable. Otherwise we need to see if the
1366 // variable is mutated inside closures. 1388 // variable is mutated inside closures.
1367 setDependsOnSomething(); 1389 setDependsOnSomething();
1368 } 1390 }
1369 } 1391 }
1370 1392
1371 class HLocalSet extends HFieldSet { 1393 class HLocalSet extends HFieldSet {
1372 HLocalSet(Element element, HLocalValue local, HInstruction value) 1394 HLocalSet(Element element, HLocalValue local, HInstruction value)
1373 : super(element, local, value); 1395 : super.withElement(element, local, value);
1374 1396
1375 accept(HVisitor visitor) => visitor.visitLocalSet(this); 1397 accept(HVisitor visitor) => visitor.visitLocalSet(this);
1376 1398
1377 HLocalValue get local() => inputs[0]; 1399 HLocalValue get local() => inputs[0];
1378 1400
1379 void prepareGvn() { 1401 void prepareGvn() {
1380 // TODO(floitsch): implement more fine grained side effects. 1402 // TODO(floitsch): implement more fine grained side effects.
1381 setAllSideEffects(); 1403 setAllSideEffects();
1382 } 1404 }
1383 } 1405 }
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 HBasicBlock get start() => expression.start; 2705 HBasicBlock get start() => expression.start;
2684 HBasicBlock get end() { 2706 HBasicBlock get end() {
2685 // We don't create a switch block if there are no cases. 2707 // We don't create a switch block if there are no cases.
2686 assert(!statements.isEmpty()); 2708 assert(!statements.isEmpty());
2687 return statements.last().end; 2709 return statements.last().end;
2688 } 2710 }
2689 2711
2690 bool accept(HStatementInformationVisitor visitor) => 2712 bool accept(HStatementInformationVisitor visitor) =>
2691 visitor.visitSwitchInfo(this); 2713 visitor.visitSwitchInfo(this);
2692 } 2714 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698