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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/objects.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 template <class CompactionCallback> 2508 template <class CompactionCallback>
2509 void Compact(); 2509 void Compact();
2510 2510
2511 inline Object* Get(int index) const; 2511 inline Object* Get(int index) const;
2512 inline void Clear(int index); 2512 inline void Clear(int index);
2513 inline int Length() const; 2513 inline int Length() const;
2514 2514
2515 inline bool IsEmptySlot(int index) const; 2515 inline bool IsEmptySlot(int index) const;
2516 static Object* Empty() { return Smi::FromInt(0); } 2516 static Object* Empty() { return Smi::FromInt(0); }
2517 2517
2518 class Iterator {
2519 public:
2520 explicit Iterator(Object* maybe_array) : list_(NULL) { Reset(maybe_array); }
2521 void Reset(Object* maybe_array);
2522
2523 template <class T>
2524 inline T* Next();
2525
2526 private:
2527 int index_;
2528 WeakFixedArray* list_;
2529 #ifdef DEBUG
2530 int last_used_index_;
2531 DisallowHeapAllocation no_gc_;
2532 #endif // DEBUG
2533 DISALLOW_COPY_AND_ASSIGN(Iterator);
2534 };
2535
2518 DECLARE_CAST(WeakFixedArray) 2536 DECLARE_CAST(WeakFixedArray)
2519 2537
2520 private: 2538 private:
2521 static const int kLastUsedIndexIndex = 0; 2539 static const int kLastUsedIndexIndex = 0;
2522 static const int kFirstIndex = 1; 2540 static const int kFirstIndex = 1;
2523 2541
2524 static Handle<WeakFixedArray> Allocate( 2542 static Handle<WeakFixedArray> Allocate(
2525 Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from); 2543 Isolate* isolate, int size, Handle<WeakFixedArray> initialize_from);
2526 2544
2527 static void Set(Handle<WeakFixedArray> array, int index, 2545 static void Set(Handle<WeakFixedArray> array, int index,
(...skipping 3395 matching lines...) Expand 10 before | Expand all | Expand 10 after
5923 // Init line_ends array with code positions of line ends inside script source. 5941 // Init line_ends array with code positions of line ends inside script source.
5924 static void InitLineEnds(Handle<Script> script); 5942 static void InitLineEnds(Handle<Script> script);
5925 5943
5926 // Get the JS object wrapping the given script; create it if none exists. 5944 // Get the JS object wrapping the given script; create it if none exists.
5927 static Handle<JSObject> GetWrapper(Handle<Script> script); 5945 static Handle<JSObject> GetWrapper(Handle<Script> script);
5928 5946
5929 // Look through the list of existing shared function infos to find one 5947 // Look through the list of existing shared function infos to find one
5930 // that matches the function literal. Return empty handle if not found. 5948 // that matches the function literal. Return empty handle if not found.
5931 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); 5949 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun);
5932 5950
5951 // Iterate over all script objects on the heap.
5952 class Iterator {
5953 public:
5954 explicit Iterator(Isolate* isolate);
5955 Script* Next();
5956
5957 private:
5958 WeakFixedArray::Iterator iterator_;
5959 DISALLOW_COPY_AND_ASSIGN(Iterator);
5960 };
5961
5933 // Dispatched behavior. 5962 // Dispatched behavior.
5934 DECLARE_PRINTER(Script) 5963 DECLARE_PRINTER(Script)
5935 DECLARE_VERIFIER(Script) 5964 DECLARE_VERIFIER(Script)
5936 5965
5937 static const int kSourceOffset = HeapObject::kHeaderSize; 5966 static const int kSourceOffset = HeapObject::kHeaderSize;
5938 static const int kNameOffset = kSourceOffset + kPointerSize; 5967 static const int kNameOffset = kSourceOffset + kPointerSize;
5939 static const int kLineOffsetOffset = kNameOffset + kPointerSize; 5968 static const int kLineOffsetOffset = kNameOffset + kPointerSize;
5940 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; 5969 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize;
5941 static const int kContextOffset = kColumnOffsetOffset + kPointerSize; 5970 static const int kContextOffset = kColumnOffsetOffset + kPointerSize;
5942 static const int kWrapperOffset = kContextOffset + kPointerSize; 5971 static const int kWrapperOffset = kContextOffset + kPointerSize;
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
6386 // Initialize a SharedFunctionInfo from a parsed function literal. 6415 // Initialize a SharedFunctionInfo from a parsed function literal.
6387 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, 6416 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info,
6388 FunctionLiteral* lit); 6417 FunctionLiteral* lit);
6389 6418
6390 // Dispatched behavior. 6419 // Dispatched behavior.
6391 DECLARE_PRINTER(SharedFunctionInfo) 6420 DECLARE_PRINTER(SharedFunctionInfo)
6392 DECLARE_VERIFIER(SharedFunctionInfo) 6421 DECLARE_VERIFIER(SharedFunctionInfo)
6393 6422
6394 void ResetForNewContext(int new_ic_age); 6423 void ResetForNewContext(int new_ic_age);
6395 6424
6425 // Iterate over all shared function infos that are created from a script.
6426 // That excludes shared function infos created for API functions and C++
6427 // builtins.
6428 class Iterator {
6429 public:
6430 explicit Iterator(Isolate* isolate);
6431 SharedFunctionInfo* Next();
6432
6433 private:
6434 bool NextScript();
6435
6436 Script::Iterator script_iterator_;
6437 WeakFixedArray::Iterator sfi_iterator_;
6438 DisallowHeapAllocation no_gc_;
6439 DISALLOW_COPY_AND_ASSIGN(Iterator);
6440 };
6441
6396 DECLARE_CAST(SharedFunctionInfo) 6442 DECLARE_CAST(SharedFunctionInfo)
6397 6443
6398 // Constants. 6444 // Constants.
6399 static const int kDontAdaptArgumentsSentinel = -1; 6445 static const int kDontAdaptArgumentsSentinel = -1;
6400 6446
6401 // Layout description. 6447 // Layout description.
6402 // Pointer fields. 6448 // Pointer fields.
6403 static const int kNameOffset = HeapObject::kHeaderSize; 6449 static const int kNameOffset = HeapObject::kHeaderSize;
6404 static const int kCodeOffset = kNameOffset + kPointerSize; 6450 static const int kCodeOffset = kNameOffset + kPointerSize;
6405 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; 6451 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize;
(...skipping 3797 matching lines...) Expand 10 before | Expand all | Expand 10 after
10203 } else { 10249 } else {
10204 value &= ~(1 << bit_position); 10250 value &= ~(1 << bit_position);
10205 } 10251 }
10206 return value; 10252 return value;
10207 } 10253 }
10208 }; 10254 };
10209 10255
10210 } } // namespace v8::internal 10256 } } // namespace v8::internal
10211 10257
10212 #endif // V8_OBJECTS_H_ 10258 #endif // V8_OBJECTS_H_
OLDNEW
« 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