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

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 {
3279 return raw_ptr()->owner_->IsHeapObject();
3280 }
3281
3282 bool OwnerIsNotNullFunction() const {
3283 return (raw_ptr()->owner_->IsHeapObject()) &&
3284 (raw_ptr()->owner_ != Function::null());
3285 }
3286
3287 bool OwnerIsAllocationStub() const {
3288 return !raw_ptr()->owner_->IsHeapObject();
3289 }
3290
3278 RawFunction* function() const { 3291 RawFunction* function() const {
3279 return raw_ptr()->function_; 3292 ASSERT(OwnerIsFunction());
3293 return reinterpret_cast<RawFunction*>(raw_ptr()->owner_);
3280 } 3294 }
3281 void set_function(const Function& function) const { 3295
3296 RawSmi* allocation_stub_class_id() const {
3297 ASSERT(OwnerIsAllocationStub());
3298 return reinterpret_cast<RawSmi*>(raw_ptr()->owner_);
3299 }
3300
3301 void set_owner_function(const Function& function) const {
turnidge 2014/02/28 19:23:37 Consider camel-case for this function and the one
3282 ASSERT(function.IsOld()); 3302 ASSERT(function.IsOld());
3283 StorePointer(&raw_ptr()->function_, function.raw()); 3303 StorePointer(&raw_ptr()->owner_,
3304 reinterpret_cast<RawObject*>(function.raw()));
3305 }
3306
3307 void set_owner_allocation_stub_class_id(RawSmi* cid) const {
3308 ASSERT(!cid->IsHeapObject());
3309 raw_ptr()->owner_ = reinterpret_cast<RawObject*>(cid);
3284 } 3310 }
3285 3311
3286 // We would have a VisitPointers function here to traverse all the 3312 // We would have a VisitPointers function here to traverse all the
3287 // embedded objects in the instructions using pointer_offsets. 3313 // embedded objects in the instructions using pointer_offsets.
3288 3314
3289 static const intptr_t kBytesPerElement = 3315 static const intptr_t kBytesPerElement =
3290 sizeof(reinterpret_cast<RawCode*>(0)->data_[0]); 3316 sizeof(reinterpret_cast<RawCode*>(0)->data_[0]);
3291 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 3317 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
3292 3318
3293 static intptr_t InstanceSize() { 3319 static intptr_t InstanceSize() {
3294 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_)); 3320 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_));
3295 return 0; 3321 return 0;
3296 } 3322 }
3297 static intptr_t InstanceSize(intptr_t len) { 3323 static intptr_t InstanceSize(intptr_t len) {
3298 ASSERT(0 <= len && len <= kMaxElements); 3324 ASSERT(0 <= len && len <= kMaxElements);
3299 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement)); 3325 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement));
3300 } 3326 }
3301 static RawCode* FinalizeCode(const Function& function, 3327 static RawCode* FinalizeCode(const Function& function,
3302 Assembler* assembler, 3328 Assembler* assembler,
3303 bool optimized = false); 3329 bool optimized = false);
3304 static RawCode* FinalizeCode(const char* name, 3330 static RawCode* FinalizeCode(const char* name,
3305 Assembler* assembler, 3331 Assembler* assembler,
3306 bool optimized = false); 3332 bool optimized = false);
3307 static RawCode* LookupCode(uword pc); 3333 static RawCode* LookupCode(uword pc);
3334 static RawCode* LookupCodeInVmIsolate(uword pc);
3308 3335
3309 int32_t GetPointerOffsetAt(int index) const { 3336 int32_t GetPointerOffsetAt(int index) const {
3310 return *PointerOffsetAddrAt(index); 3337 return *PointerOffsetAddrAt(index);
3311 } 3338 }
3312 intptr_t GetTokenIndexOfPC(uword pc) const; 3339 intptr_t GetTokenIndexOfPC(uword pc) const;
3313 3340
3314 // Find pc, return 0 if not found. 3341 // Find pc, return 0 if not found.
3315 uword GetPatchCodePc() const; 3342 uword GetPatchCodePc() const;
3316 uword GetLazyDeoptPc() const; 3343 uword GetLazyDeoptPc() const;
3317 3344
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 ASSERT(index >= 0); 3403 ASSERT(index >= 0);
3377 ASSERT(index < pointer_offsets_length()); 3404 ASSERT(index < pointer_offsets_length());
3378 // TODO(iposva): Unit test is missing for this functionality. 3405 // TODO(iposva): Unit test is missing for this functionality.
3379 return &raw_ptr()->data_[index]; 3406 return &raw_ptr()->data_[index];
3380 } 3407 }
3381 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { 3408 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) {
3382 *PointerOffsetAddrAt(index) = offset_in_instructions; 3409 *PointerOffsetAddrAt(index) = offset_in_instructions;
3383 } 3410 }
3384 3411
3385 intptr_t BinarySearchInSCallTable(uword pc) const; 3412 intptr_t BinarySearchInSCallTable(uword pc) const;
3413 static RawCode* LookupCodeInIsolate(Isolate* isolate, uword pc);
3386 3414
3387 // New is a private method as RawInstruction and RawCode objects should 3415 // New is a private method as RawInstruction and RawCode objects should
3388 // only be created using the Code::FinalizeCode method. This method creates 3416 // only be created using the Code::FinalizeCode method. This method creates
3389 // the RawInstruction and RawCode objects, sets up the pointer offsets 3417 // the RawInstruction and RawCode objects, sets up the pointer offsets
3390 // and links the two in a GC safe manner. 3418 // and links the two in a GC safe manner.
3391 static RawCode* New(intptr_t pointer_offsets_length); 3419 static RawCode* New(intptr_t pointer_offsets_length);
3392 3420
3393 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); 3421 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object);
3394 friend class Class; 3422 friend class Class;
3395 3423
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4930 sizeof(RawInstance) + (2 * kWordSize); 4958 sizeof(RawInstance) + (2 * kWordSize);
4931 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; 4959 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar;
4932 4960
4933 class CodePointIterator : public ValueObject { 4961 class CodePointIterator : public ValueObject {
4934 public: 4962 public:
4935 explicit CodePointIterator(const String& str) 4963 explicit CodePointIterator(const String& str)
4936 : str_(str), 4964 : str_(str),
4937 ch_(0), 4965 ch_(0),
4938 index_(-1), 4966 index_(-1),
4939 end_(str.Length()) { 4967 end_(str.Length()) {
4968 ASSERT(!str_.IsNull());
4940 } 4969 }
4941 4970
4942 CodePointIterator(const String& str, intptr_t start, intptr_t length) 4971 CodePointIterator(const String& str, intptr_t start, intptr_t length)
4943 : str_(str), 4972 : str_(str),
4944 ch_(0), 4973 ch_(0),
4945 index_(start - 1), 4974 index_(start - 1),
4946 end_(start + length) { 4975 end_(start + length) {
4947 ASSERT(start >= 0); 4976 ASSERT(start >= 0);
4948 ASSERT(end_ <= str.Length()); 4977 ASSERT(end_ <= str.Length());
4949 } 4978 }
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 6677
6649 6678
6650 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6679 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6651 intptr_t index) { 6680 intptr_t index) {
6652 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6681 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6653 } 6682 }
6654 6683
6655 } // namespace dart 6684 } // namespace dart
6656 6685
6657 #endif // VM_OBJECT_H_ 6686 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698