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

Side by Side Diff: src/objects.h

Issue 203583007: Support weak heap references in the ConstantPool to support IsWeakObjectInOptimizedCode objects. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3171 3171
3172 3172
3173 // ConstantPoolArray describes a fixed-sized array containing constant pool 3173 // ConstantPoolArray describes a fixed-sized array containing constant pool
3174 // entires. 3174 // entires.
3175 // The format of the pool is: 3175 // The format of the pool is:
3176 // [0]: Field holding the first index which is a raw code target pointer entry 3176 // [0]: Field holding the first index which is a raw code target pointer entry
3177 // [1]: Field holding the first index which is a heap pointer entry 3177 // [1]: Field holding the first index which is a heap pointer entry
3178 // [2]: Field holding the first index which is a int32 entry 3178 // [2]: Field holding the first index which is a int32 entry
3179 // [3] ... [first_code_ptr_index() - 1] : 64 bit entries 3179 // [3] ... [first_code_ptr_index() - 1] : 64 bit entries
3180 // [first_code_ptr_index()] ... [first_heap_ptr_index() - 1] : code pointers 3180 // [first_code_ptr_index()] ... [first_heap_ptr_index() - 1] : code pointers
3181 // [first_heap_ptr_index()] ... [first_int32_index() - 1] : heap pointers 3181 // [first_heap_ptr_index()] ... [first_weak_ptr_index() - 1] : heap pointers
3182 // [first_weak_ptr_index()] ... [first_int32_index() - 1] : weak pointers
3182 // [first_int32_index()] ... [length - 1] : 32 bit entries 3183 // [first_int32_index()] ... [length - 1] : 32 bit entries
3183 class ConstantPoolArray: public FixedArrayBase { 3184 class ConstantPoolArray: public FixedArrayBase {
3184 public: 3185 public:
3185 // Getters for the field storing the first index for different type entries. 3186 // Getters for the field storing the first index for different type entries.
3187 inline int first_ptr_index();
3186 inline int first_code_ptr_index(); 3188 inline int first_code_ptr_index();
3187 inline int first_heap_ptr_index(); 3189 inline int first_heap_ptr_index();
3190 inline int first_weak_ptr_index();
3188 inline int first_int64_index(); 3191 inline int first_int64_index();
3189 inline int first_int32_index(); 3192 inline int first_int32_index();
3190 3193
3191 // Getters for counts of different type entries. 3194 // Getters for counts of different type entries.
3195 inline int count_of_ptr_entries();
3192 inline int count_of_code_ptr_entries(); 3196 inline int count_of_code_ptr_entries();
3193 inline int count_of_heap_ptr_entries(); 3197 inline int count_of_heap_ptr_entries();
3198 inline int count_of_weak_ptr_entries();
3194 inline int count_of_int64_entries(); 3199 inline int count_of_int64_entries();
3195 inline int count_of_int32_entries(); 3200 inline int count_of_int32_entries();
3196 3201
3197 // Setter and getter for pool elements. 3202 // Setter and getter for pool elements.
3198 inline Address get_code_ptr_entry(int index); 3203 inline Address get_code_ptr_entry(int index);
3199 inline Object* get_heap_ptr_entry(int index); 3204 inline Object* get_heap_ptr_entry(int index);
3205 inline Object* get_weak_ptr_entry(int index);
3200 inline int64_t get_int64_entry(int index); 3206 inline int64_t get_int64_entry(int index);
3201 inline int32_t get_int32_entry(int index); 3207 inline int32_t get_int32_entry(int index);
3202 inline double get_int64_entry_as_double(int index); 3208 inline double get_int64_entry_as_double(int index);
3203 3209
3204 inline void set(int index, Address value); 3210 inline void set(int index, Address value);
3205 inline void set(int index, Object* value); 3211 inline void set(int index, Object* value);
3206 inline void set(int index, int64_t value); 3212 inline void set(int index, int64_t value);
3207 inline void set(int index, double value); 3213 inline void set(int index, double value);
3208 inline void set(int index, int32_t value); 3214 inline void set(int index, int32_t value);
3209 3215
3210 // Set up initial state. 3216 // Set up initial state.
3211 inline void SetEntryCounts(int number_of_int64_entries, 3217 inline void SetEntryCounts(int number_of_int64_entries,
3212 int number_of_code_ptr_entries, 3218 int number_of_code_ptr_entries,
3213 int number_of_heap_ptr_entries, 3219 int number_of_heap_ptr_entries,
3220 int number_of_weak_ptr_entries,
3214 int number_of_int32_entries); 3221 int number_of_int32_entries);
3215 3222
3216 // Copy operations 3223 // Copy operations
3217 MUST_USE_RESULT inline MaybeObject* Copy(); 3224 MUST_USE_RESULT inline MaybeObject* Copy();
3218 3225
3219 // Garbage collection support. 3226 // Garbage collection support.
3220 inline static int SizeFor(int number_of_int64_entries, 3227 inline static int SizeFor(int number_of_int64_entries,
3221 int number_of_code_ptr_entries, 3228 int number_of_ptr_entries,
3222 int number_of_heap_ptr_entries,
3223 int number_of_int32_entries) { 3229 int number_of_int32_entries) {
3224 return RoundUp(OffsetAt(number_of_int64_entries, 3230 return RoundUp(OffsetAt(number_of_int64_entries,
3225 number_of_code_ptr_entries, 3231 number_of_ptr_entries,
3226 number_of_heap_ptr_entries,
3227 number_of_int32_entries), 3232 number_of_int32_entries),
3228 kPointerSize); 3233 kPointerSize);
3229 } 3234 }
3230 3235
3231 // Code Generation support. 3236 // Code Generation support.
3232 inline int OffsetOfElementAt(int index) { 3237 inline int OffsetOfElementAt(int index) {
3233 ASSERT(index < length()); 3238 ASSERT(index < length());
3234 if (index >= first_int32_index()) { 3239 if (index >= first_int32_index()) {
3235 return OffsetAt(count_of_int64_entries(), count_of_code_ptr_entries(), 3240 return OffsetAt(count_of_int64_entries(), count_of_ptr_entries(),
3236 count_of_heap_ptr_entries(), index - first_int32_index()); 3241 index - first_int32_index());
3237 } else if (index >= first_heap_ptr_index()) { 3242 } else if (index >= first_ptr_index()) {
3238 return OffsetAt(count_of_int64_entries(), count_of_code_ptr_entries(), 3243 return OffsetAt(count_of_int64_entries(), index - first_ptr_index(), 0);
3239 index - first_heap_ptr_index(), 0);
3240 } else if (index >= first_code_ptr_index()) {
3241 return OffsetAt(count_of_int64_entries(), index - first_code_ptr_index(),
3242 0, 0);
3243 } else { 3244 } else {
3244 return OffsetAt(index, 0, 0, 0); 3245 return OffsetAt(index, 0, 0);
3245 } 3246 }
3246 } 3247 }
3247 3248
3248 // Casting. 3249 // Casting.
3249 static inline ConstantPoolArray* cast(Object* obj); 3250 static inline ConstantPoolArray* cast(Object* obj);
3250 3251
3251 // Garbage collection support. 3252 // Garbage collection support.
3252 Object** RawFieldOfElementAt(int index) { 3253 Object** RawFieldOfElementAt(int index) {
3253 return HeapObject::RawField(this, OffsetOfElementAt(index)); 3254 return HeapObject::RawField(this, OffsetOfElementAt(index));
3254 } 3255 }
3255 3256
3256 // Layout description. 3257 // Layout description.
3257 static const int kFirstCodePointerIndexOffset = FixedArray::kHeaderSize; 3258 static const int kFirstCodePointerIndexOffset = FixedArray::kHeaderSize;
3258 static const int kFirstHeapPointerIndexOffset = 3259 static const int kFirstHeapPointerIndexOffset =
3259 kFirstCodePointerIndexOffset + kPointerSize; 3260 kFirstCodePointerIndexOffset + kPointerSize;
3261 static const int kFirstWeakPointerIndexOffset =
3262 kFirstHeapPointerIndexOffset + kPointerSize;
3260 static const int kFirstInt32IndexOffset = 3263 static const int kFirstInt32IndexOffset =
3261 kFirstHeapPointerIndexOffset + kPointerSize; 3264 kFirstWeakPointerIndexOffset + kPointerSize;
3262 static const int kFirstOffset = kFirstInt32IndexOffset + kPointerSize; 3265 static const int kFirstOffset = kFirstInt32IndexOffset + kPointerSize;
3263 3266
3264 // Dispatched behavior. 3267 // Dispatched behavior.
3265 void ConstantPoolIterateBody(ObjectVisitor* v); 3268 void ConstantPoolIterateBody(ObjectVisitor* v);
3266 3269
3267 DECLARE_PRINTER(ConstantPoolArray) 3270 DECLARE_PRINTER(ConstantPoolArray)
3268 DECLARE_VERIFIER(ConstantPoolArray) 3271 DECLARE_VERIFIER(ConstantPoolArray)
3269 3272
3270 private: 3273 private:
3271 inline void set_first_code_ptr_index(int value); 3274 inline void set_first_code_ptr_index(int value);
3272 inline void set_first_heap_ptr_index(int value); 3275 inline void set_first_heap_ptr_index(int value);
3276 inline void set_first_weak_ptr_index(int value);
3273 inline void set_first_int32_index(int value); 3277 inline void set_first_int32_index(int value);
3274 3278
3275 inline static int OffsetAt(int number_of_int64_entries, 3279 inline static int OffsetAt(int number_of_int64_entries,
3276 int number_of_code_ptr_entries, 3280 int number_of_ptr_entries,
3277 int number_of_heap_ptr_entries,
3278 int number_of_int32_entries) { 3281 int number_of_int32_entries) {
3279 return kFirstOffset 3282 return kFirstOffset
3280 + (number_of_int64_entries * kInt64Size) 3283 + (number_of_int64_entries * kInt64Size)
3281 + (number_of_code_ptr_entries * kPointerSize) 3284 + (number_of_ptr_entries * kPointerSize)
3282 + (number_of_heap_ptr_entries * kPointerSize)
3283 + (number_of_int32_entries * kInt32Size); 3285 + (number_of_int32_entries * kInt32Size);
3284 } 3286 }
3285 3287
3286 DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantPoolArray); 3288 DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantPoolArray);
3287 }; 3289 };
3288 3290
3289 3291
3290 // DescriptorArrays are fixed arrays used to hold instance descriptors. 3292 // DescriptorArrays are fixed arrays used to hold instance descriptors.
3291 // The format of the these objects is: 3293 // The format of the these objects is:
3292 // [0]: Number of descriptors 3294 // [0]: Number of descriptors
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
5542 bool CanDeoptAt(Address pc); 5544 bool CanDeoptAt(Address pc);
5543 5545
5544 #ifdef VERIFY_HEAP 5546 #ifdef VERIFY_HEAP
5545 void VerifyEmbeddedObjectsDependency(); 5547 void VerifyEmbeddedObjectsDependency();
5546 #endif 5548 #endif
5547 5549
5548 inline bool IsWeakObject(Object* object) { 5550 inline bool IsWeakObject(Object* object) {
5549 return is_optimized_code() && IsWeakObjectInOptimizedCode(object); 5551 return is_optimized_code() && IsWeakObjectInOptimizedCode(object);
5550 } 5552 }
5551 5553
5552 inline bool IsWeakObjectInOptimizedCode(Object* object); 5554 static inline bool IsWeakObjectInOptimizedCode(Object* object);
5553 5555
5554 // Max loop nesting marker used to postpose OSR. We don't take loop 5556 // Max loop nesting marker used to postpose OSR. We don't take loop
5555 // nesting that is deeper than 5 levels into account. 5557 // nesting that is deeper than 5 levels into account.
5556 static const int kMaxLoopNestingMarker = 6; 5558 static const int kMaxLoopNestingMarker = 6;
5557 5559
5558 // Layout description. 5560 // Layout description.
5559 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; 5561 static const int kInstructionSizeOffset = HeapObject::kHeaderSize;
5560 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; 5562 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize;
5561 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; 5563 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize;
5562 static const int kDeoptimizationDataOffset = 5564 static const int kDeoptimizationDataOffset =
(...skipping 5221 matching lines...) Expand 10 before | Expand all | Expand 10 after
10784 } else { 10786 } else {
10785 value &= ~(1 << bit_position); 10787 value &= ~(1 << bit_position);
10786 } 10788 }
10787 return value; 10789 return value;
10788 } 10790 }
10789 }; 10791 };
10790 10792
10791 } } // namespace v8::internal 10793 } } // namespace v8::internal
10792 10794
10793 #endif // V8_OBJECTS_H_ 10795 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | src/objects-visiting-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698