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

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

Issue 883263004: Allows turning on checked mode on a per-isolate basis (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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/isolate.cc ('k') | runtime/vm/parser.cc » ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 5852 matching lines...) Expand 10 before | Expand all | Expand 10 after
5863 const char* Function::ToQualifiedCString() const { 5863 const char* Function::ToQualifiedCString() const {
5864 char* chars = NULL; 5864 char* chars = NULL;
5865 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false, 5865 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false,
5866 kQualifiedFunctionLibKindLibUrl); 5866 kQualifiedFunctionLibKindLibUrl);
5867 return chars; 5867 return chars;
5868 } 5868 }
5869 5869
5870 5870
5871 bool Function::HasCompatibleParametersWith(const Function& other, 5871 bool Function::HasCompatibleParametersWith(const Function& other,
5872 Error* bound_error) const { 5872 Error* bound_error) const {
5873 ASSERT(FLAG_error_on_bad_override); 5873 ASSERT(Isolate::Current()->ErrorOnBadOverrideEnabled());
5874 ASSERT((bound_error != NULL) && bound_error->IsNull()); 5874 ASSERT((bound_error != NULL) && bound_error->IsNull());
5875 // Check that this function's signature type is a subtype of the other 5875 // Check that this function's signature type is a subtype of the other
5876 // function's signature type. 5876 // function's signature type.
5877 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(), 5877 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(),
5878 other, Object::null_type_arguments(), bound_error)) { 5878 other, Object::null_type_arguments(), bound_error)) {
5879 // For more informative error reporting, use the location of the other 5879 // For more informative error reporting, use the location of the other
5880 // function here, since the caller will use the location of this function. 5880 // function here, since the caller will use the location of this function.
5881 *bound_error = LanguageError::NewFormatted( 5881 *bound_error = LanguageError::NewFormatted(
5882 *bound_error, // A bound error if non null. 5882 *bound_error, // A bound error if non null.
5883 Script::Handle(other.script()), 5883 Script::Handle(other.script()),
(...skipping 7668 matching lines...) Expand 10 before | Expand all | Expand 10 after
13552 ASSERT(type_arguments.IsNull() || 13552 ASSERT(type_arguments.IsNull() ||
13553 (type_arguments.Length() >= cls.NumTypeArguments())); 13553 (type_arguments.Length() >= cls.NumTypeArguments()));
13554 } 13554 }
13555 Class& other_class = Class::Handle(isolate); 13555 Class& other_class = Class::Handle(isolate);
13556 TypeArguments& other_type_arguments = TypeArguments::Handle(isolate); 13556 TypeArguments& other_type_arguments = TypeArguments::Handle(isolate);
13557 // Note that we may encounter a bound error in checked mode. 13557 // Note that we may encounter a bound error in checked mode.
13558 if (!other.IsInstantiated()) { 13558 if (!other.IsInstantiated()) {
13559 const AbstractType& instantiated_other = AbstractType::Handle( 13559 const AbstractType& instantiated_other = AbstractType::Handle(
13560 isolate, other.InstantiateFrom(other_instantiator, bound_error)); 13560 isolate, other.InstantiateFrom(other_instantiator, bound_error));
13561 if ((bound_error != NULL) && !bound_error->IsNull()) { 13561 if ((bound_error != NULL) && !bound_error->IsNull()) {
13562 ASSERT(FLAG_enable_type_checks); 13562 ASSERT(Isolate::Current()->TypeChecksEnabled());
13563 return false; 13563 return false;
13564 } 13564 }
13565 other_class = instantiated_other.type_class(); 13565 other_class = instantiated_other.type_class();
13566 other_type_arguments = instantiated_other.arguments(); 13566 other_type_arguments = instantiated_other.arguments();
13567 } else { 13567 } else {
13568 other_class = other.type_class(); 13568 other_class = other.type_class();
13569 other_type_arguments = other.arguments(); 13569 other_type_arguments = other.arguments();
13570 } 13570 }
13571 return cls.IsSubtypeOf(type_arguments, other_class, other_type_arguments, 13571 return cls.IsSubtypeOf(type_arguments, other_class, other_type_arguments,
13572 bound_error); 13572 bound_error);
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
14221 // more specific than test. 14221 // more specific than test.
14222 ASSERT(test_kind == kIsMoreSpecificThan); 14222 ASSERT(test_kind == kIsMoreSpecificThan);
14223 return false; 14223 return false;
14224 } 14224 }
14225 // In case the type checked in a type test is malbounded, the code generator 14225 // In case the type checked in a type test is malbounded, the code generator
14226 // may compile a throw instead of a run time call performing the type check. 14226 // may compile a throw instead of a run time call performing the type check.
14227 // However, in checked mode, a function type may include malbounded result 14227 // However, in checked mode, a function type may include malbounded result
14228 // type and/or malbounded parameter types, which will then be encountered here 14228 // type and/or malbounded parameter types, which will then be encountered here
14229 // at run time. 14229 // at run time.
14230 if (IsMalbounded()) { 14230 if (IsMalbounded()) {
14231 ASSERT(FLAG_enable_type_checks); 14231 ASSERT(Isolate::Current()->TypeChecksEnabled());
14232 if ((bound_error != NULL) && bound_error->IsNull()) { 14232 if ((bound_error != NULL) && bound_error->IsNull()) {
14233 *bound_error = error(); 14233 *bound_error = error();
14234 } 14234 }
14235 return false; 14235 return false;
14236 } 14236 }
14237 if (other.IsMalbounded()) { 14237 if (other.IsMalbounded()) {
14238 ASSERT(FLAG_enable_type_checks); 14238 ASSERT(Isolate::Current()->TypeChecksEnabled());
14239 if ((bound_error != NULL) && bound_error->IsNull()) { 14239 if ((bound_error != NULL) && bound_error->IsNull()) {
14240 *bound_error = other.error(); 14240 *bound_error = other.error();
14241 } 14241 }
14242 return false; 14242 return false;
14243 } 14243 }
14244 if (IsBoundedType() || other.IsBoundedType()) { 14244 if (IsBoundedType() || other.IsBoundedType()) {
14245 if (Equals(other)) { 14245 if (Equals(other)) {
14246 return true; 14246 return true;
14247 } 14247 }
14248 return false; // TODO(regis): We should return "maybe after instantiation". 14248 return false; // TODO(regis): We should return "maybe after instantiation".
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
14435 bool Type::IsMalformed() const { 14435 bool Type::IsMalformed() const {
14436 if (raw_ptr()->error_ == LanguageError::null()) { 14436 if (raw_ptr()->error_ == LanguageError::null()) {
14437 return false; 14437 return false;
14438 } 14438 }
14439 const LanguageError& type_error = LanguageError::Handle(error()); 14439 const LanguageError& type_error = LanguageError::Handle(error());
14440 return type_error.kind() == Report::kMalformedType; 14440 return type_error.kind() == Report::kMalformedType;
14441 } 14441 }
14442 14442
14443 14443
14444 bool Type::IsMalbounded() const { 14444 bool Type::IsMalbounded() const {
14445 if (!FLAG_enable_type_checks) { 14445 if (!Isolate::Current()->TypeChecksEnabled()) {
14446 return false; 14446 return false;
14447 } 14447 }
14448 if (raw_ptr()->error_ == LanguageError::null()) { 14448 if (raw_ptr()->error_ == LanguageError::null()) {
14449 return false; 14449 return false;
14450 } 14450 }
14451 const LanguageError& type_error = LanguageError::Handle(error()); 14451 const LanguageError& type_error = LanguageError::Handle(error());
14452 return type_error.kind() == Report::kMalboundedType; 14452 return type_error.kind() == Report::kMalboundedType;
14453 } 14453 }
14454 14454
14455 14455
14456 bool Type::IsMalformedOrMalbounded() const { 14456 bool Type::IsMalformedOrMalbounded() const {
14457 if (raw_ptr()->error_ == LanguageError::null()) { 14457 if (raw_ptr()->error_ == LanguageError::null()) {
14458 return false; 14458 return false;
14459 } 14459 }
14460 const LanguageError& type_error = LanguageError::Handle(error()); 14460 const LanguageError& type_error = LanguageError::Handle(error());
14461 if (type_error.kind() == Report::kMalformedType) { 14461 if (type_error.kind() == Report::kMalformedType) {
14462 return true; 14462 return true;
14463 } 14463 }
14464 ASSERT(type_error.kind() == Report::kMalboundedType); 14464 ASSERT(type_error.kind() == Report::kMalboundedType);
14465 return FLAG_enable_type_checks; 14465 return Isolate::Current()->TypeChecksEnabled();
14466 } 14466 }
14467 14467
14468 14468
14469 void Type::set_error(const LanguageError& value) const { 14469 void Type::set_error(const LanguageError& value) const {
14470 StorePointer(&raw_ptr()->error_, value.raw()); 14470 StorePointer(&raw_ptr()->error_, value.raw());
14471 } 14471 }
14472 14472
14473 14473
14474 void Type::set_is_resolved() const { 14474 void Type::set_is_resolved() const {
14475 ASSERT(!IsResolved()); 14475 ASSERT(!IsResolved());
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
15432 const TypeArguments& instantiator_type_arguments, 15432 const TypeArguments& instantiator_type_arguments,
15433 Error* bound_error, 15433 Error* bound_error,
15434 GrowableObjectArray* trail) const { 15434 GrowableObjectArray* trail) const {
15435 ASSERT(IsFinalized()); 15435 ASSERT(IsFinalized());
15436 AbstractType& bounded_type = AbstractType::Handle(type()); 15436 AbstractType& bounded_type = AbstractType::Handle(type());
15437 if (!bounded_type.IsInstantiated()) { 15437 if (!bounded_type.IsInstantiated()) {
15438 bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments, 15438 bounded_type = bounded_type.InstantiateFrom(instantiator_type_arguments,
15439 bound_error, 15439 bound_error,
15440 trail); 15440 trail);
15441 } 15441 }
15442 if (FLAG_enable_type_checks && 15442 if ((Isolate::Current()->TypeChecksEnabled()) &&
15443 (bound_error != NULL) && bound_error->IsNull()) { 15443 (bound_error != NULL) && bound_error->IsNull()) {
15444 AbstractType& upper_bound = AbstractType::Handle(bound()); 15444 AbstractType& upper_bound = AbstractType::Handle(bound());
15445 ASSERT(!upper_bound.IsObjectType() && !upper_bound.IsDynamicType()); 15445 ASSERT(!upper_bound.IsObjectType() && !upper_bound.IsDynamicType());
15446 const TypeParameter& type_param = TypeParameter::Handle(type_parameter()); 15446 const TypeParameter& type_param = TypeParameter::Handle(type_parameter());
15447 if (!upper_bound.IsInstantiated()) { 15447 if (!upper_bound.IsInstantiated()) {
15448 upper_bound = upper_bound.InstantiateFrom(instantiator_type_arguments, 15448 upper_bound = upper_bound.InstantiateFrom(instantiator_type_arguments,
15449 bound_error, 15449 bound_error,
15450 trail); 15450 trail);
15451 } 15451 }
15452 if (bound_error->IsNull()) { 15452 if (bound_error->IsNull()) {
(...skipping 5112 matching lines...) Expand 10 before | Expand all | Expand 10 after
20565 return tag_label.ToCString(); 20565 return tag_label.ToCString();
20566 } 20566 }
20567 20567
20568 20568
20569 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20569 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20570 Instance::PrintJSONImpl(stream, ref); 20570 Instance::PrintJSONImpl(stream, ref);
20571 } 20571 }
20572 20572
20573 20573
20574 } // namespace dart 20574 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698