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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 // Returns an instance of Double or Double::null(). | 1203 // Returns an instance of Double or Double::null(). |
1204 // 'index' points to either: | 1204 // 'index' points to either: |
1205 // - constants_list_ position of found element, or | 1205 // - constants_list_ position of found element, or |
1206 // - constants_list_ position where new canonical can be inserted. | 1206 // - constants_list_ position where new canonical can be inserted. |
1207 RawDouble* LookupCanonicalDouble(Zone* zone, | 1207 RawDouble* LookupCanonicalDouble(Zone* zone, |
1208 double value, intptr_t* index) const; | 1208 double value, intptr_t* index) const; |
1209 RawMint* LookupCanonicalMint(Zone* zone, | 1209 RawMint* LookupCanonicalMint(Zone* zone, |
1210 int64_t value, intptr_t* index) const; | 1210 int64_t value, intptr_t* index) const; |
1211 RawBigint* LookupCanonicalBigint(Zone* zone, | 1211 RawBigint* LookupCanonicalBigint(Zone* zone, |
1212 const Bigint& value, intptr_t* index) const; | 1212 const Bigint& value, intptr_t* index) const; |
| 1213 RawPixels* LookupCanonicalPixels(Zone* zone, |
| 1214 intptr_t value, intptr_t* index) const; |
1213 // The methods above are more efficient than this generic one. | 1215 // The methods above are more efficient than this generic one. |
1214 RawInstance* LookupCanonicalInstance(Zone* zone, | 1216 RawInstance* LookupCanonicalInstance(Zone* zone, |
1215 const Instance& value) const; | 1217 const Instance& value) const; |
1216 | 1218 |
1217 RawInstance* InsertCanonicalConstant(Zone* zone, | 1219 RawInstance* InsertCanonicalConstant(Zone* zone, |
1218 const Instance& constant) const; | 1220 const Instance& constant) const; |
1219 void InsertCanonicalNumber(Zone* zone, | 1221 void InsertCanonicalNumber(Zone* zone, |
1220 intptr_t index, | 1222 intptr_t index, |
1221 const Number& constant) const; | 1223 const Number& constant) const; |
1222 | 1224 |
(...skipping 5114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6337 static RawTypedData* NewDigitsFromDecCString(const char* str, intptr_t* used, | 6339 static RawTypedData* NewDigitsFromDecCString(const char* str, intptr_t* used, |
6338 Heap::Space space = Heap::kNew); | 6340 Heap::Space space = Heap::kNew); |
6339 | 6341 |
6340 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); | 6342 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); |
6341 | 6343 |
6342 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); | 6344 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); |
6343 friend class Class; | 6345 friend class Class; |
6344 }; | 6346 }; |
6345 | 6347 |
6346 | 6348 |
6347 // Class Double represents class Double in corelib_impl, which implements | 6349 class Pixels : public Number { |
| 6350 public: |
| 6351 static const intptr_t kFractionalBits = 6; |
| 6352 static const intptr_t kScaling = 1 << kFractionalBits; |
| 6353 static const intptr_t kPlusInfinity = kSmiMax32; |
| 6354 static const intptr_t kMinusInfinity = kSmiMin32; |
| 6355 |
| 6356 // Returns the internal representation, i.e. the scaled value. |
| 6357 intptr_t Value() const { |
| 6358 return Smi::Value(raw_ptr()->value_); |
| 6359 } |
| 6360 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 6361 |
| 6362 static RawPixels* New(Heap::Space space = Heap::kNew) { // For snapshots. |
| 6363 return New(0, space); |
| 6364 } |
| 6365 |
| 6366 static RawPixels* New(intptr_t value, Heap::Space space = Heap::kNew); |
| 6367 |
| 6368 // Returns a canonical Pixels object allocated in the old gen space. |
| 6369 static RawPixels* NewCanonical(intptr_t value); |
| 6370 |
| 6371 // Returns a canonical Pixels object (allocated in the old gen space) or |
| 6372 // Pixels::null() if str points to a string that does not convert to a |
| 6373 // Pixels value. |
| 6374 static RawPixels* NewCanonical(const String& str); |
| 6375 |
| 6376 static intptr_t InstanceSize() { |
| 6377 return RoundedAllocationSize(sizeof(RawPixels)); |
| 6378 } |
| 6379 |
| 6380 static intptr_t value_offset() { |
| 6381 return OFFSET_OF(RawPixels, value_); |
| 6382 } |
| 6383 |
| 6384 private: |
| 6385 void set_value(intptr_t value) const; |
| 6386 |
| 6387 FINAL_HEAP_OBJECT_IMPLEMENTATION(Pixels, Number); |
| 6388 friend class Class; |
| 6389 friend class Number; |
| 6390 }; |
| 6391 |
| 6392 |
| 6393 // Class Double represents Dart class _Double in runtime/lib, which implements |
6348 // abstract class double in corelib. | 6394 // abstract class double in corelib. |
6349 class Double : public Number { | 6395 class Double : public Number { |
6350 public: | 6396 public: |
6351 double value() const { | 6397 double value() const { |
6352 return raw_ptr()->value_; | 6398 return raw_ptr()->value_; |
6353 } | 6399 } |
6354 | 6400 |
6355 bool BitwiseEqualsToDouble(double value) const; | 6401 bool BitwiseEqualsToDouble(double value) const; |
6356 virtual bool OperatorEquals(const Instance& other) const; | 6402 virtual bool OperatorEquals(const Instance& other) const; |
6357 virtual bool CanonicalizeEquals(const Instance& other) const; | 6403 virtual bool CanonicalizeEquals(const Instance& other) const; |
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8655 | 8701 |
8656 inline void TypeArguments::SetHash(intptr_t value) const { | 8702 inline void TypeArguments::SetHash(intptr_t value) const { |
8657 // This is only safe because we create a new Smi, which does not cause | 8703 // This is only safe because we create a new Smi, which does not cause |
8658 // heap allocation. | 8704 // heap allocation. |
8659 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8705 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
8660 } | 8706 } |
8661 | 8707 |
8662 } // namespace dart | 8708 } // namespace dart |
8663 | 8709 |
8664 #endif // VM_OBJECT_H_ | 8710 #endif // VM_OBJECT_H_ |
OLD | NEW |