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

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

Issue 10345003: Temporary fix for GrowableArray type arguments: use the type arguments stores in GrowableArray inst… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « no previous file | runtime/vm/code_generator_ia32.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) 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (!tp_argument.IsType()) { 473 if (!tp_argument.IsType()) {
474 // E.g, it is TypeParameter. 474 // E.g, it is TypeParameter.
475 return; 475 return;
476 } 476 }
477 ASSERT(tp_argument.HasResolvedTypeClass()); 477 ASSERT(tp_argument.HasResolvedTypeClass());
478 } 478 }
479 } 479 }
480 AbstractTypeArguments& instance_type_arguments = 480 AbstractTypeArguments& instance_type_arguments =
481 AbstractTypeArguments::Handle(); 481 AbstractTypeArguments::Handle();
482 const Class& instance_class = Class::Handle(instance.clazz()); 482 const Class& instance_class = Class::Handle(instance.clazz());
483 AbstractTypeArguments& original_instance_type_arguments =
484 AbstractTypeArguments::Handle();
483 if (instance_class.HasTypeArguments()) { 485 if (instance_class.HasTypeArguments()) {
486 original_instance_type_arguments = instance.GetTypeArguments();
484 OptimizeTypeArguments(instance); 487 OptimizeTypeArguments(instance);
485 instance_type_arguments = instance.GetTypeArguments(); 488 instance_type_arguments = instance.GetTypeArguments();
486 } 489 }
487 490
488 DartFrameIterator iterator; 491 DartFrameIterator iterator;
489 StackFrame* caller_frame = iterator.NextFrame(); 492 StackFrame* caller_frame = iterator.NextFrame();
490 ASSERT(caller_frame != NULL); 493 ASSERT(caller_frame != NULL);
491 const Code& code = Code::Handle(caller_frame->LookupDartCode()); 494 const Code& code = Code::Handle(caller_frame->LookupDartCode());
492 ASSERT(!code.IsNull()); 495 ASSERT(!code.IsNull());
493 uword loc = code.GetTypeTestAtNodeId(node_id); 496 uword loc = code.GetTypeTestAtNodeId(node_id);
494 if (loc != 0) { 497 if (loc != 0) {
495 // Found type test cache. 498 // Found type test cache.
496 Array& cache = Array::Handle(CodePatcher::GetTypeTestArray(loc)); 499 Array& cache = Array::Handle(CodePatcher::GetTypeTestArray(loc));
497 // TODO(srdjan): Prevent type test cache from growing too much, it has been 500 // TODO(srdjan): Prevent type test cache from growing too much, it has been
498 // observed to grow to 100 elements. 501 // observed to grow to 100 elements.
499 // Don't enter duplicate entries. 502 // Don't enter duplicate entries.
500 // TODO(srdjan): Check instantiator type arguments as well. 503 // TODO(srdjan): Check instantiator type arguments as well.
501 Object& last_instance_class = Object::Handle(); 504 Object& last_instance_class = Object::Handle();
502 Object& last_instance_type_arguments = Object::Handle(); 505 Object& last_instance_type_arguments = Object::Handle();
506 // Check for duplicate entries (can happen if we optimized type arguments
507 // above).
503 for (intptr_t i = 0; i < cache.Length(); 508 for (intptr_t i = 0; i < cache.Length();
504 i += SubTypeTestCache::kNumEntries) { 509 i += SubTypeTestCache::kNumEntries) {
505 last_instance_class = cache.At(i + SubTypeTestCache::kInstanceClass); 510 last_instance_class = cache.At(i + SubTypeTestCache::kInstanceClass);
506 last_instance_type_arguments = 511 last_instance_type_arguments =
507 cache.At(i + SubTypeTestCache::kInstanceTypeArguments); 512 cache.At(i + SubTypeTestCache::kInstanceTypeArguments);
508 if ((last_instance_class.raw() == instance_class.raw()) && 513 if ((last_instance_class.raw() == instance_class.raw()) &&
509 (last_instance_type_arguments.raw() == 514 (last_instance_type_arguments.raw() ==
510 instance_type_arguments.raw())) { 515 instance_type_arguments.raw())) {
511 if (FLAG_trace_type_checks) { 516 if (FLAG_trace_type_checks &&
517 (original_instance_type_arguments.raw() ==
518 instance_type_arguments.raw())) {
512 PrintTypeCheck("WARNING duplicate cache entry", instance, type, 519 PrintTypeCheck("WARNING duplicate cache entry", instance, type,
513 type_instantiator, result); 520 type_instantiator, result);
514 } 521 }
515 return; 522 return;
516 } 523 }
517 } 524 }
518 525
519 // Array must be null terminated. 526 // Array must be null terminated.
520 ASSERT(last_instance_class.IsNull()); 527 ASSERT(last_instance_class.IsNull());
521 ASSERT(!cache.IsNull()); 528 ASSERT(!cache.IsNull());
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 } 1571 }
1565 } 1572 }
1566 } 1573 }
1567 // The cache is null terminated, therefore the loop above should never 1574 // The cache is null terminated, therefore the loop above should never
1568 // terminate by itself. 1575 // terminate by itself.
1569 UNREACHABLE(); 1576 UNREACHABLE();
1570 return Code::null(); 1577 return Code::null();
1571 } 1578 }
1572 1579
1573 } // namespace dart 1580 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698