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

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

Issue 1737693003: - Remove Isolate::Flags structure and store flags directly in isolate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 4 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
« no previous file with comments | « runtime/vm/jit_optimizer.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 5924 matching lines...) Expand 10 before | Expand all | Expand 10 after
5935 const char* Function::ToQualifiedCString() const { 5935 const char* Function::ToQualifiedCString() const {
5936 char* chars = NULL; 5936 char* chars = NULL;
5937 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false, 5937 ConstructFunctionFullyQualifiedCString(*this, &chars, 0, false,
5938 kQualifiedFunctionLibKindLibUrl); 5938 kQualifiedFunctionLibKindLibUrl);
5939 return chars; 5939 return chars;
5940 } 5940 }
5941 5941
5942 5942
5943 bool Function::HasCompatibleParametersWith(const Function& other, 5943 bool Function::HasCompatibleParametersWith(const Function& other,
5944 Error* bound_error) const { 5944 Error* bound_error) const {
5945 ASSERT(Isolate::Current()->flags().error_on_bad_override()); 5945 ASSERT(Isolate::Current()->error_on_bad_override());
5946 ASSERT((bound_error != NULL) && bound_error->IsNull()); 5946 ASSERT((bound_error != NULL) && bound_error->IsNull());
5947 // Check that this function's signature type is a subtype of the other 5947 // Check that this function's signature type is a subtype of the other
5948 // function's signature type. 5948 // function's signature type.
5949 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(), 5949 if (!TypeTest(kIsSubtypeOf, Object::null_type_arguments(),
5950 other, Object::null_type_arguments(), bound_error, 5950 other, Object::null_type_arguments(), bound_error,
5951 Heap::kOld)) { 5951 Heap::kOld)) {
5952 // For more informative error reporting, use the location of the other 5952 // For more informative error reporting, use the location of the other
5953 // function here, since the caller will use the location of this function. 5953 // function here, since the caller will use the location of this function.
5954 *bound_error = LanguageError::NewFormatted( 5954 *bound_error = LanguageError::NewFormatted(
5955 *bound_error, // A bound error if non null. 5955 *bound_error, // A bound error if non null.
(...skipping 8273 matching lines...) Expand 10 before | Expand all | Expand 10 after
14229 return true; 14229 return true;
14230 } 14230 }
14231 Function& other_signature = Function::Handle(zone); 14231 Function& other_signature = Function::Handle(zone);
14232 TypeArguments& other_type_arguments = TypeArguments::Handle(zone); 14232 TypeArguments& other_type_arguments = TypeArguments::Handle(zone);
14233 // Note that we may encounter a bound error in checked mode. 14233 // Note that we may encounter a bound error in checked mode.
14234 if (!other.IsInstantiated()) { 14234 if (!other.IsInstantiated()) {
14235 AbstractType& instantiated_other = AbstractType::Handle( 14235 AbstractType& instantiated_other = AbstractType::Handle(
14236 zone, other.InstantiateFrom(other_instantiator, bound_error, 14236 zone, other.InstantiateFrom(other_instantiator, bound_error,
14237 NULL, NULL, Heap::kOld)); 14237 NULL, NULL, Heap::kOld));
14238 if ((bound_error != NULL) && !bound_error->IsNull()) { 14238 if ((bound_error != NULL) && !bound_error->IsNull()) {
14239 ASSERT(Isolate::Current()->flags().type_checks()); 14239 ASSERT(Isolate::Current()->type_checks());
14240 return false; 14240 return false;
14241 } 14241 }
14242 if (instantiated_other.IsTypeRef()) { 14242 if (instantiated_other.IsTypeRef()) {
14243 instantiated_other = TypeRef::Cast(instantiated_other).type(); 14243 instantiated_other = TypeRef::Cast(instantiated_other).type();
14244 } 14244 }
14245 if (instantiated_other.IsDynamicType() || 14245 if (instantiated_other.IsDynamicType() ||
14246 instantiated_other.IsObjectType() || 14246 instantiated_other.IsObjectType() ||
14247 instantiated_other.IsDartFunctionType()) { 14247 instantiated_other.IsDartFunctionType()) {
14248 return true; 14248 return true;
14249 } 14249 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
14285 (type_arguments.Length() >= cls.NumTypeArguments())); 14285 (type_arguments.Length() >= cls.NumTypeArguments()));
14286 } 14286 }
14287 Class& other_class = Class::Handle(zone); 14287 Class& other_class = Class::Handle(zone);
14288 TypeArguments& other_type_arguments = TypeArguments::Handle(zone); 14288 TypeArguments& other_type_arguments = TypeArguments::Handle(zone);
14289 AbstractType& instantiated_other = AbstractType::Handle(zone, other.raw()); 14289 AbstractType& instantiated_other = AbstractType::Handle(zone, other.raw());
14290 // Note that we may encounter a bound error in checked mode. 14290 // Note that we may encounter a bound error in checked mode.
14291 if (!other.IsInstantiated()) { 14291 if (!other.IsInstantiated()) {
14292 instantiated_other = other.InstantiateFrom(other_instantiator, bound_error, 14292 instantiated_other = other.InstantiateFrom(other_instantiator, bound_error,
14293 NULL, NULL, Heap::kOld); 14293 NULL, NULL, Heap::kOld);
14294 if ((bound_error != NULL) && !bound_error->IsNull()) { 14294 if ((bound_error != NULL) && !bound_error->IsNull()) {
14295 ASSERT(Isolate::Current()->flags().type_checks()); 14295 ASSERT(Isolate::Current()->type_checks());
14296 return false; 14296 return false;
14297 } 14297 }
14298 if (instantiated_other.IsTypeRef()) { 14298 if (instantiated_other.IsTypeRef()) {
14299 instantiated_other = TypeRef::Cast(instantiated_other).type(); 14299 instantiated_other = TypeRef::Cast(instantiated_other).type();
14300 } 14300 }
14301 if (instantiated_other.IsDynamicType()) { 14301 if (instantiated_other.IsDynamicType()) {
14302 return true; 14302 return true;
14303 } 14303 }
14304 } 14304 }
14305 other_type_arguments = instantiated_other.arguments(); 14305 other_type_arguments = instantiated_other.arguments();
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
14978 // more specific than test. 14978 // more specific than test.
14979 ASSERT(test_kind == kIsMoreSpecificThan); 14979 ASSERT(test_kind == kIsMoreSpecificThan);
14980 return false; 14980 return false;
14981 } 14981 }
14982 // In case the type checked in a type test is malbounded, the code generator 14982 // In case the type checked in a type test is malbounded, the code generator
14983 // may compile a throw instead of a run time call performing the type check. 14983 // may compile a throw instead of a run time call performing the type check.
14984 // However, in checked mode, a function type may include malbounded result 14984 // However, in checked mode, a function type may include malbounded result
14985 // type and/or malbounded parameter types, which will then be encountered here 14985 // type and/or malbounded parameter types, which will then be encountered here
14986 // at run time. 14986 // at run time.
14987 if (IsMalbounded()) { 14987 if (IsMalbounded()) {
14988 ASSERT(Isolate::Current()->flags().type_checks()); 14988 ASSERT(Isolate::Current()->type_checks());
14989 if ((bound_error != NULL) && bound_error->IsNull()) { 14989 if ((bound_error != NULL) && bound_error->IsNull()) {
14990 *bound_error = error(); 14990 *bound_error = error();
14991 } 14991 }
14992 return false; 14992 return false;
14993 } 14993 }
14994 if (other.IsMalbounded()) { 14994 if (other.IsMalbounded()) {
14995 ASSERT(Isolate::Current()->flags().type_checks()); 14995 ASSERT(Isolate::Current()->type_checks());
14996 if ((bound_error != NULL) && bound_error->IsNull()) { 14996 if ((bound_error != NULL) && bound_error->IsNull()) {
14997 *bound_error = other.error(); 14997 *bound_error = other.error();
14998 } 14998 }
14999 return false; 14999 return false;
15000 } 15000 }
15001 if (other.IsObjectType() || other.IsDynamicType()) { 15001 if (other.IsObjectType() || other.IsDynamicType()) {
15002 return true; 15002 return true;
15003 } 15003 }
15004 if (IsBoundedType() || other.IsBoundedType()) { 15004 if (IsBoundedType() || other.IsBoundedType()) {
15005 if (Equals(other)) { 15005 if (Equals(other)) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
15236 bool Type::IsMalformed() const { 15236 bool Type::IsMalformed() const {
15237 if (raw_ptr()->error_ == LanguageError::null()) { 15237 if (raw_ptr()->error_ == LanguageError::null()) {
15238 return false; 15238 return false;
15239 } 15239 }
15240 const LanguageError& type_error = LanguageError::Handle(error()); 15240 const LanguageError& type_error = LanguageError::Handle(error());
15241 return type_error.kind() == Report::kMalformedType; 15241 return type_error.kind() == Report::kMalformedType;
15242 } 15242 }
15243 15243
15244 15244
15245 bool Type::IsMalbounded() const { 15245 bool Type::IsMalbounded() const {
15246 if (!Isolate::Current()->flags().type_checks()) { 15246 if (!Isolate::Current()->type_checks()) {
15247 return false; 15247 return false;
15248 } 15248 }
15249 if (raw_ptr()->error_ == LanguageError::null()) { 15249 if (raw_ptr()->error_ == LanguageError::null()) {
15250 return false; 15250 return false;
15251 } 15251 }
15252 const LanguageError& type_error = LanguageError::Handle(error()); 15252 const LanguageError& type_error = LanguageError::Handle(error());
15253 return type_error.kind() == Report::kMalboundedType; 15253 return type_error.kind() == Report::kMalboundedType;
15254 } 15254 }
15255 15255
15256 15256
15257 bool Type::IsMalformedOrMalbounded() const { 15257 bool Type::IsMalformedOrMalbounded() const {
15258 if (raw_ptr()->error_ == LanguageError::null()) { 15258 if (raw_ptr()->error_ == LanguageError::null()) {
15259 return false; 15259 return false;
15260 } 15260 }
15261 const LanguageError& type_error = LanguageError::Handle(error()); 15261 const LanguageError& type_error = LanguageError::Handle(error());
15262 if (type_error.kind() == Report::kMalformedType) { 15262 if (type_error.kind() == Report::kMalformedType) {
15263 return true; 15263 return true;
15264 } 15264 }
15265 ASSERT(type_error.kind() == Report::kMalboundedType); 15265 ASSERT(type_error.kind() == Report::kMalboundedType);
15266 return Isolate::Current()->flags().type_checks(); 15266 return Isolate::Current()->type_checks();
15267 } 15267 }
15268 15268
15269 15269
15270 void Type::set_error(const LanguageError& value) const { 15270 void Type::set_error(const LanguageError& value) const {
15271 StorePointer(&raw_ptr()->error_, value.raw()); 15271 StorePointer(&raw_ptr()->error_, value.raw());
15272 } 15272 }
15273 15273
15274 15274
15275 void Type::SetIsResolved() const { 15275 void Type::SetIsResolved() const {
15276 ASSERT(!IsResolved()); 15276 ASSERT(!IsResolved());
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
15743 bool FunctionType::IsMalformed() const { 15743 bool FunctionType::IsMalformed() const {
15744 if (raw_ptr()->error_ == LanguageError::null()) { 15744 if (raw_ptr()->error_ == LanguageError::null()) {
15745 return false; 15745 return false;
15746 } 15746 }
15747 const LanguageError& type_error = LanguageError::Handle(error()); 15747 const LanguageError& type_error = LanguageError::Handle(error());
15748 return type_error.kind() == Report::kMalformedType; 15748 return type_error.kind() == Report::kMalformedType;
15749 } 15749 }
15750 15750
15751 15751
15752 bool FunctionType::IsMalbounded() const { 15752 bool FunctionType::IsMalbounded() const {
15753 if (!Isolate::Current()->flags().type_checks()) { 15753 if (!Isolate::Current()->type_checks()) {
15754 return false; 15754 return false;
15755 } 15755 }
15756 if (raw_ptr()->error_ == LanguageError::null()) { 15756 if (raw_ptr()->error_ == LanguageError::null()) {
15757 return false; 15757 return false;
15758 } 15758 }
15759 const LanguageError& type_error = LanguageError::Handle(error()); 15759 const LanguageError& type_error = LanguageError::Handle(error());
15760 return type_error.kind() == Report::kMalboundedType; 15760 return type_error.kind() == Report::kMalboundedType;
15761 } 15761 }
15762 15762
15763 15763
15764 bool FunctionType::IsMalformedOrMalbounded() const { 15764 bool FunctionType::IsMalformedOrMalbounded() const {
15765 if (raw_ptr()->error_ == LanguageError::null()) { 15765 if (raw_ptr()->error_ == LanguageError::null()) {
15766 return false; 15766 return false;
15767 } 15767 }
15768 const LanguageError& type_error = LanguageError::Handle(error()); 15768 const LanguageError& type_error = LanguageError::Handle(error());
15769 if (type_error.kind() == Report::kMalformedType) { 15769 if (type_error.kind() == Report::kMalformedType) {
15770 return true; 15770 return true;
15771 } 15771 }
15772 ASSERT(type_error.kind() == Report::kMalboundedType); 15772 ASSERT(type_error.kind() == Report::kMalboundedType);
15773 return Isolate::Current()->flags().type_checks(); 15773 return Isolate::Current()->type_checks();
15774 } 15774 }
15775 15775
15776 15776
15777 void FunctionType::set_error(const LanguageError& value) const { 15777 void FunctionType::set_error(const LanguageError& value) const {
15778 StorePointer(&raw_ptr()->error_, value.raw()); 15778 StorePointer(&raw_ptr()->error_, value.raw());
15779 } 15779 }
15780 15780
15781 15781
15782 void FunctionType::SetIsResolved() const { 15782 void FunctionType::SetIsResolved() const {
15783 ASSERT(!IsResolved()); 15783 ASSERT(!IsResolved());
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
16706 bounded_type.InstantiateFrom(instantiator_type_arguments, 16706 bounded_type.InstantiateFrom(instantiator_type_arguments,
16707 bound_error, 16707 bound_error,
16708 instantiation_trail, 16708 instantiation_trail,
16709 bound_trail, 16709 bound_trail,
16710 space); 16710 space);
16711 // In case types of instantiator_type_arguments are not finalized 16711 // In case types of instantiator_type_arguments are not finalized
16712 // (or instantiated), then the instantiated_bounded_type is not finalized 16712 // (or instantiated), then the instantiated_bounded_type is not finalized
16713 // (or instantiated) either. 16713 // (or instantiated) either.
16714 // Note that instantiator_type_arguments must have the final length, though. 16714 // Note that instantiator_type_arguments must have the final length, though.
16715 } 16715 }
16716 if ((Isolate::Current()->flags().type_checks()) && 16716 if ((Isolate::Current()->type_checks()) &&
16717 (bound_error != NULL) && bound_error->IsNull()) { 16717 (bound_error != NULL) && bound_error->IsNull()) {
16718 AbstractType& upper_bound = AbstractType::Handle(bound()); 16718 AbstractType& upper_bound = AbstractType::Handle(bound());
16719 ASSERT(upper_bound.IsFinalized()); 16719 ASSERT(upper_bound.IsFinalized());
16720 ASSERT(!upper_bound.IsObjectType() && !upper_bound.IsDynamicType()); 16720 ASSERT(!upper_bound.IsObjectType() && !upper_bound.IsDynamicType());
16721 AbstractType& instantiated_upper_bound = 16721 AbstractType& instantiated_upper_bound =
16722 AbstractType::Handle(upper_bound.raw()); 16722 AbstractType::Handle(upper_bound.raw());
16723 if (!upper_bound.IsInstantiated()) { 16723 if (!upper_bound.IsInstantiated()) {
16724 instantiated_upper_bound = 16724 instantiated_upper_bound =
16725 upper_bound.InstantiateFrom(instantiator_type_arguments, 16725 upper_bound.InstantiateFrom(instantiator_type_arguments,
16726 bound_error, 16726 bound_error,
(...skipping 4725 matching lines...) Expand 10 before | Expand all | Expand 10 after
21452 return UserTag::null(); 21452 return UserTag::null();
21453 } 21453 }
21454 21454
21455 21455
21456 const char* UserTag::ToCString() const { 21456 const char* UserTag::ToCString() const {
21457 const String& tag_label = String::Handle(label()); 21457 const String& tag_label = String::Handle(label());
21458 return tag_label.ToCString(); 21458 return tag_label.ToCString();
21459 } 21459 }
21460 21460
21461 } // namespace dart 21461 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/jit_optimizer.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698