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

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
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3447 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew);
3468
3469 // Returns a canonical Integer object allocated in the old gen space.
3470 static RawInteger* NewCanonical(const String& str);
3471
3468 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); 3472 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew);
3469 3473
3470 virtual double AsDoubleValue() const; 3474 virtual double AsDoubleValue() const;
3471 virtual int64_t AsInt64Value() const; 3475 virtual int64_t AsInt64Value() const;
3472 3476
3473 // Returns 0, -1 or 1. 3477 // Returns 0, -1 or 1.
3474 virtual int CompareWith(const Integer& other) const; 3478 virtual int CompareWith(const Integer& other) const;
3475 3479
3476 // Return the most compact presentation of an integer. 3480 // Return the most compact presentation of an integer.
3477 RawInteger* AsValidInteger() const; 3481 RawInteger* AsValidInteger() const;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
3616 3620
3617 static intptr_t InstanceSize() { return 0; } 3621 static intptr_t InstanceSize() { return 0; }
3618 3622
3619 static intptr_t InstanceSize(intptr_t len) { 3623 static intptr_t InstanceSize(intptr_t len) {
3620 ASSERT(0 <= len && len <= kMaxElements); 3624 ASSERT(0 <= len && len <= kMaxElements);
3621 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); 3625 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement));
3622 } 3626 }
3623 3627
3624 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew); 3628 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew);
3625 3629
3630 // Returns a canonical Bigint object allocated in the old gen space.
3631 static RawBigint* NewCanonical(const String& str);
3632
3626 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const; 3633 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const;
3627 3634
3628 private: 3635 private:
3629 Chunk GetChunkAt(intptr_t i) const { 3636 Chunk GetChunkAt(intptr_t i) const {
3630 return *ChunkAddr(i); 3637 return *ChunkAddr(i);
3631 } 3638 }
3632 3639
3633 void SetChunkAt(intptr_t i, Chunk newValue) const { 3640 void SetChunkAt(intptr_t i, Chunk newValue) const {
3634 *ChunkAddr(i) = newValue; 3641 *ChunkAddr(i) = newValue;
3635 } 3642 }
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5981 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5975 return false; 5982 return false;
5976 } 5983 }
5977 } 5984 }
5978 return true; 5985 return true;
5979 } 5986 }
5980 5987
5981 } // namespace dart 5988 } // namespace dart
5982 5989
5983 #endif // VM_OBJECT_H_ 5990 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698