| OLD | NEW |
| 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 3248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 // This class and class 'other' do not need to be finalized, however, they must | 3259 // This class and class 'other' do not need to be finalized, however, they must |
| 3260 // be resolved as well as their interfaces. | 3260 // be resolved as well as their interfaces. |
| 3261 bool Class::TypeTestNonRecursive(const Class& cls, | 3261 bool Class::TypeTestNonRecursive(const Class& cls, |
| 3262 Class::TypeTestKind test_kind, | 3262 Class::TypeTestKind test_kind, |
| 3263 const TypeArguments& type_arguments, | 3263 const TypeArguments& type_arguments, |
| 3264 const Class& other, | 3264 const Class& other, |
| 3265 const TypeArguments& other_type_arguments, | 3265 const TypeArguments& other_type_arguments, |
| 3266 Error* bound_error) { | 3266 Error* bound_error) { |
| 3267 // Use the thsi object as if it was the receiver of this method, but instead | 3267 // Use the thsi object as if it was the receiver of this method, but instead |
| 3268 // of recursing reset it to the super class and loop. | 3268 // of recursing reset it to the super class and loop. |
| 3269 Class& thsi = Class::Handle(cls.raw()); | 3269 Isolate* isolate = Isolate::Current(); |
| 3270 Class& thsi = Class::Handle(isolate, cls.raw()); |
| 3270 while (true) { | 3271 while (true) { |
| 3271 ASSERT(!thsi.IsVoidClass()); | 3272 ASSERT(!thsi.IsVoidClass()); |
| 3272 // Check for DynamicType. | 3273 // Check for DynamicType. |
| 3273 // Each occurrence of DynamicType in type T is interpreted as the dynamic | 3274 // Each occurrence of DynamicType in type T is interpreted as the dynamic |
| 3274 // type, a supertype of all types. | 3275 // type, a supertype of all types. |
| 3275 if (other.IsDynamicClass()) { | 3276 if (other.IsDynamicClass()) { |
| 3276 return true; | 3277 return true; |
| 3277 } | 3278 } |
| 3278 // In the case of a subtype test, each occurrence of DynamicType in type S | 3279 // In the case of a subtype test, each occurrence of DynamicType in type S |
| 3279 // is interpreted as the bottom type, a subtype of all types. | 3280 // is interpreted as the bottom type, a subtype of all types. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3316 return test_kind == Class::kIsSubtypeOf; | 3317 return test_kind == Class::kIsSubtypeOf; |
| 3317 } | 3318 } |
| 3318 return type_arguments.TypeTest(test_kind, | 3319 return type_arguments.TypeTest(test_kind, |
| 3319 other_type_arguments, | 3320 other_type_arguments, |
| 3320 from_index, | 3321 from_index, |
| 3321 num_type_params, | 3322 num_type_params, |
| 3322 bound_error); | 3323 bound_error); |
| 3323 } | 3324 } |
| 3324 const bool other_is_function_class = other.IsFunctionClass(); | 3325 const bool other_is_function_class = other.IsFunctionClass(); |
| 3325 if (other.IsSignatureClass() || other_is_function_class) { | 3326 if (other.IsSignatureClass() || other_is_function_class) { |
| 3326 const Function& other_fun = Function::Handle(other.signature_function()); | 3327 const Function& other_fun = Function::Handle(isolate, |
| 3328 other.signature_function()); |
| 3327 if (thsi.IsSignatureClass()) { | 3329 if (thsi.IsSignatureClass()) { |
| 3328 if (other_is_function_class) { | 3330 if (other_is_function_class) { |
| 3329 return true; | 3331 return true; |
| 3330 } | 3332 } |
| 3331 // Check for two function types. | 3333 // Check for two function types. |
| 3332 const Function& fun = Function::Handle(thsi.signature_function()); | 3334 const Function& fun = |
| 3335 Function::Handle(isolate, thsi.signature_function()); |
| 3333 return fun.TypeTest(test_kind, | 3336 return fun.TypeTest(test_kind, |
| 3334 type_arguments, | 3337 type_arguments, |
| 3335 other_fun, | 3338 other_fun, |
| 3336 other_type_arguments, | 3339 other_type_arguments, |
| 3337 bound_error); | 3340 bound_error); |
| 3338 } | 3341 } |
| 3339 // Check if type S has a call() method of function type T. | 3342 // Check if type S has a call() method of function type T. |
| 3340 Function& function = | 3343 Function& function = |
| 3341 Function::Handle(thsi.LookupDynamicFunction(Symbols::Call())); | 3344 Function::Handle(isolate, |
| 3345 thsi.LookupDynamicFunction(Symbols::Call())); |
| 3342 if (function.IsNull()) { | 3346 if (function.IsNull()) { |
| 3343 // Walk up the super_class chain. | 3347 // Walk up the super_class chain. |
| 3344 Class& cls = Class::Handle(thsi.SuperClass()); | 3348 Class& cls = Class::Handle(isolate, thsi.SuperClass()); |
| 3345 while (!cls.IsNull() && function.IsNull()) { | 3349 while (!cls.IsNull() && function.IsNull()) { |
| 3346 function = cls.LookupDynamicFunction(Symbols::Call()); | 3350 function = cls.LookupDynamicFunction(Symbols::Call()); |
| 3347 cls = cls.SuperClass(); | 3351 cls = cls.SuperClass(); |
| 3348 } | 3352 } |
| 3349 } | 3353 } |
| 3350 if (!function.IsNull()) { | 3354 if (!function.IsNull()) { |
| 3351 if (other_is_function_class || | 3355 if (other_is_function_class || |
| 3352 function.TypeTest(test_kind, | 3356 function.TypeTest(test_kind, |
| 3353 type_arguments, | 3357 type_arguments, |
| 3354 other_fun, | 3358 other_fun, |
| 3355 other_type_arguments, | 3359 other_type_arguments, |
| 3356 bound_error)) { | 3360 bound_error)) { |
| 3357 return true; | 3361 return true; |
| 3358 } | 3362 } |
| 3359 } | 3363 } |
| 3360 } | 3364 } |
| 3361 // Check for 'direct super type' specified in the implements clause | 3365 // Check for 'direct super type' specified in the implements clause |
| 3362 // and check for transitivity at the same time. | 3366 // and check for transitivity at the same time. |
| 3363 Array& interfaces = Array::Handle(thsi.interfaces()); | 3367 Array& interfaces = Array::Handle(isolate, thsi.interfaces()); |
| 3364 AbstractType& interface = AbstractType::Handle(); | 3368 AbstractType& interface = AbstractType::Handle(isolate); |
| 3365 Class& interface_class = Class::Handle(); | 3369 Class& interface_class = Class::Handle(isolate); |
| 3366 TypeArguments& interface_args = TypeArguments::Handle(); | 3370 TypeArguments& interface_args = TypeArguments::Handle(isolate); |
| 3367 Error& error = Error::Handle(); | 3371 Error& error = Error::Handle(isolate); |
| 3368 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 3372 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 3369 interface ^= interfaces.At(i); | 3373 interface ^= interfaces.At(i); |
| 3370 if (!interface.IsFinalized()) { | 3374 if (!interface.IsFinalized()) { |
| 3371 // We may be checking bounds at finalization time and can encounter | 3375 // We may be checking bounds at finalization time and can encounter |
| 3372 // a still unfinalized interface. | 3376 // a still unfinalized interface. |
| 3373 ClassFinalizer::FinalizeType( | 3377 ClassFinalizer::FinalizeType( |
| 3374 thsi, interface, ClassFinalizer::kCanonicalize); | 3378 thsi, interface, ClassFinalizer::kCanonicalize); |
| 3375 interfaces.SetAt(i, interface); | 3379 interfaces.SetAt(i, interface); |
| 3376 } | 3380 } |
| 3377 if (interface.IsMalbounded()) { | 3381 if (interface.IsMalbounded()) { |
| (...skipping 12860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16238 } | 16242 } |
| 16239 | 16243 |
| 16240 | 16244 |
| 16241 RawArray* Array::New(intptr_t len, Heap::Space space) { | 16245 RawArray* Array::New(intptr_t len, Heap::Space space) { |
| 16242 ASSERT(Isolate::Current()->object_store()->array_class() != Class::null()); | 16246 ASSERT(Isolate::Current()->object_store()->array_class() != Class::null()); |
| 16243 return New(kClassId, len, space); | 16247 return New(kClassId, len, space); |
| 16244 } | 16248 } |
| 16245 | 16249 |
| 16246 | 16250 |
| 16247 RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) { | 16251 RawArray* Array::New(intptr_t class_id, intptr_t len, Heap::Space space) { |
| 16248 if (len < 0 || len > Array::kMaxElements) { | 16252 if ((len < 0) || (len > Array::kMaxElements)) { |
| 16249 // This should be caught before we reach here. | 16253 // This should be caught before we reach here. |
| 16250 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len); | 16254 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len); |
| 16251 } | 16255 } |
| 16252 Array& result = Array::Handle(); | |
| 16253 { | 16256 { |
| 16254 RawObject* raw = Object::Allocate(class_id, | 16257 RawArray* raw = reinterpret_cast<RawArray*>( |
| 16255 Array::InstanceSize(len), | 16258 Object::Allocate(class_id, |
| 16256 space); | 16259 Array::InstanceSize(len), |
| 16260 space)); |
| 16257 NoGCScope no_gc; | 16261 NoGCScope no_gc; |
| 16258 result ^= raw; | 16262 raw->ptr()->length_ = Smi::New(len); |
| 16259 result.SetLength(len); | 16263 return raw; |
| 16260 } | 16264 } |
| 16261 return result.raw(); | |
| 16262 } | 16265 } |
| 16263 | 16266 |
| 16264 | 16267 |
| 16265 void Array::MakeImmutable() const { | 16268 void Array::MakeImmutable() const { |
| 16266 NoGCScope no_gc; | 16269 NoGCScope no_gc; |
| 16267 uword tags = raw_ptr()->tags_; | 16270 uword tags = raw_ptr()->tags_; |
| 16268 tags = RawObject::ClassIdTag::update(kImmutableArrayCid, tags); | 16271 tags = RawObject::ClassIdTag::update(kImmutableArrayCid, tags); |
| 16269 raw_ptr()->tags_ = tags; | 16272 raw_ptr()->tags_ = tags; |
| 16270 } | 16273 } |
| 16271 | 16274 |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17498 return "_MirrorReference"; | 17501 return "_MirrorReference"; |
| 17499 } | 17502 } |
| 17500 | 17503 |
| 17501 | 17504 |
| 17502 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17505 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 17503 Instance::PrintToJSONStream(stream, ref); | 17506 Instance::PrintToJSONStream(stream, ref); |
| 17504 } | 17507 } |
| 17505 | 17508 |
| 17506 | 17509 |
| 17507 } // namespace dart | 17510 } // namespace dart |
| OLD | NEW |