| OLD | NEW |
| 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 3258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 RawFunction* function() const { | 3278 RawFunction* function() const { |
| 3279 return raw_ptr()->function_; | 3279 return reinterpret_cast<RawFunction*>(raw_ptr()->owner_); |
| 3280 } | 3280 } |
| 3281 void set_function(const Function& function) const { | 3281 |
| 3282 RawObject* owner() const { |
| 3283 return raw_ptr()->owner_; |
| 3284 } |
| 3285 |
| 3286 void set_owner(const Function& function) const { |
| 3282 ASSERT(function.IsOld()); | 3287 ASSERT(function.IsOld()); |
| 3283 StorePointer(&raw_ptr()->function_, function.raw()); | 3288 StorePointer(&raw_ptr()->owner_, |
| 3289 reinterpret_cast<RawObject*>(function.raw())); |
| 3290 } |
| 3291 |
| 3292 void set_owner(const Class& cls) { |
| 3293 ASSERT(cls.IsOld()); |
| 3294 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(cls.raw())); |
| 3284 } | 3295 } |
| 3285 | 3296 |
| 3286 // We would have a VisitPointers function here to traverse all the | 3297 // We would have a VisitPointers function here to traverse all the |
| 3287 // embedded objects in the instructions using pointer_offsets. | 3298 // embedded objects in the instructions using pointer_offsets. |
| 3288 | 3299 |
| 3289 static const intptr_t kBytesPerElement = | 3300 static const intptr_t kBytesPerElement = |
| 3290 sizeof(reinterpret_cast<RawCode*>(0)->data_[0]); | 3301 sizeof(reinterpret_cast<RawCode*>(0)->data_[0]); |
| 3291 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 3302 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 3292 | 3303 |
| 3293 static intptr_t InstanceSize() { | 3304 static intptr_t InstanceSize() { |
| 3294 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_)); | 3305 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_)); |
| 3295 return 0; | 3306 return 0; |
| 3296 } | 3307 } |
| 3297 static intptr_t InstanceSize(intptr_t len) { | 3308 static intptr_t InstanceSize(intptr_t len) { |
| 3298 ASSERT(0 <= len && len <= kMaxElements); | 3309 ASSERT(0 <= len && len <= kMaxElements); |
| 3299 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement)); | 3310 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement)); |
| 3300 } | 3311 } |
| 3301 static RawCode* FinalizeCode(const Function& function, | 3312 static RawCode* FinalizeCode(const Function& function, |
| 3302 Assembler* assembler, | 3313 Assembler* assembler, |
| 3303 bool optimized = false); | 3314 bool optimized = false); |
| 3304 static RawCode* FinalizeCode(const char* name, | 3315 static RawCode* FinalizeCode(const char* name, |
| 3305 Assembler* assembler, | 3316 Assembler* assembler, |
| 3306 bool optimized = false); | 3317 bool optimized = false); |
| 3307 static RawCode* LookupCode(uword pc); | 3318 static RawCode* LookupCode(uword pc); |
| 3319 static RawCode* LookupCodeInVmIsolate(uword pc); |
| 3308 | 3320 |
| 3309 int32_t GetPointerOffsetAt(int index) const { | 3321 int32_t GetPointerOffsetAt(int index) const { |
| 3310 return *PointerOffsetAddrAt(index); | 3322 return *PointerOffsetAddrAt(index); |
| 3311 } | 3323 } |
| 3312 intptr_t GetTokenIndexOfPC(uword pc) const; | 3324 intptr_t GetTokenIndexOfPC(uword pc) const; |
| 3313 | 3325 |
| 3314 // Find pc, return 0 if not found. | 3326 // Find pc, return 0 if not found. |
| 3315 uword GetPatchCodePc() const; | 3327 uword GetPatchCodePc() const; |
| 3316 uword GetLazyDeoptPc() const; | 3328 uword GetLazyDeoptPc() const; |
| 3317 | 3329 |
| 3318 uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const; | 3330 uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const; |
| 3319 intptr_t GetDeoptIdForOsr(uword pc) const; | 3331 intptr_t GetDeoptIdForOsr(uword pc) const; |
| 3320 | 3332 |
| 3321 // Returns true if there is an object in the code between 'start_offset' | 3333 // Returns true if there is an object in the code between 'start_offset' |
| 3322 // (inclusive) and 'end_offset' (exclusive). | 3334 // (inclusive) and 'end_offset' (exclusive). |
| 3323 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const; | 3335 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const; |
| 3324 | 3336 |
| 3325 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. | 3337 // Each (*node_ids)[n] has a an extracted ic data array (*arrays)[n]. |
| 3326 // Returns the maximum id found. | 3338 // Returns the maximum id found. |
| 3327 intptr_t ExtractIcDataArraysAtCalls( | 3339 intptr_t ExtractIcDataArraysAtCalls( |
| 3328 GrowableArray<intptr_t>* node_ids, | 3340 GrowableArray<intptr_t>* node_ids, |
| 3329 const GrowableObjectArray& ic_data_objs) const; | 3341 const GrowableObjectArray& ic_data_objs) const; |
| 3330 | 3342 |
| 3331 // Returns an array indexed by deopt id, containing the extracted ICData. | 3343 // Returns an array indexed by deopt id, containing the extracted ICData. |
| 3332 RawArray* ExtractTypeFeedbackArray() const; | 3344 RawArray* ExtractTypeFeedbackArray() const; |
| 3333 | 3345 |
| 3346 RawString* Name() const; |
| 3347 RawString* UserName() const; |
| 3348 |
| 3334 private: | 3349 private: |
| 3335 void set_state_bits(intptr_t bits) const; | 3350 void set_state_bits(intptr_t bits) const; |
| 3336 | 3351 |
| 3337 friend class RawCode; | 3352 friend class RawCode; |
| 3338 enum { | 3353 enum { |
| 3339 kOptimizedBit = 0, | 3354 kOptimizedBit = 0, |
| 3340 kAliveBit = 1, | 3355 kAliveBit = 1, |
| 3341 }; | 3356 }; |
| 3342 | 3357 |
| 3343 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; | 3358 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3376 ASSERT(index >= 0); | 3391 ASSERT(index >= 0); |
| 3377 ASSERT(index < pointer_offsets_length()); | 3392 ASSERT(index < pointer_offsets_length()); |
| 3378 // TODO(iposva): Unit test is missing for this functionality. | 3393 // TODO(iposva): Unit test is missing for this functionality. |
| 3379 return &raw_ptr()->data_[index]; | 3394 return &raw_ptr()->data_[index]; |
| 3380 } | 3395 } |
| 3381 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { | 3396 void SetPointerOffsetAt(int index, int32_t offset_in_instructions) { |
| 3382 *PointerOffsetAddrAt(index) = offset_in_instructions; | 3397 *PointerOffsetAddrAt(index) = offset_in_instructions; |
| 3383 } | 3398 } |
| 3384 | 3399 |
| 3385 intptr_t BinarySearchInSCallTable(uword pc) const; | 3400 intptr_t BinarySearchInSCallTable(uword pc) const; |
| 3401 static RawCode* LookupCodeInIsolate(Isolate* isolate, uword pc); |
| 3386 | 3402 |
| 3387 // New is a private method as RawInstruction and RawCode objects should | 3403 // New is a private method as RawInstruction and RawCode objects should |
| 3388 // only be created using the Code::FinalizeCode method. This method creates | 3404 // only be created using the Code::FinalizeCode method. This method creates |
| 3389 // the RawInstruction and RawCode objects, sets up the pointer offsets | 3405 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 3390 // and links the two in a GC safe manner. | 3406 // and links the two in a GC safe manner. |
| 3391 static RawCode* New(intptr_t pointer_offsets_length); | 3407 static RawCode* New(intptr_t pointer_offsets_length); |
| 3392 | 3408 |
| 3393 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); | 3409 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); |
| 3394 friend class Class; | 3410 friend class Class; |
| 3395 | 3411 |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4930 sizeof(RawInstance) + (2 * kWordSize); | 4946 sizeof(RawInstance) + (2 * kWordSize); |
| 4931 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; | 4947 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; |
| 4932 | 4948 |
| 4933 class CodePointIterator : public ValueObject { | 4949 class CodePointIterator : public ValueObject { |
| 4934 public: | 4950 public: |
| 4935 explicit CodePointIterator(const String& str) | 4951 explicit CodePointIterator(const String& str) |
| 4936 : str_(str), | 4952 : str_(str), |
| 4937 ch_(0), | 4953 ch_(0), |
| 4938 index_(-1), | 4954 index_(-1), |
| 4939 end_(str.Length()) { | 4955 end_(str.Length()) { |
| 4956 ASSERT(!str_.IsNull()); |
| 4940 } | 4957 } |
| 4941 | 4958 |
| 4942 CodePointIterator(const String& str, intptr_t start, intptr_t length) | 4959 CodePointIterator(const String& str, intptr_t start, intptr_t length) |
| 4943 : str_(str), | 4960 : str_(str), |
| 4944 ch_(0), | 4961 ch_(0), |
| 4945 index_(start - 1), | 4962 index_(start - 1), |
| 4946 end_(start + length) { | 4963 end_(start + length) { |
| 4947 ASSERT(start >= 0); | 4964 ASSERT(start >= 0); |
| 4948 ASSERT(end_ <= str.Length()); | 4965 ASSERT(end_ <= str.Length()); |
| 4949 } | 4966 } |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6648 | 6665 |
| 6649 | 6666 |
| 6650 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6667 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6651 intptr_t index) { | 6668 intptr_t index) { |
| 6652 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6669 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6653 } | 6670 } |
| 6654 | 6671 |
| 6655 } // namespace dart | 6672 } // namespace dart |
| 6656 | 6673 |
| 6657 #endif // VM_OBJECT_H_ | 6674 #endif // VM_OBJECT_H_ |
| OLD | NEW |