| 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 10 matching lines...) Expand all Loading... |
| 21 namespace dart { | 21 namespace dart { |
| 22 | 22 |
| 23 // Forward declarations. | 23 // Forward declarations. |
| 24 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 24 #define DEFINE_FORWARD_DECLARATION(clazz) \ |
| 25 class clazz; | 25 class clazz; |
| 26 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 26 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
| 27 #undef DEFINE_FORWARD_DECLARATION | 27 #undef DEFINE_FORWARD_DECLARATION |
| 28 class Api; | 28 class Api; |
| 29 class Assembler; | 29 class Assembler; |
| 30 class Code; | 30 class Code; |
| 31 class DeoptInstr; |
| 31 class LocalScope; | 32 class LocalScope; |
| 32 class Symbols; | 33 class Symbols; |
| 33 | 34 |
| 34 #define OBJECT_IMPLEMENTATION(object, super) \ | 35 #define OBJECT_IMPLEMENTATION(object, super) \ |
| 35 public: /* NOLINT */ \ | 36 public: /* NOLINT */ \ |
| 36 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ | 37 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ |
| 37 void operator=(Raw##object* value) { \ | 38 void operator=(Raw##object* value) { \ |
| 38 initializeHandle(this, value); \ | 39 initializeHandle(this, value); \ |
| 39 } \ | 40 } \ |
| 40 bool Is##object() const { return true; } \ | 41 bool Is##object() const { return true; } \ |
| (...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 private: | 2322 private: |
| 2322 // Describes the layout of deopt info data. The index of a deopt-info entry | 2323 // Describes the layout of deopt info data. The index of a deopt-info entry |
| 2323 // is implicitly the target slot in which the value is written into. | 2324 // is implicitly the target slot in which the value is written into. |
| 2324 enum { | 2325 enum { |
| 2325 kInstruction = 0, | 2326 kInstruction = 0, |
| 2326 kFromIndex, | 2327 kFromIndex, |
| 2327 kNumberOfEntries, | 2328 kNumberOfEntries, |
| 2328 }; | 2329 }; |
| 2329 | 2330 |
| 2330 public: | 2331 public: |
| 2332 // The number of instructions. |
| 2331 intptr_t Length() const; | 2333 intptr_t Length() const; |
| 2332 | 2334 |
| 2335 // The number of real (non-suffix) instructions needed to execute the |
| 2336 // deoptimization translation. |
| 2337 intptr_t TranslationLength() const; |
| 2338 |
| 2333 static RawDeoptInfo* New(intptr_t num_commands); | 2339 static RawDeoptInfo* New(intptr_t num_commands); |
| 2334 | 2340 |
| 2335 static const intptr_t kBytesPerElement = (kNumberOfEntries * kWordSize); | 2341 static const intptr_t kBytesPerElement = (kNumberOfEntries * kWordSize); |
| 2336 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 2342 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 2337 | 2343 |
| 2338 static intptr_t InstanceSize() { | 2344 static intptr_t InstanceSize() { |
| 2339 ASSERT(sizeof(RawDeoptInfo) == OFFSET_OF(RawDeoptInfo, data_)); | 2345 ASSERT(sizeof(RawDeoptInfo) == OFFSET_OF(RawDeoptInfo, data_)); |
| 2340 return 0; | 2346 return 0; |
| 2341 } | 2347 } |
| 2342 | 2348 |
| 2343 static intptr_t InstanceSize(intptr_t len) { | 2349 static intptr_t InstanceSize(intptr_t len) { |
| 2344 ASSERT(0 <= len && len <= kMaxElements); | 2350 ASSERT(0 <= len && len <= kMaxElements); |
| 2345 return RoundedAllocationSize(sizeof(RawDeoptInfo) + | 2351 return RoundedAllocationSize(sizeof(RawDeoptInfo) + |
| 2346 (len * kBytesPerElement)); | 2352 (len * kBytesPerElement)); |
| 2347 } | 2353 } |
| 2348 | 2354 |
| 2349 // 'index' corresponds to target, to-index. | 2355 // 'index' corresponds to target, to-index. |
| 2350 void SetAt(intptr_t index, | 2356 void SetAt(intptr_t index, |
| 2351 intptr_t instr_kind, | 2357 intptr_t instr_kind, |
| 2352 intptr_t from_index) const; | 2358 intptr_t from_index) const; |
| 2353 | 2359 |
| 2354 intptr_t Instruction(intptr_t index) const; | 2360 intptr_t Instruction(intptr_t index) const; |
| 2355 intptr_t FromIndex(intptr_t index) const; | 2361 intptr_t FromIndex(intptr_t index) const; |
| 2356 intptr_t ToIndex(intptr_t index) const { | 2362 intptr_t ToIndex(intptr_t index) const { |
| 2357 return index; | 2363 return index; |
| 2358 } | 2364 } |
| 2359 | 2365 |
| 2366 // Unpack the entire translation into an array of deoptimization |
| 2367 // instructions. This copies any shared suffixes into the array. |
| 2368 void ToInstructions(const Array& table, |
| 2369 GrowableArray<DeoptInstr*>* instructions) const; |
| 2370 |
| 2360 private: | 2371 private: |
| 2361 intptr_t* EntryAddr(intptr_t index, intptr_t entry_offset) const { | 2372 intptr_t* EntryAddr(intptr_t index, intptr_t entry_offset) const { |
| 2362 ASSERT((index >=0) && (index < Length())); | 2373 ASSERT((index >=0) && (index < Length())); |
| 2363 intptr_t data_index = (index * kNumberOfEntries) + entry_offset; | 2374 intptr_t data_index = (index * kNumberOfEntries) + entry_offset; |
| 2364 return &raw_ptr()->data_[data_index]; | 2375 return &raw_ptr()->data_[data_index]; |
| 2365 } | 2376 } |
| 2366 | 2377 |
| 2367 void SetLength(intptr_t value) const; | 2378 void SetLength(intptr_t value) const; |
| 2368 | 2379 |
| 2369 HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object); | 2380 HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object); |
| (...skipping 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5737 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5748 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5738 return false; | 5749 return false; |
| 5739 } | 5750 } |
| 5740 } | 5751 } |
| 5741 return true; | 5752 return true; |
| 5742 } | 5753 } |
| 5743 | 5754 |
| 5744 } // namespace dart | 5755 } // namespace dart |
| 5745 | 5756 |
| 5746 #endif // VM_OBJECT_H_ | 5757 #endif // VM_OBJECT_H_ |
| OLD | NEW |