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

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

Issue 11348259: Canonicalize all integer constants taht we create by parsing a string. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 3446 matching lines...) Expand 10 before | Expand all | Expand 10 after
3457 UNREACHABLE(); 3457 UNREACHABLE();
3458 return false; 3458 return false;
3459 } 3459 }
3460 OBJECT_IMPLEMENTATION(Number, Instance); 3460 OBJECT_IMPLEMENTATION(Number, Instance);
3461 friend class Class; 3461 friend class Class;
3462 }; 3462 };
3463 3463
3464 3464
3465 class Integer : public Number { 3465 class Integer : public Number {
3466 public: 3466 public:
3467 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); 3467 // Returns a canonical Integer object allocated in the old gen space.
3468 static RawInteger* NewCanonical(const String& str);
3469
3468 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); 3470 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew);
3469 3471
3470 virtual double AsDoubleValue() const; 3472 virtual double AsDoubleValue() const;
3471 virtual int64_t AsInt64Value() const; 3473 virtual int64_t AsInt64Value() const;
3472 3474
3473 // Returns 0, -1 or 1. 3475 // Returns 0, -1 or 1.
3474 virtual int CompareWith(const Integer& other) const; 3476 virtual int CompareWith(const Integer& other) const;
3475 3477
3476 // Return the most compact presentation of an integer. 3478 // Return the most compact presentation of an integer.
3477 RawInteger* AsValidInteger() const; 3479 RawInteger* AsValidInteger() const;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3614 static const intptr_t kBytesPerElement = kChunkSize; 3616 static const intptr_t kBytesPerElement = kChunkSize;
3615 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 3617 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
3616 3618
3617 static intptr_t InstanceSize() { return 0; } 3619 static intptr_t InstanceSize() { return 0; }
3618 3620
3619 static intptr_t InstanceSize(intptr_t len) { 3621 static intptr_t InstanceSize(intptr_t len) {
3620 ASSERT(0 <= len && len <= kMaxElements); 3622 ASSERT(0 <= len && len <= kMaxElements);
3621 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); 3623 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement));
3622 } 3624 }
3623 3625
3624 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew); 3626 // Returns a canonical Bigint object allocated in the old gen space.
3627 static RawBigint* NewCanonical(const String& str);
3625 3628
3626 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const; 3629 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const;
3627 3630
3628 private: 3631 private:
3629 Chunk GetChunkAt(intptr_t i) const { 3632 Chunk GetChunkAt(intptr_t i) const {
3630 return *ChunkAddr(i); 3633 return *ChunkAddr(i);
3631 } 3634 }
3632 3635
3633 void SetChunkAt(intptr_t i, Chunk newValue) const { 3636 void SetChunkAt(intptr_t i, Chunk newValue) const {
3634 *ChunkAddr(i) = newValue; 3637 *ChunkAddr(i) = newValue;
(...skipping 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5977 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5975 return false; 5978 return false;
5976 } 5979 }
5977 } 5980 }
5978 return true; 5981 return true;
5979 } 5982 }
5980 5983
5981 } // namespace dart 5984 } // namespace dart
5982 5985
5983 #endif // VM_OBJECT_H_ 5986 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698