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

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

Issue 2953753002: Revert "Inline instance object hash code into object header on 64 bit." (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « runtime/vm/method_recognizer.h ('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 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 #define MINT_OBJECT_IMPLEMENTATION(object, rettype, super) \ 238 #define MINT_OBJECT_IMPLEMENTATION(object, rettype, super) \
239 FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, rettype, super) 239 FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, rettype, super)
240 240
241 class Object { 241 class Object {
242 public: 242 public:
243 virtual ~Object() {} 243 virtual ~Object() {}
244 244
245 RawObject* raw() const { return raw_; } 245 RawObject* raw() const { return raw_; }
246 void operator=(RawObject* value) { initializeHandle(this, value); } 246 void operator=(RawObject* value) { initializeHandle(this, value); }
247 247
248 uint32_t CompareAndSwapTags(uint32_t old_tags, uint32_t new_tags) const { 248 uword CompareAndSwapTags(uword old_tags, uword new_tags) const {
249 return AtomicOperations::CompareAndSwapUint32(&raw()->ptr()->tags_, 249 return AtomicOperations::CompareAndSwapWord(&raw()->ptr()->tags_, old_tags,
250 old_tags, new_tags); 250 new_tags);
251 } 251 }
252 bool IsCanonical() const { return raw()->IsCanonical(); } 252 bool IsCanonical() const { return raw()->IsCanonical(); }
253 void SetCanonical() const { raw()->SetCanonical(); } 253 void SetCanonical() const { raw()->SetCanonical(); }
254 void ClearCanonical() const { raw()->ClearCanonical(); } 254 void ClearCanonical() const { raw()->ClearCanonical(); }
255 intptr_t GetClassId() const { 255 intptr_t GetClassId() const {
256 return !raw()->IsHeapObject() ? static_cast<intptr_t>(kSmiCid) 256 return !raw()->IsHeapObject() ? static_cast<intptr_t>(kSmiCid)
257 : raw()->GetClassId(); 257 : raw()->GetClassId();
258 } 258 }
259 inline RawClass* clazz() const; 259 inline RawClass* clazz() const;
260 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); } 260 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 427 }
428 // Value marking that we are transitioning from sentinel, e.g., computing 428 // Value marking that we are transitioning from sentinel, e.g., computing
429 // a field value. Used to detect circular initialization. 429 // a field value. Used to detect circular initialization.
430 static const Instance& transition_sentinel() { 430 static const Instance& transition_sentinel() {
431 ASSERT(transition_sentinel_ != NULL); 431 ASSERT(transition_sentinel_ != NULL);
432 return *transition_sentinel_; 432 return *transition_sentinel_;
433 } 433 }
434 434
435 #if defined(HASH_IN_OBJECT_HEADER) 435 #if defined(HASH_IN_OBJECT_HEADER)
436 static uint32_t GetCachedHash(const RawObject* obj) { 436 static uint32_t GetCachedHash(const RawObject* obj) {
437 return obj->ptr()->hash_; 437 uword tags = obj->ptr()->tags_;
438 return tags >> 32;
438 } 439 }
439 440
440 static void SetCachedHash(RawObject* obj, uint32_t hash) { 441 static void SetCachedHash(RawObject* obj, uintptr_t hash) {
441 obj->ptr()->hash_ = hash; 442 ASSERT(hash >> 32 == 0);
443 obj->ptr()->tags_ |= hash << 32;
442 } 444 }
443 #endif 445 #endif
444 446
445 // Compiler's constant propagation constants. 447 // Compiler's constant propagation constants.
446 static const Instance& unknown_constant() { 448 static const Instance& unknown_constant() {
447 ASSERT(unknown_constant_ != NULL); 449 ASSERT(unknown_constant_ != NULL);
448 return *unknown_constant_; 450 return *unknown_constant_;
449 } 451 }
450 static const Instance& non_constant() { 452 static const Instance& non_constant() {
451 ASSERT(non_constant_ != NULL); 453 ASSERT(non_constant_ != NULL);
(...skipping 6370 matching lines...) Expand 10 before | Expand all | Expand 10 after
6822 intptr_t Hash() const { 6824 intptr_t Hash() const {
6823 intptr_t result = GetCachedHash(raw()); 6825 intptr_t result = GetCachedHash(raw());
6824 if (result != 0) { 6826 if (result != 0) {
6825 return result; 6827 return result;
6826 } 6828 }
6827 result = String::Hash(*this, 0, this->Length()); 6829 result = String::Hash(*this, 0, this->Length());
6828 SetCachedHash(raw(), result); 6830 SetCachedHash(raw(), result);
6829 return result; 6831 return result;
6830 } 6832 }
6831 6833
6832 static intptr_t Hash(RawString* raw);
6833
6834 bool HasHash() const { 6834 bool HasHash() const {
6835 ASSERT(Smi::New(0) == NULL); 6835 ASSERT(Smi::New(0) == NULL);
6836 return GetCachedHash(raw()) != 0; 6836 return GetCachedHash(raw()) != 0;
6837 } 6837 }
6838 6838
6839 #if defined(HASH_IN_OBJECT_HEADER)
6840 static intptr_t hash_offset() { return kInt32Size; } // Wrong for big-endian?
6841 #else
6839 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } 6842 static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); }
6843 #endif
6840 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); 6844 static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len);
6841 static intptr_t Hash(const char* characters, intptr_t len); 6845 static intptr_t Hash(const char* characters, intptr_t len);
6842 static intptr_t Hash(const uint16_t* characters, intptr_t len); 6846 static intptr_t Hash(const uint16_t* characters, intptr_t len);
6843 static intptr_t Hash(const int32_t* characters, intptr_t len); 6847 static intptr_t Hash(const int32_t* characters, intptr_t len);
6844 static intptr_t HashRawSymbol(const RawString* symbol) { 6848 static intptr_t HashRawSymbol(const RawString* symbol) {
6845 ASSERT(symbol->IsCanonical()); 6849 ASSERT(symbol->IsCanonical());
6846 intptr_t result = GetCachedHash(symbol); 6850 intptr_t result = GetCachedHash(symbol);
6847 ASSERT(result != 0); 6851 ASSERT(result != 0);
6848 return result; 6852 return result;
6849 } 6853 }
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
9053 9057
9054 inline void TypeArguments::SetHash(intptr_t value) const { 9058 inline void TypeArguments::SetHash(intptr_t value) const {
9055 // This is only safe because we create a new Smi, which does not cause 9059 // This is only safe because we create a new Smi, which does not cause
9056 // heap allocation. 9060 // heap allocation.
9057 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 9061 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
9058 } 9062 }
9059 9063
9060 } // namespace dart 9064 } // namespace dart
9061 9065
9062 #endif // RUNTIME_VM_OBJECT_H_ 9066 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/method_recognizer.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698