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

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

Issue 10823022: Improve static type propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 2515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 Error* malformed_error) const { 2526 Error* malformed_error) const {
2527 ASSERT(IsFinalized()); 2527 ASSERT(IsFinalized());
2528 ASSERT(other.IsFinalized()); 2528 ASSERT(other.IsFinalized());
2529 // In case the type checked in a type test is malformed, the code generator 2529 // In case the type checked in a type test is malformed, the code generator
2530 // may compile a throw instead of a run time call performing the type check. 2530 // may compile a throw instead of a run time call performing the type check.
2531 // However, in checked mode, a function type may include malformed result type 2531 // However, in checked mode, a function type may include malformed result type
2532 // and/or malformed parameter types, which will then be encountered here at 2532 // and/or malformed parameter types, which will then be encountered here at
2533 // run time. 2533 // run time.
2534 if (IsMalformed()) { 2534 if (IsMalformed()) {
2535 ASSERT(FLAG_enable_type_checks); 2535 ASSERT(FLAG_enable_type_checks);
2536 if (malformed_error->IsNull()) { 2536 if ((malformed_error != NULL) && malformed_error->IsNull()) {
2537 *malformed_error = this->malformed_error(); 2537 *malformed_error = this->malformed_error();
2538 } 2538 }
2539 return false; 2539 return false;
2540 } 2540 }
2541 if (other.IsMalformed()) { 2541 if (other.IsMalformed()) {
2542 ASSERT(FLAG_enable_type_checks); 2542 ASSERT(FLAG_enable_type_checks);
2543 if (malformed_error->IsNull()) { 2543 if ((malformed_error != NULL) && malformed_error->IsNull()) {
2544 *malformed_error = other.malformed_error(); 2544 *malformed_error = other.malformed_error();
2545 } 2545 }
2546 return false; 2546 return false;
2547 } 2547 }
2548 // AbstractType parameters cannot be handled by Class::TypeTest(). 2548 // AbstractType parameters cannot be handled by Class::TypeTest().
2549 // When comparing two uninstantiated function types, one returning type 2549 // When comparing two uninstantiated function types, one returning type
2550 // parameter K, the other returning type parameter V, we cannot assume that K 2550 // parameter K, the other returning type parameter V, we cannot assume that K
2551 // is a subtype of V, or vice versa. We only return true if K == V, i.e. if 2551 // is a subtype of V, or vice versa. We only return true if K == V, i.e. if
2552 // they have the same index (both are finalized, so their indices are 2552 // they have the same index (both are finalized, so their indices are
2553 // comparable). 2553 // comparable).
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 Error& malformed_bound_error = Error::Handle(); 3302 Error& malformed_bound_error = Error::Handle();
3303 if (bound.IsMalformed()) { 3303 if (bound.IsMalformed()) {
3304 malformed_bound_error = bound.malformed_error(); 3304 malformed_bound_error = bound.malformed_error();
3305 } else if (!bound.IsInstantiated()) { 3305 } else if (!bound.IsInstantiated()) {
3306 bound = bound.InstantiateFrom(bounds_instantiator); 3306 bound = bound.InstantiateFrom(bounds_instantiator);
3307 } 3307 }
3308 if (!malformed_bound_error.IsNull() || 3308 if (!malformed_bound_error.IsNull() ||
3309 !this_type_arg.IsSubtypeOf(bound, malformed_error)) { 3309 !this_type_arg.IsSubtypeOf(bound, malformed_error)) {
3310 // Ignore this bound error if another malformed error was already 3310 // Ignore this bound error if another malformed error was already
3311 // reported for this type test. 3311 // reported for this type test.
3312 if (malformed_error->IsNull()) { 3312 if ((malformed_error != NULL) && malformed_error->IsNull()) {
3313 const String& type_arg_name = 3313 const String& type_arg_name =
3314 String::Handle(this_type_arg.UserVisibleName()); 3314 String::Handle(this_type_arg.UserVisibleName());
3315 const String& class_name = String::Handle(cls.Name()); 3315 const String& class_name = String::Handle(cls.Name());
3316 const String& bound_name = String::Handle(bound.UserVisibleName()); 3316 const String& bound_name = String::Handle(bound.UserVisibleName());
3317 const Script& script = Script::Handle(cls.script()); 3317 const Script& script = Script::Handle(cls.script());
3318 // Since the bound was canonicalized, its token index was lost, 3318 // Since the bound was canonicalized, its token index was lost,
3319 // therefore, use the token index of the corresponding type parameter. 3319 // therefore, use the token index of the corresponding type parameter.
3320 *malformed_error ^= FormatError(malformed_bound_error, 3320 *malformed_error ^= FormatError(malformed_bound_error,
3321 script, cls_type_param.token_pos(), 3321 script, cls_type_param.token_pos(),
3322 "type argument '%s' does not " 3322 "type argument '%s' does not "
(...skipping 7447 matching lines...) Expand 10 before | Expand all | Expand 10 after
10770 const String& str = String::Handle(pattern()); 10770 const String& str = String::Handle(pattern());
10771 const char* format = "JSRegExp: pattern=%s flags=%s"; 10771 const char* format = "JSRegExp: pattern=%s flags=%s";
10772 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10772 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10773 char* chars = reinterpret_cast<char*>( 10773 char* chars = reinterpret_cast<char*>(
10774 Isolate::Current()->current_zone()->Allocate(len + 1)); 10774 Isolate::Current()->current_zone()->Allocate(len + 1));
10775 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10775 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10776 return chars; 10776 return chars;
10777 } 10777 }
10778 10778
10779 } // namespace dart 10779 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698