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

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

Issue 2983823002: Improve hashCode for closures (Closed)
Patch Set: Created 3 years, 5 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_RAW_OBJECT_H_ 5 #ifndef RUNTIME_VM_RAW_OBJECT_H_
6 #define RUNTIME_VM_RAW_OBJECT_H_ 6 #define RUNTIME_VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 RawObject** from() { 912 RawObject** from() {
913 return reinterpret_cast<RawObject**>(&ptr()->context_scope_); 913 return reinterpret_cast<RawObject**>(&ptr()->context_scope_);
914 } 914 }
915 RawContextScope* context_scope_; 915 RawContextScope* context_scope_;
916 RawFunction* parent_function_; // Enclosing function of this local function. 916 RawFunction* parent_function_; // Enclosing function of this local function.
917 RawType* signature_type_; 917 RawType* signature_type_;
918 RawInstance* closure_; // Closure object for static implicit closures. 918 RawInstance* closure_; // Closure object for static implicit closures.
919 RawObject** to_snapshot() { 919 RawObject** to_snapshot() {
920 return reinterpret_cast<RawObject**>(&ptr()->closure_); 920 return reinterpret_cast<RawObject**>(&ptr()->closure_);
921 } 921 }
922 RawObject* hash_; 922 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->closure_); }
923 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); }
924 923
925 friend class Function; 924 friend class Function;
926 }; 925 };
927 926
928 class RawSignatureData : public RawObject { 927 class RawSignatureData : public RawObject {
929 private: 928 private:
930 RAW_HEAP_OBJECT_IMPLEMENTATION(SignatureData); 929 RAW_HEAP_OBJECT_IMPLEMENTATION(SignatureData);
931 930
932 RawObject** from() { 931 RawObject** from() {
933 return reinterpret_cast<RawObject**>(&ptr()->parent_function_); 932 return reinterpret_cast<RawObject**>(&ptr()->parent_function_);
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 }; 1791 };
1793 1792
1794 class RawClosure : public RawInstance { 1793 class RawClosure : public RawInstance {
1795 private: 1794 private:
1796 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); 1795 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure);
1797 1796
1798 RawObject** from() { 1797 RawObject** from() {
1799 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); 1798 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_);
1800 } 1799 }
1801 1800
1802 // No instance fields should be declared before the following 4 fields whose 1801 // No instance fields should be declared before the following fields whose
1803 // offsets must be identical in Dart and C++. 1802 // offsets must be identical in Dart and C++.
1804 1803
1805 // These 4 fields are also declared in the Dart source of class _Closure. 1804 // The following fields are also declared in the Dart source of class
1805 // _Closure.
1806 RawTypeArguments* instantiator_type_arguments_; 1806 RawTypeArguments* instantiator_type_arguments_;
1807 RawTypeArguments* function_type_arguments_; 1807 RawTypeArguments* function_type_arguments_;
1808 RawFunction* function_; 1808 RawFunction* function_;
1809 RawContext* context_; 1809 RawContext* context_;
1810 RawInteger* cached_hash_code_;
rmacnak 2017/07/19 01:00:24 RawSmi* hash_; Compare other hash fields on Strin
alexmarkov 2017/07/19 17:54:19 Done.
1810 1811
1811 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->context_); } 1812 RawObject** to() {
1813 return reinterpret_cast<RawObject**>(&ptr()->cached_hash_code_);
1814 }
1812 1815
1813 // Note that instantiator_type_arguments_ and function_type_arguments_ are 1816 // Note that instantiator_type_arguments_ and function_type_arguments_ are
1814 // used to instantiate the signature of function_ when this closure is 1817 // used to instantiate the signature of function_ when this closure is
1815 // involved in a type test. In other words, these fields define the function 1818 // involved in a type test. In other words, these fields define the function
1816 // type of this closure instance, but they are not used when invoking it. 1819 // type of this closure instance, but they are not used when invoking it.
1817 // If this closure is generic, it can be invoked with function type arguments 1820 // If this closure is generic, it can be invoked with function type arguments
1818 // that will be processed in the prolog of the closure function_. For example, 1821 // that will be processed in the prolog of the closure function_. For example,
1819 // if the generic closure function_ has a generic parent function, the 1822 // if the generic closure function_ has a generic parent function, the
1820 // passed-in function type arguments get concatenated to the function type 1823 // passed-in function type arguments get concatenated to the function type
1821 // arguments of the parent that are found in the context_. 1824 // arguments of the parent that are found in the context_.
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2436 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2434 kTypedDataInt8ArrayViewCid + 15); 2437 kTypedDataInt8ArrayViewCid + 15);
2435 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2438 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2436 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2439 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2437 return (kNullCid - kTypedDataInt8ArrayCid); 2440 return (kNullCid - kTypedDataInt8ArrayCid);
2438 } 2441 }
2439 2442
2440 } // namespace dart 2443 } // namespace dart
2441 2444
2442 #endif // RUNTIME_VM_RAW_OBJECT_H_ 2445 #endif // RUNTIME_VM_RAW_OBJECT_H_
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698