| 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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 return closure.raw(); | 1633 return closure.raw(); |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 | 1636 |
| 1637 void Class::set_signature_function(const Function& value) const { | 1637 void Class::set_signature_function(const Function& value) const { |
| 1638 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction()); | 1638 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction()); |
| 1639 StorePointer(&raw_ptr()->signature_function_, value.raw()); | 1639 StorePointer(&raw_ptr()->signature_function_, value.raw()); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 | 1642 |
| 1643 void Class::set_class_state(RawClass::ClassState state) const { | |
| 1644 ASSERT((state == RawClass::kAllocated) || | |
| 1645 (state == RawClass::kPreFinalized) || | |
| 1646 (state == RawClass::kFinalized)); | |
| 1647 set_state_bits(StateBits::update(state, raw_ptr()->state_bits_)); | |
| 1648 } | |
| 1649 | |
| 1650 | |
| 1651 void Class::set_state_bits(intptr_t bits) const { | 1643 void Class::set_state_bits(intptr_t bits) const { |
| 1652 raw_ptr()->state_bits_ = static_cast<uint16_t>(bits); | 1644 raw_ptr()->state_bits_ = static_cast<uint16_t>(bits); |
| 1653 } | 1645 } |
| 1654 | 1646 |
| 1655 | 1647 |
| 1656 void Class::set_library(const Library& value) const { | 1648 void Class::set_library(const Library& value) const { |
| 1657 StorePointer(&raw_ptr()->library_, value.raw()); | 1649 StorePointer(&raw_ptr()->library_, value.raw()); |
| 1658 } | 1650 } |
| 1659 | 1651 |
| 1660 | 1652 |
| 1661 void Class::set_type_parameters(const TypeArguments& value) const { | 1653 void Class::set_type_parameters(const TypeArguments& value) const { |
| 1662 StorePointer(&raw_ptr()->type_parameters_, value.raw()); | 1654 StorePointer(&raw_ptr()->type_parameters_, value.raw()); |
| 1663 } | 1655 } |
| 1664 | 1656 |
| 1665 | 1657 |
| 1666 intptr_t Class::NumTypeParameters() const { | 1658 intptr_t Class::NumTypeParameters() const { |
| 1659 if (IsMixinApplication() && !is_mixin_type_applied()) { |
| 1660 ClassFinalizer::ApplyMixinType(*this); |
| 1661 } |
| 1667 if (type_parameters() == TypeArguments::null()) { | 1662 if (type_parameters() == TypeArguments::null()) { |
| 1668 return 0; | 1663 return 0; |
| 1669 } | 1664 } |
| 1670 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); | 1665 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); |
| 1671 return type_params.Length(); | 1666 return type_params.Length(); |
| 1672 } | 1667 } |
| 1673 | 1668 |
| 1674 | 1669 |
| 1675 intptr_t Class::NumTypeArguments() const { | 1670 intptr_t Class::NumTypeArguments() const { |
| 1676 // To work properly, this call requires the super class of this class to be | 1671 // To work properly, this call requires the super class of this class to be |
| 1677 // resolved, which is checked by the SuperClass() call. | 1672 // resolved, which is checked by the type_class() call on the super type. |
| 1673 // Note that calling type_class() on a MixinAppType fails. |
| 1678 Isolate* isolate = Isolate::Current(); | 1674 Isolate* isolate = Isolate::Current(); |
| 1679 ReusableHandleScope reused_handles(isolate); | 1675 ReusableHandleScope reused_handles(isolate); |
| 1680 Class& cls = reused_handles.ClassHandle(); | 1676 Class& cls = reused_handles.ClassHandle(); |
| 1681 TypeArguments& type_params = reused_handles.TypeArgumentsHandle(); | 1677 TypeArguments& type_params = reused_handles.TypeArgumentsHandle(); |
| 1682 AbstractType& sup_type = reused_handles.AbstractTypeHandle(); | 1678 AbstractType& sup_type = reused_handles.AbstractTypeHandle(); |
| 1683 cls ^= raw(); | 1679 cls ^= raw(); |
| 1684 intptr_t num_type_args = 0; | 1680 intptr_t num_type_args = 0; |
| 1685 | 1681 |
| 1686 do { | 1682 do { |
| 1687 if (cls.IsSignatureClass()) { | 1683 if (cls.IsSignatureClass()) { |
| 1688 Function& signature_fun = reused_handles.FunctionHandle(); | 1684 Function& signature_fun = reused_handles.FunctionHandle(); |
| 1689 signature_fun ^= cls.signature_function(); | 1685 signature_fun ^= cls.signature_function(); |
| 1690 if (!signature_fun.is_static() && | 1686 if (!signature_fun.is_static() && |
| 1691 !signature_fun.HasInstantiatedSignature()) { | 1687 !signature_fun.HasInstantiatedSignature()) { |
| 1692 cls = signature_fun.Owner(); | 1688 cls = signature_fun.Owner(); |
| 1693 } | 1689 } |
| 1694 } | 1690 } |
| 1695 if (cls.type_parameters() != TypeArguments::null()) { | 1691 // Calling NumTypeParameters() on a mixin application class will setup the |
| 1692 // type parameters if not already done. |
| 1693 if (cls.NumTypeParameters() > 0) { |
| 1696 type_params ^= cls.type_parameters(); | 1694 type_params ^= cls.type_parameters(); |
| 1697 num_type_args += type_params.Length(); | 1695 num_type_args += type_params.Length(); |
| 1698 } | 1696 } |
| 1699 | 1697 |
| 1700 // Super type of Object class is null. | 1698 // Super type of Object class is null. |
| 1701 if (cls.super_type() == AbstractType::null() || | 1699 if (cls.super_type() == AbstractType::null() || |
| 1702 cls.super_type() == isolate->object_store()->object_type()) { | 1700 cls.super_type() == isolate->object_store()->object_type()) { |
| 1703 break; | 1701 break; |
| 1704 } | 1702 } |
| 1705 sup_type ^= cls.super_type(); | 1703 sup_type ^= cls.super_type(); |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2347 void Class::set_is_const() const { | 2345 void Class::set_is_const() const { |
| 2348 set_state_bits(ConstBit::update(true, raw_ptr()->state_bits_)); | 2346 set_state_bits(ConstBit::update(true, raw_ptr()->state_bits_)); |
| 2349 } | 2347 } |
| 2350 | 2348 |
| 2351 | 2349 |
| 2352 void Class::set_is_mixin_typedef() const { | 2350 void Class::set_is_mixin_typedef() const { |
| 2353 set_state_bits(MixinTypedefBit::update(true, raw_ptr()->state_bits_)); | 2351 set_state_bits(MixinTypedefBit::update(true, raw_ptr()->state_bits_)); |
| 2354 } | 2352 } |
| 2355 | 2353 |
| 2356 | 2354 |
| 2355 void Class::set_is_mixin_type_applied() const { |
| 2356 set_state_bits(MixinTypeAppliedBit::update(true, raw_ptr()->state_bits_)); |
| 2357 } |
| 2358 |
| 2359 |
| 2357 void Class::set_is_finalized() const { | 2360 void Class::set_is_finalized() const { |
| 2358 ASSERT(!is_finalized()); | 2361 ASSERT(!is_finalized()); |
| 2359 set_state_bits(StateBits::update(RawClass::kFinalized, | 2362 set_state_bits(ClassFinalizedBits::update(RawClass::kFinalized, |
| 2360 raw_ptr()->state_bits_)); | 2363 raw_ptr()->state_bits_)); |
| 2361 } | 2364 } |
| 2362 | 2365 |
| 2363 | 2366 |
| 2364 void Class::set_is_prefinalized() const { | 2367 void Class::set_is_prefinalized() const { |
| 2365 ASSERT(!is_finalized()); | 2368 ASSERT(!is_finalized()); |
| 2366 set_state_bits(StateBits::update(RawClass::kPreFinalized, | 2369 set_state_bits(ClassFinalizedBits::update(RawClass::kPreFinalized, |
| 2367 raw_ptr()->state_bits_)); | 2370 raw_ptr()->state_bits_)); |
| 2368 } | 2371 } |
| 2369 | 2372 |
| 2370 | 2373 |
| 2371 void Class::set_is_marked_for_parsing() const { | 2374 void Class::set_is_marked_for_parsing() const { |
| 2372 set_state_bits(MarkedForParsingBit::update(true, raw_ptr()->state_bits_)); | 2375 set_state_bits(MarkedForParsingBit::update(true, raw_ptr()->state_bits_)); |
| 2373 } | 2376 } |
| 2374 | 2377 |
| 2375 | 2378 |
| 2376 void Class::reset_is_marked_for_parsing() const { | 2379 void Class::reset_is_marked_for_parsing() const { |
| 2377 set_state_bits(MarkedForParsingBit::update(false, raw_ptr()->state_bits_)); | 2380 set_state_bits(MarkedForParsingBit::update(false, raw_ptr()->state_bits_)); |
| 2378 } | 2381 } |
| 2379 | 2382 |
| 2380 | 2383 |
| 2381 void Class::set_interfaces(const Array& value) const { | 2384 void Class::set_interfaces(const Array& value) const { |
| 2382 // Verification and resolving of interfaces occurs in finalizer. | 2385 // Verification and resolving of interfaces occurs in finalizer. |
| 2383 ASSERT(!value.IsNull()); | 2386 ASSERT(!value.IsNull()); |
| 2384 StorePointer(&raw_ptr()->interfaces_, value.raw()); | 2387 StorePointer(&raw_ptr()->interfaces_, value.raw()); |
| 2385 } | 2388 } |
| 2386 | 2389 |
| 2387 | 2390 |
| 2388 void Class::set_mixin(const Type& value) const { | 2391 void Class::set_mixin(const Type& value) const { |
| 2389 // Resolution and application of mixin type occurs in finalizer. | 2392 // Resolution and application of mixin type occurs in finalizer. |
| 2390 ASSERT(!value.IsNull()); | 2393 ASSERT(!value.IsNull()); |
| 2391 StorePointer(&raw_ptr()->mixin_, value.raw()); | 2394 StorePointer(&raw_ptr()->mixin_, value.raw()); |
| 2392 } | 2395 } |
| 2393 | 2396 |
| 2394 | 2397 |
| 2398 bool Class::IsMixinApplication() const { |
| 2399 return mixin() != Type::null(); |
| 2400 } |
| 2401 |
| 2402 |
| 2395 void Class::set_patch_class(const Class& cls) const { | 2403 void Class::set_patch_class(const Class& cls) const { |
| 2396 ASSERT(patch_class() == Class::null()); | 2404 ASSERT(patch_class() == Class::null()); |
| 2397 StorePointer(&raw_ptr()->patch_class_, cls.raw()); | 2405 StorePointer(&raw_ptr()->patch_class_, cls.raw()); |
| 2398 } | 2406 } |
| 2399 | 2407 |
| 2400 | 2408 |
| 2401 void Class::AddDirectSubclass(const Class& subclass) const { | 2409 void Class::AddDirectSubclass(const Class& subclass) const { |
| 2402 ASSERT(!subclass.IsNull()); | 2410 ASSERT(!subclass.IsNull()); |
| 2403 ASSERT(subclass.SuperClass() == raw()); | 2411 ASSERT(subclass.SuperClass() == raw()); |
| 2404 // Do not keep track of the direct subclasses of class Object. | 2412 // Do not keep track of the direct subclasses of class Object. |
| (...skipping 12507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14912 } | 14920 } |
| 14913 | 14921 |
| 14914 | 14922 |
| 14915 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14923 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14916 stream->OpenObject(); | 14924 stream->OpenObject(); |
| 14917 stream->CloseObject(); | 14925 stream->CloseObject(); |
| 14918 } | 14926 } |
| 14919 | 14927 |
| 14920 | 14928 |
| 14921 } // namespace dart | 14929 } // namespace dart |
| OLD | NEW |