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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 14703005: Added Object._cid getter, optimized it. Added to (some) classes a static final _clCid. Use those to… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/intermediate_language.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1409
1410 ConstantInstr* zero = flow_graph()->GetConstant(Smi::Handle(Smi::New(0))); 1410 ConstantInstr* zero = flow_graph()->GetConstant(Smi::Handle(Smi::New(0)));
1411 StrictCompareInstr* compare = 1411 StrictCompareInstr* compare =
1412 new StrictCompareInstr(Token::kEQ_STRICT, 1412 new StrictCompareInstr(Token::kEQ_STRICT,
1413 new Value(load), 1413 new Value(load),
1414 new Value(zero)); 1414 new Value(zero));
1415 ReplaceCall(call, compare); 1415 ReplaceCall(call, compare);
1416 } 1416 }
1417 1417
1418 1418
1419 void FlowGraphOptimizer::InlineObjectCid(InstanceCallInstr* call) {
1420 LoadClassIdInstr* load = new LoadClassIdInstr(new Value(call->ArgumentAt(0)));
1421 ReplaceCall(call, load);
1422 }
1423
1424
1419 static intptr_t OffsetForLengthGetter(MethodRecognizer::Kind kind) { 1425 static intptr_t OffsetForLengthGetter(MethodRecognizer::Kind kind) {
1420 switch (kind) { 1426 switch (kind) {
1421 case MethodRecognizer::kObjectArrayLength: 1427 case MethodRecognizer::kObjectArrayLength:
1422 case MethodRecognizer::kImmutableArrayLength: 1428 case MethodRecognizer::kImmutableArrayLength:
1423 return Array::length_offset(); 1429 return Array::length_offset();
1424 case MethodRecognizer::kTypedDataLength: 1430 case MethodRecognizer::kTypedDataLength:
1425 // .length is defined in _TypedList which is the base class for internal 1431 // .length is defined in _TypedList which is the base class for internal
1426 // and external typed data. 1432 // and external typed data.
1427 ASSERT(TypedData::length_offset() == ExternalTypedData::length_offset()); 1433 ASSERT(TypedData::length_offset() == ExternalTypedData::length_offset());
1428 return TypedData::length_offset(); 1434 return TypedData::length_offset();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 } else if (target.kind() == RawFunction::kMethodExtractor) { 1494 } else if (target.kind() == RawFunction::kMethodExtractor) {
1489 return false; 1495 return false;
1490 } 1496 }
1491 1497
1492 // Not an implicit getter. 1498 // Not an implicit getter.
1493 MethodRecognizer::Kind recognized_kind = 1499 MethodRecognizer::Kind recognized_kind =
1494 MethodRecognizer::RecognizeKind(target); 1500 MethodRecognizer::RecognizeKind(target);
1495 1501
1496 // VM objects length getter. 1502 // VM objects length getter.
1497 switch (recognized_kind) { 1503 switch (recognized_kind) {
1504 case MethodRecognizer::kObjectCid: {
1505 InlineObjectCid(call);
1506 return true;
1507 }
1498 case MethodRecognizer::kObjectArrayLength: 1508 case MethodRecognizer::kObjectArrayLength:
1499 case MethodRecognizer::kImmutableArrayLength: 1509 case MethodRecognizer::kImmutableArrayLength:
1500 case MethodRecognizer::kTypedDataLength: 1510 case MethodRecognizer::kTypedDataLength:
1501 case MethodRecognizer::kGrowableArrayLength: { 1511 case MethodRecognizer::kGrowableArrayLength: {
1502 if (!ic_data.HasOneTarget()) { 1512 if (!ic_data.HasOneTarget()) {
1503 // TODO(srdjan): Implement for mutiple targets. 1513 // TODO(srdjan): Implement for mutiple targets.
1504 return false; 1514 return false;
1505 } 1515 }
1506 const bool is_immutable = 1516 const bool is_immutable =
1507 (recognized_kind == MethodRecognizer::kObjectArrayLength) || 1517 (recognized_kind == MethodRecognizer::kObjectArrayLength) ||
(...skipping 4988 matching lines...) Expand 10 before | Expand all | Expand 10 after
6496 6506
6497 // Insert materializations at environment uses. 6507 // Insert materializations at environment uses.
6498 const Class& cls = Class::Handle(alloc->constructor().Owner()); 6508 const Class& cls = Class::Handle(alloc->constructor().Owner());
6499 for (intptr_t i = 0; i < exits.length(); i++) { 6509 for (intptr_t i = 0; i < exits.length(); i++) {
6500 CreateMaterializationAt(exits[i], alloc, cls, *fields); 6510 CreateMaterializationAt(exits[i], alloc, cls, *fields);
6501 } 6511 }
6502 } 6512 }
6503 6513
6504 6514
6505 } // namespace dart 6515 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698