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

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

Issue 23072013: - Avoid double iteration when accessing anonymous classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object.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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2239 int next_ix_; // Index of next element. 2239 int next_ix_; // Index of next element.
2240 2240
2241 friend class ClassDictionaryIterator; 2241 friend class ClassDictionaryIterator;
2242 friend class LibraryPrefixIterator; 2242 friend class LibraryPrefixIterator;
2243 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator); 2243 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator);
2244 }; 2244 };
2245 2245
2246 2246
2247 class ClassDictionaryIterator : public DictionaryIterator { 2247 class ClassDictionaryIterator : public DictionaryIterator {
2248 public: 2248 public:
2249 explicit ClassDictionaryIterator(const Library& library); 2249 enum IterationKind {
2250 kIteratePrivate,
2251 kNoIteratePrivate
2252 };
2253
2254 ClassDictionaryIterator(const Library& library,
2255 IterationKind kind = kNoIteratePrivate);
2256
2257 bool HasNext() const { return (next_ix_ < size_) || (anon_ix_ < anon_size_); }
2250 2258
2251 // Returns a non-null raw class. 2259 // Returns a non-null raw class.
2252 RawClass* GetNextClass(); 2260 RawClass* GetNextClass();
2253 2261
2254 private: 2262 private:
2255 void MoveToNextClass(); 2263 void MoveToNextClass();
2256 2264
2265 const Array& anon_array_;
2266 const int anon_size_; // Number of anonymous classes to iterate over.
2267 int anon_ix_; // Index of next anonymous class.
2268
2257 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator); 2269 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator);
2258 }; 2270 };
2259 2271
2260 2272
2261 class LibraryPrefixIterator : public DictionaryIterator { 2273 class LibraryPrefixIterator : public DictionaryIterator {
2262 public: 2274 public:
2263 explicit LibraryPrefixIterator(const Library& library); 2275 explicit LibraryPrefixIterator(const Library& library);
2264 RawLibraryPrefix* GetNext(); 2276 RawLibraryPrefix* GetNext();
2265 private: 2277 private:
2266 void Advance(); 2278 void Advance();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 void AddAnonymousClass(const Class& cls) const; 2341 void AddAnonymousClass(const Class& cls) const;
2330 2342
2331 void AddExport(const Namespace& ns) const; 2343 void AddExport(const Namespace& ns) const;
2332 2344
2333 void AddClassMetadata(const Class& cls, intptr_t token_pos) const; 2345 void AddClassMetadata(const Class& cls, intptr_t token_pos) const;
2334 void AddFieldMetadata(const Field& field, intptr_t token_pos) const; 2346 void AddFieldMetadata(const Field& field, intptr_t token_pos) const;
2335 void AddFunctionMetadata(const Function& func, intptr_t token_pos) const; 2347 void AddFunctionMetadata(const Function& func, intptr_t token_pos) const;
2336 void AddLibraryMetadata(const Class& cls, intptr_t token_pos) const; 2348 void AddLibraryMetadata(const Class& cls, intptr_t token_pos) const;
2337 RawObject* GetMetadata(const Object& obj) const; 2349 RawObject* GetMetadata(const Object& obj) const;
2338 2350
2351 intptr_t num_anonymous_classes() const { return raw_ptr()->num_anonymous_; }
2352 RawArray* anonymous_classes() const { return raw_ptr()->anonymous_classes_; }
2353
2339 // Library imports. 2354 // Library imports.
2340 void AddImport(const Namespace& ns) const; 2355 void AddImport(const Namespace& ns) const;
2341 intptr_t num_imports() const { return raw_ptr()->num_imports_; } 2356 intptr_t num_imports() const { return raw_ptr()->num_imports_; }
2342 RawNamespace* ImportAt(intptr_t index) const; 2357 RawNamespace* ImportAt(intptr_t index) const;
2343 RawLibrary* ImportLibraryAt(intptr_t index) const; 2358 RawLibrary* ImportLibraryAt(intptr_t index) const;
2344 bool ImportsCorelib() const; 2359 bool ImportsCorelib() const;
2345 2360
2346 RawFunction* LookupFunctionInScript(const Script& script, 2361 RawFunction* LookupFunctionInScript(const Script& script,
2347 intptr_t token_pos) const; 2362 intptr_t token_pos) const;
2348 2363
(...skipping 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after
6054 6069
6055 6070
6056 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6071 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6057 intptr_t index) { 6072 intptr_t index) {
6058 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6073 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6059 } 6074 }
6060 6075
6061 } // namespace dart 6076 } // namespace dart
6062 6077
6063 #endif // VM_OBJECT_H_ 6078 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698