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

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

Issue 10830339: Propagate class ids using existing type propagation framework. (Closed) Base URL: http://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
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | 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 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 if (other->use_list() != NULL) { 315 if (other->use_list() != NULL) {
316 current->next_use_ = other->use_list(); 316 current->next_use_ = other->use_list();
317 other->use_list()->previous_use_ = current; 317 other->use_list()->previous_use_ = current;
318 } 318 }
319 other->set_use_list(head); 319 other->set_use_list(head);
320 set_use_list(NULL); 320 set_use_list(NULL);
321 } 321 }
322 322
323 323
324 bool Definition::SetPropagatedCid(intptr_t cid) {
325 ASSERT(cid != 1);
regis 2012/08/16 16:02:47 What does 1 mean?
srdjan 2012/08/16 18:00:56 Debugging remainder. Thanks for catching it
326 ASSERT(cid != kIllegalCid);
327 if (propagated_cid_ == kIllegalCid) {
328 // First setting, nothing has changed.
329 propagated_cid_ = cid;
330 return false;
331 }
332 bool has_changed = (propagated_cid_ != cid);
333 propagated_cid_ = cid;
334 return has_changed;
335 }
336
324 RawAbstractType* BindInstr::CompileType() const { 337 RawAbstractType* BindInstr::CompileType() const {
325 ASSERT(!HasPropagatedType()); 338 ASSERT(!HasPropagatedType());
326 // The compile type may be requested when building the flow graph, i.e. before 339 // The compile type may be requested when building the flow graph, i.e. before
327 // type propagation has occurred. 340 // type propagation has occurred.
328 return computation()->CompileType(); 341 return computation()->CompileType();
329 } 342 }
330 343
331 344
345 intptr_t BindInstr::GetPropagatedCid() {
346 if (has_propagated_cid()) return propagated_cid();
347 intptr_t cid = computation()->ResultCid();
348 ASSERT(cid != kIllegalCid);
349 SetPropagatedCid(cid);
350 return cid;
351 }
352
332 void BindInstr::RecordAssignedVars(BitVector* assigned_vars, 353 void BindInstr::RecordAssignedVars(BitVector* assigned_vars,
333 intptr_t fixed_parameter_count) { 354 intptr_t fixed_parameter_count) {
334 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count); 355 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count);
335 } 356 }
336 357
337 358
338 // ==== Postorder graph traversal. 359 // ==== Postorder graph traversal.
339 void GraphEntryInstr::DiscoverBlocks( 360 void GraphEntryInstr::DiscoverBlocks(
340 BlockEntryInstr* current_block, 361 BlockEntryInstr* current_block,
341 GrowableArray<BlockEntryInstr*>* preorder, 362 GrowableArray<BlockEntryInstr*>* preorder,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 582 }
562 if (value().IsInstance()) { 583 if (value().IsInstance()) {
563 return Instance::Cast(value()).GetType(); 584 return Instance::Cast(value()).GetType();
564 } else { 585 } else {
565 ASSERT(value().IsAbstractTypeArguments()); 586 ASSERT(value().IsAbstractTypeArguments());
566 return AbstractType::null(); 587 return AbstractType::null();
567 } 588 }
568 } 589 }
569 590
570 591
592 intptr_t ConstantVal::ResultCid() const {
593 if (value().IsNull()) {
594 return kNullCid;
595 }
596 if (value().IsInstance()) {
597 return Class::Handle(value().clazz()).id();
598 } else {
599 ASSERT(value().IsAbstractTypeArguments());
600 return kDynamicCid;
601 }
602 }
603
604
571 RawAbstractType* UseVal::CompileType() const { 605 RawAbstractType* UseVal::CompileType() const {
572 if (definition()->HasPropagatedType()) { 606 if (definition()->HasPropagatedType()) {
573 return definition()->PropagatedType(); 607 return definition()->PropagatedType();
574 } 608 }
575 // The compile type may be requested when building the flow graph, i.e. before 609 // The compile type may be requested when building the flow graph, i.e. before
576 // type propagation has occurred. To avoid repeatedly computing the compile 610 // type propagation has occurred. To avoid repeatedly computing the compile
577 // type of the definition, we store it as initial propagated type. 611 // type of the definition, we store it as initial propagated type.
578 AbstractType& type = AbstractType::Handle(definition()->CompileType()); 612 AbstractType& type = AbstractType::Handle(definition()->CompileType());
579 definition()->SetPropagatedType(type); 613 definition()->SetPropagatedType(type);
580 return type.raw(); 614 return type.raw();
581 } 615 }
582 616
583 617
618 intptr_t UseVal::ResultCid() const {
619 return definition()->GetPropagatedCid();
620 }
621
622
584 RawAbstractType* AssertAssignableComp::CompileType() const { 623 RawAbstractType* AssertAssignableComp::CompileType() const {
585 const AbstractType& value_compile_type = 624 const AbstractType& value_compile_type =
586 AbstractType::Handle(value()->CompileType()); 625 AbstractType::Handle(value()->CompileType());
587 if (!value_compile_type.IsNull() && 626 if (!value_compile_type.IsNull() &&
588 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { 627 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) {
589 return value_compile_type.raw(); 628 return value_compile_type.raw();
590 } 629 }
591 return dst_type().raw(); 630 return dst_type().raw();
592 } 631 }
593 632
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 if (compiler->is_ssa()) { 1353 if (compiler->is_ssa()) {
1315 ASSERT(locs()->in(0).IsRegister()); 1354 ASSERT(locs()->in(0).IsRegister());
1316 __ PushRegister(locs()->in(0).reg()); 1355 __ PushRegister(locs()->in(0).reg());
1317 } 1356 }
1318 } 1357 }
1319 1358
1320 1359
1321 #undef __ 1360 #undef __
1322 1361
1323 } // namespace dart 1362 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698