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

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

Issue 11421064: Cleanups and added more checks for valid Integer allocation (must be Smi, Mint or Bigint for their … (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 | « runtime/lib/integers.cc ('k') | 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 3456 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); 3468 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew);
3469 3469
3470 virtual double AsDoubleValue() const; 3470 virtual double AsDoubleValue() const;
3471 virtual int64_t AsInt64Value() const; 3471 virtual int64_t AsInt64Value() const;
3472 3472
3473 // Returns 0, -1 or 1. 3473 // Returns 0, -1 or 1.
3474 virtual int CompareWith(const Integer& other) const; 3474 virtual int CompareWith(const Integer& other) const;
3475 3475
3476 // Return the most compact presentation of an integer. 3476 // Return the most compact presentation of an integer.
3477 RawInteger* AsInteger() const; 3477 RawInteger* AsValidInteger() const;
3478 // Return an integer in the form of a RawBigint. 3478 // Return an integer in the form of a RawBigint.
3479 RawBigint* AsBigint() const; 3479 RawBigint* AsBigint() const;
3480 3480
3481 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; 3481 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const;
3482 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; 3482 RawInteger* BitOp(Token::Kind operation, const Integer& other) const;
3483 3483
3484 OBJECT_IMPLEMENTATION(Integer, Number); 3484 OBJECT_IMPLEMENTATION(Integer, Number);
3485 friend class Class; 3485 friend class Class;
3486 }; 3486 };
3487 3487
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 3615 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
3616 3616
3617 static intptr_t InstanceSize() { return 0; } 3617 static intptr_t InstanceSize() { return 0; }
3618 3618
3619 static intptr_t InstanceSize(intptr_t len) { 3619 static intptr_t InstanceSize(intptr_t len) {
3620 ASSERT(0 <= len && len <= kMaxElements); 3620 ASSERT(0 <= len && len <= kMaxElements);
3621 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); 3621 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement));
3622 } 3622 }
3623 3623
3624 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew); 3624 static RawBigint* New(const String& str, Heap::Space space = Heap::kNew);
3625 static RawBigint* New(int64_t value, Heap::Space space = Heap::kNew);
3626 3625
3627 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const; 3626 RawBigint* ArithmeticOp(Token::Kind operation, const Bigint& other) const;
3628 3627
3629 private: 3628 private:
3630 Chunk GetChunkAt(intptr_t i) const { 3629 Chunk GetChunkAt(intptr_t i) const {
3631 return *ChunkAddr(i); 3630 return *ChunkAddr(i);
3632 } 3631 }
3633 3632
3634 void SetChunkAt(intptr_t i, Chunk newValue) const { 3633 void SetChunkAt(intptr_t i, Chunk newValue) const {
3635 *ChunkAddr(i) = newValue; 3634 *ChunkAddr(i) = newValue;
(...skipping 2339 matching lines...) Expand 10 before | Expand all | Expand 10 after
5975 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5974 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5976 return false; 5975 return false;
5977 } 5976 }
5978 } 5977 }
5979 return true; 5978 return true;
5980 } 5979 }
5981 5980
5982 } // namespace dart 5981 } // namespace dart
5983 5982
5984 #endif // VM_OBJECT_H_ 5983 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698