Chromium Code Reviews| 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 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2161 return name.Hash(); | 2161 return name.Hash(); |
| 2162 } | 2162 } |
| 2163 }; | 2163 }; |
| 2164 typedef UnorderedHashSet<ClassFunctionsTraits> ClassFunctionsSet; | 2164 typedef UnorderedHashSet<ClassFunctionsTraits> ClassFunctionsSet; |
| 2165 | 2165 |
| 2166 | 2166 |
| 2167 void Class::SetFunctions(const Array& value) const { | 2167 void Class::SetFunctions(const Array& value) const { |
| 2168 ASSERT(!value.IsNull()); | 2168 ASSERT(!value.IsNull()); |
| 2169 StorePointer(&raw_ptr()->functions_, value.raw()); | 2169 StorePointer(&raw_ptr()->functions_, value.raw()); |
| 2170 const intptr_t len = value.Length(); | 2170 const intptr_t len = value.Length(); |
| 2171 ClassFunctionsSet set(HashTables::New<ClassFunctionsSet>(len, Heap::kOld)); | |
| 2172 if (len >= kFunctionLookupHashTreshold) { | 2171 if (len >= kFunctionLookupHashTreshold) { |
| 2172 ClassFunctionsSet set(HashTables::New<ClassFunctionsSet>(len, Heap::kOld)); | |
| 2173 Function& func = Function::Handle(); | 2173 Function& func = Function::Handle(); |
| 2174 for (intptr_t i = 0; i < len; ++i) { | 2174 for (intptr_t i = 0; i < len; ++i) { |
| 2175 func ^= value.At(i); | 2175 func ^= value.At(i); |
| 2176 // Verify that all the functions in the array have this class as owner. | 2176 // Verify that all the functions in the array have this class as owner. |
| 2177 ASSERT(func.Owner() == raw()); | 2177 ASSERT(func.Owner() == raw()); |
| 2178 set.Insert(func); | 2178 set.Insert(func); |
| 2179 } | 2179 } |
| 2180 StorePointer(&raw_ptr()->functions_hash_table_, set.Release().raw()); | |
| 2180 } | 2181 } |
| 2181 StorePointer(&raw_ptr()->functions_hash_table_, set.Release().raw()); | |
| 2182 } | 2182 } |
| 2183 | 2183 |
| 2184 | 2184 |
| 2185 void Class::AddFunction(const Function& function) const { | 2185 void Class::AddFunction(const Function& function) const { |
| 2186 const Array& arr = Array::Handle(functions()); | 2186 const Array& arr = Array::Handle(functions()); |
| 2187 const Array& new_arr = | 2187 const Array& new_arr = |
| 2188 Array::Handle(Array::Grow(arr, arr.Length() + 1, Heap::kOld)); | 2188 Array::Handle(Array::Grow(arr, arr.Length() + 1, Heap::kOld)); |
| 2189 new_arr.SetAt(arr.Length(), function); | 2189 new_arr.SetAt(arr.Length(), function); |
| 2190 StorePointer(&raw_ptr()->functions_, new_arr.raw()); | 2190 StorePointer(&raw_ptr()->functions_, new_arr.raw()); |
| 2191 // Add to hash table, if any. | 2191 // Add to hash table, if any. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2203 | 2203 |
| 2204 void Class::RemoveFunction(const Function& function) const { | 2204 void Class::RemoveFunction(const Function& function) const { |
| 2205 const Array& arr = Array::Handle(functions()); | 2205 const Array& arr = Array::Handle(functions()); |
| 2206 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); | 2206 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); |
| 2207 Function& entry = Function::Handle(); | 2207 Function& entry = Function::Handle(); |
| 2208 for (intptr_t i = 0; i < arr.Length(); i++) { | 2208 for (intptr_t i = 0; i < arr.Length(); i++) { |
| 2209 entry ^= arr.At(i); | 2209 entry ^= arr.At(i); |
| 2210 if (function.raw() != entry.raw()) { | 2210 if (function.raw() != entry.raw()) { |
| 2211 AddFunction(entry); | 2211 AddFunction(entry); |
| 2212 } | 2212 } |
| 2213 } | 2213 } |
|
siva
2015/10/15 01:13:15
Not sure who uses this function but shouldn't this
| |
| 2214 } | 2214 } |
| 2215 | 2215 |
| 2216 | 2216 |
| 2217 intptr_t Class::FindFunctionIndex(const Function& needle) const { | 2217 intptr_t Class::FindFunctionIndex(const Function& needle) const { |
| 2218 Thread* thread = Thread::Current(); | 2218 Thread* thread = Thread::Current(); |
| 2219 if (EnsureIsFinalized(thread) != Error::null()) { | 2219 if (EnsureIsFinalized(thread) != Error::null()) { |
| 2220 return -1; | 2220 return -1; |
| 2221 } | 2221 } |
| 2222 REUSABLE_ARRAY_HANDLESCOPE(thread); | 2222 REUSABLE_ARRAY_HANDLESCOPE(thread); |
| 2223 REUSABLE_FUNCTION_HANDLESCOPE(thread); | 2223 REUSABLE_FUNCTION_HANDLESCOPE(thread); |
| (...skipping 19429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21653 return tag_label.ToCString(); | 21653 return tag_label.ToCString(); |
| 21654 } | 21654 } |
| 21655 | 21655 |
| 21656 | 21656 |
| 21657 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21657 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21658 Instance::PrintJSONImpl(stream, ref); | 21658 Instance::PrintJSONImpl(stream, ref); |
| 21659 } | 21659 } |
| 21660 | 21660 |
| 21661 | 21661 |
| 21662 } // namespace dart | 21662 } // namespace dart |
| OLD | NEW |