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

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

Issue 2992013002: [vm] Change TypedData_getUint64 native method to silently cast values (Closed)
Patch Set: Created 3 years, 4 months 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
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 RUNTIME_VM_OBJECT_H_ 5 #ifndef RUNTIME_VM_OBJECT_H_
6 #define RUNTIME_VM_OBJECT_H_ 6 #define RUNTIME_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 6404 matching lines...) Expand 10 before | Expand all | Expand 10 after
6415 6415
6416 private: 6416 private:
6417 OBJECT_IMPLEMENTATION(Number, Instance); 6417 OBJECT_IMPLEMENTATION(Number, Instance);
6418 6418
6419 friend class Class; 6419 friend class Class;
6420 }; 6420 };
6421 6421
6422 class Integer : public Number { 6422 class Integer : public Number {
6423 public: 6423 public:
6424 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); 6424 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew);
6425
6426 // Creates a new Integer by given uint64_t value.
6427 // In the --limit-ints-to-64-bits mode silently casts value to int64_t
6428 // (with wrap-around if it is greater than kMaxInt64).
6425 static RawInteger* NewFromUint64(uint64_t value, 6429 static RawInteger* NewFromUint64(uint64_t value,
6426 Heap::Space space = Heap::kNew); 6430 Heap::Space space = Heap::kNew);
6427 6431
6428 // Returns a canonical Integer object allocated in the old gen space. 6432 // Returns a canonical Integer object allocated in the old gen space.
6429 // Returns null if integer is out of range (in --limit-ints-to-64-bits mode). 6433 // Returns null if integer is out of range (in --limit-ints-to-64-bits mode).
6430 static RawInteger* NewCanonical(const String& str); 6434 static RawInteger* NewCanonical(const String& str);
6431 6435
6432 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); 6436 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew);
6433 6437
6438 // Returns true iff the given uint64_t value is representable as Dart integer.
6439 static bool IsValidUint64(uint64_t value);
6440
6434 virtual bool OperatorEquals(const Instance& other) const { 6441 virtual bool OperatorEquals(const Instance& other) const {
6435 return Equals(other); 6442 return Equals(other);
6436 } 6443 }
6437 virtual bool CanonicalizeEquals(const Instance& other) const { 6444 virtual bool CanonicalizeEquals(const Instance& other) const {
6438 return Equals(other); 6445 return Equals(other);
6439 } 6446 }
6440 virtual uword ComputeCanonicalTableHash() const { 6447 virtual uword ComputeCanonicalTableHash() const {
6441 UNREACHABLE(); 6448 UNREACHABLE();
6442 return 0; 6449 return 0;
6443 } 6450 }
(...skipping 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after
8985 8992
8986 inline void TypeArguments::SetHash(intptr_t value) const { 8993 inline void TypeArguments::SetHash(intptr_t value) const {
8987 // This is only safe because we create a new Smi, which does not cause 8994 // This is only safe because we create a new Smi, which does not cause
8988 // heap allocation. 8995 // heap allocation.
8989 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8996 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8990 } 8997 }
8991 8998
8992 } // namespace dart 8999 } // namespace dart
8993 9000
8994 #endif // RUNTIME_VM_OBJECT_H_ 9001 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698