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

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

Issue 10134069: Inline type check where type argument that we check against is instantiated. (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') | runtime/vm/code_generator_ia32.cc » ('J')
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // inlined assembly. 387 // inlined assembly.
388 if (!type.IsInstantiated()) return; 388 if (!type.IsInstantiated()) return;
389 // TODO(srdjan): Implement assembly code for checking type arguments then 389 // TODO(srdjan): Implement assembly code for checking type arguments then
390 // remove this check. 390 // remove this check.
391 if (Class::Handle(type.type_class()).HasTypeArguments()) { 391 if (Class::Handle(type.type_class()).HasTypeArguments()) {
392 const AbstractTypeArguments& type_arguments = 392 const AbstractTypeArguments& type_arguments =
393 AbstractTypeArguments::Handle(type.arguments()); 393 AbstractTypeArguments::Handle(type.arguments());
394 const bool is_raw_type = type_arguments.IsNull() || 394 const bool is_raw_type = type_arguments.IsNull() ||
395 type_arguments.IsRaw(type_arguments.Length()); 395 type_arguments.IsRaw(type_arguments.Length());
396 if (!is_raw_type) { 396 if (!is_raw_type) {
397 return; 397 // We cannot inline tests for instances with more than one type argument
398 // or if its class has not been resolved (malformed type).
399 if (type_arguments.Length() != 1) {
400 // We can handle only one argument so far.
401 return;
402 }
403 const AbstractType& tp_argument =
404 AbstractType::ZoneHandle(type_arguments.TypeAt(0));
405 if (!tp_argument.IsType()) {
406 // E.g, it is TypeParameter.
407 return;
408 }
409 const Type& list_type =
410 Type::Handle(Isolate::Current()->object_store()->list_interface());
411 Error& malformed_error = Error::Handle();
412 if (!list_type.IsSubtypeOf(type, &malformed_error)) {
413 return;
414 }
415 // The type argument at index 0 must be instantiated and not malformed.
416 // A malformed type would have caused a type error earlier.
417 ASSERT(tp_argument.HasResolvedTypeClass());
398 } 418 }
399 } 419 }
400 DartFrameIterator iterator; 420 DartFrameIterator iterator;
401 StackFrame* caller_frame = iterator.NextFrame(); 421 StackFrame* caller_frame = iterator.NextFrame();
402 ASSERT(caller_frame != NULL); 422 ASSERT(caller_frame != NULL);
403 const Code& code = Code::Handle(caller_frame->LookupDartCode()); 423 const Code& code = Code::Handle(caller_frame->LookupDartCode());
404 ASSERT(!code.IsNull()); 424 ASSERT(!code.IsNull());
405 uword loc = code.GetTypeTestAtNodeId(node_id); 425 uword loc = code.GetTypeTestAtNodeId(node_id);
406 if (loc != 0) { 426 if (loc != 0) {
407 // Found type test cache. 427 // Found type test cache.
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 } 1486 }
1467 } 1487 }
1468 } 1488 }
1469 // The cache is null terminated, therefore the loop above should never 1489 // The cache is null terminated, therefore the loop above should never
1470 // terminate by itself. 1490 // terminate by itself.
1471 UNREACHABLE(); 1491 UNREACHABLE();
1472 return Code::null(); 1492 return Code::null();
1473 } 1493 }
1474 1494
1475 } // namespace dart 1495 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator_ia32.h » ('j') | runtime/vm/code_generator_ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698