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

Unified Diff: src/objects.h

Issue 1300333003: Introduce SharedFunctionInfo::Iterator and Script::Iterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix rebase Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 96da77ef636ca8f71e838e3c0d743287ab817df4..c8856d4c6b6f3f4772989652f5221745ae5dd821 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -2515,6 +2515,24 @@ class WeakFixedArray : public FixedArray {
inline bool IsEmptySlot(int index) const;
static Object* Empty() { return Smi::FromInt(0); }
+ class Iterator {
+ public:
+ explicit Iterator(Object* maybe_array) : list_(NULL) { Reset(maybe_array); }
+ void Reset(Object* maybe_array);
+
+ template <class T>
+ inline T* Next();
+
+ private:
+ int index_;
+ WeakFixedArray* list_;
+#ifdef DEBUG
+ int last_used_index_;
+ DisallowHeapAllocation no_gc_;
+#endif // DEBUG
+ DISALLOW_COPY_AND_ASSIGN(Iterator);
+ };
+
DECLARE_CAST(WeakFixedArray)
private:
@@ -5930,6 +5948,17 @@ class Script: public Struct {
// that matches the function literal. Return empty handle if not found.
MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun);
+ // Iterate over all script objects on the heap.
+ class Iterator {
+ public:
+ explicit Iterator(Isolate* isolate);
+ Script* Next();
+
+ private:
+ WeakFixedArray::Iterator iterator_;
+ DISALLOW_COPY_AND_ASSIGN(Iterator);
+ };
+
// Dispatched behavior.
DECLARE_PRINTER(Script)
DECLARE_VERIFIER(Script)
@@ -6393,6 +6422,23 @@ class SharedFunctionInfo: public HeapObject {
void ResetForNewContext(int new_ic_age);
+ // Iterate over all shared function infos that are created from a script.
+ // That excludes shared function infos created for API functions and C++
+ // builtins.
+ class Iterator {
+ public:
+ explicit Iterator(Isolate* isolate);
+ SharedFunctionInfo* Next();
+
+ private:
+ bool NextScript();
+
+ Script::Iterator script_iterator_;
+ WeakFixedArray::Iterator sfi_iterator_;
+ DisallowHeapAllocation no_gc_;
+ DISALLOW_COPY_AND_ASSIGN(Iterator);
+ };
+
DECLARE_CAST(SharedFunctionInfo)
// Constants.
« no previous file with comments | « src/heap/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698