| 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 13922 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 13933 intptr_t MegamorphicCache::filled_entry_count() const { | 13933 intptr_t MegamorphicCache::filled_entry_count() const { | 
| 13934   return raw_ptr()->filled_entry_count_; | 13934   return raw_ptr()->filled_entry_count_; | 
| 13935 } | 13935 } | 
| 13936 | 13936 | 
| 13937 | 13937 | 
| 13938 void MegamorphicCache::set_filled_entry_count(intptr_t count) const { | 13938 void MegamorphicCache::set_filled_entry_count(intptr_t count) const { | 
| 13939   StoreNonPointer(&raw_ptr()->filled_entry_count_, count); | 13939   StoreNonPointer(&raw_ptr()->filled_entry_count_, count); | 
| 13940 } | 13940 } | 
| 13941 | 13941 | 
| 13942 | 13942 | 
|  | 13943 void MegamorphicCache::set_target_name(const String& value) const { | 
|  | 13944   StorePointer(&raw_ptr()->target_name_, value.raw()); | 
|  | 13945 } | 
|  | 13946 | 
|  | 13947 | 
|  | 13948 void MegamorphicCache::set_arguments_descriptor(const Array& value) const { | 
|  | 13949   StorePointer(&raw_ptr()->args_descriptor_, value.raw()); | 
|  | 13950 } | 
|  | 13951 | 
|  | 13952 | 
| 13943 RawMegamorphicCache* MegamorphicCache::New() { | 13953 RawMegamorphicCache* MegamorphicCache::New() { | 
| 13944   MegamorphicCache& result = MegamorphicCache::Handle(); | 13954   MegamorphicCache& result = MegamorphicCache::Handle(); | 
| 13945   { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, | 13955   { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, | 
| 13946                                       MegamorphicCache::InstanceSize(), | 13956                                       MegamorphicCache::InstanceSize(), | 
| 13947                                       Heap::kOld); | 13957                                       Heap::kOld); | 
| 13948     NoSafepointScope no_safepoint; | 13958     NoSafepointScope no_safepoint; | 
| 13949     result ^= raw; | 13959     result ^= raw; | 
| 13950   } | 13960   } | 
|  | 13961   result.set_filled_entry_count(0); | 
|  | 13962   return result.raw(); | 
|  | 13963 } | 
|  | 13964 | 
|  | 13965 | 
|  | 13966 RawMegamorphicCache* MegamorphicCache::New(const String& target_name, | 
|  | 13967                                            const Array& arguments_descriptor) { | 
|  | 13968   MegamorphicCache& result = MegamorphicCache::Handle(); | 
|  | 13969   { RawObject* raw = Object::Allocate(MegamorphicCache::kClassId, | 
|  | 13970                                       MegamorphicCache::InstanceSize(), | 
|  | 13971                                       Heap::kOld); | 
|  | 13972     NoSafepointScope no_safepoint; | 
|  | 13973     result ^= raw; | 
|  | 13974   } | 
| 13951   const intptr_t capacity = kInitialCapacity; | 13975   const intptr_t capacity = kInitialCapacity; | 
| 13952   const Array& buckets = Array::Handle( | 13976   const Array& buckets = Array::Handle( | 
| 13953       Array::New(kEntryLength * capacity, Heap::kOld)); | 13977       Array::New(kEntryLength * capacity, Heap::kOld)); | 
| 13954   const Function& handler = Function::Handle( | 13978   const Function& handler = Function::Handle( | 
| 13955       MegamorphicCacheTable::miss_handler(Isolate::Current())); | 13979       MegamorphicCacheTable::miss_handler(Isolate::Current())); | 
| 13956   for (intptr_t i = 0; i < capacity; ++i) { | 13980   for (intptr_t i = 0; i < capacity; ++i) { | 
| 13957     SetEntry(buckets, i, smi_illegal_cid(), handler); | 13981     SetEntry(buckets, i, smi_illegal_cid(), handler); | 
| 13958   } | 13982   } | 
| 13959   result.set_buckets(buckets); | 13983   result.set_buckets(buckets); | 
| 13960   result.set_mask(capacity - 1); | 13984   result.set_mask(capacity - 1); | 
|  | 13985   result.set_target_name(target_name); | 
|  | 13986   result.set_arguments_descriptor(arguments_descriptor); | 
| 13961   result.set_filled_entry_count(0); | 13987   result.set_filled_entry_count(0); | 
| 13962   return result.raw(); | 13988   return result.raw(); | 
| 13963 } | 13989 } | 
| 13964 | 13990 | 
| 13965 | 13991 | 
| 13966 void MegamorphicCache::EnsureCapacity() const { | 13992 void MegamorphicCache::EnsureCapacity() const { | 
| 13967   intptr_t old_capacity = mask() + 1; | 13993   intptr_t old_capacity = mask() + 1; | 
| 13968   double load_limit = kLoadFactor * static_cast<double>(old_capacity); | 13994   double load_limit = kLoadFactor * static_cast<double>(old_capacity); | 
| 13969   if (static_cast<double>(filled_entry_count() + 1) > load_limit) { | 13995   if (static_cast<double>(filled_entry_count() + 1) > load_limit) { | 
| 13970     const Array& old_buckets = Array::Handle(buckets()); | 13996     const Array& old_buckets = Array::Handle(buckets()); | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 14008       set_filled_entry_count(filled_entry_count() + 1); | 14034       set_filled_entry_count(filled_entry_count() + 1); | 
| 14009       return; | 14035       return; | 
| 14010     } | 14036     } | 
| 14011     i = (i + 1) & id_mask; | 14037     i = (i + 1) & id_mask; | 
| 14012   } while (i != index); | 14038   } while (i != index); | 
| 14013   UNREACHABLE(); | 14039   UNREACHABLE(); | 
| 14014 } | 14040 } | 
| 14015 | 14041 | 
| 14016 | 14042 | 
| 14017 const char* MegamorphicCache::ToCString() const { | 14043 const char* MegamorphicCache::ToCString() const { | 
| 14018   return "MegamorphicCache"; | 14044   const String& name = String::Handle(target_name()); | 
|  | 14045   return OS::SCreate(Thread::Current()->zone(), | 
|  | 14046                      "MegamorphicCache(%s)", name.ToCString()); | 
| 14019 } | 14047 } | 
| 14020 | 14048 | 
| 14021 | 14049 | 
| 14022 void MegamorphicCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | 14050 void MegamorphicCache::PrintJSONImpl(JSONStream* stream, bool ref) const { | 
| 14023   JSONObject jsobj(stream); | 14051   JSONObject jsobj(stream); | 
| 14024   AddCommonObjectProperties(&jsobj, "Object", ref); | 14052   AddCommonObjectProperties(&jsobj, "Object", ref); | 
| 14025   jsobj.AddServiceId(*this); | 14053   jsobj.AddServiceId(*this); | 
|  | 14054   jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); | 
| 14026   if (ref) { | 14055   if (ref) { | 
| 14027     return; | 14056     return; | 
| 14028   } | 14057   } | 
| 14029   jsobj.AddProperty("_buckets", Object::Handle(buckets())); | 14058   jsobj.AddProperty("_buckets", Object::Handle(buckets())); | 
| 14030   jsobj.AddProperty("_mask", mask()); | 14059   jsobj.AddProperty("_mask", mask()); | 
|  | 14060   jsobj.AddProperty("_argumentsDescriptor", | 
|  | 14061                     Object::Handle(arguments_descriptor())); | 
| 14031 } | 14062 } | 
| 14032 | 14063 | 
| 14033 | 14064 | 
| 14034 RawSubtypeTestCache* SubtypeTestCache::New() { | 14065 RawSubtypeTestCache* SubtypeTestCache::New() { | 
| 14035   ASSERT(Object::subtypetestcache_class() != Class::null()); | 14066   ASSERT(Object::subtypetestcache_class() != Class::null()); | 
| 14036   SubtypeTestCache& result = SubtypeTestCache::Handle(); | 14067   SubtypeTestCache& result = SubtypeTestCache::Handle(); | 
| 14037   { | 14068   { | 
| 14038     // SubtypeTestCache objects are long living objects, allocate them in the | 14069     // SubtypeTestCache objects are long living objects, allocate them in the | 
| 14039     // old generation. | 14070     // old generation. | 
| 14040     RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, | 14071     RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, | 
| (...skipping 7679 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 21720   return tag_label.ToCString(); | 21751   return tag_label.ToCString(); | 
| 21721 } | 21752 } | 
| 21722 | 21753 | 
| 21723 | 21754 | 
| 21724 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21755 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 
| 21725   Instance::PrintJSONImpl(stream, ref); | 21756   Instance::PrintJSONImpl(stream, ref); | 
| 21726 } | 21757 } | 
| 21727 | 21758 | 
| 21728 | 21759 | 
| 21729 }  // namespace dart | 21760 }  // namespace dart | 
| OLD | NEW | 
|---|