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

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

Issue 182703003: Cleanup native, collected, and stub code handling in profiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 (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 3257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 } 3268 }
3269 3269
3270 RawExceptionHandlers* exception_handlers() const { 3270 RawExceptionHandlers* exception_handlers() const {
3271 return raw_ptr()->exception_handlers_; 3271 return raw_ptr()->exception_handlers_;
3272 } 3272 }
3273 void set_exception_handlers(const ExceptionHandlers& handlers) const { 3273 void set_exception_handlers(const ExceptionHandlers& handlers) const {
3274 ASSERT(handlers.IsOld()); 3274 ASSERT(handlers.IsOld());
3275 StorePointer(&raw_ptr()->exception_handlers_, handlers.raw()); 3275 StorePointer(&raw_ptr()->exception_handlers_, handlers.raw());
3276 } 3276 }
3277 3277
3278 bool OwnerIsFunction() const {
Ivan Posva 2014/02/28 21:46:35 IsFunction, IsStub, IsAllocationStub
Cutch 2014/02/28 22:47:05 Done.
3279 return raw_ptr()->owner_->IsHeapObject();
3280 }
3281
3282 bool OwnerIsAllocationStub() const {
3283 return !raw_ptr()->owner_->IsHeapObject();
3284 }
3285
3286 bool OwnerIsStub() const {
3287 return raw_ptr()->owner_ == Function::null();
3288 }
3289
3278 RawFunction* function() const { 3290 RawFunction* function() const {
3279 return raw_ptr()->function_; 3291 ASSERT(OwnerIsFunction());
3292 return reinterpret_cast<RawFunction*>(raw_ptr()->owner_);
3280 } 3293 }
3281 void set_function(const Function& function) const { 3294
3295 RawSmi* allocation_stub_class_id() const {
3296 ASSERT(OwnerIsAllocationStub());
3297 return reinterpret_cast<RawSmi*>(raw_ptr()->owner_);
3298 }
3299
3300 void set_owner_function(const Function& function) const {
3282 ASSERT(function.IsOld()); 3301 ASSERT(function.IsOld());
3283 StorePointer(&raw_ptr()->function_, function.raw()); 3302 StorePointer(&raw_ptr()->owner_,
3303 reinterpret_cast<RawObject*>(function.raw()));
3304 }
3305
3306 void set_owner_allocation_stub_class_id(RawSmi* cid) const {
3307 ASSERT(!cid->IsHeapObject());
3308 raw_ptr()->owner_ = reinterpret_cast<RawObject*>(cid);
3284 } 3309 }
3285 3310
3286 // We would have a VisitPointers function here to traverse all the 3311 // We would have a VisitPointers function here to traverse all the
3287 // embedded objects in the instructions using pointer_offsets. 3312 // embedded objects in the instructions using pointer_offsets.
3288 3313
3289 static const intptr_t kBytesPerElement = 3314 static const intptr_t kBytesPerElement =
3290 sizeof(reinterpret_cast<RawCode*>(0)->data_[0]); 3315 sizeof(reinterpret_cast<RawCode*>(0)->data_[0]);
3291 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 3316 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
3292 3317
3293 static intptr_t InstanceSize() { 3318 static intptr_t InstanceSize() {
3294 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_)); 3319 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_));
3295 return 0; 3320 return 0;
3296 } 3321 }
3297 static intptr_t InstanceSize(intptr_t len) { 3322 static intptr_t InstanceSize(intptr_t len) {
3298 ASSERT(0 <= len && len <= kMaxElements); 3323 ASSERT(0 <= len && len <= kMaxElements);
3299 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement)); 3324 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement));
3300 } 3325 }
3301 static RawCode* FinalizeCode(const Function& function, 3326 static RawCode* FinalizeCode(const Function& function,
3302 Assembler* assembler, 3327 Assembler* assembler,
3303 bool optimized = false); 3328 bool optimized = false);
3304 static RawCode* FinalizeCode(const char* name, 3329 static RawCode* FinalizeCode(const char* name,
3305 Assembler* assembler, 3330 Assembler* assembler,
3306 bool optimized = false); 3331 bool optimized = false);
3307 static RawCode* LookupCode(uword pc); 3332 static RawCode* LookupCode(uword pc);
3333 static RawCode* LookupCodeInVmIsolate(uword pc);
3308 3334
3309 int32_t GetPointerOffsetAt(int index) const { 3335 int32_t GetPointerOffsetAt(int index) const {
3310 return *PointerOffsetAddrAt(index); 3336 return *PointerOffsetAddrAt(index);
3311 } 3337 }
3312 intptr_t GetTokenIndexOfPC(uword pc) const; 3338 intptr_t GetTokenIndexOfPC(uword pc) const;
3313 3339
3314 // Find pc, return 0 if not found. 3340 // Find pc, return 0 if not found.
3315 uword GetPatchCodePc() const; 3341 uword GetPatchCodePc() const;
3316 uword GetLazyDeoptPc() const; 3342 uword GetLazyDeoptPc() const;
3317 3343
3318 uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const; 3344 uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const;
3319 intptr_t GetDeoptIdForOsr(uword pc) const; 3345 intptr_t GetDeoptIdForOsr(uword pc) const;
3320 3346
3321 // Returns true if there is an object in the code between 'start_offset' 3347 // Returns true if there is an object in the code between 'start_offset'
3322 // (inclusive) and 'end_offset' (exclusive). 3348 // (inclusive) and 'end_offset' (exclusive).
3323 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const; 3349 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const;
3324 3350
3325 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. 3351 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n].
3326 // Returns the maximum id found. 3352 // Returns the maximum id found.
3327 intptr_t ExtractIcDataArraysAtCalls( 3353 intptr_t ExtractIcDataArraysAtCalls(
3328 GrowableArray<intptr_t>* node_ids, 3354 GrowableArray<intptr_t>* node_ids,
3329 const GrowableObjectArray& ic_data_objs) const; 3355 const GrowableObjectArray& ic_data_objs) const;
3330 3356
3331 // Returns an array indexed by deopt id, containing the extracted ICData. 3357 // Returns an array indexed by deopt id, containing the extracted ICData.
3332 RawArray* ExtractTypeFeedbackArray() const; 3358 RawArray* ExtractTypeFeedbackArray() const;
3333 3359
3360 RawString* Name() const;
3361 RawString* UserName() const;
3362
3334 private: 3363 private:
3335 void set_state_bits(intptr_t bits) const; 3364 void set_state_bits(intptr_t bits) const;
3336 3365
3337 friend class RawCode; 3366 friend class RawCode;
3338 enum { 3367 enum {
3339 kOptimizedBit = 0, 3368 kOptimizedBit = 0,
3340 kAliveBit = 1, 3369 kAliveBit = 1,
3341 }; 3370 };
3342 3371
3343 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; 3372 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {};
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 ASSERT(index >= 0); 3405 ASSERT(index >= 0);
3377 ASSERT(index < pointer_offsets_length()); 3406 ASSERT(index < pointer_offsets_length());
3378 // TODO(iposva): Unit test is missing for this functionality. 3407 // TODO(iposva): Unit test is missing for this functionality.
3379 return &raw_ptr()->data_[index]; 3408 return &raw_ptr()->data_[index];
3380 } 3409 }
3381 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { 3410 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) {
3382 *PointerOffsetAddrAt(index) = offset_in_instructions; 3411 *PointerOffsetAddrAt(index) = offset_in_instructions;
3383 } 3412 }
3384 3413
3385 intptr_t BinarySearchInSCallTable(uword pc) const; 3414 intptr_t BinarySearchInSCallTable(uword pc) const;
3415 static RawCode* LookupCodeInIsolate(Isolate* isolate, uword pc);
3386 3416
3387 // New is a private method as RawInstruction and RawCode objects should 3417 // New is a private method as RawInstruction and RawCode objects should
3388 // only be created using the Code::FinalizeCode method. This method creates 3418 // only be created using the Code::FinalizeCode method. This method creates
3389 // the RawInstruction and RawCode objects, sets up the pointer offsets 3419 // the RawInstruction and RawCode objects, sets up the pointer offsets
3390 // and links the two in a GC safe manner. 3420 // and links the two in a GC safe manner.
3391 static RawCode* New(intptr_t pointer_offsets_length); 3421 static RawCode* New(intptr_t pointer_offsets_length);
3392 3422
3393 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); 3423 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object);
3394 friend class Class; 3424 friend class Class;
3395 3425
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4930 sizeof(RawInstance) + (2 * kWordSize); 4960 sizeof(RawInstance) + (2 * kWordSize);
4931 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; 4961 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar;
4932 4962
4933 class CodePointIterator : public ValueObject { 4963 class CodePointIterator : public ValueObject {
4934 public: 4964 public:
4935 explicit CodePointIterator(const String& str) 4965 explicit CodePointIterator(const String& str)
4936 : str_(str), 4966 : str_(str),
4937 ch_(0), 4967 ch_(0),
4938 index_(-1), 4968 index_(-1),
4939 end_(str.Length()) { 4969 end_(str.Length()) {
4970 ASSERT(!str_.IsNull());
4940 } 4971 }
4941 4972
4942 CodePointIterator(const String& str, intptr_t start, intptr_t length) 4973 CodePointIterator(const String& str, intptr_t start, intptr_t length)
4943 : str_(str), 4974 : str_(str),
4944 ch_(0), 4975 ch_(0),
4945 index_(start - 1), 4976 index_(start - 1),
4946 end_(start + length) { 4977 end_(start + length) {
4947 ASSERT(start >= 0); 4978 ASSERT(start >= 0);
4948 ASSERT(end_ <= str.Length()); 4979 ASSERT(end_ <= str.Length());
4949 } 4980 }
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 6679
6649 6680
6650 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6681 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6651 intptr_t index) { 6682 intptr_t index) {
6652 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6683 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6653 } 6684 }
6654 6685
6655 } // namespace dart 6686 } // namespace dart
6656 6687
6657 #endif // VM_OBJECT_H_ 6688 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698